Re: Getting a class name

2007-02-19 Thread Gabriel Genellina
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): >> >> >>> >

Re: Getting a class name

2007-02-19 Thread Fuzzyman
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

Re: Getting a class name

2007-02-18 Thread Gabriel Genellina
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

Re: Getting a class name

2007-02-18 Thread Fuzzyman
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

Re: Getting a class name

2007-02-18 Thread Bruno Desthuilliers
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

Re: Getting a class name

2007-02-18 Thread Gabriel Genellina
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

Re: Getting a class name

2007-02-18 Thread goodwolf
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

Re: Getting a class name

2007-02-18 Thread Fuzzyman
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

Re: Getting a class name

2007-02-18 Thread Michele Simionato
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

Re: Getting a class name

2007-02-18 Thread Daniel Klein
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__ >

Re: Getting a class name

2007-02-18 Thread Fuzzyman
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

Re: Getting a class name

2007-02-18 Thread Gabriel Genellina
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

Re: Getting a class name

2007-02-17 Thread goodwolf
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

Re: Getting a class name

2007-02-17 Thread deelan
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 --

Getting a class name

2007-02-17 Thread Harlin Seritt
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

Re: Getting a class name from within main

2007-02-08 Thread Chris Lambacher
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__

Re: Getting a class name from within main

2007-02-07 Thread Marc 'BlackJack' Rintsch
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

Re: Getting a class name from within main

2007-02-07 Thread Robin Becker
[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

Getting a class name from within main

2007-02-07 Thread bg_ie
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