Newbie: print-to-file-Syntax
John Machin
sjmachin at lexicon.net
Sat May 18 20:37:06 EDT 2002
More information about the Python-list mailing list
Sat May 18 20:37:06 EDT 2002
- Previous message (by thread): Pyro 2.8 available
- Next message (by thread): Newbie: print-to-file-Syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sabine Richter <sabine at textraeume.de> wrote in message news:<mailman.1021745730.10043.python-list at python.org>... > Hello, > > I looked the syntax up in the python doc, but nevertheless, I don't > understand it. What's wrong? > > PROT=open("c:\\existing_dir\\prot.txt",'w') > PROT.write("Written String") > print >> PROT "Printed String" > print PROT "Printed String" > > PROT.close() > > --> Written String has been written. But for the print-Statements I get > a syntax error message > > > And a second question: > > Is it possible to write: > PROT=None > print... print-to-file-syntax > Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> foo = None >>> print >> foo, "Hello ..." Hello ... The answers are (1) you are missing a comma (2) yes. In both cases, see example above. :-) Don't expect a visit from folk in nice red uniforms who will no doubt want to caution you about (1) uppercase variable names like PROT (2) using "print >>" at all. :-) Regards, John
- Previous message (by thread): Pyro 2.8 available
- Next message (by thread): Newbie: print-to-file-Syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list