I'm building a script that uses selenium to log into and upload a file(s) to imgur. Currently it's a main() function that calls a signin(), then upload() function in sequence. Should I be returning something at the end of the signin() and upload() functions?
https://github.com/RainyCityCoder/imgurapp
#๐ Selenium script & function returns
8 messages ยท Page 1 of 1 (latest)
@real bough
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.
Closes after a period of inactivity, or when you send !close.
I mean if you have to go the way of using selenium to upload a photo it's a good sign they don't want you doing that and that you should find an alternative
looks like you could use https://www.imghippo.com/ to the same effect without running a whole browser to do it a whole running browser
so assuming you switch to using something that wants you to use it (so we don't break rule 5): whether those functions should return something or not depends entirely on how you're designing your code. Those functions can fail, the question is, how are you expecting to get information about those failures? You can return a value that says whether login succeeded or failed, or you can raise an exception. Or maybe once you're logged on or have uploaded something, maybe you want some information about the action that you just did, maybe the uploaded image's URL or something, so you can return that. There's no right or wrong here, all depends on how you're designing your code
if you mean purely in the stylistic sense of "should I have a return statement at the end of the function", no, you don't need a return statement at the end of a function, python functions return None by default
This help channel has been closed. 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.