Re: executing multiple functions in background simultaneously

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: > I would like to spawn off multiple instances of a function > and run them simultaneously and then wait until they all complete. > Currently I'm doing this by calling them as sub-processes > executable from the command-line. Is there a w

Programming friction

2009-01-13 Thread killsto
I'm trying to implement a basic user controlled sliding box with pygame. I have everything worked out, except for two things. The acceleration is changed once a second (for meters/second) this leads to very jumpy movement. I need to add a way to check how long it takes the program to loop and mult

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread alex23
On Jan 14, 10:45 am, "Russ P." wrote: > The Wikipedia entry for "object-oriented programming" also lists > encapsulation as a "fundamental concept." The Wikipedia entry for "encapsulation" defines it as "the grouping together of data and functionality". That sounds like Python classes & modules

Re: Programming friction

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:29 AM, killsto wrote: > I'm trying to implement a basic user controlled sliding box with > pygame. I have everything worked out, except for two things. Try the pygame mailing list :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: executing multiple functions in background simultaneously

2009-01-13 Thread MRAB
James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing this by calling them as sub-processes executable from the command-lin

Re: executing multiple functions in background simultaneously

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:35 AM, MRAB wrote: > The disadvantage of threads in Python (CPython, actually) is that > there's the GIL (Global Interpreter Lock), so you won't get any speed > advantage if the threads are mostly processor-bound. The OP didn't really say what this function does :) *sig

Re: New Python 3.0 string formatting - really necessary?

2009-01-13 Thread Arlo Belshee
For R, and others who haven't read the PEP or worked a lot with the web, here are some really strong advantages of the new string formatting over the old. Note: I'm not saying that you have to use one or the other. I'm just pointing out some of the things that the new format gives us - things whic

Re: are there some special about '\x1a' symbol

2009-01-13 Thread Grant Edwards
On 2009-01-12, John Machin wrote: > I didn't think your question was stupid. Stupid was (a) CP/M recording > file size as number of 128-byte sectors, forcing the use of an in-band > EOF marker for text files (b) MS continuing to regard Ctrl-Z as an EOF > decades after people stopped writing Ctrl-

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Russ P.
On Jan 13, 5:29 pm, alex23 wrote: > On Jan 14, 10:45 am, "Russ P." wrote: > > > The Wikipedia entry for "object-oriented programming" also lists > > encapsulation as a "fundamental concept." > > The Wikipedia entry for "encapsulation" defines it as "the grouping > together of data and functionali

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-13 Thread Ivan Illarionov
Ben Sizer wrote: > What am I doing wrong? What are you trying to achieve? If you want to modify sys.path I suggest using Python/C API directly: (boilerplate removed) PyImport_ImportModule("sys") PyObject_GetAttrString(sysmod_pointer, "path") PyList_Insert(pathobj_pointer, 0, path_python_str) --

problem calling method

2009-01-13 Thread pieterprovoost
I'm trying to call a method within my wx frame, but that doesn't seem to work. What am I doing wrong? class MyFrame(wx.Frame): def __init__(self, *args, **kwds): self.Bind(wx.EVT_BUTTON, self.test, self.testbutton) ... def sendmail(self): ... def test(self, even

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:50 AM, Russ P. wrote: > Here's the definition on the Wikipedia page for object oriented > programming (and it does *not* sound like Python classes): > > Encapsulation conceals the functional details of a class from objects > that send messages to it. ... Encapsulation is

Re: ctype problem

2009-01-13 Thread Mark Tolonen
"Aaron Brady" wrote in message news:6197f37d-0ea0-4430-a466-2f36b2011...@v42g2000yqj.googlegroups.com... On Jan 13, 10:22 am, Grimson wrote: hello out there, I have a problem with c-types. I made a c-library, which expects a pointer to a self defined structure. let the funtion call myfuncti

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-13 Thread Christian Heimes
Ivan Illarionov schrieb: > Ben Sizer wrote: >> What am I doing wrong? > > What are you trying to achieve? > If you want to modify sys.path I suggest using Python/C API directly: > (boilerplate removed) > PyImport_ImportModule("sys") > PyObject_GetAttrString(sysmod_pointer, "path") > PyList_Insert

Re: why cannot assign to function call

2009-01-13 Thread Aaron Brady
On Jan 13, 5:06 pm, Mark Wooding wrote: snip > I'm going to move away from the formal semantics stuff and try a > different tack.  Here's what I think is the defining property of > pass-by-value (distilled from the formal approach I described earlier, > but shorn of the symbolism): > >   The calle

Re: Programming friction

2009-01-13 Thread Jervis Whitley
On Wed, Jan 14, 2009 at 12:29 PM, killsto wrote: > > force. So lets say I am slowing down at a rate of -2m/s^2, if I hit 1, > the next number will be -1 and I shoot off in the other direction. How > do I fix this an still have backwards movement? > -- > http://mail.python.org/mailman/listinfo/pyt

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Paul Rubin
"James Mills" writes: > You do realize this is a model and not strictly a requirement. Quite > a few things in Python are done merely by convention. > Don't get caught up. But, if something is done by convention, then departing from the convention is by definition unconventional. If you do somet

Re: problem calling method

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:28 AM, wrote: > class MyFrame(wx.Frame): >def __init__(self, *args, **kwds): It might be helpful here if you called the parent __init__. Like so: class MyFrame(wx.Frame): def __init__(self, *args, **kwds): super(MyFrame, self).__init__(*args, **kwargs) .

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 12:27 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "James Mills" writes: >> You do realize this is a model and not strictly a requirement. Quite >> a few things in Python are done merely by convention. >> Don't get caught up. > > But, if something is done by con

Re: urllib2 - 403 that _should_ not occur.

2009-01-13 Thread ajaksu
On Jan 13, 1:33 am, Philip Semanchuk wrote: > I don't think I understand you clearly. Whether or not Google et al   > whitelist the Python UA isn't a Python issue, is it? Hi, sorry for taking so long to reply :) I imagine it's something akin to Firefox's 'Report broken website': evangelism. IMH

Re: Standard IPC for Python?

2009-01-13 Thread Philip Semanchuk
On Jan 13, 2009, at 6:41 PM, Mel wrote: Philip Semanchuk wrote: I'm working on message queue support, but the Sys V IPC API is a headache and takes longer to code against than the POSIX API. I hadn't found it that bad. I have a C extension I should perhaps clean up and make public. Ha

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Terry Reedy
Russ P. wrote: On Jan 13, 5:29 pm, alex23 wrote: On Jan 14, 10:45 am, "Russ P." wrote: The Wikipedia entry for "object-oriented programming" also lists encapsulation as a "fundamental concept." The Wikipedia entry for "encapsulation" defines it as "the grouping together of data and function

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 12:57 PM, Terry Reedy wrote: > public = no leading underscore > private = one leading underscore > protected = two leading underscores > > Python uses encapsulation by convention rather than by enforcement. As mentioned previously this is not encapsulation, but access cont

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Russ P.
On Jan 13, 6:04 pm, "James Mills" wrote: > On Wed, Jan 14, 2009 at 11:50 AM, Russ P. wrote: > > Here's the definition on the Wikipedia page for object oriented > > programming (and it does *not* sound like Python classes): > > > Encapsulation conceals the functional details of a class from object

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Rhodri James
On Wed, 14 Jan 2009 02:27:09 -, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: But, if something is done by convention, then departing from the convention is by definition unconventional. If you do something unconventional in a program, it could be on purpose for a reason, or it could

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:18 PM, Russ P. wrote: > Yes, but the fact that you can approximate OO programming in a > particular language does not make that language object oriented. You > can approximate OO programming in C, but that does not mean that C is > an OO language. Wrong. Not having stric

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread r
> public = no leading underscore > private = one leading underscore > protected = two leading underscores > > Python uses encapsulation by convention rather than by enforcement. Very well said Terry! I like that python does not force me to do "everything" but does force things like parenthesis in

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:25 PM, Rhodri James wrote: > I wouldn't violently object to having some means of policing class > or module privacy, but it does have consequences. When it's a > convention, you can break it; when it isn't, you can't, even if > you do have good reason. Add that to the o

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:31 PM, r wrote: >> public = no leading underscore >> private = one leading underscore >> protected = two leading underscores >> >> Python uses encapsulation by convention rather than by enforcement. > > Very well said Terry! > > I like that python does not force me to do

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Carl Banks
On Jan 13, 6:45 pm, "Russ P." wrote: > On Jan 13, 3:07 pm, Carl Banks wrote: > > > I've seen no evidence that any Python project is moving even remotely > > toward data encapsulation.  That would be a drastic change.  Even if > > it were only a minor change in the implementation (and it would not

Re: urllib2 - 403 that _should_ not occur.

2009-01-13 Thread Philip Semanchuk
On Jan 13, 2009, at 9:42 PM, ajaksu wrote: On Jan 13, 1:33 am, Philip Semanchuk wrote: I don't think I understand you clearly. Whether or not Google et al whitelist the Python UA isn't a Python issue, is it? Hi, sorry for taking so long to reply :) I imagine it's something akin to Firefox'

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Carl Banks
On Jan 13, 9:50 pm, Carl Banks wrote: > The cultural impact that would have on the > community is far worse, IMHO, than any short-sighted benefits like > being able to catch an accidental usage of an internal variable. > Trust would be replaced by mistrust, and programming in Python would > go fro

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:50 PM, Carl Banks wrote: > 1. Wise people don't believe everything that is written on Wikipedia. > 2. The person who wrote that line in Python.org is a wise person. Agreed. > You know what? Computer science buzzwords mean jack squat to me. I > don't give a horse's tai

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread r
On Jan 13, 9:50 pm, Carl Banks wrote: [snip] it gives > the library implementor the power to dictate to the user how they can > and can't use the library.  The cultural impact that would have on the > community is far worse, IMHO, than any short-sighted benefits like > being able to catch an accid

Re: Standard IPC for Python?

2009-01-13 Thread drobi...@gmail.com
On Jan 13, 5:08 pm, Philip Semanchuk wrote: > On Jan 13, 2009, at 4:31 PM, drobi...@gmail.com wrote: > > > On Jan 13, 2:37 pm, Philip Semanchuk wrote: > >> I was suggesting getting posix_ipc or sysv_ipc to compile against a > >> compatibility library (Cygwin?) under Windows. It sounds like you're

Re: Weird behaviour re: Python on Windows

2009-01-13 Thread Jerry Hill
On Tue, Jan 13, 2009 at 5:29 PM, Kevin Jing Qiu wrote: > I've been experiencing weird behavior of Python's os module on Windows: > > Here's the environment: > Box1: Running Windows 2003 Server with Apache+mod_python > Box2: Running Windows 2003 Server with Zope/Plone and Z:\ mapped to D:\ > on Box

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Roy Smith
In article , "Russ P." wrote: > I can claim that Python is not strictly object oriented until it > gets encapsulation (in the sense of data hiding). That is simply a > fact, and no amount of pleading or obfuscation will change it. I have no idea if Python is strictly anything. What I do know

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Russ P.
On Jan 13, 7:50 pm, Carl Banks wrote: > On Jan 13, 6:45 pm, "Russ P." wrote: > > > > > On Jan 13, 3:07 pm, Carl Banks wrote: > > > > I've seen no evidence that any Python project is moving even remotely > > > toward data encapsulation.  That would be a drastic change.  Even if > > > it were only

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread r
Here is a piece of C code this same guy showed me saying Pythonic indention would make this hard to read -- Well lets see then! I swear, before god, this is the exact code he showed me. If you don't believe me i will post a link to the thread. // Warning ugly C code ahead! if( is_opt_data() < si

Re: Standard IPC for Python?

2009-01-13 Thread Philip Semanchuk
On Jan 13, 2009, at 11:26 PM, drobi...@gmail.com wrote: On Jan 13, 5:08 pm, Philip Semanchuk wrote: On Jan 13, 2009, at 4:31 PM, drobi...@gmail.com wrote: On Jan 13, 2:37 pm, Philip Semanchuk wrote: I was suggesting getting posix_ipc or sysv_ipc to compile against a compatibility library

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Russ P.
On Jan 13, 7:32 pm, "James Mills" wrote: > On Wed, Jan 14, 2009 at 1:18 PM, Russ P. wrote: > > Yes, but the fact that you can approximate OO programming in a > > particular language does not make that language object oriented. You > > can approximate OO programming in C, but that does not mean th

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:11 PM, Russ P. wrote: (...) >> Give me one use-case where you strictly require >> that members of an object be private and their >> access enforced as such ? > > You're kidding, right? Think about a ten-million line program being > developed by 100 developers. No I"m so

Re: executing multiple functions in background simultaneously

2009-01-13 Thread Michele Simionato
On Jan 14, 2:02 am, Catherine Moroney wrote: > Hello everybody, > > I know how to spawn a sub-process and then wait until it > completes.  I'm wondering if I can do the same thing with > a Python function. > > I would like to spawn off multiple instances of a function > and run them simultaneously

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Russ P.
On Jan 13, 7:50 pm, Carl Banks wrote: > You know what?  Computer science buzzwords mean jack squat to me.  I > don't give a horse's tail whether some people label it a fundamental > concept of object-oriented programming or not.  I think it's a bad > thing.  And it's a bad thing for exactly the r

initialising a class by name

2009-01-13 Thread Krishnakant
hello all, I have a strange situation where I have to load initiate an instance of a class at run-time with the name given by the user from a dropdown list. Is this possible in python and how? To make things clear, let me give the real example. there is an inventory management system and products b

Re: initialising a class by name

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 9:46 PM, Krishnakant wrote: > hello all, > I have a strange situation where I have to load initiate an instance of > a class at run-time with the name given by the user from a dropdown > list. > Is this possible in python and how? > To make things clear, let me give the rea

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:11 PM, Russ P. wrote: > I think you are the one who is confused. Part of the problem here is > that the term "encapsulation" has at least two widely used meanings > (in the context of programming). In one sense, it just means grouping > data and methods together. In anoth

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:35 PM, Russ P. wrote: > You know what? The more I think about the kind of nonsense you and > others are spouting here, the more annoyed I get. I will gladly agree > that encapsulation may be more trouble than it's worth for small > applications, maybe even some medium siz

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Paul Rubin
"James Mills" writes: > Bare in mind also, that enfocing access control / policing as you > called it has a performance hit as the machine (the Python vm) > has to perform checks each time members of an object are accessed. It's the other way around. If the compiler knows that you aren't creatin

pep 8 constants

2009-01-13 Thread Brendan Miller
PEP 8 doesn't mention anything about using all caps to indicate a constant. Is all caps meaning "don't reassign this var" a strong enough convention to not be considered violating good python style? I see a lot of people using it, but I also see a lot of people writing non-pythonic code... so I th

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 4:35 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "James Mills" writes: >> Bare in mind also, that enfocing access control / policing as you >> called it has a performance hit as the machine (the Python vm) >> has to perform checks each time members of an object

Re: pep 8 constants

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 4:49 PM, Brendan Miller wrote: > PEP 8 doesn't mention anything about using all caps to indicate a constant. > > Is all caps meaning "don't reassign this var" a strong enough > convention to not be considered violating good python style? I see a > lot of people using it, bu

Re: urllib2 - 403 that _should_ not occur.

2009-01-13 Thread Steve Holden
ajaksu wrote: > On Jan 13, 1:33 am, Philip Semanchuk wrote: >> I don't think I understand you clearly. Whether or not Google et al >> whitelist the Python UA isn't a Python issue, is it? > > Hi, sorry for taking so long to reply :) > > I imagine it's something akin to Firefox's 'Report broken

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Steven D'Aprano
On Wed, 14 Jan 2009 15:25:38 +1000, James Mills wrote: > On Wed, Jan 14, 2009 at 3:11 PM, Russ P. wrote: > (...) > >>> Give me one use-case where you strictly require that members of an >>> object be private and their access enforced as such ? >> >> You're kidding, right? Think about a ten-milli

read string in bits

2009-01-13 Thread ts
hi, is there a way to read a character/string into bits in python? i understand that character is read in bytes. Do i have to write a function to convert it myself into 1010101 or there is a library in python that enable me to do that? -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Paul Rubin
"James Mills" writes: > Python is a dynamic object oriented language ... (almost verbatim > from the website). It is compiled to bytecode and run on a virtual > machine. 1. There is nothing inherent about dynamic languages that prevents them from being compiled. There are compiled implementatio

Re: pep 8 constants

2009-01-13 Thread Brendan Miller
> FOO = 1 > > def f(x=FOO): > ... > > > Use this instead: > > def f(x=1): > ... I tend to use constants as a means of avoiding the proliferation of magic literals for maintenance reasons... Like say if your example of FOO would have been used in 10 places. Maybe it is more pythonic to simply

Re: read string in bits

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 11:21 PM, ts wrote: > hi, is there a way to read a character/string into bits in python? > > i understand that character is read in bytes. Do i have to write a > function to convert it myself into 1010101 or there is a library in > python that enable me to do that? It's no

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Carl Banks
On Jan 13, 11:35 pm, "Russ P." wrote: > I suggest you call Boeing and tell them that encapsulation is more > trouble than it's worth for their 787 flight software. But please > don't do it if you ever wish to work for them, because you will be > proving conclusively that you don't have a clue abou

Re: are there some special about '\x1a' symbol

2009-01-13 Thread Steve Holden
Unknown wrote: > On 2009-01-12, John Machin wrote: > >> I didn't think your question was stupid. Stupid was (a) CP/M recording >> file size as number of 128-byte sectors, forcing the use of an in-band >> EOF marker for text files (b) MS continuing to regard Ctrl-Z as an EOF >> decades after peopl

Re: WebDAV client module

2009-01-13 Thread Vincent Gulinao
Um.. and I can't seem to find any sample code of it around. Can anybody share a simple snippet of how to use it? I don't understand what's URI in PutFile method is suppose to be. TIA. On Tue, Jan 13, 2009 at 8:03 PM, Vincent Gulinao wrote: > Kindly point me to a good WebDAV client module for Py

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Steven D'Aprano
On Tue, 13 Jan 2009 20:17:08 -0800, Carl Banks wrote: > On Jan 13, 9:50 pm, Carl Banks wrote: >> The cultural impact that would have on the community is far worse, >> IMHO, than any short-sighted benefits like being able to catch an >> accidental usage of an internal variable. Trust would be repl

Re: read string in bits

2009-01-13 Thread ts
On Jan 14, 3:32 pm, Chris Rebert wrote: > On Tue, Jan 13, 2009 at 11:21 PM, ts wrote: > > hi, is there a way to read a character/string into bits in python? > > > i understand that character is read in bytes. Do i have to write a > > function to convert it myself into 1010101 or there is a librar

Re: initialising a class by name

2009-01-13 Thread Krishnakant
On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote: > Assuming all the classes are in the same module as the main program: > > instance = vars()[class_name](args, to, init) > The classes are not in the same module. Every glade window is coupled with one py file (module) containing one class th

Re: initialising a class by name

2009-01-13 Thread Steven D'Aprano
On Wed, 14 Jan 2009 11:16:58 +0530, Krishnakant wrote: > hello all, > I have a strange situation where I have to load initiate an instance of > a class at run-time with the name given by the user from a dropdown > list. Not strange at all. > Is this possible in python and how? Of course. Just u

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-13 Thread Paul Rubin
Carl Banks writes: > At GE there was no encapsulation in sight on any system I worked on. > In fact, our engine simulation was a special-purpose object-oriented > language with--get this--no private variables. Some other systems I > worked on didn't even use scoping, let alone encapsulation. Whe

Re: initialising a class by name

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 11:49 PM, Krishnakant wrote: > On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote: >> Assuming all the classes are in the same module as the main program: >> >> instance = vars()[class_name](args, to, init) >> > The classes are not in the same module. > Every glade windo

<    1   2