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: 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: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

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 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

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: 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: 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-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: 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

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 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

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 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: 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: 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:/

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: 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

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: .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: 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: 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: .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: .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: 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 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: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: 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: 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 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 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 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: 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: 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: 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

<    1   2