Anaconda Spyder-类属性自动完成

发布于 2025-02-06 23:47:14 字数 2059 浏览 2 评论 0原文

我有几个班级定义。 这两个类都将JSON文件作为输入,并将数据提取到类实例中,然后将它们放入字典中。

因此,我所有的就业剥离实例都存储在一个名为SP的字典中,员工将电子邮件作为密钥,将类实例作为值。

我所有的风险福特实例都存储在称为“风险”的字典中,风险_ID作为键,类实例作为值。

class EmployeeProfile:
    def __init__(self, profile):
        self.displayname = profile.get('displayName')
        self.email = profile.get('email')
        self.firstname = profile.get('firstName')
        self.surname = profile.get('surname')
        self.fullname = profile.get('fullName')
        self.costcode = profile.get('work').get('custom')\
            .get('Cost Category_t9HHc')
        self.title = profile.get('work').get('title')
        self.department = profile.get('work').get('department')
        self.city = profile.get('work').get('site')
        self.id = profile.get('work').get('employeeIdInCompany')
        self.manageremail = ''
        self.costline = 'N/A'
        self.groups = {}
        self.attest = {}
class RiskProfile:
    def __init__(self, risk_profile):
        self.ID = risk_profile.get('ID')
        self.key = risk_profile.get('Key')
        self.name = risk_profile.get('Name')
        self.description = risk_profile.get('Description', '')
        self.owner = risk_profile.get("Owner_DisplayName")
        self.assignedto = risk_profile.get("AssignedTo_DisplayName")
        self.email = None
        self.costline = ''
        self.notes = ''
        self.assessmentlevel = int(risk_profile.get("AssessmentLevel"))
        self.rating = ''
        self.workflow = risk_profile.get('WorkflowState')

现在,当我做类似的事情时:

for profile in SP:
    print(SP[profile].{here i see the attribute of the class instance})

这样我就可以看到可能要打印或更改等的属性选择...

print(SP[profile].department)

但是,

print(SP[profile].name)

当我为风险较高的实例做同样的事情时,我没有得到属性列表。 如果我手动输入它们,我的代码仍然可以工作,但是有人知道为什么这样做的方式不同样吗?

for profile in RISKS:
    print(RISK[profile].{I never get a list of attributes})

我用Spyder使用Anaconda。

I have a couple of Classes defined.
Both of these classes take a json file as input, and extract the data into a class instance, and places them into a dictionary.

So all of my EmployeeProfile instances are stored in a dictionary called SP, with the employees email as the key, and the class instance as the value.

All of my RiskProfile instances are stored in a dictionary called RISKS, with the risk_ID as the key and the class instance as the value.

class EmployeeProfile:
    def __init__(self, profile):
        self.displayname = profile.get('displayName')
        self.email = profile.get('email')
        self.firstname = profile.get('firstName')
        self.surname = profile.get('surname')
        self.fullname = profile.get('fullName')
        self.costcode = profile.get('work').get('custom')\
            .get('Cost Category_t9HHc')
        self.title = profile.get('work').get('title')
        self.department = profile.get('work').get('department')
        self.city = profile.get('work').get('site')
        self.id = profile.get('work').get('employeeIdInCompany')
        self.manageremail = ''
        self.costline = 'N/A'
        self.groups = {}
        self.attest = {}
class RiskProfile:
    def __init__(self, risk_profile):
        self.ID = risk_profile.get('ID')
        self.key = risk_profile.get('Key')
        self.name = risk_profile.get('Name')
        self.description = risk_profile.get('Description', '')
        self.owner = risk_profile.get("Owner_DisplayName")
        self.assignedto = risk_profile.get("AssignedTo_DisplayName")
        self.email = None
        self.costline = ''
        self.notes = ''
        self.assessmentlevel = int(risk_profile.get("AssessmentLevel"))
        self.rating = ''
        self.workflow = risk_profile.get('WorkflowState')

Now when I do something like:

for profile in SP:
    print(SP[profile].{here i see the attribute of the class instance})

So I can see a selection of the attributes I may want to print or change etc...

print(SP[profile].department)

or

print(SP[profile].name)

However when I do the same for RiskProfile instances I do not get the list of attributes.
If I enter them manually my code still works, but does anyone know why this is not working the same way?

for profile in RISKS:
    print(RISK[profile].{I never get a list of attributes})

I use Anaconda with Spyder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文