[Tutor] combining tuples in a list
Lloyd Hugh Allen
lha2@columbia.edu
Fri, 05 Apr 2002 14:52:51 -0500
I use 2.2. Needed to have 2.2 to use Danny's "Permutations using
Generators" to answer a friend's problem.
Now that I look more closely at inheritance, I could have overwritten
the __add__ method, but then within it called tuple.__add__(self,
other[1:]) to make the code more transparent. Don't want to repost the
whole big thing though.
A complete solution, then, would also have to check and make sure that
you don't have (abc)(cda), which would yield an animal with its head at
its tail.
Brad Reisfeld wrote:
>
> Thank you for the response.
>
> It looks like an interesting approach. What version of Python are you using?
> I get a "TypeError: base is not a class object" error when I try to run the
> script. Is it possible for a class to inherit from the tuple type in Python
> 2.1?
>
> To answer the question both you and Kirby raised, the beginning and ending
> members of a given tuple should never be the same, i.e. ('a','b','a') should
> never happen in my problem.
>
> -Brad
>