Rosetta Code on Python.org site?

Just saw what the Perl 6 site does to punt the curious to their entries on the Rosetta Code site here: http://perl6.org/community/rosettacode and I thought maybe we could do something similar on Python.org? I know that the core development team of Perl 6 have put a lot of effort into their RC entries, and over the years I have seen evidence of tasks being used to highlight areas for subsequent improvement in Perl 6. I don't *recognise *such a contribution from core development Pythoneers on RC but members of the Python community have made great efforts in making Python solutions available for most tasks on RC in a mixture of Python 2 and 3 and also showing greater use of our interactive command line interface/REPL for solutions which other languages may have, but rarely show unless the task asks specifically for an answer using a REPL. *In short:* Python on RC <http://rosettacode.org/wiki/Category:Python> has good code examples - why not advertise that fact on Python.org in a similar way to the Perl 6 site? *Disclosure: *I should add that I am an administrator, task writer and one of the Python code contributors to the Rosetta Code site.

On 10/7/2015 2:31 AM, Paddy3118 wrote:
Just saw what the Perl 6 site does to punt the curious to their entries on the Rosetta Code site here: http://perl6.org/community/rosettacode
Perl6 is apparently different from Perl 5 and before to justify adding Perl 6 sections after the Perl sections, with Perl entries re-written. Given the slow development and use of Perl 6, I can understand the Perl 6 people wanting to promote Perl 6 that way. Python 3 is not quite in the same position.
and I thought maybe we could do something similar on Python.org <http://Python.org>?
python-ideas is about future version of the language. The pydotorg list discusses the site https://mail.python.org/mailman/listinfo/pydotorg This would be the place to suggest an addition under 'Community'. But if modern Python 3 code is not welcome on the site (see below), I would not want it promoted as containing examples of 'Python' code.
The page you reference seems a bit hostile to Python 3. It equates 'Python' with 'Python 2' and calls code that also works with Python 3 'unidiomatic Python', and makes no mention of the possibility of submitting Python 3.
and also showing greater use of our interactive command line interface/REPL for solutions which other languages may have,
Since one cannot do anything in the REPL that one cannot do in a file, except leave out 'print', I do not see the point. Leaving '>>>' and '...' in examples only makes it hard to copy and paste.
Reading this page, I am not sure how welcome I would be if I came and tried to contribute. Aside from that, I do not see any obvious way to get of list of tasks without a Python solution, or is that an empty set?
has good code examples - why not advertise that fact on Python.org in a similar way to the Perl 6 site?
Because I do not consider code with 'print x' instead of 'print(x)'. especially when that is the only thing keeping the code from also running on Python 3, to be a 'good code example'. Ditto for 2.x-only code (or 3.x-only code, for that matter) that is not labelled as such. On Python list and elsewhere, newbies frequently post 'I copied this code form ... and it does not run.' because they are running it on the wrong interpreter.
*Disclosure: *I should add that I am an administrator, task writer and one of the Python code contributors to the Rosetta Code site.
Please consider making it more Python 3 friendly than it strikes me as being. Or if my impression is wrong, edit the Python page to at least treat Python 3 on an equal footing. Out of curiosity, and to make a point: Does the current tasks include any that test the quality and completeness of unicode implementation? Something simple like the following, involving astral chars. "Construct a string consisting of the unicode characters U+33, U+333, U+11111, U+334, U+11112, U+11113. U+34. Print the decimal codepoint of the third character before the first occurrence of U+11113. (Answer: 69905.) The code should work on any platform the code could run on." 3.x code: s = "\u0033\u0333\U00011111\u0334\U00011112\U00011113" print(ord(s[s.index('\U00011113')-3])) 2.x code: several lines more to accommodate Windows and narrow unicode builds on some linuxes. -- Terry Jan Reedy

On Oct 14, 2015, at 18:03, Terry Reedy <tjreedy@udel.edu> wrote:
The page you reference seems a bit hostile to Python 3. It equates 'Python' with 'Python 2' and calls code that also works with Python 3 'unidiomatic Python', and makes no mention of the possibility of submitting Python 3.
It also seems to imply that widespread use of reduce is pythonic, apologizing for the unpythonic need to check for and import it in case of Python 3, which makes me wonder how pythonic the code is even for a decade ago…

FWIW, that comment is from five years ago and was written by someone who claims to have been using Python far longer than that (and has enough contributions for that to be believable). It reads more to me like a preemptive apology to "The Haters" than a dismissal of Python 3. I'm sure any contributor to the site can easily reword it to better reflect that not all examples are as terse as they could be if they avoided the 2/3 straddle. Cheers, Steve Top-posted from my Windows Phone -----Original Message----- From: "Andrew Barnert via Python-ideas" <python-ideas@python.org> Sent: 10/14/2015 19:03 To: "Terry Reedy" <tjreedy@udel.edu> Cc: "python-ideas@python.org" <python-ideas@python.org> Subject: Re: [Python-ideas] Rosetta Code on Python.org site? On Oct 14, 2015, at 18:03, Terry Reedy <tjreedy@udel.edu> wrote:
The page you reference seems a bit hostile to Python 3. It equates 'Python' with 'Python 2' and calls code that also works with Python 3 'unidiomatic Python', and makes no mention of the possibility of submitting Python 3.
It also seems to imply that widespread use of reduce is pythonic, apologizing for the unpythonic need to check for and import it in case of Python 3, which makes me wonder how pythonic the code is even for a decade ago… _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

At risk of completely going off topic from the mission of Python-Ideas, I'd almost rather see a delineation between Python 2 and Python 3, like RC has done with Perl 5 (http://rosettacode.org/wiki/Category:Perl) and Perl 6 (http://rosettacode.org/wiki/Category:Perl_6). From RC:
And from https://wiki.python.org/moin/Python2orPython3
While there are many ways to make 'good' code, compatible with both Python 2 and 3, I think that the most terse, efficient code would be better demonstrated by segregating Python 2.x from Python 3.x. On 10/15/2015 6:19 AM, Steve Dower wrote:
--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

On Thu, Oct 15, 2015 at 10:37 AM, Jason Schwerberg <jason@schwerberg.com> wrote:
At risk of completely going off topic from the mission of Python-Ideas, I'd almost rather see a delineation between Python 2 and Python 3
makes sense to me. RC is a wiki, yes? So it looks like this: http://rosettacode.org/wiki/Rosetta_Code:Add_a_Language Is what you need to do... Or would there really be strong objections from the community to having a Python3 section on the site? -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov

On Thu, Oct 15, 2015 at 02:14:16PM -0700, Chris Barker wrote:
I would object to adding Python 3 as a different language. It is not, and we should be emphasising the similarities, not the differences. Migration to Python 3 is slow enough without giving more ammunition ("it's a completely different language, like Perl 6 is to Perl 5") to the foot-draggers and haters. Adding Python 3 as a different language would be a strategic error, because most code snippets will be identical except for possibly print and (raw_)input. That's going to discourage people from adding a Python 3 version that is all but identical to the Python 2 version, which will increase the perception that nobody is using Python 3. ("There are hundreds of Python 2 examples, and only a dozen Python 3 examples.") In my opinion, as far as Rosetta Code and similar sites go, all it takes to manage the Python 2/3 transition is a single comment at the start of the code snippet listing the version(s) targeted. I would consider that the minimum needed. Actually providing hybrid 2+3 code, or side-by-side versions, would be acceptible too, but that's more work. I just looked at a small sample of arbitrary examples, and found that three out of the four already support Python 3, and the one that didn't just needed parens added to print to work. So I don't think there's actually a problem here that needs fixing. -- Steven

On 10/15/2015 8:02 PM, Steven D'Aprano wrote:
Yes, Python 3 *is* Python. Python has always been dynamic in its definition, as well as its execution. 'Python 2' is a sequence of older, frozen dialects. Note that 2.7 code may not run in older versions. And that 2.0 code, for instance, may not work in some 2.x and after. Python 2 sections could be added for 2.x-only code, but for most of the tasks, solutions that run on 3.x and some subset of 2.x are easily possible. When not, the format allow multiple solutions within a language section. For example, FizzBuzz/Python has a both 'print 100 lines' for-loop solution and and infinite itertools-based iterator solution.
This is why I said the Perl6/5- was not the example to follow.
Except for version labeling and blessing rather than dissing 3.x or 2&3 solutions. -- Terry Jan Reedy

On Wed, Oct 7, 2015 at 2:31 AM, Paddy3118 <paddy3118@gmail.com> wrote:
Problem with rosettacode is they can end up like stackoverflow answers that some are good and some are bad. Some will view that as Bible and some will constantly make "suggestions" why X is better. But in the spirit of playground and show case, why not make this a personal project and have people commit to a public repo such as GitHub? Everyone will come up with a different solution. Take BFS and DFS as examples, there are at least two kinds of popular ways to implement that in Python.

On 10/7/2015 2:31 AM, Paddy3118 wrote:
Just saw what the Perl 6 site does to punt the curious to their entries on the Rosetta Code site here: http://perl6.org/community/rosettacode
Perl6 is apparently different from Perl 5 and before to justify adding Perl 6 sections after the Perl sections, with Perl entries re-written. Given the slow development and use of Perl 6, I can understand the Perl 6 people wanting to promote Perl 6 that way. Python 3 is not quite in the same position.
and I thought maybe we could do something similar on Python.org <http://Python.org>?
python-ideas is about future version of the language. The pydotorg list discusses the site https://mail.python.org/mailman/listinfo/pydotorg This would be the place to suggest an addition under 'Community'. But if modern Python 3 code is not welcome on the site (see below), I would not want it promoted as containing examples of 'Python' code.
The page you reference seems a bit hostile to Python 3. It equates 'Python' with 'Python 2' and calls code that also works with Python 3 'unidiomatic Python', and makes no mention of the possibility of submitting Python 3.
and also showing greater use of our interactive command line interface/REPL for solutions which other languages may have,
Since one cannot do anything in the REPL that one cannot do in a file, except leave out 'print', I do not see the point. Leaving '>>>' and '...' in examples only makes it hard to copy and paste.
Reading this page, I am not sure how welcome I would be if I came and tried to contribute. Aside from that, I do not see any obvious way to get of list of tasks without a Python solution, or is that an empty set?
has good code examples - why not advertise that fact on Python.org in a similar way to the Perl 6 site?
Because I do not consider code with 'print x' instead of 'print(x)'. especially when that is the only thing keeping the code from also running on Python 3, to be a 'good code example'. Ditto for 2.x-only code (or 3.x-only code, for that matter) that is not labelled as such. On Python list and elsewhere, newbies frequently post 'I copied this code form ... and it does not run.' because they are running it on the wrong interpreter.
*Disclosure: *I should add that I am an administrator, task writer and one of the Python code contributors to the Rosetta Code site.
Please consider making it more Python 3 friendly than it strikes me as being. Or if my impression is wrong, edit the Python page to at least treat Python 3 on an equal footing. Out of curiosity, and to make a point: Does the current tasks include any that test the quality and completeness of unicode implementation? Something simple like the following, involving astral chars. "Construct a string consisting of the unicode characters U+33, U+333, U+11111, U+334, U+11112, U+11113. U+34. Print the decimal codepoint of the third character before the first occurrence of U+11113. (Answer: 69905.) The code should work on any platform the code could run on." 3.x code: s = "\u0033\u0333\U00011111\u0334\U00011112\U00011113" print(ord(s[s.index('\U00011113')-3])) 2.x code: several lines more to accommodate Windows and narrow unicode builds on some linuxes. -- Terry Jan Reedy

On Oct 14, 2015, at 18:03, Terry Reedy <tjreedy@udel.edu> wrote:
The page you reference seems a bit hostile to Python 3. It equates 'Python' with 'Python 2' and calls code that also works with Python 3 'unidiomatic Python', and makes no mention of the possibility of submitting Python 3.
It also seems to imply that widespread use of reduce is pythonic, apologizing for the unpythonic need to check for and import it in case of Python 3, which makes me wonder how pythonic the code is even for a decade ago…

FWIW, that comment is from five years ago and was written by someone who claims to have been using Python far longer than that (and has enough contributions for that to be believable). It reads more to me like a preemptive apology to "The Haters" than a dismissal of Python 3. I'm sure any contributor to the site can easily reword it to better reflect that not all examples are as terse as they could be if they avoided the 2/3 straddle. Cheers, Steve Top-posted from my Windows Phone -----Original Message----- From: "Andrew Barnert via Python-ideas" <python-ideas@python.org> Sent: 10/14/2015 19:03 To: "Terry Reedy" <tjreedy@udel.edu> Cc: "python-ideas@python.org" <python-ideas@python.org> Subject: Re: [Python-ideas] Rosetta Code on Python.org site? On Oct 14, 2015, at 18:03, Terry Reedy <tjreedy@udel.edu> wrote:
The page you reference seems a bit hostile to Python 3. It equates 'Python' with 'Python 2' and calls code that also works with Python 3 'unidiomatic Python', and makes no mention of the possibility of submitting Python 3.
It also seems to imply that widespread use of reduce is pythonic, apologizing for the unpythonic need to check for and import it in case of Python 3, which makes me wonder how pythonic the code is even for a decade ago… _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

At risk of completely going off topic from the mission of Python-Ideas, I'd almost rather see a delineation between Python 2 and Python 3, like RC has done with Perl 5 (http://rosettacode.org/wiki/Category:Perl) and Perl 6 (http://rosettacode.org/wiki/Category:Perl_6). From RC:
And from https://wiki.python.org/moin/Python2orPython3
While there are many ways to make 'good' code, compatible with both Python 2 and 3, I think that the most terse, efficient code would be better demonstrated by segregating Python 2.x from Python 3.x. On 10/15/2015 6:19 AM, Steve Dower wrote:
--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

On Thu, Oct 15, 2015 at 10:37 AM, Jason Schwerberg <jason@schwerberg.com> wrote:
At risk of completely going off topic from the mission of Python-Ideas, I'd almost rather see a delineation between Python 2 and Python 3
makes sense to me. RC is a wiki, yes? So it looks like this: http://rosettacode.org/wiki/Rosetta_Code:Add_a_Language Is what you need to do... Or would there really be strong objections from the community to having a Python3 section on the site? -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov

On Thu, Oct 15, 2015 at 02:14:16PM -0700, Chris Barker wrote:
I would object to adding Python 3 as a different language. It is not, and we should be emphasising the similarities, not the differences. Migration to Python 3 is slow enough without giving more ammunition ("it's a completely different language, like Perl 6 is to Perl 5") to the foot-draggers and haters. Adding Python 3 as a different language would be a strategic error, because most code snippets will be identical except for possibly print and (raw_)input. That's going to discourage people from adding a Python 3 version that is all but identical to the Python 2 version, which will increase the perception that nobody is using Python 3. ("There are hundreds of Python 2 examples, and only a dozen Python 3 examples.") In my opinion, as far as Rosetta Code and similar sites go, all it takes to manage the Python 2/3 transition is a single comment at the start of the code snippet listing the version(s) targeted. I would consider that the minimum needed. Actually providing hybrid 2+3 code, or side-by-side versions, would be acceptible too, but that's more work. I just looked at a small sample of arbitrary examples, and found that three out of the four already support Python 3, and the one that didn't just needed parens added to print to work. So I don't think there's actually a problem here that needs fixing. -- Steven

On 10/15/2015 8:02 PM, Steven D'Aprano wrote:
Yes, Python 3 *is* Python. Python has always been dynamic in its definition, as well as its execution. 'Python 2' is a sequence of older, frozen dialects. Note that 2.7 code may not run in older versions. And that 2.0 code, for instance, may not work in some 2.x and after. Python 2 sections could be added for 2.x-only code, but for most of the tasks, solutions that run on 3.x and some subset of 2.x are easily possible. When not, the format allow multiple solutions within a language section. For example, FizzBuzz/Python has a both 'print 100 lines' for-loop solution and and infinite itertools-based iterator solution.
This is why I said the Perl6/5- was not the example to follow.
Except for version labeling and blessing rather than dissing 3.x or 2&3 solutions. -- Terry Jan Reedy

On Wed, Oct 7, 2015 at 2:31 AM, Paddy3118 <paddy3118@gmail.com> wrote:
Problem with rosettacode is they can end up like stackoverflow answers that some are good and some are bad. Some will view that as Bible and some will constantly make "suggestions" why X is better. But in the spirit of playground and show case, why not make this a personal project and have people commit to a public repo such as GitHub? Everyone will come up with a different solution. Take BFS and DFS as examples, there are at least two kinds of popular ways to implement that in Python.
participants (8)
-
Andrew Barnert
-
Chris Barker
-
Jason Schwerberg
-
John Wong
-
Paddy3118
-
Steve Dower
-
Steven D'Aprano
-
Terry Reedy