Perl is worse!
Karl Ulbrich
kulbrich at yahoo.com
Fri Jul 28 19:29:52 EDT 2000
More information about the Python-list mailing list
Fri Jul 28 19:29:52 EDT 2000
- Previous message (by thread): Is the "Be" significant? (Re: The State of Python)
- Next message (by thread): Perl is worse!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> A variable gets its type upon assignment. That is implicit typing. Variables do not have type. Data has types. If a variable later points to an object of a different type, then calculations using this variable have a different type to contend with. If variables became typed upon assignment, the following would fail: a = 1 a = "z" > >Huh? Where in Python did you find your declarations? I'm confused. > > a = None > int(a) > > a is declared as None at assignment. Not declared as. _Refers_ to None. > >Well, because it doesn't really make a lot of sense if you want to convert > >something to an integer when Python can't figure it out. If you're so > >sure of yourself, you can always do: > > > >try: > > a = int(b) > >except ValueError: > > a = 0 > > Right, which is basically what I had to do except I left None as None. > Just seems like a pain in the butt to do after I have allready made sure, > beyond all doubt, that those variables contain numbers in the first place. If they already contained numbers (well, strings of digits), and you were certain, then simply: a = int(b) > A regex could return a string or None, only one of which is convertable to > int. You must litter your code with such checks. If you do this a *lot*, maybe a little code around re to return digits as numbers, and None as 0, would be appropriate in that case? Karl Ulbrich
- Previous message (by thread): Is the "Be" significant? (Re: The State of Python)
- Next message (by thread): Perl is worse!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list