Re: [Freevo-devel] Python question

2008-03-18 Thread Jason Tackaberry
On Mon, 2008-03-17 at 23:32 -0700, Michel Lespinasse wrote: > Not a big deal, but it did trip me up the first time (and, I still don't know > of a good way to create the two-dimensional array with actual separate > copies for each row) A bit kludgy, but you could use a list comprehension: [ [0

Re: [Freevo-devel] Python question

2008-03-17 Thread Michel Lespinasse
On Mon, Mar 17, 2008 at 12:01:04PM -0400, Jason Tackaberry wrote: > On Mon, 2008-03-17 at 16:47 +0100, Duncan Webb wrote: > > Thanks both Jason and James, it makes sense that the list is created > > when the method is first parsed, this is something that I need to watch > > out for. I guess that

Re: [Freevo-devel] Python question

2008-03-17 Thread Jason Tackaberry
On Mon, 2008-03-17 at 16:47 +0100, Duncan Webb wrote: > Thanks both Jason and James, it makes sense that the list is created > when the method is first parsed, this is something that I need to watch > out for. I guess that this is only a problem for mutable objects, so > strings and numbers are

Re: [Freevo-devel] Python question

2008-03-17 Thread Duncan Webb
Jason Tackaberry wrote: > On Mon, 2008-03-17 at 15:42 +0100, Duncan Webb wrote: > >> class A: >> def __init__(self, l=[]): >> self.l = l >> > > Note that this creates a default list for l only once at > class-declaration time. All instances of A will share this list. This > is

Re: [Freevo-devel] Python question

2008-03-17 Thread Jason Tackaberry
On Mon, 2008-03-17 at 15:42 +0100, Duncan Webb wrote: > class A: > def __init__(self, l=[]): > self.l = l Note that this creates a default list for l only once at class-declaration time. All instances of A will share this list. This is a common python gotcha. You might want instead:

Re: [Freevo-devel] Python question

2008-03-17 Thread James Oakley
On March 17, 2008, Duncan Webb wrote: > Here is a bit of code: > > class A: > def __init__(self, l=[]): > self.l = l > > class B: > def __init__(self): > self.l = [] > > a1 = A() > a2 = A() > > b1 = B() > b2 = B() > > a1.l += ['a1'] > a2.l += ['a2'] > b1.l += ['b1'] > b2.l +

Re: [Freevo-devel] Python Question

2003-03-14 Thread Thomas Schueppel
On Fri, 14 Mar 2003, Starkeeper wrote: > I try to write a small LCD-script for freevo, but I have no experience in > programming Python. I did not find anything about device-files on python.org > so I ask here. > How can I print out some text to a device-file with Python? For reading or w