title: How to modify existing variable and also import new variables using import *
body: <p>I have a file <code>test.py</code> with</p>
  <pre><code>list_sample = [1,2,4]
  </code></pre>
  <p>Now, I want to append to the list from another file</p>
  <p>eg: test2.py</p>
  <pre><code>list_sample =+ [10,11]
  
  # also I have many other things in this script
  a=10
  c=10+a
  </code></pre>
  <p>and modify <code>test.py</code> as</p>
  <pre><code>list_sample = [1,2,4]
  
  # I want to import all the variables from test2.py but also append the list_sample
  # I cant do that directly in this file. Because this is like blueprint
  from .test2 import *
  
  print(a+30)
  print(list_sample)
  
  </code></pre>
  <p>But this gives an error list_sample not defined</p>
  <p>The only way I can do this  change test2.py to</p>
  <pre><code>list_sample = [1,2,4,10,11]
  
  # also I have many other things in this script
  a=10
  c=10+a
  </code></pre>
  <p>One more option i have is change test2.py to</p>
  <pre><code>from .test import list_sample
  
  list_sample += [10,11]
  
  # also I have many other things in this script
  a=10
  c=10+a
  </code></pre>
  <p>but this will lead to circular imports</p>
  <p><strong>Conclusion</strong></p>
  <p>This is not possible so then i decided to just go like this. Add some segregation in the <code>test2.py</code></p>
  <pre><code># variables from master file
  # copy them from the test.py
  list_sample = [1,2,3]
  
  # changes to variables from master file
  list_sample =+ [10,11]
  
  # new variables
  a=10
  c=10+a
  </code></pre>
  <p><strong>Reason I want this</strong></p>
  <p>In Django i have <code>settings.py</code> and in that i have <code>INSTALLED_APPS</code> list</p>
  <p>I use <code>django_extensions</code> while working on my pc, but when i share this code to others i dont want the other to depend on <code>django_extensions</code></p>
  <p>Generally in <code>settings.py</code> we can manipulate by using <code>DEGUB=True</code> i.e</p>
  <pre><code>if DEBUG=True:
      INSTALLED_APPS =+ INSTALLED_APPS+[&quot;django_extensions&quot;]
  </code></pre>
  <p>but this is w.r.t to <code>DEBUG</code></p>
  <p>but what i am looking is w.r.t to different people all using <code>DEBUG=TRUE</code></p>
  <p>so for that i have seen someone doing like below</p>
  <p><code>setting.py</code></p>
  <pre><code>INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'ordered_model',
  
      # new apps created
      'users',
      'apps',
  ]
  
  
  if os.path.exists(os.path.join(BASE_DIR, &quot;custom_settings.py&quot;)):
      from .custom_settings.py import *
  </code></pre>
  <p>and in <code>custom_settings.py</code> add <code>INSTALLED_APPS</code> full with <code>django_extensions</code></p>
  <pre><code>INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'ordered_model',
  
      # new apps created
      'users',
      'apps',
      'django_extensions'
  ]
  </code></pre>
  <p>I was planning to make this more generic type, so any project i am working i just copy paste <code>custom_settings.py</code> file into the folder with <code>settings.py</code> and do my work and again remove <code>custom_settings.py</code> or (add in gitignore), so the other person who works with this code, dont have to bother about my settings.</p>
  <p>So now i will adjust like this in <code>custom_settings.py</code></p>
  <pre><code># THIS PART MANUALLY COPY PASTE FROM settings.py
  INSTALLED_APPS = [
     ........  COPY PASTE FROM settings.py
  ]
  
  # my additional apps i want to use
  INSTALLED_APPS =+ [&quot;django_extension&quot;]
  </code></pre>