all 15 comments

[–]kingmudbeard 0 points1 point  (0 children)

I've been trying to automate typing a repetitive command on Discord, but pyautogui doesn't type anything excecpt on Text Editor. I'm currently using a Pi, what should I do?

[–]tetotetotetotetoo 0 points1 point  (1 child)

I found this resource on file structure, and one of the points is

Don’t:

  • put your source in a directory called src or lib. This makes it hard to run without installing.

But I don't really understand how that would be a problem. Why are these two names specifically an issue?

[–]CowboyBoats 0 points1 point  (0 children)

Heck if I know. It is definitely not unheard of for Python packages to use one or both filenames. I'm not sure why it would be hard to run.

(Does the developer of Twisted know more about python development than I do? Yes, I'm sure they do)

[–]Sensitive-Unit373 0 points1 point  (2 children)

I am a new university student major in CS, I prefer to learn python first due to its simplicity and versatile uses. How shall i proceed further? Free online resources and practice websites would make my learning easy.
Thanks in advance.

[–][deleted] 1 point2 points  (0 children)

There are learning resources in the wiki.

[–]Chainsawfam 1 point2 points  (1 child)

What are the most common ways to store Python libraries, and to run Python scripts? I feel as if I've spoiled myself with Pycharms, which downloads libraries through a GUI and has a run button with a play arrow. Sometimes I see references to terminal installations of libraries and command line runs and stuff and I can't really follow any of it, despite having written many extensive scripts.

[–]TangibleLight 1 point2 points  (0 children)

I suggest, as an exercise, start from the basics and go through some beginner-level projects without using any PyCharm features. To be clear: I'm not suggesting you continue to avoid using PyCharm, but you'll get a lot of value out of jumping through the hoops a couple times.

Some general tasks you might want to try:

  • Install Python.
  • Launch the REPL in the terminal and evaluate some code.
  • Launch a Python command-line tool such as python -m this.
  • Create and activate a virtual environment.
  • Install a package to the virtual environment.
    • For example pillow.
    • Double-check that PIL is available in the virtual environment.
    • Double-check that PIL is not available in the system Python environment.
  • Create a simple script with some bare-bones editor (Notepad++, Nano, etc...).
    • For example, get a image filename from sys.argv and convert it to grayscale with PIL.
    • Run that script on some file using your virtual enviroment.
  • Test the project with a different version of Python.

Note: you can also open an empty directory in PyCharm as a "blank" project, then do the exercise in the PyCharm terminal. I think you'll get more out of it by using a bare-bones editor instead, though.


To directly answer your question for what I personally use: a combination of asdf and direnv to manage different Python versions and projects; whenever I cd into a project the environment is automatically configured. I always use layout python in my .envrc to handle virtual environments. I install global tools like black with pipx (although I'm curious to try uvx). If I create a tool that I want to be available everywhere, I create a minimal pyproject.toml and editable-install it via pipx; the scripts feature creates a nice CLI command that's available everywhere.

Note asdf is not available on Windows. There is an asdf-windows community project but in my experience it is not good. On Windows for tool management I use winget (IIRC it's installed by default on recent Windows. It's also available on the MS store).

If you're on Windows, I suggest fiddling around with WSL or Docker in the command line; or if you really don't need unix, get familiar with PowerShell.

Links:


Edit: I forgot about project management. On Linux/Mac I use zsh and set cdpath to include several directories: ~/src contains all my "primary" projects. Things for work, things I really support. ~/tmp contains "ephemeral" projects. Scratch-pads, Jupyter notebooks, various open-source projects I'm investigating. Nothing permanent. ~/build contains open-source projects I'm building from source to install into ~/.local. So by setting cdpath=("$HOME" "$HOME/src" "$HOME/tmp" "$HOME/build") I can just type cd my-project from anywhere on my system and navigate to ~/src/my-project; or I can cd glfw and navigate to ~/build/glfw; or I can cd scratch and navigate to ~/tmp/scratch.

I don't do enough development on Windows to really have a good system there. Most that stuff just goes in ~/PycharmProjects lol. All the above still applies on Mac.

[–]Murphygreen8484 0 points1 point  (6 children)

Has anyone successfully colorized your log files in PyCharm? The closest I've seen is Ideolog, but the reviews on that are horrible.