[Baypiggies] Baypiggies snippets

Max Slimmer max at theslimmers.net
Thu Mar 29 07:27:21 CEST 2007


What doug is asking for is any sequence to have some method say flatten such
that
Seq = [a,b,c]
Flatseq = Seq.flatten()

Your answer below could import some function util.flatten
And then Flatseq = util.flatten(Seq) but not quit what was asked for.

max 

> -----Original Message-----
> From: baypiggies-bounces at python.org 
> [mailto:baypiggies-bounces at python.org] On Behalf Of Keith Dart ?
> Sent: Wednesday, March 28, 2007 7:42 PM
> To: Doug Landauer
> Cc: baypiggies at python.org
> Subject: Re: [Baypiggies] Baypiggies snippets
> 
> Doug Landauer wrote the following on 2007-03-21 at 23:07 PDT:
> ===
> > If we have come across the need/desire for a new general 
> method that 
> > should work just fine with anything that "quacks like a 
> sequence", and 
> > we would like to make it available to any sequence in any of our 
> > Python code, and I want to invoke it as foo.method for any 
> foo that is 
> > a sequence, then where/how would I define such a method?
> ===
> 
> Ok, so now I also have a better idea of what the answer to 
> this question is. The consensus is: anywhere you want, as 
> long as you explicitly import it. 
> 
> I suppose the most acceptable pattern is something like this:
> 
> from mypackage import utils
> 
> utils.waddle(quacker)
> 
> What say you?
> 
> 
> 
> --
> -- 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    Keith Dart <keith at dartworks.biz>
>    public key: ID: 19017044
>    <http://www.dartworks.biz/>
>    
> =====================================================================
> 
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
> 



More information about the Baypiggies mailing list