Re: [Python-Dev] context manager - generator interaction?

2007-04-06 Thread Guido van Rossum
On 4/5/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> > Guido van Rossum wrote:
> >> Isn't this violating the rule that a try/except should only enclose
> >> the smallest expression where the exception is expected?
> >
> > Yeah, and I keep finding myself wanting to hyperlink to that "rule" in
> > the official docs, but it only seems to be written down in developer's
> > heads. Can we get that into the Language Ref somewhere? Maybe on the
> > http://docs.python.org/ref/try.html page?
>
> I'll add a snippet to the tutorial with advice on try/except.
>
> I don't think it should go in the main documentation because it is
> really more of a suggestion or technique than an actual rule.
> Also, there are plenty of other situations where the "rule" doesn't apply.

I see a lot of code written by Googlers who are not (yet) experienced
Python users. Overly wide try/except clauses are a common mistake, and
it is nearly always easy to apply this rule. I would argue, as a style
issue, for making this rule the norm, and require deviations to be
thought through very carefully.

This rule has no place in a pure language *reference* manual. But it
certainly deserves mention in any form of more practical
documentation, be it a tutorial or a more advanced programming manual.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] context manager - generator interaction?

2007-04-06 Thread Steve Holden
Guido van Rossum wrote:
> On 4/5/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
>>> Guido van Rossum wrote:
 Isn't this violating the rule that a try/except should only enclose
 the smallest expression where the exception is expected?
>>> Yeah, and I keep finding myself wanting to hyperlink to that "rule" in
>>> the official docs, but it only seems to be written down in developer's
>>> heads. Can we get that into the Language Ref somewhere? Maybe on the
>>> http://docs.python.org/ref/try.html page?
>> I'll add a snippet to the tutorial with advice on try/except.
>>
>> I don't think it should go in the main documentation because it is
>> really more of a suggestion or technique than an actual rule.
>> Also, there are plenty of other situations where the "rule" doesn't apply.
> 
> I see a lot of code written by Googlers who are not (yet) experienced
> Python users. Overly wide try/except clauses are a common mistake, and
> it is nearly always easy to apply this rule. I would argue, as a style
> issue, for making this rule the norm, and require deviations to be
> thought through very carefully.
> 
> This rule has no place in a pure language *reference* manual. But it
> certainly deserves mention in any form of more practical
> documentation, be it a tutorial or a more advanced programming manual.
> 
PEP 8 would (also? I don't see this being relevant to the reference 
manual, but that's not a biggie) seem a logical place for this 
information to go, since it deals with try-except. I'd suggest something 
along the lines of:

A frequent beginner's error is to make the scope of a try clause too 
broad, covering a larger span of code that necessary so that the except 
clause is triggered by unanticipated exceptions. Try to ensure that a 
try clause applies to the fewest possible statements to avoid these issues.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings   http://holdenweb.blogspot.com

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] context manager - generator interaction?

2007-04-06 Thread skip

Guido> This rule has no place in a pure language *reference* manual. But
Guido> it certainly deserves mention in any form of more practical
Guido> documentation, be it a tutorial or a more advanced programming
Guido> manual.

PEP 8 anyone?

Skip
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] context manager - generator interaction?

2007-04-06 Thread Fred L. Drake, Jr.
On where to write guidelines about exception handling scope:

Guido wrote:
 > This rule has no place in a pure language *reference* manual.  But
 > it certainly deserves mention in any form of more practical 
 > documentation, be it a tutorial or a more advanced programming
 > manual.

On Friday 06 April 2007 10:31, [EMAIL PROTECTED] wrote:
 > PEP 8 anyone?

New users should be exposed sooner than this; most will never read any PEP.  
The tutorial seems like a good place.  This is general good programming 
practice we're talking about here, not style.


  -Fred

-- 
Fred L. Drake, Jr.   
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] context manager - generator interaction?

2007-04-06 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Apr 6, 2007, at 10:40 AM, Fred L. Drake, Jr. wrote:

> On Friday 06 April 2007 10:31, [EMAIL PROTECTED] wrote:
>> PEP 8 anyone?
>
> New users should be exposed sooner than this; most will never read  
> any PEP.
> The tutorial seems like a good place.  This is general good  
> programming
> practice we're talking about here, not style.

I'm not so sure that's true about PEP 8.  Several organizations that  
I know of link their own "Python Coding Standards" directly to that  
PEP, and expect their devs to read it and adhere to it, possibly with  
a few local exceptions.  It might even be worthwhile to give PEP 8  
more exposure in the tutorial or on the documentation ToC page.

- -Barry

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFGFmAl2YZpQepbvXERAs7XAJ9IAjcpiyeh6x1c6YDdpj8jmQoKRwCgse+a
R/I6zIMjvBKmIqfqbrPrtFo=
=5x7r
-END PGP SIGNATURE-
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] More exposure for PEP8 (was: context manager - generator interaction?)

2007-04-06 Thread Oleg Broytmann
On Fri, Apr 06, 2007 at 10:58:41AM -0400, Barry Warsaw wrote:
> It might even be worthwhile to give PEP 8  
> more exposure in the tutorial or on the documentation ToC page.

   And bundle the PEP with the distributed documentation.

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] context manager - generator interaction?

2007-04-06 Thread Guido van Rossum
I've added a paragraph to the PEP, with examples.

On 4/6/07, Barry Warsaw <[EMAIL PROTECTED]> wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On Apr 6, 2007, at 10:40 AM, Fred L. Drake, Jr. wrote:
>
> > On Friday 06 April 2007 10:31, [EMAIL PROTECTED] wrote:
> >> PEP 8 anyone?
> >
> > New users should be exposed sooner than this; most will never read
> > any PEP.
> > The tutorial seems like a good place.  This is general good
> > programming
> > practice we're talking about here, not style.
>
> I'm not so sure that's true about PEP 8.  Several organizations that
> I know of link their own "Python Coding Standards" directly to that
> PEP, and expect their devs to read it and adhere to it, possibly with
> a few local exceptions.  It might even be worthwhile to give PEP 8
> more exposure in the tutorial or on the documentation ToC page.
>
> - -Barry
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.6 (Darwin)
>
> iD8DBQFGFmAl2YZpQepbvXERAs7XAJ9IAjcpiyeh6x1c6YDdpj8jmQoKRwCgse+a
> R/I6zIMjvBKmIqfqbrPrtFo=
> =5x7r
> -END PGP SIGNATURE-
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] Python Regression Test Failures opt (1)

2007-04-06 Thread Raymond Hettinger
I believe the failures started with Facundo Batista's checkin on April 4th:

-
Author: facundo.batista
Date: Wed Apr  4 16:10:40 2007
New Revision: 54681

Modified:
   python/trunk/Lib/test/test_socket_ssl.py
Log:

Fixed the way that the .pem files are looked for, and changed
how to kill the process in win32 to use the _handle attribute.


Modified: python/trunk/Lib/test/test_socket_ssl.py


  - Original Message - 
  From: Brett Cannon 
  To: [EMAIL PROTECTED] 
  Cc: [EMAIL PROTECTED] 
  Sent: Friday, April 06, 2007 11:27 AM
  Subject: Re: [Python-checkins] Python Regression Test Failures opt (1)





  On 4/6/07, Neal Norwitz <[EMAIL PROTECTED]> wrote:
[SNIP]
test_socket_ssl
test test_socket_ssl failed -- Traceback (most recent call last):
  File "/tmp/python-test/local/lib/python2.6/test/test_socket_ssl.py", line 
117, in testBasic
self.assertEqual (i, "Foo\n")
AssertionError: 'ERRO' != 'Foo\n'

test_socketserver
test_socketserver skipped -- Use of the `network' resource not enabled
test_softspace
test_sort
Exception in thread Thread-43: 
Traceback (most recent call last):
  File "/tmp/python-test/local/lib/python2.6/threading.py", line 460, in 
__bootstrap
self.run()
  File "/tmp/python-test/local/lib/python2.6/test/test_socket_ssl.py", line 
163, in run 
self.s.stdin.write(l)
IOError: [Errno 32] Broken pipe


  Anyone know what caused these two tests to start failing?

  -Brett 







--


  ___
  Python-checkins mailing list
  [EMAIL PROTECTED]
  http://mail.python.org/mailman/listinfo/python-checkins
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com