pycrossword  0.3
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | List of all members
pycross.crossword.Word Class Reference

Implementation of a single word in a hypothetical crossword. More...

Inheritance diagram for pycross.crossword.Word:
pycross.crossword.Coords

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...
 
- Public Member Functions inherited from pycross.crossword.Coords
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...
 
- Public Attributes inherited from pycross.crossword.Coords
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def pycross.crossword.Word.__init__ (   self,
  coord_start,
  coord_end,
  num = 0,
  clue = '',
  word = None 
)

Initializes and validates data.

Parameters
coord_start2-tuple the start coordinate (x, y)
coord_end2-tuple the end coordinate (x, y)
numint word number (in a hypothetical cw grid)
cluestr word clue text, e.g. "NBA superstar Jordan's first name"
wordstr word text, e.g. "FATHER"

Member Function Documentation

◆ __hash__()

def pycross.crossword.Word.__hash__ (   self)

Python hash() overload: to make Word objects comparable / searchable in collections.

◆ __repr__()

def pycross.crossword.Word.__repr__ (   self)

Python repr() overload: human-readable representation of Word object.

Reimplemented from pycross.crossword.Coords.

◆ set_word()

def pycross.crossword.Word.set_word (   self,
  wd 
)

Sets the internal word string (text).

Parameters
wdstr the word text
Exceptions
crossword::CWErrorpassed word has incorrect length (not corresponding to Coords::len())

Member Data Documentation

◆ clue

pycross.crossword.Word.clue

str word clue text

◆ num

pycross.crossword.Word.num

int word number (in a hypothetical cw grid)

◆ word

pycross.crossword.Word.word

str word text


The documentation for this class was generated from the following file: