Re: Reading from sys.stdin reads the whole file in

2014-08-26 Thread Naoki INADA
I recommend Python 3. On Python 2, iterating lines without buffering is slow, tricky and ugly. for line in iter(sys.stdin.readline(), ''):     print line — Sent from Mailbox On Wed, Aug 27, 2014 at 3:03 PM, Chris Angelico wrote: > On Wed, Aug 27, 2014 at 3:19 PM, Steven D'Aprano wrote: >>

Re: CLI framework using python

2014-10-14 Thread Naoki INADA
Click_ is another CLI framework. It support multi-level nested command like git and it has some nice utilities. I love it's design. .. _click: http://click.pocoo.org/3/ — Sent from Mailbox On Tue, Oct 14, 2014 at 10:35 PM, vijnaana bhairava wrote: > Hi Folks, > The requirement is to

What is file.encoding convention?

2009-07-22 Thread Naoki INADA
In document : >> The encoding that this file uses. When Unicode strings are written to a file, >> they will be converted to byte strings using this encoding. In addition, >> when the file is connected to a terminal, the attribute gives

Re: What is file.encoding convention?

2009-07-23 Thread Naoki INADA
> What is file.encoding convention? > If I want to write a unicode string to a file(-like) that have > encoding attribute, I should do > (1) try: file.write(unicode_str), > (2) except UnicodeEncodeError: file.write(unicode_str.encode > (file.encoding)) > like logging? > It seems agly. s/agly/ugly/

Re: What is file.encoding convention?

2009-07-23 Thread Naoki INADA
> What is the encoding of sys.stderr in your example? Sorry, I missed. It is cp932 > So the problem is essentially this: if a stream has an encoding > attribute, sometimes it is a wrapped stream which encodes Unicode > (e.g. a stream obtained via the codecs module) and sometimes it is not > (e.g.

Re: What is file.encoding convention?

2009-07-23 Thread Naoki INADA
> > Yes! I confused by it. s/I confused/I am confused/ > "Writing unicode to a file(-like)" is a simple requirement. > Does python have any simple resolution for it? s/resolution/solution/ Sorry about my poor English. -- http://mail.python.org/mailman/listinfo/python-list