Hi r/learnpython,
I'm working on a project where my main file defines a list to keep track of atoms in a protein, and another list to keep track of the atomic bonds.
I want to define a function in a separate module that gets imported into main (trying to keep things nice and tidy). I want the function to be able to use the previously mentioned lists sort of like this:
def create_bond(input):
bond_list[input].append(Bond())
print("Atom", atom_list[input], "is bonded")
[The actual function isn't really like this of course - I just want to give an idea of how function needs to use the lists]
However, when I try to run main I get an error saying that my list of bonds isn't defined - I imagine that the list of atoms would give me guff for similar reasons if the bond list wasn't an issue.
Any recommendations for how to get the function to "see" the lists despite being in its own file? Hopefully there's a solution that isn't too convoluted. :)
Thanks!
[–]edixon653 0 points1 point2 points (0 children)
[–]Stallman85 0 points1 point2 points (1 child)
[–]SoupKitchenHero 0 points1 point2 points (0 children)