Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python.': 0.02; 'subject:not': 0.03; 'subject:Python': 0.06; 'sys': 0.07; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'workaround?': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'bytes': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; '(like': 0.30; 'converting': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '3.x': 0.31; 'file': 0.32; 'run': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'maybe': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; '14,': 0.36; 'url:listinfo': 0.36; 'responsible': 0.36; 'url:org': 0.36; 'nov': 0.38; 'little': 0.38; 'skip:p 20': 0.39; 'url:mail': 0.40; 'read': 0.60; 'improved': 0.60; 'series': 0.66; 'nobody': 0.68; 'topic,': 0.81; '3.4': 0.84; 'joel': 0.91; 'to:addr:nobody': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iKY1Z/fwz32MdrUiKp1JrFGtxNLtu0nKObfKGBjQvTY=; b=u4o0HhK/7ZXm4P4Pmk6SCYlnXstQmTBx3OMHuH2g6hvnjM5Fzeef1sqrggWPo13rPA u8N2ho4bNdHx9pwnXMlzE4Nsf/4zQThfhLPhBctS6w9ydPG3VNK4lq1Eh20gPkOlWU7h +9Aw9bPAWhBR5toDcjfHy96Sipvi7kf5nh7h6Q18Z7QVeatJmyiwJrKT55vCUSzzoqBn iql28kl0N+Lh6A+qb5JN8EsLzgOigsCg8xrKw3HUvf0GWee1SqCrKRi7emN4RFbGbIOc iK7dITfFzBpXigE5rIkVsyMfOr9ha2mkp+rylR9C8O7fD63PUsMvRR5sPcYs58xvcL64 ViDQ== MIME-Version: 1.0 X-Received: by 10.224.7.200 with SMTP id e8mr11730394qae.77.1415974184527; Fri, 14 Nov 2014 06:09:44 -0800 (PST) In-Reply-To: References: Date: Fri, 14 Nov 2014 09:09:44 -0500 Subject: Re: fileno() not supported in Python 3.1 From: Joel Goldstick To: Nobody Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415974187 news.xs4all.nl 2886 [2001:888:2000:d::a6]:34659 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80764 On Fri, Nov 14, 2014 at 8:59 AM, Nobody wrote: > On Thu, 13 Nov 2014 15:48:32 -0800, satishmlmlml wrote: > >> import sys >> for stream in (sys.stdin, sys.stdout, sys.stderr): >> print(stream.fileno()) >> >> >> io.UnsupportedOperation: fileno >> >> Is there a workaround? > > Try: > sys.stdin.buffer.fileno() > > or maybe > > sys.stdin.buffer.raw.fileno() > > In Python 3.x, sys.stdin isn't actually a "file", it's a TextIOWrapper > around a BufferedReader around a file (io.FileIO). > > TextIOWrapper is responsible for converting a stream of bytes to a stream > of (Unicode) characters. BufferedReader is responsible for buffering (like > C stdio). > A little off topic, but why not upgrade to 3.4 if you are learning python. I run 2.7, but I've read that much has improved in the 3.x series since 3.1 > > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com