Re: Re: Re: How to output a complex List object to a file.

bluefisher80 bluefisher80 at gmail.com
Mon Jun 22 22:31:45 EDT 2009


Hi 

Thanks for you tip, 

I am generating some code for another python application, 

so is there a better way for code generating? Actually i just need to generate some list objects to define EDI syntax using python.


2009-06-23 



bluefisher80 



发件人: Chris Rebert 
发送时间: 2009-06-23  09:55:41 
收件人: bluefisher80 
抄送: J. Cliff Dyer; python-list 
主题: Re: Re: How to output a complex List object to a file. 
 
2009/6/22 bluefisher80 <bluefisher80 at gmail.com>:
>
> Actually I think i am just looking for
>
> print >> myFile.py, myListObj
Well, that syntax is deprecated. And you'd have to create the actual
file object. And put it in a variable.
So it's more like:
f = file("myFile.py", "w")
f.write(str(myListObj))
f.close()
However, the fact that you want to do this suggests a code smell.
Why do you need to do this in the first place?
Cheers,
Chris
-- 
http://blog.rebertia.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090623/11ad4358/attachment-0001.html>


More information about the Python-list mailing list