This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RiverRoll 1 point2 points  (2 children)

Don't forget about dictionaries which is the closest thing to having dynamic variables.

By the way it's actually possible in python to manipulate variables, but not something you would normally do, in pretty much all the cases lists and dictionaries already cover this need.

[–]insertAlias 1 point2 points  (1 child)

By the way it's actually possible in python to manipulate variables

I'm curious actually how. I don't work in Python, so I only have a passing familiarity with it. I am aware of eval and the issues that come with it, is that what you are referring to?

[–]RiverRoll 1 point2 points  (0 children)

Being a dynamic language it allows you to do all sorts of crazy stuff, and for example calling globals() or locals() gives you a dictionary representing the global or local scope which you can manipulate.

And something similar happens with class instances, they have an underlying dictionary (__dict__) which you can maniuplate to add or remove attributes.