[Python-Dev] class Foo(object) vs class Foo: should be clearly explained in python 2 and 3 doc

2014-08-09 Thread John Yeuk Hon Wong

Hi.

Referring to my discussion on [1] and then on #python this afternoon.

A little background would help people to understand where this was 
coming from.


1. I write Python 2 code and have done zero Python-3 specific code.
2. I have always been using class Foo(object) so I do not know the new 
style is no longer required in Python 3. I feel "stupid" and "wrong" by 
thinking (object) is still a convention in Python 3.
3. Many Python 2 tutorials do not use object as the base class whether 
for historical reason, or lack of information/education, and can cause 
confusing to newcomers searching for answers when they consult the 
official documentation.


While Python 3 code no longer requires object be the base class for the 
new-style class definition, I believe (object) is still required if one 
has to write a 2-3 compatible code. But this was not explained or warned 
anywhere in Python 2 and Python 3 code, AFAIK. (if I am wrong, please 
correct me)


I propose the followings:

* It is desirable to state boldly to users that (object) is no longer 
needed in Python-3 **only** code and warn users to revert to (object) 
style if the code needs to be 2 and 3 compatible.


* In addition, Python 2 doc [2] should be fixed by introducing the 
new-style classes. This problem was noted a long long time ago according 
to [4].


* I would like to see warnings from suggested action item 1 on [2] and 
[3], for python 2 and 3 documentations.


Possible objections(s):

* We are pushing toward Python 3, some years later we don't need to 
maintain both Python 2 and 3 code. And many people, especially the 
newcomers will probably have no need to maintain Python 2 and 3 
compatible codes.


My answer to that is we need to be careful with marketing. First, it is 
a little embarrassing to assume and to find out the assumption is not 
entirely accurate. Secondly, Python 2 will not go away any time soon and 
most tutorials available on the Internet today are still written for 
Python 2. Furthermore, this CAN be a "gotcha" for new developers knowing 
only Python 3 writing Python 2 & 3 compatible code.


* Books can do a better job

I haven't actually reviewed/read any Python 3 books knowing most of my 
code should work without bothering Python 3-2 incompatibility yet.
So I don't have an accurate answer, but a very very quick glance over a 
popular Python 3 book (I am not sure if naming it out is ethical or not 
so I am going to grey it out here) the book just writes class Foo: and 
doesn't note the different between 2 and 3 with classes. It is not wrong 
since the book is about programming in Python 3, NOT writing 2 and 3, 
but this is where the communication breaks. Docs and books don't give 
all the answers needed.



P.S. Sorry if I should've have asked on #python-dev first or made a 
ticket but I've decided to send to mailing list before making a bug ticket.

First time!

Thanks.

Best,
Yeuk Hon

[1]: https://news.ycombinator.com/item?id=8154471

[2]: https://docs.python.org/2/tutorial/classes.html
https://docs.python.org/3/tutorial/classes.html

[3]: https://docs.python.org/3/tutorial/classes.html

[4]: https://www.python.org/doc/newstyle/
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 2.x vs 3.x survey results

2014-01-04 Thread John Yeuk Hon Wong

On 1/4/14 10:42 PM, Ben Finney wrote:

Luca Sbardella  writes:


you are my heroes but this survey is quite useless, can you include more
people?

The survey cohort was self-selected from those who read the forums where
it was posted.


I wasn't aware of it so many thousands of python users.

That statement confuses me. Were you aware of it, or not? How did you
become aware of it?


And after that, you are well aware that Python 3 or 2 is becoming a
liability, just stick with one, anyone (3) at this point.

The policy of the Python core developers is quite clear, and has been
for many years: Python 2 is a dead end, and Python 2.7 (released
2010-07-03, 3½ years ago) is the last Python 2.

Python 2.7 is the last of the Python 2 line, there will never be new
Python 2 features http://python.org/dev/peps/pep-0404/>, everyone
should migrate to Python 3.

That is already the Python core developers's published policy. So, to
whom are you speaking here on the Python core developers' forum?


I don't want to go and learn a new language, please.

Great! If you already know Python, then there is very little (certainly
not “a new language”) different to move from Python 2.7 to Python 3.

Enjoy!

I think it helps Luca and many others (including myself) if there is a 
reference of the difference between 2.7 and Python 3.3+.

There are PEPs and books, but is there any such long list of references?

If not, should we start investing in one? I know the basic one such as 
xrange and range, items vs iteritems, izip vs zip that sort of uniform 
syntax/library inclusion difference.


If there is such reference available?
Yeuk Hon
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Enable Hostname and Certificate Chain Validation

2014-01-22 Thread John Yeuk Hon Wong

On 1/22/14 8:16 AM, Nick Coghlan wrote:
Which is exactly the way most non-web-specialists working inside the 
comfort of corporate and academic firewalls will react to a change 
that breaks their access to internal applications, where self-signed 
certs and improperly configured internal CAs are endemic (of course, 
that's assuming they're using HTTPS at all, which I admit is an 
optimistic assumption).
The number of people who are using 3.4+ in these environments is 
probably very very low to be honest. I don't have a number to prove, but 
in that environment people are more likely to still be using 2.6+. I 
think a deprecation in 2.7+ would be nice, but forward we should just 
enable it by default.


When requests changed property calls (e.g. requests.json) to callable 
instead of an attribute(from requests.json to requests.json()), I was 
shocked. I had to figure out by Googling it. I found out from github 
issue


I think a hard fail is somehow necessary.

Also, a lot of people overlook at deprecation warnings. They either 
don't care or don't see it. I see a lot of deprecation warnings in the 
older applications I write, but I can careless until it breaks. So as we 
moving forward, we can break it. For those stuck behind, deprecation is 
the right approach.


John
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com