[Tutor] ok, got a primitive but workable solution

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri, 28 Dec 2001 14:58:26 -0800 (PST)


On 28-Dec-2001 Kirk Bailey wrote:
> 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]
> 

apparently you missed my mail.

def getname(thing): # list is A BAD NAME TO USE
    import os.path
    name = os.path.basename(thing)
    name, ext = os.path.splitext(name)
    return name