Re: Use list name as string

2009-02-05 Thread Tino Wildenhain
Hi, Vincent Davis wrote: Sorry for not being clear I would have something like this x = [1, 2, 3,5 ,6 ,9,234] Then def savedata(dataname): .. savedata(x) this would save a to a file called x.csv This is my problem, getting the name to be x.csv which is the same as the name of the

Re: Use list name as string

2009-02-05 Thread Tino Wildenhain
Hendrik van Rooyen wrote: MRAB goo...@mrett.plus.com wrote: The actual names of the variables and functions shouldn't matter to the outside world; the name of an output file shouldn't depend on the name of a variable. That is a matter of opinion. It is however, an interesting

Re: Use list name as string

2009-02-05 Thread Rhodri James
On Thu, 05 Feb 2009 03:32:59 -, Vincent Davis vinc...@vincentdavis.net wrote: The problem is you seem to be thinking in terms of objects having names. They don't. Names have objects.I agree this is my problem. This is not correct terminology then? The name of the object is anobject No.

Use list name as string

2009-02-04 Thread Vincent Davis
Do to laking knowledge my google searches have not turned up an answer for me. I know this is wrong it uses the items in the list as the filename, how do I refer to the dataname and not the items in it. def savedata(dataname): filename = str(dataname) # this does not do what I would like it

Re: Use list name as string

2009-02-04 Thread Gary Herron
Vincent Davis wrote: Do to laking knowledge my google searches have not turned up an answer for me. I know this is wrong it uses the items in the list as the filename, how do I refer to the dataname and not the items in it. def savedata(dataname): filename = str(dataname) # this does

Re: Use list name as string

2009-02-04 Thread Tim Chase
I know this is wrong it uses the items in the list as the filename, how do I refer to the dataname and not the items in it. Without a sample value for dataname, it's hard to tell what you're trying to do. Do you mean dataname = ['path', 'to', 'file'] ... filename =

Re: Use list name as string

2009-02-04 Thread Vincent Davis
Sorry for not being clearI would have something like this x = [1, 2, 3,5 ,6 ,9,234] Then def savedata(dataname): .. savedata(x) this would save a to a file called x.csv This is my problem, getting the name to be x.csv which is the same as the name of the list. and the data in the file

Re: Use list name as string

2009-02-04 Thread MRAB
Vincent Davis wrote: Sorry for not being clear I would have something like this x = [1, 2, 3,5 ,6 ,9,234] Then def savedata(dataname): .. savedata(x) this would save a to a file called x.csv This is my problem, getting the name to be x.csv which is the same as the name of the

Re: Use list name as string

2009-02-04 Thread Vincent Davis
I know nothing but that sucks. I can think of a lot of times I would like to do something similar. There really is no way to do this, it seems like there would be some simple way kind of like str(listname) but backwards or different. Thanks Vincent Davis On Wed, Feb 4, 2009 at 10:07 AM, MRAB

Re: Use list name as string

2009-02-04 Thread Vincent Davis
I guess what I am saying is that it does not seem like I am adding any information that is not already there when I have to enter that list and list name after all they are the same. Thanks Vincent Davis On Wed, Feb 4, 2009 at 10:18 AM, Vincent Davis vinc...@vincentdavis.netwrote: I know

Re: Use list name as string

2009-02-04 Thread Vincent Davis
can I do it the otherway, that issavedata('nameoflist') Thanks Vincent Davis 720-301-3003 On Wed, Feb 4, 2009 at 10:23 AM, Vincent Davis vinc...@vincentdavis.netwrote: I guess what I am saying is that it does not seem like I am adding any information that is not already there when I have to

Re: Use list name as string

2009-02-04 Thread Tim Chase
I know nothing but that sucks. I can think of a lot of times I would like to do something similar. There really is no way to do this, it seems like there would be some simple way kind of like str(listname) but backwards or different. Python does the only reasonable thing: doesn't give you

Re: Use list name as string

2009-02-04 Thread Tim Chase
can I do it the otherway, that issavedata('nameoflist') for limited cases where your variable is defined globally, you can use: a = [1,2,3,4] def save(s): ... print globals().get(s, UNDEFINED) ... save(a) [1, 2, 3, 4] save(b) UNDEFINED b = (6,5,4,3) save(b)

Re: Use list name as string

2009-02-04 Thread MRAB
Vincent Davis wrote: I guess what I am saying is that it does not seem like I am adding any information that is not already there when I have to enter that list and list name after all they are the same. If you write: y = x then both x and y refer to the same list. The actual names of the

Re: Use list name as string

2009-02-04 Thread Rhodri James
On Wed, 04 Feb 2009 17:23:55 -, Vincent Davis vinc...@vincentdavis.net wrote: I guess what I am saying is that it does not seem like I am adding any information that is not already there when I have to enter that list and list name after all they are the same. Thanks But you are.

Re: Use list name as string

2009-02-04 Thread Vincent Davis
if I start with M = [1,3,5,7] M is [1,3,5,7] This seems one way, as [1,3,5,7] is not M in the sense that there is no operation I can preform on [1,3,5,7] and get M back. Other than asking/testing M==[1,3,5,7] This seems fine to me. but when I savedata(M) it seems I should be able to refer to both

Re: Use list name as string

2009-02-04 Thread Tim Chase
My argument comes down to; we use M so we don't have to type [1,3,5,7], I realize that this is in part because we might not no what M will be. This is starting to sound like double talk on my part, I have only been programing in python for 2 weeks so my credibility is only that of an outside that

Re: Use list name as string

2009-02-04 Thread Rhodri James
On Thu, 05 Feb 2009 01:36:17 -, Vincent Davis vinc...@vincentdavis.net wrote: if I start with M = [1,3,5,7] M is [1,3,5,7] This seems one way, as [1,3,5,7] is not M in the sense that there is no operation I can preform on [1,3,5,7] and get M back. Other than asking/testing M==[1,3,5,7]

Re: Use list name as string

2009-02-04 Thread Jervis Whitley
On Thu, Feb 5, 2009 at 3:57 AM, Vincent Davis vinc...@vincentdavis.net wrote: Sorry for not being clear I would have something like this x = [1, 2, 3,5 ,6 ,9,234] Then def savedata(dataname): .. savedata(x) this would save a to a file called x.csv This is my problem, getting the

Re: Use list name as string

2009-02-04 Thread Vincent Davis
The problem is you seem to be thinking in terms of objects having names. They don't. Names have objects.I agree this is my problem. This is not correct terminology then? The name of the object is anobject Let me give another example and let me know if I am just beating a dead horse. In my

Re: Use list name as string

2009-02-04 Thread Vincent Davis
Jervis Whitley wrote Although you should really solve your problem by thinking about it from a completely different angle, maybe subclassing your datatype and adding a 'name' attribute ? I'm sure some of the others here have suggested that already. That is beyond my current knowledge. Any

Re: Use list name as string

2009-02-04 Thread Jervis Whitley
On Thu, Feb 5, 2009 at 2:37 PM, Vincent Davis vinc...@vincentdavis.net wrote: Jervis Whitley wrote Although you should really solve your problem by thinking about it from a completely different angle, maybe subclassing your datatype and adding a 'name' attribute ? I'm sure some of the others

Re: Use list name as string

2009-02-04 Thread Aahz
In article mailman.8810.1233792569.3487.python-l...@python.org, Rhodri James rho...@wildebst.demon.co.uk wrote: Fundamentally, the concept of a single unique name for any object isn't something built into the language (or, indeed, most languages I can think of). An object can have no names

Re: Use list name as string

2009-02-04 Thread Hendrik van Rooyen
MRAB goo...@mrett.plus.com wrote: The actual names of the variables and functions shouldn't matter to the outside world; the name of an output file shouldn't depend on the name of a variable. That is a matter of opinion. It is however, an interesting problem, namely: How does one get