Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80774

Re: fileno() not supported in Python 3.1

References <bcc9a923-4a68-45b2-9854-a6f750e71ee7@googlegroups.com> <20141114073646.GA32086@cskk.homeip.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-11-14 09:51 -0700
Subject Re: fileno() not supported in Python 3.1
Newsgroups comp.lang.python
Message-ID <mailman.15825.1415984229.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Nov 14, 2014 at 12:36 AM, Cameron Simpson <cs@zip.com.au> wrote:
> On 13Nov2014 15:48, satishmlmlml@gmail.com <satishmlmlml@gmail.com> wrote:
>>
>> import sys
>> for stream in (sys.stdin, sys.stdout, sys.stderr):
>>           print(stream.fileno())
>>
>>
>> io.UnsupportedOperation: fileno
>>
>> Is there a workaround?
>
>
> The first workaround that suggests itself it to use a more modern Python.
> I've got 3.4.2 here, and it goes:
>
>    Python 3.4.2 (default, Nov  5 2014, 21:19:51)
>    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
>    Type "help", "copyright", "credits" or "license" for more information.
>    >>> import sys
>    >>> for stream in (sys.stdin, sys.stdout, sys.stderr):
>    ...   print(stream.fileno())
>    ...
>    0
>    1
>    2
>    >>>
>
> In short, in 3.4.2 it just works.

Why do you think the Python version has anything to do with it?

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for stream in (sys.stdin, sys.stdout, sys.stderr):
...     print(stream.fileno())
...
0
1
2

Clearly, in 2.7.6 it also "just works".

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

fileno() not supported in Python 3.1 satishmlmlml@gmail.com - 2014-11-13 15:48 -0800
  Re: fileno() not supported in Python 3.1 Ben Finney <ben+python@benfinney.id.au> - 2014-11-14 10:57 +1100
    Re: fileno() not supported in Python 3.1 satishmlmlml@gmail.com - 2014-11-13 16:08 -0800
      Re: fileno() not supported in Python 3.1 Ben Finney <ben+python@benfinney.id.au> - 2014-11-14 13:52 +1100
  Re: fileno() not supported in Python 3.1 Cameron Simpson <cs@zip.com.au> - 2014-11-14 18:36 +1100
  Re: fileno() not supported in Python 3.1 Nobody <nobody@nowhere.invalid> - 2014-11-14 13:59 +0000
    Re: fileno() not supported in Python 3.1 Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-14 09:09 -0500
  Re: fileno() not supported in Python 3.1 Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-14 09:51 -0700
    Re: fileno() not supported in Python 3.1 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-15 22:23 +1100
  Re: fileno() not supported in Python 3.1 Dan Stromberg <drsalists@gmail.com> - 2014-11-15 21:25 -0800
  Re: fileno() not supported in Python 3.1 Chris Angelico <rosuav@gmail.com> - 2014-11-16 16:29 +1100

csiph-web