Ask Your Question
0

Getting H703 when i am trying i18n _() on running tox -e pep8

asked 2014-01-30 09:55:29 -0500

Hi all,

I am trying to edit my plugin to add log message using i18n like this msg = _("Created a network %s under a tenant %s") % (network_id, tenant_id)

Functionality wise it is fine , but when i run tox -epep8 against this change i am getting H703 multiple positional placeholders.

Why am I getting this error, how to resolve this, Can somebody please help?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-01-31 02:50:20 -0500

aji-zqfan gravatar image

It means you need to use dictionary-based string formatting ( http://www.diveintopython.net/html_processing/dictionary_based_string_formatting.html (http://www.diveintopython.net/html_pr...) ).

msg = _("Created a network %(net_id)s under a tenant %(tenant_id)s") % {'net_id': network_id, 'tenant_id': tenant_id}

(NOTE this is more than 80 characters in one line, you need to break it down)

edit flag offensive delete link more
0

answered 2014-01-31 06:38:31 -0500

Thanks ZhiQiang Fan, that solved my question.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-01-30 09:55:29 -0500

Seen: 111 times

Last updated: Jan 31 '14