File creation, polluted name space?

D

Derek Rhodes

This is a python session I had running
Python 2.3.3 (win32)

-----------------------------------------------
IDLE 1.0.2
Traceback (most recent call last):
File "<pyshell#4>", line 1, in -toplevel-
infile = open("file3", 'w')
TypeError: an integer is required----------------------------------------------------------
after I < from import os * > I can't seem to create a file
by the method shown above.

The error indicates that an integer is required,
however, I don't see how an integer would fit
in here.
Does anyone know what's going on?
Is the name space being polluted?

-derek
 
J

Josiah Carlson

Does anyone know what's going on?
Yes
Is the name space being polluted?
Yes

Try:

help(open)
import os
help(os.open)

Note the different arguments and help output.

- Josiah
 
C

Christopher A. Craig

Derek Rhodes said:
after I < from import os * > I can't seem to create a file
by the method shown above.

Then don't from os import * :)

The "from spam import *" construct is known to be susceptible to all
kinds of name space collisions and its use is generally discouraged.

Unless you _really_ know what you're doing and have a _really_ good
reason, either use "import spam" or "from spam import ham,eggs". If
you have a really good reason, you may want to rethink it anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top