[issue44109] missing dataclass decorator in match-statement example

2021-06-26 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Ahmet: once there's agreement on how to fix this, would you like to work on a 
patch?

--

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-06-25 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I agree the example is confusing for all of the stated reasons.

It seems to me it's better to use a plain class with a `__init__()` for two 
reason:

- for people who are not familiar with namedtuples or dataclasses, it would be 
harder to learn two fairly complex topics at the same time. Docs for both are 
fairly extensive.

- for those who *are* familiar with namedtuples or dataclasses (whichever is 
used in the example), the example may imply they should be used with pattern 
matching, and that plain classes may not work or not work well.

I can make a PR that adds `__init__` if this makes sense..

--
nosy: +andrei.avk

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-17 Thread Eric V. Smith


Eric V. Smith  added the comment:

I agree with Raymond: a more useful example would use dataclasses or 
typing.NamedTuple. The use of class variables is unusual, and it took me a 
while to understand how it would work.

--
nosy: +eric.smith

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-14 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Thoughts from others?

As it stands, the Point class is weird and atypical by only using class 
variables.  The example would be improved by adding @dataclass or inheriting 
from typing.NamedTuple.

--
nosy: +rhettinger

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-13 Thread Brandt Bucher


Brandt Bucher  added the comment:

I don't really think there is anything wrong with the documentation. I can 
copy-and-paste all of the code from the PEP 634 section of the 3.10 What's New 
into the REPL without any issues (provided that named subjects like 
point/points/test_variable/color are actually defined).

Note that none of the example snippets actually *create* Point instances. 
Rather, some of the patterns *match* Point instances... which is sort of the 
opposite of instantiation.

As the Point class is currently written, instantiation would probably look like:

>>> p = Point()
>>> p.x = 0
>>> p.y = 0

Sure, it would help to have an __init__ defined in real code, but I sort of 
feel like adding it to this example would just distract (especially since the 
example doesn't actually *need* it).

Thoughts from others?

--

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-13 Thread Brandt Bucher


Change by Brandt Bucher :


--
nosy: +brandtbucher

___
Python tracker 

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



[issue44109] missing dataclass decorator in match-statement example

2021-05-11 Thread Ahmet Burak


New submission from Ahmet Burak :

Using Point class as in the documentation example, raises TypeError: Point() 
takes no arguments
https://docs.python.org/3.10/whatsnew/3.10.html#patterns-and-classes

Also there is same example in the PEP 636's latests parts, Point class used 
with dataclass decorator and works perfectly.
https://www.python.org/dev/peps/pep-0636/

--
assignee: docs@python
components: Documentation
messages: 393454
nosy: ahmetveburak, docs@python
priority: normal
severity: normal
status: open
title: missing dataclass decorator in match-statement example
type: behavior
versions: Python 3.10

___
Python tracker 

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