RE: Class, object question.

2005-04-05 Thread Ian Sparks
Use the *args positional-argument to catch all the positional arguments in the constructor then test them to see what you have and call a kind of sub-init based on that : class Point:     def __init__(self,x,y,z):    self.x = x    self.y = y    self.z = z   class Vector:    de

Unicode question : turn "José" into u"José"

2006-04-05 Thread Ian Sparks
This is probably stupid and/or misguided but supposing I'm passed a byte-string value that I want to be unicode, this is what I do. I'm sure I'm missing something very important. Short version : >>> s = "José" #Start with non-unicode string >>> unicoded = eval("u'%s'" % "José") Long version :