Re: [Python-Dev] Python Library Addition: First-class Procedure Signatures

2007-11-16 Thread Brett Cannon
On Nov 15, 2007 12:48 PM, Steven Bethard <[EMAIL PROTECTED]> wrote:
> On Nov 14, 2007 1:18 PM, Brett Cannon <[EMAIL PROTECTED]> wrote:
> > On Nov 14, 2007 10:30 AM, Isaac Morland <[EMAIL PROTECTED]> wrote:
> > > So I wrote a Signature class.  Instances of the class represent all the
> > > information present between the parentheses of a procedure definition.
> > > Properties are provided to get the information out, and an expand_args 
> > > method
> > > can be called to expand arguments into a dictionary.  This expand_args 
> > > method
> > > implements (if I've done it right) the argument conversion part of section
> > > 5.3.4 of the Python Reference Manual 
> > > (http://docs.python.org/ref/calls.html).
> >
> > As Collin already pointed out, it sounds like you want PEP 362 to get
> > into the stdlib.  I have not made a big push to try to get my existing
> > implementation into Python 2.6/3.0, but I plan to at some point.
>
> Every time I read PEP 362, I get lost in the details.  When you get
> around to working on it again, could you add a bunch of examples?
> That would make it much easier to tell why we want all those objects
> and attributes.
>

Done.  I tossed up an annotations duck typing checker in the PEP.

> FWIW, Isaac's version of bind() that returns a regular str->object
> dict is all I've ever needed in my own code.

My implementation does that as well.  It was a typo in the PEP that
said bind() returned Parameter objects as values.

-Brett
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] for loop with if filter

2007-11-16 Thread Tristan Seligmann
* Terry Reedy <[EMAIL PROTECTED]> [2007-11-16 18:31:12 -0500]:

> 
> "Gustavo Carneiro" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> |I am finding myself often doing for loops over a subset of a list, like:
> |
> |for r in results:
> |if r.numNodes != numNodes:
> |continue
> |# do something with r
> 
> Why write it backwards?
> 
> for r in results:
>   if r.numNodes == numNodes
> # do something with r
> 
> is the direct parallel with the below code.

The extra level of indentation is awkward.
-- 
mithrandi, i Ainil en-Balandor, a faer Ambar


signature.asc
Description: Digital signature
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] for loop with if filter

2007-11-16 Thread Terry Reedy

"Gustavo Carneiro" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
|I am finding myself often doing for loops over a subset of a list, like:
|
|for r in results:
|if r.numNodes != numNodes:
|continue
|# do something with r

Why write it backwards?

for r in results:
  if r.numNodes == numNodes
# do something with r

is the direct parallel with the below code.

| It would be nice if the plain for loop was as flexible as list
| comprehensions and allowed an optional if clause, like this:
|
|for r in results if r.numNodes == numNodes:
|# do something with r

Same as above with ':\n' deleted.  A trivial difference.
An optional if clause is *less* flexible than an optional if statement and 
block.

| Has this idea come up before?  Does anyone else like this idea?

Yes, and Guido rejected at that time.

tjr
 



___
Python-Dev mailing list
Python-Dev@python.org
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 Library Addition: First-class Procedure Signatures

2007-11-16 Thread Brett Cannon
On Nov 15, 2007 12:48 PM, Steven Bethard <[EMAIL PROTECTED]> wrote:
> On Nov 14, 2007 1:18 PM, Brett Cannon <[EMAIL PROTECTED]> wrote:
> > On Nov 14, 2007 10:30 AM, Isaac Morland <[EMAIL PROTECTED]> wrote:
> > > So I wrote a Signature class.  Instances of the class represent all the
> > > information present between the parentheses of a procedure definition.
> > > Properties are provided to get the information out, and an expand_args 
> > > method
> > > can be called to expand arguments into a dictionary.  This expand_args 
> > > method
> > > implements (if I've done it right) the argument conversion part of section
> > > 5.3.4 of the Python Reference Manual 
> > > (http://docs.python.org/ref/calls.html).
> >
> > As Collin already pointed out, it sounds like you want PEP 362 to get
> > into the stdlib.  I have not made a big push to try to get my existing
> > implementation into Python 2.6/3.0, but I plan to at some point.
>
> Every time I read PEP 362, I get lost in the details.  When you get
> around to working on it again, could you add a bunch of examples?
> That would make it much easier to tell why we want all those objects
> and attributes.
>

You might not need them in general.  It just re-packages all the
information that is found between a function object and a code object
into a single location.

> FWIW, Isaac's version of bind() that returns a regular str->object
> dict is all I've ever needed in my own code.

That's what the implementation does at the moment (if I remember correctly).

I am about to bundle up the code and submit to PyPI to get feedback
from folks and to just get it out there instead of languishing in the
sandbox while I try to decide exactly what to do about the open
issues.  I will see if i can toss in some examples into the PEP.

-Brett
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Summary of Tracker Issues

2007-11-16 Thread Tracker

ACTIVITY SUMMARY (11/09/07 - 11/16/07)
Tracker at http://bugs.python.org/

To view or respond to any of the issues listed below, click on the issue 
number.  Do NOT respond to this message.


 1323 open (+13) / 11612 closed (+25) / 12935 total (+38)

Open issues with patches:   418

Average duration of open issues: 691 days.
Median duration of open issues: 799 days.

Open Issues Breakdown
   open  1318 (+13)
pending 5 ( +0)

Issues Created Or Reopened (39)
___

Garbage collection not working correctly in Python 2.3   11/09/07
CLOSED http://bugs.python.org/issue1405reopened tiran
   

py3k: pythonw.exe fails because std streams a missing11/10/07
CLOSED http://bugs.python.org/issue1415created  tiran
   py3k

@prop.setter decorators  11/10/07
CLOSED http://bugs.python.org/issue1416created  gvanrossum   
   patch   

Weakref not working properly 11/10/07
CLOSED http://bugs.python.org/issue1417created  MHOOO
   

Python/hypot.c is never used 11/10/07
CLOSED http://bugs.python.org/issue1418created  marketdickinson  
   

ssl module version 1.10 causes TypeError when accepting connecti 11/11/07
CLOSED http://bugs.python.org/issue1419created  complex  
   

Unicode literals in tokenize.py and tests.   11/11/07
CLOSED http://bugs.python.org/issue1420created  ron_adam 
   py3k, patch 

python.org: outdated and false information   11/11/07
CLOSED http://bugs.python.org/issue1421created  tiran
   

Writing to an invalid fd doesn't raise an exception  11/11/07
CLOSED http://bugs.python.org/issue1422created  tiran
   py3k

wave sunau aifc 16bit errors 11/11/07
   http://bugs.python.org/issue1423created  jeroen   
   

py3k: readline and rlcompleter doesn't list choices  11/11/07
CLOSED http://bugs.python.org/issue1424created  tiran
   py3k

readline: no display matches hook set11/11/07
CLOSED http://bugs.python.org/issue1425created  tiran
   py3k

readline module needs a review   11/11/07
CLOSED http://bugs.python.org/issue1426created  tiran
   py3k

Error in standard module calendar11/11/07
CLOSED http://bugs.python.org/issue1427created  gdamjan  
   patch   

Update to property.__doc__   11/11/07
CLOSED http://bugs.python.org/issue1428created  tiran
   patch   

FD leak in SocketServer  11/12/07
   http://bugs.python.org/issue1429created  luke-jr  
   

Installing on Vista asks to close Explorer (and Nokia PC Suite)  11/12/07
CLOSED http://bugs.python.org/issue1430created  dabarlow 
   

pth files not loaded at startup  11/12/07
   http://bugs.python.org/issue1431created  gbloisi  
   patch   

Strange behavior of urlparse.urljoin 11/13/07
   http://bugs.python.org/issue1432created  yan  
   

marshal roundtripping for unicode11/13/07

Re: [Python-Dev] for loop with if filter

2007-11-16 Thread martin
I started thinking about itertools when I saw this then I realised  
that your question was about changing the syntax to produce fewer  
lines of code rather than writing more effiicient code.. seemed like a  
case where you could use ifilter.

//Martin

  are talking about cvhanging the syntax rQuoting Gustavo Carneiro  
<[EMAIL PROTECTED]>:

> I am finding myself often doing for loops over a subset of a list, like:
>
> for r in results:
> if r.numNodes != numNodes:
> continue
> # do something with r
>
> It would be nice if the plain for loop was as flexible as list
> comprehensions and allowed an optional if clause, like this:
>
> for r in results if r.numNodes == numNodes:
> # do something with r
>
> Has this idea come up before?  Does anyone else like this idea?
>
> --
> Gustavo J. A. M. Carneiro
> INESC Porto, Telecommunications and Multimedia Unit
> "The universe is always one step beyond logic." -- Frank Herbert
>


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


Re: [Python-Dev] for loop with if filter

2007-11-16 Thread Paul Moore
On 16/11/2007, Gustavo Carneiro <[EMAIL PROTECTED]> wrote:
> Yes, I can do that, as well as I can use the 'continue' statement, but both
> versions are slightly more verbose and less clear than what I propose.

This should go to python-ideas, I guess. (FWIW, I can see the
attraction of the idea, but I don't think it's worth the cost in terms
of new syntax, subtle corner cases, etc etc).

Paul.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] for loop with if filter

2007-11-16 Thread Facundo Batista
2007/11/16, Gustavo Carneiro <[EMAIL PROTECTED]>:

> Yes, I can do that, as well as I can use the 'continue' statement, but both
> versions are slightly more verbose and less clear than what I propose.

The question is: is this slightly more verbosity and less clarity
worth enough as to make a syntax change in the language?

Personally, my answer is No.

-- 
.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] for loop with if filter

2007-11-16 Thread Gustavo Carneiro
On 16/11/2007, Benji York <[EMAIL PROTECTED]> wrote:
>
> Gustavo Carneiro wrote:
> > I am finding myself often doing for loops over a subset of a list, like:
> >
> > for r in results:
> > if r.numNodes != numNodes:
> > continue
> > # do something with r
> >
> > It would be nice if the plain for loop was as flexible as list
> comprehensions
> > and allowed an optional if clause, like this:
> >
> > for r in results if r.numNodes == numNodes:
> > # do something with r
>
> You can do the same today, sans sugar:
>
>  for r in (s for s in results if s.numNodes == numNodes):
>  # do something with r


Yes, I can do that, as well as I can use the 'continue' statement, but both
versions are slightly more verbose and less clear than what I propose.

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] for loop with if filter

2007-11-16 Thread Benji York
Gustavo Carneiro wrote:
 > I am finding myself often doing for loops over a subset of a list, like:
 >
 > for r in results:
 > if r.numNodes != numNodes:
 > continue
 > # do something with r
 >
 > It would be nice if the plain for loop was as flexible as list 
comprehensions
 > and allowed an optional if clause, like this:
 >
 > for r in results if r.numNodes == numNodes:
 > # do something with r

You can do the same today, sans sugar:

 for r in (s for s in results if s.numNodes == numNodes):
 # do something with r
-- 
Benji York
http://benjiyork.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] for loop with if filter

2007-11-16 Thread Gustavo Carneiro
I am finding myself often doing for loops over a subset of a list, like:

for r in results:
if r.numNodes != numNodes:
continue
# do something with r

It would be nice if the plain for loop was as flexible as list
comprehensions and allowed an optional if clause, like this:

for r in results if r.numNodes == numNodes:
# do something with r

Has this idea come up before?  Does anyone else like this idea?

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com