Jan Eden wrote on 07.08.2005:
>But the assignment in the for loop obviously does not work with
>instance attributes. I will have to read up some more about instance
>attributes.
Ok... so this works:
class NewClass:
def __init__(self, **parameters):
self.data = {}
for i in parameters.keys(): self.data[i] = parameters[i]
self = NewClass(arg1='Value', arg2='Another value', arg3='Yet another value')
print self.data
It seems that I need to add a dictionary as a data attribute to my instance
object to do what I wanted to.
This is unfortunate, because it complicates my syntax: Instead of self.type, I
need to use self.data['type'].
- Jan
--
I'd never join any club that would have the likes of me as a member. - Groucho
Marx
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor