Re: "except" and "subclasscheck" changed between CPython2 and 3

2018-03-05 Thread Steven D'Aprano
On Sat, 03 Mar 2018 04:28:24 +, 高岡陽太 wrote: > Hello, > > I found a difference of behavior about `except` statement between > CPython 2.7 and 3.x . > `except EXC_CLASS:` calls `__subclasscheck__` in 2.7, but does not in > 3.x . Python 3 does not accept virtual subclasses for exception handli

Re: How to access the help page of SRE_Pattern?

2018-03-05 Thread Steven D'Aprano
On Mon, 05 Mar 2018 18:13:59 -0600, Peng Yu wrote: > Hi, > import re prog=re.compile('[a-f]+') help(prog) > > I can use the above command to access SRE_Pattern. But this involves the > creation of an object of the class. If you're using help() interactively, the cost of creating

How to access the help page of SRE_Pattern?

2018-03-05 Thread Peng Yu
Hi, >>> import re >>> prog=re.compile('[a-f]+') >>> help(prog) I can use the above command to access SRE_Pattern. But this involves the creation of an object of the class. I tried to directly access the class. But it does not work. Does anybody know if there is a way to directly access the class

Re: How to make Python run as fast (or faster) than Julia

2018-03-05 Thread Dan Stromberg
On Mon, Mar 5, 2018 at 3:53 PM, Python wrote: > On Sat, Mar 03, 2018 at 08:18:03AM +1100, Chris Angelico wrote: >> > Python is often a preferred solution because it is often fantastic for >> > rapid implementation and maintainability. The GIL's interference >> > with threaded code performance has

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Chris Angelico
On Tue, Mar 6, 2018 at 10:04 AM, Steven D'Aprano wrote: > # Later. > if __name__ = '__main__': > # Enter the Kingdom of Nouns. Don't you need a NounKingdomEnterer to do that for you? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make Python run as fast (or faster) than Julia

2018-03-05 Thread Python
On Sat, Mar 03, 2018 at 08:18:03AM +1100, Chris Angelico wrote: > > Python is often a preferred solution because it is often fantastic for > > rapid implementation and maintainability. The GIL's interference > > with threaded code performance has, for me at least, on several > > occasions been...

Re: Bitstream -- Binary Data for Humans

2018-03-05 Thread Roel Schroeven
Sébastien Boisgérault schreef op 5/03/2018 20:05: I have released bitstream, a Python library to manage binary data (at the byte or bit level), > hopefully without the pain that this kind of thing usually entails :) If you have struggled with this topic in the past, please take a look at the

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Steven D'Aprano
On Mon, 05 Mar 2018 09:22:33 -0800, Ooomzay wrote: [...] >> Looking at that code, my major thought is that there is far too much >> OO design, not enough simplicity. > > If this is far too much OO for you then RAII will be of no interest to > you. I think this is probably the wisest thing you h

Re: "built-in" callables?

2018-03-05 Thread Gregory Ewing
Stefan Ram wrote: . So, what does "built-in" in the sense of »isbuiltin« actually mean? It means "implemented in C". Yes, this is confusing. The term "built-in" is used in two different ways, and you just have to disambiguate them from context. -- Greg -- https://mail.python.org/mailman/

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 19:14:05 UTC, Paul Rubin wrote: > Ooomzay writes: > > If you want to use RAII objects then you will make sure you avoid > > adding them to orphan cycles by design. If you don't know how to do > > that then don't write applications that manage critical resources. > > My cla

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 17:58:40 UTC, Chris Angelico wrote: > On Tue, Mar 6, 2018 at 4:53 AM, Ooomzay wrote: > > On Monday, 5 March 2018 14:21:54 UTC, Chris Angelico wrote: > >> On Tue, Mar 6, 2018 at 12:58 AM, Ooomzay wrote: > >> > Here is my fixed example, if someone else could try it in CPytho

Re: Bitstream -- Binary Data for Humans

2018-03-05 Thread sum abiut
Thanks On 6/03/2018 7:13 AM, "Sébastien Boisgérault" < sebastien.boisgera...@gmail.com> wrote: Hi everyone, I have released bitstream, a Python library to manage binary data (at the byte or bit level), hopefully without the pain that this kind of thing usually entails :) If you have struggled w

Bitstream -- Binary Data for Humans

2018-03-05 Thread Sébastien Boisgérault
Hi everyone, I have released bitstream, a Python library to manage binary data (at the byte or bit level), hopefully without the pain that this kind of thing usually entails :) If you have struggled with this topic in the past, please take a look at the documentation (http://boisgera.github.io

Re: Ways to make a free variable local to a function?

2018-03-05 Thread Terry Reedy
On 3/5/2018 9:34 AM, Chris Angelico wrote: On Tue, Mar 6, 2018 at 12:52 AM, Terry Reedy wrote: On 3/5/2018 7:12 AM, Kirill Balunov wrote: # 1. By passing through local variable's default values def func_local_1(numb, _int = int, _float = float, _range = range): You are not required t

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Chris Angelico
On Tue, Mar 6, 2018 at 4:53 AM, Ooomzay wrote: > On Monday, 5 March 2018 14:21:54 UTC, Chris Angelico wrote: >> On Tue, Mar 6, 2018 at 12:58 AM, Ooomzay wrote: >> > Here is my fixed example, if someone else could try it in CPython and >> > report back that would be interesting:- >> > >> > class

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 14:21:54 UTC, Chris Angelico wrote: > On Tue, Mar 6, 2018 at 12:58 AM, Ooomzay wrote: > > Here is my fixed example, if someone else could try it in CPython and > > report back that would be interesting:- > > > > class RAIIFileAccess(): > > def __init__(self, fname): >

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 16:47:02 UTC, Steven D'Aprano wrote: > On Sun, 04 Mar 2018 16:58:38 -0800, Ooomzay wrote: > > > Here is an example of a composite resource using RAII:- > > > > class RAIIFileAccess(): > > def __init__(self, fname): > > print("%s Opened" % fname) > > def __

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Steven D'Aprano
On Mon, 05 Mar 2018 07:31:57 -0800, Ooomzay wrote: > We do not expect this to work in PyPy. Or Jython, IronPython, possibly not Stackless either, or in the interactive interpreter of (probably) any implementation, or CPython if the object is garbage collected during interpreter shutdown or is i

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Steven D'Aprano
On Sun, 04 Mar 2018 16:58:38 -0800, Ooomzay wrote: > Here is an example of a composite resource using RAII:- > > class RAIIFileAccess(): > def __init__(self, fname): > print("%s Opened" % fname) > def __del__(self): > print("%s Closed" % fname) > > class A(): > def __

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 15:17:13 UTC, bartc wrote: > On 05/03/2018 13:58, Ooomzay wrote: > > On Monday, 5 March 2018 11:24:37 UTC, Chris Angelico wrote: > >> On Mon, Mar 5, 2018 at 10:09 PM, Ooomzay wrote: > >>> Here is an example of a composite resource using RAII:- > >>> > >>> class RAIIFileAcc

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread bartc
On 05/03/2018 13:58, Ooomzay wrote: On Monday, 5 March 2018 11:24:37 UTC, Chris Angelico wrote: On Mon, Mar 5, 2018 at 10:09 PM, Ooomzay wrote: Here is an example of a composite resource using RAII:- class RAIIFileAccess(): def __init__(self, fname): print("%s Opened" % fname)

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 14:36:30 UTC, Chris Angelico wrote: > On Tue, Mar 6, 2018 at 1:25 AM, Ooomzay wrote: > > Ahah... I see now you are running it from a shell so the exception is > > staying in scope. We just need to include normal exception handling in the > > example to fix this:- > > > >

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Chris Angelico
On Tue, Mar 6, 2018 at 1:25 AM, Ooomzay wrote: > Ahah... I see now you are running it from a shell so the exception is staying > in scope. We just need to include normal exception handling in the example to > fix this:- > > def main(): > try: > c = C() > c.dostuff() > exc

Re: Ways to make a free variable local to a function?

2018-03-05 Thread Chris Angelico
On Tue, Mar 6, 2018 at 12:52 AM, Terry Reedy wrote: > On 3/5/2018 7:12 AM, Kirill Balunov wrote: >> # 1. By passing through local variable's default values >> >> def func_local_1(numb, _int = int, _float = float, _range = range): > > > You are not required to mangle the names. > > def func_lo

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 13:59:35 UTC, Ooomzay wrote: > On Monday, 5 March 2018 11:24:37 UTC, Chris Angelico wrote: > > On Mon, Mar 5, 2018 at 10:09 PM, Ooomzay wrote: > > > Here is an example of a composite resource using RAII:- > > > > > > class RAIIFileAccess(): > > > def __init__(self, fna

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Chris Angelico
On Tue, Mar 6, 2018 at 12:58 AM, Ooomzay wrote: > Then that is indeed a challenge. From CPython back in 2.6 days up to > Python36-32 what I see is:- > > a Opened > b Opened > Traceback (most recent call last): > ... > AttributeError: 'C' object has no attribute 'dostuff' > a Closed > b Closed > >

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, 5 March 2018 11:24:37 UTC, Chris Angelico wrote: > On Mon, Mar 5, 2018 at 10:09 PM, Ooomzay wrote: > > Here is an example of a composite resource using RAII:- > > > > class RAIIFileAccess(): > > def __init__(self, fname): > > print("%s Opened" % fname) > > def __del__(se

Re: Ways to make a free variable local to a function?

2018-03-05 Thread Terry Reedy
On 3/5/2018 7:12 AM, Kirill Balunov wrote: Hi, At the moment, in order to slightly speed up the function in Python, free variables are passed as local variables to the function, thereby getting rid of extra look ups. For example, for the following function, I especially do not use list comprehen

Ways to make a free variable local to a function?

2018-03-05 Thread Kirill Balunov
Hi, At the moment, in order to slightly speed up the function in Python, free variables are passed as local variables to the function, thereby getting rid of extra look ups. For example, for the following function, I especially do not use list comprehension) and therefore maybe it's not the best e

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Chris Angelico
On Mon, Mar 5, 2018 at 10:09 PM, Ooomzay wrote: > Here is an example of a composite resource using RAII:- > > class RAIIFileAccess(): > def __init__(self, fname): > print("%s Opened" % fname) > def __del__(self): > print("%s Closed" % fname) > > class A(): > def __init_

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Sunday, 4 March 2018 23:56:09 UTC, Chris Angelico wrote: > On Sun, Mar 4, 2018 at 10:37 PM, Ooomzay wrote: > > Please consider the case of a composite resource: You need to implement > > __enter__, __exit__ and track the open/closed state at every level in > > your component hierarchy - even i

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread Ooomzay
On Monday, March 5, 2018 at 6:38:49 AM UTC, Mark Lawrence wrote: > On 05/03/18 01:01, Ooomzay wrote: > > On Sunday, 4 March 2018 23:57:24 UTC, Mark Lawrence wrote: > >> On 04/03/18 02:28, Ooomzay wrote: > >>> On Friday, 2 March 2018 15:37:25 UTC, Paul Moore wrote: > >>> [snip] > def f

Re: Bypassing firewall

2018-03-05 Thread Alister via Python-list
On Mon, 05 Mar 2018 08:37:14 +, Faruq Bashir wrote: > How will i bypass web application firewall For what purpose? is this your firewall? -- https://mail.python.org/mailman/listinfo/python-list

Re: Bypassing firewall

2018-03-05 Thread Chris Angelico
On Mon, Mar 5, 2018 at 7:37 PM, Faruq Bashir via Python-list wrote: > How will i bypass web application firewall Easy! Talk to the person who's in charge of it. Use a $5 wrench if you have to. https://xkcd.com/538/ ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Bypassing firewall

2018-03-05 Thread Faruq Bashir via Python-list
    How will i bypass web application firewall -- https://mail.python.org/mailman/listinfo/python-list