
Codeplot This is something like a toy example for Piddle that you might use as well to visually fingerprint Python code in a weird way, a bit like in the "Matrix", perhaps. ;-) Introduction (from codeplot's doc string): This module takes a Python source code file and creates a two-dimensional plot out of it. The plot generated is a symmetrical one, much like a 2D matrix where a dot at (i,j) indicates that lines i and j in the input file are the same. Sounds silly? Maybe, yes. After all, this is a one day fun 'project' while reading a book on, you guessed it, patterns. But I guess you'll be surprised of what you can see in these silly plots. Peaks result by definition from identical lines (in red). Very often this will be the case due to empty lines, therefore these lines are marked distinctly (grey). Other interesting things come from lines that are similar, but not identical. In the current implementation, "similar" means lines that are identical modulo an arbitrary inden- tation (marked in blue). So this is a little bit only of a bias towards Python as a language, but in fact you can run codeplot on any kind of ASCII file (that is made of individual lines, separated by newlines). The plots are generated using the new PIDDLE interface (during development codeplot created PDF files) in the version 1.0.3. Some words of praise for PIDDLE: it's cool! Without it codeplot would never have happened. What's the future of this thing?! I don't know! I'll do a bit more here and there, maybe create a proper EPS file instead of PDF (such that it can be included some- where else more easily). There's likely still something to improve to handle indentation by tabs properly as well. It could be faster, perhaps, but it's inherently O(n^2), so don't use it on a 200 KB C file (yes - they DO exist, sigh...). Using Numeric might be an idea, not sure... If you think you can do something to improve it let me know. If you use it in some interesting way, let me know, too. Installation: Put codeplot.py somewhere in your Python path. Also make sure you have Piddle already installed. You can find Piddle here: http://www.strout.net/python/piddle/ Files: README.txt - This file. codeplot.py - The Python codeplot module. samples.zip - Some sample PDF files. The samples were more or less randomly selected from the following packages: pythondoc, idle, pdfgen, piddle, consdiag, Zope, the Python Interpreter (a C file) and codeplot itself (the filenames should suffice to get an idea of where they awere taken from). The original python files are not included, though (except codeplot.py). Several differences can be observed, but these are to be explained elsewhere. Contact: Author: Dinu C. Gherman, gherman@europemail.com.nospam Web-Site: http://starship.python.net/crew/gherman/playground/codeplot/ Copyright: Do with it whatever you want, but don't sue me! If you make money with codeplot, pay me half of it as royalities! ;-) 1999-07-28 (codeplot 0.1) Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. <P><A HREF="http://starship.python.net/crew/gherman/playground/codeplot/">codeplot 0.1</A> - visually fingerprint Python code in a weird way... (28-Jul-99) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce@python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------
participants (1)
-
Dinu C. Gherman