python improvements (Was: Re: New Language)
emile at fenx.com
emile at fenx.com
Tue May 16 07:48:18 EDT 2000
It looks like you can sneak your way into a class:
class Pass:
None
class Test:
def __init__(self, a,b,c,d,e):
self.f = f(a,b,c,d,e)
def func(self, a):
print "This is a class function (call ref: %s)" % a
a = Pass()
a.__class__ = Test
a.func('class')
If-the-class-method-works-without-an-instance-ly y'rs
Emile van Sebille
emile at fenx.com
Bernhard Herzog <herzog at online.de> wrote in message
news:<m3ln1bqw4q.fsf at greebo.nodomain.de>...
<snip>
> In that situation, real class methods would have been useful and cleaner
> than any other solution. In the end, I fell back to normal class
> attributes that are computed at class definition time because it works
> well enough for the time being.
>
>
> [1] e.g. sys.modules[classobj.__module__] to get the module or
> classobj.method.im_func.func_globals to get the globals dict
>
> --
> Bernhard Herzog | Sketch, a drawing program for Unix
> herzog at online.de | http://sketch.sourceforge.net/
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list