Re: a heisenbug

2017-08-28 Thread Peter Otten
Steve D'Aprano wrote: > On Tue, 29 Aug 2017 07:09 am, Peter Otten wrote: > >> The lesson is that if you use a (sub)module you should never rely on an >> implicit import. > > ... unless the module is documented as automatically importing the > submodule. An example is os.path. os.path is the onl

Re: tkinter keypress events are a mess for numpad keys

2017-08-28 Thread Terry Reedy
On 8/28/2017 7:20 PM, Irmen de Jong wrote: Hi, Using tkinter in python3, I was trying to intercept individual keypresses (and releases) of keys on the numeric keypad. I want to use this as a simple joystick simulation. While you can bind the event, actually doing something sensible with it i

Re: doctest random output?

2017-08-28 Thread Chris Angelico
On Tue, Aug 29, 2017 at 11:53 AM, Steve D'Aprano wrote: > (1) Disable doctesting for that example, and treat it as just documentation: > > def my_thing(): > """blah blah blah > > >>> my_thing() #doctest:+SKIP > 4 > > """ For a lot of functions, this completely destroys the value

Re: doctest random output?

2017-08-28 Thread Steve D'Aprano
On Mon, 28 Aug 2017 07:41 pm, Leam Hall wrote: > Is this a good way to test if random numeric output? It seems to work > under Python 2.6 and 3.6 but that doesn't make it 'good'. That depends on what you are actually testing. If you are intending to test the statistical properties of random, goog

Re: Quiz: Difference between implicit and explicit inheritence

2017-08-28 Thread Steve D'Aprano
On Mon, 28 Aug 2017 11:27 pm, Pavol Lisy wrote: > object = int # this could be trick > ... > class Spam(object): > ... > > dis.dis show difference too, next line is just for "class > Spam(object):" version: > LOAD_GLOBAL 0 (object) > > So nor rebinding object nor rebinding

Re: a heisenbug

2017-08-28 Thread Steve D'Aprano
On Tue, 29 Aug 2017 07:09 am, Peter Otten wrote: > The lesson is that if you use a (sub)module you should never rely on an > implicit import. ... unless the module is documented as automatically importing the submodule. An example is os.path. -- Steve “Cheer up,” they said, “things could be wo

Re: Protocols in Python

2017-08-28 Thread Ian Kelly
On Mon, Aug 28, 2017 at 12:53 PM, Stefan Ram wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: >>The "The Python Library Reference, Release 3.6.0" (LIB) says: >>»it must support the sequence protocol (the >>__getitem__() method with integer arguments >>starting at 0).«. >>But in the "The Pytho

tkinter keypress events are a mess for numpad keys

2017-08-28 Thread Irmen de Jong
Hi, Using tkinter in python3, I was trying to intercept individual keypresses (and releases) of keys on the numeric keypad. I want to use this as a simple joystick simulation. While you can bind the event, actually doing something sensible with it in a cross platform way seems utterly impossib

Re: a heisenbug

2017-08-28 Thread Chris Angelico
On Tue, Aug 29, 2017 at 9:03 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> It's a bit surprising but only an issue with interactive work. >> (You won't use help() elsewhere.) > > > Unless you decide to put help(collections) at the top > of your program because it makes the bug go away. :-

Re: a heisenbug

2017-08-28 Thread Gregory Ewing
Chris Angelico wrote: It's a bit surprising but only an issue with interactive work. (You won't use help() elsewhere.) Unless you decide to put help(collections) at the top of your program because it makes the bug go away. :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Send mouse clicks to minimized window

2017-08-28 Thread Matt Wheeler
On Mon, 28 Aug 2017 at 12:30 wrote: > I'm using python to automate some seriously boring stuff at work, but > would like to improve current code. > > The way it is now, PyAutoGui moves mouse and clicks the Application. I am, > therefore, hostage of my python "assistant", as I cannot use my comput

Re: a heisenbug

2017-08-28 Thread Peter Otten
Chris Angelico wrote: > On Tue, Aug 29, 2017 at 4:59 AM, Stefan Ram > wrote: >> This might be what one calls "heisenbug": >> >> No attribute 'abc' is visible. One tries to >> study it with "help". And next time it's there. >> "help" /did/ help! >> >> Python 3.6.0 ... >> > import colle

Re: A vocabulary trainer

2017-08-28 Thread Peter Otten
Stefan Ram wrote: > My course participants always are impatient for "useful > applications". So at a point in my course where no control > structures (if, for, while, ...) have been introduced yet, > but function calls, function declarations, assignments, > lists and dictionaries already

Re: A vocabulary trainer

2017-08-28 Thread Chris Angelico
On Tue, Aug 29, 2017 at 5:42 AM, Stefan Ram wrote: > def main(): > v = random.choice( list( vocs.keys() )) Should be able to just use list(vocs) here. > print( v, end='' ) > input() input(v) should do the same job of issuing a prompt. > print( vocs[ v ]); > main() > Are t

Re: a heisenbug

2017-08-28 Thread Chris Angelico
On Tue, Aug 29, 2017 at 4:59 AM, Stefan Ram wrote: > This might be what one calls "heisenbug": > > No attribute 'abc' is visible. One tries to > study it with "help". And next time it's there. > "help" /did/ help! > > Python 3.6.0 ... > import collections > isinstance( 'abc', col

Re: Protocols in Python

2017-08-28 Thread Chris Angelico
On Tue, Aug 29, 2017 at 4:53 AM, Stefan Ram wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: >>The "The Python Library Reference, Release 3.6.0" (LIB) says: >>»it must support the sequence protocol (the >>__getitem__() method with integer arguments >>starting at 0).«. >>But in the "The Python

Re: doctest random output?

2017-08-28 Thread Leam Hall
On 08/28/2017 11:40 AM, Dennis Lee Bieber wrote: ... a bunch of good stuff ... I'm (re-)learning python and just trying make sure my function works. Not at the statistical or cryptographic level. :) Thanks! Leam -- https://mail.python.org/mailman/listinfo/python-list

Re: Quiz: Difference between implicit and explicit inheritence

2017-08-28 Thread Pavol Lisy
On 8/28/17, Steven D'Aprano wrote: > In Python 3, what's the difference between these two classes? > # implicitly inherit from object > class Spam: > ... > > # explicitly inherit from object > class Spam(object): > ... > > If you sense a trick question, you're right :-) > object = int #

Send mouse clicks to minimized window

2017-08-28 Thread gabriel . lins97
Hello, guys I'm using python to automate some seriously boring stuff at work, but would like to improve current code. The way it is now, PyAutoGui moves mouse and clicks the Application. I am, therefore, hostage of my python "assistant", as I cannot use my computer while the .py is running. I

Re: doctest random output?

2017-08-28 Thread Peter Otten
Leam Hall wrote: > Is this a good way to test if random numeric output? It seems to work > under Python 2.6 and 3.6 but that doesn't make it 'good'. > > ### Code > import random > > def my_thing(): >""" Return a random number from 1-6 >>>> 0 < my_thing() <=6 >True >>>> 6 < my_th

resume

2017-08-28 Thread Gayu anbu
hi, i am gayathri,studying final year It.i want one page resume please any one send me template -- https://mail.python.org/mailman/listinfo/python-list

doctest random output?

2017-08-28 Thread Leam Hall
Is this a good way to test if random numeric output? It seems to work under Python 2.6 and 3.6 but that doesn't make it 'good'. ### Code import random def my_thing(): """ Return a random number from 1-6 >>> 0 < my_thing() <=6 True >>> 6 < my_thing() False """ return random.randi

Re: Need advice on writing better test cases.

2017-08-28 Thread Anubhav Yadav
> A good way to learn unit testing and regression testing is to download > the Python source code and read the test suites. It’s a fantastic idea. I will also have a good understanding of the internals of the standard library and at I can learn more about testing. Any specific module that you

Re: Need advice on writing better test cases.

2017-08-28 Thread Steven D'Aprano
On Mon, 28 Aug 2017 01:55:25 +0530, Anubhav Yadav wrote: > Can you suggest me the right python testing frameworks that I should be > using? Right now I am using unittest to write test cases and manual > if/else statements to run the functional test cases. A good way to learn unit testing and reg

Re: Need advice on writing better test cases.

2017-08-28 Thread Anubhav Yadav
> If you have a function and you want to assert *that function's* > behaviour, you can avoid external dependencies during the test run by > providing fake resources. These can be mocks (e.g. with ‘unittest.mock’) > or other fake resources that are going to behave exactly how you want, > for the pu

Re: Need advice on writing better test cases.

2017-08-28 Thread Anubhav Yadav
> On 28-Aug-2017, at 04:35, Ben Finney wrote: > > Anubhav Yadav writes: > >> I want to write more test cases, specially that rely on database >> insertions and reads and file IO. > > Thanks for taking seriously the importance of test cases for your code! > > One important thing to recognise

Quiz: Difference between implicit and explicit inheritence

2017-08-28 Thread Steven D'Aprano
In Python 3, what's the difference between these two classes? # implicitly inherit from object class Spam: ... # explicitly inherit from object class Spam(object): ... S P O I L E R S P A C E If you sense a trick question, you're right :-) -- “You are deluded if you think