Re: PyPy Progress (and Psyco)

2009-03-15 Thread andrew cooke
Fuzzyman wrote: > On Mar 15, 3:46 pm, Gerhard Häring wrote: [...] >> Me too. I doubt it, though. From an outside view, the project seems to >> lack focus. To me, it looks like a research platform, and producing a >> successor to CPython seems to be just one out of a dozen projects. [...] > Well, I

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
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. your example will not work because code at the class level is evaluated when the module is loaded. but code at the me

Re: how to repeat function definitions less

2009-03-14 Thread andrew cooke
is this what you want (python 3.0)? >>> class Colours: ... def __init__(self): ... for colour in ['red', 'blue']: ... setattr(self, colour, lambda value, c=colour: self.write(value, c)) ... def write(self, value, colour): ... print(value, colour) ... >>> c = Colours() >>> c.red(

TypeError when creating frozenset with no hash

2009-03-14 Thread andrew cooke
I was going to file a bug report for this, but then I wondered if it was considered normal behaviour. Am I wrong in thinking there should be a better error message? >>> class NoHash: ... def __hash__(self): ... pass ... >>> frozenset([NoHash()]) Traceback (most recent call last): File ""

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 suggestions i posted. andrew -- http://mail.python.org/mailman/

Re: An ordering question

2009-03-13 Thread andrew cooke
Hrvoje Niksic wrote: > Kottiyath writes: > >> Hi, >> I have 2 lists >> a = [(4, 1), (7, 3), (3, 2), (2, 4)] >> b = [2, 4, 1, 3] >> >> Now, I want to order _a_ (a[1]) based on _b_. >> i.e. the second element in tuple should be the same as b. >> i.e. Output would be [(3, 2), (2, 4),

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

2009-03-13 Thread andrew cooke
Raymond Hettinger wrote: > [Lie Ryan] >> A hyphotetical code using conv function and the microlanguage could look >> like this: >> >>  >>> num = 213210.3242 >>  >>> fmt = create_format(sep='-', decsep='@') >>  >>> print fmt >> 50|\/|3_v3ry_R34D4|3L3_C0D3 >>  >>> '{0!{1}}'.format(num, fmt) >> '213-.

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 bytes literal) and as far as i can tell, that's correct behaviour according to the docs. andrew -

Re: lexical analysis of python

2009-03-10 Thread andrew cooke
robert.mull...@gmail.com wrote: > I understand the method, but when you say you "count one DEDENT for > each level" > well lets say you counted 3 of them. Do you have a way to interject 3 > consecutive > DEDENT tokens into the token stream so that the parser receives them > before it > receives the

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
es are big enough for you. If you mention your expectation for > test > data sizes, I will try to find them. > > Saki > > On Mon, Mar 9, 2009 at 5:06 PM, andrew cooke wrote: > >> Saki wrote: >> > Hello, >> > >> > I need an MT940 file parses.

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
Aaron Brady wrote: > Hello, > > I am creating a container. I have some types which are built to be > members of the container. The members need to know which container > they are in, as they call methods on it, such as finding other > members. I want help with the syntax to create the members. >

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
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. >> >> > The result is a stack of dictionaries. the query returns up to >> >

Re: Help cleaning up some code

2009-03-07 Thread andrew cooke
') andrew Paul Rubin wrote: > "andrew cooke" writes: >> def copy(src, dst, name, quote_none=False): >> value = src[name] >> dst[name] = 'None' if quote_none and value is None else value > > def copy(src, dst, name, default=None): >

Re: Help cleaning up some code

2009-03-06 Thread andrew cooke
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. > > The result is a stack of dictionaries. the query returns up to > STACK_SIZE ads for a user. The check which i think is very ugly is > putting an

Re: Is there a better way of doing this?

2009-03-06 Thread andrew cooke
i have not been following this discussion in detail, so someone may have already explained this, but it should not be necessary to actually construct the roulette wheel to select values from it. what you are doing is selecting from a list where the there are different probabilities of selecting d

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
Steven D'Aprano wrote: > Steve Holden wrote: > >> If x and b are meant to be global than bite the bullet and *make* them >> global. > > Well, there's global, and there's global. > > There's global to a few functions in a module, there's global to > everything > in a module, and global to an entire

Re: Asking for prophecy

2009-03-06 Thread andrew cooke
3 and 2.6 are compatible. so develop on 3, to make sure you don't use old junk, and then switch to 2.6 if you need to. there are a few wrinkles in doing so, but it is not a big problem. 3.0 is a nicer language. it's cleaner and more consistent. i think important libraries will move there. no

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
i agree it's not clear how this is related to python (although i can see the influence), but it does look like a nice language. one thing i was surprised to find missing was that the discussion of types doesn't include classes (the discussion of macros doesn't include types, but that is more unde

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
Neal Becker wrote: > What if I had: > > my_obj = common_variables() > That set all these attributes, but then with function A I inject them into > A's scope (shouldn't be too hard to do, I think)? "DRY" is a shorthand for people to remember, but it's not a direct law. i am worried that you are tr

Re: Decorators

2009-03-06 Thread andrew cooke
the arguments are similar to aspect oriented programming (so you could google that). sometimes you want to do a similar thing in various places in your code. the classic example is logging when a method is called. rather than adding logging statements to every method, you can use a decorator -

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
if the values are related in meaning then it seems possible that they should be attributes on an object. in which case you would use an instance of the object in both cases and set the values in the objects constructor. if they are not related in meaning then you're not really repeating yourself

Re: alias method definitions / syntactic sugar suggestion

2009-03-06 Thread andrew cooke
[sorry for dup terry; prev not to list] Terry Reedy wrote: > @alias('justAsFantastic') > def someFantasticMethod(args): ... does this exist? i read the previous post and thought "i think a decorator could do that", but i haven't written one. the reason i ask is that for 3->2 backwards compatabi

Re: help understanding class or function

2009-03-05 Thread andrew cooke
Vincent Davis wrote: > I guess I am thinking of it as an operation that I am preforming on a list > and not making a new list. Also looking to learn better methods. This is > difficult when you are working alone. It is difficult to know where to > improve. python occupies a strange place. in some

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
Benjamin Peterson wrote: > Paul Hildebrandt yahoo.com> writes: >> I really like the look of Sphinx BUT I want autogenerated >> documentation like Epydoc/doxygen. Does anyone know of a frontend for >> Sphix that will make it work like Epydoc? > > There's a Sphinx extension called autodoc which sho

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 use distutils with

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

Re: PyPI editing

2009-03-05 Thread andrew cooke
ah! thanks very much. that is obviously what i need to do. i am pretty sure i was doing the wrong thing, but am now at work. i'll check this tonight. thanks again, andrew David Stanek wrote: > On Thu, Mar 5, 2009 at 3:32 AM, andrew cooke wrote: >> >> Apparently not

Does profiling remove some optimisations?

2009-03-05 Thread andrew cooke
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 "optimised" version of that function for when "monitor" is empty, with all the "if monitor" tests removed, the profiler (cProfile) indicates a

Re: PyPI editing

2009-03-05 Thread andrew cooke
Apparently not (this will probably change, but see http://pypi.python.org/pypi/LEPL/2.0.1 which is currently displaying restructured text literally) Thanks, Andrew Chris Rebert wrote: > On Wed, Mar 4, 2009 at 11:42 PM, andrew cooke wrote: >> >> Not sure where to ask this, but h

Re: Dr Dobbs' Python Weekly URL Archive?

2009-03-04 Thread andrew cooke
if it's any help, i have them going back to march 2003 in an imap folder. i can provide a tarball or similar of a maildir. andrew Steve Holden wrote: > My well-known-search-engine-foo must be at an all-time low today. *Is* > there an index and I can't see for looking? > > regards > Steve > --

PyPI editing

2009-03-04 Thread andrew cooke
Not sure where to ask this, but how do I edit my PyPI page? http://pypi.python.org/pypi/LEPL/2.0 doesn't have any text compared to http://pypi.python.org/pypi/pypp/0.0.2 (selected at random). How do I the "Benefits", "Drawbacks" etc? I have clicked around the admin interface, but I only see wha

Re: Python parser

2009-03-04 Thread andrew cooke
Kay Schluehr wrote: > You'll most likely need a GLR parser. i'm not sure why you think this. as far as i can tell, the OP needs a parser that is suitable for whatever grammar they find (and the grammar will probably be written for a particular parser, which may not be GLR). however, if you are s

Re: Indentifying types?

2009-03-03 Thread andrew cooke
oh crap. sorry about that - replied to the wrong thread. andrew andrew cooke wrote: > > either will work for what you want. people in the python list prefer > python. you only have to post a question once. this gives an idea of the > relative popularity and trends: > http:/

Re: Indentifying types?

2009-03-03 Thread andrew cooke
either will work for what you want. people in the python list prefer python. you only have to post a question once. this gives an idea of the relative popularity and trends: http://www.google.com/trends?q=python+language%2C+perl+language andrew Oltmans wrote: > I'm reading from a file that co

Re: Pickle Problem

2009-03-03 Thread andrew cooke
maybe the following are simpler as they use print if you are using python 2.6 or python 3: >>> from __future__ import print_function >>> f = open('myfile.txt', 'w') >>> print(123, file=f) >>> print(456, file=f) >>> f.close() alternatively, in python 2.5 or 2.6: >>> f = open('myfile.txt', 'w'

Re: Pickle Problem

2009-03-03 Thread andrew cooke
Fab86 wrote: > I am wanting to store the integers in a file so that I can then run it > through some software without having to edit it. Will json enable me > to do this? no. ignore json - it is for something else entirely. all you need to do is to write the numbers out to a file: f = open('fil

Re: how to find all completely connected sub-graphs?

2009-03-03 Thread andrew cooke
if you mean "strongly connected components" then see http://en.wikipedia.org/wiki/Strongly_connected_component. there is no need to invent a solution; standard methods already exist. andrew Hyunchul Kim wrote: > Hi, all, > > How can I find all "completely connected subgraphs" in a graph when n

Re: Python parser

2009-03-02 Thread andrew cooke
Clarendon wrote: [...] > I need to parse a large amount of texts collected from the web (around > a couple hundred sentences at a time) very quickly, so I need a parser > with a broad scope of grammar, enough to cover all these texts. This > is what I mean by 'random'. so the most important things

Re: Performance of Python 3

2009-03-02 Thread andrew cooke
Isaac Gouy wrote: [...] > I think it would be silly to dispute whether or not programs that have > import psyco; psyco.bind are Python programs. > > I'm not sure it would be equally silly to dispute whether or not > programs with type declarations have moved away from being Python > programs. i do

Re: Python parser

2009-03-02 Thread andrew cooke
if this is for natural language texts you may want to look at http://www.nltk.org/ andrew Clarendon wrote: > Can somebody recommend a good parser that can be used in Python > programs? I need a parser with large grammar that can cover a large > amount of random texts. > > Thank you very much. >

Re: Reference or Value?

2009-02-24 Thread andrew cooke
Gabriel Genellina wrote: > En Tue, 24 Feb 2009 06:44:01 -0200, andrew cooke > escribió: > >> Steven D'Aprano wrote: >>> On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: >>> >>>> Steven D'Aprano wrote: >>>>> On Sun, 22

Re: Reference or Value?

2009-02-24 Thread andrew cooke
Steven D'Aprano wrote: > On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: > >> Steven D'Aprano wrote: >>> On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: >>> >>>> as far as i understand things, the best model is: >>>> &

Re: more on unescaping escapes

2009-02-23 Thread andrew cooke
do you know that a string with the letter "r" in front doesn't escape slashes? it's intended for regular expressions, but would simplify things for you here too. just do a=r'c:\\Program Files\test' andrew bvdp wrote: > > I'm getting hopelessly lost in a series of \\\ s :) > > Let's see

RE: Peculiar swap behavior

2009-02-23 Thread andrew cooke
andrew cooke wrote: > Delaney, Timothy (Tim) wrote: >> Tim Chase wrote: >>> # swap list contents...not so much... >>> >>> m,n = [1,2,3],[4,5,6] >>> >>> m[:],n[:] = n,m >>> >>> m,n >>> ([4, 5, 6], [4, 5

RE: Peculiar swap behavior

2009-02-23 Thread andrew cooke
Delaney, Timothy (Tim) wrote: > Tim Chase wrote: >> # swap list contents...not so much... >> >>> m,n = [1,2,3],[4,5,6] >> >>> m[:],n[:] = n,m >> >>> m,n >> ([4, 5, 6], [4, 5, 6]) [...] > For these types of things, it's best to expand the code out. The > appropriate expansion of: > m,n = [1,2

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

2009-02-23 Thread andrew cooke
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 andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: shared lib from python code?

2009-02-23 Thread andrew cooke
Gabriel Rossetti wrote: > Ok, maybe I mis-stated my problem (or mis-understood your answers).. I > don' t want to share code as in have multiple processes access a > variable and have the same value, like it is done in threads, what I > want is to not have n copies of the code (classes, functions,

Re: Reference or Value?

2009-02-23 Thread andrew cooke
Steven D'Aprano wrote: > On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: > >> as far as i understand things, the best model is: >> >> 1 - everything is an object >> 2 - everything is passed by reference > > Except that is wrong. If it were true, you

Re: Reference or Value?

2009-02-22 Thread andrew cooke
as far as i understand things, the best model is: 1 - everything is an object 2 - everything is passed by reference 3 - some objects are immutable 4 - some (immutable?) objects are cached/reused by the system andrew Torsten Mohr wrote: > Hi, > > how is the rule in Python, if i pass objects to

Re: how to assert that method accepts specific types

2009-02-20 Thread andrew cooke
Darren Dale wrote: > I would like to assert that a method accepts certain types. I have a > short example that works: just in case it's useful - are you aware that pep3107 (which looks like it should be leet-speak for something) is implemented in python 3? http://www.python.org/dev/peps/pep-3107/

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-20 Thread andrew cooke
lues to below 1000 makes things much faster # note 200,000 below, 20,000 above! summarise(compose(take(20), repeat(compose(ints, small, all_operators)))(START)) # get to larger values faster by sorting in the repeat #s

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-20 Thread andrew cooke
this is a neat problem. here is what i would do: use generators that extend an input. a stream approach. the initial input would be the numbers themselves. [('1', 1),('2', 2),('3', 3)] those are (expression, value) pairs then an initial attempt at the next function would be to extend that li

Re: Regular expression bug?

2009-02-19 Thread andrew cooke
i wonder what fraction of people posting with "bug?" in their titles here actually find bugs? anyway, how about: re.findall('[A-Z]?[a-z]*', 'fooBarBaz') or re.findall('([A-Z][a-z]*|[a-z]+)', 'fooBarBaz') (you have to specify what you're matching and lookahead/back doesn't do that). andrew

Re: Porting to new Python version

2009-02-19 Thread andrew cooke
ot;latest"; (3) moving from 2.4 to 2.6 is probably best done before branching for 3; (4) moving from 2.4 to 2.6 is probably easier than moving from 2 to 3. andrew andrew cooke wrote: > > i don't know what the context is, so it's hard for me to comment on the > decision (i ass

Re: Porting to new Python version

2009-02-19 Thread andrew cooke
i don't know what the context is, so it's hard for me to comment on the decision (i assume there are commerical pressures like customers not wanting to install old versions). however,if you go ahead, you need to think about exactly what you want to target. the latest version is really 3.0.1. mo

Re: SVN/CVS and Branching

2009-02-19 Thread andrew cooke
ant to work on the branch and remove the link > when i want to work on the head. This actually works fine, but > thought there may be a better way. > > Jeff > > On Wed, Feb 18, 2009 at 7:40 PM, andrew cooke wrote: >> >> maybe this is just me, but i don't have a cl

Re: SVN/CVS and Branching

2009-02-18 Thread andrew cooke
maybe this is just me, but i don't have a clue what your problem is. what does "starting imports all over the place" mean? what do you mean by "retired"? i use svn with python in exactly the same way as with java (and, i thought, in the same way as anyone uses svn with any language; java uses t

Re: number theory libraries / project euler

2009-02-18 Thread andrew cooke
eliben wrote: > Hello, > > What are some good & recommended number theory libs for Python (or > accessible interfaces to C libs), for things like primes, > factorization, etc. Naturally, speed is of utmost importance here. i just read the project site and one of the things they say on their front

Re: Is there something easier than ORM?

2009-02-17 Thread andrew cooke
Philip Semanchuk wrote: > In short, I gather that others on this list are a lot more fond of > SqlAlchemy and ORMs in general than I am. Granted, my experience is > very limited. I tried to integrate SqlAlchemy in one project, > struggled for a long time to express how I wanted my tables joined, >

Re: Will multithreading make python less popular?

2009-02-17 Thread andrew cooke
Bruno Desthuilliers wrote: > rushen...@gmail.com a écrit : > (snip) >> And the story begins here. As i search on the net, I have found that >> because of the natural characteristics of python such as GIL, we are >> not able to write multi threaded programs. > > I'm surprised no one here corrected

Re: Will multithreading make python less popular?

2009-02-17 Thread andrew cooke
why do you think that current work is ignorant of occam? occam itself was based on hoare's "communicating sequential processes" which is a classic of the field. the ideas behind occam are not unknown and it hasn't been forgotten (there are many libraries based on synchronous message passing; one

Re: Will multithreading make python less popular?

2009-02-16 Thread andrew cooke
andrew cooke wrote: > something like Haskell or OCaml. Or, if you want to get hands-on > experience of concurrency now, Erlang. I think for once I said something useful there. I think you would probably enjoy Erlang, and it would be very useful for understanding concurrency. Also, Erl

Re: Will multithreading make python less popular?

2009-02-16 Thread andrew cooke
rushen...@gmail.com wrote: > Hi everybody, > I am an engineer. I am trying to improve my software development > abilities. I have started programming with ruby. I like it very much > but i want to add something more. According to my previous research i > have designed a learning path for myself. It

Re: confusion about variable scope in a class

2009-02-14 Thread andrew cooke
it's not a scope issue. you are confusing variables and objects. a variable is a box that can hold an object so x = 2 puts the object '2' in the box 'x'. following that with x = '3' changes the box 'x' to hold the object '3'. but lists are also boxes, different from variables. so x = [1,2,3]

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread andrew cooke
Sorry, this reply was delayed (trying to use usenet...) and so now seems (even more) bad tempered than needed. Andrew andrew cooke wrote: > you are declaring class variables, not instance variables. you need to > declare these in an __init__ method. RTFM. > http://docs.python.org

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread andrew cooke
you are declaring class variables, not instance variables. you need to declare these in an __init__ method. RTFM. http://docs.python.org/tutorial/classes.html#a-first-look-at-classes Berend van Berkum wrote: > class MyParser(sgmllib.SGMLParser): > > content = '' > markup = [] > span_stack = [

Re: Problem with objects copying each other in memory

2009-02-12 Thread andrew cooke
he list? > > > On Feb 12, 2009, at 5:15 PM, andrew cooke wrote: > >> >> you're setting the new knight's "sl" to the value self.sl and then >> adding >> values to it. that's the same list - so you are adding values to the >> self.sl list

Re: Problem with objects copying each other in memory

2009-02-12 Thread andrew cooke
you're setting the new knight's "sl" to the value self.sl and then adding values to it. that's the same list - so you are adding values to the self.sl list when you add them to the knight's sl. this is easier to understand just by seeing the fix, which is to use: temp = Knight(self.x, self.y, s

Re: Spam

2009-02-12 Thread andrew cooke
Grant Edwards wrote: >> I should be working; I will try that this evening. What was the name of >> the client that threaded messages with a cute ascii tree?! > > slrn? i think i was remembering trn, which is now apparently dead. will try slrn... thanks, andrew -- http://mail.python.org/mailma

Re: how to distribute python extensions independently of python

2009-02-12 Thread andrew cooke
You might want to read https://www.dfwpython.org/repo/Presentations/2008-10-04-PyArkansas-PythonEggsIntro/eggs-introduction.pdf It covers a lot of ground; I used it to work out how to distribute a pure Python package, but I am sure it mentions compiled packages too. In my case I ended up using s

Re: Spam

2009-02-12 Thread andrew cooke
A quick search on "imap nntp" turned up this list that might be useful - http://deflexion.com/messaging/ although I wonder when it was written because I remember using Aaron's RSS to email aggregator when RSS was new(!). It mentions gmane, though, which certainly still exists (I assume it carries

Re: Another optimization request :-)

2009-02-12 Thread andrew cooke
jeffg wrote: > To be honest, this is not my code and I'm new to python. It's part of > the open source project NetworkX, but I'm using this one call > extensively. I'm also not that familiar with the math behind the > physics. I'll read the documents and see if I can figure it > out. :-) Thank

Re: Another optimization request :-)

2009-02-11 Thread andrew cooke
sorry, that was stupid. there is no inversion (apart from 1/m), just the integration. still, improving the integration would allow larger steps. andrew andrew cooke wrote: > > why are you dong this point by point? surely you can express the physics > as a set of equations and i

Re: Another optimization request :-)

2009-02-11 Thread andrew cooke
why are you dong this point by point? surely you can express the physics as a set of equations and invert the matrix? wouldn't that be a lot faster? you'd replace the iteration over all combinations of points with a faster matrix inversion. see for example http://www.medwelljournals.com/fullte

Re: Avoiding argument checking in recursive calls

2009-02-11 Thread andrew cooke
Terry Reedy wrote: > Reverse the test order > > def fact(n): > if n > 0: return fact(n-1)*n > if n == 0: return 1 > raise ValueError sweet! but is this generally possible? ie: did you think this up for this question or is it an idiom that you find yourself using often? andrew --

Re: Functional schmunctional...

2009-02-10 Thread andrew cooke
r0g wrote: > def ip2inet(a): > li = a.split('.') > assert len(li) == 4 or len(li) == 6 > return reduce(add,[int(li[e])*(256**((len(li)-1)-e)) for e in > xrange(0,len(li))]) what a mess. i don't use this extreme a functional style in python (it's not really how the language is intended to be

Re: Convert date/time to unix timestamp?

2009-02-10 Thread andrew cooke
the python routines are a bit basic - you really have to think quite hard about what you are doing to get the right answer. in your case, you need to be clear what the timezone is for the datetime you are using. timezone info is optional (see the datetime documentation, where it talks about "nai

Re: generator object or 'send' method?

2009-02-10 Thread andrew cooke
steven probably knows this, but to flag the issue for people who are looking at generators/coroutines for the first time: there's a little "gotcha" about exactly how the two sides of the conversation are synchronized. in simple terms: send also receives. unfortunately the example steven gave doe

Re: generator object or 'send' method?

2009-02-09 Thread andrew cooke
If I were experimenting with Python to see just how far I could push coroutines at the moment, I would use .send() and look at how I could factor things into a small library (containing, for example, your trap-and-response secondary generator). But if this was paid work, I would write a class wit

Re: Python3.0 has more duplication in source code than Python2.5

2009-02-07 Thread andrew cooke
Steve Holden wrote: >> You'd best hope the copied section was thoroughly reviewed otherwise >> you're >> duplicating a flaw across X other sections. And then you also best hope >> that >> whoever finds said flaw and fixes it is also smart enough to check for >> similar constructs around the code ba

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread andrew cooke
there's a justification for this awful mess here - http://mail.python.org/pipermail/python-3000/2006-March/000104.html i didn't know about this, and even after reading steven's broken (i assume) example, managed to get it backwards. the else is if there *isn't* a break and is for search loops (s

Re: Ordered dict by default

2009-02-05 Thread andrew cooke
so what is happening with pep 372? http://www.python.org/dev/peps/pep-0372/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing two book chapters (text files)

2009-02-05 Thread andrew cooke
On Feb 4, 10:20 pm, Nick Matzke wrote: > So I have an interesting challenge.  I want to compare two book > chapters, which I have in plain text format, and find out (a) percentage > similarity and (b) what has changed. no idea if it will help, but i found this yesterday - http://www.nltk.org/ it

Re: How to find wxPython method documentation??

2009-02-04 Thread andrew cooke
On Feb 4, 8:06 pm, len wrote: > How does one find the methods that are available in the classes. heh. welcome to the wonderful world of wxpython :o( if you use eclipse to edit your code, then (providing the wind is in the right direction and the file you are editing doesn't have any syntax erro

Re: Structuring Modules with a Ubiquitous Base Class (Circular Dependencies)

2009-02-04 Thread andrew cooke
On Feb 4, 7:49 pm, andrew cooke wrote: > This leads to a circular dependency - the base class wants to import > the components, which in turn want to import the base class. > > Is there any standard solution to this? well, to partially answer my own question, this is certainly possi

Structuring Modules with a Ubiquitous Base Class (Circular Dependencies)

2009-02-04 Thread andrew cooke
Is there a good solution to the following problem? I have a library whose components I would like to separate into distinct modules. These components inherit from a common base class that provides common functionality (the inheritance is important only for implementation; there's a separate ABC m

Re: Locating python

2009-02-04 Thread andrew cooke
On Feb 4, 9:16 am, andrew cooke wrote: > > actually "su" needs the root (or the target users') password > > and sudo needs _your_ (the current users) password. > > argh, sorry for the confusion. actually, no. sudo requires the root password. at least on open

Re: Locating python

2009-02-04 Thread andrew cooke
> actually "su" needs the root (or the target users') password > and sudo needs _your_ (the current users) password. argh, sorry for the confusion. -- http://mail.python.org/mailman/listinfo/python-list

Re: Locating python

2009-02-04 Thread andrew cooke
On Feb 3, 7:35 pm, David Sevilla wrote: > I am quite new to Linux, and thought that by using yast2 there would > be no user problems (I am asked for the root password). I will sudo it > to see if it solves the problem. yast asked you for the password so that easy_install could be installed correc

Re: parse date/time from a log entry with only strftime (and no regexen)

2009-02-03 Thread andrew cooke
> > ValueError: unconverted data remains:  this is the remainder of the log   > > line > > that I do not care about you could catch the ValueError and split at the ':' in the .args attribute to find the extra data. you could then find the extra data in the original string, use the index to remove

Re: Locating python

2009-02-03 Thread andrew cooke
sorry, you are using easy_install, so sudo easy_install instead of what i said a moment ago. the important thing is to use "sudo". andrew On Feb 3, 7:30 pm, andrew cooke wrote: > the exact details of what you are reporting seem a bit odd, but i have > seen a similar

Re: Locating python

2009-02-03 Thread andrew cooke
the exact details of what you are reporting seem a bit odd, but i have seen a similar error because i have tried to use my own account to install the package, instead of using root. what i believe happens is that easy_install first tries to create the "test" file, and then checks it is there. if

<    1   2   3   4   >