How hard can this be? It worked
Grant Edwards
grante at visi.com
Mon May 21 16:30:34 EDT 2001
In article <9ebqtg$o5b$1 at newsg1.svr.pol.co.uk>, Patrick Kirk wrote:
>Thanks all. Declaring the variable and adding white space fixed it.
Just to avoid confusion in the future, what you did isn't
generally called "delcaring" the variable x. You bound the
name x to a particular object (an integer object with the value
of 4).
"Declaring a variable" usually has a slightly different meaning
-- it usually means that you're telling the system that there
exists or will exist somewhere a variable with a particular
name and a particular type. It may not allocate space for the
variable (actually create the object) -- it may just reserves a
spot of a particular type in a particular namespace. Python
doesn't really have "variables" the way some other languages
do.
If that didn't make any sense, don't worry about it, I'm just
being pedantic.
>>>> import math
>>>> x = 4
>>>> if x > 0:
>... print "x is positive"
>...
>x is positive
>>>> if x%2 == 0:
>... print x, "is even"
>... else:
>... print x, "is odd"
>...
>4 is even
>>>>
>
>
--
Grant Edwards grante Yow! NANCY!! Why is
at everything RED?!
visi.com
More information about the Python-list
mailing list