Python--Initializing variables using a variable in the current parameter -


i find myself assigning variable none in variable assignment, , wondering if there more efficient , less ugly way.

def stringlength(string = "hello", slength = none):     if slength == none:         slength = len(string) 

here example. want assign slength length of string. how can in more efficient way?

i doing because using permutation code, recall using same method, please don't comment saying write variable later on :d

the possible improvement have replace slength == none slength none. latter more accurate, , perhaps more efficient.


Comments

Popular posts from this blog

c++ - list<myClass<int> * > sort -

SoapUI on windows 10 - high DPI/4K scaling issue -

java - why am i getting a "cannot resolve method" error on getApplication? -