Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.ru/trac/snake/changeset/112%3A2d048c0ed5e3
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 21:53:08 2016
Êîäèðîâêà: IBM-866
Changeset 112:2d048c0ed5e3 òÀÓ Python Battle

Changeset 112:2d048c0ed5e3


Ignore:
Timestamp:
12/20/10 12:58:45 (5 years ago)
Author:
Alex Martynov <martiran@òÀæ>
Branch:
default
Parents:
110:763c07539658 (diff), 111:9486211ec334 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Automated merge with òÀËssh://kodomo.fbb.msu.ru/snake

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • snake.py

    • Property exe set to *
    r109 r112 ˆà
    6666        for cell in self.cells:ˆà
    6767            cell.snake = selfˆà
    ˆà68        for cell in self.cells:ˆà
    ˆà69            cell.type = 'body'ˆà
    6870        self.cells[0].type = 'head'ˆà
    69ˆà        for cell in self.cells[1:-1]:ˆà
    70ˆà            cell.type = 'body'ˆà
    7171        self.cells[-1].type = 'tail'ˆà
    7272        returnˆà
  • snake.py

    r111 r112 ˆà
    99    line = line.rstrip()ˆà
    1010    return lineˆà
    ˆà11ˆà
    ˆà12class File(object):ˆà
    ˆà13    """Wrapper around file that saves the current line number."""ˆà
    ˆà14    def __init__(self, file):ˆà
    ˆà15        self.file = fileˆà
    ˆà16        self.name = file.nameˆà
    ˆà17        self.line_no = 0ˆà
    ˆà18    def __iter__(self):ˆà
    ˆà19        for line_no, line in enumerate(self.file, self.line_no):ˆà
    ˆà20            self.line_no = line_noˆà
    ˆà21            yield lineˆà
    1122ˆà
    1223class Snake(object):ˆà
    òÀæ òÀæ ˆà
    3243        See program design docs for file syntax.ˆà
    3344        """ˆà
    ˆà45        file = File(file)ˆà
    ˆà46        try:ˆà
    ˆà47            self._load(file)ˆà
    ˆà48        except Exception, e:ˆà
    ˆà49            raise Exception("%s:%s: %s" % (file.name, file.line_no, e))ˆà
    ˆà50ˆà
    ˆà51    def _load (self, file):ˆà
    ˆà52        """Actually do the loading."""ˆà
    3453        for line in file:ˆà
    3554            magic, self.name = preprocess(line).split(' ', 1)ˆà
Note: See TracChangeset for help on using the changeset viewer.