Re: sqlite 3 attribute error __exit__

2016-05-15 Thread Sayth Renshaw
> > As you've written it, the statement declares your intent to enter both > ‘conn’ and ‘conn.cursor()’ as context managers. > > https://docs.python.org/3/reference/compound_stmts.html#with> > > To “enter a context manager” entails calling the ‘__enter__’ method on > the context manager obje

Re: How to use pip to install dtrx?

2016-05-15 Thread Sayth Renshaw
On Saturday, 14 May 2016 07:39:23 UTC+10, Ehsan Hajiramezanali wrote: > Hi, > > I want to use pip to install dtrx. However, I got the following error. > > ~~~ > $ pip install --allow-external dtrx dtrx > DEPRECATION: --allow-external has been deprecated and will be removed > in the future. Due t

Re: Trouble porting glob bash behavior with argparse to windows shell

2016-05-15 Thread Sayth Renshaw
On Wednesday, 4 May 2016 17:57:32 UTC+10, Sayth Renshaw wrote: > Oops sorry noticed you did in the glob. Sorry squinting at phone. > > Sayth Hi this seems to be causing me an error in my thinking as well as the program. I am creating a function GetArgs to take a path and file extension from t

Re: sqlite 3 attribute error __exit__

2016-05-15 Thread Sayth Renshaw
On Monday, 16 May 2016 12:45:26 UTC+10, DFS wrote: > On 5/15/2016 10:21 PM, Sayth Renshaw wrote: > > Hi > > > > I have a file and want to create the sqlite3 db. Using with however i > > receive an attribute error and it causes an exit. > > > > The relevant section of the file is: > > > > import s

Re: sqlite 3 attribute error __exit__

2016-05-15 Thread Ben Finney
Sayth Renshaw writes: > with conn, conn.cursor() as cur: What are you expecting this ‘with’ statement to do? As you've written it, the statement declares your intent to enter both ‘conn’ and ‘conn.cursor()’ as context managers. https://docs.python.org/3/reference/compound_stmts.html#with>

sqlite 3 attribute error __exit__

2016-05-15 Thread Sayth Renshaw
Hi I have a file and want to create the sqlite3 db. Using with however i receive an attribute error and it causes an exit. The relevant section of the file is: import sqlite3 conn = sqlite3.connect("trial.db") with conn, conn.cursor() as cur: # First, create tables. cur.execute("dr

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Chris Angelico
On Mon, May 16, 2016 at 9:17 AM, Pavlos Parissis wrote: > On 16/05/2016 12:59 πμ, Chris Angelico wrote: >> Ah. I didn't click that link in your original post - didn't know it >> was the traceback. Better would have been to at least say so; best >> would have been to include it inline. >> > > I don

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Pavlos Parissis
On 16/05/2016 12:59 πμ, Chris Angelico wrote: > On Mon, May 16, 2016 at 8:32 AM, Pavlos Parissis > wrote: >>> Searching the CPython sources for that exception shows one hit: >>> selectors.py, where it converts a file object to an integer file >>> descriptor. (You could have helped out by showing u

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Chris Angelico
On Mon, May 16, 2016 at 8:32 AM, Pavlos Parissis wrote: >> Searching the CPython sources for that exception shows one hit: >> selectors.py, where it converts a file object to an integer file >> descriptor. (You could have helped out by showing us the full >> traceback.) > > I did, https://gist.git

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Pavlos Parissis
On 16/05/2016 12:08 πμ, Chris Angelico wrote: > On Mon, May 16, 2016 at 1:49 AM, Pavlos Parissis > wrote: >> I use subprocess.check_output like this: >> >> cmd = [ >> '/sbin/ip', >> 'address', >> 'show', >> 'dev', >> "{}".format(self.config['interface']), >> 'to', >> "{

Re: intermittent ValueErrors from subprocess

2016-05-15 Thread Chris Angelico
On Mon, May 16, 2016 at 1:49 AM, Pavlos Parissis wrote: > I use subprocess.check_output like this: > > cmd = [ > '/sbin/ip', > 'address', > 'show', > 'dev', > "{}".format(self.config['interface']), > 'to', > "{}".format(self.config['ip_prefix']), > ] Unrelated to your

Re: How to get a directory list sorted by date?

2016-05-15 Thread Chris Angelico
On Mon, May 16, 2016 at 2:00 AM, Grant Edwards wrote: > On 2016-05-15, Michael Selik wrote: >> On Sun, May 15, 2016, 10:37 AM Grant Edwards >> wrote: >>> On 2016-05-15, Tim Chase wrote: unless sorted() returns a lazy sorter, >>> >>> What's a lazy sorter? >> >> One that doesn't calcul

Re: How to get a directory list sorted by date?

2016-05-15 Thread cl
Tim Chase wrote: > On 2016-05-15 14:36, Grant Edwards wrote: > > On 2016-05-15, Tim Chase wrote: > > > unless sorted() returns a lazy sorter, > > > > What's a lazy sorter? > > A hypothetical algorithm that can spool out a sorted sequence without > holding the entire sequence in memory at the sa

Re: Pandas GroupBy does not behave consistently

2016-05-15 Thread Michael Selik
On Sun, May 15, 2016 at 7:07 AM David Shi wrote: > Hello, Michael, > > Pandas GroupBy does not behave consistently. > > Last time, when we had conversation, I used grouby. It works well. > > Now, I thought to re-write the program, so that I can end up with a clean > script. > > But, the problem

Re: How to get a directory list sorted by date?

2016-05-15 Thread Tim Chase
On 2016-05-15 14:36, Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: > > unless sorted() returns a lazy sorter, > > What's a lazy sorter? A hypothetical algorithm that can spool out a sorted sequence without holding the entire sequence in memory at the same time. Though I typed that ini

Pandas GroupBy does not behave consistently

2016-05-15 Thread David Shi via Python-list
Hello, Michael, Pandas GroupBy does not behave consistently. Last time, when we had conversation, I used grouby.  It works well. Now, I thought to re-write the program, so that I can end up with a clean script. But, the problem is that a lot of columns are missing after groupby application. Any id

Re: How to get a directory list sorted by date?

2016-05-15 Thread Grant Edwards
On 2016-05-15, Michael Selik wrote: > On Sun, May 15, 2016, 10:37 AM Grant Edwards > wrote: >> On 2016-05-15, Tim Chase wrote: >>> >>> unless sorted() returns a lazy sorter, >> >> What's a lazy sorter? > > One that doesn't calculate the next item in the sequence until you > ask for it. It's imp

Re: How to get a directory list sorted by date?

2016-05-15 Thread Michael Selik
On Sun, May 15, 2016, 10:37 AM Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: > > On 2016-05-15 11:46, Peter Otten wrote: > >> def sorted_dir(folder): > >> def getmtime(name): > >> path = os.path.join(folder, name) > >> return os.path.getmtime(path) > >> > >> retu

intermittent ValueErrors from subprocess

2016-05-15 Thread Pavlos Parissis
Hi, I get intermittent ValueErrors[1] from subprocess when I check if an IP is assigned to loopback interface by running: /sbin/ip address show dev lo to 10.52.12.2/32 I use subprocess.check_output like this: cmd = [ '/sbin/ip', 'address', 'show', 'dev', "{}".format(self.con

Re: How to get a directory list sorted by date?

2016-05-15 Thread Joel Goldstick
On Sun, May 15, 2016 at 10:36 AM, Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: >> On 2016-05-15 11:46, Peter Otten wrote: >>> def sorted_dir(folder): >>> def getmtime(name): >>> path = os.path.join(folder, name) >>> return os.path.getmtime(path) >>> >>> return so

Re: Developers using Python QT framework ??

2016-05-15 Thread tommy yama
Hey there, Many thanks, Vincent, On Sun, May 15, 2016 at 11:15 PM, Vincent Vande Vyvre < vincent.vande.vy...@telenet.be> wrote: > Le 15/05/2016 13:19, tommy yama a écrit : > >> Hi folks, >> >> Are there people using QT cross-platform framework on the list? >> I appreciate for your advices and

Re: How to get a directory list sorted by date?

2016-05-15 Thread Grant Edwards
On 2016-05-15, Tim Chase wrote: > On 2016-05-15 11:46, Peter Otten wrote: >> def sorted_dir(folder): >> def getmtime(name): >> path = os.path.join(folder, name) >> return os.path.getmtime(path) >> >> return sorted(os.listdir(folder), key=getmtime, reverse=True) >> >> The

Re: Developers using Python QT framework ??

2016-05-15 Thread Vincent Vande Vyvre
Le 15/05/2016 13:19, tommy yama a écrit : Hi folks, Are there people using QT cross-platform framework on the list? I appreciate for your advices and references regarding this. I am a novice python programmer who started using this framework. Thanks a lot in advance! Tomo Yes. Note, it is

Re: How to get a directory list sorted by date?

2016-05-15 Thread Vincent Vande Vyvre
Le 15/05/2016 10:47, c...@isbd.net a écrit : I have a little Python program I wrote myself which copies images from a camera (well, any mounted directory) to my picture archive. The picture archive is simply a directory hierarchy of dates with years at the top, then months, then days. My Python

Developers using Python QT framework ??

2016-05-15 Thread tommy yama
Hi folks, Are there people using QT cross-platform framework on the list? I appreciate for your advices and references regarding this. I am a novice python programmer who started using this framework. Thanks a lot in advance! Tomo -- https://mail.python.org/mailman/listinfo/python-list

Re: How to get a directory list sorted by date?

2016-05-15 Thread Peter Otten
Tim Chase wrote: > On 2016-05-15 11:46, Peter Otten wrote: >> def sorted_dir(folder): >> def getmtime(name): >> path = os.path.join(folder, name) >> return os.path.getmtime(path) >> >> return sorted(os.listdir(folder), key=getmtime, reverse=True) >> >> The same idea will

Re: How to get a directory list sorted by date?

2016-05-15 Thread Chris Angelico
On Sun, May 15, 2016 at 9:15 PM, Tim Chase wrote: > On 2016-05-15 11:46, Peter Otten wrote: >> def sorted_dir(folder): >> def getmtime(name): >> path = os.path.join(folder, name) >> return os.path.getmtime(path) >> >> return sorted(os.listdir(folder), key=getmtime, reverse=

Re: How to get a directory list sorted by date?

2016-05-15 Thread Tim Chase
On 2016-05-15 11:46, Peter Otten wrote: > def sorted_dir(folder): > def getmtime(name): > path = os.path.join(folder, name) > return os.path.getmtime(path) > > return sorted(os.listdir(folder), key=getmtime, reverse=True) > > The same idea will work with pathlib and os.sca

Re: How to get a directory list sorted by date?

2016-05-15 Thread Tim Chase
On 2016-05-15 20:48, Steven D'Aprano wrote: > Also, remember that most operating systems provide (at least) three > different times. I'm not sure which one you want, but if I had to > guess, I would probably guess mtime. If I remember correctly: > > atime is usually the last access time; > mtime i

Re: Design: Idiom for classes and methods that are customizable by the user?

2016-05-15 Thread Dirk Bächle
Hello Dieter, Am 13.05.2016 um 09:21 schrieb dieter: Dirk Bächle writes: ... My questions - Is this a good approach, that I could use for other parts of the architecture as well, e.g. the Node class mentioned above? You might look at the "adpater" pattern. It is heavily used

Re: Design: Idiom for classes and methods that are customizable by the user?

2016-05-15 Thread Dirk Bächle
Hi Gregory, thanks a lot for your answer and comments. Am 13.05.2016 um 08:35 schrieb Gregory Ewing: Dirk Bächle wrote: [...] I'd even suggest that *all* of the build logic should be in the Nodes, and the Taskmaster class shouldn't exist at all. The top level logic should just tell the final

Re: Design: Idiom for classes and methods that are customizable by the user?

2016-05-15 Thread Dirk Bächle
Hi Marko, Am 13.05.2016 um 07:53 schrieb Marko Rauhamaa: Dirk Bächle : For example, why do you need a key? Couldn't you simply pass the task master class as an argument? The idea behind this is, to be able to select classes by giving a parameter on the command-line. So at some point a transl

Re: How to get a directory list sorted by date?

2016-05-15 Thread Steven D'Aprano
On Sunday 15 May 2016 18:47, c...@isbd.net wrote: > What I want is a list in the order produced by:- > ls --sort=time I'm not sure if this is the best way to do it, but what I would do is sort the directory list by the file's time metadata, which you can access using os.stat. To sort the fi

Re: How to get a directory list sorted by date?

2016-05-15 Thread Peter Otten
c...@isbd.net wrote: > I have a little Python program I wrote myself which copies images from > a camera (well, any mounted directory) to my picture archive. The > picture archive is simply a directory hierarchy of dates with years at > the top, then months, then days. > > My Python program simp

How to get a directory list sorted by date?

2016-05-15 Thread cl
I have a little Python program I wrote myself which copies images from a camera (well, any mounted directory) to my picture archive. The picture archive is simply a directory hierarchy of dates with years at the top, then months, then days. My Python program simply extracts the date from the imag

ANN: psutil 4.2.0 with Windows service support is out

2016-05-15 Thread Giampaolo Rodola'
Full blog post: http://grodola.blogspot.com/2016/05/psutil-420-windows-services-and-python.html -- Giampaolo - http://grodola.blogspot.com -- https://mail.python.org/mailman/listinfo/python-list

ANN: psutil 4.2.0 with Windows service support is out

2016-05-15 Thread Giampaolo Rodola'
Full blog post: http://grodola.blogspot.com/2016/05/psutil-420-windows-services-and-python.html -- Giampaolo - http://grodola.blogspot.com -- https://mail.python.org/mailman/listinfo/python-list