[Tutor] Re: simple problem

Derrick 'dman' Hudson dman@dman.ddts.net
Fri, 5 Jul 2002 17:37:36 -0500


--qMm9M+Fa2AknHoGS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 05, 2002 at 02:46:39PM -0700, Sean 'Shaleh' Perry wrote:
| On 05-Jul-2002 Kyle Babich wrote:

| > I know how to do something like:
| > myname =3D "Kyle"
| > print "Hello, my name is", myname
| >=20
| > But how would I call up the myname variable in the middle of the print
| > command?
| > (Ie. print "Hello, #myname variable here# where do you live?"
| > ---
|=20
| myname =3D 'Sean'
| person =3D 'Kyle'
|=20
| a) print "Hello, " + person + " my name is " + myname
|=20
| b) print "Hello, %s my name is %s" % (person, myname)
|=20
|=20
| c) print "Hello, ", person, " my name is ", myname
|=20
| I tend to prefer b, many people use a.  C is kind of frowned on.

I tend to use b as well, but sometimes c while I'm debugging (just
'cause it's easy to write and I'll delete the code as soon as I've
fixed it).  Both a and b will print exactly what you wrote (with an
extra newline at the end).  c will add a space in between each
section.  That is by design, just be aware of it.

-D

--=20

A perverse man stirs up dissension,
and a gossip separates close friends.
        Proverbs 16:28
=20
http://dman.ddts.net/~dman/


--qMm9M+Fa2AknHoGS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj0mH7AACgkQO8l8XBKTpRRxcQCeOFb5wXVO0183FhvUEgDpyLwc
R1cAnA3bHJKptPkKwi7ZKHcHmzew8QEo
=Meka
-----END PGP SIGNATURE-----

--qMm9M+Fa2AknHoGS--