question on callback functions with ctypes

2020-06-20 Thread oyster
question on callback functions with ctypes I try to use GoVCL( https://github.com/ying32/govcl ) in python via ctypes. GoVCL supplies C header and simple C demo under https://github.com/ying32/govcl/tree/master/Tools/makeCHeader/test Now the simple python code can run on both win7 and win10 accor

Re: how to let argument be optional falling back to certain integer

2020-06-20 Thread Chris Angelico
On Sun, Jun 21, 2020 at 10:06 AM Boris Dorestand wrote: > > Chris Angelico writes: > > Zero being false shouldn't be a surprise. If None can count as false, > > then so should other "emptiness" values. (Remember, the canonical > > falseness value is False, not None.) > > This is true. I have wri

Re: how to let argument be optional falling back to certain integer

2020-06-20 Thread Boris Dorestand
Chris Angelico writes: > On Sun, Jun 21, 2020 at 2:02 AM Boris Dorestand > wrote: >> >> I just wrote >> >> def f(y, N, k = None): >> k = k or (N - 1) >> return k >> >> I was surprised to find out that 0 == False, so f(7, 31, 0) produces 31. >> >> I'd like 0 to be a valid choice for k. >> >>

Re: how to let argument be optional falling back to certain integer

2020-06-20 Thread Python
Le 20/06/2020 à 18:23, Stefan Ram a écrit : Boris Dorestand writes: def f(y, N, k = None): k = k or (N - 1) return k I was surprised to find out that 0 == False, so f(7, 31, 0) produces 31. bool is a subtype of int. I'd like 0 to be a valid choice for k. k = N-1 if k==None else k

Re: how to let argument be optional falling back to certain integer

2020-06-20 Thread Chris Angelico
On Sun, Jun 21, 2020 at 2:02 AM Boris Dorestand wrote: > > I just wrote > > def f(y, N, k = None): > k = k or (N - 1) > return k > > I was surprised to find out that 0 == False, so f(7, 31, 0) produces 31. > > I'd like 0 to be a valid choice for k. > > How do you guys let k be an optional argu

how to let argument be optional falling back to certain integer

2020-06-20 Thread Boris Dorestand
I just wrote def f(y, N, k = None): k = k or (N - 1) return k I was surprised to find out that 0 == False, so f(7, 31, 0) produces 31. I'd like 0 to be a valid choice for k. How do you guys let k be an optional argument such that it defaults to N - 1? Thank you. -- https://mail.pytho

Re: How to test?

2020-06-20 Thread Mats Wichmann
On 5/1/20 2:34 PM, DL Neil via Python-list wrote: >>> Given your replies, 'now' might be a good time to take a look at >>> Pytest, and see how you could use it to help build better code - by >>> building tested units/functions which are assembled into ever-larger >>> tested-units... (there is a ran

Re: How to test?

2020-06-20 Thread Stephen Rosen
Worth noting: by assertTrue he probably meant assertEqual. But I'd recommend using assertIn [1] if you're using unittest to check output written to stdout/stderr. That way, your tests are slightly more robust to changes in the exact output. pytest may also be helpful for this (or any!) type of te