Re: TypeError: object cannot be interpreted as an index

2009-04-08 Thread TennesseeLeeuwenburg
On Apr 8, 8:44 pm, Piet van Oostrum  wrote:
> > "tleeuwenb...@gmail.com"  (tc) wrote:
> >tc> What, exactly, needs to be in place for an object to be a valid
> >tc> dictionary key?
>
> It must have __hash__ and __cmp__ or __eq__ methods. Newstyle classes
> inherit these from object.
> --
> Piet van Oostrum 
> URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
> Private email: p...@vanoostrum.org

Awesome, thanks.

I wonder if this is an 'old-style' class, something I've never used
myself... I'll have to do some research.

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


Re: Multithreading / multiprocess

2009-04-12 Thread TennesseeLeeuwenburg
On Apr 11, 10:39 pm, "Diez B. Roggisch"  wrote:
> tleeuwenb...@gmail.com schrieb:
>
> > Is there anyway to begin a thread and execute a finite number of lines
> > of code, or a finite amount of time within it?
>
> > For example, say I create three child threads and I want to guarantee
> > equal timeshare between them, can I specify a quanta (say 400 LOC
> > although I know that is pretty small) to execute in each one in turn?
>
> Not as such, no. You can play tricks with the trace-module, but these
> ultimately fail when the code in question runs inside C - which puts a
> stop to any python interpreter scheduling anyway, thus native threads
> are used which can't be controlled on that level.
>
> Diez

Mmmm good point. 1 line of Python != 1 line of C. That's probably not
very important for what I have in mind, but I hadn't really been
considering that angle.

Cheers,
-T
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multithreading / multiprocess

2009-04-12 Thread TennesseeLeeuwenburg
On Apr 12, 2:59 am, a...@pythoncraft.com (Aahz) wrote:
> In article 
> <57065c62-2024-47b5-a07e-1d60ff85b...@y10g2000prc.googlegroups.com>,
>
> tleeuwenb...@gmail.com  wrote:
>
> >Is there anyway to begin a thread and execute a finite number of lines
> >of code, or a finite amount of time within it?
>
> >For example, say I create three child threads and I want to guarantee
> >equal timeshare between them, can I specify a quanta (say 400 LOC
> >although I know that is pretty small) to execute in each one in turn?
>
> You have extremely coarse-grained control with sys.setcheckinterval().
> However, there is no guarantee which thread will pick up control after
> each context switch, so one thread might get more than its share.

Thanks for your reply! Will add that to my reading list.

Cheers,
-T
--
http://mail.python.org/mailman/listinfo/python-list