I tried to use this method in my code like this:-
---------------------------------------------------------------------------------
#!/usr/bin/python                                                                                                                                 

def print_sql():
    sql = '''aaaaaaaaaaaaaaaaaaaaaaa
    bbbbbbbbbbbbbbbbbbbbbbb'''.replace("\n","")
    print sql

print_sql()

---------------------------------------------------------------------------------

the ouput of this is aaaaaaaaaaaaaaaa<space><tab>bbbb......

I can always do this :-
---------------------------------------------------------------------------------
#!/usr/bin/python                                                                                                                                 

def print_sql():
    sql = '''aaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbb'''.replace("\n","")
    print sql

print_sql()

---------------------------------------------------------------------------------

but it looks ugly


On 11/22/05, Mohammad Jeffry <[EMAIL PROTECTED]> wrote:

On 11/22/05, Paul McGuire <[EMAIL PROTECTED]> wrote:
Or for a large literal string:

"""
lots of text hundreds of characters long
more text on another line but we really don't want any line breaks
in our final string
so we replace newlines in this multiline string
with an empty string thus
""".replace('\n','')

-- Paul


I love your method. The only drawbacks for this method is I can't tell whether there is blank space at the end of each lines. For EG: the above string might be

lots of text hundreds of characters longmore text on another.....
                                                        ^
or

lots of text hundreds of characters long more text on another.....
                                                        ^





--
And whoever does an atom's weight of evil will see it.



--
And whoever does an atom's weight of evil will see it.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to