Newbie...

Corey Richardson kb1pkl at aim.com
Fri Feb 25 03:39:14 EST 2011


On 02/25/2011 03:18 AM, wisecracker at tesco.net wrote:
> True, but it is inside a Python file too. So therefore the idea is in a working state.

Then copyright the code.

>>> # >>> 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
> 
> I made the mistake of making an assumption that intelligent guys like you
> would know to save the first file as afg.py and the second as arp.py from the
> import statements given... Oh well, can`t win `em all.

Should have specified that with header comment, for example:

#######################################
## Copyright 2009, B.Walker, G0LCU.
## arp.py
##
## Something about this module
#######################################

Or even better, a docstring.


>>> # 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.
> 
> Maybe not but I code for 10 year olds to understand and be able to modify easily, I build
> HW for 10 year olds to make, modify and understand, I marry the two for 10 year olds to
> modify and understand.

Teaching good practice to the young is better than teaching them easy
bad practice. It's taken me a too long to break out of my bad habits I
learned when I was 13 first learning Python.

> Mine is easy to understand even by programmer of limited knowledge.
> Most of the Python code I`ve seen would be just visual 'noise' to a 10 year old.
> 
>> 	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'
> 
> Now show your code to a 10 year old and see if he understands it...

When I was 10 all I knew was Logo (and very little of it)!

Also, if one understands how a unicode byte looks like in a string, it's
pretty easy to understand, and looks a hell of a lot clearer than a
bunch of chr()'s without any space between. That's just my two cents.

-- 
Corey Richardson



More information about the Python-list mailing list