On Tuesday 17 January 2017 18:05, Steven D'Aprano wrote:
> I wish to emulate a "final" class using Python, similar to bool:
[...]
> Any hints?
I may have a solution: here's a singleton (so more like None than bools) where
instantiating the class returns the singleton, and subclassing the class f
On 01/16/2017 11:05 PM, Steven D'Aprano wrote:
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 have to be absolu
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 have to be absolutely bulletproof, but anyone wanting to subclass
Terry Reedy wrote:
Traceback (most recent call last):
File "", line 1, in
with None: pass
AttributeError: __enter__
Like he said, you get an AttributeError!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
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_cursor()
if c is None:
raise CantGet
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 tokenize
module. Before reporting it as a bug, I recommend that you confirm that it al
Here's something odd I've found with the tokenize module: tokenizing 'if x:\n
y' 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 other hand, if the o
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 a connection (or getting a
connection from a pool, more likely), and cl
On Mon, 16 Jan 2017 10:17:06 +, Joseph L. Casale wrote:
>> Trying to sniff Ethernet packets, I do this:
>>
>>s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
>>
>> but it results in this:
>>
>> $ sudo python3 sniff_survey.py
>> Traceback (most recent call last)
Steve D'Aprano :
> or you can let the context manager do what it does, and write your own code
> to do what you do:
>
> try:
> with ...:
>...
> except:
> ...
Even better:
try:
a = open(...)
except ...:
...
with a:
...
You want to catch exceptions
On Tue, 17 Jan 2017 05:06 am, 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 a connection (or getting a
> connection from a pool,
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 a connection (or getting a
> connection from a pool, more likely), and cleaning up
On Tue, Jan 17, 2017 at 5:06 AM, 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 a connection (or getting a
> connection from a po
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 a connection (or getting a
connection from a pool, more likely), and cleaning up after the fact (such as
putting the
On Friday, 13 January 2017 09:27:59 UTC, haraldn...@gmail.com wrote:
> I want to do some development on `distlib`, and in the process run the code
> via `virtualenv` which has distlib as a dependency.
>
> That is, not run the process inside a virtualenv, but run virtualenv's code
> using a cust
On Friday, 13 January 2017 09:27:21 UTC, haraldn...@gmail.com wrote:
> I was working on a bugfix for Virtualenv, regarding very long shebang lines
> that are breaking things. In the process, I realized that if I want really
> fix to my particular issue it likely needs to be done on the lower lev
[This announcement is in German since it targets a local user group
meeting in Düsseldorf, Germany]
ANKÜNDIGUNG
Python Meeting Düsseldorf
http://pyddf.de/
Ein Tref
> Trying to sniff Ethernet packets, I do this:
>
>s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
>
> but it results in this:
>
> $ sudo python3 sniff_survey.py
> Traceback (most recent call last):
> File "sniff_survey.py", line 118, in
> s = socket
On 1/16/2017 12:32 AM, Girish Khasnis wrote:
Hi,
I am unable to install Python on my system. After installing Python I get
the below error when I try to open Python.
[image: Inline image 1]
Copy and paste the error message. This is text only list.
--
Terry Jan Reedy
--
https://mail.pytho
To complement what Peter wrote: I'd approach this problem using
XPath. XPath is a query language for XML/HTML documents; it's a great
tool to have in your web scraping toolbox (among other tasks). With
Python's excellent lxml library you can do some XPath processing. Here's
how I might tackle this
Hi,
I am unable to install Python on my system. After installing Python I get
the below error when I try to open Python.
[image: Inline image 1]
Regards
Girish
--
https://mail.python.org/mailman/listinfo/python-list
My apologies for not providing enough information.
I'll share my code attempt shortly.
Cheers for your help :)
Shei
--
https://mail.python.org/mailman/listinfo/python-list
22 matches
Mail list logo