You could try getting some help from textwrap

import textwrap

s = """
blah blah .... blah,
     some more stuff,
and we're done."""

def getSingleLineStr(mlString):
    return " ".join([s.strip() for s in
textwrap.fill(mlString).split()])

On Sep 10, 10:34 am, haseeb ahmed <[email protected]> wrote:
> sorry, this is little off-topic. but i found most relevant pupil here,
> and probability of getting help from here is far more..
>
> is there a way (method or function or def) from some library, that can help
> converting a multi line string to single line string while taking care of
> tabs (indentation) etc...
>
> basically working on a nuke script. what i want is to set a script (set of
> commands) to a custom tab Button.
> if i wrap that set of commands with multi line triple quote and assign this
> to button command, it works
>
> i have seen similar fashion scripts, but to make it work, scripters have
> convert their set of commands to single line by putting lot of \n \t's etc
> this seems a little tedious, if manually done. and i think, ppl do it
> manually ( i have seen in a training)
>
> if i try to put that multi line string inside a def and return that string.
> ( it includes indentation) this produces error as set commands cannot have
> double indentation in button expression / script area.
>
> will glad, if someone can help.
>
> --
> regards,
> lala

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to