使用python词"type"是否安全?在我的代码中? [英] Is it safe to use the python word "type" in my code?

查看:113
本文介绍了使用python词"type"是否安全?在我的代码中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在自己的代码中使用类型"一词,还是保留?我的函数标头:

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,
    ):

谢谢

推荐答案

使用type作为函数的关键字参数将屏蔽在该函数的范围内.因此,虽然这样做不会产生SyntaxError,但它不被认为是一种好习惯,因此我会避免这样做.

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.

这篇关于使用python词"type"是否安全?在我的代码中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆