What does "first class" mean?

Christian Tismer tismer at tismer.com
Fri Apr 28 16:32:23 EDT 2000


Tom Loredo wrote:
> 
> Hi folks-
> 
> I've often seen reference here (and on the Ruby page) to Python's
> treatment of functions and methods as "first class objects."

My understanding:
It means that they are first class citizens, there is no
difference to any other object type. They are allowed in
the same context as other objects of other types.

Example:   you can write

  print f

and Python will try to print this object, regardless
whether it is an int, a string, a function, a traceback, a class,...

Notabene the entry "a function":
f is not called, since it is a first class object.
In order to call f, you need the call syntax, and Python will
try to call the object, if there is a way to do so.

VB for example would always try to call f, with or without
parentheses.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com




More information about the Python-list mailing list