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

2016-02-11 Thread John Ladasky
On Saturday, February 6, 2016 at 12:54:41 PM UTC-8, 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 Pytho

Re: Handling transactions in Python DBI module

2016-02-11 Thread dieter
Chris Angelico writes: > On Thu, Feb 11, 2016 at 6:59 PM, dieter wrote: >> In my context (web applications), I strongly discourage this use - at least >> when "conn" does not handle subtransactions properly. >> >> In a web application, the main transaction should in general be controlled >> at t

Re: Best programs written completly in Python

2016-02-11 Thread zubvit
On Sunday, August 5, 2007 at 1:14:38 PM UTC+3, Franz Steinhäusler wrote: > Hello NG, > > wWhat are the best programs in your opinion, written entirly > in pyhton, divided into categories like: > a) Games > b) Utilities/System > c) Office > d) Web/Newsreader/Mail/Browser > ... > > I don't want to

Re: Storing a big amount of path names

2016-02-11 Thread srinivas devaki
On Feb 12, 2016 6:05 AM, "Paulo da Silva" wrote: > > Hi! > > What is the best (shortest memory usage) way to store lots of pathnames > in memory where: > > 1. Path names are pathname=(dirname,filename) > 2. There many different dirnames but much less than pathnames > 3. dirnames have in general ma

Re: Storing a big amount of path names

2016-02-11 Thread Steven D'Aprano
On Fri, 12 Feb 2016 04:02 pm, Chris Angelico wrote: > On Fri, Feb 12, 2016 at 3:45 PM, Paulo da Silva > wrote: >>> Correct. Two equal strings, passed to sys.intern(), will come back as >>> identical strings, which means they use the same memory. You can have >>> a million references to the same s

Re: Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Às 05:02 de 12-02-2016, Chris Angelico escreveu: > On Fri, Feb 12, 2016 at 3:45 PM, Paulo da Silva > wrote: ... >> I think a dict, as MRAB suggested, is needed. >> At the end of the store process I may delete the dict. > > I'm not 100% sure of what's going on here, but my suspicion is that a > s

Re: First Program with Python!

2016-02-11 Thread mentificium
On Tuesday, February 9, 2016 at 5:55:30 AM UTC-8, Anita Goyal wrote: > > Start learning Python from basics to advance levels here... > https://goo.gl/hGzm6o Python experts please translate the webserver "Ghost" Perlmind into Python. http://ai.neocities.org/P6AI_FAQ.html -- https://mail.python.

Re: Storing a big amount of path names

2016-02-11 Thread Chris Angelico
On Fri, Feb 12, 2016 at 3:45 PM, Paulo da Silva wrote: >> Correct. Two equal strings, passed to sys.intern(), will come back as >> identical strings, which means they use the same memory. You can have >> a million references to the same string and it takes up no additional >> memory. > I have bein

Re: Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Às 04:23 de 12-02-2016, Chris Angelico escreveu: > On Fri, Feb 12, 2016 at 3:15 PM, Paulo da Silva > wrote: >> Às 03:49 de 12-02-2016, Chris Angelico escreveu: >>> On Fri, Feb 12, 2016 at 2:13 PM, MRAB wrote: Apart from all of the other answers that have been given: >> ... >>> >>> Simpl

Re: Storing a big amount of path names

2016-02-11 Thread Chris Angelico
On Fri, Feb 12, 2016 at 3:15 PM, Paulo da Silva wrote: > Às 03:49 de 12-02-2016, Chris Angelico escreveu: >> On Fri, Feb 12, 2016 at 2:13 PM, MRAB wrote: >>> Apart from all of the other answers that have been given: >>> > ... >> >> Simpler to let the language do that for you: >> > import sys

Re: Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Às 03:49 de 12-02-2016, Chris Angelico escreveu: > On Fri, Feb 12, 2016 at 2:13 PM, MRAB wrote: >> Apart from all of the other answers that have been given: >> ... > > Simpler to let the language do that for you: > import sys p1 = sys.intern('foo/bar') p2 = sys.intern('foo/bar') >

Re: Storing a big amount of path names

2016-02-11 Thread Chris Angelico
On Fri, Feb 12, 2016 at 2:13 PM, MRAB wrote: > Apart from all of the other answers that have been given: > p1 = 'foo/bar' p2 = 'foo/bar' id(p1), id(p2) > (982008930176, 982008930120) d = {} id(d.setdefault(p1, p1)) > 982008930176 id(d.setdefault(p2, p2)) > 98200893017

Re: Storing a big amount of path names

2016-02-11 Thread MRAB
On 2016-02-12 00:31, Paulo da Silva wrote: Hi! What is the best (shortest memory usage) way to store lots of pathnames in memory where: 1. Path names are pathname=(dirname,filename) 2. There many different dirnames but much less than pathnames 3. dirnames have in general many chars The idea is

Re: Storing a big amount of path names

2016-02-11 Thread Rob Gaddi
Tim Chase wrote: > On 2016-02-12 00:31, Paulo da Silva wrote: >> What is the best (shortest memory usage) way to store lots of >> pathnames in memory where: >> >> 1. Path names are pathname=(dirname,filename) >> 2. There many different dirnames but much less than pathnames >> 3. dirnames have in

Re: Storing a big amount of path names

2016-02-11 Thread Tim Chase
On 2016-02-12 00:31, Paulo da Silva wrote: > What is the best (shortest memory usage) way to store lots of > pathnames in memory where: > > 1. Path names are pathname=(dirname,filename) > 2. There many different dirnames but much less than pathnames > 3. dirnames have in general many chars > > Th

Re: Storing a big amount of path names

2016-02-11 Thread Ben Finney
Paulo da Silva writes: > What is the best (shortest memory usage) way to store lots of > pathnames in memory I challenge the premise. Why is “shortest memory usage” your criterion for “best”, here? How have you determined that factors like “easily understandable when reading”, or “using standar

Re: Storing a big amount of path names

2016-02-11 Thread Chris Angelico
On Fri, Feb 12, 2016 at 11:31 AM, Paulo da Silva wrote: > What is the best (shortest memory usage) way to store lots of pathnames > in memory where: > > 1. Path names are pathname=(dirname,filename) > 2. There many different dirnames but much less than pathnames > 3. dirnames have in general many

Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Hi! What is the best (shortest memory usage) way to store lots of pathnames in memory where: 1. Path names are pathname=(dirname,filename) 2. There many different dirnames but much less than pathnames 3. dirnames have in general many chars The idea is to share the common dirnames. More realisti

tarfile : secure extract?

2016-02-11 Thread Ulli Horlacher
In https://docs.python.org/2/library/tarfile.html there is a warning: Never extract archives from untrusted sources without prior inspection. It is possible that files are created outside of path, e.g. members that have absolute filenames starting with "/" or filenames with two dots "..".

Re: tarfile : read from a socket?

2016-02-11 Thread Random832
On Thu, Feb 11, 2016, at 11:41, Ulli Horlacher wrote: > When I use: > > for member in taro.getmembers(): > print('extracting "%s"' % member.name) > taro.extract(member) > > I get the error: > > File "/usr/lib/python2.7/tarfile.py", line 556, in seek > raise StreamError("seeki

Re: Cygwin and Python3

2016-02-11 Thread alvin . hacopian
On Thursday, February 11, 2016 at 10:18:53 AM UTC-8, Benoit Izac wrote: > Terry Reedy writes: > > >>> Since Python runs natively in Windows, why are you trying to run it > >>> with Cygwin? I'm not implying that you shouldn't, just offhand I don't > >>> see a reason for it. > >> > >> I do it becau

Re: Suggested datatype for getting latest information from log files

2016-02-11 Thread Martin A. Brown
Greetings, >I have timestamped log files I need to read through and keep track >of the most upto date information. > >For example lets say we had a log file > >timeStamp,name,marblesHeld,timeNow,timeSinceLastEaten I do not quite understand the distinction between timeStamp and timeNow. >I nee

Re: Suggested datatype for getting latest information from log files

2016-02-11 Thread ltomassmail
On Thursday, February 11, 2016 at 6:16:35 PM UTC, jmp wrote: > On 02/11/2016 07:07 PM, ltomassm...@gmail.com wrote: > > I thought a dictionary would be a good idea because of the key restrictions > > ensuring no duplicates, so the data would always update - However because > > they are unordered

Re: Suggested datatype for getting latest information from log files

2016-02-11 Thread ltomassmail
On Thursday, February 11, 2016 at 6:16:35 PM UTC, jmp wrote: > On 02/11/2016 07:07 PM, ltomassm...@gmail.com wrote: > > I thought a dictionary would be a good idea because of the key restrictions > > ensuring no duplicates, so the data would always update - However because > > they are unordered

Re: Cygwin and Python3

2016-02-11 Thread Benoit Izac
Terry Reedy writes: >>> Since Python runs natively in Windows, why are you trying to run it >>> with Cygwin? I'm not implying that you shouldn't, just offhand I don't >>> see a reason for it. >> >> I do it because it's easier to install third party packages, those that >> need an external library

Re: Cygwin and Python3

2016-02-11 Thread Benoit Izac
Terry Reedy writes: >>> Since Python runs natively in Windows, why are you trying to run it >>> with Cygwin? I'm not implying that you shouldn't, just offhand I don't >>> see a reason for it. >> >> I do it because it's easier to install third party packages, those that >> need an external library

Re: Suggested datatype for getting latest information from log files

2016-02-11 Thread jmp
On 02/11/2016 07:07 PM, ltomassm...@gmail.com wrote: I thought a dictionary would be a good idea because of the key restrictions ensuring no duplicates, so the data would always update - However because they are unordered and I need to do some more processing on the data afterwards I'm having

Suggested datatype for getting latest information from log files

2016-02-11 Thread ltomassmail
I have timestamped log files I need to read through and keep track of the most upto date information. For example lets say we had a log file timeStamp,name,marblesHeld,timeNow,timeSinceLastEaten I need to keep track of every 'name' in this table, I don't want duplicate values so if values com

Re: Does anyone here use wxGlade on Linux?

2016-02-11 Thread cl
Frank Miles wrote: > On Thu, 11 Feb 2016 14:29:04 +, cl wrote: > > > I am trying out wxGlade on Linux, version 0.7.1 of wxGlade on xubuntu > > 15.10. > > > > I have already written something using wxPython directly so I have the > > basics (of my Python skills and the environment) OK I think

Re: tarfile : read from a socket?

2016-02-11 Thread Lars Gustäbel
On Thu, Feb 11, 2016 at 04:41:43PM +, Ulli Horlacher wrote: > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) What about using an iterator? def myiter(tar): for t in tar: print "extracting", t.name yield t sfo = soc

Re: tarfile : read from a socket?

2016-02-11 Thread Peter Otten
Ulli Horlacher wrote: > Ulli Horlacher wrote: > >> With >> >> taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') >> >> I get no more error. > > Of course, this is the writing client. > > Now I have a small problem with the reading client. > > This code works so far: > > sfo

modifying a standard module? (was: Re: tarfile : read from a socket?)

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher wrote: > This code works so far: > > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) > > But it does not writes anything to the terminal to inform the user. > > When I use: > > for member in taro.getmembers(): >

Re: tarfile : read from a socket?

2016-02-11 Thread MRAB
On 2016-02-11 16:41, Ulli Horlacher wrote: Ulli Horlacher wrote: With taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') I get no more error. Of course, this is the writing client. Now I have a small problem with the reading client. This code works so far: sfo = sock.ma

Re: Handling transactions in Python DBI module

2016-02-11 Thread Israel Brewster
On Feb 10, 2016, at 8:06 PM, Frank Millman wrote: > > "Israel Brewster" wrote in message > news:92d3c964-0323-46ee-b770-b89e7e7e6...@ravnalaska.net... > >> I am working on implementing a Python DB API module, and am hoping I can get >> some help with figuring out the workflow of handling tran

Re: Handling transactions in Python DBI module

2016-02-11 Thread Israel Brewster
On Feb 10, 2016, at 8:14 PM, Chris Angelico wrote: > > On Thu, Feb 11, 2016 at 4:06 PM, Frank Millman wrote: >> A connection has 2 possible states - 'in transaction', or 'not in >> transaction'. When you create the connection it starts off as 'not'. >> >> When you call cur.execute(), it checks

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher wrote: > With > > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') > > I get no more error. Of course, this is the writing client. Now I have a small problem with the reading client. This code works so far: sfo = sock.makefile('r') taro = tarfile.open(fil

Re: Does anyone here use wxGlade on Linux?

2016-02-11 Thread Frank Miles
On Thu, 11 Feb 2016 14:29:04 +, cl wrote: > I am trying out wxGlade on Linux, version 0.7.1 of wxGlade on xubuntu > 15.10. > > I have already written something using wxPython directly so I have the > basics (of my Python skills and the environment) OK I think. > > I am having a lot of troubl

Re: Unable to insert data into MongoDB.

2016-02-11 Thread Arjun Srivatsa
Hello, I changed PORT = 27017 to PORT = 5. I am not getting the error anymore. But I am still unable to insert the data into MongoDB. On Thursday, February 11, 2016 at 4:12:30 PM UTC+1, Arjun Srivatsa wrote: > Hi guys. I am basically transferring the data from PLC to PC (where

Re: Unable to insert data into MongoDB.

2016-02-11 Thread MRAB
On 2016-02-11 15:12, Arjun Srivatsa wrote: Hi guys. I am basically transferring the data from PLC to PC (where the Python API runs) but I'm unable to insert into MongoDB thereafter. When I run the Python script on IDLE, the output is Hello World! Traceback (most recent call last): File "C:\Use

Unable to insert data into MongoDB.

2016-02-11 Thread Arjun Srivatsa
Hi guys. I am basically transferring the data from PLC to PC (where the Python API runs) but I'm unable to insert into MongoDB thereafter. When I run the Python script on IDLE, the output is Hello World! Traceback (most recent call last): File "C:\Users\SRA2LO\Desktop\API.py", line 32, in s.bi

Does anyone here use wxGlade on Linux?

2016-02-11 Thread cl
I am trying out wxGlade on Linux, version 0.7.1 of wxGlade on xubuntu 15.10. I have already written something using wxPython directly so I have the basics (of my Python skills and the environment) OK I think. I am having a lot of trouble getting beyond the first hurdle of creating a trivial Pytho

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Chris Angelico wrote: > Sounds like tarfile needs a seekable file. How big is this file you're > reading? No limits. It can be many TBs... The use case is: http://fex.rus.uni-stuttgart.de:8080/ -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mai

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher wrote: > I have: > > sock = socket.create_connection((server,port)) > bs = kB64 > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w') > > > > Traceback (most recent call last): > (...) > File "./fexit.py", line 1838, in sex_send > taro = tarf

Re: Cygwin and Python3

2016-02-11 Thread Mark Lawrence
On 11/02/2016 07:46, blindanag...@nowhere.net wrote: On 10/02/2016 23:05, Mike S wrote: On 2/10/2016 5:05 AM, Mark Lawrence wrote: [snip] Have you seen this? http://www.davidbaumgold.com/tutorials/set-up-python-windows/ I have now, but I'm perfectly happy with the free versions of Visual S

Re: tarfile : read from a socket?

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 11:53 PM, Ulli Horlacher wrote: > I have: > > sock = socket.create_connection((server,port)) > bs = kB64 > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w') > > > > Traceback (most recent call last): > (...) > File "./fexit.py", line 1838, in sex_send

Re: tarfile : read from a socket?

2016-02-11 Thread MRAB
On 2016-02-11 12:53, Ulli Horlacher wrote: Antoon Pardon wrote: > (How) can I read a tar file from a (tcp) socket? > I do not have a pathname but a socket object from socket.create_connection # First you construct a file object with makefile. fo = socket.makefile() # Then you use the fileob

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Antoon Pardon wrote: > > (How) can I read a tar file from a (tcp) socket? > > I do not have a pathname but a socket object from socket.create_connection > > # First you construct a file object with makefile. > > fo = socket.makefile() > > # Then you use the fileobj argument with tarfile.open.

Re: timedelta and float multiplication in python 2

2016-02-11 Thread Peter Otten
Nagy László Zsolt wrote: > I ran into a problem today where I had to determine the mean point > between two datetimes. Here is an example: > start = datetime.datetime(2016,2,11) stop = datetime.datetime.now() mean = start + (stop-start)*0.5 > Traceback (most recent call last): >

Re: Heap Implementation

2016-02-11 Thread Cem Karan
On Feb 10, 2016, at 1:23 PM, "Sven R. Kunze" wrote: > Hi Cem, > > On 08.02.2016 02:37, Cem Karan wrote: >> My apologies for not writing sooner, but work has been quite busy lately >> (and likely will be for some time to come). > > no problem here. :) > >> I read your approach, and it looks p

Re: timedelta and float multiplication in python 2

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 9:39 PM, Nagy László Zsolt wrote: > I have checked and it does work with Python 3. But it does not work with > Python 2 - is there a good reason for this? Mainly that Python 3 has had six years of development since Python 2.7, and Python 2 has been getting only bugfixes an

Re: tarfile : read from a socket?

2016-02-11 Thread Antoon Pardon
On 02/11/2016 09:31 AM, Ulli Horlacher wrote: > https://docs.python.org/2/library/tarfile.html says: > > tarfile.open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs) > > Return a TarFile object for the pathname name. > > > (How) can I read a tar file from a (tcp) socket? > I do not

timedelta and float multiplication in python 2

2016-02-11 Thread Nagy László Zsolt
I ran into a problem today where I had to determine the mean point between two datetimes. Here is an example: >>> start = datetime.datetime(2016,2,11) >>> stop = datetime.datetime.now() >>> mean = start + (stop-start)*0.5 Traceback (most recent call last): File "", line 1, in TypeError: unsuppo

Re: tarfile : read from a socket?

2016-02-11 Thread INADA Naoki
Have you tried socket.makefile() method? -- https://mail.python.org/mailman/listinfo/python-list

Suggestions for best practices when automating geocoding task

2016-02-11 Thread kbtyo
Good Morning, I welcome feedback and suggestions for libraries or resources in order to automate the following: 1. Given a directory of CSV files (each containing an address field) a. Read each CSV file b. Use address instance in row as part of a query and send request to external API

Re: Cygwin and Python3

2016-02-11 Thread Mike S via Python-list
On 2/10/2016 11:46 PM, blindanag...@nowhere.net wrote: On 10/02/2016 23:05, Mike S wrote: On 2/10/2016 5:05 AM, Mark Lawrence wrote: [snip] Have you seen this? http://www.davidbaumgold.com/tutorials/set-up-python-windows/ I have now, but I'm perfectly happy with the free versions of Visual

Re: asyncio and blocking - an update

2016-02-11 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmor8dMv2TDtq8RHQgWeSAaZgAmxK9gFth=oojhidwh...@mail.gmail.com... So really, the question is: Is this complexity buying you enough performance that it's worthwhile? Indeed, that is the question. Actually, in my case it is not quite the question. F

Re: Handling transactions in Python DBI module

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 6:59 PM, dieter wrote: > In my context (web applications), I strongly discourage this use - at least > when "conn" does not handle subtransactions properly. > > In a web application, the main transaction should in general be controlled > at the request level: a request shou

tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
https://docs.python.org/2/library/tarfile.html says: tarfile.open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs) Return a TarFile object for the pathname name. (How) can I read a tar file from a (tcp) socket? I do not have a pathname but a socket object from socket.create_conn

Re: Handling transactions in Python DBI module

2016-02-11 Thread dieter
Israel Brewster writes: > I am working on implementing a Python DB API module, and am hoping I can get > some help with figuring out the workflow of handling transactions. In my > experience (primarily with psycopg2) the workflow goes like this: > > - When you open a connection (or is it when y

Re: Handling transactions in Python DBI module

2016-02-11 Thread dieter
Chris Angelico writes: > ... > When I advise my students on basic databasing concepts, I recommend > this structure: > > conn = psycopg2.connect(...) > > with conn, conn.cursor() as cur: > cur.execute(...) > > The transaction block should always start at the 'with' block and end > when it exit