Re: accessor/mutator functions

2005-03-01 Thread Nick Craig-Wood
complicated code 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 <[

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

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

2005-02-28 Thread Nick Craig-Wood
ept the right operand: when an instance of a given class is expected, an instance of a subclass of that class is always acceptable. 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: Explicit or general importing of namespaces?

2005-02-28 Thread Nick Craig-Wood
pe (like the warnings subsystem). This is surely a job for pychecker / pylint? -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

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

Re: accessor/mutator functions

2005-02-28 Thread Nick Craig-Wood
y the get method) which is often the encapsulation you really want - and that is something you can't do in C++. -- 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
he data you want to pass is structured then you might consider XML-RPC which is a cross platform way of passing 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/sea

Re: low-end persistence strategies?

2005-02-18 Thread Nick Craig-Wood
f and fcntl is unspecified.)" see man lockf 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
er method to do this? I 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:

Re: low-end persistence strategies?

2005-02-16 Thread Nick Craig-Wood
ish (being lazy) that there was a seperate 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
ners with one-liners. c) add a documentation 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: For American numbers

2005-02-13 Thread Nick Craig-Wood
Yes. Unless you work in the telcoms industry, where, 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-13 Thread Nick Craig-Wood
lds are done with plain gcc of course. -- 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
indows) on a linux 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: goto, cls, wait commands

2005-02-11 Thread Nick Craig-Wood
else: # do stuff when not found 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: 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 (

Re: Python and version control

2005-02-10 Thread Nick Craig-Wood
gt; > Emacs + CVS (or CVSNT) should work just fine 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

Re: convert list of tuples into several lists

2005-02-10 Thread Nick Craig-Wood
) [(1, 4), (2, 5), (3, 6)] -- 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
ble objecst 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 kno

Dr. Dobb's Python-URL! - weekly Python news and links (Feb 9)

2005-02-09 Thread Craig Ringer
QOTW: "Such infrastructure building is in fact fun and instructive -- as long as you don't fall into the trap of *using* such complications in production code, where Python's simplicity rules;-)." -- Alex Martelli http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/41a6c

Dr. Dobb's Python-URL! - weekly Python news and links (Feb 9)

2005-02-09 Thread Craig Ringer
QOTW: "Such infrastructure building is in fact fun and instructive -- as long as you don't fall into the trap of *using* such complications in production code, where Python's simplicity rules;-)." -- Alex Martelli http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/41a6c

Re: Efficient checksum calculating on lagre files

2005-02-09 Thread Nick Craig-Wood
Thomas Heller <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > Here is an implementation of md5sum in python. Its the same speed > > give or take as md5sum itself. This isn't suprising since md5sum is > > dominated by CPU usage

Re: Efficient checksum calculating on lagre files

2005-02-09 Thread Nick Craig-Wood
ile = open(fn, "rb") >>> size = os.path.getsize(fn) >>> size 8590983168L >>> hash = md5.md5(mmap.mmap(file.fileno(), size)).hexdigest() Traceback (most recent call last): File "", line 1, in ? OverflowError: memory mapped size is too large (limited by C int) >>> -- 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
27;... or die "You [EMAIL PROTECTED]"' works even better ;-) 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

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread Nick Craig-Wood
0 176 ° > de 222 Þ > 8a 138 > e3 227 ã > b5 181 µ > b7 183 · > 51 81 Q > a7 167 § > c4 196 Ä > d8 216 Ø > e9 233 é > ed 237 í > eb 235 ë > > which is not even close, and yes, I know that it's not the same > code. Actually the hex digi

Re: Efficient checksum calculating on lagre files

2005-02-08 Thread Nick Craig-Wood
5sum(files): for filename in files: try: print "%s %s" % (md5file(filename), filename) except IOError, e: print >> sys.stderr, "Error on %s: %s" % (filename, e) if __name__ == "__main__": md5sum(sys.argv[1:]) -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Where are list methods documented?

2005-02-01 Thread Nick Craig-Wood
tation which is only available in HTML format - I'd much rather type "pydoc whatever" to see it all, rather than have to load my browser, and click through several layers of web pages. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: What's so funny? WAS Re: rotor replacement

2005-01-31 Thread Nick Craig-Wood
sions of DES for instance). -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: limited python virtual machine

2005-01-30 Thread Nick Craig-Wood
. ...it also uses python for its control programs. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: What's so funny? WAS Re: rotor replacement

2005-01-30 Thread Nick Craig-Wood
API. The cryptkit way is better than ECB > example I gave, but the ECB example shows it's possible to do it in > one call. There is a PEP about this... API for Block Encryption Algorithms v1.0 http://www.python.org/peps/pep-0272.html -- Nick Craig-Wood <[EMAIL PROTEC

Re: What's so funny? WAS Re: rotor replacement

2005-01-30 Thread Nick Craig-Wood
depend on any other library or application. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: What's so funny? WAS Re: rotor replacement

2005-01-29 Thread Nick Craig-Wood
ome up with, via Google's Cache. http://www.google.com/search?q=cache:U5-RsbkSs0MJ:www.cs.chalmers.se/Cs/Grundutb/Kurser/krypto/lect04_4.pdf -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: debugging os.spawn*() calls

2005-01-28 Thread Nick Craig-Wood
ng wrong. > > While not a 'real' answer - I use pexpect to automate my ssh scripts > these days as I had a few problems using ssh with the os.* family > perhaps you may find pexpect a wee bit easier... If using 2.4 the subprocess module is a good solution

Re: Elliptic Code

2005-01-28 Thread Nick Craig-Wood
Philip Smith <[EMAIL PROTECTED]> wrote: > I understand the algorithm quite well but how to code the multiplication > stage most efficiently in python eludes me. You might want to look at http://gmpy.sourceforge.net/ It has very fast multiplication up to any size you like! --

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Craig Ringer
create another type. Well, a type is essentially a class (in the OOP sense, not the python- specific classobj sense). You can call a type or class to create an instance of that class or type. Here, you call the 'instancemethod' type to create an instance of type 'instancemethod'.

Re: example needed: sip + Qt

2005-01-28 Thread Craig Ringer
the PyQt/PyKDE list (and search its archives first). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Hello

2005-01-27 Thread Craig Ringer
newsreader to use that. Once your newsread is talking correctly to your ISP's news server, *then* you can subscribe to comp.lang.python. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: XOR on string

2005-01-27 Thread Nick Craig-Wood
it -s'import operator; string = "abcdefghij13123kj12l3k1j23lk12j3l12kj3"' \ 'reduce(operator.xor, map(ord, string))' 10 loops, best of 3: 15.6 usec per loop -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Inherting from object. Or not.

2005-01-27 Thread Nick Craig-Wood
;>> raise MyOldException Traceback (most recent call last): File "", line 1, in ? __main__.MyOldException: <__main__.MyOldException instance at 0xb7df4cac> >>> After that I recalled a thread on python-dev about it http://mail.python.org/pipermail/python-dev

Re: Help With Python

2005-01-27 Thread Nick Craig-Wood
order()] * 7 > py> ', '.join(orders) > 'Spam, Spam, Spam, Spam, Spam, Spam, Spam' Thats still one Viking making 7 orders surely? Eg >>> vikings = [Viking()] * 7 >>> vikings[0] is vikings[1] True whereas >>> vikings = [Viking() for _ in rang

Re: Classical FP problem in python : Hamming problem

2005-01-27 Thread Nick Craig-Wood
code] Thanks for some more examples of fp-style code. I find it hard to get my head round so its been good exercise! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: exclude binary files from os.walk

2005-01-26 Thread Craig Ringer
()? > > > > > > Sure, assuming you can provide a rigorous definition of 'binary > > files'. :) > > non-ascii That's not really safe when dealing with utf-8 files though, and IIRC with UCS2 or UCS4 as well. The Unicode BOM its self might (I'm not sure) qualify as ASCII. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: python without OO

2005-01-26 Thread Craig Ringer
so small and approachable. I also love the way I can chuck a bunch of objects into a functionally styled processing pipeline, say a series of functions that each just return the result of a listcomp/genexp. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write a tutorial

2005-01-26 Thread Craig Ringer
quot; moron who appears to have nothing to do with either, or any knowledge of them. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Classical FP problem in python : Hamming problem

2005-01-25 Thread Nick Craig-Wood
Steven Bethard <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > Thinking about this some more leads me to believe a general purpose > > imerge taking any number of arguments will look neater, eg > > > > def imerge(*generators): > >

Re: Classical FP problem in python : Hamming problem

2005-01-25 Thread Nick Craig-Wood
, hamming5) ): yield n hamming2, hamming3, hamming5, result = tee(_hamming(), 4) return result (Note the iter(...) seemed not to be doing anything useful so I removed them) -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Classical FP problem in python : Hamming problem

2005-01-25 Thread Nick Craig-Wood
ming(), 4) return result PS interesting thread - never heard of Hamming sequences before! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to do a series of regexp checks with groups

2005-01-23 Thread Nick Craig-Wood
7;, line)): do_add(m.value.group(1), m.value.group(2)) elif m.set(re.search(r'mult (\d+) (\d+)', line)): do_mult(m.value.group(1), m.value.group(2)) elif m.set(re.search(r'help (\w+)', line)): show_help(m.value.group(1)) -- Nick Craig-Wood <[EMAIL PROTECTED]> --

Re: default value in a list

2005-01-22 Thread Nick Craig-Wood
Alex Martelli <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > ... > > Or this version if you want something other than "" as the default > > > > a, b, b = (line.split(':') + 3*[None])[:3] > >

Re: need help on need help on generator...

2005-01-22 Thread Craig Ringer
On Sat, 2005-01-22 at 12:20 +0100, Alex Martelli wrote: > Craig Ringer <[EMAIL PROTECTED]> wrote: > > > .>>> data = ''.join(x for x in infile) > > Maybe ''.join(infile) is a better way to express this functionality? > Avoids 2.4 dependen

Re: default value in a list

2005-01-22 Thread Nick Craig-Wood
use this old trick... a, b, c = (line+"::").split(':')[:3] Or this version if you want something other than "" as the default a, b, b = (line.split(':') + 3*[None])[:3] BTW This is a feature I miss from perl... -- Nick Craig-Wood <[EMAIL PROTECTED]>

Re: need help on need help on generator...

2005-01-22 Thread Craig Ringer
t the cost of making it less clear what's going on and having someone later go "duh, why isn't he using read() here instead" but can't seem to do much more than that. Might it be worth providing a way to have file objects seek back to the current position of the iterator when r

Re: need help on need help on generator...

2005-01-22 Thread Craig Ringer
his than: .>>> inpath = '/tmp/msg.eml' .>>> infile = open(inpath) .>>> initer = iter(infile) .>>> headers = [] .>>> for line in initer: if not line.strip(): break headers.append(tuple(line.split(':',1))) .&

Re: rotor replacement

2005-01-22 Thread Nick Craig-Wood
Note that some of these are being worked on at sourceforge just like python. Surely it must be possible to add a few simple crypto modules to python? That said a) IANAL b) 'apt-get install python-crypto' works for me ;-) -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: finding name of instances created

2005-01-21 Thread Craig Ringer
ct: > >> do_stuff(name) > > Any help, pointers, sketches or outline of solution would be greatly > appreciated. I'm not really able to grasp what you're trying to do (but others might). It wouldn't hurt if you could post a description of what you're actually trying to achieve - /why/ you want this - as that can often be very helpful both in understanding what you're thinking and in suggesting a suitable approach or alternative. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Craig Ringer
). > Python is pretty stable, so it's usually best to suspect our own code > unless you're heavily into using the C API (which I'm not, so feel free > to ignore me). That's been my experience - stability issues in my Python/C code have almost always come down to refcounting bugs and/or failing to detect and handle or propagate an exception. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Craig Ringer
LL (meaning a failure, probably of memory allocation). I also don't see anything in there to resize the tuple. http://docs.python.org/api/tupleObjects.html -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Configuring Python for Tk on Mac

2005-01-21 Thread Craig Ringer
n't build Python with Tk support. > What do I do to set it up so I can use Tkinter? Try Google - this seems to be a moderately FAQ for MacOS/X. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on generator...

2005-01-21 Thread Craig Ringer
ttp://www.python.org/peps/pep-0289.html http://docs.python.org/whatsnew/node4.html http://www.python.org/dev/doc/newstyle/ref/genexpr.html for details. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on need help on generator...

2005-01-21 Thread Craig Ringer
er handy. I'm not sure how many Python built-in functions and library modules return generators for things. > I know this is now the case for reading lines in a file or with the > new "iterator" package. But what else ? Does Craig Ringer answer mean > that list comprehensi

Re: Dynamic properties

2005-01-21 Thread Craig Ringer
s though, personally. I'd want to look into using a class factory or metaclass to do the job if __getattr__ and __setattr__ are insufficient or unacceptable. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: need help on generator...

2005-01-21 Thread Craig Ringer
On Fri, 2005-01-21 at 22:38 +0800, Craig Ringer wrote: > consecutive_sets = ( x[offset:offset+subset_size] > for subset_size in xrange(2, len(x)) > for offset in xrange(0, len(x) + 1 - subset_size) ) Where 'x' is list to operate

Re: need help on generator...

2005-01-21 Thread Craig Ringer
in xrange(2, len(x)) for offset in xrange(0, len(x) + 1 - subset_size) ) -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Overloading ctor doesn't work?

2005-01-21 Thread Nick Craig-Wood
Why is that? Its a bug! http://sourceforge.net/tracker/index.php?func=detail&aid=720908&group_id=5470&atid=105470 However its been fixed in a recent Python 2.3. (I was bitten by the same thing which used to fail but now works after an upgrade of python 2.3!) -- Nick Cr

Re: [OT] Good C++ book for a Python programmer

2005-01-19 Thread Craig Ringer
can avoid the "sometimes works, sometimes doesn't" fun of referencing deleted memory by accident. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: rotor replacement

2005-01-19 Thread Nick Craig-Wood
Cast5+6, DES, Serpent, Twofish, TEA, etc. The linux kernel+source surely goes everywhere python does so I don't think adding strong crypto modules to python is a problem now-a-days. AES in the core python library would be very useful and it would discourage people from writing the

Re: lambda

2005-01-17 Thread Craig Ringer
the Python/C API. That said, I do think "the rules" deserve consideration and respect - they're usually there because of many others' experience over time. It's interesting to learn those lessons first hand, but it's nice to be able to avoid repeating every single one

Executing a script created by the end user

2005-01-16 Thread Craig Howard
I am working on a python project where an object will have a script that can be edited by the end user: object.script If the script is a simple one with no functions, I can easily execute it using: exec object.script But if the object script is a bit more complicated, such as the example belo

Re: [Fwd: Re: Embedding Multiplr Python interpreter in C++]

2005-01-15 Thread Craig Ringer
e thread per sub-interpreter, or if it can support multiple sub interpreters in a single thread. Any ideas? I'm pretty sure it's the former, but it'd be nice to be sure. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Free python server.

2005-01-13 Thread Craig Ringer
e in the cgi-bin, not public_html, (b) be flagged executable ("chmod a+x file.py"), and (c) begin with the line: '#!/usr/bin/env python' If the server doesn't provide you with CGI (or, strongly preferable, SCGI or mod_python), you're probably out of luck. -- Craig

Re: counting items

2005-01-13 Thread Craig Ringer
lice__(0, 0, > x[1:]))) > or (not x and rest and cur.append(rest.pop(0] > > ;-) If it means I _never_ have to see that list comprehension again, then seeing 'flatten' go into itertools would make me very, very happy :-P -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Craig Ringer
one obvious way than what we have now. And then we have iteration (generator expressions, list comprehensions, for loops, ...?) over (sequences, iterators, generators) I happen to be extremely fond of the flexibility this provides, but one obvious way to do it there is not. -- Craig Ringer

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

2005-01-13 Thread Nick Craig-Wood
unstable -> testing (and eventually) -> stable. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

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

2005-01-13 Thread Nick Craig-Wood
2.2.3-10 An interactive high-level object-oriented la ii python2.3 2.3.4-18 An interactive high-level object-oriented la ii python2.4 2.4-2 An interactive high-level object-oriented la -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Refactoring; arbitrary expression in lists

2005-01-13 Thread Nick Craig-Wood
# raise NoMimeError return t[0] for f in ("index.php", "index.php3", "prog.cc", "prog.cpp", "flodge.xsl", "Makefile", "myMakefile", "potato.123"): print f, detectMimeType(f) ... prints index.php applicatio

Re: Python.org, Website of Satan

2005-01-12 Thread Craig Ringer
> or, if you haven't upgraded to 2.4, yet: That'll work fine in Python 2.3. I think you meant: print sum(ord(x) for x in "PyPy") which is a different matter entirely (well, regarding compatibility anyway). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: here document

2005-01-11 Thread Craig Ringer
t;) > print >>f , """CategoryY = GRIB > etc. > """ You mean "os.popen" not "open" I assume? The former opens a pipe to a command, the latter overwrites the file. I'd use: os.popen("/bin/exe.x", "w").write("""\ CategorY = GRIB etc. """) myself, but that's just taste (well, and performance I suspect). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: C structure in the Python extension

2005-01-10 Thread Craig Ringer
x27;t too hard, though the Python/C API does make creating types a bit cumbersome. (Most of this seems to be because you're playing pretend-we-have-objects in C, rather than issues specific to the Python/C API). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: windows mem leak

2005-01-10 Thread Nick Craig-Wood
etc. [sorry not Python related but may solve your problem!] -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: _tkinter problem

2005-01-07 Thread Craig Ringer
(Yes, I know yours isn't Python 2.4 - it doesn't matter). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Help uninstalling/installing Python 2.4

2005-01-07 Thread Craig Ringer
in ? > import readline > ImportError: No module named readline > > I think some paths are screwed up.. can someone take pity on me and give > me a hand. I'd say that'll be the same as with Tkinter - you probably didn't have the GNU readline development headers installed, so Python disabled readline support when it was compiled. That's just a guess, but seems pretty likely. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: how to extract columns like awk $1 $5

2005-01-07 Thread Craig Ringer
t;)[4:6] ['something', 'about'] so if 'x' is your string, the rough equivalent of that awk statement is: .>>> x_words = x.split() .>>> print x_words[4], x_words[5] or perhaps .>>> print "%s %s" % tuple(x.split()[4:6]) -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting on keys in a list of dicts

2005-01-07 Thread Craig Ringer
e-sorting by a different key... but you didn't know what key was last used for sorting. A stable sort algorithm means you don't need to care, because the order will be maintained for you not randomized. Well, that's several hundred more words than were probably required, but I hope I made sense. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: missing sys.setappdefaultencoding

2005-01-07 Thread Craig Ringer
e...;-) Agreed. I prefer to use explicit str.encode(), str.decode() and unicode() calls where appropriate. On a side note, PEP 263 handles the text encoding interpretation of Python program source, and is well worth reading and following. http://python.org/peps/pep-0263.html -- Craig Ringer --

Re: curses is not imported under Linux (and Python 2.4)

2005-01-06 Thread Craig Ringer
ckages (providing the ncurses header files and static libs) installed. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding a restricted python interpreter

2005-01-06 Thread Craig Ringer
Apache might well be able to respawn failed subprocesses, it's not > something that most hosting providers would like to have to do all the > time for many hosted sites. I wonder if SCGI or a similar "persistent CGI" solution might be more practical for running CGI scripts under spec

Re: File Handling Problems Python I/O

2005-01-06 Thread Craig Ringer
r not there are trailing path separators on the input strings. os.path.join can take more than two arguments, too. os.path has lots of other handy tools, so I strongly recommend checking it out. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C Object Comparison

2005-01-06 Thread Craig Ringer
a class and make the class own and manage the C++ object (and pointer to it) that it owns. Perhaps that's a better solution for you too? If you want any opinions from folks here about the best way to solve your problem, you'll probably need to explain a bit more of your problem - like

Re: Embedding a restricted python interpreter

2005-01-06 Thread Craig Ringer
On Thu, 2005-01-06 at 23:05, Peter Maas wrote: > Craig Ringer schrieb: > It would certainly be difficult to track all harmful code constructs. > But AFAIK the idea of a sandbox is not to look at the offending code > but to protect the offended objects: files, databases, URLs, socket

Re: Embedding a restricted python interpreter

2005-01-04 Thread Craig Ringer
> I do not know if it is possible to disable or override 'import'.. You can do a fair bit to it by wrapping/replacing __builtin__.__import__ . Preventing people from getting around what you've done, though... not sure. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Bad Interpreter

2005-01-03 Thread Craig Ringer
say something like : > > python sock.py > > but ./sock.py results in a :bad interpreter error > how do i troubleshoot something like this? You probably have Windows-style line endings in the file. The kernel sees the ^M at the end of the line and gets all confused. -- Craig Ringer -- http:/

RE: removing comments form a file

2005-01-03 Thread Craig Ringer
27;d be interested if you could clarify what you mean there. As far as I know, the whole file will only be read into memory if you use file.read () or file.readlines(). If you use an iterator it does internal readahead, but won't read the lot at once. If you use read() it reads only what

Re: Developing Commercial Applications in Python

2005-01-03 Thread Craig Ringer
plication. You'd simply need to keep an eye on the licenses of any extensions you used, like ReportLab, PIL, mx, database interfaces, twisted, etc. Many are licensed under the same license as Python or an MIT-like license, but of course some Python extensions are not and you would need to con

Re: emulating an and operator in regular expressions

2005-01-03 Thread Craig Ringer
7;not (not A or not B)' I thought I could try something along those lines, > but can't crack it. My first thought would be to express your 'A and B' regex as: (A.*B)|(B.*A) with whatever padding, etc, is necessary. You can even substitute in the sub-regex for A and B to avoid

Re: screen clear question

2005-01-01 Thread Craig Ringer
t clear' or '/usr/bin/clear' on many UNIX systems; no idea about Windows. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: exposing C array to python namespace: NumPy and array module.

2005-01-01 Thread Craig Ringer
le approach to me, but I'm hardly an expert. The code's license permits you to do so, and it's hardly worth repeating the work if you don't have to. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: exposing C array to python namespace: NumPy and array module.

2005-01-01 Thread Craig Ringer
s, etc. In my case, its easier to execute snippets as shown above than it is to worry about the module search path and wrapping things using a Python module. If you're doing substantial amounts of Python coding for your module, you'll almost certainly be better off writing a Python module that uses your C module internally (see PIL for a good example of this). -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed ain't bad

2004-12-31 Thread Craig Ringer
oited. True; however, it's my understanding that compressing individual files also means that in the case of damage to the archive it is possible to recover the files after the damaged file. This cannot be guaranteed when the archive is compressed as a single stream. -- Craig Ringer -- http:

Re: Probleme mit der Installation der openSource Bittorrent.... python vs JAVA

2004-12-30 Thread Craig Ringer
et) than Python in this case anyway. This is probably not the right place. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

Re: Updating file objects automatically

2004-12-30 Thread Craig Ringer
's just a stab in the dark, but perhaps it might be. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8   9   >