On Sun, 2009-03-08 at 15:49 +1100, Steven D'Aprano wrote:
> If the environmental costs of recycling something are worse than the
> environmental costs of throwing it away and making a new one, then
> recycling that object is actually harmful. But I digress.
Unless you live in a country that import
Gabriel Genellina wrote:
> Imagine you're working with someone side by side. You write a note in a
> piece of paper, put it into an envelope, and hand it to your co-worker. He
> opens the envelope, throws it away, takes the note and files it inside a
> folder right at the end. And you do this over
Lie Ryan wrote:
> mattia wrote:
>> Yes, sorry, I have to recycle! But how about this:
> rw = [[2,4], [4,5,6],[5,5]]
> rw += [[1,1]]*2
> rw
>> [[2, 4], [4, 5, 6], [5, 5], [1, 1], [1, 1]]
>> How can I recicle in this way using append?
>
> Not .append() but .extend()
Whether you use
mattia wrote:
Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto:
En Fri, 06 Mar 2009 21:31:01 -0200, mattia escribió:
Thanks, I've found another solution here:
http://www.obitko.com/tutorials/
genetic-algorithms/selection.php
so here is my implementation:
def get_fap(fitness
Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto:
> En Fri, 06 Mar 2009 21:31:01 -0200, mattia escribió:
>
>> Thanks, I've found another solution here:
>> http://www.obitko.com/tutorials/
>> genetic-algorithms/selection.php
>> so here is my implementation:
>>
>>
>> def get_fap(fi
"Gabriel Genellina" writes:
> > for x in population:
> > f = fitness(x)
> > fap += [(f, x)]
> > total += f
> > return sorted(fap, reverse=True), total
> ...
> Environmentally friendly Pythoneers avoid using discardable
> intermediate envelopes:
>
> fap.a
En Fri, 06 Mar 2009 21:31:01 -0200, mattia escribió:
Thanks, I've found another solution here:
http://www.obitko.com/tutorials/
genetic-algorithms/selection.php
so here is my implementation:
def get_fap(fitness, population):
fap = []
total = 0
for x in population:
f = fi
Il Fri, 06 Mar 2009 14:13:47 -0800, Scott David Daniels ha scritto:
> mattia wrote:
>> Here is my last shot, where I get rid of all the old intermediate
>> functions:
>>
>> def selection(fitness, population):
>> lp = len(population)
>> roulette_wheel = []
>> for x in population:
>>
Il Fri, 06 Mar 2009 18:46:44 -0300, andrew cooke ha scritto:
> 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 f
mattia wrote:
Here is my last shot, where I get rid of all the old intermediate
functions:
def selection(fitness, population):
lp = len(population)
roulette_wheel = []
for x in population:
roulette_wheel += [x]*fitness(x)
selected_population = [[]]*lp
selected_popula
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
Il Fri, 06 Mar 2009 22:28:00 +0100, Peter Otten ha scritto:
> mattia wrote:
>
>> Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto:
>>
>>> mattia wrote:
>>>
Hi, I'm new to python, and as the title says, can I improve this
snippet (readability, speed, tricks):
def g
mattia wrote:
> Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto:
>
>> mattia wrote:
>>
>>> Hi, I'm new to python, and as the title says, can I improve this
>>> snippet (readability, speed, tricks):
>>>
>>> def get_fitness_and_population(fitness, population):
>>> return [(fitness(
Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto:
> mattia wrote:
>
>> Hi, I'm new to python, and as the title says, can I improve this
>> snippet (readability, speed, tricks):
>>
>> def get_fitness_and_population(fitness, population):
>> return [(fitness(x), x) for x in population
Chris Rebert writes:
>for i in range(len(fap)):
>selected_population.append(choice(rw))
"for i in range(len(something))" is a bit of a code smell. You could
instead say:
selected_population.extend(choice(rw) for x in fap)
The unused "x" is also a slight code smell, but the most
mattia wrote:
> Hi, I'm new to python, and as the title says, can I improve this snippet
> (readability, speed, tricks):
>
> def get_fitness_and_population(fitness, population):
> return [(fitness(x), x) for x in population]
>
> def selection(fitness, population):
> '''
> Select the
On Fri, Mar 6, 2009 at 3:52 AM, mattia wrote:
> Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto:
>
>> On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote:
>>> Great, the for statement has not to deal with fap anymore, but with
>>> another sequence, like this:
>>>
>>> def get_roulette_wheel(w
Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto:
> On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote:
>> Great, the for statement has not to deal with fap anymore, but with
>> another sequence, like this:
>>
>> def get_roulette_wheel(weight_value_pairs):
>> roulette_wheel = []
>> for
On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote:
> Great, the for statement has not to deal with fap anymore, but with
> another sequence, like this:
>
> def get_roulette_wheel(weight_value_pairs):
> roulette_wheel = []
> for weight, value in weight_value_pairs:
> roulette_wheel += [valu
Il Fri, 06 Mar 2009 10:19:22 +, mattia ha scritto:
> Hi, I'm new to python, and as the title says, can I improve this snippet
> (readability, speed, tricks):
>
> def get_fitness_and_population(fitness, population):
> return [(fitness(x), x) for x in population]
>
> def selection(fitness,
On Fri, Mar 6, 2009 at 2:19 AM, mattia wrote:
> Hi, I'm new to python, and as the title says, can I improve this snippet
> (readability, speed, tricks):
>
> def get_fitness_and_population(fitness, population):
> return [(fitness(x), x) for x in population]
>
> def selection(fitness, population)
Hi, I'm new to python, and as the title says, can I improve this snippet
(readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in population]
def selection(fitness, population):
'''
Select the parent chromosomes from a popula
On Mon, 30 May 2005 14:05:36 +0200, Magnus Lycka wrote:
> Steven D'Aprano wrote:
> > print is a statement, not a function. The brackets are syntactically
> > correct, but pointless. Remove them.
> ...
>> On Sat, 28 May 2005 13:24:19 +, Michael wrote:
>>> while( newNS ):
>>
>> Guido (our Ben
Steven D'Aprano wrote:
> print is a statement, not a function. The brackets are syntactically
> correct, but pointless. Remove them.
...
> On Sat, 28 May 2005 13:24:19 +, Michael wrote:
>> while( newNS ):
>
> Guido (our Benevolent Dictator For Life and creator of Python) hates
> seeing white
Michael wrote:
> I'm fairly new at Python, and have the following code that works but
> isn't very concise, is there a better way of writing it?? It seems
> much more lengthy than python code i have read. :-)
> (takes a C++ block and extracts the namespaces from it)
Yes, there is a better way
On 5/29/05, Cyril BAZIN <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I don't know very well what you want to do, but if you want to parse c++,
> take a look at "GCC-XML python" (http://www.gccxml.org) and the python
> binding (http://pygccxml.sourceforge.net/). These tools
> translate c++ code to XML. T
Hi,
I don't know very well what you want to do, but if you want to parse
c++, take a look at "GCC-XML python" (http://www.gccxml.org) and the
python binding (http://pygccxml.sourceforge.net/). These tools
translate c++ code to XML. Then, you can parse xml with your favorite
tools and find the name
Steven D'Aprano wrote:
> Guido (our Benevolent Dictator For Life and creator of Python) hates
> seeing whitespace next to parentheses. I agree with him. while(newNS)
> good, while( newNS ) bad.
while is a statement, so while(newNS) is bad in more than one way.
--
http://mail.python.org/mail
On Sat, 28 May 2005 13:24:19 +, Michael wrote:
> Hi,
> I'm fairly new at Python, and have the following code that works but isn't
> very concise, is there a better way of writing it?? It seems much more
> lengthy than python code i have read. :-)
> (takes a C++ block and extracts the names
Hi,
I'm fairly new at Python, and have the following code that works but isn't
very concise, is there a better way of writing it?? It seems much more
lengthy than python code i have read. :-)
(takes a C++ block and extracts the namespaces from it)
def ExtractNamespaces(data):
print("Extract
30 matches
Mail list logo