Re: [Python-Dev] operator.attrgetter(attr[, args...]) etc.

2012-11-21 Thread Oscar Benjamin
On 21 November 2012 03:57, Leo  wrote:
> Sorry the python issue tracker seems broken (I cannot log in). So I am
> posting it here.
>
> In the doc:
>
>   operator.attrgetter(attr[, args...])
>   operator.itemgetter(item[, args...])
>   operator.methodcaller(name[, args...])
>
> The signatures of these functions seem confusing. ARGS is not documented
> and does not match the python implementation in the doc.

What documentation are you reading?

$ python
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import operator
>>> help(operator.attrgetter)
Help on class attrgetter in module operator:

class attrgetter(__builtin__.object)
 |  attrgetter(attr, ...) --> attrgetter object
 |
 |  Return a callable object that fetches the given attribute(s) from
its operand.
 |  After, f=attrgetter('name'), the call f(r) returns r.name.
 |  After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).
 |  After, h=attrgetter('name.first', 'name.last'), the call h(r) returns
 |  (r.name.first, r.name.last).
[snip]

I think the above explains how attrgetter works with multiple
arguments. Here's a demo:

>>> class X:
... a = 2
... b = 3
... c = 1
...
>>> getter = operator.attrgetter('a', 'b', 'c')
>>> getter(X)
(2, 3, 1)


Oscar
___
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] operator.attrgetter(attr[, args...]) etc.

2012-11-21 Thread R. David Murray
On Wed, 21 Nov 2012 14:49:05 +, Oscar Benjamin  
wrote:
> On 21 November 2012 03:57, Leo  wrote:
> > Sorry the python issue tracker seems broken (I cannot log in). So I am
> > posting it here.
> >
> > In the doc:
> >
> >   operator.attrgetter(attr[, args...])
> >   operator.itemgetter(item[, args...])
> >   operator.methodcaller(name[, args...])
> >
> > The signatures of these functions seem confusing. ARGS is not documented
> > and does not match the python implementation in the doc.
> 
> What documentation are you reading?

He's reading the operator module documentation.  I just ran into that
same thing the other day, but didn't think to file a bug report.  It
looks like the ``args`` stuff was incorrectly copy and pasted from the
methodcaller docs, where it is actually correct.

I've opened an issue:

http://bugs.python.org/issue16523

--David
___
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-checkins] cpython (3.3): - Issue #16514: Fix regression causing a traceback when sys.path[0] is None

2012-11-21 Thread Brett Cannon
On Tue, Nov 20, 2012 at 6:41 PM, Barry Warsaw  wrote:

> On Nov 20, 2012, at 05:35 PM, Terry Reedy wrote:
>
> >On 11/20/2012 3:35 PM, barry.warsaw wrote:
> >
> >>   for entry in path:
> >> +if not isinstance(entry, (str, bytes)):
> >> +continue
> >
> >Given that a non-(str,bytes) entry could indicate a programming error,
> should
> >a warning be emitted before continuing?
>
> That's not what happens in Python 3.2.


Fine, but warnings are off by default and this is simply wrong behaviour to
do. We should not paper over it just because import.c did.


>  In fact, this bug report was triggered
> by someone who was already inserting None to sys.path[0].  It is silently
> ignored in Python 3.2, but tracebacked in 3.3.


But why were they doing that? What did they hope to get out of it?
___
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-checkins] devguide: Add instructions for handling merge conflicts during null merges.

2012-11-21 Thread Chris Jerdonek
On Wed, Nov 21, 2012 at 6:07 PM, chris.jerdonek
 wrote:
> http://hg.python.org/devguide/rev/78a69b929ab7
> changeset:   573:78a69b929ab7
> user:Chris Jerdonek 
> date:Wed Nov 21 18:04:35 2012 -0800
> summary:
>   Add instructions for handling merge conflicts during null merges.

This was for issue #16517:

http://bugs.python.org/issue16517

--Chris


>
> files:
>   committing.rst |  11 +--
>   1 files changed, 9 insertions(+), 2 deletions(-)
>
>
> diff --git a/committing.rst b/committing.rst
> --- a/committing.rst
> +++ b/committing.rst
> @@ -306,17 +306,24 @@
> # Fix any conflicts; compile; run the test suite
> hg commit
>
> +.. index:: null merging
> +
>  .. note::
> -   *If the patch shouldn't be ported* from Python 3.3 to Python 3.4, you must
> -   also make it explicit: merge the changes but revert them before 
> committing::
> +   If the patch should *not* be ported from Python 3.3 to Python 3.4, you 
> must
> +   also make this explicit by doing a *null merge*: merge the changes but
> +   revert them before committing::
>
>hg update default
>hg merge 3.3
>hg revert -ar default
> +  hg resolve -am  # needed only if the merge created conflicts
>hg commit
>
> This is necessary so that the merge gets recorded; otherwise, somebody
> else will have to make a decision about your patch when they try to merge.
> +   (Using a three-way merge tool generally makes the ``hg resolve`` step
> +   in the above unnecessary; also see `this bug report
> +   `__.)
>
>  When you have finished your porting work (you can port several patches one
>  after another in your local repository), you can push **all** outstanding
>
> --
> Repository URL: http://hg.python.org/devguide
>
> ___
> Python-checkins mailing list
> python-check...@python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
___
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