[Tutor] Using type
Emeka
emekamicro at gmail.com
Fri Aug 12 22:21:36 CEST 2011
Chris,
I was just fooling around and I wanted to do something for myself before
going to bed the other night.
func myflatten will turn say [ 34 [90] [12] 1] into [34 90 12 1].
Just like its name sounds.
Emeka
On Fri, Aug 12, 2011 at 7:03 PM, Christopher King <g.nius.ck at gmail.com>wrote:
> try:
>> iter(item) # test for iterability
>> if len(item) == 1 and item == item[0]:
>> gut.append(item)
>> else:
>> gut = gut + flatten(item)
>>
>> except TypeError:
>> gut.append(item)
>>
> I wouldn't put the what you want to do if there is no error in the
> try statement. It makes it appear like your checking for an error in all the
> code. I would do.
>
> try:
> iter(item) # test for iterability
> except TypeError:
> gut.append(item)
> else:
> if len(item) == 1 and item == item[0]: ##By the way, why do you
> have this if statment
>
> gut.append(item)
> else:
> gut = gut + flatten(item)
>
> Oh ya out of curiosity, what is the flatten func for?
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
*Satajanus Nig. Ltd
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110812/2ca45ef8/attachment.html>
More information about the Tutor
mailing list