Changes between Initial Version and Version 1 of Ticket #30880


Ignore:
Timestamp:
Oct 14, 2019, 2:08:34 PM (5 years ago)
Author:
ankit1219
Comment:

I can send a PR to optimize the code.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30880 – Description

    initial v1  
    11The **_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   
     3def _tx_resource_for_name(name):
    54    if name == 'core':
    65        return "django.core"
    76    else:
    8         return "django.contrib-%s" % name''
     7        return "django.contrib-%s" % name
    98
    109You can use Python ternary operator to  reduce code size and increase readability of the code.
    1110
    1211
    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''
     12def _tx_resource_for_name(name):
     13       return "django.core"   if name == 'core' else "django.contrib-%s" % name
    1614
    1715It allows us to replace simple if statements with a single line expression. Increases code readability by reducing number of lines of code.
Back to Top