![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Expert Programmer
|
Dynamically set variables?
Say I import another Python script into the Python script I'm working on. I want to be able to set variables in that file, OR in the file I'm working in, by passing a single variable. For example:
import thing
def set_variable(cls):
cls.new_variable = "cheese"
set_variable(thing)
set_variable(self) # This doesn't work!
print thing.new_variable
print new_variable # I want both of these to print "cheese"! |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| When to use the new keyword in C++? | titaniumdecoy | C++ | 28 | Mar 16th, 2006 1:36 PM |
| [Efficiency] Variables vs. Calculations | kurt | C | 7 | Dec 29th, 2005 3:39 PM |
| Dynamic memory - variables | darkone916 | C++ | 4 | Dec 7th, 2005 7:24 AM |
| Variables | coldDeath | Python | 4 | Aug 9th, 2005 12:35 PM |
| global variables | uman | C++ | 2 | Feb 20th, 2005 11:39 PM |