Re: Fun python 3.2 one-liner

2011-04-14 Thread Albert van der Horst
In article mailman.46.1302010711.9059.python-l...@python.org, Daniel Fetchinson fetchin...@googlemail.com wrote: what is the character limit on a one liner :P. For PEP 8 compliance, 80 characters. :-) Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or

Re: Fun python 3.2 one-liner

2011-04-08 Thread Lie Ryan
On 04/06/11 01:07, Steven D'Aprano wrote: On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: Personally, I find that the discipline of keeping to 80 characters is good for me. It reduces the temptation of writing obfuscated Python one- liners when two lines would be better. The

Re: Fun python 3.2 one-liner

2011-04-06 Thread Chris Angelico
On the right hand side of my gmail window, Google posited that I might be interested in One-liner jokes. And I have to confess, the first thing I thought of was So I was writing a one-liner in assembly and... ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
what is the character limit on a one liner :P. For PEP 8 compliance, 80 characters. :-) Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80 characters. I'm using 140 for python these days. Seriously, who would want

Re: Fun python 3.2 one-liner

2011-04-05 Thread Steven D'Aprano
On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: what is the character limit on a one liner :P. For PEP 8 compliance, 80 characters. :-) Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80

Re: Fun python 3.2 one-liner

2011-04-05 Thread Chris Angelico
On Wed, Apr 6, 2011 at 1:07 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: Seriously, who would want to limit him/herself to 80 characters in 2011? Seriously, or is that a rhetorical question? People who like to

Re: Fun python 3.2 one-liner

2011-04-05 Thread Tim Wintle
On Tue, 2011-04-05 at 15:38 +0200, Daniel Fetchinson wrote: Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80 characters. I'm using 140 for python these days. Seriously, who would want to limit him/herself to 80

Re: Fun python 3.2 one-liner

2011-04-05 Thread Steven D'Aprano
On Wed, 06 Apr 2011 01:19:06 +1000, Chris Angelico wrote: On Wed, Apr 6, 2011 at 1:07 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: Seriously, who would want to limit him/herself to 80 characters in 2011?

Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
what is the character limit on a one liner :P. For PEP 8 compliance, 80 characters. :-) Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80 characters. I'm using 140 for python these days. Seriously, who would

Indentation levels and line lengths (was Re: Fun python 3.2 one-liner)

2011-04-05 Thread Chris Angelico
On Wed, Apr 6, 2011 at 3:48 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: and has on occasion gone as far as 12-16. I would consider anything more than four indents a code smell. That is, four is unexceptional; five would make me look over the code to see if it could be

Re: Fun python 3.2 one-liner

2011-04-05 Thread Raymond Hettinger
On Apr 5, 6:38 am, Daniel Fetchinson fetchin...@googlemail.com wrote: what is the character limit on a one liner :P. For PEP 8 compliance, 80 characters. :-) Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80

Re: Fun python 3.2 one-liner

2011-04-05 Thread Ben Finney
Raymond Hettinger pyt...@rcn.com writes: On Apr 5, 6:38 am, Daniel Fetchinson fetchin...@googlemail.com wrote: Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80 characters. I'm using 140 for python these

Re: Fun python 3.2 one-liner

2011-04-04 Thread gb
harrismh777 harrismh...@charter.net writes: Seriously, these little one liners teach me more about the python language in less time than [...] def f(x,n,w): return x if n==1 else\ (lambda x0=f(x[::2],n/2,w[::2]),\ x1=f(x[1::2],n/2,w[::2]): reduce(lambda a,b: a+b ,\

Re: Fun python 3.2 one-liner

2011-04-04 Thread Chris Angelico
On Tue, Apr 5, 2011 at 6:09 AM, gb g...@cabiate.it wrote: harrismh777 harrismh...@charter.net writes: Seriously, these little one liners teach me more about the python language in less time than [...] def f(x,n,w): return x if n==1 else\    (lambda x0=f(x[::2],n/2,w[::2]),\            

Re: Fun python 3.2 one-liner

2011-04-04 Thread Gregory Ewing
Chris Angelico wrote: (Remind me how it is that Python code is more readable than line noise or Perl code?) Crazy thought: I wonder if Perl programmers have multi line Perl competitions where they laugh their heads off at how readable the code is, and how nobody in their right mind would ever

Re: Fun python 3.2 one-liner

2011-04-04 Thread Chris Angelico
On Tue, Apr 5, 2011 at 8:16 AM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Chris Angelico wrote: Crazy thought: I wonder if Perl programmers have multi line Perl competitions where they laugh their heads off at how readable the code is, and how nobody in their right mind would ever

Re: Fun python 3.2 one-liner

2011-04-04 Thread Emile van Sebille
On 4/4/2011 3:16 PM Gregory Ewing said... Chris Angelico wrote: (Remind me how it is that Python code is more readable than line noise or Perl code?) Crazy thought: I wonder if Perl programmers have multi line Perl competitions where they laugh their heads off at how readable the code is,

Re: Fun python 3.2 one-liner

2011-04-04 Thread Giacomo Boffi
Chris Angelico ros...@gmail.com writes: def f(x,n,w): return x if n==1 else\    (lambda x0=f(x[::2],n/2,w[::2]),\            x1=f(x[1::2],n/2,w[::2]): reduce(lambda a,b: a+b ,\                                      zip(*[(x0[k]+w[k]*x1[k],\                                            

Re: Fun python 3.2 one-liner

2011-03-30 Thread Martin De Kauwe
what is the character limit on a one liner :P. Very interesting jesting apart, any more? -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun python 3.2 one-liner

2011-03-30 Thread Chris Angelico
On Wed, Mar 30, 2011 at 8:19 PM, Martin De Kauwe mdeka...@gmail.com wrote: what is the character limit on a one liner :P. Very interesting jesting apart, any more? Not sure if this can be redone as a one-liner; currently it's two. for i in range(3): print '\n\t'+(minor,medium,major)[i]+'

Re: Fun python 3.2 one-liner

2011-03-30 Thread Raymond Hettinger
On Mar 30, 2:19 am, Martin De Kauwe mdeka...@gmail.com wrote: what is the character limit on a one liner :P. Very interesting jesting apart, any more? Sure, here are three one-liners using itertools.groupby() to emulate some Unix pipelines: sort letters | uniq # list unique values

Re: Fun python 3.2 one-liner

2011-03-30 Thread Gregory Ewing
Martin De Kauwe wrote: what is the character limit on a one liner :P. For PEP 8 compliance, 80 characters. :-) -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Fun python 3.2 one-liner

2011-03-29 Thread Raymond Hettinger
from collections import Counter from itertools import product print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items( almost-normally-yours, Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun python 3.2 one-liner

2011-03-29 Thread Xavier Ho
http://www.ideone.com/infch ^ Result of the below code On 29 March 2011 19:50, Raymond Hettinger pyt...@rcn.com wrote: from collections import Counter from itertools import product print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items(

Re: Fun python 3.2 one-liner

2011-03-29 Thread Raymond Hettinger
print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items( * *** * ** * *

Re: Fun python 3.2 one-liner

2011-03-29 Thread geremy condra
On Tue, Mar 29, 2011 at 11:24 AM, Raymond Hettinger pyt...@rcn.com wrote: print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items( * *** * ** *

Re: Fun python 3.2 one-liner

2011-03-29 Thread harrismh777
Raymond Hettinger wrote: almost-normally-yours, Raymond thanks ... interesting Seriously, these little one liners teach me more about the python language in less time than *all* of the books I'm trying to digest right now. The toughest part of learning python is learning about what's

Re: Fun python 3.2 one-liner

2011-03-29 Thread Terry Reedy
On 3/29/2011 5:50 AM, Raymond Hettinger wrote: from collections import Counter from itertools import product print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, product(range(6), repeat=8))).items( The line break makes that hard to read; the axis is not labeled (and labels