Re: SMTPHandler and mail subject

2014-03-12 Thread Chris Withers
If you want a much more fully-featured mail handler for the standard logging framework, there's this: https://pypi.python.org/pypi/mailinglogger/3.8.0 cheers, Chris On 12/03/2014 12:25, eras.rasmu...@gmail.com wrote: It works. Thank you :) Eras -- Simplistix - Content Management, B

Re: Deep vs. shallow copy?

2014-03-12 Thread Rustom Mody
On Thursday, March 13, 2014 4:37:53 AM UTC+5:30, Steven D'Aprano wrote: > On Wed, 12 Mar 2014 15:29:59 +, Alex van der Spek wrote: > > Having been taught programming in Algol60 Python still defeats me at > > times! Particularly since Algol60 wasn't very long lived and what came > > thereafter

Re: What does gc.get_objects() return?

2014-03-12 Thread Terry Reedy
On 3/12/2014 3:34 PM, Jurko Gospodnetić wrote: I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? This took about 10 seconds. >>> impor

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Cameron Simpson
On 13Mar2014 11:22, Ben Finney wrote: > Cameron Simpson writes: > > Therefore you need to continue _only_ if you get EEXIST. Otherwise > > abort. > > If you target Python 3.3 or later, you can catch “FileExistsError” > http://docs.python.org/3/library/exceptions.html#FileExistsError> > which is

Re: unittest weirdness

2014-03-12 Thread Terry Reedy
On 3/12/2014 11:32 AM, Ethan Furman wrote: I strongly suspect it's memory. When I originally wrote the code I tried to include six months worth of EoM data, but had to back it down to three as my process kept mysteriously dying at four or more months. There must be waaay too much stuff bein

Re: Tuples and immutability

2014-03-12 Thread Terry Reedy
On 3/12/2014 9:35 PM, Ian Kelly wrote: On Wed, Mar 12, 2014 at 5:20 PM, Steven D'Aprano wrote: On Tue, 11 Mar 2014 17:06:43 -0600, Ian Kelly wrote: That's true but irrelevant to my point, which was to counter the assertion that mutable types can always be assumed to be able to perform operati

Re: Tuples and immutability

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 5:20 PM, Steven D'Aprano wrote: > On Tue, 11 Mar 2014 17:06:43 -0600, Ian Kelly wrote: > >> That's true but irrelevant to my point, which was to counter the >> assertion that mutable types can always be assumed to be able to perform >> operations in-place. > > "Always"? Not

Re: unittest weirdness

2014-03-12 Thread Ethan Furman
On 03/12/2014 04:38 PM, Steven D'Aprano wrote: [snip lots of good advice for unit testing] I was just removing the Personally Identifiable Information. Each test is pulling a payment from a batch of payments, so the first couple asserts are simply making sure I have the payment I think I hav

Re: unittest weirdness

2014-03-12 Thread Ethan Furman
On 03/12/2014 04:47 PM, Steven D'Aprano wrote: top -Mm -d 0.5 Cool, thanks! -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Ben Finney
Cameron Simpson writes: > Therefore you need to continue _only_ if you get EEXIST. Otherwise > abort. If you target Python 3.3 or later, you can catch “FileExistsError” http://docs.python.org/3/library/exceptions.html#FileExistsError> which is far simpler than messing around with ‘errno’ values.

Re: unittest weirdness

2014-03-12 Thread Steven D'Aprano
On Wed, 12 Mar 2014 08:32:29 -0700, Ethan Furman wrote: >> Some systems have an oom (Out Of Memory) process killer, which nukes >> (semi-random) process when the system exhausts memory. Is it possible >> this is happening? If so, you should see some log message in one of >> your system logs. >

Re: unittest weirdness

2014-03-12 Thread Steven D'Aprano
On Tue, 11 Mar 2014 13:58:17 -0700, Ethan Furman wrote: > class Test_wfbrp_20140225(TestCase): > > @classmethod > def setUpClass(cls): > cls.pp = wfbrp.PaymentProcessor( > '.../lockbox_file', > '.../aging_file', > [ > Path

Re: Tuples and immutability

2014-03-12 Thread Steven D'Aprano
On Tue, 11 Mar 2014 17:06:43 -0600, Ian Kelly wrote: > On Tue, Mar 11, 2014 at 10:46 AM, Steven D'Aprano > wrote: >>> There are a number of possible solutions. One possibility would be to >>> copy the Circle as an Ellipse and return the new object instead of >>> mutating it. Then you have the si

Re: unittest weirdness

2014-03-12 Thread Steven D'Aprano
On Wed, 12 Mar 2014 08:32:29 -0700, Ethan Furman wrote: > There must > be waaay too much stuff being kept alive by the stack traces of the > failed tests. I believe that unittest does keep stack traces alive until the process ends. I thought that there was a recent bug report for it, but th

Re: DB API question - where is a stored procedure's return value?

2014-03-12 Thread Petite Abeille
On Mar 13, 2014, at 12:00 AM, Ian Kelly wrote: > As a general solution, one might wrap a stored procedure that returns > a value into a stored procedure that has an output parameter and call > it with callproc. Some implementations might include a return value > in the parameter list anyway. A

Re: What does gc.get_objects() return?

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 9:35 AM, Ian Kelly wrote: > Or is it? > a = 1,2,3 gc.is_tracked(a) > True gc.collect() > 0 gc.is_tracked(a) > False Huh, *that* is interesting! ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Deep vs. shallow copy?

2014-03-12 Thread Steven D'Aprano
On Wed, 12 Mar 2014 15:29:59 +, Alex van der Spek wrote: > Having been taught programming in Algol60 Python still defeats me at > times! Particularly since Algol60 wasn't very long lived and what came > thereafter (FORTRAN) much worse. Fortran came first. Fortran was the first high-level lang

Re: DB API question - where is a stored procedure's return value?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 5:00 PM, Ian Kelly wrote: > result = cursor.var(cx_Oracle.NUMBER) > cursor.execute(":1 := test_proc()", [result]) > print(result.getvalue()) Sorry, that should properly be: result = cursor.var(cx_Oracle.NUMBER) cursor.execute("BEGIN :1 := test_proc();

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Mark Lawrence
On 12/03/2014 22:19, Cameron Simpson wrote: On 12Mar2014 13:29, zoom wrote: I would like to assure that when writing to a file I do not overwrite an existing file, but I'm unsure which is the best way to approach to this problem. As I can see, there are at least two possibilities: 1. I could u

Re: DB API question - where is a stored procedure's return value?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:44 PM, Skip Montanaro wrote: > What do other database adaptors do about stored procedure return > values? Does PEP 249 need revision? I can't speak generally, but in cx_Oracle you either execute a query like this: result = cursor.var(cx_Oracle.NUMBER) cursor.exe

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Cameron Simpson
On 12Mar2014 13:29, zoom wrote: > I would like to assure that when writing to a file I do not > overwrite an existing file, but I'm unsure which is the best way to > approach to this problem. As I can see, there are at least two > possibilities: > > 1. I could use fd = os.open("x", os.O_WRONLY |

Re: What does gc.get_objects() return?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 4:35 PM, Ian Kelly wrote: >> So not all optimizations are done that could be done. > > Or is it? > a = 1,2,3 gc.is_tracked(a) > True gc.collect() > 0 gc.is_tracked(a) > False I guess the reason for this is that when PyTuple_New is called, it knows how m

Re: What does gc.get_objects() return?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:44 PM, Chris Angelico wrote: > The concept is that the GC tracks (in that sense; everything in > CPython is refcounted, but that's not what these functions look at) > anything that could be a part of a reference cycle. That's all it > concerns itself with, so something th

TALK.ORIGINS CENSORS THE TRUTH

2014-03-12 Thread I THRINAXODON
EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# http://thrinaxodon.word

Re: What does gc.get_objects() return?

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 8:28 AM, Jurko Gospodnetić wrote: > So gc.collect() returns a list of all the objects GC is in charge of, and > which instances are and are not tracked by the GC is, I guess, an > interpreter implementation detail. I assume you don't mean collect() there, as that returns

DB API question - where is a stored procedure's return value?

2014-03-12 Thread Skip Montanaro
I've stumbled on a problem with the python-sybase module. If I have a stored procedure like this: create stored procedure test_proc as return 1 and call it from Python like this: curs.callproc("test_proc", {}) it's not clear to me where the return status is stored. Currently, the python-syb

Re: What does gc.get_objects() return?

2014-03-12 Thread Jurko Gospodnetić
Hi. On 12.3.2014. 21:02, MRAB wrote: I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? gc.is_tracked(...) might be relevant to you

Re: locale getlocale returns None on OSX

2014-03-12 Thread Ned Deily
In article <1394626979.46880.yahoomailba...@web163806.mail.gq1.yahoo.com>, Albert-Jan Roskam wrote: > locale.getlocale() sometimes returns (None, None) under OSX (Python 2, not > sure about Python 3, but I think so). The problem is outlined here: > http://stackoverflow.com/questions/1629699/loc

Re: What does gc.get_objects() return?

2014-03-12 Thread MRAB
On 2014-03-12 19:34, Jurko Gospodnetić wrote: Hi all. I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? [snip] gc.is_tracked(...

Re: What does gc.get_objects() return?

2014-03-12 Thread Dan Stromberg
On Wed, Mar 12, 2014 at 12:34 PM, Jurko Gospodnetić wrote: > Hi all. > > I was wondering if someone could explain gc.get_objects() in a bit more > detail to me. > > Does it return a list of 'all objects known to Python'? Only some of them? > Which does it return? Which it does not? > > For

Re: locale getlocale returns None on OSX

2014-03-12 Thread Albert-Jan Roskam
> > From: Albert-Jan Roskam >To: Python >Sent: Wednesday, March 12, 2014 1:22 PM >Subject: locale getlocale returns None on OSX > > >Hi, > >locale.getlocale() sometimes returns (None, None) under OSX (Python 2, not >sure about Python 3, but I think so). The pr

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Emile van Sebille
On 3/12/2014 5:29 AM, zoom wrote: 2. Alternatively, a unique string could be generated to assure that no same file exists. I can see one approach to this is to include date and time in the file name. But this seems to me a bit clumsy, and is not unique, i.e. it could happen (at least in theory)

What does gc.get_objects() return?

2014-03-12 Thread Jurko Gospodnetić
Hi all. I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? For example (done using CPython 3.4 interactive interpreter) here it doe

Re: Deep vs. shallow copy?

2014-03-12 Thread Wayne Brehaut
On 12 Mar 2014 15:29:59 GMT, Alex van der Spek wrote: >On Wed, 12 Mar 2014 10:00:09 -0500, Zachary Ware wrote: > >> On Wed, Mar 12, 2014 at 9:25 AM, Alex van der Spek >> wrote: === 8< === >Having been taught programming in Algol60 Python still defeats me at times! >Particularly since Algol60 w

Re:Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Dave Angel
zoom Wrote in message: > Hi! > > I would like to assure that when writing to a file I do not overwrite an > existing file, but I'm unsure which is the best way to approach to this > problem. As I can see, there are at least two possibilities: > > 1. I could use fd = os.open("x", os.O_WRONLY |

Re: unittest weirdness

2014-03-12 Thread Roy Smith
In article , Ethan Furman wrote: > > Alternatively, maybe something inside your process is just calling > > sys.exit(), or even os._exit(). You'll see the exit() system call in > > the strace output. > > My bare try/except would have caught that. A bare except would catch sys.exit(), but not

Re: How to create an instance of a python class from C++

2014-03-12 Thread Stefan Behnel
Barry Scott, 11.03.2014 22:37: > On 5 Mar 2014, at 00:14, Bill wrote: >> I can't figure out how to create an instance >> of a python class from 'C++': > > Why not use pycxx from http://sourceforge.net/projects/cxx/? > > This lib does all the heavy lifting for you for both python2 and python3. > H

Re: unittest weirdness

2014-03-12 Thread Ethan Furman
On 03/12/2014 06:44 AM, Roy Smith wrote: In article , Ethan Furman wrote: I've tried it both ways, and both ways my process is being killed, presumably by the O/S. What evidence do you have the OS is killing the process? I put a bare try/except around the call to unittest.main, with a pr

Re: Deep vs. shallow copy?

2014-03-12 Thread Alex van der Spek
On Wed, 12 Mar 2014 10:00:09 -0500, Zachary Ware wrote: > On Wed, Mar 12, 2014 at 9:25 AM, Alex van der Spek > wrote: >> I think I understand the difference between deep vs. shallow copies but >> I was bitten by this: >> >> with open(os.path.join('path', 'foo.txt', 'rb') as txt: >> reader =

Re: Deep vs. shallow copy?

2014-03-12 Thread Zachary Ware
On Wed, Mar 12, 2014 at 9:25 AM, Alex van der Spek wrote: > I think I understand the difference between deep vs. shallow copies but > I was bitten by this: > > with open(os.path.join('path', 'foo.txt', 'rb') as txt: > reader = csv.reader(txt) > data = [row.append(year) for row in reader]

Re: Deep vs. shallow copy?

2014-03-12 Thread Skip Montanaro
On Wed, Mar 12, 2014 at 9:25 AM, Alex van der Spek wrote: > with open(os.path.join('path', 'foo.txt', 'rb') as txt: > reader = csv.reader(txt) > data = [row.append(year) for row in reader] Forget deep v. shallow copies. What is the value of the variable year? And why would you expect li

Deep vs. shallow copy?

2014-03-12 Thread Alex van der Spek
I think I understand the difference between deep vs. shallow copies but I was bitten by this: with open(os.path.join('path', 'foo.txt', 'rb') as txt: reader = csv.reader(txt) data = [row.append(year) for row in reader] This does not work although the append does complete. The below wor

Re: How do we pass default argument value to create thread object?

2014-03-12 Thread Zachary Ware
On Wed, Mar 12, 2014 at 8:09 AM, Piyush Verma <114piy...@gmail.com> wrote: > Hi, > > I am using Thread class to create threads. > > thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"]) > thread.start() > > > This code is throwing compilation error(Ipython). > In [19]: import threa

Re: How do we pass default argument value to create thread object?

2014-03-12 Thread Jean-Michel Pichavant
- Original Message - > Hi, > I am using Thread class to create threads. > > thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"]) > thread.start() > > This code is throwing compilation error(Ipython). > In [19]: import threading > In [20]: def Fun(agr1, arg2, arg3=No

Re: unittest weirdness

2014-03-12 Thread Roy Smith
In article , Ethan Furman wrote: > I've tried it both ways, and both ways my process is being killed, presumably > by the O/S. What evidence do you have the OS is killing the process? Some systems have an oom (Out Of Memory) process killer, which nukes (semi-random) process when the system e

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Tim Chase
On 2014-03-12 13:29, zoom wrote: > 2. Alternatively, a unique string could be generated to assure that > no same file exists. I can see one approach to this is to include > date and time in the file name. But this seems to me a bit clumsy, > and is not unique, i.e. it could happen (at least in theo

How do we pass default argument value to create thread object?

2014-03-12 Thread Piyush Verma
Hi, I am using Thread class to create threads. thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"]) thread.start() This code is throwing compilation error(Ipython). In [19]: import threading In [20]: def Fun(agr1, arg2, arg3=None): : pass : In [21]: thread =

Re: Save to a file, but avoid overwriting an existing file

2014-03-12 Thread Skip Montanaro
This seems to be an application-level decision. If so, in your application, why not just check to see if the file exists, and implement whatever workaround you deem correct for your needs? For example (to choose a simple, but rather silly, file naming strategy): fname = "x" while os.path.exists(fn

Save to a file, but avoid overwriting an existing file

2014-03-12 Thread zoom
Hi! I would like to assure that when writing to a file I do not overwrite an existing file, but I'm unsure which is the best way to approach to this problem. As I can see, there are at least two possibilities: 1. I could use fd = os.open("x", os.O_WRONLY | os.O_CREAT | os.O_EXCL) which will f

Re: SMTPHandler and mail subject

2014-03-12 Thread eras . rasmuson
It works. Thank you :) Eras -- https://mail.python.org/mailman/listinfo/python-list

locale getlocale returns None on OSX

2014-03-12 Thread Albert-Jan Roskam
Hi, locale.getlocale() sometimes returns (None, None) under OSX (Python 2, not sure about Python 3, but I think so). The problem is outlined here: http://stackoverflow.com/questions/1629699/locale-getlocale-problems-on-osx What is the cause of this? Is it limited to just Darwin systes? Does the

Re: Tuples and immutability

2014-03-12 Thread Antoon Pardon
Op 12-03-14 10:51, Ian Kelly schreef: > On Wed, Mar 12, 2014 at 3:39 AM, Antoon Pardon > wrote: >> The documentation is wrong at that point as the following code illustrates. > Either way it still has to do a getitem and a setitem, but if you have > a more nested structure then the extra getitems

Re: which async framework?

2014-03-12 Thread Neal Becker
Grant Edwards wrote: > On 2014-03-11, Antoine Pitrou wrote: >> Sturla Molden gmail.com> writes: >>> >>> Chris Withers simplistix.co.uk> wrote: >>> > Hi All, >>> > >>> > I see python now has a plethora of async frameworks and I need to try >>> > and pick one to use from: >>> > >>> > - asyncio

Re: unittest weirdness

2014-03-12 Thread Ethan Furman
On 03/11/2014 08:36 PM, Terry Reedy wrote: On 3/11/2014 6:13 PM, John Gordon wrote: In Ethan Furman writes: if missing: raise ValueError('invoices %r missing from batch' % missing) It's been a while since I wrote test cases, but I recall using the assert* methods (

Re: SMTPHandler and mail subject

2014-03-12 Thread Andriy Kornatskyy
Eras, You have to override getSubject method of SMTPHandler. http://hg.python.org/cpython/file/677327810121/Lib/logging/handlers.py#l907 Thanks. Andriy Kornatskyy On Mar 12, 2014, at 12:08 PM, eras.rasmu...@gmail.com wrote: > Hi > > I use logging.handlers.SMTPHandler and i have tried to chan

Re: Tuples and immutability

2014-03-12 Thread Oscar Benjamin
On 12 March 2014 03:25, Terry Reedy wrote: > On 3/11/2014 10:01 PM, Rick Johnson wrote: >> >> >> On Thursday, February 27, 2014 4:18:01 PM UTC-6, Ian wrote: >>> >>> x += y is meant to be equivalent, except possibly in-place and >>> more efficient, than x = x + y. > > > The manual actually says "An

SMTPHandler and mail subject

2014-03-12 Thread eras . rasmuson
Hi I use logging.handlers.SMTPHandler and i have tried to change subject of mail. Are there exists easy way to do that ? Subject of mail can change repeatedly depends on content of mail. Eras -- https://mail.python.org/mailman/listinfo/python-list

Re: which async framework?

2014-03-12 Thread Ian Kelly
On Tue, Mar 11, 2014 at 5:38 PM, Chris Angelico wrote: > On Wed, Mar 12, 2014 at 10:18 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> What corner cases are there with threads that you don't have with >>> anything else? >> >> There are numerous. Here's one example: deadlocks due to two threa

Re: Tuples and immutability

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:39 AM, Antoon Pardon wrote: > The documentation is wrong at that point as the following code illustrates. Either way it still has to do a getitem and a setitem, but if you have a more nested structure then the extra getitems are not repeated. For example, using your log

Re: Tuples and immutability

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 12:28 AM, Steven D'Aprano wrote: > On Tue, 11 Mar 2014 23:25:19 -0400, Terry Reedy wrote: >> Nope, 'similar' is not 'equivalent'. Evaluating x twice instead of once >> and possibly allocating a new object versus not take extra time. In a >> statement like "x.y.z[3*n+m] += 1

Re: Tuples and immutability

2014-03-12 Thread Antoon Pardon
Op 12-03-14 07:28, Steven D'Aprano schreef: > On Tue, 11 Mar 2014 23:25:19 -0400, Terry Reedy wrote: > >> Nope, 'similar' is not 'equivalent'. Evaluating x twice instead of once >> and possibly allocating a new object versus not take extra time. In a >> statement like "x.y.z[3*n+m] += 1", calculati

Re: Balanced trees

2014-03-12 Thread Antoon Pardon
Op 11-03-14 00:24, Roy Smith schreef: > In article <8761nmrnfk@elektro.pacujo.net>, > Marko Rauhamaa wrote: > >> Anyway, this whole debate is rather unnecessary since every developer is >> supposed to have both weapons in their arsenal. > The problem with having a choice is that it opens up

Re: beautiful soup get class info

2014-03-12 Thread Peter Otten
Christopher Welborn wrote: > On 03/06/2014 02:22 PM, teddyb...@gmail.com wrote: >> I am using beautifulsoup to get the title and date of the website. >> title is working fine but I am not able to pull the date. Here is the >> code in the url: >> >> October 22, 2011 >> >> In Python, I am using th

Re: Tuples and immutability

2014-03-12 Thread Ethan Furman
On 03/11/2014 08:25 PM, Terry Reedy wrote: On 3/11/2014 10:01 PM, Rick Johnson wrote: On Thursday, February 27, 2014 4:18:01 PM UTC-6, Ian wrote: x += y is meant to be equivalent, except possibly in-place and more efficient, than x = x + y. The manual actually says "An augmented assignment e