Re: Chapter 9 Tutorial for Classes Not Working



tac-tics wrote:
x = MyClass
xf = x.f
while True:
print xf()

Python has some VERY nasty gotchas concerning parenthesis (or lack
there of).

Is this really a gotcha? I don't think you should blame Python for this mistake. Even a novice programmer like myself can intuitively understand that parentheses are needed.

And while this *is* something unique to Python (or maybe unique to dynamic languages in general?), the actual usage of parentheses is consistent with other programming languages, so Python or not, it should just make sense to write x = MyClass() instead of x = MyClass
.



Relevant Pages

  • Re: Chinese Syntax
    ... the parentheses can be omitted when such omission will not lead to ambiguity. ... > One of the biggest flaws in C syntax, in my opinion, is the required> parentheses for test conditions. ... > Python uses such a construct for test conditions. ...
    (comp.lang.c)
  • Re: Chinese Syntax
    ... the parentheses can be omitted when such omission will not lead to ambiguity. ... > One of the biggest flaws in C syntax, in my opinion, is the required> parentheses for test conditions. ... > Python uses such a construct for test conditions. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Python and Flaming Thunder
    ... addition or the failed comparison? ... but statements are not just expressions. ... Putting a statement into parentheses ... Python is trying to get out of. ...
    (comp.lang.python)
  • Re: Would Anonymous Functions Help in Learning Programming/Python?
    ... a name is not the object it self, like a variable is in other languages. ... I could discuss name binding but it would be great if Python said this ... within the parentheses, but parentheses are already explicitly designed ... to let you ignore the whitespace rules. ...
    (comp.lang.python)
  • Re: Chinese Syntax
    ... Curly braces, parentheses, keywords, or something ... One of the biggest flaws in C syntax, in my opinion, is the required ... Python uses such a construct for test conditions. ... This makes code much clearer than the equivalent ...
    (microsoft.public.dotnet.languages.csharp)