[Tutor] dynamic attribute assignment

John washakie at gmail.com
Fri Sep 7 07:31:27 CEST 2007


I've just noticed that you can use the import statement to import variables,
such that a simple file such as vars.py:

# File with predefined variables
var1= 'some text'
var2= 2
var3=['a','b','c']

Would then, upon import, provide:

>>>vars.var1
'some text'
>>>vars.var2
2
>>>vars.var3
['a','b','c']

This is great, I had no idea! However, is there then a way to reassign or
update the values? For instance, can you say:

>>>vars.var1='some new text'

??

Just curious!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070906/1bd8e816/attachment.htm 


More information about the Tutor mailing list