Re: How to change '\\' to '\'

2018-10-01 Thread Jach Fong
posed that most discussant want to see the reply message instantly when they open the mail. They already know what is going on and no need to pass through all those previous message. "top posting" seems more reasonable to me:-) --Jach mm0fmf at 2018/10/2 AM 05:05 wrote: On 01/10/2018 10:1

Re: How to change '\\' to '\'

2018-10-01 Thread Jach Fong
ep 2018 17:45:52 -0700, Rick Johnson wrote: Jach Fong wrote: I get a string item, for example path[0], from path = os.get_exec_path() It's something like "\\Borland\\Bcc55\\Include", a Python string. I want to use this "string" in a subprocess command as a parameter. Obviou

Re: How to change '\\' to '\'

2018-09-28 Thread Jach Fong
Yes, you are right, it's just the way Python display the '\'. Thank you. Gregory Ewing at 2018/9/28 PM 02:02 wrote: Jach Fong wrote: I get a string item, for example path[0], from path = os.get_exec_path() It's something like "\\Borland\\Bcc55\\Include" I

How to change '\\' to '\'

2018-09-27 Thread Jach Fong
I get a string item, for example path[0], from path = os.get_exec_path() It's something like "\\Borland\\Bcc55\\Include", a Python string. I want to use this "string" in a subprocess command as a parameter. Obviously this command can only recognize "\Borland\Bcc55\Include". I know there must have

Re: Debug script under pdb, how to avoid a bunch of errors caused by the exit()?

2018-09-06 Thread Jach Fong
nt Deleted breakpoint 1 at c:\test\buginpdb.py:3 > c:\test\buginpdb.py(3)() -> print('bad password') (Pdb) cont bad password The program exited via sys.exit(). Exit status: None > c:\test\buginpdb.py(1)() -> password = 'bad' (Pdb) q C:\test> O

Debug script under pdb, how to avoid a bunch of errors caused by the exit()?

2018-09-06 Thread Jach Fong
y.py", line 85, in _run_code exec(code, run_globals) File "C:\Python34\lib\pdb.py", line 1688, in pdb.main() File "C:\Python34\lib\pdb.py", line 1680, in main pdb.interaction(None, t) File "C:\Python34\lib\pdb.py", line 346, in interaction self._cmdloop() File "C:\Python34\lib\pdb.py", line 319, in _cmdloop self.cmdloop() File "C:\Python34\lib\cmd.py", line 126, in cmdloop line = input(self.prompt) ValueError: I/O operation on closed file. D:\Works\Python> How to get rid of these? Best Regards, Jach Fong --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list

Re: Why an object changes its "address" between adjacent calls?

2018-06-19 Thread Jach Fong
Terry Reedy at 2018/6/19 PM 08:35 wrote: On 6/18/2018 8:38 PM, sa...@caprilion.com.tw wrote: Grant Edwards at 2018/6/18 PM 10:36 wrote: On 2018-06-17, Jach Fong wrote: The "address" of the Font object 'TkDefaultFont' changes, why? What makes you think it's the sa

Re: Is it possible to call a class but without a new instance created?

2018-06-19 Thread Jach Fong
Jim Lee at 2018/6/19 PM 03:44 wrote: On 06/18/2018 09:22 PM, Jach Fong wrote: Ben Finney at 2018/6/19 PM 10:20 wrote: Jach Fong writes: Although it passed the first examination, I have no idea if it can work correctly in the real application:-) Neither do I. What is the real-world

Re: Is it possible to call a class but without a new instance created?

2018-06-18 Thread Jach Fong
Ben Finney at 2018/6/19 PM 10:20 wrote: Jach Fong writes: Although it passed the first examination, I have no idea if it can work correctly in the real application:-) Neither do I. What is the real-world problem you are trying to solve? Why do you think this (and not some more idiomatic

Re: Is it possible to call a class but without a new instance created?

2018-06-18 Thread Jach Fong
Ben Finney at 2018/6/18 PM 03:29 wrote: Jach Fong writes: I also make a test of my own and it fails too. class A: ... objs = [] ... def __init__(self, exists=False): ... if exists: self = self.objs[0] The function parameters (bound here to the names ‘self’, ‘exists

Re: Is it possible to call a class but without a new instance created?

2018-06-18 Thread Jach Fong
the correct value.  As others said, this is all handled in a __new__ method.  But none of this has much to do with tkinter instances. On 6/18/2018 5:09 AM, Terry Reedy wrote: On 6/18/2018 12:48 AM, Jach Fong wrote: After looking into the \tkiniter\font.py source file, triggered by Jim's hi

Is it possible to call a class but without a new instance created?

2018-06-17 Thread Jach Fong
lass A: ... objs = [] ... def __init__(self, exists=False): ... if exists: self = self.objs[0] ... else: self.objs.append(self) ... >>> a0 = A() >>> id(a0) 35569968 >>> a1 = A(exists=True) >>> id(a1) 35572336 What I expect is that id(a0) and

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Jach Fong
Steven D'Aprano at 2018/6/17 PM 04:19 wrote: On Sun, 17 Jun 2018 15:08:27 +0800, Jach Fong wrote: The "address" of the Font object 'TkDefaultFont' changes, why? Its not an address, it is an ID number. The ID number changes because you get a different object each t

Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Jach Fong
t;>> tk.Label(root, text='label one', font='TkDefaultFont').pack() >>> from tkinter import font >>> font.nametofont('TkDefaultFont') >>> font.nametofont('TkDefaultFont') >>> The "address" of the Font ob

Re: What is the "Unpacking Arguments List" rule?

2018-06-13 Thread Jach Fong
Alister via Python-list at 2018/6/13 PM 08:43 wrote: IMHO, there is no reason to check the *args has to appear at last in positional argument list in a function call because of there is no "unknown number of parameters" at the time of unpacking. It should be alright to write line 19 action(

What is the "Unpacking Arguments List" rule?

2018-06-03 Thread Jach Fong
ly unrelated. The "*any" notation used in different places with different meaning, such as defining arbitrary argument, unpacking argument or even in an assignment(a,*b=any). Maybe it will be better to stop this syntax checking and lets both statements below valid:-) acti

Re: How can an int be '+' with a tuple?

2018-06-03 Thread Jach Fong
On Sun, 03 Jun 2018 10:55:04 +0800, Jach Fong wrote: The attached is a script which can run under Python 3.4/Windows Vista correctly. One thing make me puzzled is that the "any + context" at line 18. The "any" was passed as an integer from line 43 and the "context" was

Re: How can an int be '+' with a tuple?

2018-06-02 Thread Jach Fong
jf...@ms4.hinet.net wrote: The attached is a script which can run under Python 3.4/Windows Vista correctly. One thing make me puzzled is that the "any + context" at line 18. The "any" was passed as an integer from line 43 and the "context" was defined as a tuple at li

Re: How can an int be '+' with a tuple?

2018-06-02 Thread Jach Fong
# 3.x need list for map, range ok lambda event: list(map(onEvent, range(2))) ) root.mainloop() Ben Finney 於 2018/6/3 上午 11:57 寫道: Jach Fong writes: The attached is a script Thanks for making an example script. Instead of attaching it, please post it along with your me

Re: How can an int be '+' with a tuple?

2018-06-02 Thread Jach Fong
run under Python 3.4/Windows Vista correctly. One thing make me puzzled is that the "any + context" at line 18. The "any" was passed as an integer from line 43 and the "context" was defined as a tuple at line 35. This concatenation works! how? Best Regards, Jach Fong --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list

How can an int be '+' with a tuple?

2018-06-02 Thread Jach Fong
tion works! how? Best Regards, Jach Fong --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus import _thread as thread import queue threadQueue = queue.Queue(maxsize=0) def queueChecker(wi

Re: why does list's .remove() does not return an object?

2018-05-17 Thread Jach Fong
Abdur-Rahmaan Janhangeer at 2018/5/17 PM 04:23 wrote: if then a more convenient way might be found to naturally remove and return the list maybe it was not included as one might want to remove the list only x = [1] x.remove(1) as opposed to x = [1] x.remove(1) new_list = x IMO, this way is

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

2018-04-14 Thread Jach Fong
Gregory Ewing at 2018/4/15 PM 08:20 wrote: Jach Fong wrote:  >>> pvoid = ctypes.c_void_p(ctypes.addressof(buf0))  >>> pvoid.contents Traceback (most recent call last):   File "", line 1, in AttributeError: 'c_void_p' object has no attribute 'conten

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

2018-04-13 Thread Jach Fong
eryk sun at 2018/4/14 PM 05:27 wrote: On Fri, Apr 13, 2018 at 8:44 AM, Jach Fong wrote: After studying the example you explained in your previous post replied to Gregory Ewing, I had noticed that until today I was totally misunderstand the meaning of the c_char_p. I always think it "

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

2018-04-13 Thread Jach Fong
eryk sun at 2018/4/13 PM 12:16 wrote: On Fri, Apr 13, 2018 at 12:38 AM, Jach Fong wrote: Gregory Ewing at 2018/4/13 上午 07:25 wrote: To get around this, you may need to declare the return type as POINTER(c_char) instead: For a general character pointer that may also point to binary data

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

2018-04-12 Thread Jach Fong
Gregory Ewing at 2018/4/13 上午 07:25 wrote: 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. I think we need to see the co

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

2018-04-12 Thread Jach Fong
This is the first time I am using python-list to interact with comp.lang.python forum (because there are so many spam when using browser to view it) so forgive me if something goes wrong. Python already treat the returned buffer as 'bytes'. The problem is Python don't know its size (or decides