are elements of a list in sequence in list b

2008-02-08 Thread Matthew_WARREN
Hallo, I need to search list a for the sequence of list b First I went >>> a=[1,2,34,4,5,6] >>> b=[2,3,4] >>> a in b False So ''.join([ v.__str__() for v in b ]) in ''.join([ v.__str__() for v in a ]) >>> s=SomeObject() >>> a=[1,2,3,[s,3,[4,s,9]],s,4] >>> b=[3,[s,3,[4,s,9]],s,4] >>> ''.join([

Re: Why does list have no 'get' method?

2008-02-08 Thread Matthew_WARREN
> > val = BETTER foo THAN bar > > > > ;-) > > > > Cobol-strikes-back-ly yours, > > > > George > > I use a ETL language/tool that actually has a function for this kind > of thing: > > NulltoValue(value,defaultValue) > > it returns defaultValue if value is null otherwise value. even Ksh has one

Re: a trick with lists ?

2008-02-08 Thread Matthew_WARREN
> On Feb 7, 12:20 pm, "Sébastien Vincent" free.fr> > wrote: > > I've found some class on the Net which takes basically this form : > > > > ## > > class Foo: > > def __init__(self): > > self.tasks = [] > >... > > > > def method1(self): > > tasks = [] > > w

brain stuck. whats occurring here?

2008-02-07 Thread Matthew_WARREN
Hallo, I'm after [[[],[],[],[],[]],[[],[],[],[],[]],[[],[],[],[],[]],[[],[],[],[],[]],[[],[],[],[],[]]] (NxN 'grid', 5x5 in that example, and while typing this up i figured out how to get it, but I'm still not sure what _was_ happening) I'm trying a=[] >>> row=[ [] for n in range(0,10) ]

Re: Looking for library to estimate likeness of two strings

2008-02-07 Thread Matthew_WARREN
> On Wed, 06 Feb 2008 17:32:53 -0600, Robert Kern wrote: > > > Jeff Schwab wrote: > ... > >> If the strings happen to be the same length, the Levenshtein distance > >> is equivalent to the Hamming distance. Is this really what the OP was asking for. If I understand it correctly, Levenshtein

Re: Traversing python datatypes via http

2008-02-07 Thread Matthew_WARREN
"Mark" <[EMAIL PROTECTED]> wrote > > Is it possible to traverse say python lists via http:// > > http is a network protocol. > What does that have to do with traversing python lists? > Can you clarify what you mean by that? > > > say there is a list in the memory > > can we traverse the lis

Re: Why chdir command doesn't work with client.get_transport() ?

2008-02-06 Thread Matthew_WARREN
> I try not to top-post in this group, but the strange formatting of the > message makes this advisable, as I am sure many people won't even > persist in reading down as far as the "content". > > Can I make a wild-assed guess that you are a Lotus Notes user reading > python-list? Please try an

Re: Why chdir command doesn't work with client.get_transport() ?

2008-02-06 Thread Matthew_WARREN
|---> | Internet | | [EMAIL PROTECTED]| | | |

Re: Why chdir command doesn't work with client.get_transport() ?

2008-02-06 Thread Matthew_WARREN
Internet [EMAIL PROTECTED]

Re: App idea, Any idea on implementation?

2008-02-05 Thread Matthew_WARREN
Ok, probably not the answer your after. csound can do this easily. If you doing it via python, you'll need some way of FFT analysing sample data and analysing that to get which frequencies have the most energy... although I'm sure there are some, I don't know the names of any python libs that do

Re: Why chdir command doesn't work with client.get_transport() ?

2008-02-05 Thread Matthew_WARREN
As other have said, it's because exec_command uses a new session each time. You may get some joy with this, untested exec_command('cd /some/where; somecommand') uses the semi-colon to separate multiple commands on one command line. Matt.

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Matthew_WARREN
> Another interesting technique, similar to GA, is SA or Simulated > Annealing. You should be able to adapt your quickga.py program to an > SA approach without too much trouble, and comparing the two should > tickle your academic bemusement. I shall take a look. This message and any at

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Matthew_WARREN
On Feb 1, 9:11 am, [EMAIL PROTECTED] wrote: > > > 0. Tack this bit onto the end of quickga.py, and you wont have to > > write a separate routine to import quickga and invoke evolve(): > > > > >     if __name__ == "__main__": > > >         evolve() > > > > I hear you, but something I dont ten

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Matthew_WARREN
On Jan 31, 10:43 am, [EMAIL PROTECTED] wrote: > > Hi, > > > > I got some help with this from here, and there's been a little bit of > > discussion around GA's recently, so thought I'd post up my likey slow and > > clunky version of a GA that in essence just 'evolves' a solution to 'make a > > S

Re: How to identify which numbers in a list are within each others' range

2008-02-01 Thread Matthew_WARREN
>> What is the best way to in python to identify the list items that >> overlap and the items that don't overlap with any other. >> >Is this usable? >Assuming you transform your 3 tuples into a list of start-end 2 tuples and sort them for lowest to highest, then >lst=[(55,58,52),(20,22,18

Re: How to identify which numbers in a list are within each others' range

2008-02-01 Thread Matthew_WARREN
Internet

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Matthew_WARREN
looking into speeding up the GA code I posted, I ran it with cProfile. Fri Feb 01 11:05:57 2008evprof 30100116 function calls in 93.614 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 7160929 34.5420.000 37

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Matthew_WARREN
Usually. I this case though, I really wasnt planning ahead too much as I wrote it and thats the way it happened... not the best of excuses I know. I've been thinking about the consequences though, and I'd have to run it to see really, but I'm thinking looking for average population fitness should

Re: Fw: Undeliverable Message

2008-01-31 Thread Matthew_WARREN
> Heres the code > > def increment(digits,symbols): >         overflow=True >         digitpos=-1 >         while overflow and -digitpos<=len(digits): >                 digitsymbolindex=symbols.index(digits[digitpos]) >                 if digitsymbolindex==len(symbols)-1: >                    

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-31 Thread Matthew_WARREN
Hmm, how does this fare?? for i in range(len(a)): if a[i]==99: a=a[:i]+a[i+1:] I like following your guys code noodling. I can come up with something that does what it appears your doing, sometimes, but as to it's relevant merits I havent a clue :) matt.

very simple Genetic Algorithm completed

2008-01-31 Thread Matthew_WARREN
Hi, I got some help with this from here, and there's been a little bit of discussion around GA's recently, so thought I'd post up my likey slow and clunky version of a GA that in essence just 'evolves' a solution to 'make a sum that evaluates to n using */+-0123456789' it's a really simple GA tha

Re: Executing other python code

2008-01-31 Thread Matthew_WARREN
Not a python solution, but if you look into how this was achieved with Java it may give hints to the technique needed in python; robocode, lets you specify your robot AI as java code. You design the AI, download a bunch of AI's written by other people and the robocode engine simulates a battle be

Re: validate string is valid maths

2008-01-29 Thread Matthew_WARREN
It was a very loosely thought out problem, and my Maths isn't good enough to define 'sane' rules for collapsing the signs/operators to make a sensible expression; so take my constraints with a pinch of salt. I guess a better way of putting it may be - now it has been pointed out that 8+++9 i

Re: validate string is valid maths

2008-01-28 Thread Matthew_WARREN
On Mon, 28 Jan 2008 15:10:54 +, Matthew_WARREN wrote: > Hi pythoners. > > I am generating strings of length n, randomly from the symbols > > +-/*0123456789 > > What would be the 'sensible' way of transforming the string, for example > chan

validate string is valid maths

2008-01-28 Thread Matthew_WARREN
Hi pythoners. I am generating strings of length n, randomly from the symbols +-/*0123456789 What would be the 'sensible' way of transforming the string, for example changing '3++8' into 3+8 or '3++--*-9' into '3+-9' such that eval(string) will always return a number? in cases where multipl

Re: finding child cpu usage of a running child

2008-01-28 Thread Matthew_WARREN
had to say, that subject conjoured up an interesting image in my head :) This message and any attachments (the "message") is intended solely for the addressees and is confidential. If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord w

Re: Does tkinter provide a way to search for files

2008-01-25 Thread Matthew_WARREN
You should read this page, it will help you solve your problem: http://catb.org/~esr/faqs/smart-questions.html *nod Steve Internet

Fw: Undeliverable Message

2008-01-25 Thread Matthew_WARREN
Hallo pyPeople, I wrote a little snippet of code that takes a list representing some 'digits', and according to a list of symbols, increments the digits through the symbol list. so for example, digits=["a","a","a"] symbols=["a","b","c"] increment(digits,symbols) repeatedly would return digits

Re: pairs from a list

2008-01-24 Thread Matthew_WARREN
Matthew_WARREN

Re: pairs from a list

2008-01-23 Thread Matthew_WARREN
I'm just fiddling with this, am no great expert, but I added def pairs5(x): o=[] for n in zip(x[::2],x[1:2]): o.append(n) return o I dont know if that breaks any constraints placed on the problem, but I get the following output 0.07158942896 0.26600970557