Pablo Torres wrote:
> AttributeError: 'NoneType' object has no attribute 'insert'
>
> Could somebody please explain to me why my p variable has no type
> at all?
It does have a type, NoneType. As already explained, only None
normally is of type NoneType.
Regards,
Björn
--
BOFH excuse #281:
>
> list.insert returns None. Thus, except in the one-element case, your
> generator is yielding None all the time.
>
Oh god...silly me.
Thank you guys for the help :)
P.S I'm dead stubborn, so here's what I did to fix my code:
def perm(seq):
"Reshuffles the elements of seq in every pos
Pablo Torres <[EMAIL PROTECTED]> writes:
> def perm(seq):
> "Reshuffles the elements of seq in every possible way"
> if len(seq) == 1:
> yield seq
> else:
> for p in perm(seq[1:]):
> for i in range(len(seq)):
>
On Jul 21, 12:42 am, Pablo Torres <[EMAIL PROTECTED]> wrote:
> Hey guys!
> For the last couple of days, I've been fighting a war against
> generators and they've beaten the crap out of me several times. What I
> want to do is implement one that yields every possible permutation of
> a given sequenc
Just a quick P.S: This WOULD NOT work with strings, because of
seq.insert()
In very other aspect, I'm still lost.
--
http://mail.python.org/mailman/listinfo/python-list
Hey guys!
For the last couple of days, I've been fighting a war against
generators and they've beaten the crap out of me several times. What I
want to do is implement one that yields every possible permutation of
a given sequence (I had lists in mind, but I could swear that this
would work on strin