Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2171 > unrolled thread
| Started by | harrismh777 <harrismh777@charter.net> |
|---|---|
| First post | 2011-03-29 14:00 -0500 |
| Last post | 2011-04-05 07:36 +0200 |
| Articles | 7 — 6 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Fun python 3.2 one-liner harrismh777 <harrismh777@charter.net> - 2011-03-29 14:00 -0500
Re: Fun python 3.2 one-liner gb <gb@cabiate.it> - 2011-04-04 22:09 +0200
Re: Fun python 3.2 one-liner Chris Angelico <rosuav@gmail.com> - 2011-04-05 07:46 +1000
Re: Fun python 3.2 one-liner Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-05 10:16 +1200
Re: Fun python 3.2 one-liner Chris Angelico <rosuav@gmail.com> - 2011-04-05 08:45 +1000
Re: Fun python 3.2 one-liner Emile van Sebille <emile@fenx.com> - 2011-04-04 15:46 -0700
Re: Fun python 3.2 one-liner Giacomo Boffi <giacomo.boffi@polimi.it> - 2011-04-05 07:36 +0200
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-03-29 14:00 -0500 |
| Subject | Re: Fun python 3.2 one-liner |
| Message-ID | <o%pkp.365$0s5.220@newsfe17.iad> |
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 available so as not to reinvent the proverbial wheel... thanks again... fun.
[toc] | [next] | [standalone]
| From | gb <gb@cabiate.it> |
|---|---|
| Date | 2011-04-04 22:09 +0200 |
| Message-ID | <86k4f9wzgx.fsf@aiuole.stru.polimi.it> |
| In reply to | #2171 |
harrismh777 <harrismh777@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 ,\
zip(*[(x0[k]+w[k]*x1[k],\
x0[k]-w[k]*x1[k])\
for k in range(n/2)])))()
it was a joke of sort played on it.comp.lang.python
[thanks to marco (zip(*...)) and antonio (lambda with default
arguments)]
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-04-05 07:46 +1000 |
| Message-ID | <mailman.20.1301953602.9059.python-list@python.org> |
| In reply to | #2591 |
On Tue, Apr 5, 2011 at 6:09 AM, gb <gb@cabiate.it> wrote: > harrismh777 <harrismh777@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 ,\ > zip(*[(x0[k]+w[k]*x1[k],\ > x0[k]-w[k]*x1[k])\ > for k in range(n/2)])))() > > it was a joke of sort played on it.comp.lang.python (Remind me how it is that Python code is more readable than line noise or Perl code?) What sort of parameters does this take? So far all I can figure out is that n is an integer and x and w are sliceables, but I'm not sure whether x and w should be strings or arrays. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2011-04-05 10:16 +1200 |
| Message-ID | <8vuuagFg70U2@mid.individual.net> |
| In reply to | #2602 |
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 write Perl code that way?-) -- Greg
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-04-05 08:45 +1000 |
| Message-ID | <mailman.25.1301957105.9059.python-list@python.org> |
| In reply to | #2609 |
On Tue, Apr 5, 2011 at 8:16 AM, Gregory Ewing <greg.ewing@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 write Perl code that way?-) Ha!! Okay, now I have to explain to my fellow bus passengers what it is that I just cracked up laughing at... You know what? I don't think I can. I do like readable code, but quite a few of my favorite language features are the ones commonly (ab)used to make unreadable code. C's ?: operator, Pike's interpretation of || for defaults, Python's lambda functions... all great ways to shorten your code, but so easily used for evil. I think I like things that can be used for evil. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Emile van Sebille <emile@fenx.com> |
|---|---|
| Date | 2011-04-04 15:46 -0700 |
| Message-ID | <mailman.26.1301957306.9059.python-list@python.org> |
| In reply to | #2609 |
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, and how nobody in their > right mind would ever write Perl code that way?-) > I don't know if I should be laughing or nodding in agreement... :) Emile
[toc] | [prev] | [next] | [standalone]
| From | Giacomo Boffi <giacomo.boffi@polimi.it> |
|---|---|
| Date | 2011-04-05 07:36 +0200 |
| Message-ID | <86d3l1w96y.fsf@aiuole.stru.polimi.it> |
| In reply to | #2602 |
Chris Angelico <rosuav@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],\
>> x0[k]-w[k]*x1[k])\
>> for k in range(n/2)])))()
> What sort of parameters does this take? So far all I can figure out
> is that n is an integer and x and w are sliceables, but I'm not sure
> whether x and w should be strings or arrays.
def direct_fft(x,n):
return f(x,n,[exp(-2*pi*1j*k/n) for k in range(n/2)])
def inverse_fft(x,n):
return [x/n for x in f(x,n,[exp(+2*pi*1j*k/n) for k in range(n/2)])]
--
le mie sacrosante questioni di principio
VS gli sciocchi puntigli di quel cretino del mio vicino
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web