Update gcodes.py

Attempting to add a hash representation of GCode subclasses, so that they can be used as items in sets and dictionary keys.
This commit is contained in:
John Ladasky 2020-03-02 14:53:03 -08:00 committed by GitHub
parent 5577d6560e
commit dd6114b709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,6 +210,14 @@ class GCode(object):
word_str=word_str,
parameters=param_str,
)
def __hash__(self):
"""Hash representation of the gcode, for set and dictionary usage"""
try:
return hash(self.word_key)
except TypeError:
return hash(self.word_letter) # May also want to retrieve additional value info
def _default_word(self):
if self.default_word: