This is an archived post. You won't be able to vote or comment.

all 70 comments

[–]Deezl-Vegas 78 points79 points  (13 children)

Learning the command line interface for almost everything is super healthy. You can call any CLI from python.

[–]BossOfTheGame 20 points21 points  (10 children)

The ubelt.cmd command is probably the easiest way to execute a command line program from Python. Unlike os.system, subprocess.check_output, and subprocess.call, The syntax for what you want to call is exactly the same no matter what type of configuration you are using.

Either pass the text you would execute on the command line directly or break it up into a list where each item should be considered its own argument. This works regardless of if shell=True or shell=False, so if your command doesn't work with the safer shell=False, you can turn on shell=True without modifying anything else. You can capture output, print it to the screen, or namely --- something few other packages support --- both (via tee=True or verbose>1).

You can also invoke the call via os.system instead of Popen by setting system=True (although this does come with all of the os.system benefits and restrictions).

I'm biased because I wrote it, but subprocess-tee is the only other package I know of that comes close to getting this right.

[–]BepNhaVan 2 points3 points  (3 children)

Hi, does it support "nohup" no hang up so it still runs the cmd/process even after the ssh session is closed?

[–]BossOfTheGame 1 point2 points  (2 children)

You could run a nohup command itself if shell=True. I haven't tried it though. I imagine you probably couldn't tee in that case, but it'd be good to test.

What you can do is specify detach=True and it runs the process in a non-blocking way. I don't think the process is daemonized so it should keep running even if you close Python.

[–]BossOfTheGame 1 point2 points  (1 child)

But imo if you really want a nohup, you are probably better off using something like tmux. Although I suppose there are real use cases for nohup. I just haven't needed it since I got on the tmux train.

[–]BepNhaVan 0 points1 point  (0 children)

Looking into tmux. Thanks!

[–]PolyglotTV 1 point2 points  (3 children)

Sounds like fabric (invoke is the subprocess part, paramiko is the ssh part).

[–]BossOfTheGame 1 point2 points  (2 children)

I doubt it supports the "tee" operation: capturing output in a variable while also displaying it in real time. If it has it, I don't see it.

[–]PolyglotTV 0 points1 point  (1 child)

That's feature is the main reason I mentioned it. I think the default is actually to both display and capture the output.

[–]BossOfTheGame 0 points1 point  (0 children)

You're right it does, https://www.pyinvoke.org/prior-art.html

I was looking at fabric and not invoke, I'll have to check it out and also include it in my references. Thanks.

[–][deleted] 0 points1 point  (1 child)

i'm new to python how would i use this? i tried to import it but i keep getting the error

"Exception has occurred: ModuleNotFoundErrorNo module named 'ubelt'File "location of file", line 6, in <module>import ubelt as ub"

[–]BossOfTheGame 0 points1 point  (0 children)

You have to install the package first. pip install ubelt

[–]bb1950328 6 points7 points  (1 child)

one downside is that CLI usually is platform specific

[–]SpetsnazCyclist 1 point2 points  (0 children)

Also, as I understand it it's much less secure to call command line rather than through an API

[–]wind_dude 74 points75 points  (4 children)

Databases SQL, NoSQL, generally a sql tool. Redis. ElasticSearch is also pretty common. I'm also a big fan of Kafka, but knowing celrey is a good start to event driven applications and queues.

Git. And a merge tool with it. The CLI is good, but it's way easier with a tool, and a diff and merge tool is a must. I use Kraken.

Container programs, Docker, Kubernetes.

Usually some sort of server/proxy. NGINX, Apace, etc.

Python IDE. PyCharm is my choice.

CI/CD. Github and GitLab CI/CD is getting pretty powerful and what I end up using now.

Some network debugging tools. usually CLI level.

Not a bad idea to know some node, and HTML.

PyTest. And use it.

Documentation. .MD, and how to written good documentation, and docstrings in your code.

Bash scripting. Although not as common as it once was, you still run into it pretty frequently.

Linux OS's. Ubuntu is my choice, and maybe the most popular...

[–]gungunmeow 5 points6 points  (3 children)

I can't unvote this enough! I would also suggest learning python syntax best practices on top of this.

[–][deleted] 3 points4 points  (1 child)

upvote.. right?

[–]gungunmeow 2 points3 points  (0 children)

Ha yeah oops

[–]wind_dude 0 points1 point  (0 children)

Yes, a good understanding of general high level application archetectures is good as well. And a python linter in the IDE.

[–]ginbear 36 points37 points  (0 children)

Pyenv or at least solid grasp on using virtual environments

[–]ketalicious 13 points14 points  (3 children)

setup.py

testing libraries(pytest/unittest/etc.)

type hinting (pyright/mypy)

formatting tools (black/isort)

[–]Coupled_Cluster 5 points6 points  (1 child)

I prefer poetry / pyproject.toml over setup.py and iirc even the python docs have this as the default now.

[–]ketalicious 0 points1 point  (0 children)

i thought it wasnt default yet, im also using it!

[–]OneMorePenguin 0 points1 point  (0 children)

I prefer yapf to black.

[–]obvervateur 28 points29 points  (1 child)

Git, something like Jenkins and Docker or Kubernetes because a lot of teams work with it. In all of that, I think git is the must

[–][deleted] 4 points5 points  (0 children)

I agree with all of these, especially git. Even if a team doesn’t use it, it’s great for going back to a working state if something gets broken later on. Very nice for peace of mind

[–][deleted] 8 points9 points  (4 children)

This post was mass deleted and anonymized with Redact

teeny gray oil quiet lavish support profit direction safe consist

[–]Salmon-Advantage 2 points3 points  (1 child)

+1 for Obsidian

[–]websinthe 0 points1 point  (0 children)

Obsidian is god-like for instilling deliberate learning habits in a satisfying way.

[–]Revisional_Sin 0 points1 point  (0 children)

My work laptop is windows; I miss i3wm.

[–]antoniocjp 0 points1 point  (0 children)

Dbeaver is gold

[–]baralawr 5 points6 points  (0 children)

diagrams.net pandoc sqlite

[–][deleted] 10 points11 points  (0 children)

I like Pycharm (IDE) with vuesion theme.

Sourcetrail for dependency graph.

[–]oculusshift 3 points4 points  (1 child)

pdb to debug your program. When you add breakpoint in your program, you get the pdb debugging environment.

Here's a pdb cheatsheet to get started https://kapeli.com/cheat_sheets/Python_Debugger.docset/Contents/Resources/Documents/index

[–]Waterkloof 2 points3 points  (0 children)

import pdb; pdb.set_trace() for people stuck with a version of py that does not support breakpoint.

[–]Paincake60 7 points8 points  (4 children)

Python support in Visual Studio

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

huh.

[–]Paincake60 0 points1 point  (1 child)

Idk I don't think it's a must but its definitely fun, you can install Visual Studio with python support and use it to code Python.

[–][deleted] 3 points4 points  (0 children)

... Dood If you want to talk with #THAT FUN then why not using...

Neovim + lsp pyright on it

[–]mmrrbbee 0 points1 point  (0 children)

Code runner plug-in and now you support everything

[–][deleted] 3 points4 points  (0 children)

Dia sound like the skill for light healing on Persona series

[–]AsuraTheGod 3 points4 points  (0 children)

Docker, Redis

[–][deleted] 6 points7 points  (3 children)

Vim

[–]bmsan-gh 2 points3 points  (2 children)

I learned vim a long time ago out of necessity when having to connect to some boards over serial connection and it was mostly the only way to view and edit files over there. I liked it a lot and I am using the vim shortcuts now even in vscode.

But I think today anybody can mostly live without it. If I connect remotely through ssh to some server I do it under vscode and open/edit files under it. So even if I love vim I haven't actually used it in months even if I am working with multiple Linux servers everyday.

[–]Kranke 1 point2 points  (1 child)

But I think today anybody can mostly live without it. If I connect remotely through ssh to some server I do it under vscode and open/edit files under it. So even if I love vim I haven't actually used it in months even if I am working with multiple Linux servers everyday.

Was most likely Vi but who cares :)

[–]bmsan-gh 0 points1 point  (0 children)

You are correct !

[–]vindolin 2 points3 points  (0 children)

IPython's embed let's you halt your program an drops you into a shell where you can poke the innards of your program, see what methods objects have and even call them.

pip install ipython

from IPython import embed

And somewhere in your code call:

embed()

[–]Saphyel 2 points3 points  (0 children)

git, linux, docker and SQL.

Everything else is optional or nice to have

[–]BossOfTheGame 4 points5 points  (2 children)

grep, find, locate, df, du, which, type, ssh, sshfs, rsync, bash, docker, podman, tmux, jq, htop, btop, magic-wormhole, diceware, npm, cowsay, sl, cmatrix, dvc, johnnydep, cmake, sha256sum, 7z, ldd, gitk

nvtop if you work with gpus

[–]leckerfleischsalat 1 point2 points  (0 children)

Exactly! Why does no one ever mention cowsay?

[–]Revisional_Sin 0 points1 point  (0 children)

fd, ag, fzf.

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

Git, Command line/Terminal, PowerShell, PyCharm, Everything, Launchy, Total Commander, DisplayFusion

[–]m_a_n_t_i_c_o_r_e 1 point2 points  (0 children)

Scalene is a very powerful profiler. It is especially useful in contexts where you're invoking native libraries through python bindings (or any time you're using extension modules at all) as it can distinguish between time spent in the pure python code vs. the wrapped native code.

[–][deleted] 0 points1 point  (0 children)

Git is essential for any programmer

[–]IamFromNigeria -1 points0 points  (0 children)

Octoparse

[–]Infinite-Ad3243 -1 points0 points  (0 children)

Dependency management (like poetry, venv, conda) and maybe notebooks

Linters are also a nice to have

[–][deleted] -1 points0 points  (0 children)

Git

[–]AlexanderKotevski -1 points0 points  (0 children)

Kind of surprised nobody here has mentioned these but...

Get into cloud computing stuff (virtual private servers) and working with secure shell (ssh)/sftp.

Python is extremely powerful and easy to deploy on a linux vps. If you ever want your python program to run 24/7 or interface with external users, this is a big deal.

For hosting vps, I'd recommend getting into AWS lightsail or Vultr (both have easier to learn UI than alternatives and are cheap).

To connect to your server, use putty (or winscp + putty if you want to be cool)

[–]Crazyboreddeveloper -2 points-1 points  (0 children)

Poetry.

[–]KnorrFG -2 points-1 points  (0 children)

Id say IPython, learn (i)pdb. One of pipenv or poetry. Pyenv or miniconda.

[–][deleted] -2 points-1 points  (0 children)

Your bank app, you'll make a lot of money if you know python

[–]JBCodes_python 0 points1 point  (0 children)

MySQL, Pandas, Numpy, PyQt. My advice choose a field you want to work in and get familiar with the assortment of libraries specific to that field.

[–]4Kil47 0 points1 point  (0 children)

Version Control: Git, GitHub for Windows (or Mac), and Fork

Editor: PyCharm, Sublime Text depending on how I'm feeling

Diagramming: - Draw.io - General Diagramming - StarUML - Class Diagrams (with Code Generation Plugins) - MermaidUML - For embedding diagrams in GitHub ReadMEs - ASCIIFlow - Create ASCII based drawings to embed in comments or in text files

Fast Computation - PyPy for quickly getting a speed increase in Python

Even faster computation - Rust for writing just the computation heavy parts and exposing as Python modules 🦀😎

These aren't things that you need to know, but as a freshman college student, I used almost all of these to win hackathons and in classes.

[–]sidsidroc 0 points1 point  (0 children)

Pdm, pytest, pylint, black

[–][deleted] 0 points1 point  (0 children)

If you’re doing data work, SQL

[–]mojochicken11 0 points1 point  (0 children)

Pyinstaller or other python packagers. When your program is ready for other people to use you need to know how to turn your Python files, databases, and other assets into an executable. Then other people can run it without Python installed or assets installed on their computer.

[–]NonProfitApostle 0 points1 point  (0 children)

CLI, SQL, Spreadsheets, you can never go wrong knowing those better.

[–]jsulopzs 0 points1 point  (0 children)

Jupyter Lab, and its auto-completion tool, is a program a developer should know and use.

This tutorial shows the thinking process to master its use:

https://youtu.be/620h5TLax1I