Re: Authorize.net integration problem

2009-03-31 Thread andrew cooke
have you printed msg and checked it is formatted correctly? i have node idea what the protocol is, but your use of join and string concatenation in the generation of msg looks unusual to me. andrew Lakshman wrote: > I am trying to integrate Authorize.net SIM API into django views. >

Re: Deleteing empty directories

2009-03-30 Thread andrew cooke
wrong order (is it possible to reverse the order?) the documentation for os.walk() explains how to reverse the order. http://docs.python.org/3.0/library/os.html#os.walk andrew > > It seems the only way is to manually walk the tree myself recursively > and then back up deleteing a directory i

Re: Caught out by daylight saving :-(

2009-03-30 Thread andrew cooke
OG.debug(format_exc()) exception = e if exception: raise ValueError(_('Could not parse %s: %s') % (day, exception)) else: raise ValueError(_('Could not parse %s') % (day)) def format_utc_date(epoch, format='%Y-%m-%d %H:%M:%S UTC'): da

Re: Re. suid/sudo in python

2009-03-30 Thread andrew cooke
so take care, for example, to allow only "read-like" commands to be executed, by exposing explicit methods for those rather than the unix commands as a whole) (are you sure the information you need is not available via reading /proc?) andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing PLPython - Version Problem

2009-03-29 Thread andrew cooke
be pretty easy. andrew ray wrote: > I am trying to get Python 2.6 and PostgreSQL 8.3 to work together > under Windows 2000. > > When I try to add Python to PostgreSQL via: > createlang plpythonu dbname > > But when doing so, I get an error: > createlang: language installat

Re: PyFits for Windows?

2009-03-29 Thread andrew cooke
y. The govt. sites seem to have troubles on the weekend. sorry, no idea (i used to work on iraf, but left a couple of years ago). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with dict and iter

2009-03-29 Thread andrew cooke
can probably simplify the code. this might work: job_machine = list(map(iter, JOBS)) andrew [...] > Well, you are right, just creating every time a new dict is a good > solution, I was just adding complexity to a simple problem, thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with dict and iter

2009-03-29 Thread andrew cooke
r that resets itself - i've done it by adding a special reset exception and then using generator.throw(Reset()) - but it's a lot more complicated and i don't think you need it. if you do, you need to look at writing generators explicitly using yield, and then at "enhanced generators" for using throw(). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: PyFits for Windows?

2009-03-29 Thread andrew cooke
rtainly support manipulating fits files etc, but may be a bit "heavweight" for your needs. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating Linked Lists in Python

2009-03-28 Thread andrew cooke
Aahz wrote: > In article , > andrew cooke wrote: >>(I've just noticed that the comments in Sequence are incorrect, >>unfortunately - please ignore any mention of "index"). > > s/comments/lies/ per my .sig ;-) [...] > "At Resolver we've found i

Re: Creating Linked Lists in Python

2009-03-28 Thread andrew cooke
l (you can see the source there too) and available as part of LEPL. (I've just noticed that the comments in Sequence are incorrect, unfortunately - please ignore any mention of "index"). Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: converting a string to a function parameter

2009-03-28 Thread andrew cooke
pe', u'rect') +- karg (u'sizes', [3, 4]) `- karg (u'coords', ([1, 2], [3, 4])) you can then access those values: >>> ast[0].arg [True] >>> ast[0].karg [('type', 'rect'), ('sizes', [3, 4]), ('coords', ([1

Re: Unladen-Swallow: A faster python

2009-03-28 Thread andrew cooke
dev i wonder if this is the first indication that python is going to split into separate implementations for windows and unix (via .net and llvm, respectively)? andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Any way to use a range as a key in a dictionary?

2009-03-27 Thread andrew cooke
andrew cooke wrote: > i don't completely follow what you are doing, but i currently use the > following to find a transition in a finite automaton for a regular > expression, and i suspect it's similar to what you want. i get the impression the original poster went away,

Re: c.l.py dead, news at 11 (was Re: Mangle function name with decorator?)

2009-03-27 Thread andrew cooke
nother reason might be that the action has moved on to Haskell. I get the impression that it is undergoing the same kind of surge in popularity from the "smart early adopters" that Python might have benefited from back in the day (for some perverse reason I am actually moving back to Python f

Re: c.l.py dead, news at 11 (was Re: Mangle function name with decorator?)

2009-03-27 Thread andrew cooke
I hope that clarifies things. I *really* don't want this to develop into a criticism of current posters (which is completely unfair), so I am unlikely to respond further to this thread. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Any way to use a range as a key in a dictionary?

2009-03-26 Thread andrew cooke
y that gives you the idea. bisect can be used to find values via a sorted index. so once you find "index" above, you can use that to return a value from an array. i doubt this is super-fast (i think the bisect library is pure python), but it was good enough for my initial attempt. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Code anntotations (copyright, autor, etc) in your code

2009-03-26 Thread andrew cooke
mattia wrote: > Hi all, which are the usual comments that you put at the beginning of your code to explain e.g. the author, the usage, the license etc? the GPL has guidelines at http://www.fsf.org/licensing/licenses/gpl-howto.html andrew -- http://mail.python.org/mailman/listi

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread andrew cooke
Peter Otten wrote: > I would be surprised by the behaviour of Andrew's variant: > >>>> def append(item, items=None): > ... items = items or [] > ... items.append(item) > ... return items > ... >>>> a = [] >>>> append(&q

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread andrew cooke
None..." is pretty standard python that makes it clear exactly what you are doing. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Puzzling: local variable in recursive function made global?

2009-03-26 Thread andrew cooke
it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT to is_terminal and appending values to it. instead, make a new copy: branch.next.is_terminal(list(seen_nodes)) sorry for the shouting, but someone asks this EVERY DAY AND I CAN'T TAKE ANY MORE. a

Re: Introducing Python to others

2009-03-26 Thread andrew cooke
ta[1]]) > > x = Vector([1,2]) > > print x+x that's cute, but if you show them 2.6 or 3 it's even cuter: >>> from operator import add >>> class Vector(list): ... def __add__(self, other): ... return map(add, self, other) ... >>> x = Vector([1,2]) >>> x+x [2, 4] andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Python version(s) for new project?

2009-03-26 Thread andrew cooke
Philip Semanchuk wrote: > [...]. I just want to > leverage the -3 switch on Python 2.6 to keep an eye on how many 3.x- > incompatible features I'm using. Some will be unavoidable -- print > versus print() comes to mind -- but ideally when the time comes to > support 3.x, we can just run 2to3 and be

Re: Python version(s) for new project?

2009-03-26 Thread andrew cooke
un on the "standard" 2.6 release. but it may conflict with your requirements. note - my experience is with taking 3.0 code and trying to make it run on 2.6 (easy) and 2.5 (hard). i guess it is possible things are easier if you start out with all 3 in mind. andrew > My constraints: >

Re: What way is the best to check an empty list?

2009-03-25 Thread andrew cooke
sub-item, just before the references. http://www.python.org/dev/peps/pep-0008/ andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: What way is the best to check an empty list?

2009-03-25 Thread andrew cooke
Andre Engels wrote: > On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote: >> i will go against the grain slightly and say that "len" is probably the >> best compromise in most situations (although i admit i don't know what [...] >> but i may be wrong -

Re: What way is the best to check an empty list?

2009-03-25 Thread andrew cooke
ere any containers (apart from pathological hand-crafted examples) that would not define __len__()? andrew srinivasan srinivas wrote: > > For ex: to check list 'A' is empty or not.. > if A == []: > if A.count == 0: > if len(A) == 0: > if not A: > > Thanks, > Sr

Re: Does Python have certificate?

2009-03-25 Thread andrew cooke
ds for of course) and decided i was a philosopher. so i am officially registered as a philosopher. and that apparently means i can have a programming job... no, i don't understand either :o) anyway, enough chat. better get back to philosophizing about some database queries that don't seem

Re: Unit testing frameworks

2009-03-25 Thread andrew cooke
copy+paste error; the correct Python2.6 details are: Python 2.6 (r26:66714, Feb 3 2009, 20:49:49) andrew cooke wrote: > this is with a homebuilt 3.0 - Python 3.0 (r30:67503, Jan 16 2009, > 06:50:19) and opensuse's default 2.6 - Python 3.0 (r30:67503, Jan 16 2009, > 06:50:19

Re: Unit testing frameworks

2009-03-25 Thread andrew cooke
t; and "python unit test". i can select all modules in a packages by shift-clicking (ie selecting all modules) and doing the same. but in 3.0 i cannot click on a package (directory), run it as a test, and so run all test modules inside the package. not even the top "src" direc

Re: [ANN] pylint 0.18 / logilab-astng 0.19 / logilab-common 0.39

2009-03-25 Thread andrew cooke
python 3? :o) (thanks anyway - pylint is very useful, and saved me much work) Sylvain Thénault wrote: > oops, forgot the mail content :$ Here it is... > > > I'm pleased to announce releases of pylint 0.18, logilab-astng > 0.19 and logilab-common 0.39. All these packages should now be > cleanly

Re: Tkinter - Multiple Tk() instances/mainloops in one process?

2009-03-25 Thread andrew cooke
ter from the main loop to poll a threading Queue that your thread writes). I have seen it suggested that a thread can safely use event_create to communicate with the main thread, but have found this is not safe. andrew Gregory Sheaffer wrote: > I've been working on a Python proj

Re: Unit testing frameworks

2009-03-24 Thread andrew cooke
projects - you can run tests from inside eclipse (using the pydev plugin for python). it's easy to run all tests or some small subset (although it is a bit buggy for 3.0). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Wiki syntax available when publishing on pypi

2009-03-24 Thread andrew cooke
with that convention used in sphinx). also - if there's any kind of syntax error, pypi displays the entire description literally (and gives no other error feedback that i have found). andrew Luca wrote: > A non python, but pypi only related question: > > Where I can find a reference guide

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread andrew cooke
andrew cooke wrote: ffs. feature, not bug. sorry. > This is probably quite fundamental (I guess the lexer will implement it) > so suspect it is impossible to change. That means it is a bug, not a > feature (and it's quite a reasonable restriction, since it reduces > ambi

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread andrew cooke
That means it is a bug, not a feature (and it's quite a reasonable restriction, since it reduces ambiguity). See http://docs.python.org/3.0/reference/simple_stmts.html#import http://docs.python.org/3.0/reference/lexical_analysis.html#grammar-token-identifier Andrew simon.wo...@gmail.com w

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread andrew cooke
ah, sorry, from title i guess you were aware of this. andrew andrew cooke wrote: > note that your version is open to sql injection attacks, while mrab's > reply isn't. andrew > > someone wrote: >> if mf: >> mf = " AND mf = %s "

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread andrew cooke
note that your version is open to sql injection attacks, while mrab's reply isn't. andrew someone wrote: > if mf: > mf = " AND mf = %s " % mf > if age: > age = " AND age = %s " % age -- http://mail.python.org/mailman/listinfo/python-list

Re: safely rename a method with a decorator

2009-03-22 Thread andrew cooke
there was discussion related to this same problem earlier in the week. http://groups.google.com/group/comp.lang.python/browse_thread/thread/ad08eb9eb83a4e61/d1906cbc26e16d15?q=Mangle+function+name+with+decorator%3F andrew Daniel Fetchinson wrote: > I'd like to implement a decorator th

Re: Lambda forms and scoping

2009-03-22 Thread andrew cooke
(),d[bollox][1]())] in alpha in beta Traceback (most recent call last): File "", line 1, in File "", line 2, in c TypeError: 'NoneType' object is not callable which is just the combination of: >>> c(d[bollox][0],d[bollox][1]) in alpha in beta >

Re: Using python 3 for scripting?

2009-03-22 Thread andrew cooke
mahesh wrote: > python 2.5 is prefered; no it is not. andrew -- http://mail.python.org/mailman/listinfo/python-list

Crunchy [Was: Preparing teaching materials]

2009-03-21 Thread andrew cooke
7;t find (quickly) an explanation of the implementation. since there only seem to be videos and not an actual demo page, i assume you need to install it locally? is there a technical introduction? cheers, andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Organize large DNA txt files

2009-03-21 Thread andrew cooke
770100 1780040 1890002 bash can also iterate over files trivially. you do not need python for this. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: script files with python (instead of tcsh/bash)?

2009-03-21 Thread andrew cooke
hat it played to bash's strengths, but even so i was quite surprised. it brought home to me that bash really is quite powerful. so you might be better spending the time improving your bash skills than doing what will be largely drudge work in a language you already know. andrew ps i just checke

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
that associates other resources with memory use. just because, in one limited case, you can do something, doesn't mean it's a good idea. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
andrew cooke wrote: > Aaron Brady wrote: >> On Mar 21, 7:54 am, "andrew cooke" wrote: >>> they should not be used to do things like flushing and closing >>> files, for example. >> What is your basis for this claim, if it's not the mere unreliabil

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
Aaron Brady wrote: > On Mar 21, 7:54 am, "andrew cooke" wrote: >> they should not be used to do things like flushing and closing >> files, for example. > What is your basis for this claim, if it's not the mere unreliability > of finalization? IOW, are you n

Re: Creating Linked Lists in Python

2009-03-21 Thread andrew cooke
andrew cooke wrote: [...] i messed up my example; corrected below (I hope) > in your case you could use ints for the nodes and a dict([int]) for the > graph. so: > {1: [2,3], 2: [1,3], 3: [3]} > > is a graph in which 1 and 2 are connected in each direction, both 1 and 2 > are

Re: Creating Linked Lists in Python

2009-03-21 Thread andrew cooke
simplest is to use a dict() that maps from source to destination node(s). in your case you could use ints for the nodes and a dict([int]) for the graph. so: {1: [2,3], 2: [3], 3: [3]} is a graph in which 1 and 2 are connected in each direction, both 1 and 2 are linked to 3, and 3 has a loop

Re: garbage collection / cyclic references

2009-03-21 Thread andrew cooke
Paul Rubin wrote: > "andrew cooke" writes: >> the two dominant virtual machines - .net and the jvm both handle >> circular >> references with no problem whatever. > > AFAIK, they also don't guarantee that finalizers ever run, much less > run in determ

Re: Smalltalk-like Python IDE ?

2009-03-20 Thread andrew cooke
odo as you use it? (I'm not even sure how you'd make something like a smalltalk environment in Python, because the languages are different (disclaimer, almost all my limited experience with Smalltalk is Squeak)). Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: garbage collection / cyclic references

2009-03-20 Thread andrew cooke
argets a variety of vms, i think). as for the extra methods you suggest - why do you want to expose implementation details in an api? that is not the normal aim of good design. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Disable automatic interning

2009-03-18 Thread andrew cooke
e __eq__ method (sometimes it can be very useful for nodes to be considered equal even when they are separate instances - for example in generating cyclic graphs). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread andrew cooke
sorry, ignore that. hit send before thinking properly. > have you looked in operators? that might avoid the need for a class. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread andrew cooke
have you looked in operators? that might avoid the need for a class. Jim Garrison wrote: > S Arrowsmith wrote: >> Jim Garrison wrote: >>> It's a shame the iter(o,sentinel) builtin does the >>> comparison itself, instead of being defined as iter(callable,callable) >>> where the second argument

Re: Mangle function name with decorator?

2009-03-18 Thread andrew cooke
, just that you have to find them yourself (especially with the decline of this newsgroup). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread andrew cooke
ried you think you have seen something that you have not, especially given your incorrect text above. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in Python?

2009-03-17 Thread andrew cooke
do something > buf = f.read(1) embarrassed by the other reply i have read, but not doing much binary i/o myself, i suggest: with open(...) as f: while (True): buf = f.read(1) if not buf: break ... but are you sure you don't want: with open(...) as f: for line in f: ... andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: How print binary data on screen

2009-03-17 Thread andrew cooke
Mensanator wrote: > Maybe he's looking for the face of Jesus? or aphex twin -- http://mail.python.org/mailman/listinfo/python-list

Re: packaging

2009-03-17 Thread andrew cooke
it's normal behaviour. see http://docs.python.org/3.0/tutorial/modules.html#importing-from-a-package for example, in my lepl parser - http://www.acooke.org/lepl/api/lepl-pysrc.html andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Mangle function name with decorator?

2009-03-17 Thread andrew cooke
ou might look at the code for the property decorator - it's not doing what you want, but it's an interesting non-trivial example that's public. http://docs.python.org/library/functions.html#property andrew Adam wrote: > Thanks, Andrew. I'm trying to accomplish something

Re: Mangle function name with decorator?

2009-03-17 Thread andrew cooke
ult. it's kind of obvious, but it's possible you didn't know methods were first class entities. class Foo: def __init__(self, useBar=False): if useBar: self.foo = self.__bar else: self.foo = self.__foo def __foo(self): print('foo') def __bar(self): print('bar') andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: array next pointer

2009-03-17 Thread andrew cooke
ry. not sure from what version, but certainly in 2.6 and on, you can improve the syntax slightly: >>> b = iter(a) >>> next(b) andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: array next pointer

2009-03-17 Thread andrew cooke
Andre Engels wrote: [...] >>>> b = a.__iter__() >>>> b.next() > 'cat' >>>> b.next() > 'dog' not sure from what version, but certainly in 2.6 and on, you can improve the syntax slightly: >>> b = iter(a) >>> b.next() andrew -- http://mail.python.org/mailman/listinfo/python-list

Pycon Spam

2009-03-16 Thread andrew cooke
t this? It starts: This year's Python Conference is in Chicago and will feature topics ranging from web development and scientific computing Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: can error messages be improved or can they be overridden ?

2009-03-15 Thread andrew cooke
rdmur...@bitdance.com wrote: > "andrew cooke" wrote: >> rdmur...@bitdance.com wrote: >> [...] >> > (You know, I really ought to revisit that routine and make it part >> > of my standard development toolbox.) >> >> please post it > >

Re: PyPy Progress (and Psyco)

2009-03-15 Thread andrew cooke
t happened > last year was a culling of a lot of the side projects that made it > harder to make progress on the core goals. This is so good to hear. I had exactly the same concerns as Gerhard. Thanks for posting some information. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this type of forward referencing possible?

2009-03-15 Thread andrew cooke
Paul McGuire wrote: > On Mar 15, 6:33 am, "andrew cooke" wrote: >> someone else has answered this, but an extra trick that is sometimes >> useful is that while there is no forward referencing you can often >> exploit late binding and evaluation order. [...] > Not

PyPy Progress (and Psyco)

2009-03-15 Thread andrew cooke
This looks very promising - http://www.voidspace.org.uk/python/weblog/arch_d7_2009_03_14.shtml#e1063 I am really looking forwards to PyPy having a final release. I hope it happens. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this type of forward referencing possible?

2009-03-15 Thread andrew cooke
method level is only evaluated when called, so class A: def __init__(self): self.someType = B class B: anotherType = A will work. andrew Kooks are people too wrote: > If I try this: > > class A: > someType = B > > class B: > anotherType = A > >

Re: how to repeat function definitions less

2009-03-14 Thread andrew cooke
. >>> c = Colours() >>> c.red(1) 1 red andrew alex goretoy wrote: > I'm doing this in my code, how to make it define all this functions for me > with lambda, I've been up for a while and cant seem to figure it out, > whats > the most efficient way to do i

TypeError when creating frozenset with no hash

2009-03-14 Thread andrew cooke
r containers implemented in C? Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: An ordering question

2009-03-13 Thread andrew cooke
MRAB wrote: > >>> a = [(4, 1), (7, 3), (3, 2), (2, 4)] > >>> b = [2, 4, 1, 3] > >>> d = dict((v, k) for k, v in a) > >>> c = [(d[s], s) for s in b] > >>> c > [(3, 2), (2, 4), (4, 1), (7, 3)] ah, that is more efficient than the su

Re: An ordering question

2009-03-13 Thread andrew cooke
(7, 3), (3, 2), (2, 4)] >>> b = [4, 2, 1, 3] >>> a.sort(key=lambda xy: b.index(xy[1])) >>> a [(2, 4), (3, 2), (4, 1), (7, 3)] however, it's not very efficient. it would be better to do: >>> a = [(4, 1), (7, 3), (3, 2), (2, 4)] >>> b = [4, 2, 1, 3] >>> idx = dict((b[i], i) for i in range(len(b))) >>> a.sort(key=lambda xy: idx[xy[1]]) >>> a [(2, 4), (3, 2), (4, 1), (7, 3)] for large lists andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread andrew cooke
;>> format(1234.5, ',2f') # proposed new option '1234,50' >>> format(1234.5, '.,2f') # proposed new option '1.234,50' because that would support a moderate chunk of the non-english speaking users and seems like a natural extension. (i'm still not sure this is that great an idea - if you think using a locale is "rocket science" then perhaps your excess energy would be better spent making locale easier, rather than tweaking this behaviour for a subset of users?) andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Raw String Question

2009-03-13 Thread andrew cooke
MRAB wrote: > andrew cooke wrote: >> MRAB wrote: >> [...] >>> The other special case is with \u in a Unicode string: >>> >>> >>> ur"\u0041" >>> u'A' >> >> this isn't true for 3.0: >> >>>

Re: Raw String Question

2009-03-12 Thread andrew cooke
MRAB wrote: [...] > The other special case is with \u in a Unicode string: > > >>> ur"\u0041" > u'A' this isn't true for 3.0: >>> r"\u0041" '\\u0041' (there's no "u" because it's a string, not a by

Re: lexical analysis of python

2009-03-10 Thread andrew cooke
. in that way you would stay with a machine-generated lexer and parser, with just a simple hand-written shim between them. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: A parser for S.W.I.F.T. MT940 Files (for banking transactions)

2009-03-09 Thread andrew cooke
one other thing - LEPL *only* works with Python 2.6 and 3.0. it WILL NOT work with Python 2.5. if this is an issue then it is not a suitable solution (it is not possible to back-port the library). andrew andrew cooke wrote: > > a month is more than enough - i would expect to have som

Re: A parser for S.W.I.F.T. MT940 Files (for banking transactions)

2009-03-09 Thread andrew cooke
any parser (and related libraries) thoroughly before using it in a critical application. cheers, andrew ps i'm not sure this conversation should continue on the python list! Mustafa Sakalsiz wrote: > I can wait for a month. I can also provide test data, but I am not sure if > their siz

Re: factory functions & methods

2009-03-08 Thread andrew cooke
andrew cooke wrote: > above is with 3.0. for some odd reason i thing the order of teh args to > MethodType may have changed recently, so be careful. sorry, no, had 2.6 running there... andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: factory functions & methods

2009-03-08 Thread andrew cooke
print x ... >>> from types import MethodType >>> class Bar: ... def __init__(self): ... self.foo = MethodType(foo, self) ... >>> b = Bar() >>> b.foo() <__main__.Bar instance at 0x7f35edb091b8> above is with 3.0. for some odd reason i thing the order of te

Re: Help cleaning up some code

2009-03-08 Thread andrew cooke
andrew cooke wrote: > odeits wrote: >> On Mar 7, 1:07 pm, Scott David Daniels wrote: >>> odeits wrote: >>> > I am looking to clean up this code... any help is much appreciated. >>> > Note: It works just fine, I just think it could be done cleaner. >&

Re: Help cleaning up some code

2009-03-08 Thread andrew cooke
d) >> >> --Scott David Daniels >> scott.dani...@acm.org > > Taking from several suggestions this is what i have come up with for > now: > > for row in ifilter(lambda r: r['ni'] == rows[0]['ni'],rows): not sure what version of python yo

Re: Help cleaning up some code

2009-03-07 Thread andrew cooke
ah, yes, i didn't see that clearly. in this case it might be better to have: def copy(src, dst, name, null): value = src[name] dst[name] = null if value is None else value and then make it explicit in both cases: copy(row, ad, name, null=None) ... copy(row, ad, name, null='None

Re: Help cleaning up some code

2009-03-06 Thread andrew cooke
', 'rundate', 'status'): copy(row, ad, name) for name in ('city', 'state'): copy(row, ad, name, quote_none=True) if stack and stack[0][NI] != ad[NI]: break stack.append(ad) but couldn't you change the query so that it only returns a single 'ni'? also, do you really want to break, or just skip the append? maybe you want: if not stack or stack[0]['ni'] == ad['ni']: stack.append(ad) or perhaps the 'ni' are sorted (in which case what you are doing makes some sense). andrew > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a better way of doing this?

2009-03-06 Thread andrew cooke
used to select a line at random from a file by scanning the file just once. sorry if i have misunderstood, andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
might need to work around python's stupid scoping rules with hidden params: def ifamultb(x, a=a): etc andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Asking for prophecy

2009-03-06 Thread andrew cooke
move there. no-one wants to do a perl. it's the likely future and you can always jump back to 2.6 if needed. and in the long term, we will all die. andrew Stefan Spoettl wrote: > In the pass it was always a good idea to use the newest Python verison for > starting the development of a n

Re: Eclipse And PyDev

2009-03-06 Thread andrew cooke
ctrl-space? Steve Phillips wrote: > All, > I realize this question may not belong here but I am going to ask anyway > to > the current users of Eclipse and PyDev. It's regarding the auto-complete > feature. Say you want to type "sys.path.append('yada yada yada')", using > say Komodo or IDLE. W

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread andrew cooke
ut that is more understandable). i am wondering if you have hidden problems related to co and contra variance of types (like in java generics). also, why is "@" needed as well as yield? in python, the presence of yield makes "@" implicit (i think). andrew Limin Fu wrote: >

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
e class name should be something that *means* something more than just "common variables". please, try *thinking* about what the rules mean, instead if just following them. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorators

2009-03-06 Thread andrew cooke
structured to make fundamental changes to how methods work. so in python decorators can also do things like define static and class methods. so they provide a unified approach to what, in other languages, tend to be unrelated ideas. andrew Johny wrote: > Hi, > Can anyone explain to me wh

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
ating yourself (since you may one day need to change one set, but not the other set). andrew Neal Becker wrote: > Maybe I'm missing something obvious here > > def A (...): > #set a bunch of variables > x = 1 > b = 2 > ... > > Do something with them > > def

Re: alias method definitions / syntactic sugar suggestion

2009-03-06 Thread andrew cooke
here's also next methods, can't think of anything else off the top of my head) andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: help understanding class or function

2009-03-05 Thread andrew cooke
looking at ML or Scheme or Erlang useful later... andrew > The actual functions I am making are more complicated than this example. > Thanks > Vincent Davis > 720-301-3003 > > > On Thu, Mar 5, 2009 at 5:13 PM, Gabriel Genellina > wrote: > >> En Thu, 05 Mar 2009

In search of the click track

2009-03-05 Thread andrew cooke
thought people might find this article on drummer's "click tracks" interesting - http://musicmachinery.com/2009/03/02/in-search-of-the-click-track/ here's the python lib used - http://developer.echonest.com/docs/method/remix/ andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Sphinx for API documentation

2009-03-05 Thread andrew cooke
k back + forth without too much bother. it's a bit of an aesthetic shock (to put it politely) going from sphinx to epydoc, but it's a lot more useful for someone who wants to see source etc. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: distutils: "build" command

2009-03-05 Thread andrew cooke
don't know if this is useful, but setuptools is a plug-in replacement for distutils that makes this kind of thing easier (i think). http://peak.telecommunity.com/DevCenter/setuptools andrew TP wrote: > Hi everybody, > > I have programmed a python package, and I would like to

Re: Does profiling remove some optimisations?

2009-03-05 Thread andrew cooke
Gabriel Genellina wrote: > En Thu, 05 Mar 2009 07:39:20 -0200, andrew cooke > escribió: > >> I have a core loop that is critical to performance. The code is at >> http://www.acooke.org/lepl/api/lepl.parser-pysrc.html#trampoline >> >> If I write a separate "o

<    5   6   7   8   9   10   11   12   13   14   >