assign class variable in __init__
Hi Everyone, Just a quick question - Is it possible to assign class variables in the __init__() - i.e. somthing like: def __init__(self,self.source = "test", self.length = 1) rather than def __init__(self,source = "test", length = 1): -- Ross Williamson University of Chicago Department of Astronomy & Astrophysics 773-834-9785 (office) 312-504-3051 (Cell) -- http://mail.python.org/mailman/listinfo/python-list
Overload print
Hi All Is there anyway in a class to overload the print function? >> class foo_class(): >> pass >> cc = foo_class() >> print cc Gives: <__main__.foo_class instance at > Can I do something like: >> class foo_class(): >> def __print__(self): >> print "hello" >> cc = foo_class() >> print cc Gives: hello I'm looking at finding nice way to print variables in a class just by asking to print it Cheers Ross -- Ross Williamson University of Chicago Department of Astronomy & Astrophysics 773-834-9785 (office) 312-504-3051 (Cell) -- http://mail.python.org/mailman/listinfo/python-list