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: 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 >

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

2005-01-10 Thread John Lenton
Class.__methods__ > 2) dict (because of default values: "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 bac

Re: unicode mystery

2005-01-10 Thread John Lenton
; different value for the second parameter, maybe?) Å isn't 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:

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 >

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

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: XPath and XQuery in Python?

2005-01-13 Thread John Lenton
read()) although you might want to be smarter with the errors... -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: The whole world is a scab. The point is to pick it constructively. -- Peter Beard signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: directory bug on linux; workaround?

2005-01-13 Thread John Lenton
. But I was > wondering if anyone had a better option? the bug is because os.path is assuming posix semantics, which fat doesn't have. Not using fat sounds like the best idea to me, but I'm probably strongly biased against that piece of crap. -- John Lenton ([EMAIL PROTECTE

Re: how to control the mouse pointer with python?

2005-01-13 Thread John Lenton
quot;, and start reading. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Obviously I was either onto something, or on something. -- Larry Wall on the creation of Perl signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

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

2005-01-13 Thread John Lenton
ex(' ') if sep == -1: name = line[1:].strip() else: name = line[1:sep].strip() index[name] = pos last = name self.index = index db = FASTA("/home/john/tmp/uniprot_sprot.fasta") print db["104K_THEP

Re: Producer/consumer Queue "trick"

2005-01-14 Thread John Lenton
em, I would probably have set up different server processes (consumer(s), producer(s), and queue(s)), coordinated by somthing like pyro's event server. But I don't really know the problem, so it's probably just bad guesswork on my part---you probably don't need to scale at all.

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

2005-01-14 Thread John Lenton
cond argument, and with its access argument in sync with open()'s second arg. -- 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

strange note in fcntl docs

2005-01-16 Thread John Lenton
ould 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: fefinining % of c'm'y and k

2005-01-16 Thread John Lenton
lose to the second, but YMMV. Converting from these image-specific average values to CMYK is a non-trivial problem (impossible in the general casew); see for example http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2d0c54513c4970f7 where this issue was discussed. -- Joh

Re: lambda

2005-01-17 Thread John Lenton
using mutables as hash keys, we advise newbies > to stick with immutable keys until they have gathered > enough knowledge and experience to adequatly weight > the pro and cons of a mutable key solution against > an immutable key solution. knowledgeable and experienced users know when to igno

Re: strange note in fcntl docs

2005-01-17 Thread John Lenton
would go against what I understand is the essence of os.open (i.e., a direct road to open(2)). Hmm, if the above sounds a little harsh, sprinkle :)s in. I've had too little sleep. -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: If you're right 90% of the time, why quibble about

Re: strange note in fcntl docs

2005-01-18 Thread John Lenton
[snip] yes, and it takes me back to considering why 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.a

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 rule

Re: One-Shot Property?

2005-01-18 Thread John Lenton
cing it with the computed value of the property. Line 9 shows that it worked, line 11 shows that it didn't break the class, and line 13 (through the absence of an exception) shows that it no longer is 'special' (as it shouldn't be). -- John Lenton ([EMAIL PROTECTED]) -

Re: simultaneous multiple requests to very simple database

2005-01-19 Thread John Lenton
ctionary, and it isn't sql. The use you have in mind is a bit more complicated than the simple create-me-a-dictionary-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 ([EMAI

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

2005-01-23 Thread John Lenton
in a public forum, and *you* should know better 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: implicit conversion

2005-02-01 Thread John Lenton
gt; > Can someone help me please? as later on you say you have a constructor to convert longs into your bigints, you 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: htt

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

Re: a type without a __mro__?

2005-02-05 Thread John Lenton
bute__(attr) class D(object): __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 porq

Re: Confused with methods

2005-02-07 Thread John Lenton
;>> D.__new__ = __new__ >>> 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/mailman/listinfo/python-list

Re: Confused with methods

2005-02-07 Thread John Lenton
classes. I think __new__ being an exception to this is a (minor) 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 ten

Re: "Collapsing" a list into a list of changes

2005-02-07 Thread John Lenton
python is factorial = lambda n: reduce(operator.mul, range(1, n+1)) -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: Laugh and the world thinks you're an idiot. signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

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

Re: Big development in the GUI realm

2005-02-08 Thread John Lenton
> No need to continue. You write 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: Digita

Re: multi threading in multi processor (computer)

2005-02-09 Thread John Lenton
ry. and buying more, cheap 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:

Re: PyQt and Python 2.4 - also WinXP LnF?

2005-02-09 Thread John Lenton
> PyQt4 may I observe 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 --

Re: hard_decoding

2005-02-10 Thread John Lenton
so you compute the table once). You might also try to build the table incrementally, for i in strings: i = i.translate(table) try: i.encode('ascii') except UnicodeEncodeError: table = build_translation(i, table) i = i.translate(table)

Re: Alternative to raw_input ?

2005-02-11 Thread John Lenton
t;Availability: Unix". Any 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: check if object is number

2005-02-12 Thread John Lenton
cify only those 4 > (e.g. with a typecheck), since someone could relatively easily create > their own new numeric type with the same behavior. Do you know a better > way to test for this kind of behavior? Why don't you express just this need as an assertion? assert 0 <= max

Re: low-end persistence strategies?

2005-02-16 Thread John Lenton
mpare before writing out. Complexity grows a lot, and you suddenly would be better off using pybsddb or somesuch. Of course I'm probably overlooking something, because it really can't be this easy, can it? -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: BOFH excuse #44

Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
On Wed, Feb 16, 2005 at 10:43:42PM -0800, Michele Simionato wrote: > > > 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 PROTEC

Re: How to wrap a class's methods?

2005-02-17 Thread John Lenton
class MyImap4_ssl(IMAP4_SSL): pass for method_name in ('login', 'list', 'search'): setattr(MyImap4_ssl, method_name, getattr(IMAP4_SSL, method_name)) ? I'd usually put big fat warnings around this code, and explain exaclty why I need to do t

Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
ript at the same 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 should

Re: namespace collisions

2005-02-17 Thread John Lenton
h other modules not written by > myself. 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

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 s

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, becaus

Re: low-end persistence strategies?

2005-02-18 Thread John Lenton
nt your program will run 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.

Re: how can i randomly choose keys in dictionary

2005-02-18 Thread John Lenton
ts = [1,2,3,4] > > position = random.range(len(lists)) > > 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

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

2005-02-18 Thread John Lenton
ing/pushing is O(1) in both languages. Both versions can probably be tweaked for speed quite a bit, but I 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 thoug

Re: low-end persistence strategies?

2005-02-18 Thread John Lenton
league of badness as SysV IPC; I'd still mention SysV IPC to someone who asked about IPC on Linux, however, because there are places where it is useful even though most times it's a stupid way to do things (yes, Oracle, *especially* you). -- John Lenton ([EMAIL PROTECTED]) -- Random fortu

Re: exercise: partition a list by equivalence

2005-02-18 Thread John Lenton
an O(n). Of course! I'd forgotten clean about union-find. And yes, it's O(n*log(n)) union and find, and my implementation is O(n**2) for union, O(1) for find; I'm pleased that, in spite of having forgotten about union-find, I "reinvented" (heh) somethin

Re: exercise: partition a list by equivalence

2005-02-18 Thread John Lenton
, but that creature you dismiss as a slime-dripping mutation is actually quite useful. While I'm at being unpolite, do you really think this code was harder to understand than the code posted by anton, using numarray? And, of course, if this code were for anything non-throw-awayable, there wou

Re: exercise: partition a list by equivalence

2005-02-18 Thread John Lenton
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 ([EMAIL PROTECTED]) -- Random fortune: Todo bicho que camina va a parar cuando se canse. 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 L

Re: Recognizing the Arrival of a New File

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

Re: dot products

2004-12-20 Thread John Lenton
7;array' makes a and b Numeric's 'array' objects, with atlas installed (and hence dotblas loading and assembler version of dot tuned for the system's processor (in this case a pentium3)). The code in this case is simply Numeric.dot(a, b) The advantage of atlas on syste

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(

Re: vga output

2004-12-29 Thread John Lenton
ave fade outs). it run a minimalisc > 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

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, f

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, f