Fredrik Lundh wrote:
> Ron Adam wrote:
>
>
>>For cases where single values are desired, attribues could work.
>>
>>Slicing:
>> line = line.partition(';').head
>> line = line.partition('#').head
>>
>>But it gets awkward as soon as you want more than one.
>>
>> sep, port = host.partition(':').head, host.partition(':').sep
>
>
> unless you go for the piece approach
>
> host, port = host.piece(":", 1, 2)
>
> (which, of course, is short for
>
> host, port = host.piece(":").group(1, 2)
>
> )
I'm not familiar with piece, but it occurred to me it might be useful to
get attributes groups in some way. My first (passing) thought was to do...
host, port = host.partition(':').(head, sep)
Where that would be short calling a method to return them:
host, port = host.partition(':').getattribs('head','sep')
But with only three items, the '_' is in the category of "Looks kind of
strange, but I can get used to it because it works well.".
Cheers,
Ron
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com