Use list name as string

Vincent Davis vincent at vincentdavis.net
Wed Feb 4 12:18:49 EST 2009


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 <google at mrabarnett.plus.com> wrote:

> 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 list.
> >
> > and the data in the file would be 1,2,3,5,6,9,234 this parts works
> >
> The list itself doesn't have a name. You need to pass in both the name
> and the list:
>
> def savedata(name, data): ..........
>
> savedata("x", x)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090204/64c79923/attachment.html>


More information about the Python-list mailing list