#๐ How to make code smaller and more efficient to read? 2531 lines of mess.
143 messages ยท Page 1 of 1 (latest)
@hollow glacier
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.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Theres code to review
Have you used "for in range()" or "def ..."
I don't have much to offer as I have this problem myself...
ahahaha dw man my code is 'Ahh I just about understand this..'
distribute your code among several files
make it modular
whatever that word means
put stuff into functions
how do i call the script when its exe..
word of advice don't do that
it works as is tho and it sorta feels more official ykwim?
-_-
just me?
it does bro its got animations and stuff
they wernt? actually what was the purpose for python, just algorithms?
if you really need to get an executable
which sometimes, I do too,
either
-
make a batch file to execute the command
python filename.py -
translate code hand to hand into C++ ( I do this when I need executables, fast ones especially)
if you don't want much hassle
just put it into a batch file
a batch file is a file that ends in .bat
i use pyinstaller lol and like the batch file, is it customisable?
ik what it is dw
you want to send this code to someone?
not necessarily they would need the programs it launches tbh
theres an assets folder I can send em but they would need to have everything here
its an idea thats come to mind recently though
thats hurtful. It launches apps bro
and give it any icon you want
yeah I could do that..
yeh ik you can do that with nearly anything
so you can run it with a click
but like code.. how to shorten it?
I was thinking parameters an just using loads of them but.. its confusing
wait a sec my head is spinning
Its in a class so..
get some cookies bro always helps me lol
would you mind waiting about 30 seconds, my head is spinning wildly
do not look at the code then.
okay I'm back
sorry for the delay
Let's get back to the code
I'll share an example of my project
your name is interesting.. a transitional metal compound?
my favorite carcinogen
anyways
I don't have much code for now
I am better at biology science personally..
but here's a project that has been divided into 4 files
it's a simple version control software
what you can learn from this is
- I have broken individual commands, that my program can execute
into individual files
would you import [python file name].py?
and then in each of the files, I have implemented the code for that particular command
you don't need .py
after the file name
just
import file
and howcome? wouldnt it try to import a module?
if you were trying to get a py file from a different directory would you have to include the path?
yes
how? import C:\ and so on?
this is a webpage containing the names of python modules
if you don't name your files after the module names listed here
they won't be imported
I'm not so sure about this, but I think you need to add it to PATH?
i.. dont get it tbh but very good information I might try figure out and understand when I get back from picking someone up, Thank you very much have a good day..
plz dm me it, might not be back
mf?
variable
no lol im british were always frustrated and angry
like passing in arguments to the file?
well I think you could use sys.argv
data from the previous file
import [variable name]?
# a.py
a = 12
b = 13
# b.py
import a
a = 14
print(a) # prints 14
print(a.a) # prints 12
you could do that
but that would import only one variable
that is sick.. would it import a variable within a class?
a class variable?
I suppose so?
I never use OOP so I need to try
honestly I wanna learn java or c+
its scary moving lang tho..
โC makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.โ
it's actually not that scary
in java the language works on most platforms tho..
it's just that sometimes the newer syntax can be a bit confusing
that doesn't mean it's good
no it aint lol hard af
although a lot of people would disagree with my statement
they use classes right at the start and its like whaa
especially die hard java fans
a lot of boilerplate yeah
yeah man thanks im gonna be late for her but oh well, have a good day
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.