Dmitriy Gorbachev <dgorbac...@yahoo.com> added the comment:

Hello Ned

Thank you very much for your time and for your advice where to post questions 
like mine.

I apologise for my mistake: instead of input() there was raw_input() function 
in 
the book, which works as expected on all platforms.

Best regards

Dmitry

----- Original Message ----
From: Ned Deily <rep...@bugs.python.org>
To: dgorbac...@yahoo.com
Sent: Sun, July 3, 2011 4:18:35 PM
Subject: [issue12482] input() not working correctly on Mac OS X

Ned Deily <n...@acm.org> added the comment:

The test case you've provide is working as expected but the code doesn't make a 
lot of sense as provided.  The function loadDbase sets sys.stdin to a disk file 
but never sets it back again.  If you run this in an interactive interpreter on 
any Unix-like system and call that function, it will leave sys.stdin still 
connected to the disk file which will give unexpected results.  I don't have a 
copy of the book so I don't know how the author recommends to run things but it 
won't work as it stands (also, the function loadDbase is incomplete compared 
with the book's example files).  You can remove the immediate problem by adding 
the following line just before the "return db" at the end of loadDbase:
    sys.stdin = sys.__stdin__
That will restore the original value of sys.stdin.

You may want to ask questions like this on either the tutor mailing list or 
comp.lang.python.

http://www.python.org/community/lists/ 

http://docs.python.org/library/sys.html#sys.__stdin__

----------
assignee: ronaldoussoren -> 
components:  -Macintosh
nosy: +ned.deily
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12482>
_______________________________________

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12482>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to