Re: Call for Assistance

2016-08-11 Thread Andreas Röhler
On 12.08.2016 06:48, Lawrence D’Oliveiro wrote: On Wednesday, August 10, 2016 at 3:42:39 AM UTC+12, Reto Brunner wrote: What on earth isn't "free" enough about You are free to: Share — copy and redistribute the material in any medium or format No you are not. A court has ruled

Re: Asynchronous programming

2016-08-11 Thread Paul Rudin
Steven D'Aprano writes: > Thanks to everyone who has answered, I think I'm slowly starting to get it > now. Let's see if we can come up with a toy example that doesn't involve > low-level socket programming :-) > > Let me simulate a slow function call: > > > import random, time > > def work(id):

Re: Call for Assistance

2016-08-11 Thread Paul Rubin
Charles Ross writes: > Well, I’ve been convinced. The license for the book is now Creative > Commons Attribution-ShareAlike. That means you can post it on wikibooks.org and let people edit it directly, if you want. Wikibooks is nowhere near as crazy as wikipedia. -- https://mail.python.org/mail

Re: Asynchronous programming

2016-08-11 Thread Paul Rubin
Steven D'Aprano writes: > How do I write work() so that it cooperatively multi-tasks with other ... > threads? processes? what the hell do we call these things? What does this > example become in the asynchronous world? If it's heavily computational then you have to yield to the scheduler frequen

Re: Call for Assistance

2016-08-11 Thread Lawrence D’Oliveiro
On Wednesday, August 10, 2016 at 1:09:31 PM UTC+12, Charles Ross wrote: > Well, I’ve been convinced. The license for the book is now Creative > Commons Attribution-ShareAlike. Great. :) That’s the one to use if you are worried about companies who want something for nothing coming in and ripping

Re: Call for Assistance

2016-08-11 Thread Lawrence D’Oliveiro
On Wednesday, August 10, 2016 at 3:42:39 AM UTC+12, Reto Brunner wrote: > What on earth isn't "free" enough about > > You are free to: > Share — copy and redistribute the material in any medium or format No you are not. A court has ruled

Re: python 3.5.2 lounch: api-ms-win-crt-runtime-l1-1-0.dll is missing ?

2016-08-11 Thread Lawrence D’Oliveiro
On Tuesday, August 9, 2016 at 6:46:52 AM UTC+12, Joaquin Alzola wrote: > This email is confidential and may be subject to privilege. If you are not > the intended recipient, please do not copy or disclose its content but > contact the sender immediately upon receipt. Consider yourself contacted!

Re: Asynchronous programming

2016-08-11 Thread Lawrence D’Oliveiro
On Friday, August 12, 2016 at 2:25:05 AM UTC+12, Terry Reedy wrote: > When I read something like "Python finally acquired an event loop in > 3.4" I wonder where people have been. The tk event loop has been in > Python perhaps for 2 decades... As was pointed out to me just a few days ago, that’

Re: Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Lawrence D’Oliveiro
On Friday, August 12, 2016 at 1:28:04 AM UTC+12, Cecil Westerhof wrote: > As I understood it getopt is the way to get the parameters for your > script. But at the moment it looks a bit like overkill, my script does > not have much parameters as parameter_error shows: That’s fine. But your command

Re: Asynchronous programming

2016-08-11 Thread Chris Angelico
On Fri, Aug 12, 2016 at 10:08 AM, Steven D'Aprano wrote: > Let me simulate a slow function call: > > > import random, time > > def work(id): > print("starting with id", id) > workload = random.randint(5, 15) > for i in range(workload): > time.sleep(0.2) # pretend to do some re

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
Thanks to everyone who has answered, I think I'm slowly starting to get it now. Let's see if we can come up with a toy example that doesn't involve low-level socket programming :-) Let me simulate a slow function call: import random, time def work(id): print("starting with id", id) work

Re: A strange list concatenation result

2016-08-11 Thread Steven D'Aprano
Note that your subject line is wrong. You are not doing list concatenation. Unfortunately, for technical and optimization reasons, the += assignment operator for lists is in-place, which means that it is NOT the same as ordinary list concatenation + operator. It is equivalent to calling the list.e

OT Winmx works again

2016-08-11 Thread Seymore4Head
-- https://mail.python.org/mailman/listinfo/python-list

Re: Generate reports in Python

2016-08-11 Thread Lawrence D’Oliveiro
On Thursday, August 11, 2016 at 8:30:42 PM UTC+12, wxjm...@gmail.com wrote: > I do not see to much how a library can beat that approach, unless it > duplicates what TeX does. TEX may be fine for more free-form text, but often reports take a more structured layout than that--fixed columns etc. Fo

Re: A strange list concatenation result

2016-08-11 Thread Gary Herron
On 08/11/2016 03:06 PM, Mok-Kong Shen wrote: def test(list1,list2): list1+=[4,5,6] list2=list2+[4,5,6] print("inside ",list1,list2) return # With list1=list2=[1,2,3] test(list1,list2) print("outside",list1,list2) # I got the following: # inside [1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6, 4

A strange list concatenation result

2016-08-11 Thread Mok-Kong Shen
def test(list1,list2): list1+=[4,5,6] list2=list2+[4,5,6] print("inside ",list1,list2) return # With list1=list2=[1,2,3] test(list1,list2) print("outside",list1,list2) # I got the following: # inside [1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6, 4, 5, 6] # outside [1, 2, 3, 4, 5, 6] [1, 2, 3,

Re: ctypes And The WACAH Principle

2016-08-11 Thread MRAB
On 2016-08-11 20:41, Roel Schroeven wrote: Lawrence D’Oliveiro schreef op 2016-08-10 03:45: ... so WACAH very much applies here. Pardon my ignorance, but what is the WACAH Principle? I believe he means "€œWe're All Consenting Adults Here". (I don't think I've ever seen that acronym before.)

Re: ctypes And The WACAH Principle

2016-08-11 Thread Roel Schroeven
Lawrence D’Oliveiro schreef op 2016-08-10 03:45: ... so WACAH very much applies here. Pardon my ignorance, but what is the WACAH Principle? -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- https

Re: What's the best way to minimize the need of run time checks?

2016-08-11 Thread Russell Owen
On 8/10/16 3:44 PM, Juan Pablo Romero Méndez wrote: As to why I asked that, there are several reasons: I have a very concrete need right now to find pragmatic ways to increase code quality, reduce number of defects, etc. in a Python code base. But also I want to understand better the mind set and

Re: Print function not working

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 1:38 PM MRAB wrote: > On 2016-08-11 18:18, Chris Angelico wrote: > > On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra > > wrote: > >> I have installed IDLE 3.5.1 and wrote the following to check if print > is working. When it runs, I do not see anything is printed: > >> >

Re: Asynchronous programming

2016-08-11 Thread Paul Rubin
Steven D'Aprano writes: > But what's the point in doing it asynchronously if I have to just wait for > it to complete? > begin downloading in an async thread > twiddle thumbs, doing nothing > process download Suppose the remote server is overloaded so it sends files much slower than your in

Re: Print function not working

2016-08-11 Thread MRAB
On 2016-08-11 18:18, Chris Angelico wrote: On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra wrote: I have installed IDLE 3.5.1 and wrote the following to check if print is working. When it runs, I do not see anything is printed: class Base: #{ def __init__( self ): #{ print("Hello

Re: Print function not working

2016-08-11 Thread Peter Otten
Atri Mahapatra wrote: > I have installed IDLE 3.5.1 and wrote the following to check if print is > working. When it runs, I do not see anything is printed: > > class Base: #{ > def __init__( self ): #{ > print("Hello, world: \n\n"); > > #} > > #} > > > if ( __name__ =

Re: Print function not working

2016-08-11 Thread Chris Angelico
On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra wrote: > I have installed IDLE 3.5.1 and wrote the following to check if print is > working. When it runs, I do not see anything is printed: > > class Base: #{ > def __init__( self ): #{ > print("Hello, world: \n\n"); > > #} > >

Print function not working

2016-08-11 Thread Atri Mahapatra
I have installed IDLE 3.5.1 and wrote the following print command to see if it is working. When I ran the code nothing is printed. Can you please point the reason- anything wrong with the code? class Base: #{ def __init__( self ): #{ print("Hello, world: \n\n"); #} #}

Print function not working

2016-08-11 Thread Atri Mahapatra
I have installed IDLE 3.5.1 and wrote the following to check if print is working. When it runs, I do not see anything is printed: class Base: #{ def __init__( self ): #{ print("Hello, world: \n\n"); #} #} if ( __name__ == " __main__"): #{ root = Base(); #} Can an

Re: Asynchronous programming

2016-08-11 Thread Chris Angelico
On Fri, Aug 12, 2016 at 12:55 AM, Steven D'Aprano wrote: > On Thu, 11 Aug 2016 02:41 pm, Chris Angelico wrote: > >> Consider these three ways of doing a database transaction: >> >> def synchronous(id): >> trn = conn.begin_transaction() >> trn.execute("select name from people where id=%d",

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 03:34 pm, Paul Rudin wrote: > Steven D'Aprano writes: > >> >> Is there a good beginner's tutorial introducing the basics of >> asynchronous programming? Starting with, why and where would you use it? > > You could do worse than watch Dave Beazley's pycon talk: > https://www.

Re: Asynchronous programming

2016-08-11 Thread Paul Rudin
Steven D'Aprano writes: > > But what's the point in doing it asynchronously if I have to just wait for > it to complete? > > begin downloading in an async thread > twiddle thumbs, doing nothing > process download If you have nothing else to do, then there's no point. But suppose you're im

Re: Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Cecil Westerhof
On Thursday 11 Aug 2016 17:15 CEST, Cecil Westerhof wrote: > On Thursday 11 Aug 2016 16:29 CEST, Peter Otten wrote: > >> Cecil Westerhof wrote: >> >>> It has been a while since I worked with Python. I wanted to get >>> some stats about the idle time of my computer, so that was a good >>> moment to

Re: Advice on optimizing a Python data driven rules engine

2016-08-11 Thread Chris Angelico
On Fri, Aug 12, 2016 at 12:56 AM, Malcolm Greene wrote: > Looking for some advice on how to optimize the BOILERPLATE portions of > the following type of code. There's an awful lot of dot dereferencing > going on. One thought was to pass in the values being dereferenced as > parameters and return v

Re: Asynchronous programming

2016-08-11 Thread Jussi Piitulainen
Michael Selik writes: > On Thu, Aug 11, 2016 at 11:46 AM Michael Selik > wrote: > >> On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano < >> steve+pyt...@pearwood.info> wrote: >> >>> That ... looks wrong. You're taking something which looks like a procedure >>> in the first case (trn.execute), so

Re: Asynchronous programming

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 11:46 AM Michael Selik wrote: > On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano < > steve+pyt...@pearwood.info> wrote: > >> That ... looks wrong. You're taking something which looks like a procedure >> in the first case (trn.execute), so it probably returns None, and yiel

Re: Asynchronous programming

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano wrote: > That ... looks wrong. You're taking something which looks like a procedure > in the first case (trn.execute), so it probably returns None, and yielding > over it. Even it that's not wrong, and it actually returned something which > you ign

Re: Advice on optimizing a Python data driven rules engine

2016-08-11 Thread Michael Selik
On Thu, Aug 11, 2016 at 10:57 AM Malcolm Greene wrote: > Background: I'm building a rules engine for transforming rows of data > being returned by csv DictReader, eg. each row of data is a dict of column > name to value mappings. My rules are a list of rule objects whose > attributes get referen

Re: Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Cecil Westerhof
On Thursday 11 Aug 2016 16:29 CEST, Peter Otten wrote: > Cecil Westerhof wrote: > >> It has been a while since I worked with Python. I wanted to get >> some stats about the idle time of my computer, so that was a good >> moment to pick up Python again. ;-) >> >> >> As I understood it getopt is the

Re: Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 11:23 pm, Cecil Westerhof wrote: > It has been a while since I worked with Python. I wanted to get some > stats about the idle time of my computer, so that was a good moment to > pick up Python again. ;-) > > > As I understood it getopt is the way to get the parameters for yo

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 02:41 pm, Chris Angelico wrote: > Consider these three ways of doing a database transaction: > > def synchronous(id): > trn = conn.begin_transaction() > trn.execute("select name from people where id=%d", (id,)) > name, = trn.fetchone() > trn.execute("update peo

Advice on optimizing a Python data driven rules engine

2016-08-11 Thread Malcolm Greene
Background: I'm building a rules engine for transforming rows of data being returned by csv DictReader, eg. each row of data is a dict of column name to value mappings. My rules are a list of rule objects whose attributes get referenced by rule specific methods. Each rule has an associated meth

Re: Asynchronous programming

2016-08-11 Thread Marko Rauhamaa
Steven D'Aprano : > Say I want to download data from a network, and it will take a long > time. If I can do the read in parallel to something else, that makes > sense: > > begin downloading in another thread/process > make a coffee > process download > > But what's the point in doing it asyn

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 03:06 pm, Paul Rubin wrote: > The basic characteristic of asynchronous programming is that it involves > changing all your usual blocking i/o calls to non-blocking ones, so your > program can keep running as soon as your request is started. That's the bit that confuses me. I u

Re: Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Peter Otten
Cecil Westerhof wrote: > It has been a while since I worked with Python. I wanted to get some > stats about the idle time of my computer, so that was a good moment to > pick up Python again. ;-) > > > As I understood it getopt is the way to get the parameters for your > script. But at the moment

Re: Asynchronous programming

2016-08-11 Thread Marko Rauhamaa
Steven D'Aprano : > Instructions unclear, poked myself in the eye with a sharp stick. I have updated my Dining Philosophers example for Python 3.5: http://pacujo.net/~marko/philosophers.py> It demonstrates how to get an event loop and start a number of asyncs concurrently. Marko -- https:

Re: Asynchronous programming

2016-08-11 Thread Terry Reedy
On 8/11/2016 2:34 AM, Christian Gollwitzer wrote: Am 11.08.16 um 06:38 schrieb Terry Reedy: You might be able to glean something from the succession of files I uploaded to https://bugs.python.org/issue27546 Integrate tkinter and asyncio (and async) I started with just mixing tk and asyncio call

Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Cecil Westerhof
It has been a while since I worked with Python. I wanted to get some stats about the idle time of my computer, so that was a good moment to pick up Python again. ;-) As I understood it getopt is the way to get the parameters for your script. But at the moment it looks a bit like overkill, my scri

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 07:33 pm, Chris Angelico wrote: > Yes, > threading bugs can be harder to debug; but only when you've violated > the other principles. Especially the principle "Avoid threaded programming". Some people, when faced with a problem, Now they think "I know, I'll have use two thre

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 03:34 pm, Paul Rudin wrote: > Steven D'Aprano writes: > >> >> Is there a good beginner's tutorial introducing the basics of >> asynchronous programming? Starting with, why and where would you use it? > > You could do worse than watch Dave Beazley's pycon talk: > https://www.

Re: Asynchronous programming

2016-08-11 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Aug 11, 2016 at 5:55 PM, Marko Rauhamaa wrote: >> My favorite asynchronous development model is the "callback hell," where >> each cell of the state/event matrix is represented by a method (or at >> least a switch case in C) and each state has an explicit name in the >>

Re: Asynchronous programming

2016-08-11 Thread Paul Rudin
Chris Angelico writes: > On Thu, Aug 11, 2016 at 7:45 PM, Steven D'Aprano > wrote: >> I don't know whether you would call that a callback. I suppose it could be, >> in >> the sense that you might say: >> >> button.set_mouseup_function(mouseUp) >> >> but I'm used to thinking of it as a prope

Re: Asynchronous programming

2016-08-11 Thread Chris Angelico
On Thu, Aug 11, 2016 at 7:45 PM, Steven D'Aprano wrote: > I don't know whether you would call that a callback. I suppose it could be, in > the sense that you might say: > > button.set_mouseup_function(mouseUp) > > but I'm used to thinking of it as a property of the button. "Callback" simply m

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thursday 11 August 2016 16:21, Christian Gollwitzer wrote: > In typical GUI code, there are usually not that many places qhere ou > have sequential code. A simple exmaple might be a counter. Using asyncio > and a properly integrated GUI toolkit, you could write it as (pseudo-code) > > async de

Re: Asynchronous programming

2016-08-11 Thread Chris Angelico
On Thu, Aug 11, 2016 at 5:55 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> Hmm. I'm not sure about that last bit. In order to properly support >> asynchronous I/O and the concurrency and reentrancy that that implies, >> you basically need all the same disciplines that you would for >> threaded

Re: Asynchronous programming

2016-08-11 Thread Marko Rauhamaa
Chris Angelico : > Hmm. I'm not sure about that last bit. In order to properly support > asynchronous I/O and the concurrency and reentrancy that that implies, > you basically need all the same disciplines that you would for > threaded programming Correct. Python's asyncio closely mirrors threads

Re: Python slang

2016-08-11 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > On Thursday, August 11, 2016 at 7:18:28 AM UTC+12, Marko Rauhamaa wrote: > >> Oh, there's of course COBOL: >> >>ADD X TO Y GIVING RESULT > > I think COBOL has the same usage of “=” as BASIC, as assignment or > equality comparison, depending on context. There's the COM

Re: Asynchronous programming

2016-08-11 Thread Paul Rubin
Christian Gollwitzer writes: > I'm convinced that it is possible to integrate Tcl's event loop with > asyncio's loop without regular update polling. This might require a > patch to Tkinter at the C level. For example, an easy way is to put > Tcl/Tk in it's own thread. ... I did something like tha