Re: Getting "empty" attachment with smtplib

2012-11-14 Thread Dieter Maurer
Tobiah writes: > I just found out that the attachment works fine > when I read the mail from the gmail website. Thunderbird > complains that the attachment is empty. The MIME standard (a set of RFCs) specifies how valid messages with attachments should look like. Fetch the mail (unprocessed if

Re: Python garbage collector/memory manager behaving strangely

2012-11-14 Thread Dieter Maurer
a...@pythoncraft.com (Aahz) writes: > ... def readlines(f): lines = [] while "f is not empty": line = f.readline() if not line: break if len(line) > 2 and line[-2:] == '|\n': lines.append(lin

DNS from Python (was Re: Subprocess puzzle and two questions)

2012-11-14 Thread Aahz
In article , Chris Angelico wrote: >On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith wrote: >> >> My first thought to solve both of these is that it shouldn't be too >> hard to hand-craft a minimal DNS query and send it over UDP. Then, I >> hunted around a bit and found that somebody had already don

Re: Subprocess puzzle and two questions

2012-11-14 Thread Kushal Kumaran
Chris Angelico writes: > On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith wrote: >> In article , >> Chris Angelico wrote: >> >>> I'm slightly surprised that there's no way with the Python stdlib to >>> point a DNS query at a specific server >> >> Me too, including the "only slightly" part. The nor

Re: Subprocess puzzle and two questions

2012-11-14 Thread Dave Angel
On 11/14/2012 09:21 PM, Chris Angelico wrote: > On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith wrote: >> In article , >> Chris Angelico wrote: >> >>> Indeed. But Python boasts that the batteries are included, and given >>> the wealth of other networking facilities that are available, it is a >>> bit

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> Indeed. But Python boasts that the batteries are included, and given >> the wealth of other networking facilities that are available, it is a >> bit of a hole that you can't run DNS queries in this way.

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , Chris Angelico wrote: > Indeed. But Python boasts that the batteries are included, and given > the wealth of other networking facilities that are available, it is a > bit of a hole that you can't run DNS queries in this way. Think of the socket and struct modules as a pile of carbo

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> I'm slightly surprised that there's no way with the Python stdlib to >> point a DNS query at a specific server > > Me too, including the "only slightly" part. The normal high-level C > resolver routin

Re: Python questions help

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 12:47 PM, su29090 <129k...@gmail.com> wrote: > I brought a python book and i'm a beginner and I read and tried to do the > questions and I still get it wrong. Pick one of the questions, write as much of the code as you can, and then post the specific difficulties you're ha

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , Chris Angelico wrote: > I'm slightly surprised that there's no way with the Python stdlib to > point a DNS query at a specific server Me too, including the "only slightly" part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old gethostbyname se

Python questions help

2012-11-14 Thread su29090
I brought a python book and i'm a beginner and I read and tried to do the questions and I still get it wrong. How to create a program that reads an uspecified number of integers, that determines how many positive and negative values have been read, and computes the total and average of the inpu

Re: Simple Question regarding running .py program

2012-11-14 Thread Terry Reedy
On 11/14/2012 2:02 AM, ru...@yahoo.com wrote: On the other hand finding and configuring a newsreader for someone whose never done it before, as you recommend, is a major time consumer. Use a mail/news program such as Thunderbird and the newsreader comes for free. Setting up a gmane account wi

Re: Simple Question regarding running .py program

2012-11-14 Thread Terry Reedy
On 11/13/2012 11:10 PM, Chris Angelico wrote: On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou wrote: Thank you Dave and everybody here for your helpful comments!This place is awesome! I found this group when I googled python-list. Seems like this is not the usual way you guys access the list?

Re: Simple Question regarding running .py program

2012-11-14 Thread Steven D'Aprano
On Wed, 14 Nov 2012 23:07:53 +, Steven D'Aprano wrote: > On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: [...] > [...] >> As an aside, I've noticed that some those most vocal against GG have >> also been very vocal about this group being inclusive. > > I call bullshit. If you are going to ac

Re: access spreadsheet data

2012-11-14 Thread Terry Reedy
On 11/14/2012 1:35 AM, Amit Agrawal wrote: my problem is, i want to access data in spreadsheet to python code manualy My data is 1/1982 8:00:000 1/2/1982 8:00:000 1/3/1982 8:00:000 1/4/1982 8:00:000 1/5/1982 8:00:000.7885 1/6/1982 8:00:000 1/7/1982 8:00:000 1/8/1982 8:00:001.6127 You used tabs

Re: Simple Question regarding running .py program

2012-11-14 Thread Joshua Landau
Steven, whilst I hold you in high regard, this post seems spurned by bias. I would urge you to reconsider your *argument*, although your *position* has merit. On 14 November 2012 23:07, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wro

Re: Simple Question regarding running .py program

2012-11-14 Thread rurpy
On Wednesday, November 14, 2012 4:07:53 PM UTC-7, Steven D'Aprano wrote: > On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: > [...] > > As an aside, I've noticed that some those most vocal against GG have > > also been very vocal about this group being inclusive. > > I call bullshit. If you are go

Re: Simple Question regarding running .py program

2012-11-14 Thread Steven D'Aprano
On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: > On 11/14/2012 06:35 AM, Chris Angelico wrote: [...] >> I stand by what I said. Members, plural, of this list. I didn't say >> "all members of", ergo the word "some" is superfluous, yet not needful, >> as Princess Ida put it. > > Then you would ha

Describing code with slides

2012-11-14 Thread John Graves
I'm trying to work out the best way to provide a description of some code in a set of presentation slides which can be played backward and forward through the bits that someone is trying to understand (rather than using a screencast -- where you can never seem to rewind just the right amount ...).

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith wrote: > I wrote: >>> Oh, my. You're using DNS as a replacement for ping? Fair enough. In >>> that case, all you really care about is that you can connect to port 53 >>> on the server... >>> >>> s = socket.socket() >>> s.connect(('8.8.8.8', 53)) > > In

Re: creating size-limited tar files

2012-11-14 Thread Dave Angel
On 11/14/2012 03:43 PM, Andrea Crotti wrote: > > Anyway the only thing I wanted to understand is if using the pipes in > subprocess is exactly the same as doing > the Linux pipe, or not. It's not the same thing, but you can usually assume it's close. Other effects will probably dominate any diff

Re: creating size-limited tar files

2012-11-14 Thread Andrea Crotti
On 11/14/2012 04:33 PM, Dave Angel wrote: Well, as I said, I don't see how the particular timing has anything to do with the rest of the thread. If you want to do an ls within a Python program, go ahead. But if all you need can be done with ls itself, then it'll be slower to launch python just

Re: Running a curl command within py script

2012-11-14 Thread Gisle Vanem
"Smaran Harihar" wrote: i found pycurl to execute python curl command but not sure how I can execute the curl command using the pycurl. curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d 'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp' http://localhost:8080/geoserver/re

Re: Error

2012-11-14 Thread MRAB
On 2012-11-14 15:18, inshu chauhan wrote: for this code m getting this error : CODE : def ComputeClasses(data): radius = .5 points = [] for cy in xrange(0, data.height): for cx in xrange(0, data.width): if data[cy,cx] != (0.0,0.0,0.0): centr

Re: Simple Question regarding running .py program

2012-11-14 Thread rurpy
On 11/14/2012 06:35 AM, Chris Angelico wrote: > On Wed, Nov 14, 2012 at 6:02 PM, rurpy wrote: >> On 11/13/2012 11:02 PM, Chris Angelico wrote: >>> To be more accurate: This is deprecated *by members of* this list. As >>> there is no commanding/controlling entity here, it's up to each >>> individual

How Run Py.test from PyScripter

2012-11-14 Thread san
I am a newbie to py.test , Please let me know how to run the py.test in PyScripter Editor. I have tried in the belwo way but it doesn't work. import pytest def func(x): return x + 1 def test_answer(): assert func(3) == 5 pytest.main() below is the Exception that i get Traceback (most recent

Running a curl command within py script

2012-11-14 Thread Smaran Harihar
Hi Guys, i found pycurl to execute python curl command but not sure how I can execute the curl command using the pycurl. curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d 'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp' http://localhost:8080/geoserver/rest/workspaces/acme

Re: Getting "empty" attachment with smtplib

2012-11-14 Thread Tobiah
I just found out that the attachment works fine when I read the mail from the gmail website. Thunderbird complains that the attachment is empty. Thanks, Toby On 11/14/2012 09:51 AM, Tobiah wrote: I've been sending an email blast out with smtplib and it's been working fine. I'm attaching an ht

Re: creating size-limited tar files

2012-11-14 Thread Dave Angel
On 11/14/2012 11:16 AM, andrea crotti wrote: > 2012/11/14 Dave Angel : >> On 11/14/2012 10:56 AM, andrea crotti wrote: >>> Ok this is all very nice, but: >>> >>> [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py > /dev/null >>> >>> real 0m21.215s >>> user 0m0.750s >>> sys 0m1.703s >>>

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
I wrote: >> Oh, my. You're using DNS as a replacement for ping? Fair enough. In >> that case, all you really care about is that you can connect to port 53 >> on the server... >> >> s = socket.socket() >> s.connect(('8.8.8.8', 53)) In article , Chris Angelico wrote: >That assumes that (a) the

Re: Python-list Digest, Vol 110, Issue 106

2012-11-14 Thread Jun Tanaka
Hi, I have a question about Django. I easy_installed Django1.4 and psycopg2, and python manage.py syncdb. And gave me a error; No module named psycopg2.extensions. posgre9.1 is installed. It works fine on my MAC but not my Windows. Does anyone know about this issue Hope to resolve this issue soon

Re: creating size-limited tar files

2012-11-14 Thread andrea crotti
2012/11/14 Dave Angel : > On 11/14/2012 10:56 AM, andrea crotti wrote: >> Ok this is all very nice, but: >> >> [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py > /dev/null >> >> real 0m21.215s >> user 0m0.750s >> sys 0m1.703s >> >> [andrea@andreacrotti tar_baller]$ time ls -lR /home/

Re: creating size-limited tar files

2012-11-14 Thread Dave Angel
On 11/14/2012 10:56 AM, andrea crotti wrote: > Ok this is all very nice, but: > > [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py > /dev/null > > real 0m21.215s > user 0m0.750s > sys 0m1.703s > > [andrea@andreacrotti tar_baller]$ time ls -lR /home/andrea | cat > /dev/null > > real

Re: Error

2012-11-14 Thread Joel Goldstick
On Wed, Nov 14, 2012 at 10:18 AM, inshu chauhan wrote: > > for this code m getting this error : > > CODE : > def ComputeClasses(data): > radius = .5 > points = [] > for cy in xrange(0, data.height): > for cx in xrange(0, data.width): > if data[cy,cx] != (0.0,0.0,0.0

Re: Subprocess puzzle and two questions

2012-11-14 Thread wrw
On Nov 14, 2012, at 9:22 AM, Roy Smith wrote: > In article , > William Ray Wing wrote: > >> On Nov 13, 2012, at 11:41 PM, Roy Smith wrote: >> >>> In article , >>> w...@mac.com wrote: >>> I need to time the operation of a command-line utility (specifically nslookup) from within a p

Re: Error

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 2:18 AM, inshu chauhan wrote: > > for this code m getting this error : > > CODE : > def ComputeClasses(data): > if data[cy,cx] != (0.0,0.0,0.0): > centre = data[cy, cx] > ... > dist = distance(centre, point) > > ERROR

Error

2012-11-14 Thread inshu chauhan
for this code m getting this error : CODE : def ComputeClasses(data): radius = .5 points = [] for cy in xrange(0, data.height): for cx in xrange(0, data.width): if data[cy,cx] != (0.0,0.0,0.0): centre = data[cy, cx] points.append(cent

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 1:22 AM, Roy Smith wrote: > Oh, my. You're using DNS as a replacement for ping? Fair enough. In > that case, all you really care about is that you can connect to port 53 > on the server... > > import socket > import time > s = socket.socket() > t0 = time.time() > s.conne

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , William Ray Wing wrote: > On Nov 13, 2012, at 11:41 PM, Roy Smith wrote: > > > In article , > > w...@mac.com wrote: > > > >> I need to time the operation of a command-line utility (specifically > >> nslookup) from within a python program I'm writing. > > > > Ugh. Why are you d

Re: Python garbage collector/memory manager behaving strangely

2012-11-14 Thread Aahz
In article <50570de3$0$29981$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: >On Mon, 17 Sep 2012 06:46:55 -0400, Dave Angel wrote: >> On 09/16/2012 11:25 PM, alex23 wrote: >>> >>> def readlines(f): >>> lines = [] >>> while "f is not empty": >>> line =

Re: Simple Question regarding running .py program

2012-11-14 Thread Chris Angelico
On Wed, Nov 14, 2012 at 6:02 PM, wrote: > On 11/13/2012 11:02 PM, Chris Angelico wrote: >> To be more accurate: This is deprecated *by members of* this list. As >> there is no commanding/controlling entity here, it's up to each >> individual to make a decision - for instance, abusive users get >>

Re: Generate unique ID for URL

2012-11-14 Thread Johannes Bauer
On 14.11.2012 13:33, Dave Angel wrote: > Te birthday paradox could have been important had the OP stated his goal > differently. What he said was: > > """Ideally I would want to avoid collisions altogether. But if that means > significant extra CPU time then 1 collision in 10 million hashes wou

Re: Generate unique ID for URL

2012-11-14 Thread Dave Angel
On 11/14/2012 06:29 AM, Johannes Bauer wrote: > > > When doing these calculations, it's important to keep the birthday > paradox in mind (this is kind of counter-intuitive): The chance of a > collission raises tremendously when we're looking for *any* arbitrary > two hashes colliding within a cert

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 11:51, Hans Mulder wrote: > It would be nice if he could give specific error messages, e.g. > > "Can't write %s because it is locked by %s." > > vs. > > "Can't write %s because you don't have write access." > > I can't speak for Ali, but I'm always annoyed by error message

Re: Detect file is locked - windows

2012-11-14 Thread Hans Mulder
On 14/11/12 11:02:45, Tim Golden wrote: > On 14/11/2012 00:33, Ali Akhavan wrote: >> I am trying to open a file in 'w' mode open('file', 'wb'). open() >> will throw with IOError with errno 13 if the file is locked by >> another application or if user does not have permission to open/write >> to the

Re: creating size-limited tar files

2012-11-14 Thread andrea crotti
2012/11/14 Kushal Kumaran : > > Well, well, I was wrong, clearly. I wonder if this is fixable. > > -- > regards, > kushal > -- > http://mail.python.org/mailman/listinfo/python-list But would it not be possible to use the pipe in memory in theory? That would be way faster and since I have in theor

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 00:33, Ali Akhavan wrote: > I am trying to open a file in 'w' mode open('file', 'wb'). open() > will throw with IOError with errno 13 if the file is locked by > another application or if user does not have permission to open/write > to the file. > > How can I distinguish these two ca

Re: Generate unique ID for URL

2012-11-14 Thread Johannes Bauer
On 14.11.2012 02:39, Roy Smith wrote: > The next step is to reduce the number of bits you are encoding. You > said in another post that "1 collision in 10 million hashes would be > tolerable". So you need: > math.log(10*1000*1000, 2) > 23.25349666421154 > > 24 bits worth of key. Nope

Re: Supported Platforms for Python

2012-11-14 Thread Ulrich Eckhardt
Am 14.11.2012 10:51, schrieb Kiran N Mallekoppa: 1. Is this information available somewhere? 2. I was pointed to PEP-11, which documents the platforms that are not supported. So, can we take that all active versions of Python (2.7.3 and 3.3, i believe) are supported on all the OS flavors that Pyt

Re: Generate unique ID for URL

2012-11-14 Thread Richard
thanks for perspective! -- http://mail.python.org/mailman/listinfo/python-list

Re: Supported Platforms for Python

2012-11-14 Thread Kiran N Mallekoppa
Hi there! Our team at IBM are exploring the possibility of implementing one of our products using Python. I had a query in this regard. As per IBM's policy, we list details of platforms that our product works on - including the flavors of OS, the versions supported (and sometimes, even the servi

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 00:33, Ali Akhavan wrote: > I am trying to open a file in 'w' mode open('file', 'wb'). open() > will throw with IOError with errno 13 if the file is locked by > another application or if user does not have permission to open/write > to the file. What version of Python are you using?

Re: Generate unique ID for URL

2012-11-14 Thread Johannes Bauer
On 14.11.2012 01:41, Richard Baron Penman wrote: > I found the MD5 and SHA hashes slow to calculate. Slow? For URLs? Are you kidding? How many URLs per second do you want to calculate? > The builtin hash is fast but I was concerned about collisions. What > rate of collisions could I expect? MD5

Re: stackoverflow quote on Python

2012-11-14 Thread Chris Angelico
On Wed, Nov 14, 2012 at 7:56 PM, wrote: > I'am still fascinated by the mathematically absurd "negative > logic" used in and by the flexible string representation > (algorithm). I am still fascinated that you persist in comparing a buggy old Python against a bug-free new Python and haven't notice

Re: Division matrix

2012-11-14 Thread wxjmfauth
Le mardi 13 novembre 2012 02:00:28 UTC+1, Cleuson Alves a écrit : > Hello, I need to solve an exercise follows, first calculate the inverse > matrix and then multiply the first matrix. > > I await help. > > Thank you. > > follows the code below incomplete. > > > > m = [[1,2,3],[4,5,6],[7,8,9

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 08:55, Hans Mulder wrote: > On 14/11/12 02:14:59, Mark Lawrence wrote: >> On 14/11/2012 00:33, Ali Akhavan wrote: >>> I am trying to open a file in 'w' mode open('file', 'wb'). open() will >>> throw with IOError with errno 13 if the file is locked by another >>> application or if user

Re: stackoverflow quote on Python

2012-11-14 Thread wxjmfauth
Le mardi 13 novembre 2012 16:53:30 UTC+1, Mark Lawrence a écrit : > On 13/11/2012 13:21, wxjmfa...@gmail.com wrote: > > > Le mardi 13 novembre 2012 06:42:19 UTC+1, Steven D'Aprano a écrit : > > >> On Tue, 13 Nov 2012 03:08:54 +, Mark Lawrence wrote: > > >> > > >> * strings are now proper te

Re: Detect file is locked - windows

2012-11-14 Thread Hans Mulder
On 14/11/12 02:14:59, Mark Lawrence wrote: > On 14/11/2012 00:33, Ali Akhavan wrote: >> I am trying to open a file in 'w' mode open('file', 'wb'). open() will >> throw with IOError with errno 13 if the file is locked by another >> application or if user does not have permission to open/write to the

Re: creating size-limited tar files

2012-11-14 Thread Kushal Kumaran
Ian Kelly writes: > On Tue, Nov 13, 2012 at 11:05 PM, Kushal Kumaran > wrote: >> Or, you could just change the p1's stderr to an io.BytesIO instance. >> Then call p2.communicate *first*. > > This doesn't seem to work. > b = io.BytesIO() p = subprocess.Popen(["ls", "-l"], stdout=b) > Tr

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-14 Thread Hans Mulder
On 13/11/12 22:36:47, Thomas Rachel wrote: > Am 12.11.2012 19:30 schrieb Hans Mulder: > >> This will break if there are spaces in the file name, or other >> characters meaningful to the shell. If you change if to >> >> xargsproc.append("test -f '%s/{}'&& md5sum '%s/{}'" >>