[Tutor] paste question

cuciferus at gmail.com cuciferus at gmail.com
Sun Sep 28 11:58:31 CEST 2008



On Sunday 28 September 2008 11:37:26 Alan Gauld wrote:
> "Alan Gauld" <alan.gauld at btinternet.com> wrote
>
> >> 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.
> >
> > 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"
>
> Had a rethink...
>
> I don't know enough about how the X paste mechanism and the
> console stdin work together but this may not work because
> raw_input will probably stop reading at the first \n character.
> You probably need to use sys.stdin.read:
>
> print 'paste now'
> s = sys.stdin.read()
> count = s.split('\n)  # no need for a loop.
> print "You have ", count/5," questions left in ", count/100," pages"
yup this did the trick, actually len(count)/5 . Thanks man!
>
> Maybe...



More information about the Tutor mailing list