Objects in Python
Mark Lawrence
breamoreboy at yahoo.co.uk
Wed Aug 22 16:46:29 EDT 2012
On 22/08/2012 21:31, MRAB wrote:
> On 22/08/2012 20:45, lipska the kat wrote:
>>
>> compare this to a function declaration in Python
>>
>> def foo(self):
>>
> [snip]
> That's not actually a declaration but a definition. :-)
>
> The function's body is bound to the name at runtime, so:
>
> def double_it(x):
> return x * 2
>
> is not far from:
>
> double_it = lambda x: x * 2
>
> The only declarations are "global" and "nonlocal" (and the latter
> exists only in recent versions of Python).
Looking at the self I'm assuming that's a method and not a function.
--
Cheers.
Mark Lawrence.
More information about the Python-list
mailing list