How to debug an unfired tkinter event?

2017-10-18 Thread jfong
In last few days, I tried to experiment with the scrolling table implemented in canvas, started from this example: http://code.activestate.com/recipes/580793-tkinter-table-with-scrollbars/. Everything works fine until I moved the scrolling_area instance (which the canvas is in) from column=0 to

Re: How to debug an unfired tkinter event?

2017-10-19 Thread jfong
Peter Otten at 2017-10-19 UTC+8 PM 3:24:30 wrote: > It's not clear to me what you mean with this. Did you place the table from > the recipe elsewhere inside a window that you created or did you make > changes in the recipe's code? Thank you, Peter. I am using Python 3.4.4 under WinXP. When run

Re: How to debug an unfired tkinter event?

2017-10-19 Thread jfong
Peter Otten於 2017年10月19日星期四 UTC+8下午6時04分39秒寫道: > jf...@ms4.hinet.net wrote: > > > Peter Otten at 2017-10-19 UTC+8 PM 3:24:30 wrote: > >> It's not clear to me what you mean with this. Did you place the table > >> from the recipe elsewhere inside a window that you created or did you > >> make change

Re: How to debug an unfired tkinter event?

2017-10-19 Thread jfong
Peter Otten於 2017年10月20日星期五 UTC+8上午4時37分10秒寫道: > jf...@ms4.hinet.net wrote: > > > Peter Otten於 2017年10月19日星期四 UTC+8下午6時04分39秒寫道: > >> jf...@ms4.hinet.net wrote: > >> > >> > Peter Otten at 2017-10-19 UTC+8 PM 3:24:30 wrote: > >> >> It's not clear to me what you mean with this. Did you place the ta

Re: How to debug an unfired tkinter event?

2017-10-19 Thread jfong
Terry Reedy於 2017年10月20日星期五 UTC+8上午7時37分59秒寫道: > On 10/19/2017 5:07 AM, jf...@ms4.hinet.net wrote: > > > I got some info below each time when I squeeze the table: > > . > > .5006 > > .5006.50712528 > > .5006.50712496 > > .5006.50712464 > > .5006.50712144 > > .5006.50712528.

Re: How to debug an unfired tkinter event?

2017-10-21 Thread jfong
Terry Reedy at 2017-10-20 UTC+8 AM 7:37:59 wrote: > On 10/19/2017 5:07 AM, jf...@ms4.hinet.net wrote: > > > I got some info below each time when I squeeze the table: > > . > > .5006 > > .5006.50712528 > > .5006.50712496 > > .5006.50712464 > > .5006.50712144 > > .5006.507125

How to modify this from Python 2.x to v3.4?

2017-11-11 Thread jfong
I learned python start from using v3.4 and never has any v2.x experience. There is a Pypi project "ctypesgen" I like to use, but it seems is for v2.x. (un)Fortunately I found one of its branch on github which announced is for Python3, but strangely it still use some v2.x words, for example, prin

Re: How to modify this from Python 2.x to v3.4?

2017-11-11 Thread jfong
Ned Batchelder於 2017年11月11日星期六 UTC+8下午8時49分27秒寫道: > This looks like fairly advanced code.  It will be difficult to port to > Python 3 *without* understanding some of the old history.  There seem to > be forks on GitHub, including one with a pull request about Python 3 > made in the last few days

Re: How to modify this from Python 2.x to v3.4?

2017-11-12 Thread jfong
Rick Johnson於 2017年11月12日星期日 UTC+8上午11時07分20秒寫道: > `print` was changed from a statement to a function, so it's > just a matter of converting it to a function call. If you > read the docs for the new print function, it should be > relatively easy to translate. I don't understand why you're > having

Re: How to modify this from Python 2.x to v3.4?

2017-11-12 Thread jfong
Thomas Jollans於 2017年11月12日星期日 UTC+8下午5時17分38秒寫道: > By all means, port ctypesgen to Python 3 (and publish your port) if you > want to, I am not the right person because I have never use Python2 before:-) > but you might want to consider whether it's easier to port your > code from ctypes/ctypesg

How to exec a string which has an embedded '\n'?

2017-12-30 Thread jfong
I have a multiline string, something like '''...\nf.write('\n')\n...''' when pass to exec(), I got SyntaxError: EOL while scanning string literal How to get rid of it? Best Regards, Jach Fong -- https://mail.python.org/mailman/listinfo/python-list

Re: How to exec a string which has an embedded '\n'?

2017-12-31 Thread jfong
Random832於 2017年12月31日星期日 UTC+8下午1時25分50秒寫道: > On Sat, Dec 30, 2017, at 23:57, jf...@ms4.hinet.net wrote: > > I have a multiline string, something like '''...\nf.write('\n')\n...''' > > when pass to exec(), I got > > SyntaxError: EOL while scanning string literal > > > > How to get rid of it? > >

Re: How to exec a string which has an embedded '\n'? (Posting On Python-List Prohibited)

2017-12-31 Thread jfong
Lawrence D’Oliveiro於 2018年1月1日星期一 UTC+8上午7時56分02秒寫道: > On Sunday, December 31, 2017 at 11:04:19 PM UTC+13, jf...@ms4.hinet.net wrote: > > > > This answer makes me think about '\' more thoughtful:-) > > Python generating HTML containing JavaScript which generates HTML: > > out.write \ >

Re: File opening modes (r, w, a ...)

2018-02-22 Thread jfong
ast於 2018年2月22日星期四 UTC+8下午8時33分00秒寫道: > Hello > > I share a very valuable table I found on > StackOverflow about file opening modes > > If like me you always forget the details of > file opening mode, the following table provides > a good summary > >| r r+ w w+ a a+

Re: File opening modes (r, w, a ...)

2018-02-22 Thread jfong
Lew Pitcher於 2018年2月23日星期五 UTC+8上午9時43分19秒寫道: > jf...@ms4.hinet.net wrote: > > > ast於 2018年2月22日星期四 UTC+8下午8時33分00秒寫道: > >> Hello > >> > >> I share a very valuable table I found on > >> StackOverflow about file opening modes > >> > >> If like me you always forget the details of > >> file opening

How to make a foreign function run as fast as possible in Windows?

2016-09-26 Thread jfong
This function is in a DLL. It's small but may run for days before complete. I want it takes 100% core usage. Threading seems not a good idea for it shares the core with others. Will the multiprocessing module do it? Any suggestion? Thanks ahead. --Jach -- https://mail.python.org/mailman/listi

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-27 Thread jfong
eryk sun at 2016/9/27 11:44:49AM wrote: > The threads of a process do not share a single core. The OS schedules > threads to distribute the load across all cores hmmm... your answer overthrow all my knowledge about Python threads completely:-( I actually had ever considered using ProcessPoolE

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-28 Thread jfong
eryk sun at 2016/9/28 1:05:32PM wrote: > In Unix, Python's os module may have sched_setaffinity() to set the > CPU affinity for all threads in a given process. > > In Windows, you can use ctypes to call SetProcessAffinityMask, > SetThreadAffinityMask, or SetThreadIdealProcessor (a hint for the > s

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-28 Thread jfong
Paul Moore at 2016/9/28 11:31:50PM wrote: > Taking a step back from the more detailed answers, would I be right to assume > that you want to call this external function multiple times from Python, and > each call could take days to run? Or is it that you have lots of calls to > make and each on

Re: How to make a foreign function run as fast as possible in Windows?

2016-09-30 Thread jfong
Paul Moore at 2016/9/30 7:07:35PM wrote: > OK. So if your Python code only calls the function once, the problem needs to > be fixed in the external code (the assembly routine). But if you can split up > the task at the Python level to make multiple calls to the function, each to > do a part of

Re: How to make a foreign function run as fast as possible in Windows?

2016-10-01 Thread jfong
Chris Angelico at 2016/10/1 11:25:03AM wrote: > What's it doing? Not every task can saturate the CPU - sometimes they > need the disk or network more. > This function has no I/O or similar activity, just pure data processing, and it takes less than 200 bytes of data area to work with. My CPU is

Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread jfong
I have two files in the Q:\lib directory: Q:\lib>dir 2007/03/11 AM 08:025,260 lib_MARK.so 2007/03/11 AM 08:024,584 lib_mark.so Under Python 3.4.4 I got: >>> f = open('lib_MARK.so', 'br') >>> data = f.read() >>> f.close() >>> len(data) 4584 I know Windows won't, but can Python

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread jfong
Hi, eryk, thanks for your solution. I had try to find the document of the _winapi module, but can't find any in my installed Python directory. Can you give me a link to look for? > This alone doesn't make the Windows API case sensitive, but it does > enable individual CreateFile calls to be case

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread jfong
wxjm...@gmail.com at 2016/10/11 9:40:21PM wrote: > If you are about to modify your registry, do not > forget to switch your Windows in a *utf-8 mode*. Have no idea how to "switch" Windows in a "utf-8 mode"? What will happens if not? Can you give a simple example? Thanks ahead. --Jach -- https:/

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

2016-11-13 Thread jfong
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 I can get a correct answer this way: >>> import deen >>> deen.tblm = deen.tbli >>> deen.gpa(0x7d) 173 # 0xad (= 0x7

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 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: help on "from deen import *" vs. "import deen"

2016-11-15 Thread jfong
Michael Torrie at 2016/11/15 10:43:58PM wrote: > Seems like you're still not understanding Python variables. I do, just not get used to it yet:-) > However once > you assign to these names in your current module you are breaking this > link to the deen module and assigning a new object to th

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

2016-11-16 Thread jfong
Steve D'Aprano at 2016/11/16 8:33:23AM wrote: > `import foo` imports the module foo, that is all. (To be pedantic: it is > *nominally* a module. By design, it could be any object at all.) > > `from foo import *` imports all the visible public attributes of foo. > > They do completely different th

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

2016-11-16 Thread jfong
Michael Torrie at 2016/11/16 11:15:11AM wrote: > ... The globals object is a dictionary and is itself > mutable. But when we assign a new object to a particular dictionary > key, it tosses out the old reference and makes the key now refer to the > new object. It does not do anything to the old ob

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

2016-11-16 Thread jfong
Steven D'Aprano at 2016/11/17 12:06:19PM wrote: > You understand how this works? Yes, thank you for your detail explanation. > import russia as _tmp > president = _tmp.president > del _tmp This one I can understand. But the previous one >>_tmp = int('5') >>for name in dir(_tmp): >>

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

2016-11-17 Thread jfong
Steven D'Aprano at 2016/11/17 4:04:04PM wrote: > The most important thing you should learn from this thread is: > > - avoid using "from module import *" as it is usually more trouble > than it is worth. > > > It is confusing and leads to more problems than it solves. If Python was > being >

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

2016-11-17 Thread jfong
Michael Torrie at 2016/11/17 11:38:32PM wrote: > Like I said, whether the names you use are appropriate is completely up > to you. But this statement seems to imply you're still not getting it > and still thinking of variables as boxes like they are in other > languages, rather than labels that ca

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

2016-11-17 Thread jfong
Michael Torrie at 2016/11/18 11:03:12AM wrote: > >> Python's variables are different from other languages, but in an > >> understandable way. > > > > Unfortunately it's also different from human language. > > How so? I don't find this to be true at all. The fact that most novices will stumble

How to append a modified list into a list?

2016-11-18 Thread jfong
I have a working list 'tbl' and recording list 'm'. I want to append 'tbl' into 'm' each time when the 'tbl' was modified. I will record the change by append it through the function 'apl'. For example: >>>tbl=[0,0] >>>m=[] >>>tbl[0]=1 >>>apl(tbl) >>>m [[1,0]] >>>tbl[1]=2 >>>apl(tbl) >>>m [[1,

Re: How to append a modified list into a list?

2016-11-18 Thread jfong
Oh, I don't know slice well enough:-( So, slice tbl[:] will create a new object (a copy of tbl) which can be passed as a function argument m.append(tbl[:]) or bind to a new name w=tbl[:] or re-bind to itself w[:]=tbl Thanks you, Ian and Steve. Steve D'Aprano at 2016/11/19 11:01:26AM wrote: >

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

2016-11-19 Thread jfong
Chris Angelico at 2016/11/19 2:58:41PM wrote: > On Sat, Nov 19, 2016 at 3:34 PM, Steve D'Aprano > wrote: > > What happens if you do this? > > > > spam = eggs = cheese = obj > > > > Is that different from: > > > > spam = obj > > eggs = obj > > cheese = obj > > > > > > or from this? > > > > spam = o

Re: How to append a modified list into a list?

2016-11-19 Thread jfong
Peter Otten at 2016/11/19 5:40:34PM wrote: > And now for something completely different ;) > > What if you only record the changes to the list? For a long list that would > save space at the expense of calculation time. For example: Excellent! Although not 100% fit into my application, I must st

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

2016-11-20 Thread jfong
Tristan B. Kildaire at 2016/11/20 8:23:37PM wrote: > From deen import * imports all the things in deen but accessable with no > `deen.` These "accessible" objects become read-only even if it's mutable. For immutable objects, you can't even create a new one in the deen's namespace. > import deen

{:2X} didn't output what I expected

2018-03-19 Thread jfong
D:\Temp>py Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> '{:02X}'.format(256) '100' >>> What I expected is '00'. Am I wrong? Best Regards, Jach Fong -- https://mail.python.

Re: {:2X} didn't output what I expected

2018-03-19 Thread jfong
Chris Angelico於 2018年3月20日星期二 UTC+8上午8時06分05秒寫道: > On Tue, Mar 20, 2018 at 10:46 AM, wrote: > > D:\Temp>py > > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 > > bit (Intel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > '{:0

In asyncio, does the event_loop still running after run_until_complete returned?

2018-04-02 Thread jfong
I am new to the asyncio subject, just trying to figure out how to use it. Below is the script I use for testing: - # asyncio_cancel_task2.py import asyncio @asyncio.coroutine def task_func(): print('in task_func, sleeping') try: yield from asyncio.

Re: In asyncio, does the event_loop still running after run_until_complete returned?

2018-04-02 Thread jfong
Ian於 2018年4月2日星期一 UTC+8下午9時37分08秒寫道: > On Mon, Apr 2, 2018 at 5:32 AM, wrote: > > I am new to the asyncio subject, just trying to figure out how to use it. > > Below is the script I use for testing: > > - > > # asyncio_cancel_task2.py > > > > import asyncio > > >

Re: In asyncio, does the event_loop still running after run_until_complete returned?

2018-04-03 Thread jfong
Ian於 2018年4月3日星期二 UTC+8下午1時38分57秒寫道: > On Mon, Apr 2, 2018 at 9:01 PM, wrote: > > def run_forever(self): > """Run until stop() is called.""" >try: > events._set_running_loop(self) > while True: > self._run_once() > if se

Is pdb suitable for debugging asyncio module?

2018-04-04 Thread jfong
I have a module below and run it under pdb, the result seems not easy to xplain. (Note: the sleep periods are in reverse order) --- # asyncio_as_completed.py import asyncio @asyncio.coroutine def phase(i): print('in phase {}'.format(i)) yield from asyncio.sleep(0.5 - (0.1 * i)

How to write partial of a buffer which was returned from a C function to a file?

2018-04-11 Thread jfong
This C function returns a buffer which I declared it as a ctypes.c_char_p. The buffer has size 0x1 bytes long and the valid data may vary from a few bytes to the whole size. In every call I know how much the valid data size is, but I suppose I can't use slice to get it because there may be

Re: How to write partial of a buffer which was returned from a C function to a file?

2018-04-12 Thread jfong
Chris Angelico於 2018年4月12日星期四 UTC+8下午1時31分35秒寫道: > On Thu, Apr 12, 2018 at 2:16 PM, wrote: > > This C function returns a buffer which I declared it as a ctypes.c_char_p. > > The buffer has size 0x1 bytes long and the valid data may vary from a > > few bytes to the whole size. > > > > In eve

Re: How to write partial of a buffer which was returned from a C function to a file?

2018-04-12 Thread jfong
Chris Angelico於 2018年4月12日星期四 UTC+8下午4時05分29秒寫道: > On Thu, Apr 12, 2018 at 4:20 PM, wrote: > > Chris Angelico於 2018年4月12日星期四 UTC+8下午1時31分35秒寫道: > >> On Thu, Apr 12, 2018 at 2:16 PM, wrote: > >> > This C function returns a buffer which I declared it as a > >> > ctypes.c_char_p. The buffer has s

Re: Observations on the List - "Be More Kind"

2018-10-09 Thread jfong
I am wondering the role of the moderator. Does he own the server or pay the bill? Where he get the power to suspending people? Is he a police or judge? Can he shoot someone just because he has any reason? What will happen if his power was limited? Will the forum be end in disorder? No, I don't

Re: Observations on the List - "Be More Kind"

2018-10-09 Thread jfong
Richard Damon at 2018.10.9 UTC+8 PM 8:40:29 wrote: > Moderators are generally appointed by those who do 'pay the bill' for > the mailing list they are moderators for, and serve at their pleasure. > Mailing List are generally 'private property', though often made open to > the public for general use

Re: Observations on the List - "Be More Kind"

2018-10-09 Thread jfong
Chris Angelico at 2018.10.10 UTC+8 AM 10:31:33 wrote: > On Wed, Oct 10, 2018 at 1:21 PM wrote: > > I switched from comp.lang.python to mailing list a few months ago for those > > spam threads there. Now it seems a bad decision because 1) replied mail can > > be lost or duplicated or even banned

How to run/debug a script file its name has characters such as space, (, etc.

2018-10-12 Thread jfong
I saw a directory where all its filenames are something like this: ... 1a PSG (Entry and PopUp).py 1b PSG (Format).py 1c PSG (persistent form and bind key).py ... Just wondering how these file can run and debugged under Windows? --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: How to run/debug a script file its name has characters such as space, (, etc.

2018-10-12 Thread jfong
Chris Angelico於 2018年10月12日星期五 UTC+8下午4時39分37秒寫道: > On Fri, Oct 12, 2018 at 6:26 PM wrote: > > > > I saw a directory where all its filenames are something like this: > > ... > > 1a PSG (Entry and PopUp).py > > 1b PSG (Format).py > > 1c PSG (persistent form and bind key).py > > ... > > > > Just won

Is it dangeous when using custom metaclass?

2018-10-15 Thread jfong
class StructureMeta(type): def __init__(self, clsname, bases, clsdict): offset = 0 ... ... setattr(self, 'struct_size', offset) class Structure(metaclass=StructureMeta): ... ... class PolyHeader(Structure): ... ... As my understanding, the meta

Re: Is it dangeous when using custom metaclass?

2018-10-16 Thread jfong
Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote > jf...@ms4.hinet.net wrote: > > class Structure(metaclass=StructureMeta): ... > > > > class PolyHeader(Structure): ... > > > > As my understanding, the metaclass's __init__ was called when a class was > > created. In the above example, both the

Re: Is it dangeous when using custom metaclass?

2018-10-17 Thread jfong
dieter at 2018/10/17 UTC+8 PM 1:15:01 wrote: > jf...@ms4.hinet.net writes: > > Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote > >> jf...@ms4.hinet.net wrote: > >> > class Structure(metaclass=StructureMeta): ... > >> > > >> > class PolyHeader(Structure): ... > >> > > >> > As my understanding,

Re: how to create a dictionary from csv file?

2016-04-26 Thread jfong
Just curious:-) why everyone here open the csv file without using newline='' as suggested in Python 3.4.4 document section 14.1? -- https://mail.python.org/mailman/listinfo/python-list

Dictionary is really not easy to handle

2016-04-28 Thread jfong
I have a dictionary like this: >>> dct ={1: 'D', 5: 'A', 2: 'B', 3: 'B', 4: 'E'} The following code works: >>> for k in dct: print(k, dct[k]) ... 1 D 2 B 3 B 4 E 5 A and this one too: >>> for k,v in dct.items(): print(k,v) ... 1 D 2 B 3 B 4 E 5 A But...this one? >>> for k,v in dct: print(k,v

Re: Dictionary is really not easy to handle

2016-04-28 Thread jfong
I was overwhelmed that three gurus inspire me in three different ways in their own flavour:-) That's really appreciated! Now I understand why it's so, thanks to all of you. To Peter: > With that information, can you predict what > for k, v in {(1, 2): "three"}: print(k, v) > will print? It's

Re: You gotta love a 2-line python solution

2016-05-02 Thread jfong
DFS at 2016/5/2 UTC+8 11:39:33AM wrote: > To save a webpage to a file: > - > 1. import urllib > 2. urllib.urlretrieve("http://econpy.pythonanywhere.com > /ex/001.html","D:\file.html") > - > > That's it! Why my system can

Re: You gotta love a 2-line python solution

2016-05-02 Thread jfong
DFS at 2016/5/3 9:12:24AM wrote: > try > > from urllib.request import urlretrieve > > http://stackoverflow.com/questions/21171718/urllib-urlretrieve-file-python-3-3 > > > I'm running python 2.7.11 (32-bit) Alright, it works...someway. I try to get a zip file. It works, the file can be unzippe

Re: You gotta love a 2-line python solution

2016-05-02 Thread jfong
Stephen Hansen at 2016/5/3 11:49:22AM wrote: > On Mon, May 2, 2016, at 08:27 PM, jf...@ms4.hinet.net wrote: > > But when I try to get this forum page, it does get a html file but can't > > be viewed normally. > > What does that mean? > > -- > Stephen Hansen > m e @ i x o k a i . i o The page

How to memory dump an object?

2016-05-20 Thread jfong
Is there any tools which can do the memory dump of an object so I can view their content or implementation? For example, >>> s1 = '\x80abc' >>> b1 = b'\x80abc' What are exactly stored in memory for each of them? Is their content really the same? This kind of tool should be helpful "for me" to l

Re: How to memory dump an object?

2016-05-20 Thread jfong
Sorry, forget to mention that I am working on version 3.4 Following the steps given in Chris's reply, I get the result from bytes string: >>> b1 = b'\x80abc' >>> ctypes.cast(id(b1), ctypes.c_voidp) c_void_p(35495992) >>> sys.getsizeof(b1) 21 >>> b1ptr = ctypes.cast(id(b1), ctypes.POINTER(ctypes.c

Re: How to memory dump an object?

2016-05-21 Thread jfong
Make a quick experiment under version 3.4.4 through this simple "tool" Chris had provided, now I know how the unicode string was stored in memory:-) >>> s1 = '\x80abc' >>> s1 '\x80abc' >>> len(s1) 4 >>> sys.getsizeof(s1) 41 >>> s1ptr = ctypes.cast(id(s1), ctypes.POINTER(ctypes.c_uint8)) >>> bytes

Re: Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

2016-06-21 Thread jfong
Pushpanth Gundepalli at 2016/6/21 7:03:28PM wrote: > Guys, can you please share me some sites where we can practice python > programs for beginners and Intermediate. Is this you want? http://pythontutor.com/ --Jach -- https://mail.python.org/mailman/listinfo/python-list

"for/while ... break(by any means) ... else" make sense?

2016-06-28 Thread jfong
Anyone who wrote the code below must be insane:-) for x in range(3): print(x) else: print('I am done') But here it seems perfectly OK: for x in range(3): print(x) if x == 1: break else: print('I am done') To me, the "else" was bonded with

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread jfong
Steven D'Aprano at 2016/6/29 UTC+8 10:43:52AM wrote: > The "else" in for...else has nothing to do with any "if" inside the for > block. Yes, the "else" has nothing to do with "break" syntactically in Python language, but semantically in English it cause confusion. When I said "insane", I just wa

Re: Iteration, while loop, and for loop

2016-06-30 Thread jfong
Steven D'Aprano at 2016/6/30 7:59:40AM wrote: > py> mi = list('bananas') > py> for char in mi: > ... if char == 'a': > ... mi.extend(' yum') > ... print(char, end='') > ... else: # oh no, the feared for...else! > ... # needed to prevent the prompt overwriting the output > .

Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
>>> 00 0 >>> 03 File "", line 1 03 ^ SyntaxError: invalid token >>> Any particular reason? -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: > Before Python 3, a leading 0 in an integer literal would indicate an > octal (base 8) number. So, the reason is historical. > The old form is now invalid in order to reduce the chance of bugs. I encounter this problem on trying to do something like th

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > What is it exactly that you're trying to accomplish with this? Perhaps > there's a better way than using eval. This problem comes from solving a word puzzle, ab + aa + cd == ce Each character will be translate to a digit and evaluate the correctness,

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
I can understand the difficulty of throwing old thing away and accept new one in human. There seems have a huge inertia there. This phenomenon appears on every aspects, not only on the transition from Python2 to Python3. But, as a new comer of Python like me, I have no difficulty to accept it be

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread jfong
Avi Gross at 2018/12/8 UTC+8 PM2:09:20 wrote: > [[READERS DIGEST CONDENSED ANSWER: use int("string") ]] > > Since we all agree python will not make notations like "05" work > indefinitely, and the need expressed is how to solve a symbolic puzzle (see > message below) then it makes sense to look at

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread jfong
Grant Edwards於 2018年12月9日星期日 UTC+8上午12時52分04秒寫道: > On 2018-12-08, Cameron Simpson wrote: > > On 07Dec2018 20:24, Jach Fong wrote: > >>Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > >>> What is it exactly that you're trying to accomplish with this? Perhaps > >>> there's a better way than using eval. >

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread jfong
Avi Gross於 2018年12月9日星期日 UTC+8上午1時40分26秒寫道: > Jach, > > Just for fun, I looked at the puzzle you asked about and solved it several > ways without running into your 03 problem at all. There are more efficient > solutions than total brute force. > > Anyone not interested, stop here, please. After

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread jfong
Chris Angelico於 2018年12月10日星期一 UTC+8下午6時17分14秒寫道: > On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon wrote: > > > > On 10/12/18 11:03, Chris Angelico wrote: > > > Considering that, in a problem of that description, neither S nor M > > > may represent zero, I don't think there's a problem here. > > >

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread jfong
Chris Angelico於 2018年12月10日星期一 UTC+8下午7時09分01秒寫道: > On Mon, Dec 10, 2018 at 9:46 PM wrote: > > > > Chris Angelico於 2018年12月10日星期一 UTC+8下午6時17分14秒寫道: > > > On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon > > > wrote: > > > > > > > > On 10/12/18 11:03, Chris Angelico wrote: > > > > > Considering tha

Re: 03 digression by brute force

2018-12-13 Thread jfong
Just for fun:-) On my ooold PC, it takes 0.047 seconds to run the following algorithm on the problem 'SNED + MORE == MONEY". - import time import itertools #S, E, N, D, M, O, R, Y n = 0 digits = {x for x in range(10)} def tenThousand(u, Cin): # Cin == M global n

Re: Smarter algo, was Re: 03 digression by brute force

2018-12-15 Thread jfong
Appreciate your thoughtfully analysis on this code. Before generalize it with arbitrary additions, as Peter suggested:-), a recursive version is needed. I may give it a try on this Sunday. Avi Gross at 2018/12/15 UTC+8 AM8:13:37 wrote: > REAL SUBJECT: Analysis of alternate algorithms. > > Pete

Re: Smarter algo, was Re: 03 digression by brute force

2018-12-16 Thread jfong
BlindAnagram at 2018/12/15 UTC+8 PM 8:41:21 wrote: > On 15/12/2018 09:56, jf...@ms4.hinet.net wrote: > > Appreciate your thoughtfully analysis on this code. Before generalize it > > with arbitrary additions, as Peter suggested:-), a recursive version is > > needed. I may give it a try on this Sun

Ask for help about class variable scope (Re: Why doesn't a dictionary work in classes?)

2018-12-26 Thread jfong
I saw the code below at stackoverflow. I have a little idea about the scope of a class, and list comprehension and generator expressions, but still can't figure out why Z4 works and Z5 not. Can someone explain it? (in a not-too-complicated way:-) class Foo(): XS = [15, 15, 15, 15] Z4 =

Re: Ask for help about class variable scope (Re: Why doesn't a dictionary work in classes?)

2018-12-27 Thread jfong
eryk sun於 2018年12月27日星期四 UTC+8下午2時31分58秒寫道: > On 12/26/18, jf...@ms4.hinet.net wrote: > > I saw the code below at stackoverflow. I have a little idea about the scope > > of a class, and list comprehension and generator expressions, but still > > can't figure out why Z4 works and Z5 not. Can someon

Re: Ask for help about class variable scope (Re: Why doesn't a dictionary work in classes?)

2018-12-28 Thread jfong
eryk sun at 2018/12/27 UTC+8 PM 6:58:33 wrote: > On 12/27/18, jf...@ms4.hinet.net wrote: > > > > I still don't get it. When I change it to using list comprehension, the > > problem is still there. (it now has no late-binding variable, right? :-) > > > class Too: > > ... XS = [15, 15, 15,

Re: Ask for help about class variable scope (Re: Why doesn't a dictionary work in classes?)

2018-12-28 Thread jfong
jf...@ms4.hinet.net於 2018年12月28日星期五 UTC+8下午4時04分07秒寫道: > eryk sun at 2018/12/27 UTC+8 PM 6:58:33 wrote: > > On 12/27/18, jf...@ms4.hinet.net wrote: > > > > > > I still don't get it. When I change it to using list comprehension, the > > > problem is still there. (it now has no late-binding variable

How to run a module before install?

2019-01-13 Thread jfong
I had download a module which has the following directory structure: [XL-Sudoku-Solver_master] |__[tests] |__[xl_sudoku_solver] |__setup.py |__ __init__.py |__problem1.txt |__ __main__.py |__README.md |__ ... |__ ... The setup.py file has something like this:

Re: How to run a module before install?

2019-01-14 Thread jfong
Peter Otten於 2019年1月14日星期一 UTC+8下午4時04分33秒寫道: > jf...@ms4.hinet.net wrote: > > > I had download a module which has the following directory structure: > > > > [XL-Sudoku-Solver_master] > > |__[tests] > > |__[xl_sudoku_solver] > > |__setup.py |__ __init__.py > > |__problem1.txt |__

Re: Problem : Generator

2019-02-15 Thread jfong
Prahallad Achar於 2019年2月15日星期五 UTC+8下午5時27分36秒寫道: > I get list object instead gen obj > > On Fri, 15 Feb 2019, 13:57 Chris Angelico > > On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar > > wrote: > > > > > > How about this > > > List1=[ 1,2,3,4] > > > Rever_gen = ( x*x for x in list1, reversed

Ask for help on using asynctk package

2019-02-20 Thread jfong
The file below is a simple script to test this package. - # test_asynctk.py import asynctk as atk root = atk.AsyncTk() def delay5S(): btn0.after(5000) def inc1(): msgs = btn1.cget('text').split() n = int(msgs[1]) msg = msgs[0] + ' ' + str(n+1) btn1.config(text=msg

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
ast於 2019年2月26日星期二 UTC+8上午12時25分40秒寫道: > Hello > > I noticed a quirk difference between classes and functions > > >>> x=0 > >>> > >>> class Test: > x = x+1 > print(x) > x = x+1 > print(x) > > 1 > 2 > >>> print(x) > 0 > > Previous code doesn't generate any

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > Thomas Jollans wrote: > > I imagine there's a justification for the difference in behaviour to do > > with the fact that the body of a class is only ever executed once, while > > the body of a function is executed multiple times. > > I suspect there i

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > Thomas Jollans wrote: > > > > I imagine there's a justification for the difference in behaviour to do > > > > with the fact that the body of a class

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Chris Angelico於 2019年2月27日星期三 UTC+8上午11時29分04秒寫道: > On Wed, Feb 27, 2019 at 2:21 PM wrote: > > > > Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > > > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > > > Thomas Jollans wrote: > > > > >

Re: Quirk difference between classes and functions

2019-02-27 Thread jfong
jf...@ms4.hinet.net於 2019年2月26日星期二 UTC+8下午4時46分04秒寫道: > ast於 2019年2月26日星期二 UTC+8上午12時25分40秒寫道: > > Hello > > > > I noticed a quirk difference between classes and functions > > > > >>> x=0 > > >>> > > >>> class Test: > > x = x+1 > > print(x) > > x = x+1 > > p

Re: Implement C's Switch in Python 3

2019-03-15 Thread jfong
Sayth Renshaw at 2019/2/3 UTC+8 AM9:52:50 wrote: > Or perhaps use a 3rd party library like > https://github.com/mikeckennedy/python-switch Thank you for this link. It's a good general implementation. --Jach -- https://mail.python.org/mailman/listinfo/python-list

How to debug a function under the (pdb) prompt?

2019-05-10 Thread jfong
For example, there is a file test0.py: - 1 def foo(): 2 for i in range(3): 3 print(i) 4 5 x = 0 - I start the debug session as below. My question is why the break point at line 3 didn't work. How to debug the function foo() at this time? D:\Works\Python>py -m pdb t

Re: Instance vs Class variable oddity

2019-05-17 Thread jfong
Correct me if I am wrong, please. I always think that the LEGB rule (e.g. the namespace to look up for) was applied at compile-time, only the binding was resolved "dynamically" at run-time. For example: def foo(): print(x) foo() will cause a NameError. But after x = 5 foo() will run corr

Re: Instance vs Class variable oddity

2019-05-18 Thread jfong
Chris Angelico於 2019年5月18日星期六 UTC+8下午3時09分37秒寫道: > On Sat, May 18, 2019 at 1:51 PM wrote: > > > > Correct me if I am wrong, please. > > > > I always think that the LEGB rule (e.g. the namespace to look up for) was > > applied at compile-time, only the binding was resolved "dynamically" at > > ru

tkinter.tix "Control" widget don't work with StringVar?

2019-06-01 Thread jfong
Below is a simplified version of the sample script downloaded from its package. When run it, the entry field display '0' instead of 'P&W'. PS. I am using Python 3.4.4, Windows 32bit test0.py 1 from tkinter import tix as Tix 2 3 root = Tix.Tk() 4 5 demo_maker = Tix.StringVar() 6 dem

Re: tkinter.tix "Control" widget don't work with StringVar?

2019-06-01 Thread jfong
MRAB於 2019年6月2日星期日 UTC+8上午10時18分36秒寫道: > On 2019-06-02 02:28, jf...@ms4.hinet.net wrote: > > Below is a simplified version of the sample script downloaded from its > > package. > > When run it, the entry field display '0' instead of 'P&W'. > > PS. I am using Python 3.4.4, Windows 32bit > > > > --

  1   2   3   >