Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 visibility/space of variables. Pls help.
I have two modules only.
the first one - is the main programm, which is using functions from the second module.
The second module consists from functions only
Here is the first module
import requests
from bs4 import BeautifulSoup
import sys
spisok = []         
_tmpvar = ""        
import F_Hydac_POST
_name_element = "pi3111"
spisok = F_Hydac_POST.start_parce(_name_element)
print("Here is the Hydac list", spisok)
here is the second module
def fg_list_bot(_name_element, _output_file):
    _url = ""
    # THis line produces an error message
    s = requests.Session()
    _headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"}
    _data = {"tx_hybetterfit_pi2[query]": _name_element}
    r =, data=_data, headers = _headers)
    with open(_output_file, "w") as f: f.write(r.text)
def start_parce(_name_element):
    _output_file = "IDLE_HYDAC.html"
    _tmpvar = fg_list_bot(_name_element, _output_file)
Here is the error message
 ================= RESTART: E:\Python\Learning\ =================
Traceback (most recent call last):
  File "E:\Python\Learning\", line 10, in <module>
    spisok = F_Hydac_POST.start_parce(_name_element)
  File "E:\Python\Learning\Parce_functions\", line 81, in start_parce
    _tmpvar = fg_list_bot(_name_element, _output_file)
  File "E:\Python\Learning\Parce_functions\", line 5, in fg_list_bot
    s = requests.Session()
NameError: name 'requests' is not defined
the "second" module has no way to know what you would eventually import in the "first" module
you need to import requests in the second module

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  modifying variables in local or global space Skaperen 2 316 Aug-14-2019, 07:13 AM
Last Post: Skaperen
  PyMODINIT_FUNC and gcc hidden visibility jock 0 1,083 Feb-01-2018, 03:47 PM
Last Post: jock
  How is space of variables/functions/objects... called? j.crater 4 2,183 Dec-19-2016, 12:24 PM
Last Post: j.crater

Forum Jump:

Users browsing this thread: 1 Guest(s)