[Tutor] A couple newbie questions about Python

Alan Gauld alan.gauld at btinternet.com
Thu Jun 12 00:48:37 CEST 2014


On 11/06/14 21:46, Deb Wyatt wrote:
> Hi.  Everywhere I have read, the 'standard practice' for indentation is 4 spaces,

That's a style recommendation. Python doesn't care.
But your readers will. 2 spaces is the absolute minimum,
8 spaces is about the absolute maximum. Outside that it
gets hard to read the code.

3, 4 or 5 spaces is pretty good and you are unlikely
to get complaints except from style pedants or if you
are submitting code for the standard library where they
like to stick with the official guidance.


> I just recently became aware of the inaccuracy of calculations using floats
 > and I am concerned about that.

The inaccuracies are an inevitable result of the way your computer 
processes floating point numbers.

In what way are you concerned? Its not a Python issue - the exact same 
issues occur in any computer - or even your pocket calculator.
If it concerns you in Excel or in Visual Basic/Java/C++ etc too then the 
good news is that Python has alternative renderings that can often 
reduce/eliminate them - but at the cost of speed and complexity.


HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list