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 (object):
name = getCodeName()
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):
return
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
class MyClass
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): pass
...
f = Foo()
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__
Get the class first,
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 descriptor
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 class for
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 getCodeName(deap=0):
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
definition
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 wont get class name into its
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, goodwolf [EMAIL
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 MyClass.__name__?
I were asking,
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
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
--
d.
--
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() + '!'
--
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__':
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 any
[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 scope as seen
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 there any way
I have the following test code setup, trying to get the class name of a
subclass in the super class. (Reason why i want this is described below)
file class_name_start.py
import class_name as cn
obj = cn.B()
obj.printclass()
file class_name.py
flupke [EMAIL PROTECTED] wrote:
I have the following test code setup, trying to get the class name of a
subclass in the super class. (Reason why i want this is described below)
file class_name_start.py
import class_name as cn
obj = cn.B()
obj.printclass()
George Sakkis wrote:
snip
Make printclass a class method:
class A(object):
def __init__(self):
print I'm A
# for python 2.4
@classmethod
def printclass(cls):
print Module, cls.__module__
print Class, cls.__name__
# for 2.3 or older
On Wed, 20 Jul 2005 14:06:57 GMT,
flupke [EMAIL PROTECTED] wrote:
file class_name.py
class A(object):
def __init__(self):
print I'm A
def printclass(self):
print Name ,__name__
print Class ,A.__name__
Why A.__name__ and not
23 matches
Mail list logo