En Mon, 19 Feb 2007 17:25:56 -0300, Fuzzyman <[EMAIL PROTECTED]> escribió:
> On Feb 19, 5:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>> En Sun, 18 Feb 2007 20:56:48 -0300, Fuzzyman <[EMAIL PROTECTED]>
>> escribió:
>> > [somebody] wrote:
>> >> >>> > def getCodeName(deap=0):
>> >> >>> >
On Feb 19, 5:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Sun, 18 Feb 2007 20:56:48 -0300, Fuzzyman <[EMAIL PROTECTED]> escribió:
>
>
>
> > [somebody] wrote:
> >> >>> > def getCodeName(deap=0):
> >> >>> > return sys._getframe(deap+1).f_code.co_name
>
> >> >>> > class MyClass (obje
En Sun, 18 Feb 2007 20:56:48 -0300, Fuzzyman <[EMAIL PROTECTED]> escribió:
> [somebody] wrote:
>> >>> > def getCodeName(deap=0):
>> >>> > return sys._getframe(deap+1).f_code.co_name
>>
>> >>> > class MyClass (object):
>> >>> > name = getCodeName() + '!'
>>
>> >>> What's the advantage over
On Feb 18, 11:54 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Gabriel Genellina a écrit :
>
> > En Sun, 18 Feb 2007 14:14:41 -0300, goodwolf <[EMAIL PROTECTED]>
> > escribió:
>
> >> On Feb 18, 9:17 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> >>> En Sun, 18 Feb 2007 04:20:33 -0300
Gabriel Genellina a écrit :
> En Sun, 18 Feb 2007 14:14:41 -0300, goodwolf <[EMAIL PROTECTED]>
> escribió:
>
>> On Feb 18, 9:17 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>>
>>> En Sun, 18 Feb 2007 04:20:33 -0300, goodwolf <[EMAIL PROTECTED]>
>>> escribió:
>>>
>>> > I suppose that you wo
En Sun, 18 Feb 2007 14:14:41 -0300, goodwolf <[EMAIL PROTECTED]>
escribió:
> On Feb 18, 9:17 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>> En Sun, 18 Feb 2007 04:20:33 -0300, goodwolf <[EMAIL PROTECTED]>
>> escribió:
>>
>> > I suppose that you wont get class name into its code (or before
On Feb 18, 9:17 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Sun, 18 Feb 2007 04:20:33 -0300, goodwolf <[EMAIL PROTECTED]>
> escribió:
>
> > I suppose that you wont get class name into its code (or before
> > definition end) but not into a method definition.
>
> > import sys
>
> > def ge
On Feb 18, 1:22 pm, "Michele Simionato" <[EMAIL PROTECTED]>
wrote:
> On Feb 18, 1:24 pm, "Fuzzyman" <[EMAIL PROTECTED]> wrote:
>
> > Why is the __name__ attribute not available to the instance? Why don't
> > normal lookup rules apply (meaning that a magic attribute will be
> > looked up on the clas
On Feb 18, 1:24 pm, "Fuzzyman" <[EMAIL PROTECTED]> wrote:
> Why is the __name__ attribute not available to the instance? Why don't
> normal lookup rules apply (meaning that a magic attribute will be
> looked up on the class for instances) ?
Because __name__ isn't really an attribute, it is a descr
On 18 Feb 2007 04:24:47 -0800, "Fuzzyman" <[EMAIL PROTECTED]> wrote:
>On Feb 17, 8:33 pm, deelan <[EMAIL PROTECTED]> wrote:
>> Harlin Seritt wrote:
>> > Hi,
>>
>> > How does one get the name of a class from within the class code? I
>> > tried something like this as a guess:
>>
>> > self.__name__
>
On Feb 17, 8:33 pm, deelan <[EMAIL PROTECTED]> wrote:
> Harlin Seritt wrote:
> > Hi,
>
> > How does one get the name of a class from within the class code? I
> > tried something like this as a guess:
>
> > self.__name__
>
> Get the class first, then inspect its name:
>
> >>> class Foo(object): pas
En Sun, 18 Feb 2007 04:20:33 -0300, goodwolf <[EMAIL PROTECTED]>
escribió:
> I suppose that you wont get class name into its code (or before
> definition end) but not into a method definition.
>
>
> import sys
>
> def getCodeName(deap=0):
> return sys._getframe(deap+1).f_code.co_name
>
>
> c
I suppose that you wont get class name into its code (or before
definition end) but not into a method definition.
import sys
def getCodeName(deap=0):
return sys._getframe(deap+1).f_code.co_name
class MyClass (object):
name = getCodeName() + '!'
--
http://mail.python.org/mailman/list
Harlin Seritt wrote:
> Hi,
>
> How does one get the name of a class from within the class code? I
> tried something like this as a guess:
>
> self.__name__
Get the class first, then inspect its name:
>>> class Foo(object): pass
...
>>> f = Foo()
>>> f.__class__.__name__
'Foo'
>>>
HTH
--
Hi,
How does one get the name of a class from within the class code? I
tried something like this as a guess:
self.__name__
Obviously it didn't work.
Anyone know how to do that?
Thanks,
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Feb 07, 2007 at 01:02:39AM -0800, [EMAIL PROTECTED] wrote:
> Hi,
>
> Lets say I have the following class -
>
> class MyClass:
> def __init__(self):
> print (__name__.split("."))[-1]
I would spell this:
print self.__class__.__name__
>
> if __name__ == '__main__
In <[EMAIL PROTECTED]>, bg_ie wrote:
> class MyClass:
> def __init__(self):
> print (__name__.split("."))[-1]
>
> if __name__ == '__main__':
> MyClassName = "MyClass"
>
> I can print the name of the class from within the class scope as seen
> above in the init, but is t
[EMAIL PROTECTED] wrote:
> Hi,
>
> Lets say I have the following class -
>
> class MyClass:
> def __init__(self):
> print (__name__.split("."))[-1]
>
> if __name__ == '__main__':
> MyClassName = "MyClass"
>
> I can print the name of the class from within the class scop
Hi,
Lets say I have the following class -
class MyClass:
def __init__(self):
print (__name__.split("."))[-1]
if __name__ == '__main__':
MyClassName = "MyClass"
I can print the name of the class from within the class scope as seen
above in the init, but is there a
19 matches
Mail list logo