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

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

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