Is it safe to use the python word "type" in my code?

Niklas R. picture Niklas R. · May 13, 2012 · Viewed 24.1k times · Source

Can I use the word "type" in my own code or is it reserved? My function header:

def get(
    self,
    region='Delhi',
    city='Delhi',
    category='Apartments',
    type='For sale',
limit = 60,
    PAGESIZE=5,
    year=2012,
    month=1,
    day=1,
    next_page=None,
threetapspage=0,
    ):

Thank you

Answer

modocache picture modocache · May 13, 2012

Using type as a keyword argument to a function will mask the built-in function "type" within the scope of the function. So while doing so does not raise a SyntaxError, it is not considered good practice, and I would avoid doing so.