You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2019/04/02 08:47:03 UTC
[jira] [Commented] (AIRFLOW-4034) Make string formatting explicit
by removing locals()
[ https://issues.apache.org/jira/browse/AIRFLOW-4034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16807542#comment-16807542 ]
ASF subversion and git services commented on AIRFLOW-4034:
----------------------------------------------------------
Commit 4a2c9c55500fd31c2a71f4c7a1c984aac1dcec3e in airflow's branch refs/heads/master from BasPH
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=4a2c9c5 ]
[AIRFLOW-4034] Remove unnecessary string formatting with **locals() (#4861)
**locals() is used a lot for string formatting. This is considered
bad programming practice.
> Make string formatting explicit by removing locals()
> ----------------------------------------------------
>
> Key: AIRFLOW-4034
> URL: https://issues.apache.org/jira/browse/AIRFLOW-4034
> Project: Apache Airflow
> Issue Type: Improvement
> Reporter: Bas Harenslak
> Priority: Major
>
> Best practice for Python is generally to write explicit and readable code. With this mindset, it's preferable to string format like this:
> {code:java}
> mystring = "{var1} {var2}".format(var1=myobject.something, var2=somethingelse){code}
> Instead of:
> {code:java}
> mystring = "{var1} {var2}".format(**locals()){code}
> Because it makes string formatting explicit and is readable to the reader of the code what variables are used in the string format.
> So, I suggest to remove all **locals() string formatting.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)