staticmethod() problems

Erik Max Francis max at alcyone.com
Thu Jan 23 03:26:45 CET 2003


Aum wrote:

> I'm trying to find a way for a static method in a class to determine
> if it
> was called from the class, or from an instance.
	...
> Is there any way to do this without having to define 2 separate
> methods?

The very purpose of staticmethod is to create a method that can be
invoked from an instance or a class and won't know the difference, or
care.  In some sense, what you're trying to do is at odds with the
purpose of classmethod in the first place.

Maybe if you back up one step and tell us why you need to know this we
could suggest a better solution.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ We're looking for a custom fit in an off-the-rack world.
\__/ Capt. Benjamin "Hawkeye" Pierce
    PyUID / http://www.alcyone.com/pyos/uid/
 A module for generating "unique" IDs in Python.




More information about the Python-list mailing list