Re: In Python2, does it need to wrap imp.find/load_module with imp_acquire/release_lock?

2018-03-01 Thread Xiang Zhang
On Wednesday, February 28, 2018 at 3:02:38 PM UTC+8, dieter wrote: > Xiang Zhang writes: > > > Just like the title. It seems to me it is needed from the source code but > > codes in stdlib all doesn't do that. > > The "import" machinery uses locks of its

In Python2, does it need to wrap imp.find/load_module with imp_acquire/release_lock?

2018-02-27 Thread Xiang Zhang
Just like the title. It seems to me it is needed from the source code but codes in stdlib all doesn't do that. -- https://mail.python.org/mailman/listinfo/python-list

tool interface in Python

2017-09-06 Thread Xiang Zhang
Is there any project in Python about tool interface? In Java, it gets JVMTI which allows users easily build tools upon it. For example, for an APM framework, it allows you use Java agent to dynamically trace functions in your application. And you don't have to modify or restart your application

Re: Special attributes added to classes on creation

2016-07-04 Thread Xiang Zhang
On Monday, July 4, 2016 at 12:02:41 AM UTC+8, Steven D'Aprano wrote: > I have some code which can preprocess (using a metaclass) or postprocess > (using a decorator) a class: > > @process > class K: > pass > > > class K(metaclass=process): > pass > > > Both should give the same result,

Re: How to get which attribute causes the AttributeError except inspecting strings?

2016-03-07 Thread Xiang Zhang
On Tuesday, March 8, 2016 at 12:38:31 AM UTC+8, Tim Golden wrote: > On 07/03/2016 16:25, Xiang Zhang wrote: > > Hi, > > > > I know I can get the attribute name in some way, but since I just > > want the attribute name when an AttributeError caused by it raised, I >

Re: How to get which attribute causes the AttributeError except inspecting strings?

2016-03-07 Thread Xiang Zhang
Hi, I know I can get the attribute name in some way, but since I just want the attribute name when an AttributeError caused by it raised, I really don't want to inspect the string or introduce one more layer over getattr. I hope I can get the attribute which causes the exception from the Attrib

Re: How to get which attribute causes the AttributeError except inspecting strings?

2016-03-07 Thread Xiang Zhang
On Monday, March 7, 2016 at 5:49:48 PM UTC+8, Peter Otten wrote: > ZhangXiang wrote: > > > In python3, when I write code like this: > > > > try: > > fields = [getattr(Product, field) for field in fields.split(',')] > > except AttributeError as e: > > raise HTTPError(...) > > > > I want t

Re: What is the meaning of Py_INCREF a static PyTypeObject?

2015-11-13 Thread Xiang Zhang
n 11/13/2015 02:52 AM, Jason Swails wrote: On Thu, Nov 12, 2015 at 3:05 AM, Xiang Zhang <18518281...@126.com <mailto:18518281...@126.com>> wrote: Recently I am learning Python C API. When I read the tutorial <https://docs.python.org/3/extending/newtypes.html#the-basi

What is the meaning of Py_INCREF a static PyTypeObject?

2015-11-12 Thread Xiang Zhang
Recently I am learning Python C API. When I read the tutorial , defining new types, I feel confused. After PyType_Ready(&noddy_NoddyType) comes Py_INCREF(&noddy_NoddyType). Actually noddy_NoddyType is a static struct so I don't und

Python: How to find out values of all feasible x under constraints.

2015-05-14 Thread Xiang Zhang
s x (domain of x) using python, like [0,0,0,0,0,0,0,0,0,0], [1,1,1,1,1,1,1,1,1,1] etc ? What should be the code? Any hint or help would be highly appreciated! Sincerely, Xiang Zhang -- https://mail.python.org/mailman/listinfo/python-list