[jira-python] Accessing a property including spaces

Hi,

I can access a property that has a space using the raw dictionary as follows :

jira.project('prj1').raw["roles"]['Product Manager']

u'https://xxxx..com/rest/api/2/project/10500/role/10201'

However how can I do it without using this dictionary like I do for other roles ?

jira.project('prj1').roles.Administrators

Out[84]: u'https://xxxx.com/rest/api/2/project/10500/role/10002'

1 answer

First of all, there’s no reason to avoid using the raw dictionary. It’s part of the jira-python interface, it’s well-defined, and as you see, it works when names have spaces.

It turns out you are not asking a jira-python question. You’re just asking a python question: How do I access an object’s attribute using the dot notation when the attribute name has spaces in it? And the answer is that you can’t do it. You have to do something like use the “getattr” function, like so:

getattr(jira.project('prj1').roles, 'Product Manager')

There’s other ways in python to do it, but like I said, it’s really a python question.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you