[issue21279] str.translate documentation incomplete

2015-01-25 Thread John Posner

John Posner added the comment:

Per Martin's suggestion, deltas from issue21279.v5.patch:

* no change to patch for doc/library/stdtypes.rst

* doc string reflowed in patch for objects/unicodeobject.c

--
Added file: http://bugs.python.org/file37855/issue21279.v6.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21279
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21279] str.translate documentation incomplete

2014-12-23 Thread John Posner

John Posner added the comment:

issue21279.v5.patch tries to apply the comments in msg233013, msg233014, and 
msg233025 to the Doc/library/stdtypes.rst writeup. Then it applies some of the 
same language to the docstring in Objects/unicodeobject.c.

--
Added file: http://bugs.python.org/file37536/issue21279.v5.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21279
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21279] str.translate documentation incomplete

2014-12-21 Thread John Posner

John Posner added the comment:

Patch of 12-21 looks good, Martin.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21279
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21279] str.translate documentation incomplete

2014-12-19 Thread John Posner

John Posner added the comment:

Regarding Martin's patch of 12-18:

stdtypes.rst -- looks good to me

unicodeobject.c -- I suggest changing this sentence:

If a character is not in the table, the subscript operation should raise 
LookupError, and the character is left untouched.

 ... to:

If the subscript operation raises a LookupError, the character is left 
untouched.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21279
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21279] str.translate documentation incomplete

2014-12-15 Thread John Posner

John Posner added the comment:

Kindly ignore message #2 on the Rietveld page (sorry for the channel noise). 
Here's my suggested revision:

Return a copy of the string *str* in which each character has been mapped 
through the given translation *table*. The table must be a subscriptable 
object, for instance a list or dictionary; when subscripted (indexed) by a 
Unicode ordinal (an integer in range(1048576)), the table object can:

* return a Unicode ordinal or a string, to map the character to one or more 
other characters.

* return None, to delete the character from the return string.

* raise a LookupError (possibly an instance of subclass IndexError or 
KeyError), to map the character to itself.

--
nosy: +jjposner

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21279
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9536] defaultdict doc makes incorrect reference to __missing__ method

2010-08-08 Thread John Posner

John Posner jjpos...@optimum.net added the comment:

I think it would be confusing to create of subclass of defaultdict, defining a 
__missing__ method in that subclass. The existence of the __missing__ method 
would cancel the main functionality of the defaultdict object: invoking the 
default value factory callable.

I think it would be better to encourage programmers to subclass dict directly, 
instead of subclassing defaultdict.

--
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9536
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9536] defaultdict doc makes incorrect reference to __missing__ method

2010-08-08 Thread John Posner

John Posner jjpos...@optimum.net added the comment:

On python-list, Wolfram Hinderer objected to the proposed patch's calling 
__missing__ a special method.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9536
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9536] defaultdict doc makes incorrect reference to __missing__ method

2010-08-08 Thread John Posner

Changes by John Posner jjpos...@optimum.net:


--
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9536
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9536] defaultdict doc makes incorrect reference to __missing__ method

2010-08-06 Thread John Posner

New submission from John Posner jjpos...@optimum.net:

The documentation for collections.defaultdict is confusing with respect to the 
__missing__ method. The fact is that a programmer using defaultdict does not 
need to know anything about __missing__.

The attached patch contains a rewrite of the entire section (but not the 
defaultdict Examples section, which is fine.

--
assignee: d...@python
components: Documentation
files: defaultdict.patch
keywords: patch
messages: 113105
nosy: d...@python, jjposner
priority: normal
severity: normal
status: open
title: defaultdict doc makes incorrect reference to __missing__ method
versions: Python 2.7
Added file: http://bugs.python.org/file18417/defaultdict.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9536
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8012] Revise generator-related Glossary entries

2010-04-02 Thread John Posner

John Posner jjpos...@optimum.net added the comment:

Georg, your change (r79587) makes this the main definition:

  generator
  A function which returns an iterator.
  
I'm concerned that this definition does not fit well with the occurrence of 
generator object in the following:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
 obj1 = (x for x in [1,2])
 def gfunc():
... count = 0
... while True:
... count += 1
... yield count
...
 obj2 = gfunc()
 obj1
generator object genexpr at 0x00CC6378
 obj2
generator object gfunc at 0x00CC6328



My patch attempted to make generator be the same as generator object in the 
above.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8012
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8012] Revise generator-related Glossary entries

2010-04-02 Thread John Posner

John Posner jjpos...@optimum.net added the comment:

Fair enough, Georg. Case closed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8012
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5621] Add description of special case to Assignment statements section

2009-09-08 Thread John Posner

John Posner jjpos...@optimum.net added the comment:

George, here is a patch file for this bug. It modifies file
doc/reference/simple_stmts.rst

Please let me know if this was the wrong way to submit the patch file.

--
keywords: +patch
status: pending - open
Added file: http://bugs.python.org/file14861/assignment_statement.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5621
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5621] Add description of special case to Assignment statements section

2009-03-31 Thread John Posner

New submission from John Posner john_posner_a...@post.harvard.edu:

The subsection Augmented assignment statements includes a note on this
special case:

  a.x += 1

But the parent section Assignment statements does not include such a
note, even though it's essentially the same situation. I suggest
replacing the bulleted paragraph that begins If the target is an
attribute reference with the following:

-

*   If the target is an attribute reference: The primary expression in
the reference is evaluated. It should yield an object with
assignable attributes; if this is not the case, TypeError is raised.
That object is then asked to assign the assigned object to the given
attribute; if it cannot perform the assignment, it raises an
exception (usually but not necessarily AttributeError).

If the object is a class instance and the attribute
reference occurs on both sides of the assignment operator; for example::

a.x = a.x + 1

... in the RHS expression, ``a.x`` is evaluated with
``getattr()``, which can access either an instance attribute or (if
no instance attribute exists) a class attribute. The LHS target
``a.x`` is assigned with ``setattr()``, which *always* accesses
an instance attribute, creating it if necessary. Thus, the two
occurrences of ``a.x`` do not necessarily refer to the same
variable. If the RHS expression refers to a class attribute, the LHS
creates a new instance attribute as the target of the assignment.
(This description does not necessarily
apply to attributes defined with ``property()``, which are accessed
with user-defined functions instead of ``getattr()`` and ``setattr()``).

See section Augmented assignment statements for a similar note on
attribute references.

-

--
assignee: georg.brandl
components: Documentation
messages: 84790
nosy: georg.brandl, jjposner
severity: normal
status: open
title: Add description of special case to Assignment statements section
versions: Python 2.6, Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5621
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5621] Add description of special case to Assignment statements section

2009-03-31 Thread John Posner

John Posner john_posner_a...@post.harvard.edu added the comment:

The Assignment statements section *does* talk about the RHS -- but in
a subtle way:

  For targets which are attribute references, the initial
  value is retrieved with a getattr()

The retrieving of the initial value (maybe current value would be
better) occurs on the RHS of the assignment statement.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5621
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com