![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
return dict(vars()) |
|
|
|
|
|
|
#12 |
|
Programmer
|
*args is more like va_list with friends.
|
|
|
|
|
|
#13 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,784
Rep Power: 5
![]() |
So, would that mean that returning vars() (without copying it first), would be handing off variables that refer to memory locations inside that scope? The scope that no longer exists because the function has ended? Or do the variables still exist in memory after the function has ended? I'll play with this a bit.
You also didn't really answer my question. I know what's happening, what I don't know is if it has any impact on Python. If vars is actually an essential part of Python, or some sort of representation therein.Dawei, I've sent you a PM. |
|
|
|
|
|
#14 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
In a sense, you're persisting the scope of a function after the function has ended. Hmm. Interesting to think what you could do with that. |
|
|
|
|
|
|
#15 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,784
Rep Power: 5
![]() |
Wow, when you step back and it look at it for a second, it's really working on so many dependancy levels. It boggles my mind at least, not saying much however. :p
By the way, I'm not sure if you saw my post edit? It wasn't included in your quote. I'll assume you hadn't seen it. ![]() |
|
|
|
|
|
#16 | ||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
Quote:
|
||
|
|
|
|
|
#17 | |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,784
Rep Power: 5
![]() |
I was referring to my earlier question.
Quote:
It seems strange that I can delete "vars" and still be able to declare variables and use them. |
|
|
|
|
|
|
#18 | |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 730
Rep Power: 4
![]() |
Quote:
Since you aren't supposed to modify it, that leaves the actual implementation with the option to return a proxy/reference to the internal symbol table rather than a copy. Certainly good for efficiency. The point is, it doesn't matter how much "control" you are given as a result of implementation...the behavior is ultimately undefined, so a little hack that happens to work today might not work a few releases from now.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
|
#19 |
|
Programmer
|
vars() is just a copy of the local variables as changes do nothing. globals() gives you an object who's changes are propagated into the global namespace, but the deletition of a globals() output is completely harmless since python retains a copy and thus only a reference is deleted.
EDIT: ok, I guess my first sentence was wrong. EDIT2: it looks like python2.3.5 gives you a copy when calling vars, except in the global namespace, where vars acts like globals. |
|
|
|
![]() |
| 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 |
| Dynamically set variables? | titaniumdecoy | Python | 1 | Jul 11th, 2006 7:09 PM |
| When to use the new keyword in C++? | titaniumdecoy | C++ | 28 | Mar 16th, 2006 12:36 PM |
| Variables | coldDeath | Python | 4 | Aug 9th, 2005 11:35 AM |
| Assignment of numbers to variables without asking | Haz | C# | 26 | May 23rd, 2005 10:30 AM |
| global variables | uman | C++ | 2 | Feb 20th, 2005 10:39 PM |