Re: Custom Classes?

2008-05-01 Thread Victor Subervi
On Wed, Apr 30, 2008 at 12:35 PM, J. Cliff Dyer <[EMAIL PROTECTED]> wrote: > Post working code, and I'll answer your actual question. Good grief! The code is *not* double spaced! Take a look. Click to the end of the first line and hit the right arrow key, and see for yourself. As for not initi

Re: is +=1 thread safe

2008-05-01 Thread Gary Herron
AlFire wrote: Hi, I have a piece of software which uses threads in very massive way - like hundreds of them generated every second. there is also a piece of code which maintains the number of outstanding threads, simply counter+=1 is executed when before starting the thread and counter-=1

Re: dropping win98 support? was Re: Python 2.6 and wrapping C libraries on Windows

2008-05-01 Thread Terry Reedy
"illume" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Ah, why is that? Were any of the reasons given in http://www.python.org/dev/peps/pep-0011/ unclear? It appears you are already aware of MS's non-support of Win98 | Seems like a lot of people using it, so it's still worthwhil

Pep11

2008-05-01 Thread Terry Reedy
The syllable link at the bottem is not currently working. The site itself is still alive and distributing 2.5.1 terry -- http://mail.python.org/mailman/listinfo/python-list

Re: where do I begin with web programming in python?

2008-05-01 Thread Graham Dumpleton
On May 2, 7:45 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > jmDesktop schrieb: > > > I have been to the main python site, but am still confused. I have > > been using .net, so it may be obvious how to do this to everyone > > else. I am aware there are various frameworks (Django, Pylons, etc.

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Torsten Bronger
Hallöchen! Ivan Illarionov writes: > [...] > > For me it looks more like an old-school/new-school thing than > use-case thing. I may be wrong, but I see more and more new > projects use things like reST and YAML/JSON and it feels like they > are gradually replacing traditional old-school solution

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Carl Banks
On May 1, 4:50 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On Thu, 01 May 2008 11:56:20 -0700, Carl Banks wrote: > > On May 1, 1:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > >> On Thu, 01 May 2008 09:45:28 -0700, Carl Banks wrote: > >> > On May 1, 12:11 pm, Jon Ribbens <[EMAIL PROTECTED

Up to the minute gizmo and gadget news and reviews!

2008-05-01 Thread gizmohackers
Come check out this new site on the latest news and reviews on gizmos and gadgets! http://gizmohacker.com/ -- http://mail.python.org/mailman/listinfo/python-list

RegEx for matching brackets

2008-05-01 Thread NevilleDNZ
Below is a (flawed) one line RegEx that checks curly brackets (from awk/c/python input) are being matched. Is there a one liner for doing this in python? ThanX N re_open_close="(((\{))[^{}]*((?(0)\})))+" re_open_close=re.compile(re_open_close) tests=""" { this is a test BAD { this is a test

Re: where do I begin with web programming in python?

2008-05-01 Thread George Sakkis
On May 1, 7:13 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On May 2, 7:45 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > > > jmDesktop schrieb: > > > > I have been to the main python site, but am still confused.  I have > > > been using .net, so it may be obvious how to do this to ever

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 16:32:00 -0700, Carl Banks wrote: > On May 1, 4:50 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> On Thu, 01 May 2008 11:56:20 -0700, Carl Banks wrote: >> > On May 1, 1:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> >> On Thu, 01 May 2008 09:45:28 -0700, Carl Banks wro

Re: where do I begin with web programming in python?

2008-05-01 Thread Paul Rubin
jmDesktop <[EMAIL PROTECTED]> writes: > I am aware there are various frameworks (Django, Pylons, etc.), > but I would like to know how to create web pages without these. If I > have mod_python or fastcgi on apache, where do I start? I don't have > clue where to begin to create a web page from scr

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Fri, 02 May 2008 01:21:38 +0200, Torsten Bronger wrote: > Hallöchen! > > Ivan Illarionov writes: > >> [...] >> >> For me it looks more like an old-school/new-school thing than use-case >> thing. I may be wrong, but I see more and more new projects use things >> like reST and YAML/JSON and it

Re: RegEx for matching brackets

2008-05-01 Thread John Machin
On May 2, 9:44 am, NevilleDNZ <[EMAIL PROTECTED]> wrote: > Below is a (flawed) one line RegEx that checks curly brackets (from > awk/c/python input) are being matched. Is there a one liner for doing > this in python? > > ThanX > N > > re_open_close="(((\{))[^{}]*((?(0)\})))+" > re_open_close=re.co

Problems with psycopg2

2008-05-01 Thread David Anderson
Hi all I have this function: def checkName(self, name): cur = self.conn.cursor() sql = "SELECT * from patient WHERE fn_pat = '" + name + "'" cur.execute(sql) rows = cur.fetchall() if rows == "[]": self.insert() It seems to work fine, But I'm ge

TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

2008-05-01 Thread Jordan Harry
I'm trying to write a simple program to calculate permutations. I created a file called "mod.py" and put the following in it: def factorial(n): a = n b = n while a>0 and b>1: n = (n)*(b-1) b = b-1 def perm(n, r): a = factorial(n) b = factorial(n-r) q =

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Carl Banks
On May 1, 7:54 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > No, all I want is to give the OP a useful alternative Fair enough, I can't argue with that. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: RegEx for matching brackets

2008-05-01 Thread George Sakkis
On May 1, 7:44 pm, NevilleDNZ <[EMAIL PROTECTED]> wrote: > Below is a (flawed) one line RegEx that checks curly brackets (from > awk/c/python input) are being matched. Is there a one liner for doing > this in python? There is not even a 1000-liner regular expression for this; it's a context-free

Re: TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

2008-05-01 Thread Sean DiZazzo
On May 1, 5:21 pm, "Jordan Harry" <[EMAIL PROTECTED]> wrote: > I'm trying to write a simple program to calculate permutations.  I created a > file called "mod.py" and put the following in it: > > def factorial(n): >     a = n >     b = n >     while a>0 and b>1: >         n = (n)*(b-1) >         b

Re: TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

2008-05-01 Thread Ben Finney
"Jordan Harry" <[EMAIL PROTECTED]> writes: > I'm trying to write a simple program to calculate permutations. I > created a file called "mod.py" and put the following in it: > > def factorial(n): > a = n > b = n > while a>0 and b>1: > n = (n)*(b-1) > b = b-1 A functio

#!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Yves Dorfsman
On UNIX, some people use #!/usr/bin/env python While other use #!/usr/bin/python Why is one preferred over the other one ? Thanks. -- Yves. http://www.SollerS.ca -- http://mail.python.org/mailman/listinfo/python-list

portable fork+exec/spawn

2008-05-01 Thread Brendan Miller
I want to spawn a child process based on an external executable that I have the path for. I then want to wait on that executable, and capture it's output. In the os module, fork is only supported on unix, but spawn is only supported on windows. The os.system call is implemented by calling the C s

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread J Sisson
The first method allows python to be installed in an alternate location (i.e. /usr/local/bin). "env" in this case is being used to launch python from whatever location python is installed to. I like to think of it as an "abstraction" of the python location to make it "multiplatform-friendly" sinc

help with list comprehension

2008-05-01 Thread Yves Dorfsman
In the following script, m1() and m2() work fine. I am assuming m2() is faster although I haven't checked that (loops through the list twice instead of once). Now what I am trying to do is something like m3(). As currently written it does not work, and I have tried different ways, but I have

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Ben Finney
Yves Dorfsman <[EMAIL PROTECTED]> writes: > On UNIX, some people use > #!/usr/bin/env python > > While other use > #!/usr/bin/python You haven't indicated your understanding of what the difference in meaning is, so I'll explain it for those who might not know. The shebang line (the initial line

Re: portable fork+exec/spawn

2008-05-01 Thread Ben Finney
Brendan Miller <[EMAIL PROTECTED]> writes: > Is there an actual portable means of asynchronously spawning a > process and getting a handle to it, being able to write stdin and > read stdout, or does everyone just write their own wrapper for fork > and spawn? You're looking for the 'subprocess' mo

Re: how to pass C++ object to another C++ function via Python function

2008-05-01 Thread grbgooglefan
On Apr 22, 7:54 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > If you have a C function that receives a PyCObject, just include the   > relevant headers (cobject.h) and you can retrieve the original pointer   > using PyCObject_AsVoidPtr: > > void foo(PyObject *pyobj) > { >    TOriginalType

Re: help with list comprehension

2008-05-01 Thread Carsten Haese
Yves Dorfsman wrote: In the following script, m1() and m2() work fine. I am assuming m2() is faster although I haven't checked that (loops through the list twice instead of once). Well, let's check it: $ python -m timeit -s "import x" "x.m1()" 10 loops, best of 3: 6.43 usec per loop $

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote: > I've never clearly understood why people want to use "#! /usr/bin/env > python", which is prone to finding a different Python from the one > installed by the operating system. I'd be interested to see what > responses are in

no cleanup on TERM signal

2008-05-01 Thread Yves Dorfsman
I did a few tests with this script: class byebye: def __del__(self): print 'Bye, bye...' x = byebye() x.del() gets executed if: -I del x, then run gc.collect() -simply exit the script -get the script to abort on an exception But if I kill it with the default signal TERM, the script di

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread D'Arcy J.M. Cain
On Fri, 02 May 2008 13:24:01 +1000 Ben Finney <[EMAIL PROTECTED]> wrote: > I much prefer "#! /usr/bin/python" because I want my Python programs > to, by default, be run with the default Python, and depend on Python > being installed by the operating system's package manager. On systems > that use s

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Torsten Bronger
Hallöchen! Ivan Illarionov writes: > On Fri, 02 May 2008 01:21:38 +0200, Torsten Bronger wrote: > >> [...] >> >> In contrast to many other areas of software, configuration files >> needn't be compatible with anything except the user's brain. So >> even if the rest of the world uses config forma

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Jeroen Ruigrok van der Werven
-On [20080502 05:26], Ben Finney ([EMAIL PROTECTED]) wrote: >I've never clearly understood why people want to use "#! /usr/bin/env >python", which is prone to finding a different Python from the one >installed by the operating system. I'd be interested to see what >responses are in favour of it, an

Re: help with list comprehension

2008-05-01 Thread Karthik Gurusamy
On May 1, 8:01 pm, Yves Dorfsman <[EMAIL PROTECTED]> wrote: > In the following script, m1() and m2() work fine. I am assuming m2() is > faster although I haven't checked that (loops through the list twice instead > of once). > > Now what I am trying to do is something like m3(). As currently writte

Re: portable fork+exec/spawn

2008-05-01 Thread Brendan Miller
On Fri, 02 May 2008 13:25:55 +1000, Ben Finney wrote: > URL:http://docs.python.org/lib/module-subprocess.html Awesome. This is exactly what I was hoping existed. -- http://mail.python.org/mailman/listinfo/python-list

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Tim Roberts
Yves Dorfsman <[EMAIL PROTECTED]> wrote: > >On UNIX, some people use >#!/usr/bin/env python > >While other use >#!/usr/bin/python > >Why is one preferred over the other one ? The /usr/bin/env solution finds the Python interpreter anywhere on the PATH, whether it be /usr/bin or /usr/local/bin, or w

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Ben Finney
Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> writes: > -On [20080502 05:26], Ben Finney ([EMAIL PROTECTED]) wrote: > >I've never clearly understood why people want to use "#! > >/usr/bin/env python", which is prone to finding a different Python > >from the one installed by the operating syste

Re: help with list comprehension

2008-05-01 Thread George Sakkis
On May 1, 11:46 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > Yves Dorfsman wrote: > > > In the following script, m1() and m2() work fine. I am assuming m2() is > > faster although I haven't checked that (loops through the list twice > > instead of once). > > Well, let's check it: > > $ python -m

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-01 Thread Ben Finney
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > On Fri, 02 May 2008 13:24:01 +1000 > Ben Finney <[EMAIL PROTECTED]> wrote: > > I much prefer "#! /usr/bin/python" because I want my Python > > programs to, by default, be run with the default Python, and > > depend on Python being installed by the o

Re: help with list comprehension

2008-05-01 Thread Matimus
On May 1, 10:50 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On May 1, 11:46 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > > > > Yves Dorfsman wrote: > > > > In the following script, m1() and m2() work fine. I am assuming m2() is > > > faster although I haven't checked that (loops through the

Re: no cleanup on TERM signal

2008-05-01 Thread Marc 'BlackJack' Rintsch
On Fri, 02 May 2008 04:36:06 +, Yves Dorfsman wrote: > x.del() gets executed if: > -I del x, then run gc.collect() > -simply exit the script > -get the script to abort on an exception > > But if I kill it with the default signal TERM, the script dies, but I don't > get the message, so I am a

<    1   2