Optional arguments in a function I'm writing a python script to find restrictionplaces. I was wondering if there is a better way to write the following:

def restrictionplace(string, minLength = '', maxLength = ''):
    if minLength == '': minLength = 4
    if maxLength == '': maxLength = 12

    #rest of script


if there is no min or maxlength given, the script should use 4 or 12.
Python lets you set default values for parameters in the method signature in the way you have done above with minLength=''. This means that if the caller of the function doesn't provide a value for that parameter the default of an empty string will be used instead. Essentially doing the job of your if minLength == '': minLength = 4 line. Here is what you might write instead:

def restriction_place(string, min_length=4, max_length=12):
    pass


I also took the liberty of using snake_case as that's the convention in Python for variable and function names (in most cases).

There is a caveat to default values when using mutables, however. see: http://docs.python-guide.org/en/latest/writing/gotchas/