Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Why has python3 been created as a seperate language where thereis still python2.7 ? (http://www.velocityreviews.com/forums/t947494-re-why-has-python3-been-created-as-a-seperate-language-where-thereis-still-python2-7-a.html)

Michiel Overtoom 06-25-2012 10:10 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 

On Jun 24, 2012, at 05:46, gmspro wrote:

> Why has python3 been created as a seperate language where there is still python2.7?


It has not. Python2 and Python3 are very similar. It's not like if you learn Python using version 2, you have to relearn the language when you want to switch Python3. The syntax is the same, only 'print' is a function instead of a statement. Other improvements are unicode strings, cleanups in the library, lazy iterators, new-style classes by default etc... mostly background stuff you won't even notice in daily Python use.

Greetings,

--
Test your knowledge of flowers! http://www.learn-the-flowers.com
or http://www.leer-de-bloemen.nl for the Dutch version.

Test je kennis van bloemen! http://www.leer-de-bloemen.nl
of http://www.learn-the-flowers.com voor de Engelse versie.





rantingrickjohnson@gmail.com 06-26-2012 02:28 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
On Monday, June 25, 2012 5:10:47 AM UTC-5, Michiel Overtoom wrote:
> It has not. Python2 and Python3 are very similar. It's not like if
> you learn Python using version 2, you have to relearn the language
> when you want to switch Python3. The syntax is the same, only
> 'print' is a function instead of a statement.


However, there is something to be said for "old habits die hard". I myself lament every time i must type->(, then blah, then->) AGAIN!. My fingers are hardwired for the old print statement. Damned that Guido and his mind games!

http://www.youtube.com/watch?v=-Ny42Mdg5qo

rantingrickjohnson@gmail.com 06-26-2012 02:28 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
On Monday, June 25, 2012 5:10:47 AM UTC-5, Michiel Overtoom wrote:
> It has not. Python2 and Python3 are very similar. It's not like if
> you learn Python using version 2, you have to relearn the language
> when you want to switch Python3. The syntax is the same, only
> 'print' is a function instead of a statement.


However, there is something to be said for "old habits die hard". I myself lament every time i must type->(, then blah, then->) AGAIN!. My fingers are hardwired for the old print statement. Damned that Guido and his mind games!

http://www.youtube.com/watch?v=-Ny42Mdg5qo

Steven D'Aprano 06-26-2012 03:35 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
(Rick, don't make me regret communicating with you again.)

On Mon, 25 Jun 2012 19:28:01 -0700, rantingrickjohnson wrote:

> However, there is something to be said for "old habits die hard". I
> myself lament every time i must type->(, then blah, then->) AGAIN!. My
> fingers are hardwired for the old print statement. Damned that Guido and
> his mind games!


There's no real difference between typing print(...) and all the other
functions in Python. Do you lament having to type len(obj) instead of
"len obj" or list(zip(a, b, c)) instead of "list zip a b c"?

Making print a statement in the first place was a mistake, but
fortunately it was a simple enough mistake to rectify once the need for
backward compatibility was relaxed.


--
Steven

Terry Reedy 06-26-2012 04:33 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
On 6/25/2012 11:35 PM, Steven D'Aprano wrote:
> (Rick, don't make me regret communicating with you again.)
>
> On Mon, 25 Jun 2012 19:28:01 -0700, rantingrickjohnson wrote:
>
>> However, there is something to be said for "old habits die hard". I
>> myself lament every time i must type->(, then blah, then->) AGAIN!. My
>> fingers are hardwired for the old print statement. Damned that Guido and
>> his mind games!

>
> There's no real difference between typing print(...) and all the other
> functions in Python.


Yes there is ... as Rick said, habit. I still sometimes forget ;-(

> Do you lament having to type len(obj) instead of
> "len obj" or list(zip(a, b, c)) instead of "list zip a b c"?


No.

> Making print a statement in the first place was a mistake, but
> fortunately it was a simple enough mistake to rectify once the need for
> backward compatibility was relaxed.


Complete agreed. I have used all of sep=, end=, and file= at various times.

--
Terry Jan Reedy




Jeremiah Dodds 06-26-2012 05:04 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
rantingrickjohnson@gmail.com writes:

> On Monday, June 25, 2012 5:10:47 AM UTC-5, Michiel Overtoom wrote:
>> It has not. Python2 and Python3 are very similar. It's not like if
>> you learn Python using version 2, you have to relearn the language
>> when you want to switch Python3. The syntax is the same, only
>> 'print' is a function instead of a statement.

>
> However, there is something to be said for "old habits die hard". I myself
> lament every time i must type->(, then blah, then->) AGAIN!. My fingers are
> hardwired for the old print statement. Damned that Guido and his mind games!
>
> http://www.youtube.com/watch?v=-Ny42Mdg5qo


I'm of the opinion that the solution to this involves configuring your editor.

Devin Jeanpierre 06-26-2012 06:15 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
On Mon, Jun 25, 2012 at 11:35 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> There's no real difference between typing print(...) and all the other
> functions in Python. Do you lament having to type len(obj) instead of
> "len obj" or list(zip(a, b, c)) instead of "list zip a b c"?


Surely you mean "list $ zip a b c"? ;)

But yes, it's really not a big deal. It's a trivial change, and one
that 2to3 can handle really easily.

>
> Making print a statement in the first place was a mistake, but
> fortunately it was a simple enough mistake to rectify once the need for
> backward compatibility was relaxed.


Hmmm, why is the function so much better than the statement? You like
using it in expressions? Or is it that you like passing it in as a
callback?

-- Devin

Stefan Behnel 06-26-2012 06:24 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
Jeremiah Dodds, 26.06.2012 07:04:
> rantingrickjohnson@gmail.com writes:
>
>> On Monday, June 25, 2012 5:10:47 AM UTC-5, Michiel Overtoom wrote:
>>> It has not. Python2 and Python3 are very similar. It's not like if
>>> you learn Python using version 2, you have to relearn the language
>>> when you want to switch Python3. The syntax is the same, only
>>> 'print' is a function instead of a statement.

>>
>> However, there is something to be said for "old habits die hard". I myself
>> lament every time i must type->(, then blah, then->) AGAIN!. My fingers are
>> hardwired for the old print statement. Damned that Guido and his mind games!
>>
>> http://www.youtube.com/watch?v=-Ny42Mdg5qo

>
> I'm of the opinion that the solution to this involves configuring your editor.


But wasn't the whole idea behind Python to be accessible for innocent
users? Isn't the one and only acceptable goal of a language cleanup that
those who do not have the expert knowledge to configure the editor of their
choice should finally be able to wholeheartedly type down their Pythonish
code without having the parser allude them to the one holy way from time to
time? It clearly cannot have achieved that goal, given the amount of
traffic on this list, can it?

Maybe we should add a remote error reporting mode to Python that sends all
syntax error messages not only to the local screen but also directly to the
PSF so that they can fund developers who are able to delete that error
message from the interpreter based on real world statistical evidence. That
would eventually make the language match the powerset of what all users
have in their fingers. A very worthy goal, if you ask me.

Stefan


Stefan Behnel 06-26-2012 06:34 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
Devin Jeanpierre, 26.06.2012 08:15:
> On Mon, Jun 25, 2012 at 11:35 PM, Steven D'Aprano
>> Making print a statement in the first place was a mistake, but
>> fortunately it was a simple enough mistake to rectify once the need for
>> backward compatibility was relaxed.

>
> Hmmm, why is the function so much better than the statement? You like
> using it in expressions? Or is it that you like passing it in as a
> callback?


First of all, the statement has a rather special syntax that is not obvious
and practically non-extensible. It also has hidden semantics that are hard
to explain and mixes formatting with output - soft-space, anyone?

The function is straight forward, configurable, does one thing, works with
help() and doesn't get in the way. And something as rarely[1] used as a
print simply doesn't deserve special syntax. Oh, and, yes, you can even
pass it into some code as callback, although I rarely had a need for that.

Stefan


[1] Seriously, it's not very helpful in interactive mode and too simplistic
to be used in application code. Even scripts often work better with logging
than with prints.


Steven D'Aprano 06-26-2012 07:40 AM

Re: Why has python3 been created as a seperate language where thereis still python2.7 ?
 
On Tue, 26 Jun 2012 02:15:17 -0400, Devin Jeanpierre wrote:

>> Making print a statement in the first place was a mistake, but
>> fortunately it was a simple enough mistake to rectify once the need for
>> backward compatibility was relaxed.

>
> Hmmm, why is the function so much better than the statement? You like
> using it in expressions? Or is it that you like passing it in as a
> callback?


Simplicity: there doesn't seem to be anything special about print that
requires it to be syntax instead of just a built-in function. Nearly
everything else which is handled by syntax is special: assignment,
deletion, imports, flow control. (Decorators are the obvious exception,
but they are pure syntactic sugar.)

Consistency: print as a function isn't a special case to be learned.
There's no need to memorise magic syntax to control it, you just pass
ordinary arguments using ordinary syntax. Instead of arcane and bizarre
special cases like this:

print >>sys.stderr, spam, ham, eggs,

you just use:

print(spam, ham, eggs, file=sys.stderr, end='')

While it's a tad longer, there's no special syntax to be learned.

Practicality: as a function, you can use print anywhere you can use other
functions. You can bind it to another name, pass it as argument to
another function such as help(), store it in a list, use it as a
callback, or monkey-patch it, without needing to write a wrapper
"print_" (or "prnt", "pr", etc.) around it.


Compare that to print as a statement, which only has one argument in
favour: backwards compatibility.



--
Steven


All times are GMT. The time now is 11:06 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.