Which curses version should I use under Windows

2019-06-17 Thread jfong
As many others had encountered, when I import the curses module under Windows, I got ImportError: No module named '_curses' Search "curses" on the Pypi returns plenty of related packages. Which one should I use? Is this package still valid on usage? Any comment will be appreciated. --Jach

Re: Which curses version should I use under Windows

2019-06-17 Thread jfong
MRAB於 2019年6月18日星期二 UTC+8上午10時08分23秒寫道: > On 2019-06-18 02:39, jf...@ms4.hinet.net wrote: > > As many others had encountered, when I import the curses module under > > Windows, I got > > > > ImportError: No module named '_curses' > > > > Search "curses" on the Pypi returns plenty of related

Re: Which curses version should I use under Windows

2019-06-17 Thread jfong
Terry Reedy於 2019年6月18日星期二 UTC+8上午11時03分00秒寫道: > On 6/17/2019 10:54 PM, jf...@ms4.hinet.net wrote: > > > c:\Works\Python34>pip install windows-curses > > DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the > > last one supporting it. Please upgrade your Python as Python 3.4

Re: Which curses version should I use under Windows

2019-06-18 Thread jfong
MRAB於 2019年6月18日星期二 UTC+8下午6時12分50秒寫道: > On 2019-06-18 04:57, jf...@ms4.hinet.net wrote: > > Terry Reedy於 2019年6月18日星期二 UTC+8上午11時03分00秒寫道: > >> On 6/17/2019 10:54 PM, jf...@ms4.hinet.net wrote: > >> > >> > c:\Works\Python34>pip install windows-curses > >> > DEPRECATION: Python 3.4 support has bee

What's wrong on using Popen's communicate method?

2019-07-03 Thread jfong
I have the test0.py below. I expect to see 'abcd' showing in the notepad window: - import subprocess as sp p0 = sp.Popen('notepad.exe', stdin=sp.PIPE) p0.communicate(input=b'abcd') - But nothing happens. The notepad is completely empty. What have I missed? --Jach PS. I am using py

Re: What's wrong on using Popen's communicate method?

2019-07-03 Thread jfong
Chris Angelico於 2019年7月4日星期四 UTC+8上午8時37分13秒寫道: > On Thu, Jul 4, 2019 at 10:01 AM wrote: > > > > I have the test0.py below. I expect to see 'abcd' showing in the notepad > > window: > > - > > import subprocess as sp > > p0 = sp.Popen('notepad.exe', stdin=sp.PIPE) > > p0.communicate(input=

Re: What's wrong on using Popen's communicate method?

2019-07-03 Thread jfong
Wildman於 2019年7月4日星期四 UTC+8上午11時15分57秒寫道: > On Thu, 04 Jul 2019 10:36:36 +1000, Cameron Simpson wrote: > > > On 03Jul2019 16:57, Jach Fong wrote: > >>I have the test0.py below. I expect to see 'abcd' showing in the notepad > >>window: > >>- > >>import subprocess as sp > >>p0 = sp.Popen('

Re: What's wrong on using Popen's communicate method?

2019-07-05 Thread jfong
Terry Reedy於 2019年7月5日星期五 UTC+8上午12時13分25秒寫道: > On 7/3/2019 7:57 PM, jf...@ms4.hinet.net wrote: > > I have the test0.py below. I expect to see 'abcd' showing in the notepad > > window: > > - > > import subprocess as sp > > p0 = sp.Popen('notepad.exe', stdin=sp.PIPE) > > p0.communicate(inpu

Re: What's wrong on using Popen's communicate method?

2019-07-05 Thread jfong
Chris Angelico於 2019年7月6日星期六 UTC+8上午10時48分10秒寫道: > On Sat, Jul 6, 2019 at 12:31 PM wrote: > > > > Terry Reedy於 2019年7月5日星期五 UTC+8上午12時13分25秒寫道: > > > On 7/3/2019 7:57 PM, jf...@ms4.hinet.net wrote: > > > > I have the test0.py below. I expect to see 'abcd' showing in the > > > > notepad window: >

Re: What's wrong on using Popen's communicate method?

2019-07-06 Thread jfong
eryk sun於 2019年7月6日星期六 UTC+8下午2時13分23秒寫道: > On 7/5/19, jf...@ms4.hinet.net wrote: > > Terry Reedy於 2019年7月5日星期五 UTC+8上午12時13分25秒寫道: > > > >> Upgrade to 3.7 or 3.8 to get hundreds of bug fixes, let alone new > >> features. Both subprocess and multiprocessing have gotten fixes. > > > > I can't beca

Re: What's wrong on using Popen's communicate method?

2019-07-06 Thread jfong
Michael Torrie於 2019年7月6日星期六 UTC+8下午12時02分02秒寫道: > On 07/05/2019 09:03 PM, jf...@ms4.hinet.net wrote: > > From Vista to Win10? That's a three generation gap! Buy a new PC might > > be a better solution:-) > > Maybe. Windows 10 would probably run okay on that machine. It might be > 10 years o

Re: What's wrong on using Popen's communicate method?

2019-07-06 Thread jfong
eryk sun於 2019年7月6日星期六 UTC+8下午6時26分42秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > eryk sun於 2019年7月6日星期六 UTC+8下午2時13分23秒寫道: > > > >> Major versions of Python support Windows versions that have extended > >> support from Microsoft at the time of the first release. For Vista, > >> extended suppo

Re: What's wrong on using Popen's communicate method?

2019-07-06 Thread jfong
eryk sun於 2019年7月7日星期日 UTC+8上午10時13分34秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > > > According to the info you give, I have done the following steps: > > 1. Upgrade to SP2 first. > > 2. Install the CRT update. > > But the result is still the same, nothing happens after double click the > > f

Re: What's wrong on using Popen's communicate method?

2019-07-06 Thread jfong
eryk sun於 2019年7月7日星期日 UTC+8下午12時00分47秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > > > In TEMP, there is only one file "chrome_installer.log" dated at the time of > > doing the upgrade (strange?, why chrome?). No errors in it. > > So the installer doesn't even execute. Do you maybe have an >

Re: What's wrong on using Popen's communicate method?

2019-07-07 Thread jfong
eryk sun於 2019年7月7日星期日 UTC+8下午3時51分57秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > > > I turn off the anti-virus and tried v3.6.8, get the same result. Usually the > > anti-virus program will warn me if something was blocked. > > In case the executable is corrupt, clear your browser cache and

Re: What's wrong on using Popen's communicate method?

2019-07-07 Thread jfong
eryk sun於 2019年7月7日星期日 UTC+8下午3時51分57秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > > > I turn off the anti-virus and tried v3.6.8, get the same result. Usually the > > anti-virus program will warn me if something was blocked. > > In case the executable is corrupt, clear your browser cache and

Is there a simple way to wrap a built-in function for the whole package?

2019-07-31 Thread jfong
I get a package from Pypi. The package has many modules using built-in open() function. I like to redefine all the open() there with the default encoding 'utf-8', but not for code outside the package. Maybe I can put my def statement at the beginning of every module of this package, but just won

Re: Is there a simple way to wrap a built-in function for the whole package?

2019-08-01 Thread jfong
Cameron Simpson於 2019年8月2日星期五 UTC+8上午6時25分00秒寫道: > On 31Jul2019 19:16, Jach Fong wrote: > >I get a package from Pypi. The package has many modules using built-in > >open() function. I like to redefine all the open() there with the default > >encoding 'utf-8', but not for code outside the package

Re: Is there a simple way to wrap a built-in function for the whole package?

2019-08-02 Thread jfong
Batuhan Taskaya於 2019年8月3日星期六 UTC+8上午5時27分49秒寫道: > functools.partial is a better option > > On Fri, Aug 2, 2019, 1:25 AM Cameron Simpson wrote: > > > On 31Jul2019 19:16, Jach Fong wrote: > > >I get a package from Pypi. The package has many modules using built-in > > open() function. I like to r

Which editor is suited for view a python package's source?

2019-08-19 Thread jfong
I like to download one package's source and study it in an editor. It allows me to open the whole package as a project and let me jump from a reference in one file to its definition in another file back and forth. It will be even better if it can handle the import modules too. (Maybe this is too

Re: Which editor is suited for view a python package's source?

2019-08-19 Thread jfong
Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道: > PyCharm takes you to the source code within the editor for any > variables/functions/classes/modules if you ctrl+click on what you want to > see. It allows you to browse the relevant bits of code quickly, as well as > let you change them in your loc

Re: Which editor is suited for view a python package's source?

2019-08-20 Thread jfong
Nick Sarbicki於 2019年8月20日星期二 UTC+8下午1時33分32秒寫道: > Yes the community edition works fine. > > It seems to require a 64 bit version of Windows 7 or higher (I'm not sure > as I haven't used Windows in years). > > On Tue, 20 Aug 2019, 03:27 , wrote: > > > Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒

How to record the console's content in the interpreter?

2019-08-22 Thread jfong
Say I like to record everything showing in the console into a file after I start a debug session, and stop it when finished. It's not a console redirection. I still need to see what is going on during the session. --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: How to record the console's content in the interpreter?

2019-08-22 Thread jfong
Cameron Simpson於 2019年8月23日星期五 UTC+8下午12時09分54秒寫道: > On 22Aug2019 19:38, Jach Fong wrote: > >Say I like to record everything showing in the console into a file > >after I start a debug session, and stop it when finished. It's not > >a console redirection. I still need to see what is going on durin

Re: How to record the console's content in the interpreter?

2019-08-23 Thread jfong
Manfred Lotz於 2019年8月23日星期五 UTC+8下午2時58分48秒寫道: > On Thu, 22 Aug 2019 21:48:33 -0700 (PDT) > jf...@ms4.hinet.net wrote: > > > Cameron Simpson於 2019年8月23日星期五 UTC+8下午12時09分54秒寫道: > > > On 22Aug2019 19:38, Jach Fong wrote: > > > >Say I like to record everything showing in the console into a file >

Re: How to record the console's content in the interpreter?

2019-08-23 Thread jfong
Manfred Lotz於 2019年8月23日星期五 UTC+8下午6時08分11秒寫道: > On Fri, 23 Aug 2019 00:42:26 -0700 (PDT) > jf...@ms4.hinet.net wrote: > > > Manfred Lotz於 2019年8月23日星期五 UTC+8下午2時58分48秒寫道: > > > On Thu, 22 Aug 2019 21:48:33 -0700 (PDT) > > > jf...@ms4.hinet.net wrote: > > > > > > > Cameron Simpson於 2019年8月23日星期

Re: How to record the console's content in the interpreter?

2019-08-23 Thread jfong
Terry Reedy於 2019年8月23日星期五 UTC+8下午7時27分50秒寫道: > On 8/23/2019 3:42 AM, jf...@ms4.hinet.net wrote: > > > Say I like to record everything showing in the console into a file > > after I start a debug session, and stop it when finished. It's not > > a console redirection. I still need to se

Re: How to record the console's content in the interpreter?

2019-08-23 Thread jfong
eryk sun於 2019年8月24日星期六 UTC+8上午2時53分56秒寫道: > On 8/23/19, jf...@ms4.hinet.net wrote: > > > > it won't show output from print command, and "print" is the most > > command used in a module when a response was needed > > ConEmu is an alternate console for Windows that allows logging all > console out

Is it 'fine' to instantiate a widget without parent parameter?

2019-09-07 Thread jfong
I know it is valid, according to the Tkinter source, every widget constructor has a 'master=None' default. What happens on doing this? In what circumstance, we do it this way? and will it cause any trouble? --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: Is it 'fine' to instantiate a widget without parent parameter?

2019-09-08 Thread jfong
Terry Reedy於 2019年9月8日星期日 UTC+8下午5時31分34秒寫道: > On 9/7/2019 9:44 PM, jf...@ms4.hinet.net wrote: > > I know it is valid, according to the Tkinter source, every widget > > constructor has a 'master=None' default. What happens on doing this? > > Tkinter creates a default Tk object and uses that as th

Re: Is it 'fine' to instantiate a widget without parent parameter?

2019-09-08 Thread jfong
David於 2019年9月8日星期日 UTC+8下午6時44分55秒寫道: > On Sun, 8 Sep 2019 at 20:25, wrote: > > > > If I have two widgets created this way: > > t0 = tkinter.Text() > > t1 = tkinter.Text() > > How many Tk objects will there be? > > $ python3 > Python 3.5.3 (default, Sep 27 2018, 17:25:39) > [GCC 6.3.0 20170516]

Re: Is it 'fine' to instantiate a widget without parent parameter?

2019-09-08 Thread jfong
David於 2019年9月8日星期日 UTC+8下午8時14分03秒寫道: > On Sun, 8 Sep 2019 at 21:05, wrote: > > David於 2019年9月8日星期日 UTC+8下午6時44分55秒寫道: > > > On Sun, 8 Sep 2019 at 20:25, wrote: > > > > > If I have two widgets created this way: > > > > t0 = tkinter.Text() > > > > t1 = tkinter.Text() > > > > How many Tk objects

Re: Is it 'fine' to instantiate a widget without parent parameter?

2019-09-09 Thread jfong
Terry Reedy於 2019年9月9日星期一 UTC+8下午3時06分27秒寫道: > On 9/8/2019 8:40 PM, jf...@ms4.hinet.net wrote: > > > Thank you. After a quick trace to find out the reason, I found that Tkinter > > prevents Tk() be called more than once from widget constructors, so only > > one Tk object exists:-) > > There wil

How to correctly use 'in_' argument in tkinter grid()?

2019-09-09 Thread jfong
I had tried the following script test.py: import tkinter as tk class Demo(tk.Frame): def __init__(self): tk.Frame.__init__(self, name='demo') self.pack() panel = tk.Frame(self, name='panel') panel.pack() start = tk.Button(text=

Re: Is it 'fine' to instantiate a widget without parent parameter?

2019-09-09 Thread jfong
Terry Reedy於 2019年9月10日星期二 UTC+8上午11時43分05秒寫道: > On 9/9/2019 8:30 PM, jf...@ms4.hinet.net wrote: > > Terry Reedy於 2019年9月9日星期一 UTC+8下午3時06分27秒寫道: > > >> There will only be one default Tk object, but there can be multiple Tk > >> objects. > > import tkinter as tk > f0 = tk.Frame() > > T

Re: How to correctly use 'in_' argument in tkinter grid()?

2019-09-10 Thread jfong
Peter Otten於 2019年9月10日星期二 UTC+8下午5時04分27秒寫道: > jf...@ms4.hinet.net wrote: > > > I had tried the following script test.py: > > > > import tkinter as tk > > > > class Demo(tk.Frame): > > def __init__(self): > > tk.Frame.__init__(self, name='demo') > > self.pack() > >

Re: Is it 'fine' to instantiate a widget without parent parameter?

2019-09-10 Thread jfong
Terry Reedy於 2019年9月10日星期二 UTC+8下午5時16分19秒寫道: > On 9/10/2019 12:02 AM, jf...@ms4.hinet.net wrote: > > > Got it. The first Tk object is always the default one no matter where it > > was created. The default one is always the one which the widget > > constructor refer to when required. > > Or on

Re: exec and globals and locals ...

2019-09-19 Thread jfong
>>> x = 3 >>> def foo(): ... exec("print(globals(), locals()); x = x + 1; print(globals(), locals())") ... >>> foo() {'foo': , '__package__': None, '__builtins__': , '__loader__': , '__doc__': None, '__name__': '__main__', '__spec__': None, 'x': 3} {} {'foo': , '__package__': None, '__builti

Re: exec and globals and locals ...

2019-09-20 Thread jfong
Peter Otten於 2019年9月20日星期五 UTC+8下午3時31分48秒寫道: > jf...@ms4.hinet.net wrote: > > x = 3 > def foo(): > > ... exec("print(globals(), locals()); x = x + 1; print(globals(), > > locals())") ... > foo() > > {'foo': , '__package__': None, '__builtins__': > > {, '__loader__': > {'_froze

How to handle '-' in the 'from' part in a "from import" statement?

2019-10-07 Thread jfong
For example: from my-dir import test I know it can be solved by renaming, but any alternative? --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: How to handle '-' in the 'from' part in a "from import" statement?

2019-10-07 Thread jfong
DL Neil於 2019年10月8日星期二 UTC+8上午11時02分20秒寫道: > On 8/10/19 3:45 PM, jf...@ms4.hinet.net wrote: > > For example: > > from my-dir import test > > > > I know it can be solved by renaming, but any alternative? > > > The manual is your friend: > - import > - importlib > > (the latter allows modules to

Re: How to handle '-' in the 'from' part in a "from import" statement?

2019-10-08 Thread jfong
dieter於 2019年10月8日星期二 UTC+8下午1時33分20秒寫道: > jf...@ms4.hinet.net writes: > > ... > > But most of the download from Github has a directory named '-master' > > which causes a trouble sometimes. > > Those are likely not meant to be imported directly. > > Typically, you have a "setup" step which i

Re: How to handle '-' in the 'from' part in a "from import" statement?

2019-10-08 Thread jfong
jf...@ms4.hinet.net於 2019年10月8日星期二 UTC+8上午10時45分36秒寫道: > For example: > from my-dir import test > > I know it can be solved by renaming, but any alternative? > > --Jach Maybe another (better?) solution is: import sys sys.path.append(r'my-dir') import test --Jach -- https://mail.python.org/mail

What's the purpose the hook method showing in a class definition?

2019-10-19 Thread jfong
For the two examples below: (1) >>> class A: ... def foo(self): ... self.goo() ... >>> class B(A): ... def goo(self): ... print(1) ... (2) >>> class A: ... def foo(self): ... self.goo() ... def goo(self): pass ... >>> class B(A): ... def goo(self): ...

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread jfong
Sibylle Koczian於 2019年10月20日星期日 UTC+8上午2時04分54秒寫道: > Am 19.10.2019 um 13:11 schrieb jf...@ms4.hinet.net: > > For the two examples below: > > (1) > class A: > > ... def foo(self): > > ... self.goo() > > ... > class B(A): > > ... def goo(self): > > ... print(1) > > .

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread jfong
Ian Hobson於 2019年10月20日星期日 UTC+8下午6時05分11秒寫道: > Hi Jach, > > On 20/10/2019 09:34, jf...@ms4.hinet.net wrote: > > What puzzles me is how a parent's method foo() can find its child's method > > goo(), no matter it was overwrote or not? MRO won't explain this and I > > can't find document about it

What's the difference between running a script under command box and interpreter?

2019-10-31 Thread jfong
The script test.py is something like this: ---test.py from pyeds import fsm ... ... class Rule_Parse: def __init__(self): ... self.current_char = '' ... ... def main(input_str): for c in input_str: ... rule.current_char = c ... if __name__ == '__

Re: What's the difference between running a script under command box and interpreter?

2019-10-31 Thread jfong
Cameron Simpson於 2019年11月1日星期五 UTC+8下午12時13分45秒寫道: > On 31Oct2019 20:44, Jach Fong wrote: > >The script test.py is something like this: > >---test.py > >from pyeds import fsm > >... > >... > >class Rule_Parse: > >def __init__(self): > >... > >self.current_char = '' > >... >

Re: What's the difference between running a script under command box and interpreter?

2019-11-01 Thread jfong
Cameron Simpson於 2019年11月1日星期五 UTC+8下午5時28分42秒寫道: > On 31Oct2019 22:03, Jach Fong wrote: > >Cameron Simpson於 2019年11月1日星期五 UTC+8下午12時13分45秒寫道: > >> On 31Oct2019 20:44, Jach Fong wrote: > >> >The script test.py is something like this: > >> >---test.py > >> >from pyeds import fsm > >> >... > >>

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread jfong
Peter J. Holzer於 2019年11月4日星期一 UTC+8上午3時59分36秒寫道: > On 2019-11-01 04:24:38 -0700, jf...@ms4.hinet.net wrote: > > > The globals are your current module's namespace, and functions defines > > > in a module are bound to that module's namespace. > > > > > > Strip your test.py back. A lot. Try this: >

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread jfong
Chris Angelico於 2019年11月4日星期一 UTC+8上午8時43分07秒寫道: > On Mon, Nov 4, 2019 at 11:36 AM wrote: > > > > Peter J. Holzer於 2019年11月4日星期一 UTC+8上午3時59分36秒寫道: > > > On 2019-11-01 04:24:38 -0700, jf...@ms4.hinet.net wrote: > > > > > The globals are your current module's namespace, and functions defines > > >

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread jfong
Chris Angelico於 2019年11月4日星期一 UTC+8上午10時19分50秒寫道: > On Mon, Nov 4, 2019 at 1:01 PM wrote: > > > > Chris Angelico於 2019年11月4日星期一 UTC+8上午8時43分07秒寫道: > > > Ah, that's a fair point. If you specifically WANT that behaviour, what > > > you can do is invoke the script interactively: > > > > > > python3 -

Re: What's the difference between running a script under command box and interpreter?

2019-11-04 Thread jfong
Grant Edwards於 2019年11月5日星期二 UTC+8上午12時41分24秒寫道: > On 2019-11-04, Dennis Lee Bieber wrote: > > Using > > > >from module import * > > > > is often the worst thing one can do. > > I agree 100%. > > Unfortunately, most of the official standard library documentation is > written assuming you do

Re: How execute at least two python files at once when imported?

2019-11-06 Thread jfong
Igor Korot於 2019年11月7日星期四 UTC+8上午12時34分35秒寫道: > Hi, > > On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: > > > > Hi > > > > Sorry if I haven't stated my requirements clearly. > > > > I just wanted a way to import at least two python files in parallel and I > > wanted to know how this can be don

Re: python 2 to 3 converter

2019-12-08 Thread jfong
Greg Ewing於 2019年12月9日星期一 UTC+8上午6時18分32秒寫道: > On 8/12/19 9:30 pm, songbird wrote: > >wouldn't it make more sense to just go back and fix the > > converter program than to have to manually convert all this > > python2 code? > > Anything that isn't already fixed by 2to3 is probably > somewhere

Does the argparse generate a wrong help message?

2019-12-27 Thread jfong
The codes in test.py are: - import argparse parser = argparse.ArgumentParser() parser.add_argument('--foo', nargs='?', help='foo help') parser.add_argument('--goo', nargs=1, help='goo help') args = parser.parse_args() print(args.foo, args.goo) - But I get the following result: --

Re: Does the argparse generate a wrong help message?

2019-12-27 Thread jfong
Chris Angelico於 2019年12月28日星期六 UTC+8上午11時30分47秒寫道: > On Sat, Dec 28, 2019 at 2:26 PM wrote: > > > > The codes in test.py are: > > - > > import argparse > > parser = argparse.ArgumentParser() > > parser.add_argument('--foo', nargs='?', help='foo help') > > parser.add_argument('--goo', nargs

Re: Does the argparse generate a wrong help message?

2020-01-01 Thread jfong
Random832於 2020年1月2日星期四 UTC+8上午5時04分36秒寫道: > On Fri, Dec 27, 2019, at 23:08, jf...@ms4.hinet.net wrote: > > > > optional arguments: > > > > -h, --help show this help message and exit > > > > --foo [FOO] foo help > > > > --goo GOOgoo help > > > > > > > > D:\Works\Python>py test.py --foo

How to decide which module is in charge of this error? cx-Freeze or pynput or six?

2020-01-09 Thread jfong
le warning: ... Missing modules: ... ? six.moves imported from pynput._util ... Run the created hello.exe will cause this error: ... from pynput._util import Events File "C:\Users\jfong\AppData\Local\Programs\Python\Python36-32\lib\site- packages\pynput\_util\__init__.p

Re: Tkinter layout designer

2020-02-25 Thread jfong
mm0fmf於 2020年2月25日星期二 UTC+8上午5時29分33秒寫道: > Can anyone recommend a graphic layout designer for Tkinter programs. I > have a number of older C# Windows Forms apps that need porting so they > can run on Linux and Windows and this is the chance to re-write them in > Python. However, after using the

Re: Function to avoid a global variable

2020-04-27 Thread jfong
bvdp於 2020年4月28日星期二 UTC+8上午9時46分35秒寫道: > Oh my, that is very cool! So, I can do this: > > def foo(i): > if not 'bar' in foo.__dict__: > foo.bar = 5 > foo.bar += i You can have function attribute created this way if you like: def foo(i): foo.bar += i foo.bar = 5 -

Re: Any timeline for PIL for Python 3.4

2020-08-10 Thread jfong
dn於 2020年8月11日星期二 UTC+8下午1時29分47秒寫道: > On 11/08/2020 16:35, Martin wrote: > > I am running Python 3.4.4, and would like to > > use the Python Imaging Library (PIL).  This > > is currently not available for Python > > Version 3.  Does anybody know when it will > > become available? > > > > Plan B i

Re: GUI (tkinter) popularity and job prospects for

2020-10-22 Thread jfong
Lammie Jonson於 2020年10月23日星期五 UTC+8上午5時20分45秒寫道: > Thanks, > > Yes, I have some sense about how to do job interviews and market myself > which is always an ongoing process. > > I also just have an interest in different technologies that I may want to > investigate as I can get bored with cert

Re: Best way to determine user's screensize?

2020-10-30 Thread jfong
What's wrong the OP's question? Why can't just answer it? --Jach -- https://mail.python.org/mailman/listinfo/python-list

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

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

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-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-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-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-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

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

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

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

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: 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

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: 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

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
Chris Angelico at 2015/12/26 UTC+8 5:50:07PM wrote: > 11: Another normal assignment, because otherwise the rest of the work > is pointless. :) Thanks for this detailed example. As I had learned so far, Python really take "name" seriously, and every meaningful result you got have to assign to a n

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

2015-12-26 Thread jfong
Last night I noticed that Python does not resolve name in "def" during import, as C does in the compile/link stage, it was deferred until it was referenced (i.e. codes was executed). That's OK for Anyway codes has to be debugged sooner or later. I just have to get used to this style. But check

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

2015-12-27 Thread jfong
Chris Angelico at 2015/12/27 UTC+8 2:32:32PM wrote: > On Sun, Dec 27, 2015 at 3:11 PM, wrote: > > Last night I noticed that Python does not resolve name in "def" during > > import, as C does in the compile/link stage, it was deferred until it was > > referenced (i.e. codes was executed). That'

Is there a way importing a string object?

2016-01-04 Thread jfong
For example, name = "test" # test.py is a module's file import name Regards, Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way importing a string object?

2016-01-04 Thread jfong
jf...@ms4.hinet.net at 2016/1/5 UTC+8 8:49:56AM wrote: Thanks, Ian and Ben. This forum is really a good place for learning Python. I am glad I had join in. To Ben, > (Please make the body of your message complete. The "Subject" field > should be a summary of your message's subject, and may not b

Which Python editor has this feature?

2016-01-10 Thread jfong
It lets you jump between the current cursor position and the line the upper level indentation start, something like the bracket matching in C editor. Because of Python use indentation as its code block mark, It might be helpful if we can jump between different level of it:-) --Jach Fong -- ht

Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Chris Angelico at 2016/1/11 UTC+8 10:59:47AM wrote: > On Mon, Jan 11, 2016 at 12:59 PM, wrote: > > It lets you jump between the current cursor position and the line the upper > > level indentation start, something like the bracket matching in C editor. > > Because of Python use indentation as

Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Tim Chase at 2016/1/11 UTC+8 11:16:27AM wrote: > On 2016-01-10 17:59, jf...@ms4.hinet.net wrote: > > It lets you jump between the current cursor position and the line > > the upper level indentation start, something like the bracket > > matching in C editor. Because of Python use indentation as its

Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Gordon Levi at 2016/1/11 UTC+8 4:41:20PM wrote: > Jetbrains Pycharm has "go to start of block" and "go to end of block" > commands . Thanks, Gordon. But this seems only jump between the current code block's start and end, not to the code one level above:-( --J

Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Terry Reedy at 2016/1/12 UTC+8 5:22:35AM wrote: > IDLE has an optional 'code context' feature that shows header lines that > have scrolled up off the top of the screen. This would let you see > which class you are in, Thanks, Terry. It's just what I am looking for:-) By the way, do you know how

Re: Which Python editor has this feature?

2016-01-12 Thread jfong
Terry Reedy at 2016/1/12 UTC+8 3:56:03PM wrote: > Revamping IDLE to 1. use ttk widgets and 2. become a modern single > window app with multiple panes, including a tabbed editor pane, is a > goal for 2016. That will be great, I'm looking forward to it. By the way, when I was playing around with

Re: Which Python editor has this feature?

2016-01-12 Thread jfong
wxjm...@gmail.com at 2016/1/月12 4:29:08PM wrote: > IDLE ? > I need less than 10 seconds to make it crash. Unwittingly or intentionally? > The interesting aspect is not only to show that it crashes, > the very interesting point is to explain why it is crashing. Can you tell us (in a separate subj

Re: Which Python editor has this feature?

2016-01-13 Thread jfong
Terry Reedy at 2016/1/13 UTC+8 5:15:20PM wrote: > This was a Windows specific problem that was fixed (for me) in all three > recent (last November/December) bugfix releases. If you have a problem > with *current* IDLE, I would like to know. I download/install the latest version 3.4.4 and it wor

How this C function was called through ctypes this way?

2016-02-04 Thread jfong
Here is an example from "Python Cookbook, Third Edition(by David Beazley and Brian K. Jones)" Chapter 15.1. "Accessing C Code Using ctypes" --- import ctypes ... # Try to locate the .so file in the same directory as this file ... _mod = ctypes.cdll.LoadLibrary(_path) ... ... # voi

Re: How this C function was called through ctypes this way?

2016-02-04 Thread jfong
eryk sun at 2016/2/4 UTC+8 7:35:17PM wrote: > > _mod = ctypes.cdll.LoadLibrary(_path) > > Calling ctypes.CDLL directly is preferable since it allows passing > parameters such as "mode" and "use_errno". > > IMO, the ctypes.cdll and ctypes.windll loaders should be avoided in > general, especially o

Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread jfong
I know with open('foo.txt') as f: ...do something... will close the file automatically when the "with" block ends. I also saw codes in a book: for line in open('foo.txt'): ...do something... but it didn't mention if the file will be closed automatically or not when the

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-16 Thread jfong
Thanks for these detailed explanation. Both statements will close file automatically sooner or later and, when considering the exceptions, "with" is better. Hope my understanding is right. But, just curious, how do you know the "for" will do it? I can't find any document about it from every sou

Re: Will file be closed automatically in a "for ... in open..." statement?

2016-02-17 Thread jfong
The "for ... open ..." is definitely not a good design pattern. It opens a file at "for" block but leaves it closed somewhere in the sky. > The garbage collector will: > - reclaim the memory used by the object; > - close the file. I suppose (IMO) that the primitive idea of garbage collection do

How to know if an object is still be referenced?

2016-03-01 Thread jfong
Recently I was puzzled by a tkinter problem. The codes below (from a book) can display the picture correctly. gifdir = "../gifs/" from tkinter import * win = Tk() photo = PhotoImage(file=gifdir + "ora-pp.gif") Button(win, image=photo).pack() win.mainloop() And the codes b

Re: How to know if an object is still be referenced?

2016-03-02 Thread jfong
Terry Reedy at 2016/3/2 UTC+8 3:04:10PM wrote: > On 3/1/2016 9:35 PM, jf...@ms4.hinet.net wrote: > > Recently I was puzzled by a tkinter problem. The codes below (from a book) > > can display the picture correctly. > > > > gifdir = "../gifs/" > > from tkinter import * > > win = Tk(

Re: How to know if an object is still be referenced?

2016-03-02 Thread jfong
sohca...@gmail.com at 2016/3/3 UTC+8 7:38:45AM wrote: > "label" might be a local variable, but it's constructor includes a reference > to the frame in which it is going. The frame object will create a reference > to the newly-created Label object. At that point, there will be two > references

<    1   2   3   >