Re: Threading with queues

2009-12-21 Thread Stephen Hansen
On Mon, Dec 21, 2009 at 3:24 PM, Stephen Hansen wrote: > This is indented over one indentation level too much. You want it to > be at the same level as the for above. Here, its at the same level > with "t" -- meaning this entire loop gets repeated five times. Err, "this" in this context meant the

Re: numpy performance and random numbers

2009-12-21 Thread Gib Bogle
sturlamolden wrote: On 19 Des, 22:58, sturlamolden wrote: If you pick two random states (using any PRNG), you need error- checking that states are always unique, i.e. that each PRNG never reaches the starting state of the other(s). Another note on this: Ideally, we would e.g. know how to fi

Re: Using Python to Execute a C or FORTRAN Program (Windows)

2009-12-21 Thread Gib Bogle
W. eWatson wrote: Mensanator wrote: On Dec 14, 8:14�pm, "W. eWatson" wrote: I think Python is capable of executing a compiled C or FORTRAN program, Sure, if it was compiled to an .exe file. and maybe even getting some parameters passed back. Sure, if the program prints to stdout. Does

Beginner question: binary data and socket.send

2009-12-21 Thread Boris Epel
Hi! Please help with the problem: send over TCPIP data packet organized as 6 bytes of identifier, integer (LSB) and length of following binary data, binary data the clear part: create socket, connect it, use send, close socket the unclear part: create string with required data to use with send wh

Re: Object Relational Mappers are evil (a meditation)

2009-12-21 Thread r0g
J Kenneth King wrote: > c) This has nothing to do with programming languages. A programmer that > lacks critical thinking is a bad programmer. The language they use has > no bearing on such human facilities. The language may well have a bearing on the quality of the programs generated though,

Re: Threading with queues

2009-12-21 Thread Gib Bogle
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 3:12 PM, Gib Bogle wrote: #spawn a pool of threads, and pass them queue instance for i in range(5): t = ThreadUrl(queue,i) t.setDaemon(True) t.start() #populate queue with data for host in hosts: queue.put(host) This is indent

Re: How to validate the __init__ parameters

2009-12-21 Thread Steven D'Aprano
On Mon, 21 Dec 2009 21:49:11 +, r0g wrote: > I use assertions myself e.g. > foo = "123456" assert len(foo) <= 5 > Traceback (most recent call last): > File "", line 1, in > AssertionError > > > Dunno if this would be considered good or bad programming practice by > those more e

Re: Object Relational Mappers are evil (a meditation)

2009-12-21 Thread Steven D'Aprano
On Mon, 21 Dec 2009 11:44:29 -0500, J Kenneth King wrote: > A programmer that > lacks critical thinking is a bad programmer. The language they use has > no bearing on such human facilities. That's nonsense, and I can demonstrate it by reference to a single programming language, namely Python.

Re: numpy performance and random numbers

2009-12-21 Thread Robert Kern
On 2009-12-21 16:57 PM, r0g wrote: sturlamolden wrote: On 19 Des, 16:20, Carl Johan Rehn wrote: How about mulit-core or (perhaps more exciting) GPU and CUDA? I must admit that I am extremely interested in trying the CUDA-alternative. Obviously, cuBLAS is not an option here, so what is the sa

Re: Threading with queues

2009-12-21 Thread Gib Bogle
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 3:12 PM, Gib Bogle wrote: #spawn a pool of threads, and pass them queue instance for i in range(5): t = ThreadUrl(queue,i) t.setDaemon(True) t.start() #populate queue with data for host in hosts: queue.put(host) This is indent

Re: Beginner question: binary data and socket.send

2009-12-21 Thread Stephen Hansen
On Mon, Dec 21, 2009 at 3:31 PM, Boris Epel wrote: > Hi! Please help with the problem: > send over TCPIP data packet organized as 6 bytes of identifier, > integer (LSB) and length of following binary data, binary data > the clear part:  create socket, connect it, use send, close socket > the uncle

Re: how to register with pypi

2009-12-21 Thread Martin v. Loewis
>> The key ID should be an eight-digit string, such as EA5BBD71 (i.e. a >> 32-bit key ID). > > pretend I was someone who had never ever used PGP before. > > pgp -kg, then what? I don't have pgp, only gpg. In gpg --list-keys, it's the 32-bit ID that gets listed. Try -kv. If you have never used P

Re: How to validate the __init__ parameters

2009-12-21 Thread r0g
Steven D'Aprano wrote: > On Mon, 21 Dec 2009 21:49:11 +, r0g wrote: > >> I use assertions myself e.g. >> > foo = "123456" > assert len(foo) <= 5 >> Traceback (most recent call last): >> File "", line 1, in >> AssertionError >> >> >> Dunno if this would be considered good or bad prog

Re: how to register with pypi

2009-12-21 Thread Phlip
If you have never used PGP before, you *really* shouldn't register a PGP key ID in PyPI. I suppose your key doesn't have any counter signatures, anyway. Nope, thanks, I'm already in. The pypi page could mark the field "optional". I just associated it, conceptually, with the Github SSH key, and

Re: Please Help Publicize PyCon

2009-12-21 Thread Horace Blegg
*Bitten once again by 'reply all', my apologies john.* Brilliant troll :D Well done! I, for one, am looking forward to watching the videos of the talks, since I can not attend myself (hi college education!). On Mon, Dec 21, 2009 at 9:31 AM, John Nagle wrote: > Steve Holden, Chairman, PSF wrot

PyTrie 0.1

2009-12-21 Thread George Sakkis
I'm pleased to announce the first release of PyTrie, a pure Python implementation of the trie (prefix tree) data structure [1]. Tries extend the mapping interface with methods that facilitate finding the keys/values/items for a given prefix, and vice versa, finding the prefixes (or just the longes

how to register with pypi - no such setup.py

2009-12-21 Thread Phlip
And the next question in the series - how to make sure the resulting package has a setup.py file? The basic steps are... - build a python package - create a minimal setup.py - (github it, natch) - throw it at pypi with: python setup.py bdist upload - attempt to install it with: s

Re: Windows, IDLE, __doc_, other

2009-12-21 Thread W. eWatson
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wrote: This has got to be some sort of IDLE issue then. Huh? How do you figure? When I run a simple program. If I open this program in the IDLE editor: #import math print "hello, math world." print cos(0.5) print sin(0.8) th

Re: C Structure rebuild with ctypes

2009-12-21 Thread Mark Tolonen
"Georg" wrote in message news:7padi2fsm...@mid.individual.net... Hi Mark, many thanks for your help. I tried your code in my program and it worked. I would like to understand what the code is doing and I have some questions to it. Are you passing in these values, or are they being returne

[no subject]

2009-12-21 Thread bruce
hi... the following sample is an attempt to fetch two subsequent pages from a sameple site. (it's public) the script attempts to implement a request, using the POST method, as well as as cookies. Testing using LiveHttpHeaders/Firefox indicates that the app uses post/cookies, and it doesn't work if

python - fetching, post, cookie question

2009-12-21 Thread bruce
hi... the following sample is an attempt to fetch two subsequent pages from a sameple site. (it's public) the script attempts to implement a request, using the POST method, as well as as cookies. Testing using LiveHttpHeaders/Firefox indicates that the app uses post/cookies, and it doesn't work if

Re: How to validate the __init__ parameters

2009-12-21 Thread Steve Holden
r0g wrote: > Steven D'Aprano wrote: >> On Mon, 21 Dec 2009 21:49:11 +, r0g wrote: >> >>> I use assertions myself e.g. >>> >> foo = "123456" >> assert len(foo) <= 5 >>> Traceback (most recent call last): >>> File "", line 1, in >>> AssertionError >>> >>> >>> Dunno if this would be con

Re: Python 3.1.1 installer botches upgrade when installation is not on C drive.

2009-12-21 Thread Gabriel Genellina
En Mon, 21 Dec 2009 15:25:05 -0300, John Nagle escribió: I just installed "python3.1.1.msi" on a system that had "python3.1.msi" installed in "D:/python31". The installer found the old installation in "D:/python31", partially trashed it, and then installed the new version in "C:/pyth

Re: Python-list Digest, Vol 75, Issue 226

2009-12-21 Thread Gabriel Genellina
En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal escribió: I am writing a script wherein I need to merge files into existing tar.gz files. Currently, I am using tarfile module. I extract the tar.gz to a tempdir and copy the new file there and re-compress all the files back into a tar.gz.

Re: numpy performance and random numbers

2009-12-21 Thread Gib Bogle
David Cournapeau wrote: On Sun, Dec 20, 2009 at 6:47 PM, Lie Ryan wrote: On 12/20/2009 2:53 PM, sturlamolden wrote: On 20 Des, 01:46, Lie Ryan wrote: Not necessarily, you only need to be certain that the two streams don't overlap in any reasonable amount of time. For that purpose, you can u

Re: which pi formula is given in the decimal module documentation?

2009-12-21 Thread Steven D'Aprano
Nice work! But I have a question... On Mon, 21 Dec 2009 20:40:40 +, Albert van der Horst wrote: > def pi4(): > ' Calculate pi by a 5th order process, with favorable stop > criterion' > precision = 10e-20 Why do you say 10e-20 instead of 1e-19? -- Steven -- http://mail.pytho

Re: which pi formula is given in the decimal module documentation?

2009-12-21 Thread Gabriel Genellina
En Mon, 21 Dec 2009 17:40:40 -0300, Albert van der Horst escribió: In article , Albert van der Horst wrote: In article , Mark Dickinson wrote: After a cup of coffee, it's much clearer: this just comes from the Taylor series for arcsin(x), applied to x = 1/2 to get asin(1/2) = pi/6.

ScrolledText get xy index of rowheader component?

2009-12-21 Thread J Wolfe
Hi, I tried to get the xycoordinate of a click of the rowheader column of Pmw's ScrolledText...and it returns the xycoordinate of the text portion...even though I supplied it with the rowheader component. self.scrolledtext.component('rowheader').index("@%d,%d" % (event.x,event.y)) What am I doin

Re: How to validate the __init__ parameters

2009-12-21 Thread Steven D'Aprano
On Tue, 22 Dec 2009 00:18:21 +, r0g wrote: > Yikes, glad to be set me straight on that one! Thanks :) It's a pity > though, I really like the way it reads. Is there anything similar with > ISN'T disabled when optimizations are turned on? Yes: an explicit test-and-raise. if not condition:

Re: which pi formula is given in the decimal module documentation?

2009-12-21 Thread Steven D'Aprano
On Tue, 22 Dec 2009 04:04:56 +, Albert van der Horst wrote: > In article <00b967e1$0$15623$c3e8...@news.astraweb.com>, Steven D'Aprano > wrote: >>Nice work! But I have a question... >> >>On Mon, 21 Dec 2009 20:40:40 +, Albert van der Horst wrote: >> >>> def pi4(): >>> ' Calculate pi

more efficient?

2009-12-21 Thread Zubin Mithra
I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystring output = ''.join(mystring) i heard that string concatenat

OT Question

2009-12-21 Thread Victor Subervi
Hi; Back when I worked with Zope, they had this nifty form element where I could select from a list of elements on the right and click an arrow to make them go into a list on the left. I need to add this functionality to the store I am creating. What is it called? TIA, beno -- http://mail.python.o

Re: C Structure rebuild with ctypes

2009-12-21 Thread Georg
Hi Mark, many thanks for your valuable help. >>> # numVars contains size of returned arrays. Recast to access. >>> varNamesArray = c.cast(varNames,c.POINTER(PCHAR * numVars.value)) >>> varTypesArray = c.cast(varTypes,c.POINTER(INT * numVars.value)) One last question: You created an object varNa

Re: more efficient?

2009-12-21 Thread Gabriel Genellina
En Tue, 22 Dec 2009 03:13:38 -0300, Zubin Mithra escribió: I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystri

Re: Regex help needed!

2009-12-21 Thread Johann Spies
> Oltmans wrote: > >I've a string that looks something like > > > >lksjdfls kdjff lsdfs sdjfls >= "amazon_35343433">sdfsdwelcome > > > > > >>From above string I need the digits within the ID attribute. For > >example, required output from above string is > >- 35343433 > >- 345343 > >-

<    1   2