Newbie: opening files.

Bart Holthuijsen Gonk_ at spamspamhotmail.com
Fri May 19 09:57:53 EDT 2000


Thomas Wouters wrote:

> On Fri, May 19, 2000 at 03:22:28PM +0200, Bart Holthuijsen wrote:
>
>
> > TypeError: illegal argument type for built-in operation
>
> > What am I doing wrong?
>
> This:
> > from sys import *
> > from os import *
> > from string import *
>
> os.open() overwrites the builtin open(), and os.open() takes different
> arguments. A friendly tip: do *not* use 'from foo import *' until you
> realize what it does -- and then do not use it either :-) If you really
> dislike the extra few characters it takes to prepend 'os.' or 'sys.', import
> the symbols you need by hand:
>
> from os import system, fork
> from sys import argv, exit
> from string import letters, replace
>
> But I think you'll find in larger programs, just importing the modules and
> using the 'full' name makes your code a lot more obvious. Especially when
> debugging.. you wont have to re-trace to find out what a particular variable
> is bound to :)
>
> --
> Thomas Wouters <thomas at xs4all.net>
>
> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

Thank you for your quick and very helpfull reply. I will use your method in the
future. These are the kind of small hints that make all the difference when learning
a new language.

"Be spontaneous ... combust."




More information about the Python-list mailing list