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 list.

and the data in the file would be 1,2,3,5,6,9,234 this parts works

the problem you are facing comes from a little misunderstanding.
To clarify:

python objects are nameless.

You can bind them to any number of names (aka variables)

>>> 1 # unnamed integer object with value 1
1

>>> a=1 # bind the integer object to name 'a'
>>> b=a # bind the same integer object referred to by name a to name b

therefore in your above example, which "name" should your
savedata pick up for the filename? the 'x' of the first
assignment or the 'dataname' of the assignment in the function
call?

The only solution I see would be to add a property to your datastore
to give it its own unique name. (By subclassing and providing
a name attribute or property) - and while you are at it, maybe
you want to put the 'write to file' part into the class as well.

Regards
Tino

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to