[Tutor] Noob to Python - Need help with Variables
Tony Stevenson
Tony@pc-tony.com
Thu Jun 5 13:16:01 2003
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C32B85.5FC13C50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Thanks guys,=20
=20
Figured it now. =20
Using this expression instead: -
=20
=20
os.mkdir("D:\\tempint\\" + user)
=20
This seems to work very well. Of course this could be a very bad way =
of
doing things.
=20
Hmmm, comments please. :-)
=20
=20
Cheers,
Tony
=20
-----Original Message-----
From: Ole Jensen [mailto:learning.python@dbmail.dk]=20
Sent: 05 June 2003 16:32
To: tutor@python.org
Subject: Re: [Tutor] Noob to Python - Need help with Variables
=20
-----[snip]--------
=20
> ...and don't worry, you can always ask questions here if you get =
stuck at=20
> someplace ...but you really should get the basic stuff under your =
belt
before=20
> you move on.
>=20
> (*) Introductory docs can be found at:
> http://www.python.org/doc/Intros.html
<http://www.python.org/doc/Intros.html>=20
> Look under "Introductions to Python programming for =
non-programmers"
>From one nooB to the other I agree totally with Steve that you should =
go
through some of the tutorials.
=20
Now the reason I am replying before you barely pressed the link is =
mostly
because that I had a really difficult time finding this answer, as I =
have
only seen this in one tutorial.
for now:
what you need to do is use the percent sign. Which as far as I now is =
called
the mudulo operator, and in all but one of the tutorials I've been =
through
this is only descriped as a way to calculate the remainder of a =
division.
E.g. 7 / 4 =3D 1 with a remainder of 3, so in python 7 % 4 =3D 3
But thats far from what the persent sign can do...
if you want to include a varible in a string e.g.:
=20
>>> name =3D "Tony"
>>> str =3D "Hello, %s" % name
>>> print str
Hello, Tony
=20
There's annother way to do it as well, but i'm not to sure about that:
keeping the varibles as is
=20
>>> str =3D "Hello, =B4name=B4"
should print: Hello, Tony
=20
however I get a unicode error so I'm obvously doing something wrong, if
anybody else know about this method I would really like what im doing =
wrong!
=20
Finally again as steve said you really need to go through some =
tutorials,
these two I found extremly useful:
=20
Alan Guald's http://www.freenetpages.co.uk/hp/alan.gauld/
<http://www.freenetpages.co.uk/hp/alan.gauld/>=20
and
Michael Williams' http://users.ox.ac.uk/~sann1276/python/handbook/
<http://users.ox.ac.uk/~sann1276/python/handbook/>=20
=20
ohh and forgot about this one http://www.ibiblio.org/obp/thinkCSpy/
<http://www.ibiblio.org/obp/thinkCSpy/> , "How to Think Like a =
Computer
Scientist"
=20
Now I might be a slow learner but I have never even heard of this
'shutil.rmtree("d:\\tempint\"user"' (by the way I think need an end =
brace on
that), but depending on how brave you are I would recommend getting =
down
with the basics before you play around with something you could =
accidentally
mess up.
=20
=20
Ole
------_=_NextPart_001_01C32B85.5FC13C50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 10">
<meta name=3DOriginator content=3D"Microsoft Word 10">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C32B8D.C31E93D0">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:EnvelopeVis/>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;
mso-font-charset:2;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:553679495 -2147483648 8 0 66047 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:blue;
text-decoration:underline;
text-underline:single;}
span.EmailStyle17
{mso-style-type:personal-reply;
mso-style-noshow:yes;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:navy;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */=20
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=3Dwhite lang=3DEN-GB link=3Dblue vlink=3Dblue =
style=3D'tab-interval:36.0pt'>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Thanks guys, =
<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 color=3Dnavy =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Figured it =
now.</span></font></span><font
size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;
color:navy'><span style=3D'mso-spacerun:yes'>=A0 =
</span><o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Using this expression instead: =
-<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><span class=3DSpellE><span class=3DGramE><font =
size=3D2
color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;
color:navy'>os.mkdir</span></font></span></span><span =
class=3DGramE><font size=3D2
color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;
color:navy'>(</span></font></span><font size=3D2 color=3Dnavy =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>"D:\\tempint\\"
+ user)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>This seems to work very well. =
<span
style=3D'mso-spacerun:yes'>=A0</span>Of course this could be a very bad =
way of
doing things.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Hmmm, comments please.<span
style=3D'mso-spacerun:yes'>=A0 </span></span></font><font size=3D2 =
color=3Dnavy
face=3DWingdings><span =
style=3D'font-size:10.0pt;font-family:Wingdings;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:navy;=
mso-char-type:symbol;mso-symbol-font-family:Wingdings'><span =
style=3D'mso-char-type:
symbol;mso-symbol-font-family:Wingdings'>J</span></span></font><font =
size=3D2
color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Cheers,<o:p></o:p></span></font></p=
>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Tony<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>=
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma;mso-ansi-language:EN-US'>--=
---Original
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Ole Jensen
[mailto:learning.python@dbmail.dk] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> 05 June 2003 =
16:32<br>
<b><span style=3D'font-weight:bold'>To:</span></b> tutor@python.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [Tutor] =
Noob to
Python - Need help with Variables</span></font></p>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D3
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt'><o:p> </o:p></span></font></p>
<div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>-----[snip]--------<o:p></o=
:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><br>
<br>
> ...and don't worry, you can always ask questions here if you get =
stuck at <br>
> someplace ...but you really should get the basic stuff under your =
belt
before <br>
> you move on.<br>
> <br>
> (*) Introductory docs can be found at:<br>
> <a =
href=3D"http://www.python.org/doc/Intros.html">http://www.python.org/doc=
/Intros.html</a><br>
> Look under "Introductions to Python =
programming
for non-programmers"<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>From one nooB to the other =
I agree
totally with Steve that you should go through some of the =
tutorials.<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Now the reason I am =
replying before
you barely pressed the link is mostly because that I had a really =
difficult
time finding this answer, as I have only seen this in one =
tutorial.<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>for =
now:<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>what you need to do is use =
the percent
sign. Which as far as I now is called the mudulo operator, and in all =
but one
of the tutorials I've been through this is only descriped as a way =
to
calculate the remainder of a division. E.g. 7 / 4 =3D 1 with =
a
remainder of 3, so in python 7 % 4 =3D =
3<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>But thats far from what =
the persent
sign can do...<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if you want to include a =
varible in
a string e.g.:<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>>>> name =3D =
"Tony"<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>>>> str =3D =
"Hello,
%s" % name<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>>>> print =
str<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Hello, =
Tony<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>There's annother way to do =
it as
well, but i'm not to sure about that:<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>keeping the varibles as =
is<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>>>> str =3D =
"Hello,
=B4name=B4"<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>should print: Hello, =
Tony<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>however I get a unicode =
error so I'm
obvously doing something wrong, if anybody else know about this method =
I would
really like what im doing wrong!<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Finally again as steve =
said you
really need to go through some tutorials, these two I found extremly =
useful:<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Alan Guald's <a
href=3D"http://www.freenetpages.co.uk/hp/alan.gauld/">http://www.freenet=
pages.co.uk/hp/alan.gauld/</a><o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>and<o:p></o:p></span></font=
></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Michael Williams' <a
href=3D"http://users.ox.ac.uk/~sann1276/python/handbook/">http://users.o=
x.ac.uk/~sann1276/python/handbook/</a><o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>ohh and forgot about this =
one <a
href=3D"http://www.ibiblio.org/obp/thinkCSpy/">http://www.ibiblio.org/ob=
p/thinkCSpy/</a> ,
"How to Think Like a Computer =
Scientist"<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Now I might be a slow =
learner but I
have never even heard of this
'shutil.rmtree("d:\\tempint\"user"' (by the way I think =
need an
end brace on that), but depending on how brave you are I would =
recommend
getting down with the basics before you play around with something you =
could
accidentally mess up.<o:p></o:p></span></font></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> <o:p></o:p></span></f=
ont></p>
</div>
<div>
<p class=3DMsoNormal style=3D'margin-left:36.0pt'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Ole<o:p></o:p></span></font=
></p>
</div>
</div>
</div>
</body>
</html>
------_=_NextPart_001_01C32B85.5FC13C50--