programming container object

Hrvoje Niksic hniksic at xemacs.org
Mon Dec 17 05:34:49 EST 2007


"Diez B. Roggisch" <deets at nospam.web.de> writes:

>> In any case, it is not possible, because the instance method cannot
>> know whether its result is being assigned to a name or just thrown
>> away.
>
> This isn't entirely correct - there _are_ ways to know.
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742

Not by using the public API, though.  The above recipe relies on a
number of CPython's implementation details, and will stop working if
any of this changes.  (I'm sure you're aware of that, but it might not
be obvious to some readers.)

It also doesn't work when the function is called from C code, or when
the unpacking is done in a separate step.



More information about the Python-list mailing list