clear content of 'printed'

Evan Simpson evan at 4-am.com
Mon Aug 23 13:45:26 EDT 2004


Christian Otteneuer wrote:
> I have the following problem:
> I want to write a python script, that writes text into files. The text is 
> being "collected" in a for-loop, the code looks like this:
> 
> for i in range(len(myList)):
>     id = myList[i]
>     print "some text"
>     container.writeToFile(id, printed)
[...]
> Is there a possibility to do clear the content of 'printed' in python?

This question properly belongs in one of the Zope lists, since the 
regular Python folks have no idea what you're talking about.  Thank 
goodness I spotted you, or wackiness would ensue ;-)

"printed" is a magic variable implemented by the Script machinery, and 
is read-only.  You need to drop print and use plain strings:

for i in range(len(myList)):
     id = myList[i]
     txt = "some text"
     container.writeToFile(id, txt)

Cheers,

Evan @ 4-am




More information about the Python-list mailing list