Use __dict__.update to update an object's fields.
This commit is contained in:
@@ -448,8 +448,7 @@ class ConsoleApp( Frame ):
|
|||||||
|
|
||||||
def assign( obj, **kwargs ):
|
def assign( obj, **kwargs ):
|
||||||
"Set a bunch of fields in an object."
|
"Set a bunch of fields in an object."
|
||||||
for name, value in kwargs.items():
|
obj.__dict__.update( kwargs )
|
||||||
setattr( obj, name, value )
|
|
||||||
|
|
||||||
class Object( object ):
|
class Object( object ):
|
||||||
"Generic object you can stuff junk into."
|
"Generic object you can stuff junk into."
|
||||||
|
|||||||
Reference in New Issue
Block a user