Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-16 Thread rantingrick
On Aug 9, 8:19 am, Mike Kent mrmak...@cox.net wrote:
 On Aug 8, 8:43 pm, rantingrick rantingr...@gmail.com wrote:

 Xah, this is really you, isn't it.  Come on, confess.

*MOI*, How could *I* be xah. I really don't like Ruby however he
gushes over it all the time. And he does not like Python that much
either. We are total opposites, really.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-16 Thread rantingrick
On Aug 8, 8:15 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 On Sun, 08 Aug 2010 17:43:03 -0700, rantingrick wrote:

  Ruby has what they
  call a Here Doc. Besides picking the most boneheaded name for such an
  object

 It's standard terminology that has been around for a long time in many
 different languages.

Just because something has been around around for a long time does not
necessarily mean it's was a good idea to begin with. STRAWMAN!

  As you can see it is another example of tacked on functionality that was
  not carefully considered before hand.

 I disagree. It's an old and venerable technique, and very useful on the
 rare occasion that you have lots of quotation marks in a string.

 (...snip...)

   Python strings have four delimiters:
   (1) single quote '
   (2) double quote 
   (3) single-quote here-doc '''
   (4) double-quote here-doc 

   plus equivalent raw-strings of each kind.

 Trying writing that as a single literal in Python without escapes. There
 are work-arounds, of course, like using implicit concatenation, but
 they're ugly.

Yes, with the choices we have today writing strings like you mention
is terribly asinine. And don't forget about filepaths and regexps too
with all the backslashing nonsense! However, there is a simple
solution to this mess. Python double quote strings and Python
multiline strings(that are delimited by leading and trailing
double quote triplets) should behave as they do today.

However Python 'single quote strings' and Python '''multiline
strings'''(that are delimited by leading and trailing single quote
triplets) should be raw so that they do not interpret escape
sequences. Yes i know this would break backwards compatibility *again*
but this functionality should have been made available in Py3000 since
we were already breaking it anyhow.

Why do we need both X AND '''X''' this if they do exactly the
same thing? Also why do we need both X AND 'X' if they do exactly
the same thing. A real chance to make something special was missed and
i hope one day we come to the realization that this proposed
functionality of strings (raw and normal) is sorely needed in Python.

 In Ruby they decided to be more general, so you can define whatever
 heredoc you need to quote whatever literal string you need. That's not
 bone-headed.

The fact that Ruby has multi line strings (*ahem*... HEREDOC's) is not
at all the point i take issue with. I take issue with the boneheaded
syntax. Have you ever tried to grep Ruby heredocs? It would have been
so much easier if they had made a spec like this...

mystring = :{
blah blah blah
blahblah
blah blah blah
blah
}:

Or at least *some* static token instead of just creating something on
the fly each time now thats boneheaded!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread rantingrick
On Aug 8, 8:15 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:

 In Ruby they decided to be more general, so you can define whatever
 heredoc you need to quote whatever literal string you need. That's not
 bone-headed.

Devils Advocate!

PS: Man you're irb main was so full of cobweb i could barley see the
code... haa... h... hachew!. ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Steven D'Aprano
On Mon, 09 Aug 2010 00:29:19 -0700, rantingrick wrote:

 On Aug 8, 8:15 pm, Steven D'Aprano st...@remove-this-
 cybersource.com.au wrote:
 
 In Ruby they decided to be more general, so you can define whatever
 heredoc you need to quote whatever literal string you need. That's not
 bone-headed.
 
 Devils Advocate!
 
 PS: Man you're irb main was so full of cobweb i could barley see the
 code... haa... h... hachew!. ;-)

irb's default prompt is a bit too verbose for my tastes, but Python 
allows you to customise its prompt too. You'll often see people here 
posting copy/pastes with a customised prompt, so obviously some people 
like that sort of thing.

Me, my biggest gripe with the interactive interpreter is that using  
as a prompt clashes with  as the standard quoting character in email and 
news, but Guido has refused to even consider changing it.

And that it's quite finicky about blank lines between methods and inside 
functions. Makes it hard to paste code directly into the interpreter.

And that pasting doesn't strip out any leading prompts. It needs a good 
doctest mode.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Stefan Schwarzer
Hi Steven,

On 2010-08-09 10:21, Steven D'Aprano wrote:
 And that it's quite finicky about blank lines between methods and inside 
 functions. Makes it hard to paste code directly into the interpreter.
 
 And that pasting doesn't strip out any leading prompts. It needs a good 
 doctest mode.

ipython [1] should help here:

  IPython 0.10 -- An enhanced Interactive Python.
  ? - Introduction and overview of IPython's features.
  %quickref - Quick reference.
  help  - Python's own help system.
  object?   - Details about 'object'. ?object also works, ?? prints more.
  In [1]: %paste?
  Type:   Magic function
  Base Class: type 'instancemethod'
  String Form:bound method InteractiveShell.magic_paste of 
IPython.iplib.InteractiveShell object at 0xb740096c
  Namespace:  IPython internal
  File:   /usr/lib/pymodules/python2.6/IPython/Magic.py
  Definition: %paste(self, parameter_s='')
  Docstring:
  Allows you to paste  execute a pre-formatted code block from clipboard.

  The text is pulled directly from the clipboard without user
  intervention.

  The block is dedented prior to execution to enable execution of method
  definitions. '' and '+' characters at the beginning of a line are
  ignored, to allow pasting directly from e-mails, diff files and
  doctests (the '...' continuation prompt is also stripped).  The
  executed block is also assigned to variable named 'pasted_block' for
  later editing with '%edit pasted_block'.

  You can also pass a variable name as an argument, e.g. '%paste foo'.
  This assigns the pasted block to variable 'foo' as string, without
  dedenting or executing it (preceding  and + is still stripped)

  '%paste -r' re-executes the block previously entered by cpaste.

  IPython statements (magics, shell escapes) are not supported (yet).

  See also
  
  cpaste: manually paste code into terminal until you mark its end.

Unfortunatey, when I enter

  In [2]: %paste

at the prompt it gives me (before I pasted anything)

  In [2]: %paste
  
 File string, line 1
   http://pypi.python.org/pypi/ipython/0.10
   ^
  SyntaxError: invalid syntax

So far, I couldn't find anything on the net on this.

[1] http://pypi.python.org/pypi/ipython

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Mike Kent
On Aug 8, 8:43 pm, rantingrick rantingr...@gmail.com wrote:
 Hello folks,

 You all know i been forced to use Ruby and i am not happy about that.

***Blablabla cut long rant***

Xah, this is really you, isn't it.  Come on, confess.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Robert Kern

On 2010-08-09 06:42 , Stefan Schwarzer wrote:

Hi Steven,

On 2010-08-09 10:21, Steven D'Aprano wrote:

And that it's quite finicky about blank lines between methods and inside
functions. Makes it hard to paste code directly into the interpreter.

And that pasting doesn't strip out any leading prompts. It needs a good
doctest mode.


ipython [1] should help here:

   IPython 0.10 -- An enhanced Interactive Python.
   ? -  Introduction and overview of IPython's features.
   %quickref -  Quick reference.
   help  -  Python's own help system.
   object?   -  Details about 'object'. ?object also works, ?? prints more.
   In [1]: %paste?
   Type:   Magic function
   Base Class:type 'instancemethod'
   String Form:bound method InteractiveShell.magic_paste 
ofIPython.iplib.InteractiveShell object at 0xb740096c
   Namespace:  IPython internal
   File:   /usr/lib/pymodules/python2.6/IPython/Magic.py
   Definition: %paste(self, parameter_s='')
   Docstring:
   Allows you to paste  execute a pre-formatted code block from clipboard.

   The text is pulled directly from the clipboard without user
   intervention.

   The block is dedented prior to execution to enable execution of method
   definitions. '' and '+' characters at the beginning of a line are
   ignored, to allow pasting directly from e-mails, diff files and
   doctests (the '...' continuation prompt is also stripped).  The
   executed block is also assigned to variable named 'pasted_block' for
   later editing with '%edit pasted_block'.

   You can also pass a variable name as an argument, e.g. '%paste foo'.
   This assigns the pasted block to variable 'foo' as string, without
   dedenting or executing it (preceding  and + is still stripped)

   '%paste -r' re-executes the block previously entered by cpaste.

   IPython statements (magics, shell escapes) are not supported (yet).

   See also
   
   cpaste: manually paste code into terminal until you mark its end.

Unfortunatey, when I enter

   In [2]: %paste

at the prompt it gives me (before I pasted anything)

   In [2]: %paste
   
  File string, line 1
http://pypi.python.org/pypi/ipython/0.10
^
   SyntaxError: invalid syntax


Yes, that's because you had that URL in your clipboard, not Python code. What 
were you expecting to happen?


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Stefan Schwarzer
Hi Robert,

On 2010-08-09 22:23, Robert Kern wrote:
 On 2010-08-09 06:42 , Stefan Schwarzer wrote:
 Unfortunatey, when I enter

In [2]: %paste

 at the prompt it gives me (before I pasted anything)

In [2]: %paste

   File string, line 1
 http://pypi.python.org/pypi/ipython/0.10
 ^
SyntaxError: invalid syntax
 
 Yes, that's because you had that URL in your clipboard, not Python code. What 
 were you expecting to happen?

I got that traceback as soon as I typed in %paste and
pressed enter, without pasting anything in the terminal.
I had assumed it works like :paste in Vim, activating a
kind of paste mode where everything pasted into the
terminal is modified as the help text suggests.

Ok, I just noticed I should have actually _read_ the
help text, not just scanned it. ;-) Sorry for the
confusion.

Stefan



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Stefan Schwarzer
On 2010-08-09 23:43, Stefan Schwarzer wrote:
 I got that traceback as soon as I typed in %paste and
 pressed enter, without pasting anything in the terminal.
 I had assumed it works like :paste in Vim, activating a

I meant :set paste of course.

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread sturlamolden
On 9 Aug, 10:21, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:

 And that it's quite finicky about blank lines between methods and inside
 functions. Makes it hard to paste code directly into the interpreter.

The combination of editor, debugger and interpreter is what I miss
most from Matlab. In Matlab we can have a function or script open in
an editor, and use it directly from the interpreter. No need to
reimport or anything: edit and invoke. It is also possible to paste
data directly from the clipboard into variables in the interpreter.

ipython does not have that annoying  prompt.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-09 Thread Robert Kern

On 8/9/10 4:43 PM, Stefan Schwarzer wrote:

Hi Robert,

On 2010-08-09 22:23, Robert Kern wrote:

On 2010-08-09 06:42 , Stefan Schwarzer wrote:

Unfortunatey, when I enter

In [2]: %paste

at the prompt it gives me (before I pasted anything)

In [2]: %paste

   File string, line 1
 http://pypi.python.org/pypi/ipython/0.10
 ^
SyntaxError: invalid syntax


Yes, that's because you had that URL in your clipboard, not Python code. What
were you expecting to happen?


I got that traceback as soon as I typed in %paste and
pressed enter, without pasting anything in the terminal.
I had assumed it works like :paste in Vim, activating a
kind of paste mode where everything pasted into the
terminal is modified as the help text suggests.


%cpaste will do that. I implemented %paste because not all terminals will 
correctly paste arbitrary amounts of code correctly. Grabbing the text directly 
from the clipboard is less error-prone and removes redundant user interaction.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list


Python -Vs- Ruby: A regexp match to the death!

2010-08-08 Thread rantingrick
Hello folks,

You all know i been forced to use Ruby and i am not happy about that.
But i thought i would share more compelling evidence of the moronicity
of the Ruby language syntax from the perspective of regexp's.

I recently built myself a nice little Ruby script editor because i
hate everything else out there. Whist writing the Colorizer i realized
(again) just how beautifully elegant Python is and how crufty and
asinine Ruby is. Anyhow my point is that by looking at the regexp's
you can clearly see that parsing Ruby syntax is BF and Python syntax
is elegant! Here are a few examples: Note i used look back assertions
for clarity.

 Modules

Python does not have a module syntax (an thank Guido for that!)
because we have a much better system of using the file as a module and
not introducing more cruft into our scripts. Anyway if Python *did*
have a module syntax it would look better than this crap!

  Python: N/A
Ruby: r'(?=module )(::)?(\w+(::)?)*'


 Classes

Python and Ruby class definitions are almost the same except for the
module cruft getting in the way again.

  Python: r'(?=class )\w+'
Ruby: r'(?=class )(::)?(\w+(::)?)*'

-
 Defs
-
HaHa, you're going to poop yourself when you see this! No introduction
needed :-D.

  Python: r'(?=def )\w+'
Ruby: r'(?=def )(self\.)?((\w+::\w+)|(\w+\.\w+)|(\w+))([?|!])?'

-
 Strings
-
Single line strings are exactly the same in both languages except in
Ruby double quoted strings are backslash interpreted and single quote
strings are basically raw. Except Ruby introduces more cruft (as
usual) in the form of what i call lazy man stings

 a = %w{ one two three}
[one, two, three]
 s = %{one two three}
one two three
 repat = %r{one two three}
/one two three/

... only good for hand coding!

--
 Multi Line Strings
--
Ha. Ruby does not really have multi line strings. Ruby has what they
call a Here Doc. Besides picking the most boneheaded name for such
an object they also introduced and even more boneheaded syntax. To
define a Here Doc (god i hate that name!) you start with double
greater than  and immediately follow with an identifier token of
you choice (it can be anything your dirty little mind can come up
with.

HEREDOC
this is the body
of a
here doc. Why the
hell did they not just
use triple quotes like Python did.
Now i will need to remember some token to know where'
i stopped
HEREDOC

As you can see it is another example of tacked on functionality that
was not carefully considered before hand. Anyway here are the
regexp's...

  Python: r'.*?'
  Python: r'''.*?'''
Ruby: r'(\w+).*?(\1)'

--
 Comments
--
Ruby and Python single line comments are the same. Use the hash char.
However Ruby introduces multi line comment blocks delimited by the
tokens =begin and =end.

  Python: r#.*
Ruby: r=begin.*?=end
Ruby: r#.*

-
 Conculsion
-
I just want to take this opportunity to thank Mr. Van Rossum and the
Python dev team for creating a truly revolutionary 21st century
language that no other language can hold a candle to. Without Python
we would be force to use these other monstrosities on a daily basis
-- and i just don't think i could bear it! Keep up the good work!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-08 Thread MRAB

rantingrick wrote:

Hello folks,


[snip]

-
 Strings
-
Single line strings are exactly the same in both languages except in
Ruby double quoted strings are backslash interpreted and single quote
strings are basically raw. Except Ruby introduces more cruft (as
usual) in the form of what i call lazy man stings


a = %w{ one two three}

[one, two, three]

s = %{one two three}

one two three

repat = %r{one two three}

/one two three/

... only good for hand coding!


From Perl.


--
 Multi Line Strings
--
Ha. Ruby does not really have multi line strings. Ruby has what they
call a Here Doc. Besides picking the most boneheaded name for such
an object they also introduced and even more boneheaded syntax. To
define a Here Doc (god i hate that name!) you start with double
greater than  and immediately follow with an identifier token of
you choice (it can be anything your dirty little mind can come up
with.


HEREDOC

this is the body
of a
here doc. Why the
hell did they not just
use triple quotes like Python did.
Now i will need to remember some token to know where'
i stopped
HEREDOC

As you can see it is another example of tacked on functionality that
was not carefully considered before hand. Anyway here are the
regexp's...

  Python: r'.*?'
  Python: r'''.*?'''
Ruby: r'(\w+).*?(\1)'


Also from Perl.

I don't know what the point of your post was. We already know that we
prefer Python; that's why we're here! :-)

And anyway, being nasty about other languages feels unPythonic to me...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python -Vs- Ruby: A regexp match to the death!

2010-08-08 Thread Steven D'Aprano
On Sun, 08 Aug 2010 17:43:03 -0700, rantingrick wrote:

 Ha. Ruby does not really have multi line strings. 

Except, of course, it does, as you go on to show.


 Ruby has what they
 call a Here Doc. Besides picking the most boneheaded name for such an
 object 

It's standard terminology that has been around for a long time in many 
different languages.

http://en.wikipedia.org/wiki/Here_document


 they also introduced and even more boneheaded syntax. To define a
 Here Doc (god i hate that name!) you start with double greater than
  and immediately follow with an identifier token of you choice (it
 can be anything your dirty little mind can come up with.
 
HEREDOC
 this is the body
 of a
 here doc. Why the
 hell did they not just
 use triple quotes like Python did.
 Now i will need to remember some token to know where' i stopped
 HEREDOC


Incorrect.

[st...@sylar ~]$ irb
irb(main):001:0 s = END
SyntaxError: compile error
(irb):1: syntax error
s = END
  ^
from (irb):1
irb(main):002:0 s = -END
irb(main):003:0 Multi-line text
irb(main):004:0 goes here
irb(main):005:0 END
= Multi-line text\ngoes here\n
irb(main):006:0 puts s
Multi-line text
goes here
= nil
irb(main):007:0


 
 As you can see it is another example of tacked on functionality that was
 not carefully considered before hand.

I disagree. It's an old and venerable technique, and very useful on the 
rare occasion that you have lots of quotation marks in a string.

Whether those rare occasions are common enough to require specialist 
syntax is another question. In Python, the idea is that two heredocs (''' 
and ) is enough for anybody. That makes it difficult to write a string 
literal like, e.g.:

  Python strings have four delimiters:
  (1) single quote '
  (2) double quote 
  (3) single-quote here-doc '''
  (4) double-quote here-doc 

  plus equivalent raw-strings of each kind.

Trying writing that as a single literal in Python without escapes. There 
are work-arounds, of course, like using implicit concatenation, but 
they're ugly.

In Ruby they decided to be more general, so you can define whatever 
heredoc you need to quote whatever literal string you need. That's not 
bone-headed.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-24 Thread Gregory Ewing

Jean-Michel Pichavant wrote:

(that makes me think that Perl should be renamed as it 
outrageously share the same 1st character with Python).


+1. I suggest CalcifiedMolluscSecretion. The very awkwardness
of that name will doom the language to the obscurity that it
deserves relative to the One True Language Whose Name Starts
With P. :-)

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-24 Thread Default User
On Thu, Jun 24, 2010 at 02:53, Gregory Ewing greg.ew...@canterbury.ac.nzwrote:

 Jean-Michel Pichavant wrote:

  (that makes me think that Perl should be renamed as it outrageously share
 the same 1st character with Python).


 +1. I suggest CalcifiedMolluscSecretion. The very awkwardness
 of that name will doom the language to the obscurity that it
 deserves relative to the One True Language Whose Name Starts
 With P. :-)

 --
 Greg

 --
 http://mail.python.org/mailman/listinfo/python-list



May I suggest that you read the Python license.  Really read it.  Then read
the Ruby license.  Really read it.

Ask yourself, if I am just using either internally, and not distributing
anything, does it matter which one I use?

Then, ask yourself, if I am creating code to distribute, especially for
commercial purposes, does it matter which one I use?   Which would you be
more willing to bet the farm on (or your house, your career, your food.
etc.)?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-24 Thread Rhodri James
On Wed, 23 Jun 2010 23:47:55 +0100, rantingrick rantingr...@gmail.com  
wrote:



On Jun 23, 4:43 pm, Rhodri James rho...@wildebst.demon.co.uk
wrote:


 And how exactly does your example express itself in a more
 syntactically-correct linear-flow than the two code snippets i
 provided earlier, hmmm?

You did rather carefully pick an example where Python's syntax flow the  
 other way round


rather carefully picked you say? As if built-in functions are hardly
ever used? No I think *your* statement was rather carefully picked
to try and discredit me. Sorry my friend that might work on the less
astute readers round here, but it has no effect on me ;-)


One word: map.

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Jean-Michel Pichavant

rantingrick wrote:

---

On Jun 22, 4:29 am, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:
  

This is a python list, fully dedicated to our dutch semi God. So how can
you even immagine that someone here will suggest you to go for rub...
sorry I can't prononce this blasphemous name.



---


...After reading these comments i reminisce back to a time when a good
friend of this community r said basically the same things but was
lynched for them. 


That's because r is the first letter of Ruby, try p and everybody 
will love you (that makes me think that Perl should be renamed as it 
outrageously share the same 1st character with Python).


JM

PS : I have no idea about Ruby, never used it, so I still don't 
understand why you quote me in  your anti-ruby post

--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread hackingKK
Ruby is a nice language to learn, but I seem to find it less matured.  
That might be my own personal perception.
But looking at its success which you can read on Pythonology, I think it 
is going to be my choice and of many others for a long time to come.

Besides ruby is more popular due to the rails attached to it.
Happy hacking.
Krishnakant.

On Wednesday 23 June 2010 02:10 PM, Jean-Michel Pichavant wrote:

rantingrick wrote:

---

On Jun 22, 4:29 am, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:
This is a python list, fully dedicated to our dutch semi God. So how 
can

you even immagine that someone here will suggest you to go for rub...
sorry I can't prononce this blasphemous name.


---


...After reading these comments i reminisce back to a time when a good
friend of this community r said basically the same things but was
lynched for them. 


That's because r is the first letter of Ruby, try p and everybody 
will love you (that makes me think that Perl should be renamed as it 
outrageously share the same 1st character with Python).


JM

PS : I have no idea about Ruby, never used it, so I still don't 
understand why you quote me in  your anti-ruby post


--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Ed Keith
--- On Wed, 6/23/10, Stephen Hansen me+list/pyt...@ixokai.io wrote:

 From: Stephen Hansen me+list/pyt...@ixokai.io
 Subject: Re: Should I Learn Python or Ruby next?
 To: python-list@python.org
 Date: Wednesday, June 23, 2010, 1:51 AM
 On 6/22/10 10:39 PM, Dennis Lee
 Bieber wrote:
  On Tue, 22 Jun 2010 15:55:51 -0700, Stephen Hansen
  me+list/pyt...@ixokai.io
 declaimed the following in
  gmane.comp.python.general:
  
  I second Forth. Learning and using that was --
 slightly painful, but
  
      Just pick up any advanced HP
 programmable calculator... RPL is a
  close substitute G
 
 That's just a start. The reverse and stack-oriented nature
 of the
 language makes you have to start thinking in an interesting
 way, and
 sure, a RPL/stack-calculator can get that for you.
 
 But then going on and doing real programming with it,
 making your own
 words (functions), ... its fun.
 
 -- 
 
    Stephen Hansen
    ... Also: Ixokai
    ... Mail: me+list/python (AT) ixokai
 (DOT) io
    ... Blog: http://meh.ixokai.io/
 
 
 -Inline Attachment Follows-
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 

I agree you should learn a DIFFERENT programming language. Perl, Python,  Ruby 
are all quite similar. If you want to expand your horizons, learn one of the 
following:

  Forth -lots of fun.

  Assembler - give you a much better understanding of what is really happening 
under the hood.

  Prolog - a very different way of thinking.

Give one of them a try.

   -EdK

Ed Keith
e_...@yahoo.com

Blog: edkeith.blogspot.com





  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Ed Keith

--- On Wed, 6/23/10, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 From: Dennis Lee Bieber wlfr...@ix.netcom.com
 Subject: Re: Should I Learn Python or Ruby next?
 To: python-list@python.org
 Date: Wednesday, June 23, 2010, 1:39 AM
 On Tue, 22 Jun 2010 15:55:51 -0700,
 Stephen Hansen
 me+list/pyt...@ixokai.io
 declaimed the following in
 gmane.comp.python.general:
 
  I second Forth. Learning and using that was --
 slightly painful, but
 
     Just pick up any advanced HP
 programmable calculator... RPL is a
 close substitute G
 
  really invigorating. And I also second learning a
 functional language
  (though I don't know if I'd inflict Haskell on
 anyone).
 
 
     Is APL still available?
         4 5 $rho 20 ? 52
 (using a common means for lack of greek keyboard)
 -- 
     Wulfraed       
          Dennis Lee
 Bieber         AF6VN
         wlfr...@ix.netcom.com 
   HTTP://wlfraed.home.netcom.com/
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 
Try J. It does not require a special keyboard.

-EdK

Ed Keith
e_...@yahoo.com

Blog: edkeith.blogspot.com




  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Dave Angel

Stephen Hansen wrote:

On 6/22/10 10:39 PM, Dennis Lee Bieber wrote:
  

On Tue, 22 Jun 2010 15:55:51 -0700, Stephen Hansen
me+list/pyt...@ixokai.io declaimed the following in
gmane.comp.python.general:



I second Forth. Learning and using that was -- slightly painful, but
  

Just pick up any advanced HP programmable calculator... RPL is a
close substitute G



That's just a start. The reverse and stack-oriented nature of the
language makes you have to start thinking in an interesting way, and
sure, a RPL/stack-calculator can get that for you.

But then going on and doing real programming with it, making your own
words (functions), ... its fun.

  
And two places where it differs from nearly every other language:  when 
you define your own flow-control enhancements to the language (e.g. 
WHILE is not a keyword, it's merely a function), and when you finally 
understand dodoes (that's Do Does).


DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Terry Reedy

On 6/23/2010 1:39 AM, Dennis Lee Bieber wrote:

On Tue, 22 Jun 2010 15:55:51 -0700, Stephen Hansen
me+list/pyt...@ixokai.io  declaimed the following in
gmane.comp.python.general:


I second Forth. Learning and using that was -- slightly painful, but


Just pick up any advanced HP programmable calculator... RPL is a
close substituteG


Or study the current CPython rpn stack machine.

 from dis import dis

 def f(a,b,c): return (a+b)*c

 dis(f)
  1   0 LOAD_FAST0 (a)
  3 LOAD_FAST1 (b)
  6 BINARY_ADD
  7 LOAD_FAST2 (c)
 10 BINARY_MULTIPLY
 11 RETURN_VALUE


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Rhodri James
On Wed, 23 Jun 2010 04:25:38 +0100, rantingrick rantingr...@gmail.com  
wrote:



On Jun 22, 9:31 pm, MRAB pyt...@mrabarnett.plus.com wrote:


[snip]
Napoleon once said Never interrupt your enemy when he is making a
mistake.! :-)


And how exactly does your example express itself in a more
syntactically-correct linear-flow than the two code snippets i
provided earlier, hmmm?


You did rather carefully pick an example where Python's syntax flow the  
other way round and then present all the least Pythonic paraphrases of the  
Ruby functional approach.


--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread rantingrick
On Jun 23, 4:43 pm, Rhodri James rho...@wildebst.demon.co.uk
wrote:

  And how exactly does your example express itself in a more
  syntactically-correct linear-flow than the two code snippets i
  provided earlier, hmmm?

 You did rather carefully pick an example where Python's syntax flow the  
 other way round

rather carefully picked you say? As if built-in functions are hardly
ever used? No I think *your* statement was rather carefully picked
to try and discredit me. Sorry my friend that might work on the less
astute readers round here, but it has no effect on me ;-)

 and then present all the least Pythonic paraphrases of the  
 Ruby functional approach.

What? Did you just use the words Pythonic and Ruby in the same
sentence all the while keeping a strait face? Ruby's naturally linear
phrasing is one thing i like about the language (and map of course),
short of those two niceties i prefer Python.

Would you like to present another way of achieving the same code that
makes Python look better, i would love to see it. Here is an even more
interesting example of Ruby linear-flow verses Python lisp-style-
nesting...

RUBY:
[three,one,two].map{|x| x.capitalize}.sort.join(',')

PYTHON
','.join(sorted(map(lambda x:x.title(), [three, one, two])))

I do the Python code all the time without thinking twice about it. But
to a noob i'll bet Ruby is more decipherable in these cases. It's
ironic that Python was created by a westerner and we read it from
right to left, and Ruby was created by a easterner and we read it left
to right. Go figure?

;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Stephen Hansen
 Would you like to present another way of achieving the same code that
 makes Python look better, i would love to see it. Here is an even more
 interesting example of Ruby linear-flow verses Python lisp-style-
 nesting...

 RUBY:
 [three,one,two].map{|x| x.capitalize}.sort.join(',')

 PYTHON
 ','.join(sorted(map(lambda x:x.title(), [three, one, two])))

','.join(x.title() for x in sorted([three, one, two]))

 I do the Python code all the time without thinking twice about it. But
 to a noob i'll bet Ruby is more decipherable in these cases. It's
 ironic that Python was created by a westerner and we read it from
 right to left, and Ruby was created by a easterner and we read it left
 to right. Go figure?

You read Python from right-to-left; we don't-- I don't.

--Stephen via iPad.
-- 
http://mail.python.org/mailman/listinfo/python-list


Should I Learn Python or Ruby next?

2010-06-22 Thread Josef Tupag
I've been programming (when I do program) mainly in
Perlhttp://www.perl.org/for the last 10 years or so. But I've been
itching to learn a new language
for a while now, and the two near the top of the list are
Rubyhttp://www.ruby-lang.org/and
Python http://python.org/.

I figure that Ruby would be easy to learn because of its similarity to Perl
(I'm told). But I also figure that Python would be easy to learn because of
its simplicity. And when it comes to webby stuff, I can use
Railshttp://www.rubyonrails.org/with Ruby and
Django http://www.djangoproject.com/ with Python.

I'm currently leaning toward Python and began doing so last week. I started
with Mark Pilgrim's excellent Dive Into Python
http://diveintopython.org/and made it thru the first 3 chapters
pretty quickly. So far it feels pretty
good.

Before I really dive in, though, I'm curious to hear what others think about
the choice between these two languages.

(On a related note, you might also read Tim Bray's On
Rubyhttp://www.tbray.org/ongoing/When/200x/2006/07/24/Rubypost,
since he just started learning Ruby.)

Josef Tupag - best humidifier http://thebesthumidifiers.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread James Mills
On Tue, Jun 22, 2010 at 6:58 PM, Josef Tupag joseftu...@gmail.com wrote:
 Before I really dive in, though, I'm curious to hear what others think about
 the choice between these two languages.

This is a terribly subjective opinion and I apologize to anyone that
actually uses
Ruby and likes it :)

I find Ruby (compared to Python) to be a syntactical rip-off and
a bad one at that. Some things in Ruby aren't nearly as simple or
as concise as you would find in Python.

When it comes to Web Frameworks IHMO, I believe Python has
a lot wide variety of tools available to you, not just Django,
TurbotGears, Pylons, etc. (I can't comment on Ruby).

Aside from my not liking some of Ruby's syntax or semantics
I found Ruby on Rails to be awful. I went through it's turotial
a few months back and didn't even make the first couple of pages
before I got utterly bored with reading.

So there you go...

Sorry I can't offer you a real objective response!

cheers
James
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Shashwat Anand
Josef: Make sure you ask this question on Ruby mailing list too. Just like
James I too am personally biased towards python and so will be a lot of
people on this list.

On Tue, Jun 22, 2010 at 2:50 PM, James Mills
prolo...@shortcircuit.net.auwrote:

 On Tue, Jun 22, 2010 at 6:58 PM, Josef Tupag joseftu...@gmail.com wrote:
  Before I really dive in, though, I'm curious to hear what others think
 about
  the choice between these two languages.

 This is a terribly subjective opinion and I apologize to anyone that
 actually uses
 Ruby and likes it :)

 I find Ruby (compared to Python) to be a syntactical rip-off and
 a bad one at that. Some things in Ruby aren't nearly as simple or
 as concise as you would find in Python.

 When it comes to Web Frameworks IHMO, I believe Python has
 a lot wide variety of tools available to you, not just Django,
 TurbotGears, Pylons, etc. (I can't comment on Ruby).

 Aside from my not liking some of Ruby's syntax or semantics
 I found Ruby on Rails to be awful. I went through it's turotial
 a few months back and didn't even make the first couple of pages
 before I got utterly bored with reading.

 So there you go...

 Sorry I can't offer you a real objective response!

 cheers
 James
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Jean-Michel Pichavant

Josef Tupag wrote:


I've been programming (when I do program) mainly in Perl 
http://www.perl.org/ for the last 10 years or so. But I've been 
itching to learn a new language for a while now, and the two near the 
top of the list are Ruby http://www.ruby-lang.org/ and Python 
http://python.org/.


I figure that Ruby would be easy to learn because of its similarity to 
Perl (I'm told). But I also figure that Python would be easy to learn 
because of its simplicity. And when it comes to webby stuff, I can use 
Rails http://www.rubyonrails.org/ with Ruby and Django 
http://www.djangoproject.com/ with Python.


I'm currently leaning toward Python and began doing so last week. I 
started with Mark Pilgrim's excellent Dive Into Python 
http://diveintopython.org/ and made it thru the first 3 chapters 
pretty quickly. So far it feels pretty good.


Before I really dive in, though, I'm curious to hear what others think 
about the choice between these two languages.


(On a related note, you might also read Tim Bray's On Ruby 
http://www.tbray.org/ongoing/When/200x/2006/07/24/Ruby post, since 
he just started learning Ruby.)



Josef Tupag - best humidifier http://thebesthumidifiers.com



Hello,

This is a python list, fully dedicated to our dutch semi God. So how can 
you even immagine that someone here will suggest you to go for rub... 
sorry I can't prononce this blasphemous name.


JM


--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread James Mills
On Tue, Jun 22, 2010 at 7:29 PM, Jean-Michel Pichavant
jeanmic...@sequans.com wrote:
 This is a python list, fully dedicated to our dutch semi God. So how can you
 even immagine that someone here will suggest you to go for rub... sorry I
 can't prononce this blasphemous name.

Good call :) (Personally - and again sorry if there are any
Python/Rub* dualists!) -- When I came across Rub* I found it to
be just a rip-off of Python (in some respects) and couldn't understand
how it became popular so quickly :)

It's not that great really!

--James

-- 
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Thomas Jollans
On 06/22/2010 10:58 AM, Josef Tupag wrote:
 I've been programming (when I do program) mainly in Perl
 http://www.perl.org/ for the last 10 years or so. But I've been
 itching to learn a new language for a while now, and the two near the
 top of the list are Ruby http://www.ruby-lang.org/ and Python
 http://python.org/.
 
 I figure that Ruby would be easy to learn because of its similarity to
 Perl (I'm told). But I also figure that Python would be easy to learn
 because of its simplicity. And when it comes to webby stuff, I can use
 Rails http://www.rubyonrails.org/ with Ruby and Django
 http://www.djangoproject.com/ with Python.
 
 I'm currently leaning toward Python and began doing so last week. I
 started with Mark Pilgrim's excellent Dive Into Python
 http://diveintopython.org/ and made it thru the first 3 chapters
 pretty quickly. So far it feels pretty good.
 
 Before I really dive in, though, I'm curious to hear what others think
 about the choice between these two languages.

Ruby has a bunch of strange syntactical zits: I mean, @instancevariable,
@@classvariable, $GLOBAL, and whatnot?? I don't like them, I find
Python's syntax cleaner, easier on the eye, and the finger.

It's all a matter of taste. You should probably look into Ruby too, at
least a bit. I can think of one single point where Python probably wins
hands-down: it comes with batteries included. The standard library is
great, and I don't think Ruby has anything like it. There are rubygems,
of course, but there is also the PyPI.

Everything is an object in both languages, or so they say. But what
that means is different. If you're coming from Perl 5, you probably
won't care much anyway. I personally prefer Python's [methods are
functions are objects] to Ruby's [functions are methods are
messages-to-objects]. Ah well

To get really religious, and Ruby violates quite a few of these,
 import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!



[Community!]
Ruby is almost only used on Rails and in Japan. We're much more
universal, and more friendly ! ;-)

-- Thomas

 
 (On a related note, you might also read Tim Bray's On Ruby
 http://www.tbray.org/ongoing/When/200x/2006/07/24/Ruby post, since he
 just started learning Ruby.)
 
 
 Josef Tupag - best humidifier http://thebesthumidifiers.com
 
 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread lkcl
On Tue, Jun 22, 2010 at 6:58 PM, Josef Tupag joseftu...@gmail.com
wrote:
 Before I really dive in, though, I'm curious to hear what others think about
 the choice between these two languages.

 i think one good illustration is a story i heard from someone who had
learned a hell of a lot of programming languages, but didn't know
python.  he decided one day to try it and, without looking closely at
a manual, literally guessed his way through the syntax:

how do you do lists?  let's try square brackets.  oh look, that
worked!  ok.. um... how do you do arrays?  let's try curly brackets.
oh look, that worked!  ok, what are they called?  ahh, dictionaries.
how quaint.  ok, how do you do if statements?  ok let's try the
woordd if!  ok, that worked - hmmm, how do you terminate them?  let's
tryyy... a colon - great - that worked!  hmmm, what's with this three
dots on the python prompt, now?  ok, let's put in some spaces.  ah
ha!  that worked!

 when compared to other programming languages, three things stand out
clearly for me:

 1) it's actually readable.  especially when you use colour syntax
highlighting (such as vim) which i thoroughly, thoroughly recommend:
giving yourself those visual cues that keywords are in yellow,
comments are in blue, strings in purple, it increases productivity
*massively* as you scan through reams of text, jumping to the correct
location, finding what you want, based on blocks of colour *first*,
and the characters second.

 2) it's beautiful / tidy.  the use of fixed/identical indentation to
specify a block _forces_ the developer to be tidy.  i've seen some
developers - perl mostly - _actively_ discouraged and hostile to perl
because of this, and to be frank, that's a good thing.

 3) it's a dynamic and a compact language.  i remember seeing that
comparison of python and lisp, which happened to include some java
statements as well.  _six_ lines of java to do what you can do in a
few characters of python - and about two in scheme :)

 so whilst ruby may be dynamic and compact, it's not beautiful,
readable or obvious as to what's going on.  i look at a python
program, and it uses actual... like... y'know... words that make
sense.  i look at a ruby program and i simply cannot say the same, not
even if you put code which is supposed to do exactly the same job.

 l.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Michael Crute
On Tue, Jun 22, 2010 at 4:58 AM, Josef Tupag joseftu...@gmail.com wrote:
 I've been programming (when I do program) mainly in Perl for the last 10
 years or so. But I've been itching to learn a new language for a while now,
 and the two near the top of the list are Ruby and Python.

If you have the time give both a try. Start with Python, of course
;-). I've been programming Python as my primary language for the past
4 years after having done Perl and PHP professionally. Python is a lot
of fun, the language is very clean and clear and it's got a great
standard library. From my dabbling in Ruby I can say that I'm not too
keen on the syntax of the language or some of the semantics, it just
feel sloppy (but certainly less sloppy than PHP). Both languages are
very functional and you can do the same tasks in either one so I think
it comes down, mostly, to syntax and semantics.

-- 
Michael E. Crute
http://mike.crute.org

It is a mistake to think you can solve any major problem just with
potatoes. --Douglas Adams
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Nathan Rice
It really depends on what you want to do.  Ruby and Python are both highly
expressive languages.  Python syntax seems nicer to me but that is
subjective.

As far as community support, Python has 4342 packages listed in sourceforge,
Ruby has 705.  Python is listed in ~0.4% of jobs at indeed.com's trend
analyzer, Ruby is at about 0.3%.  Ruby seems to have traction primarily in
the web arena, with rails.  Python has traction in both the web area, with
Django, and in system administration and science/data analysis fields.
 Hopefully this objective information will help guide you.

On Tue, Jun 22, 2010 at 4:58 AM, Josef Tupag joseftu...@gmail.com wrote:

 I've been programming (when I do program) mainly in 
 Perlhttp://www.perl.org/for the last 10 years or so. But I've been itching 
 to learn a new language
 for a while now, and the two near the top of the list are 
 Rubyhttp://www.ruby-lang.org/and
 Python http://python.org/.

 I figure that Ruby would be easy to learn because of its similarity to Perl
 (I'm told). But I also figure that Python would be easy to learn because of
 its simplicity. And when it comes to webby stuff, I can use 
 Railshttp://www.rubyonrails.org/with Ruby and
 Django http://www.djangoproject.com/ with Python.

 I'm currently leaning toward Python and began doing so last week. I started
 with Mark Pilgrim's excellent Dive Into Pythonhttp://diveintopython.org/and 
 made it thru the first 3 chapters pretty quickly. So far it feels pretty
 good.

 Before I really dive in, though, I'm curious to hear what others think
 about the choice between these two languages.

 (On a related note, you might also read Tim Bray's On 
 Rubyhttp://www.tbray.org/ongoing/When/200x/2006/07/24/Rubypost, since he 
 just started learning Ruby.)

 Josef Tupag - best humidifier http://thebesthumidifiers.com



 --
 http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread James Mills
On Tue, Jun 22, 2010 at 9:37 PM, Nathan Rice
nathan.alexander.r...@gmail.com wrote:
 As far as community support, Python has 4342 packages listed in sourceforge,
 Ruby has 705.  Python is listed in ~0.4% of jobs at indeed.com's trend

You are forgetting the 10278 (last count) or so packages, modules and what not
available on PyPi (1).

cheers
James

1. http://pypi.python.org/


-- 
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Stephen Hansen
On 6/22/10 4:51 AM, James Mills wrote:
 On Tue, Jun 22, 2010 at 9:37 PM, Nathan Rice
 nathan.alexander.r...@gmail.com wrote:
 As far as community support, Python has 4342 packages listed in sourceforge,
 Ruby has 705.  Python is listed in ~0.4% of jobs at indeed.com's trend
 
 You are forgetting the 10278 (last count) or so packages, modules and what not
 available on PyPi (1).

In all fairness, then you need to compare the nearly nine thousand
packages on RubyForge.

But, otherwise, I refrain from this conversation. Obviously the users on
this list prefer Python, in general. We may have many fine reasons for
doing so, some of us may have used a bit of Ruby, but LanguageA or
LanguageB conversations are never really useful.

If you're doing this to solve a certain problem: specify the problem,
and I may have some real insight for you. If you're learning this out of
an academic desire to learn a new language, then learn both.

Learning a new language is always a net win. Which first? Whatever you
have the vaguest preference for after five minutes.

No reason to be picky with adding tools to your mental toolbox.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread D'Arcy J.M. Cain
On Tue, 22 Jun 2010 03:02:15 -0700 (PDT)
lkcl luke.leigh...@gmail.com wrote:
  so whilst ruby may be dynamic and compact, it's not beautiful,
 readable or obvious as to what's going on.  i look at a python
 program, and it uses actual... like... y'know... words that make

Python is executible pseudocode.

-- 
D'Arcy J.M. Cain da...@druid.net |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Andreas Waldenburger
On Tue, 22 Jun 2010 19:38:43 +1000 James Mills
prolo...@shortcircuit.net.au wrote:

 When I came across Rub* I found it to be just a rip-off of Python (in
 some respects) and couldn't understand how it became popular so
 quickly :)

You answered your own question: It's a rip-off of Python.

On a more serious note, though, I think Ruby is as much a rip-off of
Python as Python is a rip-off of Smalltalk or Modula. I think one
should be careful with such statements. Then again, this is a Python
group, so you're relatively safe, I guess. ;)

/W

-- 
INVALID? DE!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Andreas Waldenburger
On Tue, 22 Jun 2010 10:49:49 -0400 D'Arcy J.M. Cain da...@druid.net
wrote:

 Python is executible pseudocode.
 

I don't know about you, but if I didn't know this to be praise, it'd
sound like an insult to me. As in Timecube is expendable
pseudoscience.

Phrases like Your mother [has property x] have the same effect on me,
no matter how flattering ascribing [property x] to someone might
actually be.

Your mother is executable pseudocode.
See?

No, I don't have a lot to do right now, why do you ask? ;)
/W

-- 
INVALID? DE!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread geremy condra
On Tue, Jun 22, 2010 at 1:58 AM, Josef Tupag joseftu...@gmail.com wrote:
 I've been programming (when I do program) mainly in Perl for the last 10
 years or so. But I've been itching to learn a new language for a while now,
 and the two near the top of the list are Ruby and Python.

My advice is to learn something *really different* while you've got the itch.
Work with Forth or (my favorite non-Python language) Haskell for six
months and then come back to things like Python or Ruby- IME it helps
to highlight where there are actual differences between languages and
where there's just minor variations in approach.

Geremy Condra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Stephen Hansen
On 6/22/10 3:35 PM, geremy condra wrote:
 On Tue, Jun 22, 2010 at 1:58 AM, Josef Tupag joseftu...@gmail.com wrote:
 I've been programming (when I do program) mainly in Perl for the last 10
 years or so. But I've been itching to learn a new language for a while now,
 and the two near the top of the list are Ruby and Python.
 
 My advice is to learn something *really different* while you've got the itch.
 Work with Forth or (my favorite non-Python language) Haskell for six
 months and then come back to things like Python or Ruby- IME it helps
 to highlight where there are actual differences between languages and
 where there's just minor variations in approach.

I second Forth. Learning and using that was -- slightly painful, but
really invigorating. And I also second learning a functional language
(though I don't know if I'd inflict Haskell on anyone).

It bends your brain and makes you think in a different way. The mental
toolbox expands. New possibilities suddenly occur to you down the road
when you return to Python (or Perl, even) for some sane, regular sort of
coding.

Learning new languages = good.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread John Bokma
geremy condra debat...@gmail.com writes:

 On Tue, Jun 22, 2010 at 1:58 AM, Josef Tupag joseftu...@gmail.com wrote:
 I've been programming (when I do program) mainly in Perl for the last 10
 years or so. But I've been itching to learn a new language for a while now,
 and the two near the top of the list are Ruby and Python.

 My advice is to learn something *really different* while you've got the itch.
 Work with Forth or (my favorite non-Python language) Haskell for six
 months and then come back to things like Python or Ruby- IME it helps
 to highlight where there are actual differences between languages and
 where there's just minor variations in approach.

Good advice. While I have been exposed to functional programming 16+
years ago, I am reading up on Haskell, and learing a bit of Lisp (Emacs
Lisp).

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread rantingrick

Quotes for this thread...

On Jun 22, 4:20 am, James Mills prolo...@shortcircuit.net.au wrote:
 I find Ruby (compared to Python) to be a syntactical rip-off and
 a bad one at that. Some things in Ruby aren't nearly as simple or
 as concise as you would find in Python.

---

On Jun 22, 4:29 am, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:
 This is a python list, fully dedicated to our dutch semi God. So how can
 you even immagine that someone here will suggest you to go for rub...
 sorry I can't prononce this blasphemous name.

---

On Jun 22, 5:02 am, lkcl luke.leigh...@gmail.com wrote:
  so whilst ruby may be dynamic and compact, it's not beautiful,
 readable or obvious as to what's going on.  i look at a python
 program, and it uses actual... like... y'know... words that make
 sense.  i look at a ruby program and i simply cannot say the same, not
 even if you put code which is supposed to do exactly the same job.

---

On Jun 22, 5:02 am, Thomas Jollans tho...@jollans.com wrote:
 Ruby has a bunch of strange syntactical zits: I mean, @instancevariable,
 @@classvariable, $GLOBAL, and whatnot?? I don't like them, I find
 Python's syntax cleaner, easier on the eye, and the finger.

 To get really religious, and Ruby violates quite a few of these, import 
 this

 The Zen of Python, by Tim Peters
  ...snip Zen...
 Ruby is almost only used on Rails and in Japan. We're much more
 universal, and more friendly !

---

On Jun 22, 9:49 am, D'Arcy J.M. Cain da...@druid.net wrote:
 Python is executible pseudocode.

---


...After reading these comments i reminisce back to a time when a good
friend of this community r said basically the same things but was
lynched for them. Hmm? Has the community changed? Or is it that these
comments came from someone other than r that they go unpunished.
Hmm, riddles in the dark...?

Josef, As for me i would suggest Python (of course). Ruby has a very
very few niceties but all in all Python wins hands down. However if
your a past perl obfuscation nut, or laborious lisper, just skip
strait over to Ruby right away because you ain't gonna like Python's
clean syntax! ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Rhodri James
On Wed, 23 Jun 2010 00:09:15 +0100, rantingrick rantingr...@gmail.com  
wrote:



...After reading these comments i reminisce back to a time when a good
friend of this community r said basically the same things but was
lynched for them. Hmm? Has the community changed? Or is it that these
comments came from someone other than r that they go unpunished.
Hmm, riddles in the dark...?


I don't recall seeing r say basically the same things.  Of course, r  
being one of the four people introduced to my killfile may have had an  
effect on that.


Strangely, I do recall a number of occasions on which r blathered on in  
a manner that could be mistaken for those things if one didn't actually  
read what was written.


--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Stephen Hansen
On 6/22/10 4:09 PM, rantingrick wrote:
 ...After reading these comments i reminisce back to a time when a good
 friend of this community r said basically the same things but was
 lynched for them. Hmm? Has the community changed? Or is it that these
 comments came from someone other than r that they go unpunished.
 Hmm, riddles in the dark...? 

If I remember the thread correctly, it was a part of a Call to Arms to
march out and Wage War against Ruby and Defeat It before it Defeated Us.

Or something to that nature. If I'm remembering a different thread then
you are, well -- there /was/ a thread like that.

And that's terribly exhausting. See, we all (wait, let me get up on a
stool and speak for The Community) may quite like Python, may quite not
like Ruby, and may find usage of Ruby to be perhaps a sign of some form
of mental illness (okay, no, not really), but we're also quite content
and happy for people to use Ruby if they want to. And we're oddly not
threatened by its popularity.

Good for you, Rubyers. I applaud your success and wish you more of it.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Thomas Jollans
On 06/23/2010 01:30 AM, Stephen Hansen wrote:
 On 6/22/10 4:09 PM, rantingrick wrote:
 ...After reading these comments i reminisce back to a time when a good
 friend of this community r said basically the same things but was
 lynched for them. Hmm? Has the community changed? Or is it that these
 comments came from someone other than r that they go unpunished.
 Hmm, riddles in the dark...? 
 
 If I remember the thread correctly, it was a part of a Call to Arms to
 march out and Wage War against Ruby and Defeat It before it Defeated Us.
 
 Or something to that nature. If I'm remembering a different thread then
 you are, well -- there /was/ a thread like that.
 
 And that's terribly exhausting. See, we all (wait, let me get up on a
 stool and speak for The Community) may quite like Python, may quite not
 like Ruby, and may find usage of Ruby to be perhaps a sign of some form
 of mental illness (okay, no, not really), but we're also quite content
 and happy for people to use Ruby if they want to. And we're oddly not
 threatened by its popularity.
 
 Good for you, Rubyers. I applaud your success and wish you more of it.

Hear, hear!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Emile van Sebille

On 6/22/2010 4:09 PM rantingrick said...
snip


...After reading these comments i reminisce back to a time when a good
friend of this community r said basically the same things but was
lynched for them.Hmm? Has the community changed? Or is it that these
comments came from someone other than r that they go unpunished.
Hmm, riddles in the dark...?


Hmm, I don't remember the thread you're referring to, but when Matz 
launched Ruby and the volume of posts on c.l.py talking about ruby 
increased, we all wished him the best and voted to establish c.l.ruby. 
(OK, call it voted him off the island if you wish.)  As I recall, 
compilation was the biggest missing piece that Matz wanted and my 
impression was that Ruby in the early days used much of what was then 
pythonesque.  I always figured to take a closer look if/when python 
didn't run as quickly as I needed.   Hasn't happened yet...


Emile




--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Gregory Ewing

Thomas Jollans wrote:


Everything is an object in both languages, or so they say.


That's really a meaningless statement, because it depends on
what you count as a thing. But there is at least one thing
that is an object in Python but not in Ruby. There are no
stand-alone functions in Ruby, or callable objects in general.
The only way to invoke code is to call a method of some
object.

This can be confusing to someone coming from Python, because
you can write what *look* deceptively like top-level function
definitions. But they actually become methods of class Object,
which is inherited by everything, and thus become implicitly
available in any other method.

You can ignore the difference until you start trying to
use modules. Ruby has something it calls a module, but it's
really more like a mixin class. If you try to think of it and
use it like a Python module, you'll get very confused and
frustrated and pull out large chunks of hair. At least I
did until I figured out what was really going on behind the
scenes.

Having used both, I find the way that Python handles namespaces
to be greatly preferable. This may be partly because I'm more
familiar with it, but I think there are ways in which it's
objectively simpler and more useful for organising code.

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread rantingrick
On Jun 22, 7:56 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
 Thomas Jollans wrote:
  Everything is an object in both languages, or so they say.

 That's really a meaningless statement, because it depends on
 what you count as a thing. But there is at least one thing
 that is an object in Python but not in Ruby. There are no
 stand-alone functions in Ruby, or callable objects in general.
 The only way to invoke code is to call a method of some
 object.

Although i will admit the chaining of methods compared to the nesting
of built in functions seems more linear-ly natural as in this case...

RUBY:
['one', 'two', 'three'].map{|x| x.capitalize}.join(',')

PYTHON
','.join(map(string.capitalize, ['one','two', 'three']))
','.join(map(lambda x:x.title(), ['one','two', 'three']))

...but i digress

 This can be confusing to someone coming from Python, because
 you can write what *look* deceptively like top-level function
 definitions. But they actually become methods of class Object,
 which is inherited by everything, and thus become implicitly
 available in any other method.

Yes i call that Ruby's Global Nightmare and the folks over at
SketchUp are learning day by day how this nightmare is going to
undermine the Ruby API. Not only that, but since the API is for
scripting it seems more natural to use Pythonic namespaces so you can
write simple scripts very easily with one or two functions or complete
packages spanning multiple modules without fear of name clashes (ever
tried debugging that! 8^O). Of course you can create a module with
Ruby (see next comment)

 You can ignore the difference until you start trying to
 use modules. Ruby has something it calls a module, but it's
 really more like a mixin class. If you try to think of it and
 use it like a Python module, you'll get very confused and
 frustrated and pull out large chunks of hair. At least I
 did until I figured out what was really going on behind the
 scenes.

I always found it so odd that Ruby uses a special syntax for modules
and not just copy the beautiful solution Python has pioneered. Matz,
you already copied SOOO much, are you really trying to save face,
because it's far too late for that my friend!

 Having used both, I find the way that Python handles namespaces
 to be greatly preferable. This may be partly because I'm more
 familiar with it, but I think there are ways in which it's
 objectively simpler and more useful for organising code.

Python's way is better. There is no way to argue against it. Globals
are bad, redundant end statements are bad, TIMTOWTDI is bad, module
declarations are bad, not having docstrings is bad, allowing method
calls without parenthesis is bad, using punctuation in identifiers is
bad, bad keyword naming choices are bad, need i go on...?

I would say check out Ruby if no more than just out of curiosity. You
will find the map far more useful, and the linear chaining of methods
more natural, but after that there really ain't much more to
like! ...although i am sure the word closure is coming up *real*
soon!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread MRAB

rantingrick wrote:

On Jun 22, 7:56 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:

Thomas Jollans wrote:

Everything is an object in both languages, or so they say.

That's really a meaningless statement, because it depends on
what you count as a thing. But there is at least one thing
that is an object in Python but not in Ruby. There are no
stand-alone functions in Ruby, or callable objects in general.
The only way to invoke code is to call a method of some
object.


Although i will admit the chaining of methods compared to the nesting
of built in functions seems more linear-ly natural as in this case...

RUBY:
['one', 'two', 'three'].map{|x| x.capitalize}.join(',')

PYTHON
','.join(map(string.capitalize, ['one','two', 'three']))


','.join(x.capitalize() for x in ['one','two', 'three'])


','.join(map(lambda x:x.title(), ['one','two', 'three']))

...but i digress


This can be confusing to someone coming from Python, because
you can write what *look* deceptively like top-level function
definitions. But they actually become methods of class Object,
which is inherited by everything, and thus become implicitly
available in any other method.


Yes i call that Ruby's Global Nightmare and the folks over at
SketchUp are learning day by day how this nightmare is going to
undermine the Ruby API. Not only that, but since the API is for
scripting it seems more natural to use Pythonic namespaces so you can
write simple scripts very easily with one or two functions or complete
packages spanning multiple modules without fear of name clashes (ever
tried debugging that! 8^O). Of course you can create a module with
Ruby (see next comment)


[snip]
Napoleon once said Never interrupt your enemy when he is making a
mistake.! :-)

--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread rantingrick
On Jun 22, 9:31 pm, MRAB pyt...@mrabarnett.plus.com wrote:

 [snip]
 Napoleon once said Never interrupt your enemy when he is making a
 mistake.! :-)

And how exactly does your example express itself in a more
syntactically-correct linear-flow than the two code snippets i
provided earlier, hmmm?

PS: Oh yes i do know about generators and *even* list comprehensions.
They are some of my favorite Python syntactic sugars. But heck there
are so many tasty sugars in Python i guess the only thing a Python
noob should really worry about is premature tooth decay! ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread David Cournapeau
On Tue, Jun 22, 2010 at 5:58 PM, Josef Tupag joseftu...@gmail.com wrote:
 I've been programming (when I do program) mainly in Perl for the last 10
 years or so. But I've been itching to learn a new language for a while now,
 and the two near the top of the list are Ruby and Python.

 I figure that Ruby would be easy to learn because of its similarity to Perl
 (I'm told). But I also figure that Python would be easy to learn because of
 its simplicity. And when it comes to webby stuff, I can use Rails with Ruby
 and Django with Python.

I think it does not matter much. It matters much more that you know
one of them really well rather than both of them so so.

There are some stuff in python without any equivalent in ruby AFAIK,
things like numpy/scipy. I am sure the contrary is true as well, but I
don't enough about ruby to have an informed opinion.

cheers,

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Stephen Hansen
On 6/22/10 10:39 PM, Dennis Lee Bieber wrote:
 On Tue, 22 Jun 2010 15:55:51 -0700, Stephen Hansen
 me+list/pyt...@ixokai.io declaimed the following in
 gmane.comp.python.general:
 
 I second Forth. Learning and using that was -- slightly painful, but
 
   Just pick up any advanced HP programmable calculator... RPL is a
 close substitute G

That's just a start. The reverse and stack-oriented nature of the
language makes you have to start thinking in an interesting way, and
sure, a RPL/stack-calculator can get that for you.

But then going on and doing real programming with it, making your own
words (functions), ... its fun.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-23 Thread Anh Hai Trinh
On Feb 23, 1:03 pm, Alf P. Steinbach al...@start.no wrote:

 Uhm, Paganini...

 As I understand it he invented the destroy your instruments on stage. :-)

 Cheers,

 - Alf (off-topic)

You probably meant Franz Liszt, who regularly broke piano strings.
Paganini was also a rock-star virtuoso but he did not destroy any
Guarnerius or Stradivarius violins in his possession (at least not to
anyone's knowledge :)

As for functional programming, different people take it to mean
different things. For some, simply using first-class functions
qualifies as functional programming.  Others require their functions
to be pure so that their call graphs can be automatically reduced and
their results can be lazily evaluated.  If you takes the former view,
most Python programmers already do functional programming :p

--aht
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-23 Thread Timothy N. Tsvetkov
On Feb 16, 10:41 pm, Andrej Mitrovic andrej.mitrov...@gmail.com
wrote:
 On Feb 16, 7:38 pm, Casey Hawthorne caseyhhammer_t...@istar.ca
 wrote:

  Interesting talk on Python vs. Ruby and how he would like Python to
  have just a bit more syntactic flexibility.

 http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-de...
  --
  Regards,
  Casey

 Gary's friend Geoffrey Grosenbach says in his blog post (which Gary
 linked to): Python has no comparable equivalent to Ruby’s do end
 block. Python lambdas are limited to one line and can’t contain
 statements (for, if, def, etc.). Which leaves me wondering, what’s the
 point?

 I'm sorry, lambda's do support if's and for's. Also, lambda's are
 expressions, not statements, but you can pass them around, keep them
 in a dictionary if you want to. And if you need more than one line of
 statements, for crying out loud use a def? And who needs those do-
 end blocks anyway, trying to turn Python into Pascal?

I think there are some nice use-cases for anonymous functions /
blocks. First, mentioned above, is pretty DSL. And the second is using
blocks in map/reduce functions. Yes, you can pass there a function but
I believe that in most situations it is more readable to pass a
multiline anonymous function / block than defined somewhere function
written only for a single map/reduce operation. And often when you use
reduce it is a bit more complicated then just one line function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Jonathan Gardner
On Sun, Feb 21, 2010 at 10:22 AM, John Bokma j...@castleamber.com wrote:
 Jonathan Gardner jgard...@jonathangardner.net writes:
 On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan lie.1...@gmail.com wrote:

 Now, why don't we start a PEP to make python a fully-functional language
 then?

 Because people don't think the same way that programs are written in
 functional languages.

 Heh! When I learned Miranda it felt natural to me. Prolog on the other
 hand...

 In short: I am afraid you're overgeneralizing here; it depends on one's
 background. If not, citation needed ;-)


Unfortunately, this is something that is hardly measurable. Short of a
survey (of whom? of what?), there can be no objective evaluation. To
date, I don't know of any such studies or surveys.

I won't deny that really smart people enjoy the challenge of
programming in a functional style, and some even find it easier to
work with. However, when it comes to readability and maintenance, I
appreciate the statement-based programming style, simply because it's
easier for me to understand an debug.

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Paul Rubin
Jonathan Gardner jgard...@jonathangardner.net writes:
 I won't deny that really smart people enjoy the challenge of
 programming in a functional style, and some even find it easier to
 work with. However, when it comes to readability and maintenance, I
 appreciate the statement-based programming style, simply because it's
 easier for me to understand an debug.

One thing those people are after is programs that work properly the
first time they are run, and thus don't need debugging.  They achieve
that a surprising amount of the time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread John Bokma
Jonathan Gardner jgard...@jonathangardner.net writes:

 On Sun, Feb 21, 2010 at 10:22 AM, John Bokma j...@castleamber.com wrote:
 Jonathan Gardner jgard...@jonathangardner.net writes:
 On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan lie.1...@gmail.com wrote:

 Now, why don't we start a PEP to make python a fully-functional language
 then?

 Because people don't think the same way that programs are written in
 functional languages.

 Heh! When I learned Miranda it felt natural to me. Prolog on the other
 hand...

 In short: I am afraid you're overgeneralizing here; it depends on one's
 background. If not, citation needed ;-)


 Unfortunately, this is something that is hardly measurable. Short of a
 survey (of whom? of what?), there can be no objective evaluation. To
 date, I don't know of any such studies or surveys.

 I won't deny that really smart people enjoy the challenge of
 programming in a functional style, and some even find it easier to
 work with. However, when it comes to readability and maintenance, I
 appreciate the statement-based programming style, simply because it's
 easier for me to understand an debug.

In my class there where basically 2 groups of people: the ones who got
functional programming and the ones who had a hard time with it. The
latter group consisted mostly of people who had been programming in
languages like C and Pascal for years; they had a hard time thinking
functionally. The former group consisted mostly of people who had little
or no programming experience, with a few exceptions (including me :-) ).

So I have the feeling it has more to do with your background then how
people think / are wired.

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Lawrence D'Oliveiro
In message 1ecc71bf-54ab-45e6-a38a-d1861f092...@v25g2000yqk.googlegroups.com, 
sjdevn...@yahoo.com wrote:

 On Feb 20, 1:30 am, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand 
 wrote:

 In message op.u8at0suda8n...@gnudebst, Rhodri James wrote:

  In classic Pascal, a procedure was distinct from a function in that it
  had no return value.  The concept doesn't really apply in Python; there
  are no procedures in that sense, since if a function terminates without
  supplying an explicit return value it returns None.

 If Python doesn’t distinguish between procedures and functions, why
 should it distinguish between statements and expressions?
 
 Because the latter are different in Python (and in Ruby, and in most
 modern languages), while the former aren't distinguished in Python or
 Ruby or most modern languages?  Primarily functional languages are the
 main exception, but other than them it's pretty uncommon to find any
 modern language that does distinguish procedures and functions, or one
 that doesn't distinguished statements and expressions.
 
 You can certainly find exceptions, but distinguishing statements and
 expressions is absolutely commonplace in modern languages, and
 distinguishing functions and procedures is in the minority.

So they are worth distinguishing where they are distinguished, except where
they’re not?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Paul Rubin
John Bokma j...@castleamber.com writes:
 In my class there where basically 2 groups of people: the ones who got
 functional programming and the ones who had a hard time with it. The
 latter group consisted mostly of people who had been programming in
 languages like C and Pascal for years; they had a hard time thinking
 functionally. 

I've heard it expressed this way (paraphrased): functional programming
has a steep unlearning curve.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Lawrence D'Oliveiro
In message 
3aa0205f-1e98-4376-92e4-607f96f13...@k19g2000yqc.googlegroups.com, Michael 
Sparks wrote:

 [1] This is perhaps more appropriate because '(a b c) is equivalent
 to (quote a b c), and quote a b c can be viewed as close to
 python's expression lambda: a b c

You got to be kidding.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Jonathan Gardner
On Mon, Feb 22, 2010 at 12:31 PM, John Bokma j...@castleamber.com wrote:

 In my class there where basically 2 groups of people: the ones who got
 functional programming and the ones who had a hard time with it. The
 latter group consisted mostly of people who had been programming in
 languages like C and Pascal for years; they had a hard time thinking
 functionally. The former group consisted mostly of people who had little
 or no programming experience, with a few exceptions (including me :-) ).

 So I have the feeling it has more to do with your background then how
 people think / are wired.


That's encouraging. If functional programming is really more natural
to those who are less familiar with math and programming, then perhaps
there is a future for it.

Unfortunately, I don't know that just knowing how to program
functionally is enough. Even the functional folks have a hard time
optimizing routines (time or memory). Even with DBAs, they have to
know how the functional SQL query is translated into discrete machine
instructions.

As it is now, the vast majority (all?) of the programmers who do any
programming seriously are familiar with the statement-based approach.
A minority understand let alone appreciate the functional approach.

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Steve Howell
On Feb 22, 8:35 pm, Jonathan Gardner jgard...@jonathangardner.net
wrote:
 On Mon, Feb 22, 2010 at 12:31 PM, John Bokma j...@castleamber.com wrote:

  In my class there where basically 2 groups of people: the ones who got
  functional programming and the ones who had a hard time with it. The
  latter group consisted mostly of people who had been programming in
  languages like C and Pascal for years; they had a hard time thinking
  functionally. The former group consisted mostly of people who had little
  or no programming experience, with a few exceptions (including me :-) ).

  So I have the feeling it has more to do with your background then how
  people think / are wired.

 That's encouraging. If functional programming is really more natural
 to those who are less familiar with math and programming, then perhaps
 there is a future for it.

 Unfortunately, I don't know that just knowing how to program
 functionally is enough. Even the functional folks have a hard time
 optimizing routines (time or memory). Even with DBAs, they have to
 know how the functional SQL query is translated into discrete machine
 instructions.

 As it is now, the vast majority (all?) of the programmers who do any
 programming seriously are familiar with the statement-based approach.
 A minority understand let alone appreciate the functional approach.


Hi Jonathon.  I understand three major programming paradigms--
imperative, OO, and functional.  My first instinct is always
imperative, as I just want the computer to *do* stuff.

I am not an expert in any paradigm and it is possible that I am
overlooking other major paradigms.

My gut instinct is that functional programming works well for lots of
medium sized problems and it is worth learning.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Paul Rubin
Steve Howell showel...@yahoo.com writes:
 My gut instinct is that functional programming works well for lots of
 medium sized problems and it is worth learning.

I think it's worth learning because it will make you a better programmer
even if you never use it for anything beyond academic exercises.  It's
just like playing Bach fugues in some of your practice hours will make
you a better musician even if you are professionally a heavy metal rock
guitarist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Steve Howell
On Feb 22, 9:11 pm, Steve Howell showel...@yahoo.com wrote:
 On Feb 22, 8:35 pm, Jonathan Gardner jgard...@jonathangardner.net
 wrote:



  On Mon, Feb 22, 2010 at 12:31 PM, John Bokma j...@castleamber.com wrote:

   In my class there where basically 2 groups of people: the ones who got
   functional programming and the ones who had a hard time with it. The
   latter group consisted mostly of people who had been programming in
   languages like C and Pascal for years; they had a hard time thinking
   functionally. The former group consisted mostly of people who had little
   or no programming experience, with a few exceptions (including me :-) ).

   So I have the feeling it has more to do with your background then how
   people think / are wired.

  That's encouraging. If functional programming is really more natural
  to those who are less familiar with math and programming, then perhaps
  there is a future for it.

  Unfortunately, I don't know that just knowing how to program
  functionally is enough. Even the functional folks have a hard time
  optimizing routines (time or memory). Even with DBAs, they have to
  know how the functional SQL query is translated into discrete machine
  instructions.

  As it is now, the vast majority (all?) of the programmers who do any
  programming seriously are familiar with the statement-based approach.
  A minority understand let alone appreciate the functional approach.

 Hi Jonathon.  I understand three major programming paradigms--
 imperative, OO, and functional.  My first instinct is always
 imperative, as I just want the computer to *do* stuff.

 I am not an expert in any paradigm and it is possible that I am
 overlooking other major paradigms.

 My gut instinct is that functional programming works well for lots of
 medium sized problems and it is worth learning.

Sorry for misspelling your name, and yes I agree that you always want
some notion of what happens under the covers (in any paradigm).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Steve Howell
On Feb 22, 9:06 pm, Paul Rubin no.em...@nospam.invalid wrote:
 Steve Howell showel...@yahoo.com writes:
  My gut instinct is that functional programming works well for lots of
  medium sized problems and it is worth learning.

 I think it's worth learning because it will make you a better programmer
 even if you never use it for anything beyond academic exercises.  It's
 just like playing Bach fugues in some of your practice hours will make
 you a better musician even if you are professionally a heavy metal rock
 guitarist.

Well said, and your analogy is based in fact--some pretty awesome rock
guitarists have training in classical and jazz.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Alf P. Steinbach

* Paul Rubin:

Steve Howell showel...@yahoo.com writes:

My gut instinct is that functional programming works well for lots of
medium sized problems and it is worth learning.


I think it's worth learning because it will make you a better programmer
even if you never use it for anything beyond academic exercises.  It's
just like playing Bach fugues in some of your practice hours will make
you a better musician even if you are professionally a heavy metal rock
guitarist.


Uhm, Paganini...

As I understand it he invented the destroy your instruments on stage. :-)


Cheers,

- Alf (off-topic)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-21 Thread John Bokma
Jonathan Gardner jgard...@jonathangardner.net writes:

 On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan lie.1...@gmail.com wrote:

 Now, why don't we start a PEP to make python a fully-functional language
 then?

 Because people don't think the same way that programs are written in
 functional languages.

Heh! When I learned Miranda it felt natural to me. Prolog on the other
hand...

In short: I am afraid you're overgeneralizing here; it depends on one's
background. If not, citation needed ;-)

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Jonathan Gardner
On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan lie.1...@gmail.com wrote:

 Now, why don't we start a PEP to make python a fully-functional language
 then?


Because people don't think the same way that programs are written in
functional languages.

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Chris Rebert
On Fri, Feb 19, 2010 at 11:17 PM, sjdevn...@yahoo.com
sjdevn...@yahoo.com wrote:
 On Feb 20, 1:30 am, Lawrence D'Oliveiro l...@geek-
 central.gen.new_zealand wrote:
 If Python doesn’t distinguish between procedures and functions, why should
 it distinguish between statements and expressions?

 Because the latter are different in Python (and in Ruby

I think your Ruby assertion needs fact-checking:

irb(main):001:0 a = 7  # assignments have a value
= 7
irb(main):002:0 puts(b = 42)  # as further proof
42
= nil
irb(main):003:0 b
= 42
irb(main):004:0 c = [6,4,5]
= [6, 4, 5]
irb(main):005:0 if false
irb(main):006:1   c.reverse!
irb(main):007:1 else
irb(main):008:1*   c.sort!
irb(main):009:1 end  # even the if-else control structure has a value
= [4, 5, 6]
irb(main):010:0 begin # same with exception handling
irb(main):011:1*raise a runtime error
irb(main):012:1 rescue RuntimeError
irb(main):013:1   sounds bad
irb(main):014:1 end
= sounds bad
irb(main):015:0 def foo # and same with method bodies
irb(main):016:1   99
irb(main):017:1 end
= nil
irb(main):018:0 foo
= 99

Quoth Wikipedia regarding Ruby (programming language):
For practical purposes there is no distinction between expressions
and statements

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Michael Sparks
On Feb 18, 4:15 pm, Steve Howell showel...@yahoo.com wrote:
...
     def print_numbers()
         [1, 2, 3, 4, 5, 6].map { |n|
             [n * n, n * n * n]
         }.reject { |square, cube|
             square == 25 || cube == 64
         }.map { |square, cube|
             cube
         }.each { |n|
             puts n
         }
     end

This strikes me as a terrible example. For example, this is
significantly clearer:
def print_numbers()
for n in [1,2,3,4,5,6]:
square, cube = n * n, n * n * n
if square != 25 and cube != 64:
print n

I /can/ see arguments for ruby style blocks in python, but not for
this sort of thing, or lisp style quoted expressions[1]. ie I can see
situations where you have more complex code in real life where they
will definitely simplify things.

[1] This is perhaps more appropriate because '(a b c) is equivalent
to (quote a b c), and quote a b c can be viewed as close to
python's expression lambda: a b c

However, I can also see that in simple situations - such as the
example you post - they will have a tendency to make code
significantly less clear/direct.

I suppose, if I have a choice between something (hard being possible 
simple code looking simple) and (hard things being simpler  simple
things looking harder), I'd probably personally choose the former.
This is not because I don't like hard things being simple, but because
I think that simple things are more common and making them look harder
is a mistake.

I'm well aware that's opinion however,

Regards,


Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Steve Howell
On Feb 20, 6:13 am, Michael Sparks spark...@gmail.com wrote:
 On Feb 18, 4:15 pm, Steve Howell showel...@yahoo.com wrote:
 ...

      def print_numbers()
          [1, 2, 3, 4, 5, 6].map { |n|
              [n * n, n * n * n]
          }.reject { |square, cube|
              square == 25 || cube == 64
          }.map { |square, cube|
              cube
          }.each { |n|
              puts n
          }
      end

 This strikes me as a terrible example. For example, this is
 significantly clearer:
     def print_numbers()
         for n in [1,2,3,4,5,6]:
             square, cube = n * n, n * n * n
             if square != 25 and cube != 64:
                 print n

This is not an exact translation.  My example prints the cubes.  It is
my fault for using n as the parameter in the last block.  I would
rename the parameter to cube.


 I /can/ see arguments for ruby style blocks in python, but not for
 this sort of thing, or lisp style quoted expressions[1]. ie I can see
 situations where you have more complex code in real life where they
 will definitely simplify things.

 [1] This is perhaps more appropriate because '(a b c) is equivalent
     to (quote a b c), and quote a b c can be viewed as close to
     python's expression lambda: a b c

 However, I can also see that in simple situations - such as the
 example you post - they will have a tendency to make code
 significantly less clear/direct.

 I suppose, if I have a choice between something (hard being possible 
 simple code looking simple) and (hard things being simpler  simple
 things looking harder), I'd probably personally choose the former.
 This is not because I don't like hard things being simple, but because
 I think that simple things are more common and making them look harder
 is a mistake.



I agree with much of what you are saying.  The example is indeed
terribly contrived.

I'm not sure I agree that there is anything unclear or undirect about
the Ruby, though.  I've been fairly immersed in Ruby code, so maybe
it's been warping my brain, but once you get over the unfamiliarity of
the syntax, you see that there's actually a rhythm to the code.

Setting aside punctuation and parameter lists, the code clearly
expresses the transformations and actions in the natural order that
you'd do them:

   LIST map
  expression
reject
  criteria
map
  expression
each
  statement

In English, for the list elements, map them to tuples of squares and
cubes, reject the oddballs, take the cube, and print it out.

 [1, 2, 3, 4, 5, 6].map { |n|
 [n * n, n * n * n]
 }.reject { |square, cube|
 square == 25 || cube == 64
 }.map { |square, cube|
 cube
 }.each { |cube|
 puts cube
 }

For such a small problem, I agree it's verbose.   But it's also
completely flat--you don't need to use an if statement to express
the concept of rejection.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Anh Hai Trinh
On Feb 19, 1:44 pm, Steve Howell showel...@yahoo.com wrote:

  def coroutine(co):
     def _inner(*args, **kwargs):
         gen = co(*args, **kwargs)
         gen.next()
         return gen
     return _inner

  def squares_and_cubes(lst, target):
     for n in lst:
         target.send((n * n, n * n * n))

  @coroutine
  def reject_bad_values(target):
     while True:
         square, cube = (yield)
         if not (square == 25 or cube == 64):
             target.send((square, cube))

  @coroutine
  def cubes_only(target):
     while True:
         square, cube = (yield)
         target.send(cube)

  @coroutine
  def print_results():
     while True:
         print (yield)

  squares_and_cubes(range(10),
         reject_bad_values(
             cubes_only(
                 print_results()
                 )
             )
         )

 Wow!  It took me a while to get my head around it, but that's pretty
 cool.


This pipeline idea has actually been implemented further, see http://
blog.onideas.ws/stream.py.

  from stream import map, filter, cut
  range(10)  map(lambda x: [x**2, x**3])  filter(lambda t: t[0]!
=25 and t[1]!=64)  cut[1]  list
  [0, 1, 8, 27, 216, 343, 512, 729]


--
aht
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Roald de Vries

This pipeline idea has actually been implemented further, see http://
blog.onideas.ws/stream.py.

from stream import map, filter, cut
range(10)  map(lambda x: [x**2, x**3])  filter(lambda t: t[0]!
=25 and t[1]!=64)  cut[1]  list
[0, 1, 8, 27, 216, 343, 512, 729]


Wow, cool!

Just to show that you can easily add the iterator.map(f).blabla-syntax  
to Python:


from __future__ import print_function

class rubified(list):
map= lambda self, f: rubified(map(f, self))
filter = lambda self, f: rubified(filter(f, self))
reject = lambda self, f: rubified(filter(lambda x: not f(x),  
self))
# each = lambda self, f: rubified(reduce(lambda x, y:  
print(y), self, None))

def each(self, f):
for x in self: f(x)

def __new__(cls, value):
return list.__new__(cls, value)

def print_numbers():
rubified([1, 2, 3, 4, 5, 6]).map(lambda n:
[n * n, n * n * n]).reject(lambda (square, cube):
square == 25 or cube == 64).map(lambda (square, cube):
cube).each(lambda n:
print(n))



--
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Steve Howell
On Feb 19, 7:50 am, Roald de Vries r...@roalddevries.nl wrote:
  This pipeline idea has actually been implemented further, see http://
  blog.onideas.ws/stream.py.

  from stream import map, filter, cut
  range(10)  map(lambda x: [x**2, x**3])  filter(lambda t: t[0]!
  =25 and t[1]!=64)  cut[1]  list
  [0, 1, 8, 27, 216, 343, 512, 729]

 Wow, cool!

 Just to show that you can easily add the iterator.map(f).blabla-syntax  
 to Python:

      from __future__ import print_function

      class rubified(list):
          map    = lambda self, f: rubified(map(f, self))
          filter = lambda self, f: rubified(filter(f, self))
          reject = lambda self, f: rubified(filter(lambda x: not f(x),  
 self))
          # each = lambda self, f: rubified(reduce(lambda x, y:  
 print(y), self, None))
          def each(self, f):
              for x in self: f(x)

          def __new__(cls, value):
              return list.__new__(cls, value)

      def print_numbers():
          rubified([1, 2, 3, 4, 5, 6]).map(lambda n:
              [n * n, n * n * n]).reject(lambda (square, cube):
              square == 25 or cube == 64).map(lambda (square, cube):
              cube).each(lambda n:
              print(n))

Sure, that definitely achieves the overall sequential structure of
operations that I like in Ruby.  A couple other example have been
posted as well now, which also mimic something akin to a Unix
pipeline.

A lot of Ruby that I see gets spelled like this:

   list.select { |arg1, arg2|
  expr
   }.reject { |arg|
  expr
   }.collect { |arg}
  expr
   }

With your class you can translate into Python as follows:

   list.select(lambda arg1, arg2:
  expr
   ).reject(lambda arg:
  expr
   ).collect(lambda arg:
  expr
   )

So for chaining transformations based on filters, the difference
really just comes down to syntax (and how much sugar is built into the
core library).

The extra expressiveness of Ruby comes from the fact that you can add
statements within the block, which I find useful sometimes just for
debugging purposes:

debug = true
data = strange_dataset_from_third_party_code()
data.each { |arg|
if debug and arg  1
puts arg
end
# square the values
arg * arg
}




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Steven D'Aprano
On Fri, 19 Feb 2010 08:32:53 -0800, Steve Howell wrote:

 The extra expressiveness of Ruby comes from the fact that you can add
 statements within the block, which I find useful sometimes just for
 debugging purposes:
 
 debug = true
 data = strange_dataset_from_third_party_code() 
 data.each { |arg|
 if debug and arg  1
 puts arg
 end
 # square the values
 arg * arg
 }

How is that different from this?

debug = true
data = strange_dataset_from_third_party_code() 
for i, arg in enumerate(data):
if debug and arg  1
print arg
# square the values
data[i] = arg * arg


I don't see the extra expressiveness. What I see is that the Ruby snippet 
takes more lines (even excluding the final brace), and makes things 
implicit which in my opinion should be explicit. But since I'm no Ruby 
expert, perhaps I'm misreading it.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Steve Howell
On Feb 19, 9:30 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 On Fri, 19 Feb 2010 08:32:53 -0800, Steve Howell wrote:
  The extra expressiveness of Ruby comes from the fact that you can add
  statements within the block, which I find useful sometimes just for
  debugging purposes:

      debug = true
      data = strange_dataset_from_third_party_code()
      data.each { |arg|
          if debug and arg  1
              puts arg
          end
          # square the values
          arg * arg
      }

 How is that different from this?

 debug = true
 data = strange_dataset_from_third_party_code()
 for i, arg in enumerate(data):
     if debug and arg  1
         print arg
     # square the values
     data[i] = arg * arg

 I don't see the extra expressiveness. What I see is that the Ruby snippet
 takes more lines (even excluding the final brace), and makes things
 implicit which in my opinion should be explicit. But since I'm no Ruby
 expert, perhaps I'm misreading it.


You are reading the example out of context.

Can you re-read the part you snipped?

The small piece of code can obviously be written imperatively, but the
point of the example was not to print a bunch of squares.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Lie Ryan
On 02/19/10 14:57, Steve Howell wrote:
 In a more real world example, the intermediate results would be
 something like this:
 
departments
departments_in_new_york
departments_in_new_york_not_on_bonus_cycle
employees_in_departments_in_new_york_not_on_bonus_cycle
names_of_employee_in_departments_in_new_york_not_on_bonus_cycle
 

I fare better, in less than ten-seconds thinking:

departments
eligible_departments
eligible_departments
eligible_employees
eligible_employee_names

as a bonus, they would be much more resilient when there are change of
eligibility requirements.

Names doesn't have to exactly describe what's in it; in fact, if your
names is way too descriptive, it may take significantly more brain-cycle
to parse. A good name abstracts the objects contained in it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Lawrence D'Oliveiro
In message 87eikjcuzk@benfinney.id.au, Ben Finney wrote:

 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:
 
 In message hlhdsi$2p...@theodyn.ncf.ca, cjw wrote:

  Aren't lambda forms better described as function?

 Is this a function?

 lambda : None

 What about this?

 lambda : sys.stdout.write(hi there!\n)
 
 They are both lambda forms in Python. As a Python expression, they
 evaluate to (they “return”) a function object.

So there is no distinction between functions and procedures, then?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Lawrence D'Oliveiro
In message 84166541-c10a-47b5-ae5b-
b23202624...@q2g2000pre.googlegroups.com, Steve Howell wrote:

 Some people make the definition of function more restrictive--if it
 has side effects, it is not a function.

Does changing the contents of CPU cache count as a side-effect?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Lawrence D'Oliveiro
In message op.u8at0suda8n...@gnudebst, Rhodri James wrote:

 In classic Pascal, a procedure was distinct from a function in that it had
 no return value.  The concept doesn't really apply in Python; there are no
 procedures in that sense, since if a function terminates without supplying
 an explicit return value it returns None.

If Python doesn’t distinguish between procedures and functions, why should 
it distinguish between statements and expressions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Ben Finney
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:

 So there is no distinction between functions and procedures, then?

In Python, no.

-- 
 \ “When we pray to God we must be seeking nothing — nothing.” |
  `\  —Saint Francis of Assisi |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Steve Holden
Ben Finney wrote:
 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:
 
 If Python doesn’t distinguish between procedures and functions, why
 should it distinguish between statements and expressions?
 
 I don't see the connection between those two predicates. Why does the
 former matter when determining the “should” of the latter?
 
Because s similar dichotomy exists between the two pairs.

Procedure = function not returning a value
Statement = expression not returning a value

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread sjdevn...@yahoo.com
On Feb 20, 1:28 am, Lawrence D'Oliveiro l...@geek-
central.gen.new_zealand wrote:
 In message 87eikjcuzk@benfinney.id.au, Ben Finney wrote:



  Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:

  In message hlhdsi$2p...@theodyn.ncf.ca, cjw wrote:

   Aren't lambda forms better described as function?

  Is this a function?

      lambda : None

  What about this?

      lambda : sys.stdout.write(hi there!\n)

  They are both lambda forms in Python. As a Python expression, they
  evaluate to (they “return”) a function object.

 So there is no distinction between functions and procedures, then?

Not in most modern languages, no.  i think the major places they are
differentiated are in functional languages and in pre-1993ish
languages (give or take a few years), neither of which applies to
Python or Ruby.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread sjdevn...@yahoo.com
On Feb 20, 1:30 am, Lawrence D'Oliveiro l...@geek-
central.gen.new_zealand wrote:
 In message op.u8at0suda8n...@gnudebst, Rhodri James wrote:

  In classic Pascal, a procedure was distinct from a function in that it had
  no return value.  The concept doesn't really apply in Python; there are no
  procedures in that sense, since if a function terminates without supplying
  an explicit return value it returns None.

 If Python doesn’t distinguish between procedures and functions, why should
 it distinguish between statements and expressions?

Because the latter are different in Python (and in Ruby, and in most
modern languages), while the former aren't distinguished in Python or
Ruby or most modern languages?  Primarily functional languages are the
main exception, but other than them it's pretty uncommon to find any
modern language that does distinguish procedures and functions, or one
that doesn't distinguished statements and expressions.

You can certainly find exceptions, but distinguishing statements and
expressions is absolutely commonplace in modern languages, and
distinguishing functions and procedures is in the minority.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Lie Ryan
On 02/20/10 17:30, Lawrence D'Oliveiro wrote:
 In message op.u8at0suda8n...@gnudebst, Rhodri James wrote:
 
 In classic Pascal, a procedure was distinct from a function in that it had
 no return value.  The concept doesn't really apply in Python; there are no
 procedures in that sense, since if a function terminates without supplying
 an explicit return value it returns None.
 
 If Python doesn’t distinguish between procedures and functions, why should 
 it distinguish between statements and expressions?

There are non-trivial languages that have been made without procedures
and statements and non-trivial programs written on those languages.
There is technically no need for a lambda that supports statements;
someone could simply write a full-blown Monad framework and all of the
things required for IO Monad and all their syntax sugars up to near a
level of Haskell. Then we can do away with 'def's and all the statements
or make them syntax sugar for the Monads.

Now, why don't we start a PEP to make python a fully-functional language
then?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Lie Ryan
On 02/20/10 18:17, sjdevn...@yahoo.com wrote:
 On Feb 20, 1:30 am, Lawrence D'Oliveiro l...@geek-
 central.gen.new_zealand wrote:
 In message op.u8at0suda8n...@gnudebst, Rhodri James wrote:

 In classic Pascal, a procedure was distinct from a function in that it had
 no return value.  The concept doesn't really apply in Python; there are no
 procedures in that sense, since if a function terminates without supplying
 an explicit return value it returns None.

 If Python doesn’t distinguish between procedures and functions, why should
 it distinguish between statements and expressions?
 
 Because the latter are different in Python (and in Ruby, and in most
 modern languages), while the former aren't distinguished in Python or
 Ruby or most modern languages?  Primarily functional languages are the
 main exception, but other than them it's pretty uncommon to find any
 modern language that does distinguish procedures and functions, or one
 that doesn't distinguished statements and expressions.
 
 You can certainly find exceptions, but distinguishing statements and
 expressions is absolutely commonplace in modern languages, and
 distinguishing functions and procedures is in the minority.

But it all boils down to Although practicality beats purity.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Carl Banks
On Feb 19, 10:30 pm, Lawrence D'Oliveiro l...@geek-
central.gen.new_zealand wrote:
 In message op.u8at0suda8n...@gnudebst, Rhodri James wrote:

  In classic Pascal, a procedure was distinct from a function in that it had
  no return value.  The concept doesn't really apply in Python; there are no
  procedures in that sense, since if a function terminates without supplying
  an explicit return value it returns None.

 If Python doesn’t distinguish between procedures and functions, why should
 it distinguish between statements and expressions?

Because the real world works is more complex than simplified one-
sentence generalizations.


Carl Bnkas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Carl Banks
On Feb 19, 11:12 pm, Steve Holden st...@holdenweb.com wrote:
 Ben Finney wrote:
  Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:

  If Python doesn’t distinguish between procedures and functions, why
  should it distinguish between statements and expressions?

  I don't see the connection between those two predicates. Why does the
  former matter when determining the “should” of the latter?

 Because s similar dichotomy exists between the two pairs.

 Procedure = function not returning a value
 Statement = expression not returning a value

So if your language distinguishes between procedures and functions, it
manifestly has to distinguish between statements and expressions, but
there's no reason that the converse has to be true, expecially if an
expression is a legal statement.


Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Duncan Booth
Jonathan Gardner jgard...@jonathangardner.net wrote:

 On Feb 17, 12:02 am, Lawrence D'Oliveiro l...@geek-
 central.gen.new_zealand wrote:
 In message
 8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com,

 Jonathan Gardner wrote:
  I used to think anonymous functions (AKA blocks, etc...) would be a
  nice feature for Python.

  Then I looked at a stack trace from a different programming
  language with lots of anonymous functions. (I believe it was perl.)

 Didn’t it have source line numbers in it?

 What more do you need?
 
 I don't know, but I tend to find the name of the function I called to
 be useful. It's much more memorable than line numbers, particularly
 when line numbers keep changing.
 
 I doubt it's just me, though.

Some problems with using just line numbers to track errors:

In any language it isn't much use if you get a bug report from a shipped
program that says there was an error on line 793 but no report of
exactly which version of the shipped code was being run. 

Microsoft love telling you the line number: if IE gets a Javascript
error it reports line number but not filename, so you have to guess
which of the HTML page or one of many included files actually had the
error. Plus the line number that is reported is often slightly off. 

Javascript in particular is often sent to the browser compressed then
uncompressed and eval'd. That makes line numbers completely useless for
tracking down bugs as you'll always get the line number of the eval.
Also the way functions are defined in Javascript means you'll often have
almost every function listed in a backtrace as 'Anonymous'. 

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 1:23 am, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Jonathan Gardner jgard...@jonathangardner.net wrote:
  On Feb 17, 12:02 am, Lawrence D'Oliveiro l...@geek-
  central.gen.new_zealand wrote:
  In message
  8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com,

  Jonathan Gardner wrote:
   I used to think anonymous functions (AKA blocks, etc...) would be a
   nice feature for Python.

   Then I looked at a stack trace from a different programming
   language with lots of anonymous functions. (I believe it was perl.)

  Didn’t it have source line numbers in it?

  What more do you need?

  I don't know, but I tend to find the name of the function I called to
  be useful. It's much more memorable than line numbers, particularly
  when line numbers keep changing.

  I doubt it's just me, though.

 Some problems with using just line numbers to track errors:

 In any language it isn't much use if you get a bug report from a shipped
 program that says there was an error on line 793 but no report of
 exactly which version of the shipped code was being run.

 Microsoft love telling you the line number: if IE gets a Javascript
 error it reports line number but not filename, so you have to guess
 which of the HTML page or one of many included files actually had the
 error. Plus the line number that is reported is often slightly off.

 Javascript in particular is often sent to the browser compressed then
 uncompressed and eval'd. That makes line numbers completely useless for
 tracking down bugs as you'll always get the line number of the eval.
 Also the way functions are defined in Javascript means you'll often have
 almost every function listed in a backtrace as 'Anonymous'.

If this is an argument against using anonymous functions, then it is a
quadruple strawman.

Shipping buggy code is a bad idea, even with named functions.

Obscuring line numbers is a bad idea, even with named functions.

Having your customers stay on older versions of your software is a bad
idea, even with named functions.

Not being able to know which version of software you're customer is
running is a bad idea, even with named functions.

Of course, using anonymous functions in no way prevents you from
capturing a version number in a traceback.  And in most modern source
control systems, it is fairly easy to revert to an old version of that
code.

def factory():
return lambda: 15 / 0

def bar(method):
method()

def foo(method):
bar(method)

def baz(method):
foo(method)

try:
baz(factory())
except:
print 'problem with version 1.234a'
raise

problem with version 1.234a
Traceback (most recent call last):
  File foo.py, line 14, in module
baz(factory())
  File foo.py, line 11, in baz
foo(method)
  File foo.py, line 8, in foo
bar(method)
  File foo.py, line 5, in bar
method()
  File foo.py, line 2, in lambda
return lambda: 15 / 0
ZeroDivisionError: integer division or modulo by zero
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Duncan Booth
Steve Howell showel...@yahoo.com wrote:

 If this is an argument against using anonymous functions, then it is a
 quadruple strawman.
 
 Shipping buggy code is a bad idea, even with named functions.

I doubt very much whether I have ever shipped any bug-free code but
even if it was fit for purpose when shipped it is quite possible that the 
software will interact badly with other software that did not exist at the 
time of shipping.

 
 Obscuring line numbers is a bad idea, even with named functions.

In principle I agree, but where Javascript is concerned compressing the 
downloaded files is generally a pretty good idea and practicality beats 
purity.

 
 Having your customers stay on older versions of your software is a bad
 idea, even with named functions.

I think that's their decision, not mine.

 
 Not being able to know which version of software you're customer is
 running is a bad idea, even with named functions.
 
I agree, but getting a complete coherent description out of a customer is 
not always an easy task. (I'm reading the word 'customer' here to include 
the case where there is no monetary relationship between the software 
author and the entity using it, but even when there is I think this still 
true.)


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 06:15:20 -0800, Steve Howell wrote:

 On Feb 18, 1:23 am, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Jonathan Gardner jgard...@jonathangardner.net wrote:
  On Feb 17, 12:02 am, Lawrence D'Oliveiro l...@geek-
  central.gen.new_zealand wrote:
  In message
  8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com,

  Jonathan Gardner wrote:
   I used to think anonymous functions (AKA blocks, etc...) would be
   a nice feature for Python.

   Then I looked at a stack trace from a different programming
   language with lots of anonymous functions. (I believe it was
   perl.)

  Didn’t it have source line numbers in it?

  What more do you need?

  I don't know, but I tend to find the name of the function I called to
  be useful. It's much more memorable than line numbers, particularly
  when line numbers keep changing.

  I doubt it's just me, though.

 Some problems with using just line numbers to track errors:

 In any language it isn't much use if you get a bug report from a
 shipped program that says there was an error on line 793 but no report
 of exactly which version of the shipped code was being run.

 Microsoft love telling you the line number: if IE gets a Javascript
 error it reports line number but not filename, so you have to guess
 which of the HTML page or one of many included files actually had the
 error. Plus the line number that is reported is often slightly off.

 Javascript in particular is often sent to the browser compressed then
 uncompressed and eval'd. That makes line numbers completely useless for
 tracking down bugs as you'll always get the line number of the eval.
 Also the way functions are defined in Javascript means you'll often
 have almost every function listed in a backtrace as 'Anonymous'.
 
 If this is an argument against using anonymous functions, then it is a
 quadruple strawman.

There really ought to be a special level of Hell for people who misuse 
strawman to mean a weak or invalid argument instead of what it 
actually means, which is a weak or invalid argument NOT HELD by your 
opponent, which you (generic you) made up specifically for the sake of 
shooting down.

If you actually read what Duncan says, he prefixes his response with:

Some problems with using just line numbers to track errors.

Duncan's post is an argument against relying on line numbers as your 
main, or only, source of information about the location of bugs in 
Javascript.

In fact, this post is remarkable for the sheer number of actual strawman 
arguments that you (Steve Howell) use:


 Shipping buggy code is a bad idea, even with named functions.

Strawman #1: nobody said that shipping buggy code was a good idea, with 
or without named functions. But shipping buggy code *happens*, no matter 
how careful you are, so you need to expect bug reports back from users.

(And they will be *hard to find* bugs, because if they were easy to find 
you would have found them in your own testing before shipping.)


 Obscuring line numbers is a bad idea, even with named functions.

Strawman #2: nobody said that obscuring line numbers was a good idea. But 
apparently compressing Javascript is valuable for other reasons, and 
obscuring the line numbers is the side-effect of doing so. 

And even knowing the line numbers is not necessarily useful, because many 
bugs aren't due to the line that raises the stack trace. Just because you 
know the line which failed doesn't mean you know how to fix the bug.


 Having your customers stay on older versions of your software is a bad
 idea, even with named functions.

Strawman #3: nobody said that staying on older versions is a good idea. 
But sometimes it happens whether you like it or not.

(Although I'd like to point out that from the end user's perspective, 
sometimes we don't want your stinkin' new version with all the anti-
features and pessimations and will stick to the old version for as long 
as possible. If you don't like it, then think a bit harder before adding 
anti-features like fragile, easily-corrupted databases which perform 
really, really badly when your home directory is mounted over the 
network. I'm talking to you, Firefox developers.)

And it doesn't really matter: you either end-of-life the old version, in 
which case you don't need to do anything about the bug report except say 
upgrade, or you decide to continue support, in which case it doesn't 
matter whether the bug is reported for an old version or the latest 
version, you still need to fix it.


 Not being able to know which version of software you're customer is
 running is a bad idea, even with named functions.

Strawman #4. 

See the pattern? When you attack a position the other guy hasn't taken, 
that's a strawman. When you make a weak argument, it's just a weak 
argument.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Jonathan Gardner
On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:

     def print_numbers()
         [1, 2, 3, 4, 5, 6].map { |n|
             [n * n, n * n * n]
         }.reject { |square, cube|
             square == 25 || cube == 64
         }.map { |square, cube|
             cube
         }.each { |n|
             puts n
         }
     end


If this style of programming were useful, we would all be writing Lisp
today. As it turned out, Lisp is incredibly difficult to read and
understand, even for experienced Lispers. I am pleased that Python is
not following Lisp in that regard.

for n in range(1,6):
square = n*n
cube = n*n*n
if square == 25 or cube == 64: continue
print cube
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 08:15:46 -0800, Steve Howell wrote:

 Just to be clear, I'm not saying it's unforgivable to occasionally ship
 software with bugs.  It happens.

Occasionally? Oh, if only.

I would say that there probably isn't a non-trivial application in the 
world that is entirely bug-free. If you're shipping something more 
complex than the proverbial Hello World, chances are high that there 
will be bugs, and the more complex the app, the more bugs are likely.


 Compressing Javascript is sometimes necessary, but I believe that often
 mangles named functions too.

It doesn't mangle the function, it mangles reporting of line numbers. But 
if you know the name of the function, it is much easier to recover from 
that loss of information.

 
 To the the extent that your customer is running old software and cannot
 always coherently describe tracebacks over a telephone, that problem can
 be solved in the software itself, assuming an Internet connection.  The
 software can capture the traceback and report back to a server with the
 version number.

I don't understand why you repeatedly mention old software. It is 
irrelevant: the software is either supported, or not supported. If it's 
not supported, you don't care about the bugs. If it is supported, then it 
doesn't matter whether it is version 2.2 or 2.3 or the bleeding edge 2.4-
pre-alpha straight out of subversion, you still have to go through the 
same process of finding the bug, solving it, then rolling the fix out to 
all supported versions where the bug applies.

That's not to say that the version number isn't useful information to 
have, because it can be, but distinguishing between old versions and the 
current version isn't a useful distinction. In a sense, there are no old 
versions, there are merely multiple supported current versions.

 So, much of the argument against anonymous functions presented so far is
 really orthogonal to whether functions are named or not.

Not so. The point is that anonymous functions lack useful information, 
namely the function name. Because line numbers can be unreliable or even 
missing completely, and even when reliable many people have a mental 
blind-spot for them (I know I do, and I'm gratified to see I'm not the 
only one), lacking a good name for the function is a handicap. Not 
necessarily an insurmountable one, but anonymous functions are more 
troublesome than named functions.

You wouldn't name your functions:

f01, f02, f03, f04, ... f99

(say), unless you were trying to deliberately obfuscate your code. 
Anonymous functions are even more obfuscated than that. You can get away 
with it so long as you're only dealing with a few, in well-defined 
placed, but you wouldn't want to use them all over the place.

-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread sjdevn...@yahoo.com
On Feb 18, 11:15 am, Steve Howell showel...@yahoo.com wrote:
     def print_numbers()
         [1, 2, 3, 4, 5, 6].map { |n|
             [n * n, n * n * n]
         }.reject { |square, cube|
             square == 25 || cube == 64
         }.map { |square, cube|
             cube
         }.each { |n|
             puts n
         }
     end

 IMHO there is no reason that I should have to name the content of each
 of those four blocks of code, nor should I have to introduce the
 lambda keyword.

You could do it without intermediate names or lambdas in Python as:
def print_numbers():
for i in [ cube for (square, cube) in
 [(n*n, n*n*n) for n in [1,2,3,4,5,6]]
   if square!=25 and cube!=64 ]:
print i

But frankly, although there's no reason that you _have_ to name the
content at each step, I find it a lot more readable if you do:

def print_numbers():
tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)]
filtered = [ cube for (square, cube) in tuples if square!=25 and
cube!=64 ]
for f in filtered:
print f
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread John Bokma
Jonathan Gardner jgard...@jonathangardner.net writes:

 On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:

     def print_numbers()
         [1, 2, 3, 4, 5, 6].map { |n|
             [n * n, n * n * n]
         }.reject { |square, cube|
             square == 25 || cube == 64
         }.map { |square, cube|
             cube
         }.each { |n|
             puts n
         }
     end


 If this style of programming were useful, we would all be writing Lisp
 today. As it turned out, Lisp is incredibly difficult to read and
 understand, even for experienced Lispers. I am pleased that Python is
 not following Lisp in that regard.

 for n in range(1,6):

   ^ should be 7

But for the rest, I agree with you. I can read Steve's version, but even
to an experienced Perl programmer that looks quite noisy :-)

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread John Bokma
John Bokma j...@castleamber.com writes:

 Jonathan Gardner jgard...@jonathangardner.net writes:

 On Feb 18, 8:15 am, Steve Howell showel...@yahoo.com wrote:

     def print_numbers()
         [1, 2, 3, 4, 5, 6].map { |n|
             [n * n, n * n * n]
         }.reject { |square, cube|
             square == 25 || cube == 64
         }.map { |square, cube|
             cube
         }.each { |n|
             puts n
         }
     end


 If this style of programming were useful, we would all be writing Lisp
 today. As it turned out, Lisp is incredibly difficult to read and
 understand, even for experienced Lispers. I am pleased that Python is
 not following Lisp in that regard.

 for n in range(1,6):

^ should be 7

 But for the rest, I agree with you. I can read Steve's version, but even
 to an experienced Perl programmer that looks quite noisy :-)

Oh, wait, it's Ruby :-D.

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Jonathan Gardner
On Feb 18, 3:04 pm, sjdevn...@yahoo.com sjdevn...@yahoo.com wrote:

 You could do it without intermediate names or lambdas in Python as:
 def print_numbers():
     for i in [ cube for (square, cube) in
                          [(n*n, n*n*n) for n in [1,2,3,4,5,6]]
                if square!=25 and cube!=64 ]:
         print i

 But frankly, although there's no reason that you _have_ to name the
 content at each step, I find it a lot more readable if you do:

 def print_numbers():
     tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)]
     filtered = [ cube for (square, cube) in tuples if square!=25 and
 cube!=64 ]
     for f in filtered:
         print f

Step away from the keyboard! This is a programmer's arrest!

There are laws around here, laws that we can't allow to be broken.
You've just broken 12 of them. You think the laws don't apply to you,
huh, punk? HUH?

I'm sentencing you to three months HARD LABOR in Ruby for that code
you just wrote. And if you think it's too harsh, then I'll sentence
you to NINE MONTHS PHP and see how you feel about that!

;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >