[Tutor] adding users to tweets on a list

Saad Javed sbjaved at gmail.com
Wed Aug 7 16:41:47 CEST 2013


There was only Chris responding to the question so I removed the line above
the quoted part in my responses that says "On Aug 6, 2013 11:36 PM, "Dave
Angel" <davea at davea.name> wrote:"... is that what's confusing?
On Aug 6, 2013 11:36 PM, "Dave Angel" <davea at davea.name> wrote:

> Saad Javed wrote:
>
> > I want to add users to the tweet from the list, the no. of users added
> > based on the length of the tweet.
> >
> This version should be a bit cleaner than what I've seen on this thread.
>
> #!/usr/bin/env python
>
> LIMIT = 140
> #(I use uppercase there to show it's a constant)
>
> def send(message, users):
>     output = message
>     while users:
>         while users and 1+len(output+users[0]) < LIMIT:
>             output += " " + users.pop(0)
>         if output == message:
>             print "message too long for user", user[0]
>             raise userError
>         print output
>         output = message
>
> lst = ['@saad', '@asad', '@sherry', '@danny', '@ali', '@hasan',
> '@adil', '@yousaf', '@maria', '@bilal', '@owais']
>
>
> #string = raw_input('enter string: ')
> #example string
> string = ("These are my friends living in the same city as i am."
> " I have known them for years. They are "
> "good people in general. They are:")
>
> send(string, lst)
>
> BTW, you have a bunch of other messages on the thread which are replying
> to the invisible man, posts that aren't (yet?) visible.  Since you quote
> him without attribution, we have no clue who you're commenting about.
>
> --
> DaveA
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130807/c5e06504/attachment.html>


More information about the Tutor mailing list