{ "cells": [ { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import import_ipynb\n", "import PGenType\n", "#import Rel_Attrib\n", "\n", "class PTuple():\n", " \n", " def __init__(self, attrib_list = None, *args):\n", " #list of objects of types PInt, PReal, ...\n", " self.attrib_list = []\n", " if attrib_list is not None:\n", " self.attrib_list = attrib_list\n", " #list of types of objects\n", " self.attrib_types = [genType for genType in args]\n", " \n", " def add_attrib_types(self, genType):\n", " self.attrib_types.append(genType)\n", " \n", " def get_attrib_type(self, index):\n", " return self.attrib_types[index]\n", " \n", " def get_attrib_types(self):\n", " return self.attrib_types\n", " \n", " def get_attribs(self):\n", " return self.attrib_list\n", " \n", " def __eq__(self, obj):\n", " if obj == self:\n", " return True\n", " if obj is None:\n", " return False\n", " if not isinstance(obj, PTuple):\n", " return False\n", " otherTuple = PTuple()\n", " otherTuple = obj\n", " if not(len(self.attrib_types) == len(otherTuple.get_attrib_types())):\n", " return False\n", " for idx, att in enumerate(self.attrib_types):\n", " if not(att == otherTuple.get_attrib_type(idx)):\n", " return False\n", " return True\n", "\n", " # usage: tuple = PTuple.create_tuple_instance(rel_attrib_list)\n", " @classmethod\n", " def create_tuple_instance(cls, attrib_list):\n", " return cls(attrib_list)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }