Back on topic [was [OT] Syntax highlighting]

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Sep 20 03:58:09 EDT 2010


On Mon, 20 Sep 2010 07:02:23 +0000, Seebs wrote:

> I'm
> very new to Python, so I'm not 100% sure functions are a kind of an
> object, but I seem to recall they were.

Yes, functions are objects. *Everything* in Python is an object (apart 
from statements, but they're not actually *things* in Python).


>>> def f():
...     return f.x
...
>>> f.x = 2
>>> f()
2
>>> f.x = -1
>>> f()
-1


For some interesting glimpse at how Python works, create a function f and 
then look at dir(f).


-- 
Steven



More information about the Python-list mailing list