Should the class "Menu" in "_base.py" decompress *items into tuple or list?
AllowDeny0123 opened this issue · 1 comments
AllowDeny0123 commented
class Menu(object):
"""A description of a menu.
A menu description is immutable.
It is created with a sequence of :class:`Menu.Item` instances, or a single
callable which must return a generator for the menu items.
First, non-visible menu items are removed from the list, then any instances
of :attr:`SEPARATOR` occurring at the head or tail of the item list are
removed, and any consecutive separators are reduced to one.
"""
#: A representation of a simple separator
SEPARATOR = MenuItem('- - - -', None)
def __init__(self, *items):
self._items = tuple(items)
The description of this says it should be a list, but the original is tuple.
IMHO, If you adjust the code to fit the description, it will make it easier to edit the menu items:
def __init__(self, *items):
self._items = list(items)
I don't pretend to be correct, but if there is a reason for tuple there, I'd like to hear an explanation, since I don't have much experience in development
moses-palmer commented
Thank you for your report.
Perhaps using the work "list" is a bit overloaded in the context of Python code, but the paragraph before describes it as a sequence, which I think is clear enough.
There is a reason for using a tuple: it is supposed to be immutable and change only with lambdas providing custom menu items.