
November 11th, 2003, 10:51 AM
|
 |
Only the strong survives!!.
|
|
Join Date: Feb 2003
Location: A World of wonders.
|
|
Quote: Originally posted by netytan
Applying str() to a unicode string you say.. sorry i don't get this, i gave it a try and it worked without a problem 
>>> uni = u'Im a unicode string..really'
>>> str(uni)
'Im a unicode string..really'
>>>
Maybe somthing they fixed in Python 2.3? The problem with using ',' to concatenate strings (yes id still class this as concatenation) is that it throws a whitespace into the works but i havn't heard anything about the preformance here.. to be safe i'd probably guess the same thing applies to this operator..
X: i find it helpful to think of methods with arguments as more like sub functions, i don't know if that helps or not though .. you could write this class better like this (assuming no other methods will need access to the hour, minutes, seconds)
Code:
class Time:
def __init__(self, hours = 0, minutes = 0, seconds = 0):
print '%d:%d:%d' % (hours, minutes, seconds)
time = Time(6, 34, 30)
____________________
class Time:
def __init__(self, hours = 0, minutes = 0, seconds = 0):
print '%(hours)d:%(minutes)d:%d(seconds)' % locals()
time = Time(6, 34, 30)
Mark. |
netytan yes as an experiance c programmer i know that, that way is better and faster.. but i see that you have an extra % there at the end.. that is this for?
|