asyncio and blocking - an update

2016-02-08 Thread Frank Millman
Hi all Some of you may have been following my attempts to modify my asyncio app so that it does not block when accessing the database. Here is an update. I came up with what felt like a good idea. Run the database handler in a separate thread, pass requests to it using a queue.Queue, and get

Re: Set Operations on Dicts

2016-02-08 Thread Grobu
On 08/02/16 17:12, Ian Kelly wrote: dict does already expose set-like views. How about: {k: d[k] for k in d.keys() & s} # d & s {k: d[k] for k in d.keys() - s} # d - s Interesting. But seemingly only applies to Python 3. -- https://mail.python.org/mailman/listinfo/python-list

Re: A sets algorithm

2016-02-08 Thread Gregory Ewing
Chris Angelico wrote: hash_to_filename = defaultdict(list) for fn in files: # Step 1: Hash every file. hash = calculate_hash(fn) # Step 2: Locate all pairs of files with identical hashes hash_to_filename[hash].append(fn) I think you can avoid hashing the files altogether. Firs

Re: A sets algorithm

2016-02-08 Thread Chris Angelico
On Tue, Feb 9, 2016 at 3:13 PM, Steven D'Aprano wrote: > On Tuesday 09 February 2016 02:11, Chris Angelico wrote: > >> That's fine for comparing one file against one other. He started out >> by saying he already had a way to compare files for equality. What he >> wants is a way to capitalize on th

Re: Heap Implementation

2016-02-08 Thread Cem Karan
On Feb 8, 2016, at 10:12 PM, srinivas devaki wrote: > > On Feb 8, 2016 5:17 PM, "Cem Karan" wrote: > > > > On Feb 7, 2016, at 10:15 PM, srinivas devaki > > wrote: > > > On Feb 8, 2016 7:07 AM, "Cem Karan" wrote: > > > > I know that there are methods of handling this from the client-side >

from scipy.linalg import _fblas ImportError: DLL load failed: The specified module could not be found.

2016-02-08 Thread Mike S via Python-list
I have Python 3.4.4 installed on Windows 7, also IPython, scipy, numpy, statsmodels, and a lot of other modules, and am working through this tutorial http://www.analyticsvidhya.com/blog/2016/02/time-series-forecasting-codes-python/ In Ipython notebook I run this code from statsmodels.tsa.statt

Re: A sets algorithm

2016-02-08 Thread Steven D'Aprano
On Tuesday 09 February 2016 02:11, Chris Angelico wrote: > That's fine for comparing one file against one other. He started out > by saying he already had a way to compare files for equality. What he > wants is a way to capitalize on that to find all the identical files > in a group. A naive appro

Re: Heap Implementation

2016-02-08 Thread srinivas devaki
On Feb 8, 2016 5:17 PM, "Cem Karan" wrote: > > On Feb 7, 2016, at 10:15 PM, srinivas devaki wrote: > > On Feb 8, 2016 7:07 AM, "Cem Karan" wrote: > > > I know that there are methods of handling this from the client-side (tuples with unique counters come to mind), but if your library can handle i

Re: Help using Thread (or other method)

2016-02-08 Thread Chris Angelico
On Tue, Feb 9, 2016 at 7:59 AM, Brendan Simon (eTRIX) wrote: > My application mainloop (not the threads) needs to be high priority and > always process as soon as it gets an interrupt. Is using select a good > way of doing this? How can I ensure that no other threads are utilizing > the CPU, etc

Re: Searching Sets (Lottery Results)

2016-02-08 Thread Chris Angelico
On Tue, Feb 9, 2016 at 8:45 AM, MrPink wrote: > I load the lottery drawings into memory for searching with the following code > although, it is incomplete. I am stuck and need some guidance. > > The set datatype seems to be the best for searching, but how best can I > implement it? > > And I wa

Re: trouble installing python

2016-02-08 Thread Oscar Benjamin
On 7 Feb 2016 09:50, "donald alsept via Python-list" wrote: > > Hello, > I'm trying to install the 3.5.1 of Python and am running windows 7. I keep getting an error about api-ms-win-crt-runtime-|1-1-0.dll not being installed. Any advice on what is wrong? Hi Donald, you're seeing this problem beca

Re: Set Operations on Dicts

2016-02-08 Thread Ben Finney
Marco Kaulea writes: > In one talk (I think it was [1]) it was described that sets are basically > dicts without the values. It seems an unhelpful thing to say about ‘set’, I disagree with that characterisation. > Therefor it should be easy to apply set operations on dicts Yes, that's one reas

Asyncio thought experiment

2016-02-08 Thread Marko Rauhamaa
As I stated in an earlier post, a normal subroutine may turn out to be blocking. To make it well-behaved under asyncio, you then dutifully tag the subroutine with "async" and adorn the blocking statement with "await". Consequently, you put "await" in front of all calls to the subroutine and cascad

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 2:17 AM, Veek. M wrote: > > Exceptions can be raised inside a coroutine using the throw( > > Exceptions raised in this manner will originate at the currently > executing yield state-ment in the coroutine.A coroutine can elect to > catch exception

Searching Sets (Lottery Results)

2016-02-08 Thread MrPink
This is a continuation of my pursuit to learn Python. I have been tinkering with this for a number of years and I am back at it again. I am stuck and need some guidance. This is related to other posts that I have made in the past. For example: Searching for Lottery drawing list of ticket matc

Re: Help using Thread (or other method)

2016-02-08 Thread Marko Rauhamaa
"Brendan Simon (eTRIX)" : > Is using `select` here redundant? Yes, if you go the thread way, select() is usually redundant and just gets in the way. > Does readline block until it sees an end-of-line char? i.e. does it > only wake up the thread when it has a _complete string_ or a timeout > of 0

Help using Thread (or other method)

2016-02-08 Thread Brendan Simon (eTRIX)
Hi. Need some urgent help. I have a python app that uses `select` to wait for data from an arm embedded linux kernel interrupt (every second). The mainloop of the app then grabs data from some memory mapped area, processes it and then does a http post to a server. The problem is the http post c

Syntax Highlightning for C API of CPython in VIM

2016-02-08 Thread Stephane Wirtel
Hi everyone, With my talk "Exploring our Python Interpreter", I think this VIM plugin can be useful for the community. It's a syntax highlighter for the C API of CPython 3.5 and 3.6. I used Clang for the parsing and automatically generated the keywords for VIM. PyObject and the others typede

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Chris Warrick
On 8 February 2016 at 16:53, Random832 wrote: > On Mon, Feb 8, 2016, at 10:46, Chris Angelico wrote: >> > I still think we should just retroactively declare 3.5 to be python 5, >> > and then keep going with python 6, 7, etc... >> >> http://dirtsimple.org/2004/12/python-is-not-java.html > > Java's

Re: Confused by wxpython documentation

2016-02-08 Thread cl
Ian Kelly wrote: > On Mon, Feb 8, 2016 at 8:36 AM, wrote: > > I'm playing around with some existing code that uses wxpython. I've > > been trying to understand a basic bit about the import statement and > > so went to the beginning of the wxPython on line documents. > > > > Going from the top t

Re: Confused by wxpython documentation

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 8:36 AM, wrote: > I'm playing around with some existing code that uses wxpython. I've > been trying to understand a basic bit about the import statement and > so went to the beginning of the wxPython on line documents. > > Going from the top to the "Hello World Example" (c

Re: A question about imports in wxpython

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 8:44 AM, wrote: > I'm playing with some code that uses the wxpython grid. *Every* > example I have seen starts with the imports:- > > import wx > import wx.grid as Gridlib > > As Gridlib is exactly the same number of characters as wx.grid I > really don't see the p

Re: Set Operations on Dicts

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 5:47 AM, Grobu wrote: > You can use dictionary comprehension : > > Say : > dict1 = {'a': 123, 'b': 456} > set1 = {'a'} > > intersection : { key:dict1[key] for key in dict1 if key in set1 } > {'a': 123} > > difference : { key:dict1[key] for key in dict1 if not key i

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Random832
On Mon, Feb 8, 2016, at 10:46, Chris Angelico wrote: > > I still think we should just retroactively declare 3.5 to be python 5, > > and then keep going with python 6, 7, etc... > > http://dirtsimple.org/2004/12/python-is-not-java.html Java's hardly the only, or even the first, project to drop a v

A question about imports in wxpython

2016-02-08 Thread cl
I'm playing with some code that uses the wxpython grid. *Every* example I have seen starts with the imports:- import wx import wx.grid as Gridlib As Gridlib is exactly the same number of characters as wx.grid I really don't see the point. Am I missing something? -- Chris Green · -- h

Confused by wxpython documentation

2016-02-08 Thread cl
I'm playing around with some existing code that uses wxpython. I've been trying to understand a basic bit about the import statement and so went to the beginning of the wxPython on line documents. Going from the top to the "Hello World Example" (can't give URL as the URL is the same for all the d

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Chris Angelico
On Tue, Feb 9, 2016 at 2:44 AM, Random832 wrote: > On Mon, Feb 8, 2016, at 10:40, Ian Kelly wrote: >> Besides, you're forgetting that the whole point of having so many >> backwards incompatible changes in Python 3 in the first place was to >> get them out of the way and not have to do them further

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Random832
On Mon, Feb 8, 2016, at 10:40, Ian Kelly wrote: > Besides, you're forgetting that the whole point of having so many > backwards incompatible changes in Python 3 in the first place was to > get them out of the way and not have to do them further into the > future. Python 4.0 has never been planned t

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Ian Kelly
On Sat, Feb 6, 2016 at 1:54 PM, Rick Johnson wrote: > On Wednesday, February 3, 2016 at 12:02:35 AM UTC-6, John Ladasky wrote: > >> Rick, you don't like Python? > > If i didn't like Python, then i would happily let it self- > destruct, yes? The problem is, i *DO* like Python. Python2 > was a great

Re: [newbie] problem with geometry setting in Tkinter

2016-02-08 Thread Christian Gollwitzer
Am 08.02.16 um 15:34 schrieb jenswaelk...@gmail.com: Op maandag 8 februari 2016 13:26:56 UTC+1 schreef Peter Otten: jenswaelk...@gmail.com wrote: I'm trying to set the geometry of my top window, but the size is unaffected. This is the code: top.geometry('900x460') thanks a lot for helpi

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Jason Swails
On Sun, Feb 7, 2016 at 2:58 AM, Chris Angelico wrote: > > Would writing a script to figure out whether there are more > statisticians or programmers be a statistician's job or a > programmer's? > ​Yes. -- https://mail.python.org/mailman/listinfo/python-list

Re: A sets algorithm

2016-02-08 Thread Chris Angelico
On Tue, Feb 9, 2016 at 1:49 AM, Random832 wrote: > On Sun, Feb 7, 2016, at 20:07, Cem Karan wrote: >> a) Use Chris Angelico's suggestion and hash each of the files (use the >> standard library's 'hashlib' for this). Identical files will always have >> identical hashes, but there may be fa

Re: Set Operations on Dicts

2016-02-08 Thread Jussi Piitulainen
Random832 writes: > On Mon, Feb 8, 2016, at 08:32, Matt Wheeler wrote: >> On 8 February 2016 at 12:17, Jussi Piitulainen wrote: >> > Also, what would be the nicest current way to express a priority union >> > of dicts? >> > >> > { k:(d if k in d else e)[k] for k in d.keys() | e.keys() } >> >> Sin

Re: What's the best/neatest way to get Unicode data from a database into a grid cell?

2016-02-08 Thread Vlastimil Brom
2016-02-08 11:42 GMT+01:00 : > Vlastimil Brom wrote: >> >> Hi, >> your code in >> http://www.salstat.com/news/linking-wxgrid-to-sqlite-database-in-python-an-example >> >> seems to work for me after small changes with both python 2.7 and 3.4 >> (using wx Phoenix) > > Where are you getting phoenix

Re: Set Operations on Dicts

2016-02-08 Thread Random832
On Mon, Feb 8, 2016, at 08:32, Matt Wheeler wrote: > On 8 February 2016 at 12:17, Jussi Piitulainen > wrote: > > Also, what would be the nicest current way to express a priority union > > of dicts? > > > > { k:(d if k in d else e)[k] for k in d.keys() | e.keys() } > > Since Python 3.5: {**e, **d}

Re: A sets algorithm

2016-02-08 Thread Random832
On Sun, Feb 7, 2016, at 20:07, Cem Karan wrote: > a) Use Chris Angelico's suggestion and hash each of the files (use the > standard library's 'hashlib' for this). Identical files will always have > identical hashes, but there may be false positives, so you'll need to verify > that files t

Re: [newbie] problem with geometry setting in Tkinter

2016-02-08 Thread jenswaelkens
Op maandag 8 februari 2016 13:26:56 UTC+1 schreef Peter Otten: > jenswaelk...@gmail.com wrote: > > > I'm trying to set the geometry of my top window, but the size is > > unaffected. > > This is the code: > > > > #!/usr/bin/env python > > import Tkinter > > top=Tkinter.Tk() > > top.geometry=('900x

Re: Set Operations on Dicts

2016-02-08 Thread Jussi Piitulainen
Matt Wheeler writes: > On 8 February 2016 at 12:17, Jussi Piitulainen wrote: >> Also, what would be the nicest current way to express a priority union >> of dicts? >> >> { k:(d if k in d else e)[k] for k in d.keys() | e.keys() } > > Since Python 3.5: {**e, **d} Thanks. I have considered this news

Re: Set Operations on Dicts

2016-02-08 Thread Matt Wheeler
On 8 February 2016 at 12:17, Jussi Piitulainen wrote: > Also, what would be the nicest current way to express a priority union > of dicts? > > { k:(d if k in d else e)[k] for k in d.keys() | e.keys() } Since Python 3.5: {**e, **d} -- Matt Wheeler http://funkyh.at -- https://mail.python.org/ma

Re: Set Operations on Dicts

2016-02-08 Thread Grobu
You can use dictionary comprehension : Say : dict1 = {'a': 123, 'b': 456} set1 = {'a'} intersection : >>> { key:dict1[key] for key in dict1 if key in set1 } {'a': 123} difference : >>> { key:dict1[key] for key in dict1 if not key in set1 } {'b': 456} -- https://mail.python.org/mailman/listinfo

Re: Set Operations on Dicts

2016-02-08 Thread Marco Kaulea
On Mon, Feb 8, 2016 at 1:17 PM, Jussi Piitulainen < jussi.piitulai...@helsinki.fi> wrote: > I think nobody was quite willing to lay down the law on which dictionary > would take precedence when they have keys in common but different values > on those keys. Both ways make sense, and sometimes you w

Re: [newbie] problem with geometry setting in Tkinter

2016-02-08 Thread Peter Otten
jenswaelk...@gmail.com wrote: > I'm trying to set the geometry of my top window, but the size is > unaffected. > This is the code: > > #!/usr/bin/env python > import Tkinter > top=Tkinter.Tk() > top.geometry=('900x460') That's an assignment, but geometry() is a method that you have to invoke: t

Re: Set Operations on Dicts

2016-02-08 Thread Jussi Piitulainen
Marco Kaulea writes: > In one talk (I think it was [1]) it was described that sets are > basically dicts without the values. Therefor it should be easy to > apply set operations on dicts, for example: > > {'a': 123, 'b': 456} & {'a'} => {'a': 123} > {'a': 123, 'b': 456} - {'a'} => {'b': 456} > >

[newbie] problem with geometry setting in Tkinter

2016-02-08 Thread jenswaelkens
I'm trying to set the geometry of my top window, but the size is unaffected. This is the code: #!/usr/bin/env python import Tkinter top=Tkinter.Tk() top.geometry=('900x460') top.update_idletasks() print (top.winfo_width()) print (top.winfo_height()) print (top.winfo_geometry()) top.mainloop() and

New mailing for Python in Belgium

2016-02-08 Thread Stephane Wirtel
Hello everyone, I would like to announce a new mailing list for the Belgian Python Users. This main goal of this mailing list is mainly for the Python Community of Belgium, Dutch, French and German. The main language is English, I don’t want to discuss about the languages, maybe in the futur

Re: Changing logging level only for my code?

2016-02-08 Thread Peter Otten
egarr...@gmail.com wrote: > I am using the "logging" module for my own package, but changing the level > from "INFO" to "DEBUG" enables debugging statements from third-party > libraries as well. How can I avoid them? Here is the code I am using: > > import logging > > logger = logging.

Re: Changing logging level only for my code?

2016-02-08 Thread jmp
On 02/08/2016 12:29 PM, egarr...@gmail.com wrote: I am using the "logging" module for my own package, but changing the level from "INFO" to "DEBUG" enables debugging statements from third-party libraries as well. How can I avoid them? Here is the code I am using: import logging lo

Re: Heap Implementation

2016-02-08 Thread Cem Karan
On Feb 7, 2016, at 10:15 PM, srinivas devaki wrote: > On Feb 8, 2016 7:07 AM, "Cem Karan" wrote: > > I know that there are methods of handling this from the client-side (tuples > > with unique counters come to mind), but if your library can handle it > > directly, then that could be useful to o

Changing logging level only for my code?

2016-02-08 Thread egarrulo
I am using the "logging" module for my own package, but changing the level from "INFO" to "DEBUG" enables debugging statements from third-party libraries as well. How can I avoid them? Here is the code I am using: import logging logger = logging.getLogger(__name__) log_file = logg

Re: setup failed

2016-02-08 Thread Mark Summerfield
On Monday, February 8, 2016 at 10:50:19 AM UTC, Mark Summerfield wrote: > If you need 32-bit Python on Windows my advice is to install 3.4. If you need > 32-bit and 64-bit Python on Windows, then I think it will only work with 3.4 > (or older), but not with 3.5's new installer. > > I have tried

Re: What's the best/neatest way to get Unicode data from a database into a grid cell?

2016-02-08 Thread Chris Angelico
On Mon, Feb 8, 2016 at 9:22 PM, wrote: >> Once you switch to Python 3 and Phoenix you have to modify this >> slightly, e.g. by adding this to the top of your code: >> >> try: >> basestring >> except: >> basestring = (bytes,str) >> > Everything else is 3 compatible so moving should be fair

Re: What's the best/neatest way to get Unicode data from a database into a grid cell?

2016-02-08 Thread Chris Angelico
On Mon, Feb 8, 2016 at 9:42 PM, wrote: > Vlastimil Brom wrote: >> >> Hi, >> your code in >> http://www.salstat.com/news/linking-wxgrid-to-sqlite-database-in-python-an-example >> >> seems to work for me after small changes with both python 2.7 and 3.4 >> (using wx Phoenix) > > Where are you getti

Re: setup failed

2016-02-08 Thread Mark Summerfield
If you need 32-bit Python on Windows my advice is to install 3.4. If you need 32-bit and 64-bit Python on Windows, then I think it will only work with 3.4 (or older), but not with 3.5's new installer. I have tried installing 3.5.0 and 3.5.1 on several machines both 32- and 64-bit Windows. The 3

Re: What's the best/neatest way to get Unicode data from a database into a grid cell?

2016-02-08 Thread cl
Vlastimil Brom wrote: > > Hi, > your code in > http://www.salstat.com/news/linking-wxgrid-to-sqlite-database-in-python-an-example > > seems to work for me after small changes with both python 2.7 and 3.4 > (using wx Phoenix) Where are you getting phoenix from? It's not in the Ubuntu repositori

Re: What's the best/neatest way to get Unicode data from a database into a grid cell?

2016-02-08 Thread cl
Dietmar Schwertberger wrote: > On 07.02.2016 12:19, c...@isbd.net wrote: > > However my database has quite a lot of Unicode data as there are > > French (and other) names with accents etc. What's the right way to > > handle this reasonably neatly? At the moment it traps an error at > > line 37:-

Set Operations on Dicts

2016-02-08 Thread Marco Kaulea
Hi, In one talk (I think it was [1]) it was described that sets are basically dicts without the values. Therefor it should be easy to apply set operations on dicts, for example: {'a': 123, 'b': 456} & {'a'} => {'a': 123} {'a': 123, 'b': 456} - {'a'} => {'b': 456} This if currently not implemented

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Veek. M
Veek. M wrote: > > Exceptions can be raised inside a coroutine using the throw( > > Exceptions raised in this manner will originate at the currently > executing yield state-ment in the coroutine.A coroutine can elect to > catch exceptions and handle them as appropriat

coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Veek. M
Exceptions can be raised inside a coroutine using the throw( Exceptions raised in this manner will originate at the currently executing yield state-ment in the coroutine.A coroutine can elect to catch exceptions and handle them as appropriate. It is not safe to use

Re: setup failed

2016-02-08 Thread Mike S via Python-list
On 2/4/2016 4:39 AM, Prince Thomas wrote: Hi I am an computer science engineer. I downloaded the python version 3.5.1.amd64 and just python 3.5.1. The problem is when I install the program setup is failed and showing 0*80070570-The file or directory is corrupted and unreadable. I install the n

Re: Install Error

2016-02-08 Thread Mike S via Python-list
On 2/3/2016 1:55 PM, Barrie Taylor wrote: Hi, I am attempting to install and run Python3.5.1 on my Windows machine. After installation on launching I am presented the attached error message. It reads: 'The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your compu

Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-08 Thread shaunak . bangale
On Sunday, February 7, 2016 at 1:23:32 AM UTC-7, dieter wrote: > Shaunak Bangale writes: > > ... > > while (count > 0): > > try : > > # read line from file: > > print(file.readline()) > > # parse > > parse_json(file.readline()) > > count = count - 1 > >