pycrossword
0.2
Pure-Python implementation of a crossword puzzle generator and editor
|
Implementation of a single word in a hypothetical crossword. More...
Public Member Functions | |
def | __init__ (self, coord_start, coord_end, num=0, clue='', word=None) |
Initializes and validates data. More... | |
def | set_word (self, wd) |
Sets the internal word string (text). More... | |
def | __hash__ (self) |
Python hash() overload: to make Word objects comparable / searchable in collections. More... | |
def | __repr__ (self) |
Python repr() overload: human-readable representation of Word object. More... | |
![]() | |
def | __init__ (self, coord_start, coord_end) |
The Coords constructor: initializes and validates Coords::start and Coords::end. More... | |
def | validate (self) |
Validates the start and end coordinates passed to init(). More... | |
def | coord_array (self) |
Outputs a list of (x,y) coordinates (2-tuples ) between Coords::start and Coords::end. More... | |
def | does_cross (self, coord) |
Checks if a coordinate lies anywhere between Coords::start and Coords::end. More... | |
def | __len__ (self) |
Python len() overload: the distance between Coords::start and Coords::end. More... | |
Public Attributes | |
num | |
int word number (in a hypothetical cw grid) More... | |
clue | |
str word clue text More... | |
word | |
str word text More... | |
![]() | |
start | |
2-tuple the start coordinate (x, y) More... | |
end | |
2-tuple the end coordinate (x, y) More... | |
dir | |
str direction of the start-to-end vector: 'h' = 'horizontal', 'v' = 'vertical' More... | |
Implementation of a single word in a hypothetical crossword.
The class adds to Coords the word number (as found in a crossword), word string, and clue text.
def pycross.crossword.Word.__init__ | ( | self, | |
coord_start, | |||
coord_end, | |||
num = 0 , |
|||
clue = '' , |
|||
word = None |
|||
) |
Initializes and validates data.
coord_start | 2-tuple the start coordinate (x, y) |
coord_end | 2-tuple the end coordinate (x, y) |
num | int word number (in a hypothetical cw grid) |
clue | str word clue text, e.g. "NBA superstar Jordan's first name" |
word | str word text, e.g. "FATHER" |
def pycross.crossword.Word.__hash__ | ( | self | ) |
Python hash()
overload: to make Word objects comparable / searchable in collections.
def pycross.crossword.Word.__repr__ | ( | self | ) |
Python repr()
overload: human-readable representation of Word object.
Reimplemented from pycross.crossword.Coords.
def pycross.crossword.Word.set_word | ( | self, | |
wd | |||
) |
Sets the internal word string (text).
wd | str the word text |
crossword::CWError | passed word has incorrect length (not corresponding to Coords::len()) |
pycross.crossword.Word.clue |
str
word clue text
pycross.crossword.Word.num |
int
word number (in a hypothetical cw grid)
pycross.crossword.Word.word |
str
word text