strict python?

Suchandra Thapa ssthapa at classes.cs.uchicago.edu
Sat Dec 8 09:47:58 CET 2001


Brian Sturk <bsturk at news.rcn.com> wrote:
>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.

    I would really object to that.  I use expressions
like self.func to refer to functions and to create function
lookups all the time.  E.g. returning self.func so that 
the it can be used later as a callback or some other function.
It's also pretty handy to have a dictionary that associates 
functions with xml elements for classes that extend the SAX 
ContentHandler class.  



-- 
----------------------------------------------------------------------------
	   		              |
Suchandra Thapa                       | "There are only two kinds of math . 
s-thapa-11 at NOSPAMalumni.uchicago.edu  | books. Those you cannot read beyond 
			              | the first sentence, and those you 
			              | can not read beyond the first page."
			              |                     -C.N. Yang
----------------------------------------------------------------------------



More information about the Python-list mailing list