Hello,
Can not dump class object created on runtime.
Is there anybody can help me? Thank.
Following is testing code:
import pickle
from new import classobj
class A:
def __str__(self):
return self.__class__.name
if __name__ == "__main__":
c = classobj('B', (A, ), {}) # crea
>>> import re
>>>
>>> if __name__ == "__main__":
... lst = [281, 713, 832, 1281, 1713, 1832, 2281, 2713, 2832]
... for item in lst:
... if re.match("^1?(?=281)|^1?(?=713)|^1?(?=832)", str(item)):
... print "%d invalid" % item
... else:
... print "%d v
The operator is and is not test for object identity: x is y is true if and
only if x and y are the same objects.
>>> x = 1
>>> y = 1
>>> x is y
True
Is this right? Why? Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks. Please refer to following snipt:
1 >>> class Printable(type):
2 ... def __str__(cls):
3 ... return "This is class %s" % cls.__name__
4 ...
5 >>> class C(object):
6 ... __metaclass__ = Printable
7 ...
8 >>>
9 >>> C.__str__
10
11 >>>
12 >>> print C
13 This is class C
I see,