code indentation

Diez B. Roggisch deets at nospam.web.de
Thu Jul 26 18:33:55 EDT 2007


vedrandekovic at v-programs.com schrieb:
> On 26 srp, 13:43, Steve Holden <st... at holdenweb.com> wrote:
>> Thorsten Kampe wrote:
>>> *  (Wed, 25 Jul 2007 11:22:03 -0700)
>>>> On 25 srp, 17:31, Wildemar Wildenburger <wilde... at freakmail.de> wrote:
>>>>> vedrandeko... at v-programs.com wrote:
>>>>>>> And while we're on the topic of communication: The original poster
>>>>>>> would do well to learn that increasing the number of consecutive
>>>>>>> punctuation marks (!!!, ???) is a sure way to turn away many people
>>>>>>> who would otherwise be helpful. Sentences need at most one '!' or '?',
>>>>>>> adding more does not improve the chances of being taken seriously.
>>>>>> And if you can help me than please help me , but if you can't then
>>>>>> please don't leave me some stupid messages
>>>>> Whats stupid about this? It's sane advice.
>>>>> Which looks more serious to you:
>>>>> this:
>>>>> I can't do it!!!! Can you PLEASE help me????!!!?!
>>>>> or this:
>>>>> I don't know the answer. Can you please help me?
>>>>> Even if it makes no difference to you, to many people it does. So Ben is
>>>>> right: People *will* take your posts more seriously if you restrict your
>>>>> use of punctuation (if only because its easier to read).
>>>>> Don't feel offended, nobody was trying to put you down.
>>>> On this group I ask for serious help and now we talk about
>>>> communication. Then I you don't know how to help me then please DON'T
>>>> SAY ANYTHING
>>> You already got serious help even though you haven't realised that
>>> yet.
>> We should be making allowances for this particular poster on account of
>> relative youth: I hadn't realised earlier, but we are dealing with a
>> fourteen-year-old. Since fourteen-year-olds already know everything we
>> should be honored we are being asked for help at all ;-)
>>
>> regards
>>   Steve
>> --
>> Steve Holden        +1 571 484 6266   +1 800 494 3119
>> Holden Web LLC/Ltd          http://www.holdenweb.com
>> Skype: holdenweb      http://del.icio.us/steve.holden
>> --------------- Asciimercial ------------------
>> Get on the web: Blog, lens and tag the Internet
>> Many services currently offer free registration
>> ----------- Thank You for Reading -------------
> 
> Hi again,
> 
> Just one more question, can I maybe do this indentation with string
> e.g
> here is my failed example of try with string:
> 
> kl="n=90;if n==90:print'kajmakimar'"
> 
> for line in kl.split(";"):
>     li=[]
>     m=li.append(line)
>     if line.endswith(':'):
>             m.append("\n\t\t\t\t\t\t\t\t")
>     print m
> 
> .....so maybe if you can help me with this?

This won't work. It's impossible to know how deep to indent without any 
begin/end-tokens. Consider this simple example:

if foo:
    print "foo"
    if bar:
       print "bar"

is equal to

'if foo:;print"foo";if bar:;print "bar"'

But that could as well be

if foo:
    print "foo"
if bar:
    print "bar"

So - you need some block delimiters.

And as it has been said to you a bazzillion times: stop doing what 
you're doing. Use python. As it is. Your limited understandig of parsing 
and language design makes your task beyond your capabilites. For now. 
And the forseeable future...

diez



More information about the Python-list mailing list