[Tutor] multiline comment in Python
Karl Pflästerer
sigurd at 12move.de
Sat Sep 6 02:47:51 EDT 2003
An unnamed person wrote:
> statements in it, I meant print statements using quotes. Take for example
> a small program I wrote yesterday to be run from the commandline:
Now it's clear what you mean. And with a little pice rewritten it works.
> <code>
> #!/usr/bin/env python
> def dec2hexconverter(x):
> hexstring = hex(x).replace('0x', '').replace('L', '').upper()
> length = len(hexstring)
> if length == 1:
> hexstring = '000' + hexstring
> """elif length == 2:
> hexstring = '00' + hexstring
> elif length == 3:
> hexstring = '0' + hexstring"""
> elif length == 8:
> hexstring = hexstring[:4] + ' ' + hexstring[-4:]
> print hexstring
def dec2hexconverter(x):
hexstring = hex(x).replace('0x', '').replace('L', '').upper()
length = len(hexstring)
if length == 1:
hexstring = '000' + hexstring
"""
elif length == 2:
hexstring = '00' + hexstring
elif length == 3:
hexstring = '0' + hexstring
"""
elif length == 8:
hexstring = hexstring[:4] + ' ' + hexstring[-4:]
print hexstring
Use seperate lines for the triple quotes and Python is happy.
What you can't use there you are right are triple quotes around triple
quotes. Then it's easier to use your editor (like eg XEmacs :-) ) and
use its command for commenting a region.
Karl
--
Please do *not* send copies of replies to me.
I read the list
More information about the Tutor
mailing list