[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] something ive done...



Jan Mueller wrote:

> thanx, but I tabyfied it myself now, and deleted some dead code and
> inserted some comments.
> the problems with windows will be that the Filenames will be wrong ("/"
> instead of "\" etc...) 
> 
> to fix this I thought I could write something like that:
> 
> def fn(filename):
> 	return os.path.join(string.split(filename, '/'))
> 
> but it seems that os.path.join only works with tuples and not with
> lists. can anyone tell me how to convert a list to a tuple?

l = [1,2,3]
tuple(l)
(1, 2, 3)

But its not that, os.path.join joins the separate arguments, not a list
or tuple. You can do what you had in mind by (ab)using the new *args
passthrough trick. Ie.

def fn(filename):
    return os.path.join(*string.split(filename, '/'))

The * here does what apply does with its non-keyword arguments. Look up
apply in the docs to get a better idea of what I mean.


-- 

John Eikenberry
[jae@zhar.net - http://zhar.net]
______________________________________________________________
"They who can give up essential liberty to purchase a little temporary
 safety, deserve neither liberty nor safety."
                                          --B. Franklin
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org