[Tutor] Python best practices

2009-11-27 Thread Stefan Lesicnik
hihi! (two in 1 day!) Is there a document, pep, wiki etc that defines best practice for python code? (maybe its more generic). I keep stumbling on things I think, it would be nice if someone mentioned this. Some things ive seen - keep you try blocks as small as possible, so you can isolate t

Re: [Tutor] unicode mapping doesn't work

2009-11-27 Thread Lie Ryan
On 11/27/2009 12:06 PM, Alan Gauld wrote: Huh?! Was this to the right place? It doesn't seem to be related to the previous posts in the thread? Confused Alan G. whoops.. wrong thread... ___ Tutor maillist - Tutor@python.org To unsubscribe o

[Tutor] Python on multicore machines

2009-11-27 Thread OkaMthembo
Hi All, Is there a python implementation that takes advantage of all cores on modern multicore machines? -- Regards, Lloyd ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tu

Re: [Tutor] socket timeout

2009-11-27 Thread Sander Sweers
2009/11/27 Stefan Lesicnik : > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > #s.setdefaulttimeout(1) > s.connect((proxy,port)) I have never used socket but a quick look at the docs [1] my guess is that you should use use s.settimeout() [2]. The docs say that setdefaulttimeout [3] wi

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Lie Ryan
On 11/27/2009 8:57 PM, OkaMthembo wrote: Hi All, Is there a python implementation that takes advantage of all cores on modern multicore machines? yes, Cpython if you used "multiprocessing". Ironpython and Jython doesn't have GIL. Unladen Swallow plans to remove GIL. Many minor python branch

Re: [Tutor] Python best practices

2009-11-27 Thread Wayne Werner
On Fri, Nov 27, 2009 at 2:03 AM, Stefan Lesicnik wrote: > hihi! (two in 1 day!) > > Is there a document, pep, wiki etc that defines best practice for python > code? (maybe its more generic). > > This one is fairly comprehensive: http://www.python.org/dev/peps/pep-0008/ HTH, Wayne I keep stum

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Kent Johnson
On Fri, Nov 27, 2009 at 4:57 AM, OkaMthembo wrote: > Hi All, > > Is there a python implementation that takes advantage of all cores on modern > multicore machines? Presumably you mean something like, "Is there a python implementation that can run multiple compute-bound processes on multiple cores

Re: [Tutor] Python on multicore machines

2009-11-27 Thread OkaMthembo
Sorry to double -post, Lie. Didn;t "Reply to all".. Thats interesting - is Unladen Swallow production-ready? I've been over the site briefly, but i can't decide whether it's still in incubation or not. On Fri, Nov 27, 2009 at 3:04 PM, Lie Ryan wrote: > On 11/27/2009 8:57 PM, OkaMthembo wrote: >

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Stefan Behnel
Lie Ryan, 27.11.2009 14:04: > Unladen Swallow plans to remove GIL. Don't bet your money on it. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python on multicore machines

2009-11-27 Thread OkaMthembo
Thanks, i must admit the concept of the GIL is cloudy to me - for example, if the python interpreter on a single machine is handling one process and locks until it is done, then on to the next one, and so on - isn't that what causes speed issues? I was wondering why python can't implicitly handle m

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Stefan Behnel
Kent Johnson, 27.11.2009 14:38: > On Fri, Nov 27, 2009 at 4:57 AM, OkaMthembo wrote: >> Is there a python implementation that takes advantage of all cores on modern >> multicore machines? > > Presumably you mean something like, "Is there a python implementation > that can run multiple compute-boun

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Kent Johnson
On Fri, Nov 27, 2009 at 8:57 AM, OkaMthembo wrote: > Thanks, i must admit the concept of the GIL is cloudy to me - for example, > if the python interpreter on a single machine is > handling one process and locks until it is done, then on to the next one, > and so on - isn't that what causes speed

Re: [Tutor] Python on multicore machines

2009-11-27 Thread OkaMthembo
Thanks everyone, I realise that my question is vague on a few fronts. To try and clarify, supposing i had a box running a Python web app on it, and the web server handles say, 10 concurrent requests. Now i've read that only one instance of the Python interpreter can run on a single machine. Can t

Re: [Tutor] Python on multicore machines

2009-11-27 Thread OkaMthembo
Thanks Kent, that did clear some of the smog. >At least make sure you understand the difference between threads and processes. Will be taking that advice. I think it's the reason i struggle to ask the question better. On Fri, Nov 27, 2009 at 5:12 PM, Kent Johnson wrote: > On Fri, Nov 27, 2009

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Stefan Behnel
OkaMthembo, 27.11.2009 16:15: > i've read that only one > instance of the Python interpreter can run on a single machine. That's likely the source of your confusion then. You can run any number of Python interpreters on a single machine (limited by system resources like RAM, obviously), and in fa

Re: [Tutor] Python on multicore machines

2009-11-27 Thread OkaMthembo
> That's likely the source of your confusion then. You can run any number of > Python interpreters on a single machine (limited by system resources like > RAM, obviously), and in fact, many web servers will do that for you to > handle multiple requests in parallel. Thanks Stefan, i was not aware

Re: [Tutor] Python on multicore machines

2009-11-27 Thread Kent Johnson
On Fri, Nov 27, 2009 at 10:15 AM, OkaMthembo wrote: > Thanks everyone, > > I realise that my question is vague on a few fronts. To try and clarify, > supposing i had a box running a > Python web app on it, and the web server handles say, 10 concurrent > requests. This is still pretty vague, as th

[Tutor] AttributeError: Vector instance has no attribute 'Normalize'

2009-11-27 Thread Garrett Hartshaw
The program I am writing gives the following error message when run. Traceback (most recent call last):   File "./space.py", line 177, in     main()   File "./space.py", line 173, in main     player = Ship("space/models/fighter.3ds", "space/models/realistic.bmp", Quaternion(), Vector(0, 0, -30),

Re: [Tutor] AttributeError: Vector instance has no attribute 'Normalize'

2009-11-27 Thread bob gailer
Garrett Hartshaw wrote: The program I am writing gives the following error message when run. Traceback (most recent call last): File "./space.py", line 177, in main() File "./space.py", line 173, in main player = Ship("space/models/fighter.3ds", "space/models/realistic.bmp", Quatern

Re: [Tutor] unicode mapping doesn't work

2009-11-27 Thread spir
Lie Ryan wrote: > > funnychars = u"éèêëóòôöáàâäÉÈÊËÓÒÔÖÁÀÂÄ" > > asciichars = "" > > In addition to Lie's reply, you will very probably need diacritic-free chars to be unicode, too. Otherwise prepare for later UnocideEn/De-codeError-s. As a rule of thumb, if you work wi

Re: [Tutor] python time

2009-11-27 Thread spir
Kent Johnson wrote: > On Wed, Nov 25, 2009 at 11:11 AM, spir wrote: > > Hello, > > > > How does python get the time in microseconds? (In other words, how would I > > get it if python (like some other languages) would provide time in whole > > seconds only?) > > Use the source...in particular,

Re: [Tutor] AttributeError: Vector instance has no attribute 'Normalize'

2009-11-27 Thread spir
Garrett Hartshaw wrote: > The program I am writing gives the following error message when run. > > Traceback (most recent call last): >   File "./space.py", line 177, in >     main() >   File "./space.py", line 173, in main >     player = Ship("space/models/fighter.3ds", > "space/models/realist

Re: [Tutor] python time

2009-11-27 Thread Alan Gauld
"spir" wrote So, python uses C's gettimeofday() func when available It's not C's function, it's a Unix system call. It's been part of Unix since BSD 4.2 ftime() (millisecond), Also Unix and predates BSD 4.2... else it has only plain second precision using time(). Which is an ANSI C

Re: [Tutor] python time

2009-11-27 Thread spir
"Alan Gauld" wrote: Thank you, Alan. > "spir" wrote > > > So, python uses C's gettimeofday() func when available > > It's not C's function, it's a Unix system call. > It's been part of Unix since BSD 4.2 > > > ftime() (millisecond), > > Also Unix and predates BSD 4.2... I am confused he

Re: [Tutor] python time

2009-11-27 Thread Kent Johnson
On Fri, Nov 27, 2009 at 6:07 PM, spir wrote: > I am confused here. That's what I first thought (there _must_ be a way to get > time more precise that seconds!). But on my system (ubuntu 9.10) I cannot > find the proper manner to use these system calls. Even from the command-line > directly. Ce

Re: [Tutor] python time

2009-11-27 Thread Modulok
>> Doesn't time.time return a float? >> >> >>> import time >> >>> help(time.time) >> Help on built-in function time in module time: >> >> time(...) >> time() -> floating point number >> >> Return the current time in seconds since the Epoch. >> Fractions of a second may be present if the