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
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
>
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
; 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:
> 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
>
> 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
> 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
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
. 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
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
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
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.
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
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
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
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
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
[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
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
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]) -
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
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
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
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
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
;>> 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
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
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
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
> 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
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:
> 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
--
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)
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
, 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
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
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
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
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
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(
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
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
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
57 matches
Mail list logo