Perl is worse! (was: Python is Wierd!)

William Tanksley wtanksle at dolphin.openprojects.net
Fri Jul 28 14:45:50 EDT 2000


On Fri, 28 Jul 2000 15:40:36 GMT, Steve Lamb wrote:
>What about a way to define a variable that you want to be mutable.

That simply can't be done, because in Python variables are only handles to
data.

Fortunately, what you want IS possible.  Simply define a class whose
__init__ function takes a single argument, converts it to a string, and
stores it.  Then define all of the operators the way you expect them to
behave.

a = Transformable(5)
print 5 + a
print a + "1foo"
b = Transformable("6")

>in programming, like rollover of integers in C, but I digress).  Why not,
>then, allow the programmer to say, "Yes, convert /this/ variable as needed
>based on context"?  A JUST_DO_IT!!!! flag, if you will?

Again, there's no way to mark a variable, but it's not hard to create a
datatype which is thus polluted.  It IS hard to come up with meaningful
operations, you'll find; Perl is actually quite impressive in how it built
its operations.

>      Steve C. Lamb

-- 
-William "Billy" Tanksley



More information about the Python-list mailing list