Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > visual indentation

Reply
Thread Tools

visual indentation

 
 
Greg Krohn
Guest
Posts: n/a
 
      08-22-2003

"Hilbert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
> Thanks,
> Hilbert
>
> http://www.velocityreviews.com/forums/(E-Mail Removed)
>
>


What about an if statement:

RiWorldBegin()
if True:
RiColor(1.0,1.0,1.0)
RiSurface('constant')
RiSphere(1.0,-1.0,1.0,360)
RiWorldEnd()

I realize it's ugly, but it's easy.


 
Reply With Quote
 
 
 
 
Dan Bishop
Guest
Posts: n/a
 
      08-23-2003
Hilbert <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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

....
> Is there any way to use such "visual" indentation in python?


If the code consists of nothing but expressions (which yours does), you can write:

(RiWorldBegin())
( RiColor(1.0,1.0,1.0))
( RiSurface('constant'))
( RiSphere(1.0,-1.0,1.0,360))
(RiWorldEnd())

or

(
RiWorldBegin(),
RiColor(1.0,1.0,1.0),
RiSurface('constant'),
RiSphere(1.0,-1.0,1.0,360),
RiWorldEnd()
)
 
Reply With Quote
 
 
 
 
Cliff Wells
Guest
Posts: n/a
 
      08-23-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?


I'm sending this again as the message I sent earlier apparently never
made it.

RiWorldBegin()
(
RiColor(1.0,1.0,1.0),
RiSurface('constant'),
RiSphere(1.0,-1.0,1.0,360),
)
RiWorldEnd()

There's a bit of added overhead (superfluous tuple creation) but it does
what you ask.

Regards,
Cliff

--
Should I stand midst the breakers, Should I lie with Death my bride?
-This Mortal Coil


 
Reply With Quote
 
Hilbert
Guest
Posts: n/a
 
      08-24-2003
Thanks for all the suggestions!

I like both the tuple and the if 1: approach.

I don't want to define blocks in functions because that
would actually differ from how the RIB stream works.
I'd like to have my code reflect a real RIB stream.

Thanks again,
Hilbert

(E-Mail Removed)



In article <(E-Mail Removed)>, 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?
>
> Thanks,
> Hilbert
>
> (E-Mail Removed)
>
>

 
Reply With Quote
 
Chad Netzer
Guest
Posts: n/a
 
      08-25-2003
On Fri, 2003-08-22 at 12:13, Hans Nowak wrote:
> Hilbert wrote:


> But maybe somebody else has a better solution...?



Another kinda ugly one:


RiWorldBegin() ;\
RiColor(1.0,1.0,1.0) ;\
RiSurface('constant') ;\
RiSphere(1.0,-1.0,1.0,360) ;\
RiWorldEnd()


--

Chad Netzer


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove overall indentation preserving reletive indentation Jesse B. Ruby 2 03-27-2010 07:23 PM
DataList Indentation SJ ASP .Net 2 11-04-2005 12:16 AM
[Fwd: Indentation] jacov Java 0 07-22-2004 03:22 PM
List Indentation Jay HTML 5 04-21-2004 02:49 PM
Unwanted indentation Daan HTML 2 12-09-2003 10:09 PM



Advertisments