#๐Ÿ”’ Menu problem

33 messages ยท Page 1 of 1 (latest)

fierce rockBOT
#

@real topaz

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sweet wharf
#

@real topaz how am i supposed to help here? your message got deleted

#

that's why no one's here

real topaz
#

Thank you

sweet wharf
#

Stop hijacking other channels

real topaz
#

i got a script for automating sending complaint forms

#

in instagram

#

i coded it withg slenium

#

it works there is a no problem

#

i coded a different one for different form too

#

everything is okay until here

#

both of them are works

#

i wanted to code a menu

#

it will ask for which complaint form he wants

#

he will select it

#

the menu will take the inputs

#

and it will start the complaint file

#

and it will use it with the inputs

#

how i can do it

#

Basically i just want to share variables between files

#

if you come to dm i can send you all of the code

sweet wharf
#

why not share the code here?

#

!paste

fierce rockBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

old ledge
#

you should make each of the tools define a function that takes arguments rather than just rely on some variables, then, in the menu thing, you'd have the input forms whatever to get the values for that, and based on the selected website call the function and pass the values
"sharing variables between files" is rarely what you actually need

real topaz
#

can you give a example to me

old ledge
#

tool1.py

def do_thing(x, y, z):
  ... # something using x, y, z
def main():
  x = input()
  y = input()
  z = input()
  do_thing(x, y, z)
if __name__ == "__main__":
  main() # can still be used standalone

tool2.py

def do_thing(x, y, z):
  ... # something else using x, y, z
def main():
  x = input()
  y = input()
  z = input()
  do_thing(x, y, z)
if __name__ == "__main__":
  main() # can still be used standalone

menu.py

import tool1
import tool2

def main():
  website = input() # some form to choose the website
  if website == "...":
    # whatever inputs stuff, maybe select some tab in UI
    # if the inputs to both tools are the same, you could put that out of the conditionals, obviously
    x = input()
    y = input()
    z = input()
    tool1.do_thing(x, y, z)
  elif website == "...":
    # some other part of the UI
    x = input()
    y = input()
    z = input()
    tool2.do_thing(x, y, z)
  else:
    raise ValueError("...")

if __name__ == "__main__":
  main()

you dont need anything particularly sophisticated until the simple solutions really dont work nicely

sweet wharf
#

That was quite generous of you

#

OP you should be thankful ๐Ÿ˜›

real topaz
#

thank you bro

fierce rockBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.