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 the dict, not when you try
> to set a new one ...

But it also sets the value if the key is not found:

"""
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
"""

>>> d = {}
>>> d.setdefault(1, 2)
2
>>> d
{1: 2}
>>> d.setdefault(1, 3)
2
>>> d
{1: 2}


It has been suggested that get_or_set() would have been a better name for 
that functionality...

-- 
http://mail.python.org/mailman/listinfo/python-list


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'] + 'public_html'
> 
> >
> 
> > Yes, iam using this and it works.
> 
> > One last thing:
> 
> >
> 
> > my python script file is located at 
> > /home/nikos/public_html/addon_domain/cgi-bin/
> 
> >
> 
> > How python is able to run the following statement?
> 
> >
> 
> > f = open( '/home/nikos/public_html/' + page )
> 
> >
> 
> > which is clearly levels up of addon domain's DocumentRoot?
> 
> 
> 
> Time to take a step backward and figure out what you're really trying
> 
> to accomplish. I think, after gazing idly into my crystal ball for a
> 
> while, that you actually want to chroot your script - instead of
> 
> seeing "/home/nikos/public_html/" it would see just "/", and then it
> 
> can't access anything outside of that.
> 
> 
> 
> ChrisA


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 = '''
 mailto:[email protected]";>  
 
 
  Αριθμός Επισκεπτών 
  %d ''' % hits[0]


While from within the same counter.py file

# open html template file
f = open( '/home/nikos/public_html/test.txt' )

opens OK the page file which is also past addons domain's document root

Can you help counter.py to load the image? Why does it fail to load it? Python 
can have access to ANY filesystempath , no matter from what folder counter.py 
script runs from. Correct?
-- 
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 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
>> you try to set a new one ...
> 
> But it also sets the value if the key is not found:

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 threads is not a problem in my eyes...

-- 
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 
default
value when you try to retrieve an element from the dict, not when you 
try to

set a new one ...



I guess setdefault with a sentinel default value, then set to your
new value if d[k] is sentinel?

 - mitya




Er, that makes no sense.. just setdefault to desired value. -m



--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

--
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 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 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 threads is not a problem in my eyes...

How fixed is fixed?

>>> d={}
>>> d.setdefault("foo",1)
1
>>> d.setdefault("bar",2)
2
>>> d
{'bar': 2, 'foo': 1}

If list append is guaranteed atomic, and since setdefault is
apparently atomic, then this would be a thread-safe way to maintain a
dictionary of lists:

>>> d={}
>>> lst=d.setdefault("foo",[])
>>> lst.append(1)

Are those guarantees made?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


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 added. 

> 
> So, since you didn't come to that conclusion, there must be some other 
> 
> reason you don't want to edit the files.  Is it that the real sources 
> 
> are elsewhere (e.g. Dreamweaver), and whenever one recompiles those 
> 
> sources, these files get replaced (without identifiers)?

Exactly. Files get modified/updates thus the embedded identifier will be 
missing each time. So, relying on embedding code to html template content is 
not practical.
 

> If that's the case, then I figure you have about 3 choices:
> 1) use the file path as your key, instead of requiring a number

No, i cannot, because it would mess things at a later time on when i for 
example: 

1. mv name.html othername.html   (document's filename altered) 
2. mv name.html /subfolder/name.html   (document's filepath altered) 

Hence, new database counters will be created for each of the above actions, 
therefore i will be having 2 counters for the same file, and the latter one 
will start from a zero value.

Pros: If the file's contents gets updated, that won't affect the counter.
Cons: If filepath is altered, then duplicity will happen.


> 2) use a hash of the page  (eg. md5) as your key.  of course this could  
> mean that you get a new value whenever the page is updated.  That's good  
> in many situations, but you don't give enough information to know if 
> that's desirable for you or not.

That sounds nice! A hash is a mathematical algorithm that produce a unique 
number after analyzing each file's contents? But then again what if the html 
templated gets updated? That update action will create a new hash for the file, 
hence another counter will be created for the same file, same end result as (1) 
solution.

Pros: If filepath is altered, that won't affect the counter.
Cons: If file's contents gets updated the, then duplicity will happen.


> 3) Keep an external list of filenames, and their associated id numbers. 
> The database would be a good place to store such a list, in a separate table.

I did not understand that solution.


We need to find a way so even IF:

(filepath gets modified && file content's gets modified) simultaneously the 
counter will STILL retains it's value.
-- 
http://mail.python.org/mailman/listinfo/python-list


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 annoying
your collegues ;)



Beg to differ.  Nothing wrong with getting the same hash on objects that 
compare different.  It's called a hash collision, and is quite common, 
especially in large collections.


The problem is the converse of this, where the objects compare equal, 
but they have different hashes.


--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


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 case for such a behaviour other than
>> annoying your collegues ;)
>>
> 
> Beg to differ.  Nothing wrong with getting the same hash on objects that
> compare different.  It's called a hash collision, and is quite common,
> especially in large collections.

Of course.

> The problem is the converse of this, where the objects compare equal,
> but they have different hashes.

And that I read because my expectations won over the actual text.


-- 
http://mail.python.org/mailman/listinfo/python-list


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 rewriting the file with the identifier added.




So, since you didn't come to that conclusion, there must be some other

reason you don't want to edit the files.  Is it that the real sources

are elsewhere (e.g. Dreamweaver), and whenever one recompiles those

sources, these files get replaced (without identifiers)?


Exactly. Files get modified/updates thus the embedded identifier will be 
missing each time. So, relying on embedding code to html template content is 
not practical.



If that's the case, then I figure you have about 3 choices:
1) use the file path as your key, instead of requiring a number


No, i cannot, because it would mess things at a later time on when i for 
example:

1. mv name.html othername.html   (document's filename altered)
2. mv name.html /subfolder/name.html   (document's filepath altered)

Hence, new database counters will be created for each of the above actions, 
therefore i will be having 2 counters for the same file, and the latter one 
will start from a zero value.

Pros: If the file's contents gets updated, that won't affect the counter.
Cons: If filepath is altered, then duplicity will happen.



2) use a hash of the page  (eg. md5) as your key.  of course this could
mean that you get a new value whenever the page is updated.  That's good
in many situations, but you don't give enough information to know if
that's desirable for you or not.


That sounds nice! A hash is a mathematical algorithm that produce a unique 
number after analyzing each file's contents? But then again what if the html 
templated gets updated? That update action will create a new hash for the file, 
hence another counter will be created for the same file, same end result as (1) 
solution.

Pros: If filepath is altered, that won't affect the counter.
Cons: If file's contents gets updated the, then duplicity will happen.



3) Keep an external list of filenames, and their associated id numbers.
The database would be a good place to store such a list, in a separate table.


I did not understand that solution.


We need to find a way so even IF:

(filepath gets modified && file content's gets modified) simultaneously the 
counter will STILL retains it's value.



You don't yet have a programming problem, you have a specification 
problem.  Somehow, you want a file to be considered "the same" even when 
it's moved, renamed and/or modified.  So all files are the same, and you 
only need one id.


Don't pick a mechanism until you have an self-consistent spec.

--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


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 after the current paragraph so the attention is focused even more
> >>> on the last few lines.
> >>>
> >>> Additionally, since instructions scroll automatically, I can space them
> >>> out more than you would conventionally do in a manual.
> >>>
> >> Pretty cool.
> > When reading the source of the Web page which shows the scroll,
> > I can't find the reference to the text displayed. Only "text"...
> > How may we use the software which generates the Javascript ?
> > Thanks, it's cool.
> >
> >  franck
> 
> Thanks!
> 
>   the text is in var commands = ...
> 
> You can download the generator script here:
> 
> https://github.com/pythonbyexample/PBE/blob/master/code/jstmovie.py
> 
> (you also need to grab  tmovies dir)

When looking at the source of the page :
http://lightbird.net/larks/tmovies/strings.html
I find commands = []
I can't guess where the strings displayed come from...

franck
-- 
http://mail.python.org/mailman/listinfo/python-list


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, when it reassemble
the the words, it does it like this:

 lines.append(' '.join(words))

The biggest problem is, even when the input file has many spaces, it
strips it down to one.


replace:

words = line.split()

with:
words = line.split(' ')

> The whole script will look clumsy here. I have put it up on GitHub,
> here is it: 
https://github.com/santosh/capitalizr.py/blob/master/capitalizr


In general, when the script is just this short, it's better to put it 
directly on the message.


--
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 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() ?

Great! That's exactly what I need, thanks to everyone who responded.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


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):
 print 'x'

p = MyProcess()
p.start()

It just keeps printing 'x' on my command prompt and does not end. But I think 
MyProcess should print an 'x' and then terminate. I don't why this is 
happening. I'm using Win7 64 bit, Python 2.7.3. Any idea? Thanks in advance.


Multiprocessing on Windows requires that your module be importable. So
it imports your main module, which instantiates another MyProcess,
starts it, rinse and repeat. You'll need to protect your main routine
code:

if __name__=="__main__":
 p = MyProcess()
 p.start()


This is documented in
17.2.3. Programming guidelines
17.2.3.2. Windows

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


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: [email protected]

On Friday, January 18, 2013 7:20:13 PM UTC, Kwpolska wrote:
>
> On Fri, Jan 18, 2013 at 6:04 PM, Rik  wrote:
> > The reason for disabling right-click has nothing to do with protecting 
> > content, and everything to do with stopping my students from taking the 
> > lazy way out.
>
> http://lmgtfy.com/?q=don%27t+disable+right+click
>
> > Given the chance, they'll copy/paste the code and download the designs and 
> > edit them slightly. They'd get through the tutorials in about 25 minutes 
> > and have learnt next to nothing.
>
> Ways to overcome it:
> (a) curl/python -c 'import requests; requests.get('/wget
> http://usingpython.com/; (a nice textarea with the code
> (b) browser development tools, view source keyboard shortcuts etc.;
> (c) OCR;
> (d) disabling JavaScript;
> (e) writing it by hand, because it is relatively short.
>
> > In talking to students about existing resources, they said that blindly 
> > copying code didn't really help them get a deep understanding of algorithms 
> > and how to apply them to other problems.
>
> Can’t you fail them (or whatnot) if they don’t learn that?  That
> sounds like the best solution to such problems.


Yeah I could, and maybe for larger problems i'll maybe not block the
code, I just find that students copy/paste the examples and *think*
they understand what's going on, and then aren't able to be
independent in solving similar problems. This way they are sort of
'forced' to actually understand the examples to a level that i'm happy
will hep them solve other problems. It's my job to guide their
learning in that way.
>
>
>
>
> > In the password-protected solutions i will provide downloads to source 
> > code, etc, and any student smart enough to get around my protection 
> > probably understands python basics :)
>
> WordPress ≠ Python, unless your password is a code used to generate
> the 01189998819991197253 number out of prime factorization or
> something like that.


Now that'd make a nice problem :)
>
>
> > Thanks for the comments.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
> --
> Kwpolska  | GPG KEY: 5EAAEA16
> stop html mail| always bottom-post
> http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


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 an external database,
why use
MySQL if you can have PostgreSQL for the same price?

MySQL is provided by the present server host.  It's pretty standard at
web hosting sites.
It works through "import MySQLdb" -- and it means an IP call for every
action...


That is not quite true. With most client libraries, including MySQLdb, 
connection to localhost goes through a local unix socket (or named pipe 
in Windows) instead of the TCP stack.



But
it wants to lock the entire database against reads as well as writes
when any access of the database happens.  Which is bad...


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 
processing, locking the entire database is never going to be a problem; 
for CGI scripts (and their variants), it may be a performance bottleneck 
for extremely high volume websites.



--
http://mail.python.org/mailman/listinfo/python-list


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 
> DocumentRoot by itself?

In the general case it is not possible. There is no single convention you can 
use to detect the top of a web site.

If you always use apache httpd then read the value of DocumentRoot from 
httpd.conf

Barry
-- 
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 Roy Smith
In article <[email protected]>,
 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 a race condition there: it is possible that 
> another thread may have added the same key between the check and the 
> store.
> 
> How can I add a key in a thread-safe manner?

You want something along the lines of:

from threading import Lock
lock = Lock()
[...]
lock.acquire()
if key not in dict:
   dict[key] = value
lock.release()

You probably want to wrap that up in a context manager to ensure the 
lock is released if you get an exception.  You don't want your entire 
program to hang just because somebody handed you a key which wasn't 
hashable, for example.
-- 
http://mail.python.org/mailman/listinfo/python-list


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/build/test_python_30744
>> Testing with flags: sys.flags(debug=0, inspect=0, interactive=0,
>> optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0,
>> ignore_environment=0, verbose=0, bytes_warning=0, quiet=0,
>> hash_randomization=1)
>> [1/1] test_urlwithfrag
>> test test_urlwithfrag crashed -- Traceback (most recent call last):
>>File "/home/me/Programme/Python/Python-3.3.0/Lib/test/regrtest.py",
>> line 1213, in runtest_inner
>>  the_package = __import__(abstest, globals(), locals(), [])
>> ImportError: No module named 'test.test_urlwithfrag'
>>
>> 1 test failed:
>>  test_urlwithfrag
> 
> Read the message I sent you before.
> 
> (To everyone else, I already explained that the error message means
> exactly what it says and listed the test_url files that do exist. No
> need to repeat a third time.)
> 

I encountered the OP's error message while building Python 3.3 today.

$ make test


FAIL: test_urlwithfrag (test.test_urllib2net.OtherNetworkTests) 
 
--  
 
Traceback (most recent call last):  
 
  File "/usr/src/packages/BUILD/Python-3.3.0/Lib/test/test_urllib2net.py", 
line 165, in test_urlwithfrag   
   
"http://docs.python.org/glossary.html#glossary";)
 
AssertionError: 'http://docs.python.org/2/glossary.html' != 
'http://docs.python.org/glossary.html#glossary' 
  
- http://docs.python.org/2/glossary.html
 
?-- 
 
+ http://docs.python.org/glossary.html#glossary 
 
? +  

 

 
--  
 
Ran 15 tests in 15.307s 
 

 
FAILED (failures=1, skipped=1)  
 
test test_urllib2net failed 
 
make: *** [test] Error 1  


$ ./python -m test -v test_urllib2net   

== CPython 3.3.0 (default, Jan 19 2013, 13:46:53) [GCC 4.6.2]   
 
==   Linux-3.1.10-1.16-desktop-x86_64-with-SuSE-12.1-x86_64 little-endian   
 
==   /usr/src/packages/BUILD/Python-3.3.0/build/test_python_10447   
 
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)  
  
[1/1] test_urllib2net   
 
test_urllib2net skipped -- Use of the 'network' resource not enabled
 
1 test skipped: 
 
test_urllib2net 
 
Those skips are all expected on linux. 


$ ./python -m test -v test_urlwithfrag  

== CPython 3.3.0 (default, Jan 19 2013, 13:46:53) [GCC 4.6.2]   
 
==   Linux-3.1.10-1.16-desktop-x86_64-with-SuSE-12.1-x86_64 little-endian   
 
==   /usr/src/packages/BUILD/Python-3.3.0/build/test_python_10453   
 
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)  
  
[1/1] test_urlwithfrag  
 
test test_urlwithfrag crashed -- Traceback (most recent call last): 
 
  File "/usr/src/packages/BUILD/Python-3.3.0/Lib/test/regrtest.py", line 
1213, in runtest_inner  
 
the_package = __import__(abstest, globals(), locals(), [])  
 
ImportError: No module named 'test.test_urlwithfrag'
 

 
1 test failed:  

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, cnt ),
   file = sys.stderr )
self.parent = parent
self.cnt = cnt

def __del__( self ) :
print( "In destructor for {0} {1}".format( self, self.cnt ),
   file = sys.stderr )

def foo( self ) :
print( "Before", file = sys.stderr )
self.parent.z = X( self.parent, 2 ) # Is this bad?
print( "After", file = sys.stderr )

class Y( object ) :
def __init__( self ) :
print( "In constructor for {0}".format( self ),
   file = sys.stderr )
self.z = X( self, 1 )

def __del__( self ) :
print( "In destructor for {0}".format( self ),
   file = sys.stderr )

Y( ).z.foo( )

Have a look at the line with the comment. At this point the
only reference in existence to the X class instance, of which
a method is just being executed, goes out of scope. Thus I
would assume that the GC could now kick any time, possibly
even before the following call of print() or before the method
call returns. That, in turn might result in a crash of the
script.

Is my assumption about this flawed and there are no potential
dangers? Perhaps with

Y( ).z.foo( )

a temporary second reference is created that keeps the GC
for removing the X instance...

Another thing I'm puzzled about is the output of the
script:

In constructor for <__main__.Y object at 0x2919210>
In constructor for <__main__.X object at 0x2919310> 1
Before
In constructor for <__main__.X object at 0x2919350> 2
After
In destructor for <__main__.X object at 0x2919310> 1

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 instance
of the X class nor of the Y class instance. Shouldn't
they be invoked before the program ends?

Thanks and best regards, Jens
-- 
  \   Jens Thoms Toerring  ___  [email protected]
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


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 instance of the X class nor of the Y class instance. Shouldn't
> they be invoked before the program ends?

You should avoid __del__ destructors whenever not absolutely necessary.

__del__ may not be called for objects that still exist when Python exits.

If you have a cycle of objects, and *any* of them have a __del__ method, 
it may be impossible for Python to work out a safe order for them to be 
deleted. Consequently they will never be reclaimed by the garbage 
collector.

http://docs.python.org/2/reference/datamodel.html#special-method-names

http://docs.python.org/2/library/gc.html#gc.garbage



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


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 obviously no calls of the destructors of neither the
>> second instance of the X class nor of the Y class instance. Shouldn't
>> they be invoked before the program ends?
> 
> You should avoid __del__ destructors whenever not absolutely necessary.

And here is another opinion: you should avoid cycles, rather the __del__.

http://eli.thegreenplace.net/2009/06/12/safely-using-destructors-in-python/





-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


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} {1}".format( self, cnt ),
file = sys.stderr )
 self.parent = parent
 self.cnt = cnt

 def __del__( self ) :
 print( "In destructor for {0} {1}".format( self, self.cnt ),
file = sys.stderr )

 def foo( self ) :


At this point, self is self.parent.z, which is to say, self and 
self.parent.z are 2 references to 1 object. The self and self.parent 
object refer to each other and therefore constitute a reference cycle.



 print( "Before", file = sys.stderr )
 self.parent.z = X( self.parent, 2 ) # Is this bad?


At this point, self.parent.z is another instance of X, breaking the 
existing reference cycle *and* creating a new one. Now self has just the 
one reference 'self' (plus another non-circular, hidden one, see below#).



 print( "After", file = sys.stderr )


At this point, self goes out of scope, the CPython reference count goes 
to 0, and the object that was self is deleted. Other implementations 
typically wait longer to delete.



class Y( object ) :
 def __init__( self ) :
 print( "In constructor for {0}".format( self ),
file = sys.stderr )
 self.z = X( self, 1 )


At this point, self is self.z.parent, where z is an X. This is a 
circular reference: self and self.z reference each other.



 def __del__( self ) :
 print( "In destructor for {0}".format( self ),
file = sys.stderr )

Y( ).z.foo( )


Y() creates a reference cycle. z.foo() substitute a different instance 
of X in the cycle but there still is a cycle, so the Y and X objects 
have reference counts of 1. There are no other references to the two 
objects, making them unreachable and 'dead' to the program.


The cyclic reference garbage collector (see the gc module doc) that is 
meant to delete such orphans does not delete them here because of the 
__del__ methods. Since gc was added, __del__ is semi-obsolete. If an 
object might possibly be put in a reference cycle (which is quite easy), 
any code that might have been put in __del__ should go in an explicitly 
called .close() method.



Have a look at the line with the comment. At this point the
only reference in existence to the X class instance, of which
a method is just being executed, goes out of scope.


Nope, the remaining reference, 'self', stays in scope until after the 
function exits. That is when X1 is deleted and the deletion message 
printed.



Is my assumption about this flawed


Yes


and there are no potential dangers?


The orphaned two-object cycle constitutes a memory leak.
If you called Y( ).z.foo( ) a million times,
you would have a million useless pairs of objects.
This is why gc was added.


Y( ).z.foo( )

[perhaps] a temporary second reference is created that keeps the GC
for removing the X instance...


Function calls (normally) bind argument object to parameter names in the 
function's local namespace. That binding is a temporary reference and 
objects will not disappear in the middle of the call.


# In CPython, at least, there is another internal reference to arguments 
that also disappears when the function returns, allowing the deletion of 
arguments without other references.


>>> x = 12343252  # random large number to make sure its a new object
>>> sys.getrefcount(x)
2
>>> def f(a): print(sys.getrefcount(a))

>>> f(x)
4

So print(sys.getrefcount(self)) at the top of foo prints 4 (3+1),
rather than 3 (2+1), as one might expect. The +1 is explained in the doc

sys.getrefcount(obj):
Return the reference count of the object. The count returned is 
generally one higher than you might expect, because it includes the 
(temporary) reference as an argument to getrefcount().


(Why doesn't getrefcount add 2 instead of 1, as f seems to? I don't 
know, but perhaps because it is written in C rather than Python and 
Python code objects are different from C code.)


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


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( object ) :
> def __init__( self, parent, cnt ) :
> print( "In constructor for {0} {1}".format( self, cnt ),
>file = sys.stderr )
> self.parent = parent
> self.cnt = cnt
> 
> def __del__( self ) :
> print( "In destructor for {0} {1}".format( self, self.cnt ),
>file = sys.stderr )
> 
> def foo( self ) :
> print( "Before", file = sys.stderr )
> self.parent.z = X( self.parent, 2 ) # Is this bad? 
> print( "After", file = sys.stderr )
> 
> class Y( object ) :
> def __init__( self ) :
> print( "In constructor for {0}".format( self ),
>file = sys.stderr )
> self.z = X( self, 1 )
> 
> def __del__( self ) :
> print( "In destructor for {0}".format( self ),
>file = sys.stderr )
> 
> Y( ).z.foo( )
> 
> Have a look at the line with the comment. 


You mean this line?

self.parent.z = X( self.parent, 2 ) # Is this bad? 


> At this point the only
> reference in existence to the X class instance, of which a method is
> just being executed, goes out of scope.

I don't understand this, but to the extent that I do understand it, I 
think you are wrong.

What do you mean, "the X class instance"? If you mean the class X itself, 
no, that survives until both the class itself is deleted and every one of 
it's instances. If you mean "self", no, that doesn't get deleted by that 
line at all.


> Thus I would assume that the GC
> could now kick any time, possibly even before the following call of
> print() or before the method call returns. That, in turn might result in
> a crash of the script.

It would be a pretty crappy garbage collector that collected objects 
while they were still being used.



> Is my assumption about this flawed and there are no potential dangers?
> Perhaps with
> 
> Y( ).z.foo( )
> 
> a temporary second reference is created that keeps the GC for removing
> the X instance...

I'm not even sure what X instance you are referring to, or why you think 
it is going out of scope.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


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 compilation of them at http://sql-info.de/mysql/gotchas.html


I'm getting the following from that URL:

 ERROR: database not available

... which, as irony goes, is kinda delicious :-)


Loads for me... Though the page does state that it applies to MySQL
4.1 and earlier, and not to the current 5.x series (which added prepared
queries, stored procedures, and triggers as I recall).

And the first link in the text is to:
http://sql-info.de/postgresql/postgres-gotchas.html 


The site was up for me both times I hit it, but it doesn't mean that 
Zero Piraeus didn't get a DB error (which *is* quite an amusing 
error in the context of the subject matter).


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 behaviors".


-tkc



--
http://mail.python.org/mailman/listinfo/python-list


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,
Subhabrata. 
-- 
http://mail.python.org/mailman/listinfo/python-list


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 you have blank
space after the current paragraph so the attention is focused even more
on the last few lines.

Additionally, since instructions scroll automatically, I can space them
out more than you would conventionally do in a manual.


Pretty cool.

When reading the source of the Web page which shows the scroll,
I can't find the reference to the text displayed. Only "text"...
How may we use the software which generates the Javascript ?
Thanks, it's cool.

  franck

Thanks!

   the text is in var commands = ...

You can download the generator script here:

https://github.com/pythonbyexample/PBE/blob/master/code/jstmovie.py

(you also need to grab  tmovies dir)

When looking at the source of the page :
http://lightbird.net/larks/tmovies/strings.html
I find commands = []
I can't guess where the strings displayed come from...

 franck


Look 10 lines below that line.


I have also added a related page that allows you to paste your own
text to make a movie; it's linked from the same page with the
list of generated t-movies.

(that page does not let you use typewriter effect or custom pauses
though).

 - mitya



--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

--
http://mail.python.org/mailman/listinfo/python-list


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, but, when it reassemble
the the words, it does it like this:

 lines.append(' '.join(words))

The biggest problem is, even when the input file has many spaces, it
strips it down to one.

A file with this line:

This line containsmany   spaces
becomes:

This Line Contains Many Spaces


The whole script will look clumsy here. I have put it up on GitHub,
here is it: https://github.com/santosh/capitalizr.py/blob/master/capitalizr


You know that mystr.title() can do this?

 - m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

--
http://mail.python.org/mailman/listinfo/python-list


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 = '''
>  mailto:[email protected]";>  src="/data/images/mail.png"> 
>  
>  
>   Αριθμός Επισκεπτών 
>   %d ''' % hits[0]
> 
>

> While from within the same counter.py file
>
> # open html template file
> f = open( '/home/nikos/public_html/test.txt' )
>
> opens OK the page file which is also past addons domain's document root
>
> Can you help counter.py to load the image? Why does it fail to load it? 
> Python can have access to ANY filesystempath , no matter from what folder 
> counter.py script runs from. Correct?

That piece of code is not opening the image file. It just issues the URL
for the image file. The file will then be loaded by the browser in a new
request. The image should be at
/home/nikos/public_html/data/images/mail.png

P.S. I don't understand what you mean by "addon domain".

-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question on Python Conference

2013-01-19 Thread Ned Deily
In article <[email protected]>,
 [email protected] 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 attend it by Video Conferencing? Or if I 
> request for the same will it be granted?

As far as I know, there is no live video conferencing from PyCon.  
However, nearly all sessions at recent PyCons are recorded and made 
available on the web.  The videos from the 2012 PyCon are here:

http://pyvideo.org/category/17/pycon-us-2012

-- 
 Ned Deily,
 [email protected]

-- 
http://mail.python.org/mailman/listinfo/python-list


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 behaviors".
>

Some of them are still current, though they're the least serious. The
requirement for "AS" in column aliasing is, imho, not a serious
problem - according to the SQL spec, an omitted comma is interpreted
as an alias, but PG will throw an error. The point that "SELECT
COUNT(*) FROM table" is slow is simply that MySQL happens to know the
current size of the table and can return it instantly... as soon as
you put a WHERE clause on it, both databases will perform more
comparably. Also, I think that advantage applies only to MyISAM
tables, the default but also the most problematic.

PostgreSQL does have a number of gotchas, mostly relating to
performance (for instance, the default configuration on install is
designed to work on as many systems as possible, which means it'll
perform suboptimally everywhere, and especially will not take
advantage of heaps of RAM). But MySQL has a *lot* more (whose insane
idea was it to treat "database" and "schema" as synonymous??).

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


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


Actually, SQLite3 will happily permit multiple readers (or did, the
newest version may have a new locking scheme). However, the first
connection that seeks to write will block as long as open readers are
active, yet will also block /new/ readers. When the open readers close,
the write can complete, and then new readers can enter. Conclusion:
ensure that even read-only operations have a "commit" operation to close
them


You're correct. For more precise description of what sqlite can or 
cannot do with respect to concurrency, see 
http://www.sqlite.org/faq.html#q5.


As far as I know, dbm does not support concurrencies at all, and neither 
does xml unless you put a lot of efforts into implementing your own file 
locking and all.


--
http://mail.python.org/mailman/listinfo/python-list


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 itself?

The main ways we handle something like this are:

1. Set an environment variable that Python then reads to get the
DocumentRoot value.
2. Use something like zc.buildout to produce both your httpd.conf and
create a config file containing the value of DocumentRoot.
-- 
http://mail.python.org/mailman/listinfo/python-list


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 shop, occasionally
>>   tossing GPL-licensed releases over the wall, with very little input
>>   accepted from the community.
>>
>   It has been forked by some of the original developers...
> 
My vote is to put MySQL where it has always belonged (still more so, now 
that Oracle has taken it over), and use Postgres.
-- 
http://mail.python.org/mailman/listinfo/python-list


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 builtins, and watch it break:

from types import FunctionType
g = FunctionType(f.__code__, {'x': 23})


If you call g(), you get an exception:

py> g()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in f
NameError: global name 'print' is not defined


(Don't be fooled by the traceback referring to "f" rather than g.
That's because g's code was copied from f.)

We can add support for builtins:

import builtins  # use __builtin__ with no "s" in Python 2
g.__globals__['__builtins__'] = builtins  # Note the "s" in the key.


and now calling g() prints 23, as expected.

Now let me try the same thing using Python 3.3's ChainMap. Unfortunately, 
functions insist that their __global__ is a dict, so we fool it into 
accepting a ChainMap with some multiple inheritance trickery:


from collections import ChainMap
class ChainedDict(ChainMap, dict):
pass

d = ChainedDict({}, {'x': 23}, {'x': 42})
assert d['x'] == 23
g = FunctionType(f.__code__, d)


As before, calling g() raises NameError, "global name 'print' is not 
defined". So I expected to be able to fix it just as I did before:

g.__globals__['__builtins__'] = builtins


But it doesn't work -- I still get the same NameError. Why does this not 
work here, when it works for a regular dict?


I can fix it by adding the builtins into the ChainMap:

g.__globals__.maps.append(builtins.__dict__)


And now calling g() prints 23 as expected.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


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 folder.
> 
> >
> 
> > For example. Say your personal library exists in:
> 
> >
> 
> > C:\users\user\documents\python\lib
> 
> >
> 
> > ...then there is no need to post THAT portion of the path EVERY
> 
> > STINKING TIME! For instance, let's say a script at:
> 
> >
> 
> > C:\users\user\documents\python\lib\sound\effects\echo.py
> 
> >
> 
> > ...throws an error. What will we see?
> 
> >
> 
> > Traceback (most recent call last): File
> 
> > "C:\users\user\documents\python\lib\sound\effects\echo.py", line N,
> 
> > in BLAH
> 
> >
> 
> > Why do i need to see "C:\users\user\documents\python\lib" EVERY
> 
> > time?
> 
> >
> 
> > Since all directories *BELOW* the directory that holds your personal
> 
> > Python library are /superfluous/ when posting exceptions to stderr,
> 
> > trimming this bloat can really help to make exception messages easier
> 
> > to read.
> 
> >
> 
> > Traceback (most recent call last): File
> 
> > "...\sound\effects\reverb.py", line XXX, in YYY
> 
> 
> 
> I agree with the complaint and you may have the germ of a good idea. The 
> 
> problem is that for some tracebacks, paths jump all over the place 
> 
> rather than having a common prefix. Dealing with this might require 
> 
> preprocessing the entire traceback before iterating and printing each item.
> 
> 
> 
> Are you are aware of
> 
> '''
> 
> sys.excepthook(type, value, traceback)
> 
> 
> 
>  This function prints out a given traceback and exception to sys.stderr.
> 
> 
> 
>  When an exception is raised and uncaught, the interpreter calls 
> 
> sys.excepthook with three arguments, the exception class, exception 
> 
> instance, and a traceback object. In an interactive session this happens 
> 
> just before control is returned to the prompt; in a Python program this 
> 
> happens just before the program exits. The handling of such top-level 
> 
> exceptions can be customized by assigning another three-argument 
> 
> function to sys.excepthook.
> 
> '''
> 
> This is how some apps and environments customize exception reporting 
> 
> (and logging). I believe some people also put a replacement in their 
> 
> site module.
> 
> 
> 
>  >>> import sys; sys.excepthook
> 
> 
> 
> 
> 
> I expect the default, excepthook, is something like
> 
> 
> 
> def excepthook(typ, value, traceback):
> 
>  print('Traceback (most recent call last):', file=sys.stderr)
> 
>  for item in traceback:
> 
>  print(format_tb_item(item), file=sys.stderr)
> 
>  print('{}: {}'.format(typ.__name__, value), file=sys.stderr)
> 
> 
> 
> (or the equivalent with sys.stderr.write)
> 
> 
> 
> What you want to change is format_tb_item (possibly, as I said, after 
> 
> scanning traceback before the print loop). If you come up with something 
> 
> nice, I would like to see it.
> 
> 
> 
> The only thing special that IDLE does now is to color the text red. I 
> 
> should sometime see how that is done. (Being able to doubleclick on an 
> 
> item and have IDLE open an edit window at the specified line would be 
> 
> really nice!)
> 
> 
> 
> -- 
> 
> Terry Jan Reedy

Right-click the file in the traceback and there is an "Go to file/line" option.
-- 
http://mail.python.org/mailman/listinfo/python-list


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 they've already read.

Thank you.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list