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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'python.': 0.02; 'subject:not': 0.03; 'subject:Python': 0.06; 'sys': 0.07; 'works.': 0.09; 'python': 0.11; '6.0': 0.16; 'simpson': 0.16; 'workaround?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'workaround': 0.31; 'compatible': 0.32; 'fri,': 0.33; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; '14,': 0.36; 'apple': 0.38; 'nov': 0.38; 'to:addr :python-list': 0.38; 'anything': 0.39; 'itself': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'first': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'mar': 0.68; '"just': 0.84; '2014,': 0.84; '4.2.1': 0.84; 'short,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=o0tkZdvD6lu87jCAbZu4276DAUACUGNz6zWu8Ejb44w=; b=O5Y+lRq7Yrvgiur/UDGfs48prjjAmMezTLL1FJ9khEqHoF5uM44U9t8OUBQ2Lk4N7A qvRMMiJKDThcUJT/eC2elMwB/l9to+uLJmLxzdxuJ2kSGf+rWpYS8ntRUqzIrNfJvD0e IkhQSjtvLEO3CQy7MWY+qkm3Awlk0XyzezqUb1S9rsOSClpzG1wT21id2kFeEI0gy2Cj DQlIOWD4M6+u6IPjLcbZw+tmALyE6ldEOtLIC/8DUxQx8uv68jdzN+WWljHVaBDk5fkc 17AW3Jp1odHm8tgIaMEZv0uQmN3JSdSDqVG693WamVa/gRO/q0aY5YaWC8a91NonYfN8 CoRw==
X-Received by 10.70.118.72 with SMTP id kk8mr11190725pdb.147.1415983911368; Fri, 14 Nov 2014 08:51:51 -0800 (PST)
MIME-Version 1.0
In-Reply-To <20141114073646.GA32086@cskk.homeip.net>
References <bcc9a923-4a68-45b2-9854-a6f750e71ee7@googlegroups.com> <20141114073646.GA32086@cskk.homeip.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 14 Nov 2014 09:51:11 -0700
Subject Re: fileno() not supported in Python 3.1
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15825.1415984229.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415984229 news.xs4all.nl 2930 [2001:888:2000:d::a6]:43532
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80774

Show key headers only | 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