Re: Weird Problem

Discussion in 'Python' started by Carl Banks, Aug 21, 2003.

  1. Carl Banks

    Carl Banks Guest

    Kris Caselden wrote:
    > I'm sure this is a simple newbie problem, but I can't figure it out
    > for the life of me.
    >
    > The code:
    > import sys, os
    > input = open("example.py","r")
    >
    > Gives me the error:
    > TypeError: an integer is required



    I'm going to guess. I'll bet you used "from os import *" somewhere
    above that. os has a function "open" that closely interfaces the
    operating system's open call--and the second argument has to be an
    integer.

    BTW, you don't know this, but since you're using 2.3, you should
    probably start using "file" instead of open:

    input = file("example.py","r")



    --
    CARL BANKS http://www.aerojockey.com/software
    "You don't run Microsoft Windows. Microsoft Windows runs you."
    Carl Banks, Aug 21, 2003
    #1
    1. Advertising

  2. Carl Banks

    Anand Pillai Guest

    Dont forget that 'input' is a keyword in python.
    It is used to accept user inputs as illustrated below.

    r=input("Write your name here: ")
    print r

    Maybe the interpreter is getting confused with
    your variable <input> and the keyword "input".

    My suggestion... try a different variable name
    other than <input>.

    Just guessing of course, since I can find no
    problem with the code as such.

    -Anand

    "Andrew Dalke" <> wrote in message news:<H8Z0b.1624$>...
    > Carl Banks:
    > > BTW, you don't know this, but since you're using 2.3, you should
    > > probably start using "file" instead of open:

    >
    > Something I rather don't like given how much old code I have
    > which uses 'file' as a variable. Ditto for quite a few pieces of the
    > standard library.
    >
    > Andrew
    >
    Anand Pillai, Aug 21, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dorayme
    Replies:
    1
    Views:
    600
    richard
    Jan 21, 2011
  2. richard
    Replies:
    0
    Views:
    566
    richard
    Jan 21, 2011
  3. richard
    Replies:
    0
    Views:
    601
    richard
    Jan 21, 2011
  4. Beauregard T. Shagnasty

    Re: A Weird Appearance for a Weird Site

    Beauregard T. Shagnasty, Jan 21, 2011, in forum: HTML
    Replies:
    1
    Views:
    424
    Captain Paralytic
    Jan 21, 2011
  5. will
    Replies:
    6
    Views:
    388
    Phrogz
    Dec 27, 2006
Loading...

Share This Page