[Python-bugs-list] [ python-Bugs-547138 ] - open - alias generates error
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 23 Apr 2002 22:32:57 -0700
Bugs item #547138, was opened at 2002-04-22 15:59
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=547138&group_id=5470
Category: Python Interpreter Core
Group: Not a Bug
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: rodney holland (rhhrhh)
Assigned to: Tim Peters (tim_one)
Summary: - open - alias generates error
Initial Comment:
Using python 2.2.1c on windows 98 the alias - open -
gives the following error. The function - file -
works fine.
>>> f=open("rfile.dat",'w')
Traceback (most recent call last):
File "<pyshell#42>", line 1, in ?
f=open("rfile.dat",'w')
TypeError: an integer is required
>>>
----------------------------------------------------------------------
Comment By: rodney holland (rhhrhh)
Date: 2002-04-24 05:32
Message:
Logged In: YES
user_id=522964
your analysis is correct - it is just too tempting to
use import * in order to save a few keystrokes.
Thanks for the prompt response.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-04-24 01:18
Message:
Logged In: YES
user_id=31435
Closing as not-a-bug since this is a not-quite-common
mistake and there's no reason to believe it's anything
other than that. Don't use "import *" and your life will
be happier <wink>.
----------------------------------------------------------------------
Comment By: Robert D. Penny (wobblie)
Date: 2002-04-24 00:06
Message:
Logged In: YES
user_id=393585
I just got caught by the same "gotcha" using 2.2.1 on linux.
Thanks for pointing out the problem.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-04-22 17:09
Message:
Logged In: YES
user_id=31435
Works for me. Please try the released 2.2.1, although I
can't imagine why it would make any difference. Nothing
changed here, and
C:\Python22>python
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.
>>> file is open
1
>>>
That is, "file" and "open" aren't merely aliases, they're
exactly the same object.
Are you using IDLE or PythonWin or ...? "<pyshell#42>"
doesn't appear in a DOS-box traceback.
Ah, I know! You did something stupid <wink> you're not
showing us, like
from os import *
Here:
>>> open
<type 'file'>
>>> from os import *
>>> open
<built-in function open>
>>>
If you replace the builtin open with os.open, then "an
integer is required" is the expected error. The builtin
open and os.open are different functions.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=547138&group_id=5470