visual indentation
Cliff Wells
logiplex at qwest.net
Fri Aug 22 15:26:20 EDT 2003
On Fri, 2003-08-22 at 11:10, Hilbert wrote:
> Hello,
>
> I'm using python to output RIB streams for Renderman.
> The RIB stream is a bunch of statements which describes
> a 3d image. The Rib standard allows for blocks which we
> usually indent for better visualization for example:
>
> WorldBegin
> Color [1 1 1]
> Surface "constant"
> Sphere(1.0, -1.0, 1.0, 360)
> WorldEnd
>
> I'm using CGKit in python which has a Renderman binding,
> so to output the same RIB I'd write:
>
> RiWorldBegin()
> RiColor(1.0,1.0,1.0)
> RiSurface('constant')
> RiSphere(1.0,-1.0,1.0,360)
> RiWorldEnd()
>
> But I get an error, because python interprets my indentation
> as a block in the python code. So the only way to write this
> is without the indentation:
>
> RiWorldBegin()
> RiColor(1.0,1.0,1.0)
> RiSurface('constant')
> RiSphere(1.0,-1.0,1.0,360)
> RiWorldEnd()
>
> But this is a lot harder to read.
>
> Is there any way to use such "visual" indentation in python?
How about this? It creates a bit of unnecessary overhead (a single
tuple creation), but looks okay visually (and Emacs correctly indents
it):
RiWorldBegin()
(
RiColor(1.0,1.0,1.0),
RiSurface('constant'),
RiSphere(1.0,-1.0,1.0,360),
)
RiWorldEnd()
Regards,
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 (800) 735-0555
More information about the Python-list
mailing list