mirror of
https://git.mirrors.martin98.com/https://github.com/petaflot/pygcode
synced 2025-06-04 11:25:20 +08:00
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:
parent
5577d6560e
commit
dd6114b709
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user