[Tutor] ok, got a primitive but workable solution

Kirk Bailey deliberatus@my995internet.com
Fri, 28 Dec 2001 17:16:14 -0500


I wanted to trim a statement down to give me ONLY the name of the list.
I got it.

Probably not the best solution, but it works, and works in python 1.5.2
which is what is in my server.

 'list' is a string, such as: './lists/testlist3.info'

I want to extract the pure list name so I can display ONLY that. This
works.

def getname(list):
	a=string.split(list,'/')
	b=a[2]
	c=string.split(b,'.')
	return c[0]

>>> a
['.', 'lists', 'mylist.info']
>>> list
'./lists/mylist.info'
>>> string.split(list)
['./lists/mylist.info']
>>> string.split(list,'/')
['.', 'lists', 'mylist.info']
>>> def getname:
	
SyntaxError: invalid syntax
>>> def getname(list):
	a=string.split(list,'/')
	b=a[2]
	c=string.split(b,'.')
	return c[0]

>>> list
'./lists/mylist.info'
>>> getname(list)
'mylist'
>>> 



-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end


Within the sweep of his sword, Each man is an Ubar.

http://www.howlermonkey.net/
http://www.sacredelectron.org/