Newbie Tip: Classes and variable passing vs instances from ENGSOL
Richard Jones
richard at bizarsoftware.com.au
Thu Aug 2 00:32:32 EDT 2001
On Thursday 02 August 2001 14:12, engsol at teleport.com wrote:
> def __init__(self_1, input):
> print "from the \"__init__ thing\" : " + input
Just a brief tip: the above can exploit python's ability to use two quote
characters to delimit strings:
def __init__(self_1, input):
print 'from the "__init__ thing" : ' + input
also, since there's plenty of whitespace involved, you might as well use this
slightly faster form of the above print statement that doesn't involve a
string concatenation:
def __init__(self_1, input):
print 'from the "__init__ thing" : ', input
[note that I trimmed a space from the end of the first string to compensate
for the additional space incurred using the ','.
Richard
More information about the Python-list
mailing list