Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread John Yeung
On Jun 10, 1:52 am, Steven D'Aprano wrote: > On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote: > > Therefore, to me the most up-to-date docs (which say > > that uniform(a, b) returns a float in the closed > > interval [a, b]) is closer to correct than before, > > but still fails to point out t

Re: How to insert string in each match using RegEx iterator

2009-06-09 Thread Peter Otten
504cr...@gmail.com wrote: > By what method would a string be inserted at each instance of a RegEx > match? > > For example: > > string = '123 abc 456 def 789 ghi' > newstring = ' INSERT 123 abc INSERT 456 def INSERT 789 ghi' Have a look at re.sub(): >>> s = '123 abc 456 def 789 ghi' >>> re.com

Re: graph edge generators

2009-06-09 Thread CTO
On Jun 9, 11:58 pm, William Clifford wrote: > I've become interested in basic graphs and networks and I'm wondering > about what algorithms are there for generating basic regular graphs > like the simplex graph or dodecahedron graph, etc (I'm sure there are > many). I'm particularly keen on unders

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Mensanator
On Jun 9, 11:28�pm, Steven D'Aprano wrote: > On Tue, 09 Jun 2009 21:04:49 -0700, Mensanator wrote: > > On Jun 9, 8:28 pm, John Yeung wrote: > >> On Jun 9, 8:45 pm, Mensanator wrote: > > >> > On Jun 9, 6:05 pm, "Gabriel Genellina" > >> > wrote: > >> > > py> a+(b-a)*z < b # the expression used fo

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote: The docs are now... sort of correct. For some values of a and b, uniform() can never return b. Notably, I believe uniform(0, 1) is equivalent to random(), and will never return 1. However, uniform(1, 2) CAN retur

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote: > On Jun 9, 11:24 pm, Steven D'Aprano > wrote: >> On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote: >> > The docs are now... sort of correct.  For some values of a and b, >> > uniform() can never return b.  Notably, I believe uniform(0, 1)

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread John Yeung
On Jun 10, 12:01 am, alex23 wrote: > On Jun 10, 11:32 am, John Yeung wrote: > > > On Jun 9, 8:39 pm, Paul McGuire wrote: > > > Are you trying to generate a number in the > > > range [0,n] by multiplying a random function that > > > returns [0,1] * n?  If so, then you want to do > > > this using:

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread John Yeung
On Jun 9, 11:24 pm, Steven D'Aprano wrote: > On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote: > > The docs are now... sort of correct.  For some values of a and b, > > uniform() can never return b.  Notably, I believe uniform(0, 1) is > > equivalent to random(), and will never return 1.  Howe

Re: How to insert string in each match using RegEx iterator

2009-06-09 Thread 504cr...@gmail.com
On Jun 9, 11:35 pm, "504cr...@gmail.com" <504cr...@gmail.com> wrote: > On Jun 9, 11:19 pm, Roy Smith wrote: > > > > > In article > > , > > >  "504cr...@gmail.com" <504cr...@gmail.com> wrote: > > > By what method would a string be inserted at each instance of a RegEx > > > match? > > > > For exampl

Re: .pth files and figuring out valid paths..

2009-06-09 Thread David Lyon
On Tue, 9 Jun 2009 21:33:56 -0700 (PDT), rh0dium wrote: >> Having multiple paths or multiple .PTH files isn't a >> problem for python. > .. > We use it for our dev tree before we roll to production. Once dev is > QA'd then we (integrate) those changes to main and release. Makes sense... :-)

Re: How to insert string in each match using RegEx iterator

2009-06-09 Thread 504cr...@gmail.com
On Jun 9, 11:19 pm, Roy Smith wrote: > In article > , > >  "504cr...@gmail.com" <504cr...@gmail.com> wrote: > > By what method would a string be inserted at each instance of a RegEx > > match? > > > For example: > > > string = '123 abc 456 def 789 ghi' > > newstring = ' INSERT 123 abc INSERT 456 d

Re: .pth files and figuring out valid paths..

2009-06-09 Thread rh0dium
On Jun 9, 4:58 pm, David Lyon wrote: > On Tue, 9 Jun 2009 16:30:06 -0700 (PDT), rh0dium > wrote: > > >> > Apparently there is a problem with the if statement??? > > >> > Thanks > > > No for .pth files this needs to be on a single line.. > > I can't really see why you need conditional code... > >

Re: .pth files and figuring out valid paths..

2009-06-09 Thread rh0dium
On Jun 9, 9:19 pm, alex23 wrote: > On Jun 10, 8:00 am, rh0dium wrote: > > > Apparently there is a problem with the if statement??? > > Try restructuring the if as a ternary condition: > > import os, site; smsc = os.environ.get("TECHROOT", "/home/tech"); smsc > = smsc if os.path.isdir(smsc) else "

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 21:04:49 -0700, Mensanator wrote: > On Jun 9, 8:28�pm, John Yeung wrote: >> On Jun 9, 8:45�pm, Mensanator wrote: >> >> > On Jun 9, 6:05�pm, "Gabriel Genellina" >> > wrote: >> > > py> a+(b-a)*z < b # the expression used for uniform(a,b) False >> > > py> a+(b-a)*z >> > > 11.0

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Here is part of the specification of an algorithm I'm implementing that shows the reason for my original query: vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a) xid = xid + vid (1b) where c1 and c2 are two positive constants, rand() and Rand() are two random functi

Re: .pth files and figuring out valid paths..

2009-06-09 Thread alex23
On Jun 10, 8:00 am, rh0dium wrote: > Apparently there is a problem with the if statement??? Try restructuring the if as a ternary condition: import os, site; smsc = os.environ.get("TECHROOT", "/home/tech"); smsc = smsc if os.path.isdir(smsc) else "/home/tech"; site.addsitedir (os.path.join(smsc,

Re: How to insert string in each match using RegEx iterator

2009-06-09 Thread Roy Smith
In article , "504cr...@gmail.com" <504cr...@gmail.com> wrote: > By what method would a string be inserted at each instance of a RegEx > match? > > For example: > > string = '123 abc 456 def 789 ghi' > newstring = ' INSERT 123 abc INSERT 456 def INSERT 789 ghi' If you want to do what I think y

Re: graph edge generators

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 20:58:54 -0700, William Clifford wrote: > I've become interested in basic graphs and networks and I'm wondering > about what algorithms are there for generating basic regular graphs like > the simplex graph or dodecahedron graph, etc (I'm sure there are many). > I'm particularl

How to insert string in each match using RegEx iterator

2009-06-09 Thread 504cr...@gmail.com
By what method would a string be inserted at each instance of a RegEx match? For example: string = '123 abc 456 def 789 ghi' newstring = ' INSERT 123 abc INSERT 456 def INSERT 789 ghi' Here's the code I started with: >>> rePatt = re.compile('\d+\s') >>> iterator = rePatt.finditer(string) >>> co

Re: Start the interactive shell within an application

2009-06-09 Thread alex23
On Jun 10, 1:40 am, Ben Charrow wrote: > If you're looking to debug your program, try "import pdb" Another option, if you wish to debug an error, is to run python using the -i parameter. This will leave you inside the interpreter at the point that execution stops. Very handy. - alex23 -- http:/

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread AggieDan04
On Jun 9, 4:33 pm, Esmail wrote: > Hi, > > random.random() will generate a random value in the range [0, 1). > > Is there an easy way to generate random values in the range [0, 1]? > I.e., including 1? You could do random.uniform(0, 1.0002). Due to floating- point rounding, there are

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Mensanator
On Jun 9, 8:28�pm, John Yeung wrote: > On Jun 9, 8:45�pm, Mensanator wrote: > > > On Jun 9, 6:05�pm, "Gabriel Genellina" wrote: > > > py> a+(b-a)*z < b # the expression used for uniform(a,b) > > > False > > > py> a+(b-a)*z > > > 11.0 > > > What you do with the number after it's created is not >

Re: graph edge generators

2009-06-09 Thread Rafael
William Clifford writes: > I've become interested in basic graphs and networks and I'm wondering > about what algorithms are there for generating basic regular graphs > like the simplex graph or dodecahedron graph, etc (I'm sure there are > many). I'm particularly keen on understanding the very b

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread alex23
On Jun 10, 11:32 am, John Yeung wrote: > On Jun 9, 8:39 pm, Paul McGuire wrote: > > Are you trying to generate a number in the > > range [0,n] by multiplying a random function that > > returns [0,1] * n?  If so, then you want to do > > this using: int(random.random()*(n+1))  This will > > give eq

graph edge generators

2009-06-09 Thread William Clifford
I've become interested in basic graphs and networks and I'm wondering about what algorithms are there for generating basic regular graphs like the simplex graph or dodecahedron graph, etc (I'm sure there are many). I'm particularly keen on understanding the very basic functions for determining edge

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote: > The docs are now... sort of correct. For some values of a and b, > uniform() can never return b. Notably, I believe uniform(0, 1) is > equivalent to random(), and will never return 1. However, uniform(1, 2) > CAN return 2, if this is any i

Re: multi-core software

2009-06-09 Thread Arved Sandstrom
Jon Harrop wrote: Arved Sandstrom wrote: Jon Harrop wrote: Arved Sandstrom wrote: Lew wrote: Interesting distinction. Would it be fair to compare concurrent programming to the bricks used to build the parallel program's edifice? Way too much of a fine distinction. While they are in fact dif

Re: Any idea of stopping the execution of PyRun_File()

2009-06-09 Thread kongcheng1400
On Jun 10, 7:41 am, "Gabriel Genellina" wrote: > En Mon, 08 Jun 2009 22:15:22 -0300, BigHand escribió: > > >    I have an embedded python application. which is  a MFC app with > > Python interpreter embedded. > > >    In the App, I have a separate thread to execute a Python script > > (using the

Re: multi-thread python interpreaters and c++ program

2009-06-09 Thread myopc
thanks for your reply! "Lie Ryan" $y61.12...@news-server.bigpond.net.au... myopc wrote: hi, all I am ruuning a c++ program (boost python) , which create many python interpreaters and each run a python script with use multi-thread (threading). when the c++ main program exit, I want to shut dow

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread John Yeung
On Jun 9, 8:39 pm, Paul McGuire wrote: > Are you trying to generate a number in the > range [0,n] by multiplying a random function that > returns [0,1] * n?  If so, then you want to do > this using: int(random.random()*(n+1))  This will > give equal chance of getting any number from 0 to n. Bette

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread John Yeung
On Jun 9, 8:45 pm, Mensanator wrote: > On Jun 9, 6:05 pm, "Gabriel Genellina" wrote: > > py> a+(b-a)*z < b # the expression used for uniform(a,b) > > False > > py> a+(b-a)*z > > 11.0 > > What you do with the number after it's created is not > random's concern. Mensanator, you missed Gabriel's po

Where should I store docs in my project?

2009-06-09 Thread Matthew Wilson
I used paster to create a project named pitz. I'm writing a bunch of user documentation. Where should I put it? The project looks a little like this: /home/matt/projects/pitz setup.py pitz/ __init__.py # has my project code docs/ # has my reST files

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Mensanator
On Jun 9, 6:05 pm, "Gabriel Genellina" wrote: > En Tue, 09 Jun 2009 18:33:39 -0300, Esmail escribió: > > > random.random() will generate a random value in the range [0, 1). > > > Is there an easy way to generate random values in the range [0, 1]? > > I.e., including 1? > > I think you shouldn't w

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Paul McGuire
On Jun 9, 4:33 pm, Esmail wrote: > Hi, > > random.random() will generate a random value in the range [0, 1). > > Is there an easy way to generate random values in the range [0, 1]? > I.e., including 1? > Are you trying to generate a number in the range [0,n] by multiplying a random function that

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Mensanator
On Jun 9, 6:12 pm, Robert Kern wrote: > On 2009-06-09 18:05, Mensanator wrote: > > > > > > > On Jun 9, 4:33 pm, Esmail  wrote: > >> Hi, > > >> random.random() will generate a random value in the range [0, 1). > > >> Is there an easy way to generate random values in the range [0, 1]? > >> I.e., inc

Re: .pth files and figuring out valid paths..

2009-06-09 Thread David Lyon
On Tue, 9 Jun 2009 16:30:06 -0700 (PDT), rh0dium wrote: >> > Apparently there is a problem with the if statement??? >> >> > Thanks > > No for .pth files this needs to be on a single line.. I can't really see why you need conditional code... If you want to add more locations... Simply create a

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Miles Kaufmann wrote: I'm curious what algorithm calls for random numbers on a closed interval. I'm implementing a Particle Swarm Optimizer. Depending on what paper you read you'll see mention of required random values "between 0 and 1" which is somewhat ambiguous. I came across one paper that

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Robert Kern wrote: On 2009-06-09 18:05, Mensanator wrote: On Jun 9, 4:33 pm, Esmail wrote: That's wrong. Where did you get it? http://docs.python.org/library/random What he said :-) (thanks Robert) -- http://mail.python.org/mailman/listinfo/python-list

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Gabriel Genellina wrote: En Tue, 09 Jun 2009 18:33:39 -0300, Esmail escribió: random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I think you shouldn't worry about that - the difference may

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 04:57:48 -0700, samwyse wrote: > Time to test things! I'm going to compare three things using Python > 3.0: > X={...}\nS=lambda x: x in X > S=lambda x: x in {...} > S=lambda x: x in (...) > where the ... is replaced by lists of integers of various lengths. > Here's the

Re: Any idea of stopping the execution of PyRun_File()

2009-06-09 Thread Gabriel Genellina
En Mon, 08 Jun 2009 22:15:22 -0300, BigHand escribió: I have an embedded python application. which is a MFC app with Python interpreter embedded. In the App, I have a separate thread to execute a Python script (using the PyRun_File), but if the user want to stop the executing script, ho

Re: .pth files and figuring out valid paths..

2009-06-09 Thread rh0dium
On Jun 9, 3:28 pm, Emile van Sebille wrote: > On 6/9/2009 3:00 PM rh0dium said... > > > > > > > I have a .pth file which has some logic in it - but it isn't quite > > enough... > > > It started with this.. > > import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], > > "tools/python/

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Miles Kaufmann
On Jun 9, 2009, at 7:05 PM, Mensanator wrote: On Jun 9, 4:33 pm, Esmail wrote: Hi, random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I am implementing an algorithm and want to stay as true

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Robert Kern
On 2009-06-09 18:05, Mensanator wrote: On Jun 9, 4:33 pm, Esmail wrote: Hi, random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I am implementing an algorithm and want to stay as true to the

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Mensanator
On Jun 9, 4:33 pm, Esmail wrote: > Hi, > > random.random() will generate a random value in the range [0, 1). > > Is there an easy way to generate random values in the range [0, 1]? > I.e., including 1? > > I am implementing an algorithm and want to stay as true to the > original design specificati

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Gabriel Genellina
En Tue, 09 Jun 2009 18:33:39 -0300, Esmail escribió: random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I think you shouldn't worry about that - the difference may be as small as 2**-53, o

Re: .pth files and figuring out valid paths..

2009-06-09 Thread Emile van Sebille
On 6/9/2009 3:00 PM rh0dium said... I have a .pth file which has some logic in it - but it isn't quite enough... It started with this.. import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], "tools/python/modules")) But that eventually evolved into.. import os, site; site.addsite

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Robert Kern
On 2009-06-09 17:06, Carl Banks wrote: On Jun 9, 12:42 pm, Terry Reedy wrote: Hendrik van Rooyen wrote: I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. That is symmetry. There is no string method

Re: Function/method returning list of chars in string?

2009-06-09 Thread Robert Kern
On 2009-06-09 16:34, Terry Reedy wrote: Robert Kern wrote: On 2009-06-09 14:43, Terry Reedy wrote: jon vs. python wrote: Python and the stdlib is all open source. If he were to submit a patch, and it were ignored or rejected for whatever reason, he could still release it and register it on P

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Carl Banks
On Jun 9, 12:42 pm, Terry Reedy wrote: > Hendrik van Rooyen wrote: > > I should have known - you use a string method to get a list of words, > > but you have to go to the list to get a list of characters from a string. > > That is symmetry. > > > There is no string method to do it, which is what I

.pth files and figuring out valid paths..

2009-06-09 Thread rh0dium
I have a .pth file which has some logic in it - but it isn't quite enough... It started with this.. import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], "tools/python/modules")) But that eventually evolved into.. import os, site; site.addsitedir(os.path.join(os.environ.get ("TECH

Re: multi-core software

2009-06-09 Thread Emile van Sebille
On 6/9/2009 11:59 AM Jon Harrop said... toby wrote: On Jun 7, 2:41 pm, Jon Harrop wrote: No. Most programmers still care about performance Frequently when they shouldn't. I disagree. A lot of software is still far too slow because the programmers failed to pay attention to performance.

Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
Robert Kern wrote: On 2009-06-09 14:43, Terry Reedy wrote: jon vs. python wrote: Python and the stdlib is all open source. If he were to submit a patch, and it were ignored or rejected for whatever reason, he could still release it and register it on PyPI. I just checked and NONE of the 6710

random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Hi, random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I am implementing an algorithm and want to stay as true to the original design specifications as possible though I suppose the difference

Re: multi-core software

2009-06-09 Thread Dimiter "malkia" Stanev
Erlang uses quite a bit of mutable state behind the scenes ... the programmers just don't see it. George Heh... "The CPUs use quite a bit of mutable state behind the scenes ... the programmers just don't see it." Actually with CPU they see it more, than... say Erlang (that's why you need to

Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Bret
Thanks John, I didn't realize that the quotes were supposed to surround the entire field. I ended up making a quick script to replace comma's outside quotes with tabs. I was just trying to clean this crazy "csv" file to import into msyql. thanks again, bret -- http://mail.python.org/mailman/l

Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Terry Reedy
Bret wrote: i have a csv file like so: row1,field1,[field2][text in field2 "quote, quote"],field3,field row2,field1,[field2]text in field2 "quote, quote",field3,field using csv.reader to read the file, the first row is broken into two fields: [field2][text in field2 "quote and quote" while the

Re: setting program name, like $0= in perl?

2009-06-09 Thread Daniel Fetchinson
> I'm sure this is a FAQ, but I certainly haven't been able > to find an answer. > > Is it possible to set the program name as seen by the > operating system or lower-level libraries? > > I'm connecting to a database, and the runtime helpfully > sends some information to the server, such as usernam

Re: setting program name, like $0= in perl?

2009-06-09 Thread Emile van Sebille
On 6/9/2009 1:06 PM m...@pixar.com said... I'm sure this is a FAQ, but I certainly haven't been able to find an answer. Is it possible to set the program name as seen by the operating system or lower-level libraries? I'm connecting to a database, and the runtime helpfully sends some information

Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread John Machin
Bret gmail.com> writes: > > i have a csv file like so: > row1,field1,[field2][text in field2 "quote, quote"],field3,field > row2,field1,[field2]text in field2 "quote, quote",field3,field > > using csv.reader to read the file, the first row is broken into two > fields: > [field2][text in field2

Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
Miles Kaufmann wrote: On Jun 9, 2009, at 6:05 AM, Diez B. Roggisch wrote: Also as list-comps are going away and are replaced by list() Where did you hear that? Perhaps in the discussion of possible changes for 3.0 about 18 months ago. The idea was rejected because set/list/dict(genexp) i

Re: Function/method returning list of chars in string?

2009-06-09 Thread Robert Kern
On 2009-06-09 14:43, Terry Reedy wrote: jon vs. python wrote: Sorry, I didn't realize that you already proposed list comprehension. There is some kind of asymmetry in several areas.I guess that's somehow related to this post: http://www.zedshaw.com/blog/2009-05-29.html The premise of this po

Re: multi-core software

2009-06-09 Thread George Neuner
On Tue, 9 Jun 2009 10:47:11 -0700 (PDT), toby wrote: >On Jun 7, 2:41 pm, Jon Harrop wrote: >> Arved Sandstrom wrote: >> > Jon Harrop wrote: >> >> performance means mutable state. > >Hm, not sure Erlangers would wholly agree. Erlang uses quite a bit of mutable state behind the scenes ... the pro

setting program name, like $0= in perl?

2009-06-09 Thread mh
I'm sure this is a FAQ, but I certainly haven't been able to find an answer. Is it possible to set the program name as seen by the operating system or lower-level libraries? I'm connecting to a database, and the runtime helpfully sends some information to the server, such as username, pid, and pr

Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
jon vs. python wrote: Sorry, I didn't realize that you already proposed list comprehension. There is some kind of asymmetry in several areas.I guess that's somehow related to this post: http://www.zedshaw.com/blog/2009-05-29.html The premise of this post by Zed the Insightful is that Python

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
Hendrik van Rooyen wrote: I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. That is symmetry. There is no string method to do it, which is what I am complaining about. That would be asymmetry.

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
> That works for me.  There isn't an "InterruptedSystemCall" error or > equivalent in the standard exception hierarchy.  EnvironmentError is > the parent of OSError & IOError, which is where you'll most likely be > encountering that state. Thanks! --Steve -- http://mail.python.org/mailman/listinf

Re: Start the interactive shell within an application

2009-06-09 Thread Robert Kern
On 2009-06-09 03:49, Jean-Michel Pichavant wrote: I was wondering if there is a way to start an interactive shell within a script/application. I'm sometimes tired of adding prints to scan the current namespace so I'd like to pause the execution and give the user the shell prompt. This is obviousl

csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Bret
i have a csv file like so: row1,field1,[field2][text in field2 "quote, quote"],field3,field row2,field1,[field2]text in field2 "quote, quote",field3,field using csv.reader to read the file, the first row is broken into two fields: [field2][text in field2 "quote and quote" while the second row is

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread Jeff McNeil
On Jun 9, 2:22 pm, mrstevegross wrote: > I'm trying to write a try/catch block to handle an "interrupted system > call". However, I can't seem to locate information on the actual > typename of the exception. Does anyone know what it would be? I want > my code to look like this: > > try: >   ... >

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread Jean-Michel Pichavant
mrstevegross wrote: I'm trying to write a try/catch block to handle an "interrupted system call". However, I can't seem to locate information on the actual typename of the exception. Does anyone know what it would be? I want my code to look like this: try: ... except InterruptedSystemCall # wh

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
> exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError >... > exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__ Is there a single parent exception to all those? Or should I just write it as: try: ... catch Exception: ... Thanks, --Steve -- http://

Re: Using logging module to log into flash drive

2009-06-09 Thread Carl Banks
On Jun 9, 8:57 am, kretel wrote: > Hi All, > > I am trying to implement the following functionality: > 1. log messages to the flash drive > 2. if the flash drive is not available, switch handler to the > BufferringHandler and log into buffer, > 3. once the flash drive is plugged in and available s

Re: multi-core software

2009-06-09 Thread Jon Harrop
toby wrote: > On Jun 7, 2:41 pm, Jon Harrop wrote: >> Arved Sandstrom wrote: >> > Jon Harrop wrote: >> >> I see no problem with mutable shared state. >> >> > In which case, Jon, you're in a small minority. >> >> No. Most programmers still care about performance > > Frequently when they shouldn't.

Re: Unbuffered keyboard input?

2009-06-09 Thread Jerry Hill
On Tue, Jun 9, 2009 at 1:52 PM, Ken D'Ambrosio wrote: > I need to have some non-buffered keyboard interaction with a Python script > (on Linux). Assuming you're running your code from a command prompt, something like this recipe might do the trick: http://code.activestate.com/recipes/134892/ --

Re: Unbuffered keyboard input?

2009-06-09 Thread Grant Edwards
On 2009-06-09, Ken D'Ambrosio wrote: > I need to have some non-buffered keyboard interaction with a Python script > (on Linux). Back in the day, I fired up Curses to do this in Perl. Any > idea if that's still how I have to fly? Or is there a different > mechanism? Same as it ever was (in the

spawning a process using os.spawn

2009-06-09 Thread rkmr...@gmail.com
hi im spawning a script that runs for a long from a web app like this: os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ) the script is spawned and it runs, but till it gets over i am not able to free the port that is used by the web app, or in other words i

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Terry Reedy
m...@pixar.com wrote: John Machin wrote: T=lambda x:x in(25401,25402,25408);import dis;dis.dis(L);dis.dis(T) I've learned a lot from this thread, but this is the niftiest bit I've picked up... thanks! If you are doing a lot of dissing, starting with from dis import dis saves subsequent typi

Re: Function/method returning list of chars in string?

2009-06-09 Thread Miles Kaufmann
On Jun 9, 2009, at 6:05 AM, Diez B. Roggisch wrote: Also as list-comps are going away and are replaced by list() Where did you hear that? -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Terry Reedy
Steven D'Aprano wrote: James Tauber explains this at http://jtauber.com/blog/2006/04/15/ python_tuples_are_not_just_constant_lists/>. He doesn't really explain anything though, he merely states it as revealed wisdom. The closest he comes to an explanation is to declare that in tuples "the i

What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
I'm trying to write a try/catch block to handle an "interrupted system call". However, I can't seem to locate information on the actual typename of the exception. Does anyone know what it would be? I want my code to look like this: try: ... except InterruptedSystemCall # what's the right name?

Re: Using logging module to log into flash drive

2009-06-09 Thread Krzysztof Retel
> > Anyway there's a TimedRotatingFileHandler handler in the logging package: > > you can derive from it and change the emit/doRollover pair to hold the > > records > > until a device is not ready. > > Hm, that might be the way to go. Will have a try. I had another look at the logging package. Th

Re: Unbound Method Error

2009-06-09 Thread Piet van Oostrum
> "Enrico" <4...@755189.45> (E) wrote: >E> "Piet van Oostrum" ha scritto nel messaggio >E> news:m2ljo1ajnx@cs.uu.nl... >>> The method doesn't need the class at all, so a staticmethod would be >>> preferable: >>> class Funcoes: >>> @staticmethod >>> def CifradorDeCesar(self, mensagem, chav

Unbuffered keyboard input?

2009-06-09 Thread Ken D'Ambrosio
I need to have some non-buffered keyboard interaction with a Python script (on Linux). Back in the day, I fired up Curses to do this in Perl. Any idea if that's still how I have to fly? Or is there a different mechanism? Thanks! -Ken -- This message has been scanned for viruses and dangero

Re: pylint naming conventions?

2009-06-09 Thread Esmail
R. David Murray wrote: Well, I for one looked at that long pylint output when I first tried it, and switched to another tool :) (pyflakes...but I don't think it does PEP 8) :-) Ok, so I'm not the only one who thinks the output is rather lengthy. I've since dug into the docs and searched on

Re: multi-core software

2009-06-09 Thread toby
On Jun 7, 2:41 pm, Jon Harrop wrote: > Arved Sandstrom wrote: > > Jon Harrop wrote: > >> I see no problem with mutable shared state. > > > In which case, Jon, you're in a small minority. > > No. Most programmers still care about performance Frequently when they shouldn't. > and performance means

Re: Using logging module to log into flash drive

2009-06-09 Thread Krzysztof Retel
On Jun 9, 6:10 pm, "A. Cavallo" wrote: > Hi, > the problem screams for a separate thread. I was thinking about that, as mentioned in the first post. Although, I was wonder if there is another way to tackle the problem. > Anyway there's a TimedRotatingFileHandler handler in the logging package:

Re: Unbound Method Error

2009-06-09 Thread Chris Rebert
On Tue, Jun 9, 2009 at 8:19 AM, Scott David Daniels wrote: > lczancanella wrote: >> >> Hi, i am brand new in Python, so sorry if this question is too basic, >> but i have tried a lot and dont have success... I have the following >> code... >> >> class Funcoes: >>    def CifradorDeCesar(mensagem, ch

Re: Using logging module to log into flash drive

2009-06-09 Thread A. Cavallo
Hi, the problem screams for a separate thread. Anyway there's a TimedRotatingFileHandler handler in the logging package: you can derive from it and change the emit/doRollover pair to hold the records until a device is not ready. Regards, Antonio On Tuesday 09 June 2009 16:57:00 kretel wrote:

python and getopt and spaces in option

2009-06-09 Thread David Shapiro
Hello, I have been trying to find an example of how to deal with options that have spaces in them. I am using jython, which is the same I think as python 2.2.3. I feebly tried to use optparse and argparse with no success (got gettext, locale, and optparse). The code is as follows: try

Re: multi-thread python interpreaters and c++ program

2009-06-09 Thread Lie Ryan
myopc wrote: > hi, all > I am ruuning a c++ program (boost python) , which create many python > interpreaters and each run a python script with use multi-thread > (threading). > when the c++ main program exit, I want to shut down python > interpreaters, but it crashed. I have googled a lot but can

Re: preferring [] or () in list of error codes?

2009-06-09 Thread mh
John Machin wrote: > T=lambda x:x in(25401,25402,25408);import dis;dis.dis(L);dis.dis(T) I've learned a lot from this thread, but this is the niftiest bit I've picked up... thanks! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Carl Banks
On Jun 9, 8:20 am, samwyse wrote: > On Jun 9, 12:30 am, Emile van Sebille wrote: > > > On 6/8/2009 8:43 PM Ben Finney said... > > > The fact that literal set syntax is a relative newcomer is the primary > > > reason for that, I'd wager. > > > Well, no.  It really is more, "that's odd... why use s

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Carl Banks
On Jun 9, 4:57 am, samwyse wrote: > On Jun 8, 8:57 pm, samwyse wrote: > > > I conclude that using constructors is generally a bad idea, since the > > compiler doesn't know if you're calling the builtin or something with > > an overloaded name.  I presume that the compiler will eventually > > opti

Re: Start the interactive shell within an application

2009-06-09 Thread Ben Charrow
If you're looking to debug your program, try "import pdb" and then wherever you want to debug put: pdb.set_trace() Your program will then enter the debugger when it executes that line. It's quite nice really. If you get confused on what to do, just type "help" http://docs.python.org/library/pd

Using logging module to log into flash drive

2009-06-09 Thread kretel
Hi All, I am trying to implement the following functionality: 1. log messages to the flash drive 2. if the flash drive is not available, switch handler to the BufferringHandler and log into buffer, 3. once the flash drive is plugged in and available store the logs from BufferHandler into that flas

Re: List comprehension and string conversion with formatting

2009-06-09 Thread stephen_b
On Jun 9, 10:43 am, Carl Banks wrote: > You need a % in there, chief. > > Carl Banks You are so right. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension and string conversion with formatting

2009-06-09 Thread Jaime Fernandez del Rio
On Tue, Jun 9, 2009 at 5:38 PM, stephen_b wrote: > I'd like to convert a list of floats to a list of strings constrained > to one .1f format. These don't work. Is there a better way? > > [".1f" % i for i in l] > or > [(".1f" % i) for i in l] There's a missing %, this does work... ["%.1f" % i for

Re: List comprehension and string conversion with formatting

2009-06-09 Thread Carl Banks
On Jun 9, 8:38 am, stephen_b wrote: > I'd like to convert a list of floats to a list of strings constrained > to one .1f format. These don't work. Is there a better way? > > [".1f" % i for i in l] > or > [(".1f" % i) for i in l] You need a % in there, chief. [ "%.1f" % x for x in lst ] BTW, I t

List comprehension and string conversion with formatting

2009-06-09 Thread stephen_b
I'd like to convert a list of floats to a list of strings constrained to one .1f format. These don't work. Is there a better way? [".1f" % i for i in l] or [(".1f" % i) for i in l] StephenB -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >