[Tutor] How does the interpreter determine how many decimal places to display for a float?

Alan Gauld alan.gauld at yahoo.co.uk
Sun May 16 14:54:56 EDT 2021


On 16/05/2021 18:15, boB Stepp wrote:

> somewhat surprising that any CPython code would use "cryptic" naming,
> since Python originated circa 1989 (Is that about right when GvR
> started his project?) when I wouldn't think these naming limitations
> still existed for C.

I still have an old DOS C compiler - "Mix C" - that I used
from about 1985 when I got my first PC to the present day
(running under Dosbox on Linux). It can take 32 character
names but only the first 8 characters count. That's only 4
years before Python... I use this because it's a pre-ANSI
compiler so compatible with the original K&R book. Handy
for checking ancient C examples and articles... (gcc probably
has a flag to do the same but I'm too lazy to look! :-)

And many veteran C programmers to this day will still use
very short variable names, especially inside functions,
through force of habit/tradition/community practice.
Indeed I know several who would never consider using
names longer than 5 characters inside a function(*)
 - just to save typing if nothing else!
(Function parameter names tend to be longer to document
the function API. And globals are usually sensible names too.
Likewise struct(aka record) definitions and field names
usually have sensible names, although the instance vars
of said structs will often be short.)

(*)That may sound bad but remember that good C practice says
functions should be short - less than 25 lines - to fit on
a single screen (ie. an old VT100 80x24 terminal...)
If your function is only 10-20 lines long finding the variable
and tracking it is not such a big deal.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list