On 1/15/11, Alan Gauld <alan.ga...@btinternet.com> wrote: > "Alex Hall" <mehg...@gmail.com> wrote > >> m=int(m) >> just before the if statement. This causes m to turn from a string >> into >> an integer and is what is known as "casting" or "type casting", if I >> have my vocabulary correct. > > Sadly you don't although its a common error. > > This is type conversion. You are actually changing the type of m. > > Type casting is something very different and is not really available > in Python (except by underhand use of the struct module!). In type > casting you tell the intertpreter to treat the bit pattern of one > variable > as if it were a different type but do not actually change the > underlying > bit pattern. Its used a lot in low level languages such as C but is > not > very useful in Python. Thanks. That is very interesting, and I never knew that! > > > Sorry to be pedantic, and if you hadn't mentioned correct > vocabulary I probably wouldn't have bothered correcting it. :-) Don't be sorry; it is always good to get terms right, and now I know the difference between casting and type conversion. Very cool. > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
-- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor