Re: [Tutor] Question about style

2014-07-17 Thread Mark Lawrence
On 17/07/2014 17:23, Jose Amoreira wrote: Hello, On 07/17/2014 12:05 AM, Alan Gauld wrote: Just throwing this idea in without really thinking about it... Would itertools.groupby work? It takes a sorted collection and groups the items found based on a key function. If the key function deemed t

Re: [Tutor] Question about style

2014-07-17 Thread Jose Amoreira
Hello, On 07/17/2014 12:05 AM, Alan Gauld wrote: Just throwing this idea in without really thinking about it... Would itertools.groupby work? It takes a sorted collection and groups the items found based on a key function. If the key function deemed two items identical if they were within dist

Re: [Tutor] Question about style

2014-07-16 Thread Wolfgang Maier
On 16.07.2014 13:49, Jose Amoreira wrote: Hello I wrote a function that, given a list of numbers, finds clusters of values by proximity and returns a reduced list containing the centers of these clusters. However, I find it rather unclear. I would appreciate any comments on how pythonic my functi

Re: [Tutor] Question about style

2014-07-16 Thread Alan Gauld
On 16/07/14 12:49, Jose Amoreira wrote: Hello I wrote a function that, given a list of numbers, finds clusters of values by proximity and returns a reduced list containing the centers of these clusters. However, I find it rather unclear. I would appreciate any comments on how pythonic my function

Re: [Tutor] Question about style

2014-07-16 Thread Jose Amoreira
Hi! On 07/16/2014 10:14 PM, Wolfgang Maier wrote: careful here: you just stored a tuple instead of a list; doesn't matter for your current implementation, but may bite you at some point. Oh, you're right. Silly mistake, even if harmless for the application I have in mind. else:

[Tutor] Question about style

2014-07-16 Thread Jose Amoreira
Hello I wrote a function that, given a list of numbers, finds clusters of values by proximity and returns a reduced list containing the centers of these clusters. However, I find it rather unclear. I would appreciate any comments on how pythonic my function is and suggestions to improve its re