Talin <[EMAIL PROTECTED]> wrote:
> 
> Talin <talin <at> acm.org> writes:
> 
> > 2) A suggestion which I've seen others bring up before is the use of
> > the * operator for tuple packing / unpacking operations, i.e.:
> > 
> >     a, *b = (1, 2, 3)
> 
> I wanted to add another case that I run across in my code a lot.
> 
> I often times want to split off a single leading word or token
> from a string, but I don't know in advance whether or not the
> split will actually succeed.
> 
> For example, suppose you want to render the first word of
> a paragraph in a different style:
> 
>    first, rest = paragraph.split( ' ', 1 )
[snip]

See str.partition in Python 2.5 (I don't know if it is implemented yet
or not).

'Python is fun!'.partition(' ') -> 'Python', ' ', 'is fun'

 - Josiah

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to