[issue1945] Document back ported C functions

2008-02-18 Thread John Lenton
John Lenton added the comment: This is the same as the previous patch, but I added the versionadded notation in the rst, and the info in refcounts.dat to get the return value info in the docs. Added file: http://bugs.python.org/file9461/1945-2.diff __ Tracker

[issue2112] mmap.error should be a subclass of EnvironmentError and not a direct EnvironmentError

2008-02-17 Thread John Lenton
John Lenton added the comment: Ran the regression test with this patch, all ok (on Ubuntu Gutsy). Attached diff is the same, with the addition of the NEWS entry. -- nosy: +Chipaca Added file: http://bugs.python.org/file9443/mmap3.diff __ Tracker [EMAIL

[issue1945] Document back ported C functions

2008-02-17 Thread John Lenton
John Lenton added the comment: Copied documentation from the py3k branch for the functions mentioned in the .h's (those were: PyLong_FromSsize_t, PyLong_FromSize_t, PyLong_AsSsize_t, PyUnicode_FromStringAndSize, PyUnicode_FromString, PyUnicode_FromFormat, and PyUnicode_FromFormatV). Tested

[issue1675533] setup.py LDFLAGS regexp is wrong

2008-01-19 Thread John Lenton
John Lenton added the comment: This was fixed in r57389 by georg.brandl by changing the replacement string '' to ' ' (turning the option into a non-option). Steps to reproduce this on Ubuntu Feisty, before that revision, were: $ mkdir banana $ sudo mv /usr/include/sqlite3.h banana/ $ make clean

[issue976880] mmap needs a rfind method

2008-01-19 Thread John Lenton
John Lenton added the comment: Attached patch adds two things: an 'end' argument to find, and an 'rfind' method. This includes minimal tests for rfind, but as I actually refactored find and rfind into a single method, tests covering find also cover most of rfind :). I added 'end' first because

[issue976880] mmap needs a rfind method

2008-01-19 Thread John Lenton
John Lenton added the comment: New patch, with small change after being reviewed by amk. Still against revision 60082. Added file: http://bugs.python.org/file9223/mmap.rfind.patch Tracker [EMAIL PROTECTED] http://bugs.python.org/issue976880

module placeholder

2005-04-15 Thread John Lenton
Once again I'm working on code that has several 'providers' of different features, and I thought I'd ask the list what better solutions it has to this other than what I've come up with. Currently, the cleanest way I can find is to say import foo foo.config(bar='baz') # from this point on,

Re: Recognizing the Arrival of a New File

2005-03-10 Thread John Lenton
there is a dnotify program which is easy enough to use, both from python or directly. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Knghtbrd 2fort5 sucks enough to have its own gravity ... signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: web status display for long running program

2005-02-24 Thread John Lenton
information doesn't fit nicely into a --verbose or | logger -- either too little or too much information at different | points. dd and pppd (and probably others) solve this problem by registering a signal handler that either toggles debug or prints status information to stderr. - -- John Lenton

Re: low-end persistence strategies?

2005-02-18 Thread John Lenton
mostly on Linux there is a bias towards lockf given its extra capabilities there. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: ¡¡ QQuuiittaa eell LLooccaall EEcchhoo,, MMaannoolloo !! signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python

Re: how can i randomly choose keys in dictionary

2005-02-18 Thread John Lenton
)) word = lists[position] Hi, try this: import random mydict={1: one, 2: two} print mydict[random.choice(mydict.keys())] if you're going to do that, why don't you do print random.choice(mydict.values()) ? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Quien da parte de sus

Re: [perl-python] exercise: partition a list by equivalence

2005-02-18 Thread John Lenton
don't *think* there's a better-than-O(n) algorithm for this. Note that the Python version assumes that the pairs' elements are hashable; your example used numbers, so I thought it was pretty safe assumption. The Perl version has no such restriction. -- John Lenton ([EMAIL PROTECTED]) -- Random

Re: low-end persistence strategies?

2005-02-18 Thread John Lenton
it is useful even though most times it's a stupid way to do things (yes, Oracle, *especially* you). -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: A pencil with no point needs no eraser. signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: exercise: partition a list by equivalence

2005-02-18 Thread John Lenton
saw in class. Now I'm even more worried about your dismissal of this as magic and horrible. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Why don't you fix your little problem... and light this candle? -- Alan Shepherd, the first man into space, Gemini program

Re: exercise: partition a list by equivalence

2005-02-18 Thread John Lenton
] # add it to list of partitions res.append(new) # update reverse mapping rev[first] = rev[second] = new # remove empty partitions return filter(None, res) hrmph, I should hit the sack. Sorry if this is still ugly, I'm too tired to tell. -- John Lenton

Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
On Wed, Feb 16, 2005 at 10:43:42PM -0800, Michele Simionato wrote: snip simple example with flock What happens if for any reason the application crashes? Locked files will stay locked or not? And if yes, how do I unlock them? the operating system cleans up the lock. -- John Lenton ([EMAIL

Re: How to wrap a class's methods?

2005-02-17 Thread John Lenton
)) ? I'd usually put big fat warnings around this code, and explain exaclty why I need to do things this way... -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: To vacillate or not to vacillate, that is the question ... or is it? signature.asc Description: Digital signature -- http

Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
time, and delete everything. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: If our behavior is strict, we do not need fun! signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES

2005-02-17 Thread John Lenton
On Thu, Feb 17, 2005 at 06:49:38PM +, Stephen Kellett wrote: Next you'll be telling me the world is flat and held up by an infinite array of tortoises. no, of course not! It's an iterator. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Test-tube babies shouldn't throw stones

Re: namespace collisions

2005-02-17 Thread John Lenton
. Whats the best way of handling this? If I put it in a common location in my Python path, should I call it willsutil.py? local.util is probably a convention worth starting :) or you could go with WilMcGugan.util but ThatGetsOldFast. -- John Lenton ([EMAIL PROTECTED]) -- Random

Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
On Thu, Feb 17, 2005 at 12:42:55AM -0800, Michele Simionato wrote: John Lenton: the operating system cleans up the lock. So, are you effectively saying than a custom made solution based on flock can be quite reliable and it could be a reasonable choice to use shelve+flock for small

Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
On Thu, Feb 17, 2005 at 09:02:37PM -0800, Michele Simionato wrote: John Lenton: Also, if you use something where the process doesn't terminate between calls (such as mod_python, I guess), you have to be sure to write the try/finallys around your locking code, because the OS only cleans up

Re: low-end persistence strategies?

2005-02-16 Thread John Lenton
probably overlooking something, because it really can't be this easy, can it? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: BOFH excuse #44: bank holiday - system operating credits not recharged signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo

Re: Alternative to raw_input ?

2005-02-11 Thread John Lenton
particular reason? readline should be fine on OSX and Win32 -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: sugar daddy, n.: A man who can afford to raise cain. signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: hard_decoding

2005-02-10 Thread John Lenton
) stripped.append(i) of course this won't work if you have other, non-ascii but non-composite, chars in your strings. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: El que está en la aceña, muele; que el otro va y viene. signature.asc Description: Digital signature -- http://mail.python.org

Re: multi threading in multi processor (computer)

2005-02-09 Thread John Lenton
computers gives you more processing power than buying less, multi-processor computers. So the best thing you can do is learn to leverage some distributed computing scheme. Take a look at Pyro, and its Event server. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: When the cup is full, carry

Re: PyQt and Python 2.4 - also WinXP LnF?

2005-02-09 Thread John Lenton
that if you're writing anything to do with xmms, you stick to plain ol' gtk1? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Hemos hallado al enemigo, y somos nosotros. -- Walt Kelly. signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python

Re: Big development in the GUI realm

2005-02-08 Thread John Lenton
something that uses a plugin, Eolas sues you. Don't have to mind about trolltech not if you live in a sane country. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Preserve wildlife -- pickle a squirrel today! signature.asc Description: Digital signature -- http://mail.python.org/mailman

Re: Confused with methods

2005-02-07 Thread John Lenton
method D.__new__ of course, __new__ is special-cased (*some*body should've read import this, especially the part explicit is better than implicit). -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Al freír será el reír. signature.asc Description: Digital signature -- http://mail.python.org

Re: Confused with methods

2005-02-07 Thread John Lenton
) wart, in fact it feels like premature optimization (how many __new__s do you write, that you can't stick a @staticmethod in front of them? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Fun Facts, #14: In table tennis, whoever gets 21 points first wins. That's how it once

Re: Collapsing a list into a list of changes

2005-02-07 Thread John Lenton
exactly what you want (and you have to go through hoops to do it otherwise). It also can be the fastest way to do something. For example, the fastest way to get the factorial of a (small enough) number in pure python is factorial = lambda n: reduce(operator.mul, range(1, n+1)) -- John Lenton

Re: Collapsing a list into a list of changes

2005-02-07 Thread John Lenton
On Mon, Feb 07, 2005 at 09:39:11PM +0100, Peter Otten wrote: John Lenton wrote: For example, the fastest way to get the factorial of a (small enough) number in pure python is factorial = lambda n: reduce(operator.mul, range(1, n+1)) I see

Re: a type without a __mro__?

2005-02-05 Thread John Lenton
): __metaclass__ = C instances of D have a type that behaves as if it didn't have a __mro__. This isn't exactly what you asked for, but it might be enough. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: El tiempo cura los dolores y las querellas porque cambiamos. Ya no somos la misma persona

Re: implicit conversion

2005-02-01 Thread John Lenton
should add a __coerce__ method to your class. General description of __coerce__: http://docs.python.org/ref/numeric-types.html#l2h-303 details on coercion rules: http://docs.python.org/ref/coercion-rules.html enjoy. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: BOFH excuse #309

Re: import doesn't work as i want

2005-02-01 Thread John Lenton
On Mon, Jan 31, 2005 at 04:52:24PM +0100, Olivier Noblanc ATOUSOFT wrote: Hello, In the botom of this post you will see my source code. The problem is when i launch main.py that doesn't make anything why ? I'm guessing you don't have an __init__.py in inc/ -- John Lenton ([EMAIL

Re: OT: problems mirroring python-list to c.l.py?

2005-01-23 Thread John Lenton
than to go around flapping your mouth like that. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Comer se ha de hacer en silencio, como los frailes en sus conventos. signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: simultaneous multiple requests to very simple database

2005-01-19 Thread John Lenton
-in-a-file, but is pretty straightforward. The documentation mostly refers you to the C API, but fortunately it (the C API) is clear and well written. HTH -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Today is National Existential Ennui Awareness Day. signature.asc Description: Digital

Re: strange note in fcntl docs

2005-01-18 Thread John Lenton
file objects don't have methods suck as lock, stat and mmap where those calls are available through other mechanisms... -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Yo mando a mi gato y mi gato manda a su rabo. signature.asc Description: Digital signature -- http://mail.python.org

Re: lambda

2005-01-18 Thread John Lenton
On Mon, Jan 17, 2005 at 03:20:01PM +, Antoon Pardon wrote: Op 2005-01-17, John Lenton schreef [EMAIL PROTECTED]: knowledgeable and experienced users know when to ignore the rules. Then why seems there to be so few acknowledgement that these rules may indeed be broken by users. My

Re: lambda

2005-01-17 Thread John Lenton
the pro and cons of a mutable key solution against an immutable key solution. knowledgeable and experienced users know when to ignore the rules. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Una buena gran parte del arte del bien hablar consiste en saber mentir con gracia

strange note in fcntl docs

2005-01-16 Thread John Lenton
it be elided? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Are Linux users lemmings collectively jumping off of the cliff of reliable, well-engineered commercial software? -- Matt Welsh signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: finding/replacing a long binary pattern in a .bin file

2005-01-14 Thread John Lenton
. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: If the aborigine drafted an IQ test, all of Western civilization would presumably flunk it. -- Stanley Garn signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteration over two sequences

2005-01-12 Thread John Lenton
Quite frequently, I find the need to iterate over two sequences at the same time, and I have a bit of a hard time finding a way to do this in a pythonic fashion. One example is a dot product. The straight-ahead C-like way of doing it would be: def dotproduct(a, b): psum = 0 for i in

Re: Iteration over two sequences

2005-01-12 Thread John Lenton
Downloading, installing, and getting to know numerical modules for Python is mext on my list :). However, I was under the impression that Numarray is preferred to Numeric -- is that correct? Are these two competing packages? (Hopefully this is not flame war bait...) Numeric's dot uses, if the

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread John Lenton
If you could help me figure out how to code a solution that won't be a resource whore, I'd be _very_ grateful. (I'd prefer to keep it in Python only, even though I know interaction with a relational database would provide the fastest method--the group I'm trying to write this for does not

Re: Writing huge Sets() to disk

2005-01-10 Thread John Lenton
On Tue, Jan 11, 2005 at 12:33:42AM +0200, Simo Melenius wrote: John Lenton [EMAIL PROTECTED] writes: you probably want to look into building set-like objects ontop of tries, given the homogeneity of your language. You should see imrpovements both in size and speed. Ternary search trees

Re: fetching method names from a class, and the parameter list from a method

2005-01-10 Thread John Lenton
: param = None) = Class.__method__[0].__params__ import inspect help(inspect) HTH -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: In Greene, New York, it is illegal to eat peanuts and walk backwards on the sidewalks when a concert is on. signature.asc Description: Digital signature

Re: unicode mystery

2005-01-10 Thread John Lenton
part of ISO 8859-1, so you can't get it that way. You can do one of u'\u0153' or, if you must, unicode(\305\223, utf-8) -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Lisp, Lisp, Lisp Machine, Lisp Machine is Fun. Lisp, Lisp, Lisp Machine, Fun for everyone. signature.asc Description

Re: Writing huge Sets() to disk

2005-01-10 Thread John Lenton
you probably want to look into building set-like objects ontop of tries, given the homogeneity of your language. You should see imrpovements both in size and speed. -- http://mail.python.org/mailman/listinfo/python-list

Re: vga output

2004-12-29 Thread John Lenton
OpenBSD kernel. Anyone already did something similar and/or have any recomendations? svgalib should do what you want; I don't know if there are python bindings for it, but they should be pretty easy to make if not. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Support wildlife

Re: consequences of not calling object.__init__?

2004-12-28 Thread John Lenton
in the code that follows, instances of E haven't been through D's rigorous initiation process .class C(object): .def __init__(self): .print C . .class D(object): .def __init__(self): .print D .super(D, self).__init__() . .class E(C,