Re: PyWart: Exception error paths far too verbose

2013-01-19 Thread Steven D'Aprano
On Sat, 19 Jan 2013 19:15:55 -0800, Ramchandra Apte wrote: [snip dozens of irrelevant quoted lines] > Right-click the file in the traceback and there is an "Go to file/line" > option. Please trim your replies so that the reader doesn't have to scroll through page after page of irrelevant text t

Re: PyWart: Exception error paths far too verbose

2013-01-19 Thread Ramchandra Apte
On Wednesday, 16 January 2013 15:23:55 UTC+5:30, Terry Reedy wrote: > On 1/16/2013 12:59 AM, Rick Johnson wrote: > > > > > > Python needs to trim the path to the source file from which the > > > exception was caught and only display the relative path starting from > > > your personal library f

How do functions get access to builtins?

2013-01-19 Thread Steven D'Aprano
I've been playing around with ChainedMap in Python 3.3, and run into something which perplexes me. Let's start with an ordinary function that accesses one global and one builtin. x = 42 def f(): print(x) If you call f(), it works as expected. But let's make a version with no access to bu

Re: Vote tallying...

2013-01-19 Thread Walter Hurry
On Sat, 19 Jan 2013 00:12:25 -0500, Dennis Lee Bieber wrote: > On Sat, 19 Jan 2013 07:24:40 +1100, Ben Finney > declaimed the following in > gmane.comp.python.general: > > >> * MySQL's development has suffered under Sun, and become virtually >> moribund under Oracle. They operate as a closed

Re: Forcing Python to detect DocumentRoot

2013-01-19 Thread alex23
On Jan 16, 11:51 pm, Ferrous Cranus wrote: > When trying to open an html template within Python script i use a relative > path to say go one folder back and open index.html > > f = open( '../' + page ) > > How to say the same thing in an absolute way by forcing Python to detect > DocumentRoot by

Re: Vote tallying...

2013-01-19 Thread Lie Ryan
On 20/01/13 08:22, Dennis Lee Bieber wrote: On Sat, 19 Jan 2013 22:58:17 +1100, Lie Ryan Which is the same restriction as when using XML/JSON. What it means by locking the entire database is that an sqlite database can only be read/written by a single program at any moment in time. For batch

Re: Vote tallying...

2013-01-19 Thread Chris Angelico
On Sun, Jan 20, 2013 at 4:46 AM, Tim Chase wrote: > Reading the MySQL gotchas and comparing it to the PostgreSQL gotchas, the > MySQL ones scare the pants off my inner DBA, while the PostgreSQL ones are > mostly "if you're running at 6+yr old version of the software, there are > some peculiar beha

Re: Question on Python Conference

2013-01-19 Thread Ned Deily
In article <1506a9c3-7abb-4360-91f1-f65631104...@googlegroups.com>, subhabangal...@gmail.com wrote: > As I know Python Foundation organizes some conferences all through the year. > Most probably they are known as Pycon. But I have some different question. > The question is, is it possible to atte

Re: Forcing Python to detect DocumentRoot

2013-01-19 Thread Piet van Oostrum
Ferrous Cranus writes: > This is addon domain's counter.py snippet tried to load an image mail.png and > failed because it cant see past its document root > > > # render html template and print it > data = f.read() > counter = ''' >

Re: Any algorithm to preserve whitespaces?

2013-01-19 Thread Mitya Sirenef
On 01/19/2013 05:13 AM, Santosh Kumar wrote: I have a working script which takes argv[1] as an input, deassembles each line, and then each word. Then after it capitalizes all its word (upcases the first letter) and then prints it out on the stdout. That script does the capitalization work fine,

Re: ANN: Python training "text movies"

2013-01-19 Thread Mitya Sirenef
On 01/19/2013 04:32 AM, Franck Ditter wrote: In article , Mitya Sirenef wrote: On 01/14/2013 01:34 AM, Franck Ditter wrote: In article , Jason Friedman wrote: That is right; I would also add that it may be overwhelming for a newbie to be reading through a large "wall of text" -- here

Question on Python Conference

2013-01-19 Thread subhabangalore
Dear Group, As I know Python Foundation organizes some conferences all through the year. Most probably they are known as Pycon. But I have some different question. The question is, is it possible to attend it by Video Conferencing? Or if I request for the same will it be granted? Regards, Subha

Re: Vote tallying...

2013-01-19 Thread Tim Chase
On 01/18/13 23:19, Dennis Lee Bieber wrote: On Fri, 18 Jan 2013 18:54:32 -0400, Zero Piraeus On 18 January 2013 16:57, Tim Chase wrote: - there are just some serious what-the-heck's in MySQL's handling of some edge cases regarding NULL values and dates (Feb 31st anybody). There's a good com

Re: Messing with the GC

2013-01-19 Thread Steven D'Aprano
And further thoughts... On Sat, 19 Jan 2013 14:47:16 +, Jens Thoms Toerring wrote: > Hi, > >triggered by some problems I had with PySide I got a bit > confused about what the GC may do in certain situations. Here's a small > test program I cobbled together: > > import sys > > class X(

Re: Messing with the GC

2013-01-19 Thread Terry Reedy
On 1/19/2013 9:47 AM, Jens Thoms Toerring wrote: The code comments mostly answer your questions about what happens or does not happen and when. The comments after add more detail. import sys class X( object ) : def __init__( self, parent, cnt ) : print( "In constructor for {0}

Re: Messing with the GC

2013-01-19 Thread Steven D'Aprano
On Sat, 19 Jan 2013 16:24:37 +, Steven D'Aprano wrote: > On Sat, 19 Jan 2013 14:47:16 +, Jens Thoms Toerring wrote: > >> Ok, the destrucor for the first instance of the X class is called only >> after printing out "After", so the GC didn't delete the object before. >> But then there are o

Re: Messing with the GC

2013-01-19 Thread Steven D'Aprano
On Sat, 19 Jan 2013 14:47:16 +, Jens Thoms Toerring wrote: > Ok, the destrucor for the first instance of the X class is called only > after printing out "After", so the GC didn't delete the object before. > But then there are obviously no calls of the destructors of neither the > second instan

Messing with the GC

2013-01-19 Thread Jens Thoms Toerring
Hi, triggered by some problems I had with PySide I got a bit confused about what the GC may do in certain situations. Here's a small test program I cobbled together: import sys class X( object ) : def __init__( self, parent, cnt ) : print( "In constructor for {0} {1}".format( self

Re: test failed: test_urlwithfrag

2013-01-19 Thread Kev Dwyer
Terry Reedy wrote: > On 1/7/2013 1:26 PM, Elli Lola wrote: > >> $ ./python -m test -v test_urlwithfrag >> >> == CPython 3.3.0 (default, Jan 4 2013, 23:08:00) [GCC 4.6.3] >> == Linux-3.2.0-35-generic-pae-i686-with-debian-wheezy-sid little-endian >> == /home/me/Programme/Python/Python-3.3.0/bui

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Roy Smith
In article <50fa1bf1$0$30003$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I wish to add a key to a dict only if it doesn't already exist, but do it > in a thread-safe manner. > > The naive code is: > > if key not in dict: > dict[key] = value > > > but of course there is

Re: Forcing Python to detect DocumentRoot

2013-01-19 Thread Barry Scott
On 16 Jan 2013, at 13:51, Ferrous Cranus wrote: > When trying to open an html template within Python script i use a relative > path to say go one folder back and open index.html > > f = open( '../' + page ) > > How to say the same thing in an absolute way by forcing Python to detect > Docume

Re: Vote tallying...

2013-01-19 Thread Lie Ryan
On 19/01/13 00:43, Andrew Robinson wrote: On 01/18/2013 08:47 AM, Stefan Behnel wrote: Andrew Robinson, 18.01.2013 00:59: I have a problem which may fit in a mysql database Everything fits in a MySQL database - not a reason to use it, though. Py2.5 and later ship with sqlite3 and if you go for

Re: Beginner Tutorials

2013-01-19 Thread Kwpolska
Who thought that not setting the “Reply replies to the ML” option was a good idea? -- Forwarded message -- From: Rik Date: Fri, Jan 18, 2013 at 8:31 PM Subject: Re: Beginner Tutorials To: kwpol...@gmail.com On Friday, January 18, 2013 7:20:13 PM UTC, Kwpolska wrote: > > On Fri, J

Re: Question related to multiprocessing.Process

2013-01-19 Thread Terry Reedy
On 1/19/2013 12:05 AM, Chris Angelico wrote: On Sat, Jan 19, 2013 at 3:50 PM, Cen Wang wrote: Hi, when I use multiprocessing.Process in this way: from multiprocessing import Process class MyProcess(Process): def __init__(self): Process.__init__(self) def run(self):

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Steven D'Aprano
On Fri, 18 Jan 2013 20:15:26 -0800, Chris Rebert wrote: > On Friday, January 18, 2013, Steven D'Aprano wrote: > >> I wish to add a key to a dict only if it doesn't already exist, but do >> it in a thread-safe manner. [...] > I'm not entirely sure, but have you investigated dict.setdefault() ? Gr

Re: Any algorithm to preserve whitespaces?

2013-01-19 Thread Lie Ryan
On 19/01/13 21:13, Santosh Kumar wrote: I have a working script which takes argv[1] as an input, deassembles each line, and then each word. Then after it capitalizes all its word (upcases the first letter) and then prints it out on the stdout. That script does the capitalization work fine, but,

Re: ANN: Python training "text movies"

2013-01-19 Thread Franck Ditter
In article , Mitya Sirenef wrote: > On 01/14/2013 01:34 AM, Franck Ditter wrote: > > In article , > > Jason Friedman wrote: > > > >>> That is right; I would also add that it may be overwhelming for a newbie > >>> to be reading through a large "wall of text" -- here you have blank > >>> space

Re: Uniquely identifying each & every html template

2013-01-19 Thread Dave Angel
On 01/19/2013 03:39 AM, Ferrous Cranus wrote: Τη Σάββατο, 19 Ιανουαρίου 2013 12:09:28 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: I don't understand the problem. A trivial Python script could scan through all the files in the directory, checking which ones are missing the identifier, and rewrit

Re: Any built-in ishashable method ?

2013-01-19 Thread Peter Otten
Dave Angel wrote: > On 01/18/2013 07:06 AM, Peter Otten wrote: >> Jean-Michel Pichavant wrote: >> >>> That brings me to another question, is there any valid test case where >>> key1 != key2 and hash(key1) == hash(key2) ? Or is it some kind of design >>> flaw ? >> >> I don't think there is a use ca

Re: Any built-in ishashable method ?

2013-01-19 Thread Dave Angel
On 01/18/2013 07:06 AM, Peter Otten wrote: Jean-Michel Pichavant wrote: That brings me to another question, is there any valid test case where key1 != key2 and hash(key1) == hash(key2) ? Or is it some kind of design flaw ? I don't think there is a use case for such a behaviour other than anno

Re: Uniquely identifying each & every html template

2013-01-19 Thread Ferrous Cranus
Τη Σάββατο, 19 Ιανουαρίου 2013 12:09:28 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > I don't understand the problem. A trivial Python script could scan > > through all the files in the directory, checking which ones are missing > > the identifier, and rewriting the file with the identifier adde

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Chris Angelico
On Sat, Jan 19, 2013 at 7:16 PM, Vito De Tullio wrote: > yeah, sure, but with a fixed value :) > > I mean: if the value is not important, why bother at all trying not to > override it with an if or a lock or other tecniques? doing > > d['key'] = 'fixed_value' > > multiple times in different th

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Vito De Tullio
Peter Otten wrote: uhhmm.. I think I misread the example d = {} d.setdefault(1, 2) > 2 d > {1: 2} d.setdefault(1, 3) > 2 d > {1: 2} yeah, sure it can be useful for the OP... -- ZeD -- http://mail.python.org/mailman/listinfo/python-list

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Mitya Sirenef
On 01/19/2013 02:35 AM, Mitya Sirenef wrote: On 01/19/2013 02:27 AM, Vito De Tullio wrote: Chris Rebert wrote: How can I add a key in a thread-safe manner? I'm not entirely sure, but have you investigated dict.setdefault() ? but how setdefault makes sense in this context? It's used to set a

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Vito De Tullio
Peter Otten wrote: How can I add a key in a thread-safe manner? >>> I'm not entirely sure, but have you investigated dict.setdefault() ? >> >> but how setdefault makes sense in this context? It's used to set a >> default value when you try to retrieve an element from the dict, not when >> yo

Re: Forcing Python to detect DocumentRoot

2013-01-19 Thread Ferrous Cranus
Τη Παρασκευή, 18 Ιανουαρίου 2013 11:34:05 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Sat, Jan 19, 2013 at 5:58 AM, Ferrous Cranus wrote: > > > Τη Παρασκευή, 18 Ιανουαρίου 2013 3:28:10 μ.μ. UTC+2, ο χρήστης Joel > > Goldstick έγραψε: > > > > > >> DocumentRoot = os.environ['HOME'] + 'pub

Re: Safely add a key to a dict only if it does not already exist?

2013-01-19 Thread Peter Otten
Vito De Tullio wrote: > Chris Rebert wrote: > >>> How can I add a key in a thread-safe manner? >> I'm not entirely sure, but have you investigated dict.setdefault() ? > > but how setdefault makes sense in this context? It's used to set a default > value when you try to retrieve an element from t