How to use the namedlist.NamedList function in namedlist

To help you get started, we’ve selected a few namedlist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heeres / qtlab / datalist.py View on Github external
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import data
import namedlist

class DataList(namedlist.NamedList):
    def __init__(self, time_name=True):
        namedlist.NamedList.__init__(self, 'data')

        self._time_name = time_name

    def new_item_name(self, item, name):
        '''Function to generate a new item name.'''

        if name == '':
            self._auto_counter += 1
            name = self._base_name + str(self._auto_counter)
            item.set_name(name)

        if self._time_name:
            return item.get_time_name()
        else:

namedlist

Similar to namedtuple, but instances are mutable.

Apache-2.0
Latest version published 4 years ago

Package Health Score

46 / 100
Full package analysis

Similar packages