Re: Emulating Final classes in Python

2017-01-17 Thread Steven D'Aprano
On Wednesday 18 January 2017 15:42, Ethan Furman wrote: [...] > Both those cases are good candidates for disallowing subclassing. I've given a metaclass that disallows subclassing: class MyClass(MyParent, metaclass=FinalMeta): ... Ethan took that one step further by giving a class you inhe

Re: Python 3.6 Installation

2017-01-17 Thread Terry Reedy
On 1/17/2017 11:32 PM, Michael Torrie wrote: On 01/17/2017 07:12 PM, Steven D'Aprano wrote: On Wednesday 18 January 2017 12:30, Michael Torrie wrote: Yes googling error messages is a good idea. However the SO link seems to describe this problem as a missing DLL, probably the VS 2015 runtime re

Re: Emulating Final classes in Python

2017-01-17 Thread Ethan Furman
On 01/17/2017 01:37 AM, 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 ... Traceback (most recent call last): File "", line 1, in TypeError: type 'bool' is not an acce

Re: Python 3.6 Installation

2017-01-17 Thread Michael Torrie
On 01/17/2017 07:12 PM, Steven D'Aprano wrote: > On Wednesday 18 January 2017 12:30, Michael Torrie wrote: > >> Yes googling error messages is a good idea. However the SO link seems to >> describe this problem as a missing DLL, probably the VS 2015 runtime >> redistributable library. If this is t

Re: Python 3.6 Installation

2017-01-17 Thread Steven D'Aprano
On Wednesday 18 January 2017 12:30, Michael Torrie wrote: > Yes googling error messages is a good idea. However the SO link seems to > describe this problem as a missing DLL, probably the VS 2015 runtime > redistributable library. If this is the problem, why isn't Python's > installer bundling th

Re: Emulating Final classes in Python

2017-01-17 Thread Steven D'Aprano
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 >> ... >> Traceback (most recent call last): >> File "", line 1, in >> TypeErr

Re: Python 3.6 Installation

2017-01-17 Thread Michael Torrie
On 01/17/2017 03:31 PM, Terry Reedy wrote: > On 1/17/2017 1:23 PM, Earl Izydore wrote: >> I having problems installing Python 3.6. I was using Python 2.7 >> successfully. >> >> Today, I installed python-3.6.0.exe. > > Which binary? from where? > >> At the end of the installation I got a message

Re: Emulating Final classes in Python

2017-01-17 Thread Steve D'Aprano
On Wed, 18 Jan 2017 06:14 am, Ethan Furman wrote: > On 01/16/2017 11:32 PM, Steven D'Aprano wrote: >> On Tuesday 17 January 2017 18:05, Steven D'Aprano wrote: >> >>> I wish to emulate a "final" class using Python, similar to bool: >> >> I may have a solution: here's a singleton (so more like None

Re: Emulating Final classes in Python

2017-01-17 Thread Steve D'Aprano
On Tue, 17 Jan 2017 08:54 pm, Erik wrote: > Hi Steven, > > On 17/01/17 07:05, Steven D'Aprano wrote: >> I wish to emulate a "final" class using Python, similar to bool: > > [snip] > >> It doesn't have to be absolutely bulletproof, but anyone wanting to >> subclass my class should need to work f

Re: Python 3.6 Installation

2017-01-17 Thread Terry Reedy
On 1/17/2017 1:23 PM, Earl Izydore wrote: I having problems installing Python 3.6. I was using Python 2.7 successfully. Today, I installed python-3.6.0.exe. Which binary? from where? At the end of the installation I got a message saying the installation was successful. When attempt to star

Re: Emulating Final classes in Python

2017-01-17 Thread Ethan Furman
On 01/16/2017 11:32 PM, Steven D'Aprano wrote: On Tuesday 17 January 2017 18:05, Steven D'Aprano wrote: I wish to emulate a "final" class using Python, similar to bool: I may have a solution: here's a singleton (so more like None than bools) where instantiating the class returns the singleton

Re: Error handling in context managers

2017-01-17 Thread Israel Brewster
On Jan 16, 2017, at 11:34 PM, Peter Otten <__pete...@web.de> wrote: > > Gregory Ewing wrote: > >> Israel Brewster wrote: >>> The problem is that, from time to time, I can't get a connection, the >>> result being that cursor is None, >> >> That's your problem right there -- you want a better-beha

Re: Error handling in context managers

2017-01-17 Thread Israel Brewster
On Jan 16, 2017, at 8:01 PM, Gregory Ewing wrote: > > Israel Brewster wrote: >> The problem is that, from time to time, I can't get a connection, the result >> being that cursor is None, > > That's your problem right there -- you want a better-behaved > version of psql_cursor(). > > def get_psq

Re: Error handling in context managers

2017-01-17 Thread Israel Brewster
On Jan 16, 2017, at 1:27 PM, Terry Reedy wrote: > > On 1/16/2017 1:06 PM, Israel Brewster wrote: >> I generally use context managers for my SQL database connections, so I can >> just write code like: >> >> with psql_cursor() as cursor: >> >> >> And the context manager takes care of making

Python 3.6 Installation

2017-01-17 Thread Earl Izydore
I having problems installing Python 3.6. I was using Python 2.7 successfully. Today, I installed python-3.6.0.exe. At the end of the installation I got a message saying the installation was successful. When attempt to start Python, I get the following Application Error: The application was una

Re: Python, asyncio, and systemd

2017-01-17 Thread Chris Angelico
On Wed, Jan 18, 2017 at 4:06 AM, Ian Kelly wrote: >> What's the official way to say to asyncio "here's a listening socket, >> start managing it for me"? > > I haven't tried this but create_server takes a "sock" keyword-argument. > > https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.

Re: Python, asyncio, and systemd

2017-01-17 Thread Christian Heimes
On 2017-01-17 17:57, Chris Angelico wrote: > If I write a web server using asyncio (and the aiohttp package), I can > spin up the server with: > > await loop.create_server(app.make_handler(), "0.0.0.0", 8080) > > This works fine for a high port, but if I want to bind to port 80, I > need to eithe

Re: Python, asyncio, and systemd

2017-01-17 Thread Ian Kelly
On Tue, Jan 17, 2017 at 9:57 AM, Chris Angelico wrote: > If I write a web server using asyncio (and the aiohttp package), I can > spin up the server with: > > await loop.create_server(app.make_handler(), "0.0.0.0", 8080) > > This works fine for a high port, but if I want to bind to port 80, I > ne

Python, asyncio, and systemd

2017-01-17 Thread Chris Angelico
If I write a web server using asyncio (and the aiohttp package), I can spin up the server with: await loop.create_server(app.make_handler(), "0.0.0.0", 8080) This works fine for a high port, but if I want to bind to port 80, I need to either start as root and then drop privileges, or get given th

Re: tokenize.untokenize adding line continuation characters

2017-01-17 Thread Rotwang
On Tuesday, January 17, 2017 at 11:11:27 AM UTC, Peter Otten wrote: > Rotwang wrote: > > > Here's something odd I've found with the tokenize module: tokenizing 'if > > x:\ny' and then untokenizing the result adds '\\\n' to the end. > > Attempting to tokenize the result again fails because of t

Re: tokenize.untokenize adding line continuation characters

2017-01-17 Thread Peter Otten
Rotwang wrote: > Here's something odd I've found with the tokenize module: tokenizing 'if > x:\ny' and then untokenizing the result adds '\\\n' to the end. > Attempting to tokenize the result again fails because of the backslash > continuation with nothing other than a newline after it. On the

Re: tokenize.untokenize adding line continuation characters

2017-01-17 Thread sg552
On Tuesday, January 17, 2017 at 2:47:03 AM UTC, Steven D'Aprano wrote: > On Tuesday 17 January 2017 09:42, Rotwang wrote: > > > Here's something odd I've found with the tokenize module: > [...] > > Copypasted from iPython: > > It's not impossible that iPython is doing something funny with the to

Re: Emulating Final classes in Python

2017-01-17 Thread Erik
Hi Steven, On 17/01/17 07:05, Steven D'Aprano wrote: I wish to emulate a "final" class using Python, similar to bool: [snip] It doesn't have to be absolutely bulletproof, but anyone wanting to subclass my class should need to work for it, which hopefully will tell them that they're doing som

Re: Emulating Final classes in Python

2017-01-17 Thread Antoon Pardon
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 > ... > Traceback (most recent call last): > File "", line 1, in > TypeError: type 'bool' is not an acceptable base type > > > It doesn't h

[RELEASED] Python 3.4.6 and Python 3.5.3 are now available

2017-01-17 Thread Larry Hastings
On behalf of the Python development community and the Python 3.4 and Python 3.5 release teams, I'm delighted to announce the availability of Python 3.4.6 and Python 3.5.3. Python 3.4 is now in "security fixes only" mode. This is the final stage of support for Python 3.4. Python 3.4 now onl

Re: Error handling in context managers

2017-01-17 Thread Peter Otten
Gregory Ewing wrote: > Israel Brewster wrote: >> The problem is that, from time to time, I can't get a connection, the >> result being that cursor is None, > > That's your problem right there -- you want a better-behaved > version of psql_cursor(). > > def get_psql_cursor(): > c = psql_curso