the lvalue curse? let's play with this crazy idea ;)

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri May 9 11:25:35 EDT 2008


XLiIV a écrit :
> I started playing with Python and love it since the very beginning,
> programming using Python is so ...human-like? but one thing returns to
> me almost everytime when I see/write the code
> 
> 
> Let's take a look at two ways of thinking...
> the standard one which is well-known and loved by almost everyone :)
> and that crazy concept below which suprised evan me :wacko:
> 
> <code>
> import time
> 
> ftime = time.time()
> localtime = time.localtime(ftime)
> localtime = list(localtime[:3])

You don't need the call to list here.

> localtime = [str(i) for i in localtime]
> print '-'.join(localtime)
> </code>
> 
> It's harder to read than the below concept, isn't?
> Maybe I didn't used to this way of thinking yet. I hope it'll change
> soon or i'll quit ;)
> 
> 
> <almost code>
> time.time() -> ftime -> time.localtime() -> p -> p[:3] -> g -> list(g)
> -> '-'.join()
> </almost code>

print "-".join(map(str, localtime(time.time())[:3]))

or

print "-".join(str[item] for item in localtime(time.time())[:3])


> My example conclusion and not-ansewered-yet question...
> -it's nice to read

Very subjective point here. I'm afraid I don't share your POV.

> and choosing the good names to variables aren't so
> important

> -what is the purpose of the variables here? :)

help debugging ? make code easier to grasp ?

> I realize that there is no chance to implement it,

In Python ? Not a chance, indeed.




More information about the Python-list mailing list