Checking Comments

Moshe Zadka moshez at math.huji.ac.il
Sat Apr 29 07:32:03 EDT 2000


Here's a small script I use to check the comments in a file. It is a nice
tools for Py-teachers, to check students comment their code enough.

Here it is, in all it's glory:

================ cut here =========================
# comments.py
# Released to the Public Domain by Moshe Zadka 
# on 29.4.2000
import sys, tokenize

def print_if_comment(type, token, *args):
        if type==tokenize.COMMENT:
                sys.stdout.write(token)

tokenize.tokenize(sys.stdin.readline, print_if_comment)
====================== cut here ==================

use-and-enjoy-ly y'rs, Z.
--
Moshe Zadka <mzadka at geocities.com>. 
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list