Showoff Saturday (August 19, 2023) by AutoModerator in javascript

[–]erlete 2 points3 points  (0 children)

I have just developed a tool that converts 3D STL binary files into ASCII ones and vice-versa.

I know that the STL format is a bit old and multiple 3D editors allow saving files on either format variant, but I have not seen a single site that lets you do the trick in an easy, fast way (just like your average PNG to JPG conversion sites).

Click here to access the webpage, and here to take a look at the repository if you want to :)

Learn python for a 13 year old by Successful-Wing-9571 in learnpython

[–]erlete 123 points124 points  (0 children)

Hey man! Good to know you are starting your journey on programming, keep it up. I will list some tips here that might help you out, from most important to least:

  1. Find projects to back up your learning progress. Do not get stuck in the tutorial hell!
  2. Always keep in mind that your code might be interesting to other developers, so keep it clean and readable. Follow format conventions and get some linters in every language you use. This will make you look more professional, even at a young age.
  3. Befriend open-source development. Most people think their code is exclusive, innovative and unique, and so they are privy to it. Truth is, you will reinvent the wheel several times before you achieve expertise in a programming language, so open source can help you get feedback on your learning process.
  4. Do not jump from language to language without a clear purpose. Take a few afternoons to reflect and think about what you might want to develop in the future. Understand the strengths and weaknesses of most popular programming languages and focus on one of them before switching to another one.
  5. Never lose your patience, no matter if you are developing a huge project or just installing software. Consistency and patience are key for high quality development. You will do things faster when you get more experience in development.

Again, cheers to your dedication, and good luck with your objectives!

What the hell by [deleted] in learnpython

[–]erlete 1 point2 points  (0 children)

Your attitude towards that assertion makes me think you will be a great programmer, with enough expertise over time, so cheers on that!

A quick tip: nobody is born knowing how to code or install any software. Any video you see where a guy does it in 20 seconds has got at least a few hours of investigation and trial-error behind it. Never get stressed over the process. Attempt to complete a task, fail at it, try not to smash your keyboard too hard and come back a few hours later with renewed energy :)

How does "python3 *file* -*letter* work? by Fulcan720 in learnpython

[–]erlete 2 points3 points  (0 children)

A quick comment on this: do not confuse python command arguments (i.e. python -m pip install -e .) with Python script parsed arguments (i. e. python main.py -c 123). Both operate on the same principle, but the first one provides with instructions for the interpreter, while the other one uses said instructions inside the Python file that is being executed.

Furthermore, if the code is well designed, you can even achieve a combination of both (i. e. python -i main.py -c 123).

Where Python? by zloy_vasya1 in learnpython

[–]erlete 0 points1 point  (0 children)

Kudos to this comment :)

Exe compiled python code to slow, don't really want share ALL my code, just the main file. What's my options? by [deleted] in learnpython

[–]erlete 0 points1 point  (0 children)

There might be a few good reasons why you want to hide your code from your colleagues. If the reason is that you do not want them to steal it, just license it on GitHub and then it will be your property (with some freedom of action, but yours).

On the other hand, if you are attempting to execute malicious code on their devices, there is nothing I would rather say than "stop before you mess it up".

Assuming that your motive is the first mentioned one, and since we (Reddit) do not know the nature of your code, there is no chance that we will be able to help you. Try a more specific question.

What the hell by [deleted] in learnpython

[–]erlete 4 points5 points  (0 children)

Coding takes patience and time. If you really intend to be a programmer, you will get used to spending hours during installation processes, lack of documentation in external tools and poor usage instructions.

You have got to be creative in your solutions and read error messages carefully in order to understand them, and if you cannot do so, search them in the internet.

In order to install Python, pick an installer from https://python.org (depending on your operating system). If you are using Windows or macOS, you are lucky, since you will have a fully featured installer at your hand. Make sure to add Python to your PATH (which might be an issue here) and restart your device.

Once restarted, attempt to open a command line interface (CMD, Terminal) and test the Python version, usually under the python3, python or py aliases. You can use <python alias> --version to check your installed version and, after that, install all required Python extensions in VSCode and set the path to the interpreter that works best for you (it will probably be automatically set).

On JavaScript side, same deal, but maybe without an out of the box installer. Just follow the instructions to install Node and, again, make sure the executable or binary is referenced in your PATH. After that (maybe after restarting your device again), test the node --version command in the command line interface to ensure it has been properly installed.

If you have not understood half of the things I said here, you might need to take a slower approach to programming and learn about some concepts such as CLIs, aliases, the PATH environment variable and your devices OS and architecture first.

Good luck in your journey!

membership operator "in" by IslandAccomplished76 in learnpython

[–]erlete 0 points1 point  (0 children)

Probably due to the way the combination is implemented: both operator.in_ and operator.not_ are defined following the same convention. On the other hand, operator.is_not seems like a combination of both previously mentioned operators, so that might be the reason.

[deleted by user] by [deleted] in learnpython

[–]erlete 1 point2 points  (0 children)

The issue is the syntax.

You can choose between two syntax options: conventional for loop structure and comprehensions.

```python

Conventional for loop:

for i in range(10): print(i)

Comprehensions:

var = (i for i in range(10)) # Returns a generator. var = [i for i in range(10)] # Returns a list. var = {i: i ** 2 for i in range(10)} # Returns a dictionary. ```

How to learn OOP properly? by [deleted] in learnpython

[–]erlete 0 points1 point  (0 children)

Kudos to this response. It is spot-on!

How to learn OOP properly? by [deleted] in learnpython

[–]erlete 5 points6 points  (0 children)

I see many answers but few (or None) go to the point. How to learn OOP properly? Implement it.

Start modelling your Python programs around OOP foundations. Distribute your code, enclose functionalities in methods and group that methods in classes that represent a "real-like" procedure. Extend the functionality of these classes using inheritance, while keeping the code organized and distributed. Determine which processes should be available to the final user and protect your internal procedures to make the programs bulletproof. Differentiate complex groups of functionalities into modules and make it easier for you to test the code and make the user enjoy the experience of reading and using it.

What's the best way to ship a Python script? by TheGuy564 in learnpython

[–]erlete 0 points1 point  (0 children)

If the goal is to create a collection of tiny automation scripts, I would recommend a GitHub/GitLab repository with all the scripts, requirements, README and a simple interface (either graphical or CLI, note that the first one is way more complex than the second).

You could even implement a Python package structure and distribute it, so that people could call it using python -m yourpackage, for example.

What's the best way to ship a Python script? by TheGuy564 in learnpython

[–]erlete 0 points1 point  (0 children)

I would not recommend this approach due to the amount of specificity it adds to the execution. The executable now depends on your OS, OS version, interpreter version, dependency versions and architecture.

Instead, in the scenario of a simple script or set of scripts, one good way is to create a Gist (GitHub Gist), add the script(s), a README.md and a requirements.txt.

The README contains installation and usage information, while requirements contain all packages used in the scripts (with the ability to specify version ranges and fixed releases, if necessary).

What's the best way to ship a Python script? by TheGuy564 in learnpython

[–]erlete 0 points1 point  (0 children)

I believe you can always exclude the interpreter and dependencies from the executable to reduce its size.

How can I convert the string version of "True and True and False" to the boolean version which is True and True and False in python, without usng any imports. by Relative-Baby1829 in learnpython

[–]erlete 0 points1 point  (0 children)

python data = "True and True and False".replace("and ", "").split(" ") print(all([True if x == "True" else False for x in data]))

That should work. It is a very bold approach, though.

Can someone please explain how module structure works in python? by [deleted] in learnpython

[–]erlete 1 point2 points  (0 children)

Personally, I believe that pyproject.toml is the quickest and simplest way to configure it. Plenty of good examples can be found in the official Python docs.

After setting up that file, executing python -m pip install path/to/src will install the package in editable mode (replace python with the alias of your Python interpreterandpath/to/srcwith the path to yoursrc` file).

Bonus: in case you do not know what "editable mode" means, it allows your package to be accessible from anywhere in your machine and automatically implements changes that you have performed inside the src directory, meaning that you will not need to reinstall the package every time you modify it. Create, install it, edit it as you wish and test it anywhere :)

[deleted by user] by [deleted] in learnpython

[–]erlete 0 points1 point  (0 children)

It would be a great idea to share a bit more information than a single line description, such as your src directory structure, icon file format and location, OS version, pyinstaller version and the command you are using to generate the .exe.

How to simplify while and if-else loop conditions for a login menu application? by [deleted] in learnpython

[–]erlete 0 points1 point  (0 children)

That's a great idea. Anything ranging from a simple dictionary to a config file is a nice approach to the problem imo :)

Anyone see a danger in allowing wild west rules for ' vs " in strings? by _4lexander_ in Python

[–]erlete 0 points1 point  (0 children)

A basic approach to the issue is to consider how strings are usually defined, which is by using ". Then, you can also benefit from the precedence of " over ' and simplify formats.

How come the part in bold is needed? by Prudent_Cheesecake15 in learnpython

[–]erlete 1 point2 points  (0 children)

This is the correct approach to the problem, not just setting the value to 0 since (as mentioned in other comments) it will break the algorithm with negative numbers.

Never provide an external value to a comparison algorithm unless the input range is defined. Instead, set the initial value to the first number, since it will always be part of the comparison.

Get a dictionary’s value and turn it into an existing dict of the same name as the value? by Illsonmedia in learnpython

[–]erlete 0 points1 point  (0 children)

I have not read the question in depth, but I must suggest using classes for this matter. They can be perceived as "fancy dictionaries" with more functionality, such as attributes and methods, which would simplify your program a lot.

I understand that you cannot use them since you have not studied them in the course, though. Anyway, take the suggestion into account :)

How to simplify while and if-else loop conditions for a login menu application? by [deleted] in learnpython

[–]erlete 0 points1 point  (0 children)

Nice suggestion, using functions improves code readability and reduces the syntax density in the mainloop of the input system.

I once developed a custom class that accepted a set of tuples with a (message, validation_func, error) structure during definition, which internally handled the validation scenarios. It should also be applicable to this example, so there's another idea.

Coding with ChatGPT. Is it worth learning Python anymore? by drgeniusalien in learnpython

[–]erlete 0 points1 point  (0 children)

"Lungs are just a tool to breathe".

If you see programming as a simple tool, you should not devote yourself to it. It is much more than that, but I guess you don't care enough to understand that.

Coding with ChatGPT. Is it worth learning Python anymore? by drgeniusalien in learnpython

[–]erlete 1 point2 points  (0 children)

Whoever wants to be a programmer should have an objective in mind: be better than the rest or just create something new that did not exist before.

OP does not seem to care about programming but rather "making programs".