Re: What is heating the memory here? hashlib?

2016-02-14 Thread INADA Naoki
tracemalloc module may help you to investigate leaks. 2016/02/14 午後4:05 "Paulo da Silva" : > I was unable to reproduce the situation using a simple program just > walking through all files>4K, with or without the seek, and computing > their shasums. > Only some fluctuations of about 500MB in memor

ftplib throws: IndexError: tuple index out of range

2016-02-14 Thread Antoon Pardon
I have written a small backup program, that uses ftplib to make remote backups. However recentely the program starts to regularly raise IndexErrors, as far as I can see the problem is in socket.py Can anyone shed some light? This is the traceback: Traceback (most recent call last): File "/usr/l

Re: ftplib throws: IndexError: tuple index out of range

2016-02-14 Thread Stephane Wirtel
Hi Antoon, EINTR, is an error when there is an emited signal to your process. http://man7.org/linux/man-pages/man2/read.2.html Look for EINTR in this page On 02/14, Antoon Pardon wrote: I have written a small backup program, that uses ftplib to make remote backups. However recentely the progr

Re: problem with dateutil

2016-02-14 Thread Tom P
On 02/13/2016 09:45 PM, Gary Herron wrote: On 02/13/2016 12:27 PM, Tom P wrote: On 02/13/2016 07:13 PM, Gary Herron wrote: On 02/13/2016 09:58 AM, Tom P wrote: I am writing a program that has to deal with various date/time formats and convert these into timestamps. It looks as if dateutil.pars

Re: problem with dateutil

2016-02-14 Thread Tom P
On 02/13/2016 10:01 PM, Mark Lawrence wrote: On 13/02/2016 17:58, Tom P wrote: I am writing a program that has to deal with various date/time formats and convert these into timestamps. It looks as if dateutil.parser.parse should be able to handle about any format, but what I get is: datetimestr

Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-14 Thread Geoff Munn
Hi, Noob at the Python thing so here goes, I have copied a program to demonstrate control structures in Python but get a syntax error at line 31, isint = False. I'm using Python 2.7.6 and Linux Mint based around ubuntu14.04.1. I have pasted all the code below, #!/usr/bin/env python2 ''' We

Re: ftplib throws: IndexError: tuple index out of range

2016-02-14 Thread Peter Otten
Antoon Pardon wrote: > I have written a small backup program, that uses ftplib to make > remote backups. However recentely the program starts to regularly > raise IndexErrors, as far as I can see the problem is in socket.py > Can anyone shed some light? > > This is the traceback: [...] > File

Re: How do i instantiate a class_name passed via cmd line

2016-02-14 Thread Peter Otten
Gregory Ewing wrote: > Something like this should do it: > >instance = getattr(module, class_name)(module_name, product) > > If the class name is always the same as the module name with the > first letter capitalized, you could use > >instance = getattr(module, module_name.capitalize())

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-14 Thread Peter Otten
Geoff Munn wrote: > Noob at the Python thing so here goes, > > I have copied a program to demonstrate control structures in Python but > get a syntax error at line 31, isint = False. Often the actual syntax error in your code is in one of the lines preceding the one that Python is complaining

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-14 Thread Chris Angelico
On Mon, Feb 15, 2016 at 12:39 AM, Geoff Munn wrote: > Hi, > > Noob at the Python thing so here goes, > > I have copied a program to demonstrate control structures in Python but get a > syntax error at line 31, isint = False. I'm using Python 2.7.6 and Linux Mint > based around ubuntu14.04.1. I h

Re: ftplib throws: IndexError: tuple index out of range

2016-02-14 Thread Antoon Pardon
Op 14-02-16 om 14:40 schreef Peter Otten: > Antoon Pardon wrote: > >> I have written a small backup program, that uses ftplib to make >> remote backups. However recentely the program starts to regularly >> raise IndexErrors, as far as I can see the problem is in socket.py >> Can anyone shed some l

Re: ftplib throws: IndexError: tuple index out of range

2016-02-14 Thread Antoon Pardon
Op 14-02-16 om 14:40 schreef Peter Otten: > > PS: How did you produce the overview over the local variables? That looks > nice. > I started from this recipe: http://code.activestate.com/recipes/52215-get-more-information-from-tracebacks/ made it more to my liking and turned it into a module.

Make a unique filesystem path, without creating the file

2016-02-14 Thread Ben Finney
Howdy all, How should a program generate a unique filesystem path and *not* create the filesystem entry? The ‘tempfile.mktemp’ function is strongly deprecated, and rightly so https://docs.python.org/3/library/tempfile.html#tempfile.mktemp> because it leaves the program vulnerable to insecure file

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Thomas 'PointedEars' Lahn
Ben Finney wrote: > How should a program generate a unique filesystem path and *not* create > the filesystem entry? The Python documentation suggests that it should not. > The ‘tempfile.mktemp’ function is strongly deprecated, and rightly so > https://docs.python.org/3/library/tempfile.html#tem

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Matt Wheeler
On 14 Feb 2016 21:46, "Ben Finney" wrote: > What standard library function should I be using to generate > ‘tempfile.mktemp’-like unique paths, and *not* ever create a real file > by that path? Could you use tempfile.TemporaryDirectory and then just use a consistent name within that directory. I

LIGO and Python

2016-02-14 Thread Terry Reedy
On the PSF-Community list, a Python user points out that LIGO uses Python, with numpy and IPython, extensively. He linked to https://losc.ligo.org/s/events/GW150914/GW150914_tutorial.html which explains, with code, how the gravity wave signal was pulled out of the (publicly available) raw data.

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Ben Finney
Matt Wheeler writes: > On 14 Feb 2016 21:46, "Ben Finney" wrote: > > What standard library function should I be using to generate > > ‘tempfile.mktemp’-like unique paths, and *not* ever create a real > > file by that path? > > Could you use tempfile.TemporaryDirectory and then just use a > consi

How to properly override the default factory of defaultdict?

2016-02-14 Thread Herman
I want to pass in the key to the default_factory of defaultdict and I found that defaultdict somehow can intercept my call to dict.__getitem__(self, key), so my class's __getitem__ have to catch a TypeError instead instead of KeyError. The following class is my code: class DefaultDictWithEnhancedF

Creating a List from a Loop

2016-02-14 Thread Kaley Tucker
I'm in an Intro to Python class and have an assignment where I need to implement a function calculating distance between two points, then create a loop to find points within a certain distance and create a list from those points. I was able to create the function, but I cant get my loop to creat

Re: How to properly override the default factory of defaultdict?

2016-02-14 Thread Ben Finney
Herman writes: > I want to pass in the key to the default_factory of defaultdict and I > found that defaultdict somehow can intercept my call to > dict.__getitem__(self, key), so my class's __getitem__ have to catch a > TypeError instead instead of KeyError. The following class is my code: I don

Re: Creating a List from a Loop

2016-02-14 Thread Chris Angelico
On Mon, Feb 15, 2016 at 11:23 AM, Kaley Tucker wrote: > I'm in an Intro to Python class and have an assignment where I need to > implement a function calculating distance between two points, then create a > loop to find points within a certain distance and create a list from those > points. I w

Re: How to properly override the default factory of defaultdict?

2016-02-14 Thread Chris Angelico
On Mon, Feb 15, 2016 at 11:17 AM, Herman wrote: > I want to pass in the key to the default_factory of defaultdict and I found > that defaultdict somehow can intercept my call to dict.__getitem__(self, > key), so my class's __getitem__ have to catch a TypeError instead instead > of KeyError. The fo

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Dan Sommers
On Mon, 15 Feb 2016 11:08:52 +1100, Ben Finney wrote: > I am unconcerned with whether there is a real filesystem entry of that > name; the goal entails having no filesystem activity for this. I want > a valid unique filesystem path, without touching the filesystem. That's an odd use case. If it'

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Ben Finney
Dan Sommers writes: > On Mon, 15 Feb 2016 11:08:52 +1100, Ben Finney wrote: > > > I am unconcerned with whether there is a real filesystem entry of > > that name; the goal entails having no filesystem activity for this. > > I want a valid unique filesystem path, without touching the > > filesyste

Re: What is heating the memory here? hashlib?

2016-02-14 Thread Paulo da Silva
Às 07:04 de 14-02-2016, Paulo da Silva escreveu: > I was unable to reproduce the situation using a simple program just > walking through all files>4K, with or without the seek, and computing > their shasums. > Only some fluctuations of about 500MB in memory consumption. Today I gave another try to

Re: How to properly override the default factory of defaultdict?

2016-02-14 Thread Steven D'Aprano
On Monday 15 February 2016 11:17, Herman wrote: > I want to pass in the key to the default_factory of defaultdict Just use a regular dict and define __missing__: class MyDefaultDict(dict): def __missing__(self, key): return "We gotcha key %r right here!" % key If you want a per-in

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Steven D'Aprano
On Monday 15 February 2016 11:08, Ben Finney wrote: > I am unconcerned with whether there is a real filesystem entry of that > name; the goal entails having no filesystem activity for this. I want a > valid unique filesystem path, without touching the filesystem. Your phrasing is ambiguous. If y

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Ben Finney
Steven D'Aprano writes: > On Monday 15 February 2016 11:08, Ben Finney wrote: > > > I am unconcerned with whether there is a real filesystem entry of > > that name; the goal entails having no filesystem activity for this. > > I want a valid unique filesystem path, without touching the > > filesys

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Martin A. Brown
Good evening/morning Ben, >> > I am unconcerned with whether there is a real filesystem entry of >> > that name; the goal entails having no filesystem activity for this. >> > I want a valid unique filesystem path, without touching the >> > filesystem. >> >> Your phrasing is ambiguous. > >The exis

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Steven D'Aprano
On Monday 15 February 2016 12:19, Ben Finney wrote: > One valid filesystem path each time it's accessed. That is, behaviour > equivalent to ‘tempfile.mktemp’. > > My question is because the standard library clearly has this useful > functionality implemented, but simultaneously warns strongly aga

Re: Make a unique filesystem path, without creating the file

2016-02-14 Thread Ben Finney
Steven D'Aprano writes: > If you can absolutely guarantee that this string will never actually > be used on a real filesystem, then go right ahead and use it. I'm giving advice in examples in documentation. It's not enough to have some private usage that I know is good, I am looking for a standa

fetchall is taking much longer time while getting data from Sybase module in Python

2016-02-14 Thread reetesh nigam
Hi All, I am retrieving data from Sybase database using Sybase module of Python. My query is not taking time however fecthall is taking longer time. Below is the test script : def run_query(db,query): ## Run query and resturn record result t1 = datetime.now() cursorObj = db.cur

asyncio - run coroutine in the background

2016-02-14 Thread Frank Millman
Hi all Using asyncio, there are times when I want to execute a coroutine which is time-consuming. I do not need the result immediately, and I do not want to block the current task, so I want to run it in the background. run_in_executor() can run an arbitrary function in the background, but a

Re: asyncio - run coroutine in the background

2016-02-14 Thread Marko Rauhamaa
"Frank Millman" : > Using asyncio, there are times when I want to execute a coroutine which > is time-consuming. I do not need the result immediately, and I do not > want to block the current task, so I want to run it in the background. You can't run code "in the background" using asyncio. Corout

Re: asyncio - run coroutine in the background

2016-02-14 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:8737sumpjl@elektro.pacujo.net... "Frank Millman" : > Using asyncio, there are times when I want to execute a coroutine which > is time-consuming. I do not need the result immediately, and I do not > want to block the current task, so I want to run it

Re: asyncio - run coroutine in the background

2016-02-14 Thread Marko Rauhamaa
"Frank Millman" : > The benefit of my class is that it enables me to take the coroutine > and run it in another thread, without having to re-engineer the whole > thing. > > Hope this makes sense. Sure. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: What is heating the memory here? hashlib?

2016-02-14 Thread Paulo da Silva
Às 09:49 de 14-02-2016, INADA Naoki escreveu: > tracemalloc module may help you to investigate leaks. > 2016/02/14 午後4:05 "Paulo da Silva" : > Thanks. I didn't know it! Paulo -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio - run coroutine in the background

2016-02-14 Thread Paul Rubin
"Frank Millman" writes: > The benefit of my class is that it enables me to take the coroutine > and run it in another thread, without having to re-engineer the whole > thing. Threads in Python don't get you parallelism either, of course. I haven't used async/await yet and it's looking painful.