Changes between Initial Version and Version 1 of Ticket #30880
- Timestamp:
- Oct 14, 2019, 2:08:34 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30880 – Description
initial v1 1 1 The **_tx_resource_for_name()** function in **django/scripts/manage_translations.py** uses simple if else statement to return the **Transifex resource name**. 2 3 ''def _tx_resource_for_name(name): 4 """ Return the Transifex resource name """ 2 3 def _tx_resource_for_name(name): 5 4 if name == 'core': 6 5 return "django.core" 7 6 else: 8 return "django.contrib-%s" % name ''7 return "django.contrib-%s" % name 9 8 10 9 You can use Python ternary operator to reduce code size and increase readability of the code. 11 10 12 11 13 ''def _tx_resource_for_name(name): 14 """ Return the Transifex resource name """ 15 return "django.core" if name == 'core' else "django.contrib-%s" % name'' 12 def _tx_resource_for_name(name): 13 return "django.core" if name == 'core' else "django.contrib-%s" % name 16 14 17 15 It allows us to replace simple if statements with a single line expression. Increases code readability by reducing number of lines of code.