Line indexing in Python

MRAB python at mrabarnett.plus.com
Tue Dec 22 19:13:58 EST 2009


Lie Ryan wrote:
> On 12/22/2009 11:25 PM, Steve Holden wrote:
>>> >
>>> >  If you want to extract an index number from the first part of of a 
>>> given
>>> >  line use split( split_character, maximum_splits_to_do ) and then 
>>> angle
>>> >  brackets to reference the first part (index 0)...
>>> >
>>> >
>>>>>> >>>>  a = "20 GOTO 10"
>>>>>> >>>>  int( a.split(' ',1)[0] )
>>> >  20
>>> >
>> <nit>
>> those are brackets, not angle brackets
>> </nit>
>>
> 
> <double_nit>
> those [] are square brackets, not angle brackets
> </double_nit>

<triple_nit>
[] are brackets, () are parentheses, {} are braces
</triple_nit>



More information about the Python-list mailing list