list assignment using concatenation "*"

2006-02-24 Thread liquid
If I do:

a = [ [0,0,0], [0,0,0], [0,0,0] ]
a[0][1] = 1

I get:

a = [ [0,1,0],[0,0,0],[0,0,0] ]

as expected

But if I do:

a = [ [0] * 3 ] * 3
a[0][1] = 1

I get

a = [[0,1,0],[0,1,0],[0,1,0]]

AFAIC, "*" is supposed to generate multiple copies of the given token.
Therefore I thought both cases would be the same, but they are not.

Can anyone explain to me what exactly is going on in the second case?

-- 
http://mail.python.org/mailman/listinfo/python-list


doesNotUnderstand?

2006-10-09 Thread Liquid Snake
Hello :). Some days ago i went to a seminar about Metaprograming and Reflection.I was a little famirialized with the subject, and wanted to explore it further.The seminar was great, but the point is that every example was programmed in smalltalk.
I know smalltalk, and never have much use for the doesNotUnderstand method until the guys at the conference open my eyes with some examples.Altough i have applied concepts of reflection in python many times, i think i't will be nice to have a magic method that works like doesNotUnderstand for some purposes.
The reason i'm writing is because i want to know if such method already exists... or maybe... if you think having one it's a good/possible idea.Right now... im thinkng i really can emulate that behavior using Exceptions..., and i really think that's what SmallTalk kind of do under-the-hood (dont flame me if i'm terribly worng plz).
But i still want to know if theres a method like __insertMethodNameHere__  that does it for me... or if you think it's a nice thing to have...i'm REALLY SORRY for my REALLY BAD English... so..., don't hate me please..
And I'm sorry if this question wasted your time.Thanks anyway..liquid ^.^
-- 
http://mail.python.org/mailman/listinfo/python-list

any portable way to print? (and i mean on a printer)

2006-09-05 Thread Liquid Snake
I think my question is clear.., is there any way to print any text on a portable way?..., and actually, i don't know how to print at all.., just give me some pointers, name a module, and i can investigate for myself.. sorry for my english, thanks in advance..

ps: i prefer a Standard Library module.
-- 
http://mail.python.org/mailman/listinfo/python-list