[Chicago] Inheriting from a namedtuple

Adam Forsyth adam at adamforsyth.net
Thu Jul 7 19:20:09 EDT 2016


Why namedtuple instead of __slots__? What are you getting from namedtuple?

If you do have a good reason to use namedtuple, I think it's OK to use it
like this -- it reads clearly to me, and is easy to refactor. However, I
would call the base class "PointBase" rather than "Point".

Adam

On Thu, Jul 7, 2016 at 5:58 PM, Aaron Elmquist <elmq0022 at umn.edu> wrote:

> This is a very open ended question, but what do people think about python
> code like:
>
> class Point(namedtuple("Point", "x y")):
>     # additional methods here
>
> Is it pythonic?
>
> Does it buy anything besides keystrokes?
>
> Do you use it in production?
>
> Thanks,
>
> Aaron
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20160707/927e431e/attachment.html>


More information about the Chicago mailing list