"The problem is you seem to be thinking in terms of objects having names.<br>They don't.  Names have objects."<div>I agree this is my problem. This is not correct terminology then?</div><div>The name of the object is anobject<br>
</div><div><br></div><div>Let me give another example and let me know if I am just beating a dead horse.</div><div><br></div><div>In my current script I have may print statements to verify I am manipulating my list as I hope. </div>
<div>I have many lines like;</div><div><br></div><div>print 'alist', alist</div><div><br></div><div>I need to print the names so I know what I am looking at on the output.</div><div>It would be nice if I could define fuction that did this</div>
<div>def lp(thelist):</div><div>    "magic occurs"</div><div><br></div><div>Then I could just type</div><div><br></div><div>lp(alist) </div><div><br></div><div>note I am entering the name which has an object that is a list. I am not entering [1,3,5,7]</div>
<div>and it would </div><div><br></div><div>print 'alist' alist</div><div><br></div><div>Does it not seem reasonable to what to do this.</div><div><br></div><div><br clear="all">Vincent Davis<br>720-301-3003<br>
<br><br><div class="gmail_quote">On Wed, Feb 4, 2009 at 7:55 PM, Rhodri James <span dir="ltr"><<a href="mailto:rhodri@wildebst.demon.co.uk">rhodri@wildebst.demon.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">On Thu, 05 Feb 2009 01:36:17 -0000, Vincent Davis <<a href="mailto:vincent@vincentdavis.net" target="_blank">vincent@vincentdavis.net</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
if I start with<br>
M = [1,3,5,7]<br>
M is [1,3,5,7]<br>
This seems one way, as [1,3,5,7] is not M in the sense that there is<br>
no operation I can preform on [1,3,5,7] and get M back. Other than<br>
asking/testing M==[1,3,5,7]<br>
</blockquote>
<br></div>
Correct.  If you actually try that, you get this:<br>
<br>
Python 2.5.2 (r252:60911, May  7 2008, 15:21:12)<br>
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

M = [1,3,5,7]<br>
M is [1,3,5,7]<br>
</blockquote></blockquote></blockquote></div>
False<br>
<br>
This isn't just me being funny with your suggested syntax, it's<br>
making an important point: the second [1,3,5,7] is an entirely<br>
different object to the list we named M, it just happens to<br>
contain the same data.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This seems fine to me. but when I savedata(M) it seems I should be<br>
able to refer to both [1,3,5,7] and "M", "I mean I did just type it<br>
why type it again)<br>
My argument comes down to; we use M so we don't have to type<br>
[1,3,5,7], I realize that this is in part because we might not no what<br>
M will be.<br>
</blockquote>
<br></div>
That's an oversimplification, and you're battering away well past the<br>
point where it works.  In any language, not just Python.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is starting to sound like double talk on my part, I have only<br>
been programing in python for 2 weeks so my credibility is only that<br>
of an outside that MAY have a reasonable way of thinking of this or at<br>
least a feature I would like.<br>
</blockquote>
<br></div>
The problem is you seem to be thinking in terms of objects having names.<br>
They don't.  Names have objects.<br>
<br>
What I mean by that is that when you type "M = [1,3,5,7]", you are saying<br>
"when I say 'M', substitute in this list (not just one that looks like it,<br>
this exact list".  When you type "N = M", similarly you get the name N<br>
bound to the same exact list; if you then type "N[1] = 2" and print out<br>
M, it'll show up as [1,2,5,7] -- it's still the same list under both names.<br>
In effect (to oversimplify more than a bit), Python looks up the name<br>
in a dictionary to get the object it represents.<br>
<br>
The reverse lookup doesn't exist, largely because it isn't unique.  Our<br>
[1,3,5,7] list has no idea what names, if any, refer to it, and in all<br>
but the most trivial cases the information isn't really meaningful.<br>
Suppose that we did have a "getvariablename" function, what would you<br>
expect the following code to do?<br>
<br>
def f(thing):<br>
    print getvariablename(thing)<br>
<br>
m = [1,3,5,7]<br>
for n in m:<br>
    f(n)<br>
<br>
<br>
Should it say "n" for all of them?  Or "['n', 'thing']", since 'thing'<br>
is after all a perfectly valid name for it?<br>
<br>
Then what about this:<br>
<br>
for i in range(len(m)):<br>
    f(m[i])<br>
<br>
<br>
Should it say "m[i]" for all of them, or "m[0]" "m[1]" and so on, or<br>
what?<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
by the way what is "**kwargs" I can't find any documentation on this?<br>
</blockquote>
<br>
</div><a href="http://docs.python.org/tutorial/controlflow.html#keyword-arguments" target="_blank">http://docs.python.org/tutorial/controlflow.html#keyword-arguments</a><br>
<br>
In a function definition, "**name" mops up all the keyword arguments<br>
to the function that aren't explicit formal parameters into a<br>
dictionary called "name", indexed by keyword.  "kwargs" seems to be<br>
the traditional name to use.  So:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

def demo(action, **kwargs):<br>
</blockquote></blockquote></blockquote>
...   print kwargs<br>
...<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

demo(action="dummy", text="wombats are go")<br>
</blockquote></blockquote></blockquote>
{'text': 'wombats are go'}<br>
<br>
<br>
You can also use it the other way round to expand a dictionary into<br>
keyword parameters to a function call:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

myargs = { 'action': 'avoid', 'where': 'Camelot', 'because': 'it is a silly place' }<br>
demo(**myargs)<br>
</blockquote></blockquote></blockquote>
{'because': 'it is a silly place', 'where': 'Camelot'}<br><font color="#888888">
<br>
-- <br></font><div><div></div><div class="Wj3C7c">
Rhodri James *-* Wildebeeste Herder to the Masses<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br></div>