Re: Bug in struct.pack?

2006-01-11 Thread Alex Stapleton
< 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\x

Bug in struct.pack?

2006-01-11 Thread Alex Stapleton
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'

Re: Is it possible to use python to unit test C++ code?

2005-12-21 Thread Alex Stapleton
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 sup

Re: Xah's Edu Corner: Examples of Quality Technical Writing

2005-12-06 Thread Alex Stapleton
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

Re: which feature of python do you like most?

2005-11-08 Thread Alex Stapleton
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

Re: Most efficient way of storing 1024*1024 bits

2005-11-04 Thread Alex Stapleton
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

Re: Most efficient way of storing 1024*1024 bits

2005-11-03 Thread Alex Stapleton
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 meg

Re: Web based applications are possible with wxPython?

2005-10-25 Thread Alex Stapleton
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

Re: Python vs Ruby

2005-10-21 Thread Alex Stapleton
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

Re: Hygenic Macros

2005-10-18 Thread Alex Stapleton
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

Re: Hygenic Macros

2005-10-18 Thread Alex Stapleton
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 so

Re: Python's Performance

2005-10-14 Thread Alex Stapleton
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 co

Re: Python's Performance

2005-10-09 Thread Alex Stapleton
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 l

Re: Poor man's OCR: need performance improvement tips

2005-09-24 Thread Alex Stapleton
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 p

RE: threads and sleep?

2005-07-06 Thread Alex Stapleton
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 wr

Re: Grand Challenge Pegasus Team: Programming Pegasus Bridge 1 ?

2005-06-04 Thread Alex Stapleton
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

Sorted List (binary tree) why no built-in/module?

2005-06-04 Thread Alex Stapleton
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 searche

Python really does need less lines of code ;)

2005-05-25 Thread Alex Stapleton
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 e

Re: ANNOUNCE: twill v0.7, scriptable Web testing

2005-05-23 Thread Alex Stapleton
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

Re: first release of PyPy

2005-05-23 Thread Alex Stapleton
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

RE: urllib (and urllib2) read all data from page on open()?

2005-03-14 Thread Alex Stapleton
: 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 han

RE: urllib (and urllib2) read all data from page on open()?

2005-03-14 Thread Alex Stapleton
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 PROTE

urllib (and urllib2) read all data from page on open()?

2005-03-14 Thread Alex Stapleton
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.py

RE: shuffle the lines of a large file

2005-03-07 Thread Alex Stapleton
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

RE: shuffle the lines of a large file

2005-03-07 Thread Alex Stapleton
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 unti

smtplib Segfaults Python under Debian

2005-03-01 Thread Alex Stapleton
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 b

RE: Delete first line from file

2005-03-01 Thread Alex Stapleton
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

Debian says "Warning! you are running an untested version of Python." on 2.3

2005-01-13 Thread Alex Stapleton
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 see

Re: Cool object trick

2004-12-17 Thread Alex Stapleton
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 w

Re: Cool object trick

2004-12-17 Thread Alex Stapleton
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 b

Re: Cool object trick

2004-12-17 Thread Alex Stapleton
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, >

Re: lies about OOP

2004-12-17 Thread Alex Stapleton
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... ;)

Re: Python IDE

2004-12-14 Thread Alex Stapleton
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

Re: Python IDE

2004-12-14 Thread Alex Stapleton
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 s

Re: Python mascot proposal

2004-12-13 Thread Alex Stapleton
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 Fl

Re: Python mascot proposal

2004-12-13 Thread Alex Stapleton
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