[issue13005] operator module docs include repeat

2011-09-18 Thread Luciano Ramalho

New submission from Luciano Ramalho :

The operator module documentation for versions 3.2 and 3.3 includes the repeat 
function in a table "9.3.1. Mapping Operators to Functions" [1], but fails to 
mention that the repeat function is deprecated and mul should be used instead, 
as described in the 2.7 version of the operator module docs [2].

The main entry for the repeat function was removed in the 3.2 and 3.3 docs, 
only the mention in the table remains [1].

[1] http://docs.python.org/py3k/library/operator#mapping-operators-to-functions
[2] http://docs.python.org/library/operator#operator.__repeat__

--
assignee: docs@python
components: Documentation
messages: 144251
nosy: docs@python, luciano
priority: normal
severity: normal
status: open
title: operator module docs include repeat
versions: Python 3.2, Python 3.3

___
Python tracker 
<http://bugs.python.org/issue13005>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1293741] doctest runner cannot handle non-ascii characters

2009-01-11 Thread Luciano Ramalho

Luciano Ramalho  added the comment:

I have confirmed everything that akaihola reports in Python 2.4, 2.5 and
2.6, but the problem is not limited to non-matching test output. It also
happens with doctests with zero failures when the module is run with the
-v command-line switch, or testmod is called with verbose=True.

The attached file shows a work-around: handle the UnicodeEncodeError
thrown by testmod, and display the "object" attribute of the exception
to see exactly where the problem is.

--
nosy: +luciano
title: doctest runner cannot handle non-ascii characters  -> doctest runner 
cannot handle non-ascii characters
versions: +Python 2.5, Python 2.6
Added file: http://bugs.python.org/file12684/issue1293741.py

___
Python tracker 
<http://bugs.python.org/issue1293741>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45090] Add pairwise to What's New in Python 3.10; mark it as new in itertools docs

2021-09-02 Thread Luciano Ramalho


New submission from Luciano Ramalho :

Thanks for adding `itertools.pairwise()`!

Let's make it easier to find by mentioning it in "What's New in Python 3.10" 
and also marking it as "New in Python 3.10" in the `itertools` module 
documentation.

--
assignee: docs@python
components: Documentation
messages: 400966
nosy: docs@python, ramalho
priority: normal
severity: normal
status: open
title: Add pairwise to What's New in Python 3.10; mark it as new in itertools 
docs
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue45090>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42781] functools.cached_property docs should explain that it is non-overriding

2020-12-29 Thread Luciano Ramalho


New submission from Luciano Ramalho :

functools.cached_property is a great addition to the standard library, thanks!

However, the docs do not say that @cached_property produces a non-overriding 
descriptor, in contrast with @property.

If a user replaces a @property with a @cached_property, her code may or may not 
break depending on the existence of an instance attribute with the same name as 
the decorated method. This is surprising and may affect correctness, so it 
deserves even more attention than the possible performance loss already 
mentioned in the docs, related to the shared-dict optimization.

In the future, perhaps we can add an argument to @cached_property to optionally 
make it produce overriding descriptors.

--
assignee: docs@python
components: Documentation
messages: 384019
nosy: docs@python, ramalho
priority: normal
severity: normal
status: open
title: functools.cached_property docs should explain that it is non-overriding
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue42781>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42781] functools.cached_property docs should explain that it is non-overriding

2020-12-29 Thread Luciano Ramalho


Luciano Ramalho  added the comment:

> FYI, the usual term is "data descriptor" instead of "overriding descriptor".

Yes, the Python docs are consistent in always using "data descriptor", but I've 
adopted "overriding descriptor" from Martelli's Python in a Nutshell--in Fluent 
Python I also put a note saying that "data descriptor" is used in the docs. I 
think "overriding descriptor" is more descriptive. In particular, I find 
"non-data descriptor" quite puzzling. But this issue is not about changing the 
jargon.

> Normally the docs for things like property() and cached_property()
> don't mention the term descriptor at all.  From the user point of
> view, that is an implementation detail.

I'd agree, if I wasn't personally bitten by the issue I reported. I was 
refactoring an existing class which had hand-made caches in a couple of methods 
decorated with @property. When I discovered @cached_property, I tried to 
simplify my code by using it, and it broke my code in one place, but not in the 
other. Leonardo Rochael had experience with cached_property and told me about 
the difference.

I suggest a warning noting the different behavior regarding existing instance 
attributes. The warning doesn't need to assume the user knows what is a 
descriptor, but it should in my opinion point to your excellent Descriptor 
HowTo Guide for more information.

> I would suggest a small amendment, and say "cached as a normal attribute with 
> the same name". The choice of attribute isn't arbitrary, it is exactly the 
> same as the cached property.

That's good too.

>> In the future, perhaps we can add an argument to @cached_property
>> to optionally make it produce overriding descriptors.

> That doesn't make any sense to me.  It would defeat the entire mechanism for 
> cached_property().

My idea would be to add a dummy __set__ method if the overriding option was 
True (default would be False). The method could raise an exception. But its 
presence would make @cached_property behave more like @property in the most 
common use case of @property: as an overriding descriptor emulating a read-only 
attribute.

>> If a user replaces a @property with a @cached_property, her 
>> code may or may not break depending on the existence of an 
>> instance attribute with the same name as the decorated method. 

> We've never had a report of an issue like this and I don't expect to see over.

You just did ;-). I filed this issue after spending hours trying to figure out 
what the problem was in my code on my second attempt at using @cached_property. 
I expected @cached_property would work as a drop-in replacement for @property 
when emulating a read-only attribute, and it did not.

> One other possible addition is to note that the attribute is writeable:

Yes, the code snippet you suggested is a good way of saying "this produces a 
non-overriding descriptor". 

However we want to say it, I think it is important to contrast the behavior of 
@cached_property v. @property regarding the presence of attributes with the 
same name.

Cheers and a happy 2021 with two doses of vaccine for you and your loved ones, 
Raymond!

--

___
Python tracker 
<https://bugs.python.org/issue42781>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43378] Pattern Matching section in tutorial refers to | as

2021-03-02 Thread Luciano Ramalho


Change by Luciano Ramalho :


--
nosy: ramalho
priority: normal
severity: normal
status: open
title: Pattern Matching section in tutorial refers to | as

___
Python tracker 
<https://bugs.python.org/issue43378>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43378] Pattern Matching section in tutorial refers to | as or

2021-03-02 Thread Luciano Ramalho

New submission from Luciano Ramalho :

Section 4.6. "match Statements" of the Python 3.10 tutorial says:

"""
You can combine several literals in a single pattern using | (β€œor”):
"""

For someone just learning Python, this may suggest that | is always "or", when 
in fact it is a bitwise operator (that may be overloaded), but inside a match 
clause has this special meaning without any overloading. 

I believe this exception should be made explicit in section 4.6, otherwise it 
may lead readers of the tutorial to a misconception.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
title: Pattern Matching section in tutorial refers to | as -> Pattern Matching 
section in tutorial refers to | as or
type:  -> enhancement
versions: +Python 3.10

___
Python tracker 
<https://bugs.python.org/issue43378>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40979] typing module docs: keep text, add subsections

2020-07-20 Thread Luciano Ramalho


Luciano Ramalho  added the comment:

Reviewers, besides adding section titles and reordering the entries, I made 
only these changes to the text:

- entry for IO, TextIO, BinaryIO: added sentence "These types are in the 
``typing.io`` namespace."

- entry for Pattern, Match: added sentence "These types are in the 
``typing.re`` namespace."

- entry for TypedDict: removed the words "equivalent to" from the sentence "At 
runtime it is  a plain dict."

--

___
Python tracker 
<https://bugs.python.org/issue40979>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40978] Document that typing.SupportsXXX protocols are runtime checkable

2020-08-01 Thread Luciano Ramalho


Luciano Ramalho  added the comment:

I have added a note about the protocols decorated with `@runtime_checkable` to 
the `Procools` section of the reorganized `typing.rst` in 
https://bugs.python.org/issue40979.

I also expanded the note about the caveats of `@runtime_checkable` in its entry 
in `Functions and decorators` section, giving `SupportsFloat` as an example 
issue.

--

___
Python tracker 
<https://bugs.python.org/issue40978>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40979] typing module docs: keep text, add subsections

2020-08-01 Thread Luciano Ramalho

Luciano Ramalho  added the comment:

I have incorporated Guido's suggestions and added additional subsections to 
make it easier to navigate the page.

I also added notes that fix the issue https://bugs.python.org/issue40978 β€” 
"Document that typing.SupportsXXX protocols are runtime checkable"

--

___
Python tracker 
<https://bugs.python.org/issue40979>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40978] Document that typing.SupportsXXX protocols are runtime checkable

2020-08-02 Thread Luciano Ramalho


Luciano Ramalho  added the comment:

The merged PR that fixed https://bugs.python.org/issue40979 also fixes this 
issue.

It is now documented that these protocols are runtime checkable, with caveats.

--

___
Python tracker 
<https://bugs.python.org/issue40978>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com