[Tutor] Space

Grail python@nzpagans.8m.com
Mon, 18 Mar 2002 13:34:14 +1200


This is a multi-part message in MIME format.

------=_NextPart_000_0014_01C1CE81.9847F440
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Another newbie question:
How can I *not* have a space between arguments(is that what they are =
called?)

E.g.
print oDay, suffix(oDay)

Displays as:
23 rd

I'd like to get rid of that space.


At http://starship.python.net/~da/jak/cookbook.html
It says
"In python, the print statement has very good default semantics --- most =
of the time, it does exactly what you want, putting a space between the =
arguments, and a newline at the end. If you want more control over the =
formatting, use the % operator [link to % operator]: rather than=20
    print k, ':', string.join(v)

you could use=20
print "%s: %s", (k, string.join(v))

to avoid the space before the colon."


I tried:
print "%s: %s", (oDay, suffix(oDay))

(just to see if it would work) But it displayed as:
%s: %s (12, 'th')


This is such a tiny little thing, sorry I couldn't find the answer =
myself!

------=_NextPart_000_0014_01C1CE81.9847F440
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252"><BASE=20
href=3D"file://C:\Program Files\Common Files\Microsoft =
Shared\Stationery\">
<STYLE>BODY {
	BACKGROUND-POSITION: left top; FONT-SIZE: 10pt; MARGIN-LEFT: 10px; =
COLOR: #000000; BACKGROUND-REPEAT: no-repeat; FONT-FAMILY: Arial
}
</STYLE>

<META content=3D"MSHTML 6.00.2713.1100" name=3DGENERATOR></HEAD>
<BODY vLink=3Dgreen link=3Dorange bgColor=3D#ffffff>
<DIV>Another newbie question:</DIV>
<DIV>How can I *not* have a space between arguments(is that what they =
are=20
called?)</DIV>
<DIV>&nbsp;</DIV>
<DIV>E.g.</DIV>
<DIV>print&nbsp;oDay, suffix(oDay)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Displays as:</DIV>
<DIV>23 rd</DIV>
<DIV>&nbsp;</DIV>
<DIV>I'd like to get rid of that space.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>At <A=20
href=3D"http://starship.python.net/~da/jak/cookbook.html">http://starship=
.python.net/~da/jak/cookbook.html</A></DIV>
<DIV>It says</DIV>
<DIV>"In python, the print statement has very good default semantics --- =
most of=20
the time, it does exactly what you want, putting a space between the =
arguments,=20
and a newline at the end. If you want more control over the formatting, =
use the=20
<CODE>%</CODE> operator [link to % operator]: rather than <XMP>    print =
k, ':', string.join(v)
</XMP>you could use <XMP>print "%s: %s", (k, string.join(v))
</XMP>to avoid the space before the colon."</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>I tried:</DIV>
<DIV>print "%s: %s", (oDay, suffix(oDay))</DIV>
<DIV>&nbsp;</DIV>
<DIV>(just to see if it would work) But it displayed as:</DIV>
<DIV>%s: %s (12, 'th')</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>This is&nbsp;such a tiny&nbsp;little thing, sorry I couldn't find =
the=20
answer myself!</DIV></BODY></HTML>

------=_NextPart_000_0014_01C1CE81.9847F440--