[Tutor] paste question
Alan Gauld
alan.gauld at btinternet.com
Sat Sep 27 21:27:56 CEST 2008
<cuciferus at gmail.com> wrote
Sorry but I'm confused.
> I made a little script to whom I wish to pass some pasted(with
> middle
> click(x11 style)) multi-row text. But if I pass say 99 rows it
> crashes with no
> error it exits to bash. Any ideas why?
Do you mean you are trying to paste a long piece of text into the
raw_input prompt?
Otherwise I'm not sure what the code below has to do with anything?
> from sys import exit
you don;t use exit...
> a=0
> while True:
This will loop forever (or until an error) since you have no break
statement.
> s=raw_input()
> a+=1
> if s=="finish":
> print "you have ", ((a-1)/5), " questions left"
You might be wanting to use the % mod operator here instead
of division? Otherwise it will always report a low value. And 'a'
records how many responses have been given not how many
questions are left.
> print "in", ((a-1)/100), " pages"
Similarly a has nothing to do with pages... It looks like you
need more variables, or something!
> a=0
This does't make much sense to me either.
But mostly I'm confused about what exactly you are doing with
the paste and when.
Assuming it is at the raw_input stage you could try printing
s just to see what was read. That way when it exists you
should still see what was last input.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list