Re: help on "from deen import *" vs. "import deen"

2016-11-14 Thread jfong
MRAB at 2016/11/15 11:31:41AM wrote: > When you say "from deen import *" you're copying names and their > references from the module's namespace to your local namespace: > > [module deen] [locally] > > tblm > [0, 0, 0] <- tb

Re: Who owns the memory in ctypes?

2016-11-14 Thread eryk sun
On Tue, Nov 15, 2016 at 3:15 AM, Cem Karan wrote: > if my C code allocates memory via GC_MALLOC() (the standard call for > allocating memory > in the garbage collector), and I access some object via ctypes in python, > will the python > garbage collector assume that it owns it and attempt to dis

Re: Access to the caller's globals, not your own

2016-11-14 Thread Dan Sommers
On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote: > import library > SPAMIFY = False # only affects this module, no other modules > result = library.make_spam(99) I must be missing something, because it seems too obvious: import library # only affects this module, no other modu

Re: help on "from deen import *" vs. "import deen"

2016-11-14 Thread MRAB
On 2016-11-15 01:36, jf...@ms4.hinet.net wrote: Ned Batchelder at 2016/11/15 6:33:54AM wrote: > But I get a wrong answer this way: > >>> from deen import * > >>> tblm = tbli > >>> gpa(0x7d) > 125 # it's 0x7d, the tblm[2] is 0 > > Why? why! why:-( Here you are assigning a value to your own tblm

Who owns the memory in ctypes?

2016-11-14 Thread Cem Karan
Hi all, I'm hoping that this will be an easy question. I have a pile of C code that I wrote that I want to interface to via the ctypes module (https://docs.python.org/3/library/ctypes.html). The C code uses the Boehm-Demers-Weiser garbage collector (http://www.hboehm.info/gc/) for all of its m

Re: help on "from deen import *" vs. "import deen"

2016-11-14 Thread jfong
Ned Batchelder at 2016/11/15 6:33:54AM wrote: > > But I get a wrong answer this way: > > >>> from deen import * > > >>> tblm = tbli > > >>> gpa(0x7d) > > 125 # it's 0x7d, the tblm[2] is 0 > > > > Why? why! why:-( > > Here you are assigning a value to your own tblm, not deen.tblm, > so gpa does n

Re: help on "from deen import *" vs. "import deen"

2016-11-14 Thread Ned Batchelder
On Sunday, November 13, 2016 at 9:39:12 PM UTC-5, jf...@ms4.hinet.net wrote: > Running the following codes (deen.py) under Win32 python 3.4.4 terminal: > > tbli = [0x66, 0x27, 0xD0] > tblm = [0 for x in range(3)] > def gpa(data): > td = data ^ tblm[2] > return td The function gpa referenc

Lexer/Parser question: TPG

2016-11-14 Thread Johannes Bauer
Hi group, this is not really a Python question, but I use Python to lex/parse some input. In particular, I use the amazing TPG (http://cdsoft.fr/tpg/). However, I'm now stuck at a point and am sure I'm not doing something correctly -- since there's a bunch of really smart people here, I hope to ge

Fwd: Problems with Anaconda and Pyzo

2016-11-14 Thread Dan Pineau
Hello, I'm a french student and I'm running Python 3.5.2 on windows. When I installed Anaconda3 4.2.0 version, Pyzo couldn't find a module named conda. Then I registered it as my default Python 3.5.2 version, but I couldn't use Pyzo anymore (I sent you a screenshot). So I tried to fix this problem

Re: Access to the caller's globals, not your own

2016-11-14 Thread ojacobson
On Monday, November 14, 2016 at 12:21:00 AM UTC-5, Steven D'Aprano wrote: > Don't tell me to make SPAMIFY a parameter of the function. I know that. > That's > what I would normally do, but *occasionally* it is still useful to have a > global configuration setting, and those are the cases I'm ta

Re: Why does this list swap fail?

2016-11-14 Thread Rob Gaddi
38016226...@gmail.com wrote: > L=[2,1] > L[0],L[L[0]-1]=L[L[0]-1],L[0] > > The L doesn't change. Can someone provide me the detail procedure of this > expression? Better question: Why does that list swap exist? If you're just trying to put the language through its paces that's one thing, but I

Re: Why does this list swap fail?

2016-11-14 Thread Alain Ketterlin
38016226...@gmail.com writes: > L=[2,1] > L[0],L[L[0]-1]=L[L[0]-1],L[0] > > The L doesn't change. Can someone provide me the detail procedure of > this expression? From: https://docs.python.org/3/reference/simple_stmts.html#grammar-token-assignment_stmt | Although the definition of assignment i

Re: Why does this list swap fail?

2016-11-14 Thread Jussi Piitulainen
38016226...@gmail.com writes: > L=[2,1] > L[0],L[L[0]-1]=L[L[0]-1],L[0] > > The L doesn't change. Can someone provide me the detail procedure of > this expression? The right-hand side evaluates to (1,2), but then the assignments to the targets on the left-hand side are processed in order from lef

Why does this list swap fail?

2016-11-14 Thread 380162267qq
L=[2,1] L[0],L[L[0]-1]=L[L[0]-1],L[0] The L doesn't change. Can someone provide me the detail procedure of this expression? -- https://mail.python.org/mailman/listinfo/python-list

Re: Access to the caller's globals, not your own

2016-11-14 Thread Rob Gaddi
Steven D'Aprano wrote: > Suppose I have a library function that reads a global configuration setting: > > # Toy example > SPAMIFY = True > def make_spam(n): > if SPAMIFY: > return "spam"*n > else: > return "ham"*n > > > Don't tell me to make SPAMIFY a parameter of the funct

exit ThreadPoolExecutor immediately

2016-11-14 Thread Atul Johri
I am looking for a way to stop a ThreadPoolExecutor immediately under the assumption that I don't care about what's currently running or pending. ``` limit = 2 executor = ThreadPoolExecutor(10) posts = itertools.islice(mygen(executor=executor, **kwargs), 0, limit) for post in posts: print(post)