question about input() and/or raw_input()

C

Chris Angelico

2) I didn't claim that sys.stdin.readline() was as simple as using
input. I didn't claim it was preferable. I merely presented it as
a refutation to the argument that if you don't use input/raw_input
then you have to use a GUI toolkit.

I'd draw a subtle distinction here, btw. With sys.stdin.readline(),
you're asking to read a line from standard input, but with
(raw_)input(), you're asking to read one line from the console. If
it's been redirected, that's going to be equivalent (modulo newline
handling), but if not, it would make sense for (raw_)input() to call
on GNU Readline, where sys.stdin.readline() shouldn't. Calling a
method on a file-like object representing stdin feels lower level than
"ask the user for input with this prompt" (which might well do more
than that, too - eg it might flush sys.stdout).

ChrisA
 
M

Mark Lawrence

Not me personally. I guess raw_input must have been used somewhere at
some time for something, or it would have been scrapped in Python 3, not
renamed to input.

Actually, to go off at a tangent, I'm just getting into GUIs via
wxPython. I've discovered there are distinct advantages having to write
endless lines of code just to get a piece of data. For example on a
Sunday it helps pass the time between the two sessions of the Masters
Snooker final being shown on TV.
 
G

Grant Edwards

Actually, to go off at a tangent, I'm just getting into GUIs via
wxPython. I've discovered there are distinct advantages having to
write endless lines of code just to get a piece of data. For example
on a Sunday it helps pass the time between the two sessions of the
Masters Snooker final being shown on TV.

Fair enough, but what do you do to pass the time _during_ Snooker
being shown on TV?

I can still remember the point in my first trip to the UK when I
accidentally stumbled across darts on TV. Given the endless variety
(and quantity) of pointless crap that people watch here in the US, I
can't really explain why I was so baffled and amused by darts on TV --
but I was.
 
R

Roy Smith

Grant Edwards said:
I can still remember the point in my first trip to the UK when I
accidentally stumbled across darts on TV. Given the endless variety
(and quantity) of pointless crap that people watch here in the US, I
can't really explain why I was so baffled and amused by darts on TV --
but I was.

What's so complicated?

points = 501
for dart in throws():
if points - dart == 0 and dart.is_double():
raise YouWin
if points - dart < 0:
continue
points -= dart
beer.drink()
 
C

Chris Angelico

The difference I was thinking of is:

"%h" % 3.14 # this works

vs.

hex(3.14) # this raises

In 3.5 both will raise.

Now you have me *thoroughly* intrigued. It's not %h (incomplete format
- h is a modifier), nor %H (unsupported format character). Do you mean
%x? As of 3.4.0b2, that happily truncates a float:
'3'

Is that changing in 3.5? Seems a relatively insignificant point, tbh!
Anyway, no biggie.

ChrisA
 
C

Chris Angelico

What's so complicated?

points = 501
for dart in throws():
if points - dart == 0 and dart.is_double():
raise YouWin
if points - dart < 0:
continue
points -= dart
beer.drink()

assert victory
raise beer

ChrisA
 
G

Grant Edwards

What's so complicated?

points = 501
for dart in throws():
if points - dart == 0 and dart.is_double():
raise YouWin
if points - dart < 0:
continue
points -= dart
beer.drink()

That looks like an algorithm for _playing_ darts. That I understand.
I have two dartboards (one real, one electronic) and a coule decent
sets of darts. It's watching darts on TV that I don't get.

Actually, I don't really get watching any sort of sports on TV (even
the ones I play). But there was just something about darts on TV that
seemed particularly beyond the pale.
 
E

Ethan Furman

Now you have me *thoroughly* intrigued. It's not %h (incomplete format
- h is a modifier), nor %H (unsupported format character). Do you mean
%x? As of 3.4.0b2, that happily truncates a float:

'3'

Is that changing in 3.5? Seems a relatively insignificant point, tbh!

Argh. Yes, %x or %X.
 
M

Mark Lawrence

Fair enough, but what do you do to pass the time _during_ Snooker
being shown on TV?

I can still remember the point in my first trip to the UK when I
accidentally stumbled across darts on TV. Given the endless variety
(and quantity) of pointless crap that people watch here in the US, I
can't really explain why I was so baffled and amused by darts on TV --
but I was.

Just no comparison, darts and snooker. This is excellent though
 
L

Larry Martell

Just no comparison, darts and snooker. This is excellent though

Now that we're way off on the tangent of what some people consider
boring and others don't, I'm really looking forward to watching
curling in the upcoming Olympics.
 
M

Mark Lawrence

Now that we're way off on the tangent of what some people consider
boring and others don't, I'm really looking forward to watching
curling in the upcoming Olympics.

Curling, now there's another good reason to allow Scottish independance :)
 
G

Gene Heskett

What's so complicated?

points = 501
for dart in throws():
if points - dart == 0 and dart.is_double():
raise YouWin
if points - dart < 0:
continue
points -= dart
beer.drink()

Aren't you missing a fi there, or a next dart? ;-)

Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
Required reading:
<http://culturalslagheap.wordpress.com/2014/01/12/elemental/>
Baseball is a skilled game. It's America's game - it, and high taxes.
-- The Best of Will Rogers
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.
 
G

Gene Heskett

Now that we're way off on the tangent of what some people consider
boring and others don't, I'm really looking forward to watching
curling in the upcoming Olympics.

I have Larry, and the suspense is not good for those with high blood
pressure.

Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
Required reading:
<http://culturalslagheap.wordpress.com/2014/01/12/elemental/>
I've enjoyed just about as much of this as I can stand.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,124
Latest member
JuniorPell
Top