Re: A newbie quesiton: local variable in a nested funciton

2015-12-26 Thread jfong
Chris Angelico at 2015/12/26 UTC+8 11:44:21AM wrote: > Pike is semantically very similar to Python, but it uses C-like > variable scoping. Here's an equivalent, which might help with > comprehension: > > function outerf() > { > int counter = 55; > void innerf() > { > write("%d

Re: A newbie quesiton: local variable in a nested funciton

2015-12-26 Thread jfong
Ben Finney at 2015/12/26 UTC+8 11:42:08AM wrote: > The Python FAQ answers this, even using an example the same as yours > https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value>. > Thank you, Ben. It's amazing that you seem to know every

A newbie quesiton: local variable in a nested funciton

2015-12-25 Thread jfong
As a tranditional language programmer like me, the result is really weird. Here is the test codes in file test1.py: def outerf(): counter = 55 def innerf(): print(counter) #counter += 1 return innerf myf = outerf() the result is: >>> import

Re: OT: citizens and countries - was Re: v3.5.1 - msi download

2015-12-23 Thread jfong
Michael Torrie at 2015/12/23 UTC+8 12:22:23PM wrote: > In the American way of thinking, the country *is* the people. So it was > neither a lie nor a bad thing that Kennedy proclaimed. Maybe this is > not true for other countries, but I think most Americans would feel it > is true for their count

Re: v3.5.1 - msi download

2015-12-22 Thread jfong
Mark Lawrence at 2015/12/21 UTC+8 8:50:00PM wrote: > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. When I saw this sentence, I can't resist to think of the famous lie created by president John kennedy: "Ask not what your country can do fo

Re: Problem on ctypes arguments in a DLL function

2015-12-18 Thread jfong
eryk sun at 2015/12/18 UTC+8 6:26:02PM wrote: > The function's calling convention is x86 cdecl (CDLL, caller stack > cleanup), but you're using the x86 stdcall convention (WinDLL, callee > stack cleanup). For a 64-bit process they're actually the same, but > you're using 32-bit Python, so you have

Problem on ctypes arguments in a DLL function

2015-12-18 Thread jfong
I am trying to use the libusb-win32 v1.2.6.0 with Win7. I wrote a test program(showing below) but stuck with a strange problem. Here is the result: D:\Work\Python34>python Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In tel)] on win32 T

Python 3.4 + pyUSB 1.0 + libusb-win32 1.2.6.0, what happens?

2015-12-05 Thread jfong
I am new to python. I had a USB HID device which behavior is that the host send a 64 bytes commands to it, after complete the execution of this commands it send back a 64 bytes status to the host, so the host can check the status and decide the next step. When I run it under Win7 with SwiftFort

Re: python response slow when running external DLL

2015-12-01 Thread jfong
Peter Otten at 2015/12/1 UTC+8 7:01:55PM wrote: > While the var_status.set() invoked from the second thread modifies some > internal data the main thread could kick in and modify (parts of) that same > data, thus bringing tkinter into an broken state. A simple example that > demonstrates the pr

Re: python response slow when running external DLL

2015-11-30 Thread jfong
jf...@ms4.hinet.net at 2015/11/29 UTC+8 10:55:28AM wrote: > > > . > > > . > > > #do the rest > > > var_status.set('Download...') > > > _thread.start_new_thread(td_download, ()) #must use threading > > > > > > def td_download(): > > > result = mydll.SayHello() > >

Re: python response slow when running external DLL

2015-11-28 Thread jfong
Laura Creighton at 2015/11/28 UTC+8 6:52:25PM wrote: > I never saw the reply that Peter is replying to. > The threading module constructs a higher level interface on top of the > low level thread module. Thus it is the preferred way to go for > standard Python code -- and even Fredrik's recipe con

Re: python response slow when running external DLL

2015-11-28 Thread jfong
Peter Otten at 2015/11/28 UTC+8 6:14:09PM wrote: > No, the point of both recipes is that tkinter operations are only ever > invoked from the main thread. The main thread has polling code that > repeatedly looks if there are results from the helper thread. As far I > understand the polling method

Re: python response slow when running external DLL

2015-11-27 Thread jfong
Peter Otten at 2015/11/27 UTC+8 8:20:54PM wrote: > Quick-fix example: > def download(): > var.set("Starting download...") > root.update_idletasks() > time.sleep(3) > var.set("... done") Thanks, Peter, The update_idletasks() works. In my trivial program it's easy to apply for ther

Re: python response slow when running external DLL

2015-11-27 Thread jfong
Peter Otten at 2015/11/27 UTC+8 5:19:17 PM wrote: Hi! Peter, thanks for your prompt reply. > What does var_status.set() do? If it writes to stdout you may just need to > flush(). var_status is a StringVar which binds to a lable's textvariable. I use this label as the status bar to show mes

python response slow when running external DLL

2015-11-26 Thread jfong
I am new to Python. As an exercise of it, I try to port a program which was written more than 10 years ago. This program use the Borland C++ Builder as its GUI front end and a DLL does the real work(it will takes a few seconds to complete). I saw a strange phenomenon in the following codes. The

<    1   2   3