Re: Poor man's OCR: need performance improvement tips
On 24 Sep 2005, at 19:14, qvx wrote: > Hi all, > > > 4. Process each line: compare pixels of each letter of alphabet with > corresponding pixels in line of input picture. This consists of loops > comparing pixel by pixel. This is my performance bottleneck. > > I'm using PIL for initial image processing. But then I use plain > Python > loops for pixel matrix comparision. One nice optimization was to call > PIL.Image.getdata() at the begining and then use data[y*w+x] > instead of > PIL.Image.getpixel(xy). I would like to compare each character raster > with corresponding image pixels in a "single operation" and avoid > (Python) loops. > > Oh, one more thing. Letter raster matrices have varying width and > constant height (due to proportional width font which is used). This > compare function should signal if there is a single different pixel. > > Any library that can do that? > > > Here is how I expected to solve this problem in C++. Each line of text > (and letter) has height below 16 pixels. It can be artificially made > into 16 pixels. I planned to linearize each letter's matrix by > columns. > Imagine leter with pixel indices numbered like this: > > 00 10 20 > 01 11 21 > 02 12 22 > 03 13 23 > .. .. .. > 0f 1f 2f > > I would convert it into 00 01 02 03 04 05 ... 2e 2f. Since each pixel > is one bit wide, each column would be 2 octets long. I would do the > same to the line of text of input picture. Then i would have to > compare > two buffers of length equal to the length of character. After > successfull match, I would advance "input" stream by that number of > bytes. Presumably you don't care about alignment and kerning and other things currently. If you haven't tried Psyco yet, try it. If you read the image in rotated 90 degrees then the data is linearised how you want it already. You could then just pack it into an integer and compare that, or look it up in a dictionary even. e.g. char = lookup[data[n:n+2]] where n is the left (or bottom, we rotated in 90 degrees remember?) and 2 is me assuming PIL will not encode each pixel as entire byte in a 1bpp image. I would of thought that would be pretty quick as long as you could get the alignment reliable enough. I hope this makes some actual sense, I have 0 OCR experience tbh. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Performance
On 9 Oct 2005, at 19:04, Bruno Desthuilliers wrote: > Laszlo Zsolt Nagy a écrit : > > >> Dave wrote: >> >> >> >>> Hello All, >>> >>> I would like to gather some information on Python's runtime >>> performance. As far as I understand, it deals with a lot of string >>> objects. Does it require a lot string processing during program >>> execution? How does it handle such time-consuming operations? Is >>> there >>> a way to find out how many string operations (perhaps in the >>> underlying system) ) it does during program execution? >>> >>> >> >> >> Do you want to know how many internal string operations are done >> inside >> the Python interpreter? I believe it is not a useful information. >> There >> are benchmarks testing the *real performance* of Python. >> >> For example: http://www.osnews.com/story.php?news_id=5602 >> >> >> > > A benchmark stating that Python is interpreted is bullshit. > > Except it is interpreted. What is your point? Python != C -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Performance
On 12 Oct 2005, at 09:33, bruno modulix wrote: > Donn Cave wrote: > >> Quoth "Fredrik Lundh" <[EMAIL PROTECTED]>: >> | Alex Stapleton wrote >> | >> | > Except it is interpreted. >> | >> | except that it isn't. Python source code is compiled to byte >> code, which >> | is then executed by a virtual machine. if the byte code for a >> module is up >> | to date, the Python runtime doesn't even look at the source code. >> >> Fair to say that byte code is interpreted? Seems to require an >> application we commonly call an interpreter. >> > > If so, Java is interpreted too. The only difference between Java and > Python here is that Python is smart enough to call the compiler by > itself. All languages are interpreted by something. Even x86 is interpreted by the CPU. This has been said already. Python and Java are both as distant from the machines native language, unless your using a cunning VM which does native code compilation. BASIC is in fact, lower level than Python or Java because it's VM interprets the actual source code, rather than translating it to "bytecode" first, and then interpreting that. You can see that the entire, interpreted vs compiled debate is utterly meaningless and that only implementation specific details actually matter. e.g. Java is native if you compile it with GCJ. x86 is interpreted if you run it under a VM like VirtualPC. Technical terminology generally fails to actually describing anything accurately for very long. -- http://mail.python.org/mailman/listinfo/python-list
Re: Hygenic Macros
I seem to remember a rather ugly hack at some point in the past that created a new "operator" like so A |dot| B where dot was an object which had the OR operator for left and right arguments redefined seperately so that it only made sense when used in that syntax. I guess you could hack something together along the same lines. I just wish I could remember what it was called, it's on the ActiveState Cookbook somewhere. On 18 Oct 2005, at 13:17, Adriaan Renting wrote: > Using numarray/pylab there's also dot: > from pylab import * A = array(range(10)) B = array(range(10)) A * B > [ 0, 1, 4, 9,16,25,36,49,64,81,] > dot(A, B) > 285 > > It might also make your code more readable. I would like "A dot B", > but even using ipython > I can only get as close as "dot A, B" > > Dan Farina <[EMAIL PROTECTED]> 10/18/05 1:33 pm >>> > David Pokorny wrote: > >> Hi, >> >> Just wondering if anyone has considered macros for Python. I have one >> good use case. In "R", the statistical programming language, you can >> multiply matrices with A %*% B (A*B corresponds to pointwise >> multiplication). In Python, I have to type >> >> import Numeric >> matrixmultiply(A,B) >> >> which makes my code almost unreadable. >> >> Thanks, >> David >> > > The problem here is that Python's parse trees are of non-trivial > ugliness. > > A page on the compiler.ast module: > http://docs.python.org/lib/node792.html > > it is, in fact, perfectly possible to write yourself a pre- > processor for > your particular application. You may have to fiddle with the token > you > want for notation depending on how the AST fleshes out (% is used > by at > least a couple of things, after all). My cursory familiarity with > python grammar suggests to me that this particular choice of token > could > be a problem. > > I would say try it and see. Keep in mind though that since > Python's AST > is not a trivial matter like it is in Lisp and the like that doing > metaprogramming of this sort probably falls into the category of black > magic unless it turns out to be very trivial. > > Another option is to define your own tiny class that will override the > __mult__ method so that you can simply do: > > A * B > > Which may not be what you want. > > df > -- > http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Hygenic Macros
Ahar got it http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 Would something like that be any use? On 18 Oct 2005, at 13:21, Alex Stapleton wrote: > I seem to remember a rather ugly hack at some point in the past that > created a new "operator" like so > > A |dot| B > > where dot was an object which had the OR operator for left and right > arguments redefined seperately so that it only made sense when used > in that syntax. > > I guess you could hack something together along the same lines. I > just wish I could remember what it was called, it's on the > ActiveState Cookbook somewhere. > > On 18 Oct 2005, at 13:17, Adriaan Renting wrote: > > >> Using numarray/pylab there's also dot: >> >> >>>>> from pylab import * >>>>> A = array(range(10)) >>>>> B = array(range(10)) >>>>> A * B >>>>> >>>>> >> [ 0, 1, 4, 9,16,25,36,49,64,81,] >> >> >>>>> dot(A, B) >>>>> >>>>> >> 285 >> >> It might also make your code more readable. I would like "A dot B", >> but even using ipython >> I can only get as close as "dot A, B" >> >> >> >>>>> Dan Farina <[EMAIL PROTECTED]> 10/18/05 1:33 pm >>> >>>>> >>>>> >> David Pokorny wrote: >> >> >>> Hi, >>> >>> Just wondering if anyone has considered macros for Python. I have >>> one >>> good use case. In "R", the statistical programming language, you can >>> multiply matrices with A %*% B (A*B corresponds to pointwise >>> multiplication). In Python, I have to type >>> >>> import Numeric >>> matrixmultiply(A,B) >>> >>> which makes my code almost unreadable. >>> >>> Thanks, >>> David >>> >>> >> >> The problem here is that Python's parse trees are of non-trivial >> ugliness. >> >> A page on the compiler.ast module: >> http://docs.python.org/lib/node792.html >> >> it is, in fact, perfectly possible to write yourself a pre- >> processor for >> your particular application. You may have to fiddle with the token >> you >> want for notation depending on how the AST fleshes out (% is used >> by at >> least a couple of things, after all). My cursory familiarity with >> python grammar suggests to me that this particular choice of token >> could >> be a problem. >> >> I would say try it and see. Keep in mind though that since >> Python's AST >> is not a trivial matter like it is in Lisp and the like that doing >> metaprogramming of this sort probably falls into the category of >> black >> magic unless it turns out to be very trivial. >> >> Another option is to define your own tiny class that will override >> the >> __mult__ method so that you can simply do: >> >> A * B >> >> Which may not be what you want. >> >> df >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs Ruby
On 21 Oct 2005, at 09:31, Harald Armin Massa wrote: > Casey, > > > >> I have heard, but have not been able to verify that if a program is >> about >> 10,000 lines in C++ >> it is about >> 5,000 lines in Java >> and it is about >> 3,000 lines in Python (Ruby to?) >> > > BTW: it is normally only 50 lines in Perl. Not that you could read it, > though > > Harald > Perl is more like a CISC CPU. There are a million different commands. Python is more RISC like. Line count comparisons = pointless. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web based applications are possible with wxPython?
Looks shockingly like yet another Java VNC client to me. On 18 Oct 2005, at 21:16, Eli Criffield wrote: > http://www.nomachine.com/companion_screenshots.php > > While not exacly what your talking about, its about as close as i can > think of. This allows you to run any X applications inside a web > browser. > > Eli > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Most efficient way of storing 1024*1024 bits
On 3 Nov 2005, at 05:03, Alex Martelli wrote: > Brandon K <[EMAIL PROTECTED]> wrote [inverting his topposting!]: > > >>> Six megabytes is pretty much nothing on a modern computer. >>> > > >> BTW, it'd be 6 megabits or 750kb ;) >> > > ...but Mike was proposing using one digit per bit, hence, 6 megabytes. > That makes it easy to search for bitpatterns with re or > string.find; if > the bits were packed 8 to a byte, such searches would be very hard. > They would just require some out-of-the-box thinking using character arrays and stuff I think. It's definately still doable with regex's if you really want to. -- http://mail.python.org/mailman/listinfo/python-list
Re: Most efficient way of storing 1024*1024 bits
On 4 Nov 2005, at 10:26, Ben Sizer wrote: > Tom Anderson wrote: > >> On Wed, 2 Nov 2005, Dan Bishop wrote: >> >> >>> Tor Erik Sønvisen wrote: >>> >>> I need a time and space efficient way of storing up to 6 million bits. >>> >>> The most space-efficient way of storing bits is to use the bitwise >>> operators on an array of bytes: >>> >> >> Actually, no, it's to xor all the bits together and store them in >> a single >> boolean. >> > > I'd use 'or' rather than 'xor'. The or operator is more likely to > yield > a '1' at the end of it, and a 1 is narrower than a 0, obviously making > it more efficient to store. Typical gas guzzling, SUV driving american logic. A would obviously use more POWER and hence INCREASE GLOBAL WARMING leading to the ultimate DEATH of EVERYBODY you know and LOVE! -- http://mail.python.org/mailman/listinfo/python-list
Re: which feature of python do you like most?
On 8 Nov 2005, at 12:21, [EMAIL PROTECTED] wrote: > which feature of python do you like most? > I think this question might be a bit like asking whether you love your mum or your dad most to a lot of people ;) People like Python as a whole usually. It's not like C++ or PHP or anything where it's generally usable and occasionally pisses you off. It's tends to just work as you expect it to most of the time once you've got your head around the basics. That or Python enthusiasts are just smarter than everyone else.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: Examples of Quality Technical Writing
On 6 Dec 2005, at 04:55, Xah Lee wrote: > i had the pleasure to read the PHP's manual today. > > http://www.php.net/manual/en/ To be fair, the PHP manual is pretty good most of the time. I mean, just imagine trying to use PHP *without* the manual?! It's not like the language is even vaguely consistent. -- http://mail.python.org/mailman/listinfo/python-list
Debian says "Warning! you are running an untested version of Python." on 2.3
Whenever I run python I get "Warning! you are running an untested version of Python." prepended to the start of any output on stdout. This is with Debian and python 2.3 (running the debian 2.1 and 2.2 binaries doesn't have this effect) Does anyone have any idea how to stop this or have even seen it before? Google says Your search - "you are running an untested version" - did not match any documents :( -- http://mail.python.org/mailman/listinfo/python-list
RE: threads and sleep?
Is SYS V shared memory a totalyl stupid way of doing distributed locks between processes then? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jonathan Ellis Sent: 06 July 2005 05:45 To: python-list@python.org Subject: Re: threads and sleep? Peter Hansen wrote: > Jeffrey Maitland wrote: > > I was hoping that python would allow for the cpu threading such in > > Java etc.. but I guess not. (from the answers,and other findings) I > > guess I will have to write this part of the code in something such as > > java or c or something that allows for it then I can either wrap it in > > python or avoid python for this part of the app. > > Or investigate the use of Irmen's Pyro package and how it could let you > almost transparently move your code to a *multi-process* architecture Unless you're doing anything that would require distributed locking. Many if not most such projects do, which is why almost everyone prefers to use threads on an SMP machine instead of splitting it across multiple smaller boxes. -Jonathan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: Delete first line from file
except them memory usage > file size at least make sure you do it all on disk :P # i so tested this first, honest f = open('file', 'r') fw = open('file.tmp' ,'w') lc = 0 for l in f: if lc != 0: fw.write(l) else: lc = 1 f.close() fw.close() import os os.rename('file.tmp', 'file') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Pieter Claerhout Sent: 01 March 2005 12:51 To: python-list@python.org Subject: Re: Delete first line from file what about the following? f = open( 'file.txt', 'r' ) lines = f.readlines() f.close() f = open( 'file.txt'.'w' ) f.write( '\n'.join( lines[1:] ) ) f.close() cheers, pieter On Tue, 1 Mar 2005 12:42:00 +, Peter Nuttall <[EMAIL PROTECTED]> wrote: > On Tue, Mar 01, 2005 at 01:27:27PM +0100, Tor Erik S?nvisen wrote: > > Hi > > > > How can I read the first line of a file and then delete this line, so that > > line 2 is line 1 on next read? > > > > regards > > > > > > I think you can do something like: > > n=false > f=file.open("") #stuff here > g=[] > for line in f.readlines(): >if n: g.append(line) >n=true > > #write g to file > > if you are on a unix box, then using the standard untils might be a > better idea. > > Pete > > -- > http://mail.python.org/mailman/listinfo/python-list > -- pieter claerhout . [EMAIL PROTECTED] . http://www.yellowduck.be/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
smtplib Segfaults Python under Debian
localhost:~alex#python Python 2.3.3 (#2, Feb 24 2004, 09:29:20) [GCC 3.3.3 (Debian)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import smtplib Segmentation fault (core dumped) This happens under python 2.2 and 2.3 and 2.4 argh! everything else seems to be ok, any ideas anyone? I believe this to be the debian testing version. Debian is a PITA at times :/ -- http://mail.python.org/mailman/listinfo/python-list
RE: shuffle the lines of a large file
Not tested this, run it (or some derivation thereof) over the output to get increasing randomness. You will want to keep max_buffered_lines as high as possible really I imagine. If shuffle() is too intensize you could itterate over the buffer several times randomly removing and printing lines until the buffer is empty/suitibly small removing some more processing overhead. ### START ### import random f = open('corpus.uniq') buffer = [] max_buffered_lines = 1000 for line in f: if len(buffer) < max_buffered_lines: buffer.append(line) else: buffer.shuffle() for line in buffer: print line random.shuffle(buffer) for line in buffer: print line f.close() ### END ### -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Joerg Schuster Sent: 07 March 2005 13:37 To: python-list@python.org Subject: shuffle the lines of a large file Hello, I am looking for a method to "shuffle" the lines of a large file. I have a corpus of sorted and "uniqed" English sentences that has been produced with (1): (1) sort corpus | uniq > corpus.uniq corpus.uniq is 80G large. The fact that every sentence appears only once in corpus.uniq plays an important role for the processes I use to involve my corpus in. Yet, the alphabetical order is an unwanted side effect of (1): Very often, I do not want (or rather, I do not have the computational capacities) to apply a program to all of corpus.uniq. Yet, any series of lines of corpus.uniq is obviously a very lopsided set of English sentences. So, it would be very useful to do one of the following things: - produce corpus.uniq in a such a way that it is not sorted in any way - shuffle corpus.uniq > corpus.uniq.shuffled Unfortunately, none of the machines that I may use has 80G RAM. So, using a dictionary will not help. Any ideas? Joerg Schuster -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: shuffle the lines of a large file
Woops typo. else: buffer.shuffle() for line in buffer: print line should be else: random.shuffle(buffer) for line in buffer: print line of course -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Alex Stapleton Sent: 07 March 2005 14:17 To: Joerg Schuster; python-list@python.org Subject: RE: shuffle the lines of a large file Not tested this, run it (or some derivation thereof) over the output to get increasing randomness. You will want to keep max_buffered_lines as high as possible really I imagine. If shuffle() is too intensize you could itterate over the buffer several times randomly removing and printing lines until the buffer is empty/suitibly small removing some more processing overhead. ### START ### import random f = open('corpus.uniq') buffer = [] max_buffered_lines = 1000 for line in f: if len(buffer) < max_buffered_lines: buffer.append(line) else: buffer.shuffle() for line in buffer: print line random.shuffle(buffer) for line in buffer: print line f.close() ### END ### -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Joerg Schuster Sent: 07 March 2005 13:37 To: python-list@python.org Subject: shuffle the lines of a large file Hello, I am looking for a method to "shuffle" the lines of a large file. I have a corpus of sorted and "uniqed" English sentences that has been produced with (1): (1) sort corpus | uniq > corpus.uniq corpus.uniq is 80G large. The fact that every sentence appears only once in corpus.uniq plays an important role for the processes I use to involve my corpus in. Yet, the alphabetical order is an unwanted side effect of (1): Very often, I do not want (or rather, I do not have the computational capacities) to apply a program to all of corpus.uniq. Yet, any series of lines of corpus.uniq is obviously a very lopsided set of English sentences. So, it would be very useful to do one of the following things: - produce corpus.uniq in a such a way that it is not sorted in any way - shuffle corpus.uniq > corpus.uniq.shuffled Unfortunately, none of the machines that I may use has 80G RAM. So, using a dictionary will not help. Any ideas? Joerg Schuster -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
urllib (and urllib2) read all data from page on open()?
The entire page is downloaded immediately whether you want it to or not when you do an http request using urllib. This seems slightly broken to me. Is there anyway to turn this behaviour off and have the objects read method actually read data from the socket when you ask it to? -- http://mail.python.org/mailman/listinfo/python-list
RE: urllib (and urllib2) read all data from page on open()?
Except wouldn't it of already read the entire file when it opened, or does it occour on the first read()? Also will the data returned from handle.read(100) be raw HTTP? In which case what if the encoding is chunked or gzipped? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Fuzzyman Sent: 14 March 2005 14:01 To: python-list@python.org Subject: Re: urllib (and urllib2) read all data from page on open()? Certianly under urllib2 - handle.read(100) will read the next 100 bytes (up to) from the handle. Which is the same beahviour as the read method for files. Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: urllib (and urllib2) read all data from page on open()?
Whilst it might be able to do what I want I feel this to be a flaw in urllib that should be fixed, or at least added to a buglist somewhere so I can at least pretend someone other than me cares. -Original Message- From: Swaroop C H [mailto:[EMAIL PROTECTED] Sent: 14 March 2005 14:45 To: Alex Stapleton Subject: RE: urllib (and urllib2) read all data from page on open()? --- Alex Stapleton <[EMAIL PROTECTED]> wrote: > Except wouldn't it of already read the entire file when it opened, > or does it occour on the first read()? Also will the data returned > from handle.read(100) be raw HTTP? In which case what if the > encoding is chunked or gzipped? Maybe the httplib module can help you. >From http://docs.python.org/lib/httplib-examples.html : >>> import httplib >>> conn = httplib.HTTPConnection("www.python.org") >>> conn.request("GET", "/index.html") >>> r1 = conn.getresponse() >>> print r1.status, r1.reason 200 OK >>> data1 = r1.read() >>> conn.request("GET", "/parrot.spam") >>> r2 = conn.getresponse() >>> print r2.status, r2.reason 404 Not Found >>> data2 = r2.read() >>> conn.close() As far as I can understand, you can read() data only when you want to. Caveat: There's a warning that says "This module defines classes which implement the client side of the HTTP and HTTPS protocols. It is normally not used directly -- the module urllib uses it to handle URLs that use HTTP and HTTPS." HTH, Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Well the most well known Flying Circus snake related sketch is probably the one eyed trouser snake one, which is er-, probably less than a good idea for a logo. The Snake with some sort of Monty Python themeing is probably the best idea, but drawing a snake + large foot/16 ton weight/holy grail/norweigan blue might be a bit tricky when you have to make small sized icons, which is why the current snake is so handy. I guess someone should watch the intro to flying circus, and/or the animations from some of the movies for inspiration. But on that note, how about a python + rose combo? Eric Pederson wrote: Since the word 'Python' would bring -some- sort of snake associations, I thought of combining snake and Monty Python symbolic, like making a snake wind around a giant foot, or adding long mustache and an english hat to a snake or something in that manner, or even put a snake into a holy grail heh. But then again, I'm not sure if there'll be no copyright issues. But surely only you and I and the other Pythonistas will recognize a Norwegian Blue when we see one. Might be hard to get away from the snake, as was noted, its a level or two easier mental association than MP. Logo? Maybe a Norweigian Blue on is back, one fut in e air, wit a snake ead off to is ide, grinningly wit a char-grin? es not dead! Eric Pederson ::: domainNot="@something.com" domainIs=domainNot.replace("s","z") ePrefix="".join([chr(ord(x)+1) for x in "do"]) mailMeAt=ePrefix+domainIs ::: -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
The problem with parrots is that Perl 6's engine is called Parrot. Although I suppose the image of a dead Parrot/snake eating a parrot etc could be a "good" one in some peoples minds. But i'm not sure Perl people are really the sort that you wan't to make enemies of, they are deadly with custard pies. It's a bit immature to insult another language like that anyway, not thats the idea you where going for of course. Adil Hasan wrote: Would a parrot on it's back be better? adil On Mon, 13 Dec 2004, Alex Stapleton wrote: Well the most well known Flying Circus snake related sketch is probably the one eyed trouser snake one, which is er-, probably less than a good idea for a logo. The Snake with some sort of Monty Python themeing is probably the best idea, but drawing a snake + large foot/16 ton weight/holy grail/norweigan blue might be a bit tricky when you have to make small sized icons, which is why the current snake is so handy. I guess someone should watch the intro to flying circus, and/or the animations from some of the movies for inspiration. But on that note, how about a python + rose combo? Eric Pederson wrote: Since the word 'Python' would bring -some- sort of snake associations, I thought of combining snake and Monty Python symbolic, like making a snake wind around a giant foot, or adding long mustache and an english hat to a snake or something in that manner, or even put a snake into a holy grail heh. But then again, I'm not sure if there'll be no copyright issues. But surely only you and I and the other Pythonistas will recognize a Norwegian Blue when we see one. Might be hard to get away from the snake, as was noted, its a level or two easier mental association than MP. Logo? Maybe a Norweigian Blue on is back, one fut in e air, wit a snake ead off to is ide, grinningly wit a char-grin? es not dead! Eric Pederson ::: domainNot="@something.com" domainIs=domainNot.replace("s","z") ePrefix="".join([chr(ord(x)+1) for x in "do"]) mailMeAt=ePrefix+domainIs ::: -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Chris wrote: What IDE's do y'all recommend for Python? I'm using PythonWin atm, but I'd like something with more functionality. Chris Oh god we're all going to die. But er, ActiveState Komodo is quite nice IIRC (can't use it anymore as all my coding is commercial and I don't need it enough to spend that much cash on it) but EditPlus is nice once you get it setup but not very IDEy. Eclipse with one of the various Python modules is horrible don't bother. There is of course always Emacs, but again it's hardly Visual Studio (im only talking about the UI, emacs fans please dont flame me) Personally my vote goes for Komodo, it's at least worth a try with a personal liscense. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Why didn't you like Eclipse? Was it that the Python modules were bad, or just Eclipse in general? I use it for my Java developement and haven't had any problems with it. Just the python stuff really, I've used it for some java stuff and know plenty of people that do every day and they all love it for Java, but having tried using it for anything else it's next to useless. In fact it's worse than a plain editor in some ways when your not using it for Java. -- http://mail.python.org/mailman/listinfo/python-list
Re: lies about OOP
To canadians there is no "outside" of hockey games. Jeff Shannon wrote: Peter Hansen wrote: P.S.: I'm only half Danish, but the other half is from a particularly bloodthirsty line of Canadians. I thought it was physically impossible for Canadians to be bloodthirsty outside of hockey games... ;) Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list
Re: Cool object trick
Except what if you want to access elements based on user input or something? you can't do var = "varA" obj = struct(varA = "Hello") print obj.var and expect it to say Hello to you. objects contain a __dict__ for a reason :P > Certainly makes writing 'print obj.spam, obj.spam, obj.eggs, obj.bacon, > obj.sausages, "and", obj.spam' a lot easier ;-) then why dont you have a breakfast class? if you have this many properties associated with the same thing you might as well stick them in a class anyway. [EMAIL PROTECTED] wrote: I rather like it! I prefer writing obj.spam to obj["spam"]! I wonder if there is a technical downside to this use of Python? P.S. Certainly makes writing 'print obj.spam, obj.spam, obj.eggs, obj.bacon, obj.sausages, "and", obj.spam' a lot easier ;-) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jive Sent: 17 December 2004 06:29 To: [EMAIL PROTECTED] Subject: Re: Cool object trick Kinda cool. It's occured to me that just about everything Pythonic can be done with dicts and functions. Your Obj is just a dict with an alternate syntax. You don't have to put quotes around the keys. But that's cool. class struct(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) # Indented this way, it looks like a struct: obj = struct( saying = "Nee" , something = "different" , spam = "eggs" ) print obj.spam # Is that really much different from this? obj2 = { "saying" : "Nee" , "something" : "different" , "spam" : "eggs" } print obj2["spam"] -- http://mail.python.org/mailman/listinfo/python-list
Re: Cool object trick
Steven Bethard wrote: Alex Stapleton wrote: you can't do var = "varA" obj = struct(varA = "Hello") print obj.var and expect it to say Hello to you. The Bunch object from the PEP can take parameters in the same way that dict() and dict.update() can, so this behavior can be supported like: >>> b = Bunch({"varA":"Hello!"}) >>> b.varA 'Hello!' or >>> b = Bunch([("varA", "Hello!")]) >>> b.varA 'Hello!' Steve thats nothing like what i described. you are setting the variable name in your code (b.varA), not generating the variable name in a string (var = "varA") (dictionary key) at run-time and fetching it from the __dict__ like i was attempting to describe. -- http://mail.python.org/mailman/listinfo/python-list
Re: Cool object trick
Steven Bethard wrote: Alex Stapleton wrote: you are setting the variable name in your code (b.varA), not generating the variable name in a string (var = "varA") (dictionary key) at run-time and fetching it from the __dict__ like i was attempting to describe. Ahh. Well if you just want to get an attribute, I don't see why you wouldn't do it the normal way: >>> b = Bunch(varA="Hello!") >>> getattr(b, "varA") 'Hello!' That's what getattr's for. ;) No need to go poking around in __dict__. Steve Hmm true, (i had forgotten about getattr :/) in that case im indifferent to Bunch() not that i really see why it's useful except for making code look a bit nicer occasionaly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to use python to unit test C++ code?
On 21 Dec 2005, at 09:33, [EMAIL PROTECTED] wrote: > Is it possible to use python to unit test C++ code? If yes, is there > any example available? > > Thank you. > > -- > http://mail.python.org/mailman/listinfo/python-list You could use Python to unittest a Python module written in C++ I suppose. I guess that would probably work. I suspect that you would get better/more accurate/reliable results by writing your tests in C+ + as well though. -- http://mail.python.org/mailman/listinfo/python-list
Bug in struct.pack?
from struct import pack >>> pack("B", 1) '\x01' >>> pack("BB", 0, 1) '\x00\x01' >>> pack("BI", 0, 1) '\x00\x00\x00\x00\x01\x00\x00\x00' >>> calcsize("BI") 8 >>> calcsize("BB") 2 Why does an unsigned char suddenly become 4 bytes long when you include an unsigned int in the format string? It's consistent behaviour but it's incorrect. Also. >>> calcsize('BL') 8 >>> calcsize('BBL') 8 >>> calcsize('BBBL') 8 >>> calcsize('L') 8 >>> calcsize('BL') 12 >>> pack("BBBL", 255,255,255,0) '\xff\xff\xff\x00\x00\x00\x00\x00' ### That's 3 255's and 5(!?!?) 0's >>> pack("L", 255,255,255,255,0) '\xff\xff\xff\xff\x00\x00\x00\x00' # 4 255's and 4 0's! Which is all kinds of wrong. BL should be 9 BBL should be 10 Python 2.4.1 (#2, May 5 2005, 11:32:06) [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2 Same behaviour on my PowerBook using Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin sizeof(unsigned long) should be 8 on both of these platforms sizeof(unsigned char) should be 1 on both as well So am I just being stupid and not specifying something I should be? Or is struct really that broken? -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in struct.pack?
< Idiot. On 11 Jan 2006, at 10:46, Alex Stapleton wrote: > from struct import pack >>>> pack("B", 1) > '\x01' >>>> pack("BB", 0, 1) > '\x00\x01' >>>> pack("BI", 0, 1) > '\x00\x00\x00\x00\x01\x00\x00\x00' >>>> calcsize("BI") > 8 >>>> calcsize("BB") > 2 > > Why does an unsigned char suddenly become 4 bytes long when you > include an unsigned int in the format string? It's consistent > behaviour but it's incorrect. > > Also. > >>>> calcsize('BL') > 8 >>>> calcsize('BBL') > 8 >>>> calcsize('BBBL') > 8 >>>> calcsize('L') > 8 >>>> calcsize('BL') > 12 >>>> pack("BBBL", 255,255,255,0) > '\xff\xff\xff\x00\x00\x00\x00\x00' ### That's 3 255's and 5(!?!?) > 0's >>>> pack("L", 255,255,255,255,0) > '\xff\xff\xff\xff\x00\x00\x00\x00' # 4 255's and 4 0's! > > Which is all kinds of wrong. > > BL should be 9 > BBL should be 10 > > > Python 2.4.1 (#2, May 5 2005, 11:32:06) > [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2 > > Same behaviour on my PowerBook using > > Python 2.3.5 (#1, Mar 20 2005, 20:38:20) > [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin > > sizeof(unsigned long) should be 8 on both of these platforms > sizeof(unsigned char) should be 1 on both as well > > So am I just being stupid and not specifying something I should be? > Or is struct really that broken? > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: first release of PyPy
The question still remains, can it run it's self? ;) On 20 May 2005, at 23:50, Kay Schluehr wrote: > > holger krekel wrote: > >> Welcome to PyPy 0.6 >> >> >> *The PyPy Development Team is happy to announce the first >> public release of PyPy after two years of spare-time and >> half a year of EU funded development. The 0.6 release >> is eminently a preview release.* >> > > Congratulation to You and Your team! > > PyPy is really awesome and if it succeeds in speed demands after the > translation phase I believe that the project will shift the power > within the Python community on the long run. There are moments I'm > almost shocked about it and think about the fate of other programming > programming languages like LISP. PyPy can be resolved to "Python in > Python" but also "Python multiplied/powered by itself" which is much > more triumphant. A short review of the 'thunks' objspace example gives > me the impression that the language development process as we know it > comes to an end and makes a kind of transition. This is both very > exciting and dangerous, like every philosophical event. > > Regards, > Kay > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: twill v0.7, scriptable Web testing
This is exactly the sort of thing ive been trying to avoid implementing my self for ages :) I will take it for a spin and see how it behaves, looks great though. On 23 May 2005, at 05:07, C. Titus Brown wrote: > ANNOUNCING twill v0.7. > > twill is a simple Web scripting language built on top of Python and > mechanize. It's designed for automated testing of Web sites, but > it may be useful for anybody who needs to deal with Web sites > (with e.g. logins and cookies) in a non-interactive manner. > > twill is a reimplementation of Cory Dodt's PBP. > > A twill script looks like this: > ># go to the /. login page >go http://slashdot.org/login.pl > ># fill in the form >fv 1 unickname test >fv 1 upasswd test >submit > ># ok, there's no such account ;). show error HTML. >show > > --- > > This is the first public release of twill, version 0.7. > > (Tagline: "It seems usable to me, but then I'm its author.") > > With this release, I'm looking for general feedback on usability, as > well as suggestions on additional use cases. > > Download directly here: > > http://darcs.idyll.org/~t/projects/twill-0.7.tar.gz > > Documentation is online at > > http://www.idyll.org/~t/www-tools/twill.html > > --- > > Miscellaneous details: > > twill is implemented in Python and uses pyparsing and mechanize. In > addition to the existing simple command language, twill can easily be > extended with Python. twill also provides a fairly simple and > well-documented wrapper around mechanize. > > twill scripts can be recorded with maxq, although scripts may require > some hand tweaking at the moment. See the twill documentation for > more information. > > twill does not understand JavaScript, I'm sorry to say. > > --titus, [EMAIL PROTECTED] > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Python really does need less lines of code ;)
Looking for some confirmation that Python really is a more concise language than most others, I resorted to the ever handy Computer Language Shootout and it's oh so reliable CRAPS scoring system ;)Python comes second, just after OCaml. Both of which are a significantly further ahead of everything else.For those less inclined to copy and paste the huge URLhttp://tinyurl.com/ds5bfPlease excuse the stupidly long URLhttp://shootout.alioth.debian.org/benchmark.php?test=all&lang=all&sort=fullcpu&xfullcpu=0&xmem=0&xloc=1&ackermann=1&wc=1&fannkuch=1&fasta=1&harmonic=1&heapsort=1&knucleotide=1&mandelbrot=1&nbody=1&nsieve=1&nsievebits=1&objinst=1&methcall=1&pidigits=1&random=1®exmatch=1&revcomp=1&spectralnorm=1&spellcheck=1&hello=1&sumcol=1&takfp=1&tcpecho=1&tcprequest=1&tcpstream=1&process=1&message=1&wordfreq=1&calc=Calculate-- http://mail.python.org/mailman/listinfo/python-list
Sorted List (binary tree) why no built-in/module?
Unless I've totally missed it, there isn't a binary tree/sorted list type arrangement in Python. Is there a particular reason for this? Sometimes it might be preferable over using a list and calling list.sort() all the time ;) On a somewhat unrelated note, does anyone know how python searches lists when you do things list list.index(n), is it a binary search, or does it just scan the list? -- http://mail.python.org/mailman/listinfo/python-list
Re: Grand Challenge Pegasus Team: Programming Pegasus Bridge 1 ?
I'm thinking that with a decent dynamics engine (PyODE?) you could write a reasonably realistic simulator to test this sort of code on. Obviously it won't be as good as actually you know, driving a Jeep around by wire, but it'd be a tad cheaper and more time efficient for anyone interested in this sort of thing. There the time involved in actually writing a simulator which you can experiment on your DBW code on though. You could probably get one going within a year though I imagine. Unfortunately from what i've seen of it, the Open Dynamics Engine is less than accurate under some situations. Unfortunately I believe all the really awesome ones cost huge amounts of money. Just a thought. I don't have any actual experience with DBW stuff :P On 4 Jun 2005, at 21:13, [EMAIL PROTECTED] wrote: > Folks, > > In a previous post[*] we made an announcement about the release of the > drive-by-wire code for our entry in the DARPA Grand Challenge. We will > do more in the future (including more data and more code). With > regards > to our building the full autonomous code, things are going along well. > However, the somewhat large traffic on our web site had us thinking: > > Provided we give a good HOW-TO/API, would there be any interest from > anybody to try their code on our vehicle as long as it is in Python > and > safe to run ? > > Many people think of way to deal with the programming side of > road-following and collision avoidance at 60 mph, but very few have > the > time to build a vehicle that can make these concepts a reality. In > order to respond to this, I was thinking of a possibility where > somebody would submit a code, pay $200 and we would try it on a closed > circuit. Then the programmer would be getting all the data > attendant to > the vehicle driving itself through the course following their > programs? > > > The pros for us: > - raise some money for the vehicle > - identify potentially better algorithms -> identify people we would > like to associate ourselves with. > > The cons for us: > - this is time not dedicated to focusing on the race > - issues with proprietary code/IP > - issues with safety > - coordination with many parties > > Right now I am thinking the cons are overwhelming, what do y'all think > ? > > > Igor. > > [*] > http://groups-beta.google.com/group/comp.lang.python/browse_frm/ > thread/5f78e2ecb3e9139d/af28daca5e385af3#af28daca5e385af3 > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list