Steven D'Aprano steve+comp.lang.python at
Fri Feb 25 01:36:39 CET 2011

On Thu, 24 Feb 2011 19:22:52 +0000, wisecracker wrote:

> As I know of no other way to give my Python code away I thought I`d join
> here.

It would be far more appropriate to *ask* where to put your code *first* 
rather than to just dump 350+ lines of double-spaced(!) code into 
people's inboxes, where it will likely be deleted and rapidly forgotten.

The standard place for putting Python packages and modules is on the 
Python Package Index, PyPI:

For *small* snippets, say, a single function, you can use the ActiveState 

A few random comments about your code:

> # Original idea copyright, (C)2009, B.Walker, G0LCU.

You can't copyright ideas.

> # >>> import afg[RETURN/ENTER]

I thought you said you use only "STANDARD Python"? What's afg? It doesn't 
seem very standard to me:

>>> import afg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named afg

> # Import any modules, ~sys~ is not rquired but added nevertheless.
> import sys

Don't do that. If you don't need a module, don't import it. *Especially* 
don't import it only to say "Hey, you don't need this code, I'm just 
wasting your time by making you read this!!!"

> # The program proper...
> def main():
> 	# Make all variables global, a quirk of mine... :)

It's not 1970 any more. People will avoid like the plague code that over-
uses globals.

Also, there's no need to put code inside a "main" function that exists 
only to populate a few global values. Instead of this:

def main():
    global sine
    sine = 'blah blah blah'


Just do this:

sine = 'blah blah blah'

See how much simpler and clearer it is?

> 	sine=chr(15)+chr(45)+chr(63)+chr(45)+chr(15)+chr(3)+chr(0)+chr(3)

This is much more easily and efficiently written as:

sine = ''.join([chr(n) for n in (15, 45, 63, 45, 15, 3, 0, 3)])

or even shorter, as a string constant:

sine = '\x0f-?-\x0f\x03\x00\x03'


More information about the Python-list mailing list