Re: Emulating Final classes in Python

2017-01-18 Thread Steve D'Aprano
On Thu, 19 Jan 2017 09:02 am, Ethan Furman wrote: [...] > One problem with the above is existing instances won't be modified to > inherit from the updated class. I am unsure if that is solvable before > 3.6, but in 3.6 one can use the new __init_subclass__ to avoid a Final > base class, a FinalMe

Re: Emulating Final classes in Python

2017-01-18 Thread Ethan Furman
On 01/18/2017 08:24 AM, Ethan Furman wrote: On 01/17/2017 11:05 PM, Steven D'Aprano wrote: I've given a metaclass that disallows subclassing: class MyClass(MyParent, metaclass=FinalMeta): ... Ethan took that one step further by giving a class you inherit from to disallow subclassing:

Re: Python 3.6 Installation

2017-01-18 Thread Michael Torrie
On 01/18/2017 10:59 AM, eryk sun wrote: > On Wed, Jan 18, 2017 at 6:23 AM, Terry Reedy wrote: >> Not everyone has run Windows update since the current runtime was released. > > Python's installer tries (and sometimes fails) to install the > KB2999226 update, which installs an old version of the U

Adding colormaps?

2017-01-18 Thread Martin Schöön
Is there a way to add colormaps to Matplotlib? What I would like to do is to add the perceptually uniform sequential colormaps introduced in version 1.5.something. I would like to do this without breaking my Debian system in which Matplotlib version 1.4.2 is the newest version available in the re

Re: sorting list python

2017-01-18 Thread Germán Fajardo
with open('partite.txt', 'r') as r: for line in sorted(r): print(line, end='') 2017-01-18 15:38 GMT-05:00 Smith : > On 18/01/2017 21:34, MRAB wrote: > >> If you're wondering about the blank lines, it's because the lines end >> with '\n', which starts a new line, and the print function

Re: sorting list python

2017-01-18 Thread Smith
On 18/01/2017 21:34, MRAB wrote: If you're wondering about the blank lines, it's because the lines end with '\n', which starts a new line, and the print function also starts a new line after printing the string. Try stripping the '\n' off the end of the line read in with the .rstrip method. Th

Re: sorting list python

2017-01-18 Thread Smith
On 18/01/2017 21:21, Grant Edwards wrote: I would have done better by posting the actual code instead of a blind link that may point to Dog-knows-what... sorry :-( -- https://mail.python.org/mailman/listinfo/python-list

Re: sorting list python

2017-01-18 Thread Smith
On 18/01/2017 21:20, Peter Otten wrote: with open("partite.txt") as f: by_number = sorted(f, key=lambda line: int(line.partition("'")[0])) print("".join(by_number)) Great!!! :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: sorting list python

2017-01-18 Thread MRAB
On 2017-01-18 19:51, Smith wrote: Hi all, could you do better? Thank you in advance link code: https://repl.it/FMin/8 If you're wondering about the blank lines, it's because the lines end with '\n', which starts a new line, and the print function also starts a new line after printing the stri

Re: sorting list python

2017-01-18 Thread Grant Edwards
On 2017-01-18, Smith wrote: > could you do better? Yes. > link code: > https://repl.it/FMin/8 I would have done better by posting the actual code instead of a blind link that may point to Dog-knows-what... -- Grant Edwards grant.b.edwardsYow! I had pancake makeup

Re: sorting list python

2017-01-18 Thread Peter Otten
Smith wrote: > Hi all, > could you do better? > Thank you in advance > > link code: > https://repl.it/FMin/8 Don't make it unnecessarily hard to find your code -- as long as it's small you can include it into your mail Given > with open('partite.txt', 'r') as f: > splitted = [(int(line.spl

sorting list python

2017-01-18 Thread Smith
Hi all, could you do better? Thank you in advance link code: https://repl.it/FMin/8 -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.6 Installation

2017-01-18 Thread eryk sun
On Wed, Jan 18, 2017 at 6:23 AM, Terry Reedy wrote: > Not everyone has run Windows update since the current runtime was released. Python's installer tries (and sometimes fails) to install the KB2999226 update, which installs an old version of the Universal CRT. Some installers instead bundle the

Re: Emulating Final classes in Python

2017-01-18 Thread Ethan Furman
On 01/17/2017 11:05 PM, Steven D'Aprano wrote: I've given a metaclass that disallows subclassing: class MyClass(MyParent, metaclass=FinalMeta): ... Ethan took that one step further by giving a class you inherit from to disallow subclassing: class MyClass(MyParent, Final): ... Cou

Re: Emulating Final classes in Python

2017-01-18 Thread alister
On Wed, 18 Jan 2017 13:10:41 +1100, Steven D'Aprano wrote: > On Tuesday 17 January 2017 20:37, Antoon Pardon wrote: > >> Op 17-01-17 om 08:05 schreef Steven D'Aprano: >>> I wish to emulate a "final" class using Python, similar to bool: >>> >>> py> class MyBool(bool): >>> ... pass ... >>> Trac

Re: trouble with cmd.Cmd and prompting

2017-01-18 Thread Peter Otten
Cameron Simpson wrote: > On 04Jan2017 12:20, Cameron Simpson wrote: >>I will try to get a minimal example others can run. > > Well I've made some time for this, and it seems to be an interaction with > my python3, the "input" builtin, and readline. Cmd.cmdloop behaves fine if > I turn off the .r

Re: trouble with cmd.Cmd and prompting

2017-01-18 Thread Cameron Simpson
On 04Jan2017 12:20, Cameron Simpson wrote: I will try to get a minimal example others can run. Well I've made some time for this, and it seems to be an interaction with my python3, the "input" builtin, and readline. Cmd.cmdloop behaves fine if I turn off the .raw_input attribute, and I can r