visual indentation
Skip Montanaro
skip at pobox.com
Fri Aug 22 14:47:42 EDT 2003
Hilbert> I'm using CGKit in python which has a Renderman binding, so to
Hilbert> output the same RIB I'd write:
Hilbert> RiWorldBegin()
Hilbert> RiColor(1.0,1.0,1.0)
Hilbert> RiSurface('constant')
Hilbert> RiSphere(1.0,-1.0,1.0,360)
Hilbert> RiWorldEnd()
Hilbert> But I get an error, because python interprets my indentation as
Hilbert> a block in the python code.
As it should, because whitespace is significant in Python.
Hilbert> So the only way to write this is without the indentation:
Hilbert> RiWorldBegin()
Hilbert> RiColor(1.0,1.0,1.0)
Hilbert> RiSurface('constant')
Hilbert> RiSphere(1.0,-1.0,1.0,360)
Hilbert> RiWorldEnd()
Hilbert> But this is a lot harder to read.
Hilbert> Is there any way to use such "visual" indentation in python?
In this case, just use "if 1:"
RiWorldBegin()
if 1:
RiColor(1.0,1.0,1.0)
RiSurface('constant')
RiSphere(1.0,-1.0,1.0,360)
RiWorldEnd()
Skip
More information about the Python-list
mailing list