[Tutor] paste question

cuciferus at gmail.com cuciferus at gmail.com
Sun Sep 28 11:04:40 CEST 2008



On Sunday 28 September 2008 11:16:24 Alan Gauld wrote:
> <cuciferus at gmail.com> wrote
>
> > I'm good here. You see I'm doing some online tests for my graduation
> > and in a test are hundreds of questions. The thing is it doesn't
> > display
> > the number of questions left unanswered, But it displays the status
> > of
> > questions(answered and unaswered). I copy the unanswered questions
> > and paste it in console: here a question is displayed in 5 rows, and
> > I have 20 questions/page.
>
> So you select, witgh the mouse, all of the "unanswered" questions
> from the web page and paste that into the raw_input() request in your
> python script?
yup
>
> Have you tried just printing the pasted information to the consiole
> to make sure it gets read correctly?
I'm using kmail-svn as mail client maybe not all my original message was send, 
but I did mention I was doing this in bash with:
echo "pasted text here"|wc -l
>
> However that still confuses me about what your script is trying to do:
>
> a=0
> while True:
>     s=raw_input()
>
> This should read the entire content of the paste buffer.
> All 100 lines of text.
>
>     a+=1
>     if s=="finish":
>
> This will only do anything if the pasted text is exactly "finish".
> That seems unlikely, I suspect you might have line endings
> and other stuff in there too.
I thought I'll manually insert a "finish" after each paste
>
>         print "you have  ",  ((a-1)/5), " questions left"
>         print "in", ((a-1)/100), " pages"
>
> But if we assume that the text was "finish" you would then
> come into this block which would print out "0 questions left in 0
> pages"
> until a is greater than 6 and 101 respectively.
>
> I'm beginning to suspect you really want something like
> this pseudo code:
>
> s = raw_input('Paste here> ')
> for count, line in enumerate(s): pass
> print "You have ", count/5," questions left in ", count/100," pages"
that would return me the number of words per line(right?).
I have the following 
table:http://img515.imageshack.us/my.php?image=200809281154091280x1024hf2.png
And when I paste it into raw_input one line spreads in 5.
And the unexpected thing goes like so, for s=raw_input('paste here'):
paste here: M2201151
        Reactivitatea crescuta a cailor repiratorii se ...
CS

Neabordata
<more alike sniped>
CS

cuci at cuci ~ $ Reactivitatea crescuta a cailor repiratorii se ...
-bash: Reactivitatea: command not found
<and the more alike in bash!>

So do I have a row limit in raw_input?
I know there must be a better, more pythonic way but, well I'm subscribed to 
python-tutor :)
Thanks!

>

> Am I close?




More information about the Tutor mailing list