Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
How does 'other' instance know it will be treated as float?
In the magic method add(self, other), it returns float(self) + other (and int(self) + other ). How does 'other' instance know it is float? Don't we have to have float(self) + float(other)? I guess it automatically matches to the return type of self, but I know fully understand the mechanics of it.
Variables in Python follow the standard nomenclature of an alphanumeric name beginning in a letter or underscore. Variable names are case sensitive. Variables do not need to be declared and their datatypes are inferred from the assignment statement. So, Python use an aggressive type of inference. This means that python does not knows the type of variable until it runs the program, that's when it knows whether its int or float or string.