Jervis Whitley wrote "Although you should really solve your problem by thinking about it<br>from a completely different angle, maybe subclassing your datatype and adding a 'name'<br>attribute ? I'm sure some of the others here have suggested that already."<div>
<br></div><div>That is beyond my current knowledge. Any suggestions for reading about this?</div><div><br clear="all">Thanks<br>Vincent Davis<br><br>
<br><br><div class="gmail_quote">On Wed, Feb 4, 2009 at 8:24 PM, Jervis Whitley <span dir="ltr"><<a href="mailto:jervisau@gmail.com">jervisau@gmail.com</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, Feb 5, 2009 at 3:57 AM, Vincent Davis <<a href="mailto:vincent@vincentdavis.net">vincent@vincentdavis.net</a>> wrote:<br>
> Sorry for not being clear<br>
> I would have something like this<br>
> x = [1, 2, 3,5 ,6 ,9,234]<br>
> Then<br>
> def savedata(dataname): ..........<br>
><br>
> savedata(x)<br>
> this would save a to a file called x.csv This is my problem, getting the<br>
> name to be x.csv which is the same as the name of the list.<br>
> and the data in the file would be<br>
> 1,2,3,5,6,9,234 this parts works<br>
<br>
</div>It sounds like you would _really_ like to attach a name to this list of data.<br>
<br>
How about this terrible example to solve your problem.<br>
<br>
x = dict(x=[1,2,3,5,6,9,234])<br>
<br>
then<br>
def savedata(dataname):<br>
   # extract the first key(name) and value(data) from the dataname data type.<br>
   try:<br>
      name, data = dataname.items()[0]<br>
   except AttributeError:<br>
      raise TypeError("Expecting a datatype that declares method 'items' :).")<br>
   # we could catch other exceptions here but I wont (like empty items).<br>
<br>
<br>
now you have your name and your data variable.<br>
This way you don't declare your variable name when calling savedata<br>
but when you<br>
create your variable.<br>
<br>
Although you should really solve your problem by thinking about it<br>
from a completely<br>
different angle, maybe subclassing your datatype and adding a 'name'<br>
attribute ? I'm<br>
sure some of the others here have suggested that already.<br>
<br>
Cheers,<br>
</blockquote></div><br></div>