Psychic bug

Alan Franzoni alan.franzoni.xyz at gmail.com
Wed Feb 22 17:44:41 EST 2006


Il Wed, 22 Feb 2006 19:04:48 +0000, Jennifer Hallinan ha scritto:

> Genome is a string of integers in the range 0- 3, hence the
> conversion.

Genome is a *class*, i suppose from this code, and Mutate is... an instance
method, I think. And self.genome is a string like composed of integers in
the 0-3 range.

I would advise you to use a list in first place, and define a method (maybe
__str__ or __repr__ ) in your class in order to output it as a string - I
think it may make your work easier.

Your code is a little unpythonic-inside. I think you're coding from a very
programmer-unfriendly language :-)

I don't understand your specific problem (it may be class-related but we
can't know if you don't post your full code) because the code looks fine to
me, e.g. it works as it should, with that line commented out.

For printing, try this:

print "pos:%s , old value: %s, new value: %s " % (
                                         letter, gen[letter], base)

in place of your two prints in the if block, it should help you.

-- 
Alan Franzoni <alan.franzoni.xyz at gmail.com>
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E



More information about the Python-list mailing list