string in files

Steve Holden steve at
Tue Dec 30 14:02:11 CET 2008

ibpet11 at wrote:
> On Dec 30, 11:17 am, "Narasimhan Raghu-RBQG84" <RBQ... at>
> wrote:
>> Simple solution: us result=yourString.split(" ") and you get a list with
>> all the words.
>> -----Original Message-----
>> From: python-list-bounces+rbqg84=motorola.... at
>> [mailto:python-list-bounces+rbqg84=motorola.... at] On Behalf Of
>> ibpe... at
>> Sent: Tuesday, December 30, 2008 3:43 PM
>> To: python-l... at
>> Subject: string in files
>> guys i need info on how to call up different words in a line of a file
>> using python example : file = 'this is a python coding group'
>> i want to assign a xter to this, is, a, python , coding and group
> thanks brother
> i mean how do i particularly assign (u = this)
>                                     (y = is)....
> in the strings up there. i have been able to split strings with any
> character sign.
Well, if you *know* you have a particular number of words in the string
you can say

u, v, w, x, y, z = 'this is a python coding group'.split()

But if you have a variable number of words this isn't practical in
Python 2, though Python 3 has features that make it easier.

The real question is "what is the larger goal you are trying to
achieve". Where a programmer is trying to create names dynamically there
are usually better ways to proceed. Could you tell us a little more
about what you are trying to do?

Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC    

More information about the Python-list mailing list