strict python?

Hans Nowak wurmy at
Fri Dec 7 07:34:20 CET 2001

Brian Sturk wrote:
> Can python be more strict about declarations?  I didn't see a flag to
> the interpreter, and haven't seen anything yet in my book or on
>  I ask because I got burned by something
> like this:
> def func ( self ):
>      print hello
> def call_func( self ):
>      self.func      <--- no parentheses
> my script that had code like this ran fine, but
> didn't call the function.  I would have thought that
> this would have been an error since there was no
> assignment of any kind.
> It took me a little for me to figure it out in my real
> script.  It'd be nice to have this stuff pointed out
> while parsing it.  Is it possible?

Well, 'self.func' is a perfectly valid Python expression,
just like '3'. Not very useful when used like this, but
still, perfectly valid.

The Python parser doesn't flag this as an error, for this
reason, and doesn't give any warnings either, but I believe 
PyChecker does. See

for more info.


More information about the Python-list mailing list