#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Location
    Canada
    Posts
    51
    Rep Power
    2

    Difference between IDLE and cmd python 3.3 win


    Hey I noticed something that confused me a bit. When checking stream fileno() with this code
    Code:
    >>>import sys
    >>>for stream in (sys.stdin, sys.stdout, sys.stderr):
    ...    print(stream.fileno())
    when using it on command line it works fines and returns the numbers 0,1,2 but when run using idle it returns the error
    Code:
    Traceback (most recent call last):
      File "<pyshell#3>", line 2, in <module>
        print(stream.fileno())
    io.UnsupportedOperation: fileno
    Does anyone know why this hapens?

    thanks, Ryan
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    153
    Rep Power
    5
    If you just type
    Code:
    sys.stdin
    in IDLE, you'll notice its type is "<idlelib.PyShell.PseudoInputFile object>". If you think about how IDLE operates, it makes sense that it has to define its own stdin/stdout/stderr objects, so that I/O can be done through its GUI rather than the calling shell.

    For whatever reason, the fileno operation wasn't defined in these objects.

IMN logo majestic logo threadwatch logo seochat tools logo