Newbie Question

Michael.Coll-Barth at VerizonWireless.com Michael.Coll-Barth at VerizonWireless.com
Fri Aug 19 10:19:38 EDT 2005


Tom,

Well, as one newbie to another, I tried this;

>>> x = '22,44,66,88,"asd,asd","23,43,55"'
>>> y = eval(x)
>>> y
(22, 44, 66, 88, 'asd,asd', '23,43,55')

given that x some how comes from a single line in your file.

BTW, do you get the tutor list as well?  My guess is that the 'experts' over
here might prefer that the newbies go over there for stuff like this.  

And now, a question for the experts.  Does anyone have a pointer as to why
my code might be dangerous?  I get the feeling that eval might not be a
'good' ( safe ) thing to use.

Michael

-----Original Message-----
From:
python-list-bounces+michael.coll-barth=verizonwireless.com at python.org
[mailto:python-list-bounces+michael.coll-barth=verizonwireless.com at pytho
n.org]On Behalf Of Tom Strickland
Sent: Friday, August 19, 2005 10:05 AM
To: python-list at python.org
Subject: Newbie Question


I have a file that contains many lines, each of which consists of a string 
of comma-separated variables, mostly floats but some strings. Each line 
looks like an obvious tuple to me. How do I save each line of this file as a

tuple rather than a string? Or, is that the right way to go?

Thank you.

Tom Strickland 


-- 
http://mail.python.org/mailman/listinfo/python-list
___________________________________________________________________
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.




More information about the Python-list mailing list