Re: time.clock()

2006-07-17 Thread Nick Craig-Wood
of just that process. I think the precisions are the other way round on windows. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: How to delete a Python package

2006-07-13 Thread Nick Craig-Wood
time so far! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter problem

2006-07-08 Thread Nick Craig-Wood
= /lib/tls/i686/cmov/libdl.so.2 (0xb7aa5000) /lib/ld-linux.so.2 (0x8000) If there are any missing things then you need to re-install those packages. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: defining multi dimensional array

2006-07-05 Thread Nick Craig-Wood
if you are doing heavy numerical work. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Fork You.. Forking and threading..

2006-07-05 Thread Nick Craig-Wood
from your job and it exits from the process group. You could probably close / redirect stdin/out/err too. Search for daemonize.py and you'll find a module which does all this. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo

Re: Time out question

2006-07-04 Thread Nick Craig-Wood
Grant Edwards [EMAIL PROTECTED] wrote: On 2006-07-03, Nick Craig-Wood [EMAIL PROTECTED] wrote: Alex Martelli [EMAIL PROTECTED] wrote: DarkBlue [EMAIL PROTECTED] wrote: try for 10 seconds if database.connected : do your remote thing except raise after 10 seconds

Re: Time out question

2006-07-03 Thread Nick Craig-Wood
, False, 7, _test_time_limit, nested #12a,False, 6, _test_time_limit, nested #12b,False, 10, _spin, 5) print All tests OK test() -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org

Re: Problem when import C model

2006-07-03 Thread Nick Craig-Wood
int main(void) { printf(Hello\n); return 0; } #END gcc -c -m32 -o z32.o z.c gcc -c -m64 -o z64.o z.c file z*.o gives z32.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped z64.o: ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped -- Nick Craig

Re: help() on stdout.closed

2006-06-21 Thread Nick Craig-Wood
attribute; the `close()' method changes the value. It may not be available on all file-like objects. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: os.link makes a copy, not a link

2006-06-10 Thread Nick Craig-Wood
(test) os.link(z, z2) os.stat(z).st_ino 1685186L os.stat(z2).st_ino 1685186L print os.popen(ls -li z z2).read() 1685186 -rw-r--r-- 2 ncw ncw 4 2006-06-10 08:31 z 1685186 -rw-r--r-- 2 ncw ncw 4 2006-06-10 08:31 z2 -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http

Re: os.link makes a copy, not a link

2006-06-10 Thread Nick Craig-Wood
) os.link(z, /dev/shm/z) Traceback (most recent call last): File stdin, line 1, in ? OSError: [Errno 18] Invalid cross-device link -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: how to switch from os.tmpnam to os.tmpfile

2006-06-08 Thread Nick Craig-Wood
entries. Have a look at the functions in the tempfile module, mkstemp() in particular (the posix way), or NamedTemporaryFile() http://docs.python.org/lib/module-tempfile.html -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo

Re: Best way to check that a process is running on a Unix system?

2006-06-05 Thread Nick Craig-Wood
self.by_command.get(name, []) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: a good explanation

2006-05-25 Thread Nick Craig-Wood
...if you happen to need cnt in the loop, this is what you write files = [a,b,c,d] for cnt, fi in enumerate(files): do_something(cnt, fi) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Incrementally converting a C app to Python

2006-05-10 Thread Nick Craig-Wood
as you are going along in Python. It will make more code, but it will give you a wonderful feeling of confidence that your code will actually work, and work the same as the C code. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo

Re: Python's regular expression?

2006-05-08 Thread Nick Craig-Wood
looks like it needs a regexp, but python has a much richer set of string methods, eg .startswith, .endswith, good subscripting and the nice in operator for strings. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Nick Craig-Wood
correct and most likely quicker. def distribution(N=2): L = [ random.uniform(0,1) for _ in xrange(N) ] sumL = sum(L) return [ l/sumL for l in L ] spread = distribution(10) print spread print sum(spread) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http

Re: Joining stdout stderr of subprocess ?

2006-04-21 Thread Nick Craig-Wood
and err joined synchronously in the order, it is created ? You need to either 1) change myapp to fflush() more often 2) investigate the python pty module to fool the app into thinking it is talking to a terminal -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http

Re: how to append to a list twice?

2006-04-21 Thread Nick Craig-Wood
, 1, -1)] That should be series = [x//2 for x in range(200, 1, -1)] to be from __future__ import division safe -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: XML-RPC server via xinetd

2006-04-17 Thread Nick Craig-Wood
, does what you want, ie an XMLRPC subclass which reads from stdin and writes to stdout. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference in Python and Ruby interactive shells

2006-04-10 Thread Nick Craig-Wood
and works just fine. I only type it once and then press up arrow to get it back! import workinprogress; reload(workinprogress); del(workinprogress); from workinprogress import * That gives you the module and all its globals rebound. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com

Re: To run a python script in all the machines from one server

2006-03-28 Thread Nick Craig-Wood
Status: OK -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting Time question

2006-03-28 Thread Nick Craig-Wood
:11.769000' Note that this converts using the PCs time zone (hence it says 18:14 not 17:14). You can pass your own timezone in (but it isn't easy!), or you can use utcfromtimestamp() datetime.datetime.utcfromtimestamp(1.090516451769E+15/1E6).isoformat()[-15:] '17:14:11.769000' -- Nick Craig-Wood [EMAIL

Re: 1.090516455488E9 / 1000000.000 ???

2006-03-28 Thread Nick Craig-Wood
-calculations-so-inaccurate Eg a=1.090516455488E9 / 100 print a 1090.51645549 print repr(a) 1090.516455488 If you want a given number of decimal places you can use a formatter, eg print %.20f % a 1090.5164554881961354 -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com

Re: Looking for a language/framework

2006-03-28 Thread Nick Craig-Wood
into a django site, and we've been monstrously impressed! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Have you ever considered of mousing ambidextrously?

2006-03-19 Thread Nick Craig-Wood
with my left hand quite as well as my right, but I don't attempt that very often! I can't actually think of any possible way of getting this on topic, so I'll just mention python now and we'll take it as read ;-) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http

Re: Tried Ruby (or, what Python *really* needs or perldoc!)

2006-03-16 Thread Nick Craig-Wood
-ext). Extending Embedding Python 2.3 * Python2.3-lib: (python2.3-lib). Python 2.3 Library Reference * Python2.3-ref: (python2.3-ref). Python 2.3 Reference Manual * Python2.3-tut: (python2.3-tut). Python 2.3 Tutorial -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig

Re: Tried Ruby (or, what Python *really* needs or perldoc!)

2006-03-14 Thread Nick Craig-Wood
to use for the easy things, but gets complicated for the hard things. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: do design patterns still apply with Python?

2006-03-03 Thread Nick Craig-Wood
. ;-) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

instances from bound methods

2006-03-02 Thread Nick Craig-Wood
, in ? AttributeError: 'builtin_function_or_method' object has no attribute 'im_self' fn.__self__ open file 'myfile', mode 'w' at 0xb7dc1260 I wonder why? Is there a canonical way of doing it? -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman

Re: changing value of 'self' when subclassing int

2006-02-21 Thread Nick Craig-Wood
while i: L.append(int(i 1L)) i = 1 L.reverse() content = str(L) return %s(%s) % (self.__class__.__name__, content) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python

Re: Pyserial never read

2006-02-21 Thread Nick Craig-Wood
luca72 [EMAIL PROTECTED] wrote: Thanks for your help, but it don't solve the problem. I receive only the echo and full stop. Try swapping pins 2 and 3 in the lead. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Pyserial never read

2006-02-21 Thread Nick Craig-Wood
Peter Hansen [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: luca72 [EMAIL PROTECTED] wrote: Thanks for your help, but it don't solve the problem. I receive only the echo and full stop. Try swapping pins 2 and 3 in the lead. Anything's possible, but given that in his original

Re: pythonic exec* spawn*

2006-02-13 Thread Nick Craig-Wood
/lib/module-threading.html But it will use your multiple CPUs less efficiently than fork()-ing. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Another try at Python's selfishness

2006-02-04 Thread Nick Craig-Wood
of big C++ programs various conventions are used to try to help with this - naming all parameters to functions _name rather than name, or using this-member rather than member. The python way of enforcing self.member is much cleaner and never comes back to bite you! -- Nick Craig-Wood [EMAIL

Re: add pexpect to the standard library, standard install mechanism.

2006-01-20 Thread Nick Craig-Wood
python setup.py bdist_rpm which builds an .rpm to install which you might prefer. If you want a .deb use alien to convert the rpm However in the case of this package apt-get install python-pexpect works for me on Debian and hence probably on ubuntu. -- Nick Craig-Wood [EMAIL PROTECTED

Re: Addressing a COM port from Python

2006-01-17 Thread Nick Craig-Wood
Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: flatten a level one list

2006-01-13 Thread Nick Craig-Wood
Alex Martelli [EMAIL PROTECTED] wrote: Nick Craig-Wood [EMAIL PROTECTED] wrote: Except if you are trying to sum arrays of strings... sum([a,b,c], ) Traceback (most recent call last): File stdin, line 1, in ? TypeError: sum() can't sum strings [use ''.join(seq) instead

Re: flatten a level one list

2006-01-12 Thread Nick Craig-Wood
1, in ? TypeError: sum() can't sum strings [use ''.join(seq) instead] I've no idea why this limitation is here... perhaps it is because pre python2.4 calling += on strings was very slow? -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org

Re: Cross Compile Mips / Linux

2006-01-11 Thread Nick Craig-Wood
for ARM. I found the debian ARM python quite sufficient for my needs so I didn't have to build that! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] How can I change Debian's default Python version?

2006-01-05 Thread Nick Craig-Wood
with careful use of apt preferences and sources.list. Or you can swap to ubuntu completely using apt-get! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing next/prev element while for looping

2005-12-18 Thread Nick Craig-Wood
(10) (L1, L2, L3) = tee(L, 3) L2.next() 0 L3.next() 0 L3.next() 1 for prev, current, next in izip(L1, L2, L3): print prev, current, next ... 0 1 2 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org

Re: efficient 'tail' implementation

2005-12-08 Thread Nick Craig-Wood
Gerald Klix [EMAIL PROTECTED] wrote: As long as memory mapped files are available, the fastest method is to map the whole file into memory and use the mappings rfind method to search for an end of line. Excellent idea. It'll blow up for large 2GB files on a 32bit OS though. -- Nick Craig

Re: efficient 'tail' implementation

2005-12-08 Thread Nick Craig-Wood
-1:] print \n.join(lines) if __name__ == __main__: if len(sys.argv) != 3: print Syntax: %s n file % sys.argv[0] else: main(int(sys.argv[1]), sys.argv[2]) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org

Re: Writing pins to the RS232

2005-11-29 Thread Nick Craig-Wood
the serial port up not to do automatic handshaking first (eg setDsrDtr() setRtsCts()) RS232 levels are +/- 12V, though a lot of computers only generate +/- 5V. The threshold is +/- 3V IIRC. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman

Re: sort the list

2005-11-23 Thread Nick Craig-Wood
Neil Hodgson [EMAIL PROTECTED] wrote: Nick Craig-Wood: Since no-one mentioned it and its a favourite of mine, you can use the decorate-sort-undecorate method, or Schwartzian Transform That is what the aforementioned key argument to sort is: a built-in decorate-sort-undecorate

Re: sort the list

2005-11-22 Thread Nick Craig-Wood
log N times. Its expensive in terms of memory though. With python 2.4 you can wrap it up into one line if you want [ x[-1] for x in sorted([ (x[1],x) for x in lst ]) ] or even [ x[-1] for x in sorted((x[1],x) for x in lst) ] -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

simulating #include in python

2005-11-15 Thread Nick Craig-Wood
)) # Restore sys.path sys.path = old_sys_path -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: simulating #include in python

2005-11-15 Thread Nick Craig-Wood
Peter Otten [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: I'd really like to be able to run an __import__ in the context of the file thats running the include() but I haven't figured that out. execfile()? Yes thats exactly what I was looking for - thank you very much! -- Nick

Re: gmpy/decimal interoperation

2005-11-14 Thread Nick Craig-Wood
function, but I don't think implicit conversion is that useful since decimal and gmpy are solving quite different problems. Implicit conversions also opens the can of worms - what is the preferred promotion type? decimal + mpf == decimal? mpf? mpq? IMHO of course! -- Nick Craig-Wood [EMAIL PROTECTED

Re: How to avoid f.close (no parens) bug?

2005-11-14 Thread Nick Craig-Wood
your programs is the answer! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: gmpy 1.01 rc near... anybody wanna test

2005-11-10 Thread Nick Craig-Wood
on the system). Thanks and look forward to the release Nick -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

xml.minidom and user defined entities

2005-11-09 Thread Nick Craig-Wood
spend some time searching the docs/code/google but I haven't found the answer to this question! Thanks -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: xml.minidom and user defined entities

2005-11-09 Thread Nick Craig-Wood
Fredrik Lundh [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: I'm using xml.minidom to parse some of our XML files. Some of these have entities like deg; in which aren't understood by xml.minidom. deg; is not a standard entity in XML (see below). No probably not... These give

Re: subprocess and non-blocking IO (again)

2005-10-11 Thread Nick Craig-Wood
... I'm not sure why readline only returns 1 character - the pipe returned by subprocess really does seem to be only 1 character deep which seems a little inefficient! Changing bufsize to the Popen call doesn't seem to affect it. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

Re: How to use a timer in Python?

2005-09-23 Thread Nick Craig-Wood
someone already did. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use a timer in Python?

2005-09-23 Thread Nick Craig-Wood
creates transfer.lock - so it waits if the transfer.lock is in existence too. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Premature wakeup of time.sleep()

2005-09-13 Thread Nick Craig-Wood
.) I'm not sure the best way of finding out your HZ, here is one (enter it all on one line) start=`grep timer /proc/interrupts | awk '{print $2}'`; sleep 1; end=`grep timer /proc/interrupts | awk '{print $2}'`; echo $(($end-$start)) Which prints a number about 1000 on my 2.6 machine. -- Nick Craig

Re: dual processor

2005-09-08 Thread Nick Craig-Wood
and arrives more or less on time. It goes on later to say The physical processor has 8 cores and 32 virtual processors and runs at 1080 MHz. So fewer GHz but more CPUs is the future according to Sun. http://www.theregister.co.uk/2005/09/07/sun_niagara_details/ -- Nick Craig-Wood [EMAIL PROTECTED

Re: dual processor

2005-09-05 Thread Nick Craig-Wood
Scott David Daniels [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: Splitting the GIL introduces performance and memory penalties However its crystal clear now the future is SMP. Modern chips seem to have hit the GHz barrier, and now the easy meat for the processor designers

Re: dual processor

2005-09-05 Thread Nick Craig-Wood
magic. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Revised PEP 349: Allow str() to return unicode strings

2005-08-23 Thread Nick Craig-Wood
(100L) 100L Wouldn't also a new function make the intent clearer? So I think I'm +1 on the text() built-in, and -0 on changing str. Couldn't basestring() perform this function? Its kind of what basestring is for isn't it? -- Nick Craig-Wood [EMAIL PROTECTED

Re: sending binary files to a 16 micro controller.

2005-08-22 Thread Nick Craig-Wood
recommend the OP uses UDP, not TCP. I've implemented a few systems which speak UDP directly and its very easy. I wouldn't like to implement TCP though! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Which kid's beginners programming - Python or Forth?

2005-06-30 Thread Nick Craig-Wood
from almost nothing (in modern terms) with FORTH. And like FORTH, Python has the interactive console which is essential when starting out. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting into Python, comming from Perl.

2005-04-25 Thread Nick Craig-Wood
frustration :) I like to read books to retrain myself. That may not be your way, but if it is I'd recommend Dive into Python by Mark Pilgrim as a good first step. Its available for free in electronic form too. After that you could read Programming Python. Good luck! -- Nick Craig-Wood [EMAIL

Re: Python licence again

2005-04-25 Thread Nick Craig-Wood
has [EMAIL PROTECTED] wrote: licence, practice = noun license, practise = verb Tick ;-) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Faster os.walk()

2005-04-20 Thread Nick Craig-Wood
a very good cache for stat results, and that parsing file names is very quick too, compared to python. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Nokia to speak at Python-UK next week

2005-04-19 Thread Nick Craig-Wood
Ville Vainio [EMAIL PROTECTED] wrote: Nick == Nick Craig-Wood [EMAIL PROTECTED] writes: Nick Not entirely on topic, but does anyone know if there is a Nick series 80 python? Or if the series 60 python runs on a Nick series 80 phone (eg communicator 9300/9500)? Nope nope

Re: Memory leak in python

2005-04-19 Thread Nick Craig-Wood
writing objects with __del__ methods? If so then that is your problem probably. Have you written any extension modules in C? -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Compute pi to base 12 using Python?

2005-04-18 Thread Nick Craig-Wood
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm using GMPY (see code). [snip] If you are using gmpy you might as well do it like this. gmpy.pi() uses the Brent-Salamin Arithmetic-Geometric Mean formula

Re: Nokia to speak at Python-UK next week

2005-04-18 Thread Nick Craig-Wood
if there is a series 80 python? Or if the series 60 python runs on a series 80 phone (eg communicator 9300/9500)? -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Compute pi to base 12 using Python?

2005-04-14 Thread Nick Craig-Wood
0945656a159aa6aa0a845531a592005b8a34366b882257107b190969a846474836a9800750778920ba797297a2791101b0685a86bb704b9baa17b055293679843b35215b0a8b1182b611953b080aa5431b219907a8448a81b1a9493245676b88013b470335240859594158621014216! 619553246570601967448b470174b9244892444817453865a4003b5aa7176451aab906 [EMAIL PROTECTED]' -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue.Queue-like class without the busy-wait

2005-04-04 Thread Nick Craig-Wood
about leaving the current threading alone, but adding a pthreads module for those OSes which can use or emulate posix threads? Which is windows and most unixes? -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue.Queue-like class without the busy-wait

2005-04-03 Thread Nick Craig-Wood
Paul Rubin http wrote: Nick Craig-Wood [EMAIL PROTECTED] writes: I believe futex is the thing you want for a modern linux. Not very portable though. That's really cool, but I don't see how it can be a pure userspace operation if the futex has a timeout. The kernel must need to keep

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Nick Craig-Wood
they share memory space, in which case the application is commonly called multithreaded. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: An Odd Little Script

2005-03-10 Thread Nick Craig-Wood
. The solution posted previously using mmap actually does it in-place though which will work very well for files 4GB. (And not at all for files 4GB unless you are on a 64 bit machine). -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman

Re: shuffle the lines of a large file

2005-03-08 Thread Nick Craig-Wood
at auto tuning though. You may want to set --temporary-directory also to save filling up your /tmp. In a previous job I did a lot of stuff with usenet news and was forever blowing up the server with scripts which used too much memory. sort was always the solution! -- Nick Craig-Wood [EMAIL

Re: os.system()

2005-03-07 Thread Nick Craig-Wood
:00 \_ sleep 60 Things to check 1) quoting, python vs shell 2) PATH - check PATH is set the same in shell / python 3) check the whole of the environment Also if you are using 2.4 check the subprocess module -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

Re: accessor/mutator functions

2005-03-01 Thread Nick Craig-Wood
Dan Sommers [EMAIL PROTECTED] wrote: On 28 Feb 2005 10:30:03 GMT, Nick Craig-Wood [EMAIL PROTECTED] wrote: Actually I would say just access the attribute directly for both get and set, until it needs to do something special in which case use property(). The reason why people fill

Re: accessor/mutator functions

2005-03-01 Thread Nick Craig-Wood
into a method with a useful name, or add well named intermediate variables, or add an assertion. Its a point of view... Not 100% sure I agree with it but I see where he is coming from. I like a doc-string per public method so pydoc looks nice myself... -- Nick Craig-Wood [EMAIL PROTECTED

Re: Regular Expressions: large amount of or's

2005-03-01 Thread Nick Craig-Wood
-wood.com/nick/pub/words-to-regexp.pl Yes its perl and rather cludgy but may give you ideas! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: accessor/mutator functions

2005-02-28 Thread Nick Craig-Wood
of the users. In python you just swap from direct attribute access to using property(). Also note that with property() you can make an attribute read only (by defining only the get method) which is often the encapsulation you really want - and that is something you can't do in C++. -- Nick Craig

Re: Flushing print()

2005-02-28 Thread Nick Craig-Wood
Cameron Laird [EMAIL PROTECTED] wrote: gf, remember to write sys.stdout.flush() rather than sys.stdout.flush That's a mistake that catches many. Many old perl programmers anyway (me included)! Its also a mistake pychecker catches. -- Nick Craig-Wood [EMAIL PROTECTED

Re: Explicit or general importing of namespaces?

2005-02-28 Thread Nick Craig-Wood
? -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimal, __radd__, and custom numeric types...

2005-02-28 Thread Nick Craig-Wood
. You could try this with a local copy of decimal.py since it is written in Python. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Comm. between Python and PHP

2005-02-22 Thread Nick Craig-Wood
structured data around. XML-RPC is part of the python standard library (SimpleXMLRPCServer and xmlrpclib) and there seem to be several implementations for PHP http://www.google.co.uk/search?q=xml+rpc+php That might be overkill for what you want though! -- Nick Craig-Wood [EMAIL PROTECTED

Re: low-end persistence strategies?

2005-02-18 Thread Nick Craig-Wood
and man flock -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Nick Craig-Wood
propose joinany which will join any type of object together, not just strings That way it becomes less of a poke in the eye to backwards compatibility too. Nick Explicit is better than Implicit Aye! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http

Re: low-end persistence strategies?

2005-02-16 Thread Nick Craig-Wood
debian package for just it and not the whole of Zope. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: [PATCH] allow partial replace in string.Template

2005-02-14 Thread Nick Craig-Wood
patch d) add a test suite patch -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pyMinGW support for Python 2.3.5 (final) is available

2005-02-13 Thread Nick Craig-Wood
this with python + extensions also. Yes, I was thinking of setting up a cross-compiling system, but why would you use mingw instead of just gcc on Linux? ...because we cross-compile for Windows under linux. The linux builds are done with plain gcc of course. -- Nick Craig-Wood [EMAIL

Re: For American numbers

2005-02-13 Thread Nick Craig-Wood
, for example if you order a 2 Mbit/s line you'll get 2 * 1024 * 1000 bits / s ;-) -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pyMinGW support for Python 2.3.5 (final) is available

2005-02-12 Thread Nick Craig-Wood
build host. The windows builds are done with a mingw cross compiler. It would be interesting if we could do this with python + extensions also. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficient checksum calculating on lagre files

2005-02-11 Thread Nick Craig-Wood
Christos TZOTZIOY Georgiou [EMAIL PROTECTED] wrote: On 09 Feb 2005 10:31:22 GMT, rumours say that Nick Craig-Wood [EMAIL PROTECTED] might have written: But you won't be able to md5sum a file bigger than about 4 Gb if using a 32bit processor (like x86) will you? (I don't know how the kernel

Re: goto, cls, wait commands

2005-02-11 Thread Nick Craig-Wood
The last language I saw with this very useful feature was FORTH in about 1984! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: probably weird or stupid newbie dictionary question

2005-02-10 Thread Nick Craig-Wood
is the comparability. In java, this is done using the equals method. So in the end, the actual mapping of key, value looks like this: hash(key) - [(key, value), ] Thats called hashing with chaining. See Knuth: Sorting and Searching if you want to know more! -- Nick Craig-Wood [EMAIL PROTECTED

Re: convert list of tuples into several lists

2005-02-10 Thread Nick Craig-Wood
think of dereferencing things (eg pointer de-reference in C). Its equivalent to the now deprecated apply function which does the same thing in a more wordy fashion, ie apply the list as parameters to the function. apply(zip, [(1, 2, 3), (4, 5, 6)]) [(1, 4), (2, 5), (3, 6)] -- Nick Craig-Wood

Re: Python and version control

2005-02-10 Thread Nick Craig-Wood
in Windows either. When I have to edit stuff on windows I use emacs. Cvs works fine on windows too. I haven't tried cvs in emacs on windows, but I suspect it will work fine as all emacs does is shell out to the cvs binaries. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread Nick Craig-Wood
for the python and java output I would guess. Java bytes are signed also just to add to the confusion. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python as capable as Perl for sysadmin work?

2005-02-09 Thread Nick Craig-Wood
;-) Thanks for a very amusing post! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   >