[newbie] Writing to file : "name 'concat' is not defined"?

Glenn Andreas gandreas at no.reply
Wed Jul 21 17:03:06 CEST 2004


In article <mailman.663.1090420427.5135.python-list at python.org>,
 Brian Quinlan <brian at sweetapp.com> wrote:

> Fred wrote:
> > On Wed, 21 Jul 2004 16:01:04 +0200, Brian Quinlan <brian at sweetapp.com>
> > wrote:
> > 
> >>I don't see any reference to a "concat" function in either of those 
> >>resources.
> > 
> > 
> > Er...
> > 
> > Dive into Python : "Example 6.3. Opening a File" at the very
> > beginning. No mention of an "open" statement, just concat. Same lower
> > in "Example 6.7. Writing to Files".
> 
> Example 6.3. Opening a File
> 
>  >>> f = open("/music/_singles/kairo.mp3", "rb")
>  >>> f
> <open file '/music/_singles/kairo.mp3', mode 'rb' at 010E3988>
>  >>> f.mode
> 'rb'
>  >>> f.name
> '/music/_singles/kairo.mp3'
> 
> Example 6.7. Writing to Files
> 
>  >>> logfile = open('test.log', 'w')
>  >>> logfile.write('test succeeded')
>  >>> logfile.close()
>  >>> print file('test.log').read()
> test succeeded
>  >>> logfile = open('test.log', 'a')
>  >>> logfile.write('line 2')
>  >>> logfile.close()
>  >>> print file('test.log').read()
> test succeededline 2
> 
> > And in the Python Tutorial, jump to "7.2 Reading and Writing Files"
> > The text mentions open(), but the samples don't show it, and use
> > concat() instead.
> 
> Where is the usage of concat?


Perhaps some sort of web-proxy is rewriting stuff?

If I look at the same thing (and I'm running Privoxy) I get:


Example 6.3. Opening a File

>>> f = PrivoxyWindowOpen("/music/_singles/kairo.mp3", "rb") 
>>> f                                           
<open file '/music/_singles/kairo.mp3', mode 'rb' at 010E3988>
>>> f.mode                                      
'rb'
>>> f.name                                      
'/music/_singles/kairo.mp3'

Example 6.7. Writing to Files


>>> logfile = PrivoxyWindowOpen('test.log', 'w') 
>>> logfile.write('test succeeded') 
>>> logfile.close()
>>> print file('test.log').read()   
test succeeded
>>> logfile = PrivoxyWindowOpen('test.log', 'a') 
>>> logfile.write('line 2')
>>> logfile.close()
>>> print file('test.log').read()   
test succeededline 2



More information about the Python-list mailing list