Re: How to automatically get the indent level from code?

2013-03-18 Thread Peng Yu
On Sun, Mar 17, 2013 at 1:23 AM, Mark Shroyer mshro...@awaredigital.com wrote: I realize this isn't yet precisely what you're asking for, but look at the inspect and ast modules: import ast, inspect def indent_level(): lineno = inspect.currentframe().f_back.f_lineno

RE: How to automatically get the indent level from code?

2013-03-17 Thread Mark Shroyer
But hopefully it's a start. Mark -Original Message- From: Python-list [mailto:python-list-bounces+mshroyer=awaredigital@python.org] On Behalf Of Peng Yu Sent: Sunday, March 17, 2013 12:53 AM To: python-list@python.org Subject: How to automatically get the indent level from code? Hi, I want

How to automatically get the indent level from code?

2013-03-16 Thread Peng Yu
Hi, I want to get the indent level within the code. For example, I want to print 1 within the while loop as the line is indented 1 level. Is it possible to get it within python? while 1: #print the level of indent, which is 1 here. -- Regards, Peng --

Re: How to automatically get the indent level from code?

2013-03-16 Thread Rodrick Brown
No On Sun, Mar 17, 2013 at 12:52 AM, Peng Yu pengyu...@gmail.com wrote: Hi, I want to get the indent level within the code. For example, I want to print 1 within the while loop as the line is indented 1 level. Is it possible to get it within python? while 1: #print the level of