3 ms·
> I saw her getting confused with `foo()` vs `foo.bar()` vs `foo.bar` I had the same problem when learning Python. Top that up with mutable and non-mutable str
by wodenokoto 4y ago
> I saw her getting confused with `foo()` vs `foo.bar()` vs `foo.bar`
I had the same problem when learning Python. Top that up with mutable and non-mutable structures and it can get very hard to make sense of Python as a beginner.
I remember I had a theory that foo.bar() would change foo and bar(foo) would return a value while leaving foo unchanged ... that turned out to be very wrong.
It also took me forever to realize that when you call foo.bar(), foo is the first argument of bar().
- srcreigh 4y agoWell, sometimes, other times foo is a module and foo.bar() calls a function bar with no arguments.