ProgrammerHumor

importPainAsHumor

importPainAsHumor
https://i.redd.it/2x1xo122tscf1.jpeg
Reddit

Discussion

TameTheSparks

This isn’t just wrong. It’s illegal in 42 countries

1 day ago
ChaiiWithCharm

My soul left my body at ‘pandas as tf.’

1 day ago
Badass-19

Exactly my reaction. Tf?

1 day ago
Vas1le
:ansible::g::py::bash::terraform:

The fuk?

1 day ago
GotBanned3rdTime

whu lee fuk

1 day ago
catfroman

Supposed to be all jumbled - tf would typically be tensorflow

23 hours ago
SnuggleMoonz

I am not data scientist and this offends me

1 day ago
CherryCozyPop

This is just pure evil

1 day ago
Free-Employment-9776

I actually did import torch as tf3, really fucks with people’s mind

1 day ago
rosuav

Team Fortress 3 confirmed!!

1 day ago
ANTONIN118
:js:

Titanfall 3 ?!!

1 day ago
Doctor429

Where's hl3?

1 day ago
rosuav

Alas, I don't think we have managed to import that yet.

1 day ago
0Pat

import hail as hl3

1 day ago
ANTONIN118
:js:

define true false

1 day ago
anotheridiot-
:g::c::py::bash::js:

```

define true (random()%2==0)

```

1 day ago
Nodebunny
:py::cp::js::bash::snoo_putback::table_flip:

defining true as not true would be enough to make me flip a table

1 day ago
Snudget
:rust::py::asm:

(⁠╯⁠°⁠□⁠°⁠)⁠╯⁠︵⁠ ⁠┻⁠━⁠┻

18 hours ago
ANTONIN118
:js:

Bro woke up and choosed violence

1 day ago
RareDestroyer8

I would rather restart my whole project than try and debug that

14 hours ago
Percolator2020
:ftn::unreal::c::kos:

import satan as jesus

1 day ago
Responsible_Trifle15

Subscribe

11 hours ago
lemonickous

Just when i thought i wasn't capable of murder....

1 day ago
Fritzschmied
:cs::j::js::p::unity:

Honest question but why is it so common in python anyways to use the import as statement and import pandas for example as pd. In pretty much every other language the equivalent to import as is just used in edge cases and everything they importer as is to not confuse people. I’ve never understood that because in the case you don’t want to type that many characters autocomplete exists so it shouldn’t be an issue to type pandas as a whole word.

1 day ago
Bright-Historian-216
:cp::lua::py:

it mostly applies to only pandas, numpy, and matplotlib.pyplot. all other libraries are usually imported as they already are

1 day ago
Fritzschmied
:cs::j::js::p::unity:

Yes but why those? Why is it so common to import those like that?

1 day ago
nokeldin42

Because those libraries are intended for scientists rather than programmers.

If you look at code in other languages written by scientists/mathematicians, you'll also see tons of needlessly shortened variables names. Often just x and y.

Reasons vary, part of it is how they think about problems. Holdover from pen and paper research where var names were shortened to one letter to save manual effort. Part is that this community were some of the earliest programmers, when memory was so scarce that you'd want to save every byte, even in the source code.

Python with numpy and all stands out because none of the practical concerns remain, but the culture persists and looks a bit absurd.

1 day ago
Fritzschmied
:cs::j::js::p::unity:

Thx. Makes sense

1 day ago
Bright-Historian-216
:cp::lua::py:

i dunno. it's a tradition at this point. i mean, we use indents instead of braces, you may have more important questions to ask

1 day ago
Fritzschmied
:cs::j::js::p::unity:

Yeah the indent thing is shit too but that’s just a design decision from the language designer. The shortening of pandas and so on is basically a community decision which is way more interesting to question. At least for me.

1 day ago
Flat_Initial_1823

Tbf, typing pandas every time is goofy af.

1 day ago
starostise

Then only import the modules you're actually using from the lib instead of importing the whole lib.

from pandas import DataFrame, concat, merge

from numpy import greater, less

And use as only for conflicting names.

20 hours ago
Fritzschmied
:cs::j::js::p::unity:

I mean with at least an average autocomplete it shouldn’t be sufficient to type pa or at most pan and it autocompletes to pandas. And then even people who are not familiar with the convention would know that the library used is pandas.

1 day ago
thirdegree
Violet security clearance

The people not familiar with the convention can still see the import as at the top of the file, and quickly become familiar

22 hours ago
Fritzschmied
:cs::j::js::p::unity:

Thats true but its still one step more that you would do with every other programming language because nobody does that anywhere else really

14 hours ago
Zymosan99

Makes writing it easier

22 hours ago
nickwcy
  1. Convention
  2. All online tutorial does so. People just copy (and might not even understand)
  3. Not everyone is using an IDE, especially someone who just started
  4. Readability. Shorter lines are easier to display and to read.
  5. This is similar to asking “why do we use int but not integer?” I think most developers will prefer int, unless you are using cobol, basic, or pascal
1 day ago
Fritzschmied
:cs::j::js::p::unity:

Makes sense. But I want to add two things. You don’t need an ide for autocomplete. Every acceptable editor should be able to do it and if not it’s just not suitable for coding tbh. Also many big languages uses the full words like string integer and Boolean like for example Java which is still a widely used language or typescript uses the full names too.

1 day ago
MisterProfGuy

As I tell my students though, remember that Python was also intended to help people who aren't programmers that use tools that aren't suitable for coding actually accomplish something due to the readily available modules and the ease of acquiring modules that do the things you don't know how to code. You know what supposed to happen though.

4 hours ago
Fritzschmied
:cs::j::js::p::unity:

This is so true. Python is a great tool but so many people use it for things it’s just not meant for.

2 hours ago
Away_Elephant_4977

It's the data science folks I'm pretty sure. I didn't start seeing this pattern of proactive re-aliasing of libraries until I started to get into the ML world. And then I started seeing awful things like variables named 'x' and other traditional programmer eye twitching code. By now I've gotten fairly used to it in this space, but it still drives me nuts when I have to correct either imports or usage of some LLM-generated code.

1 day ago
thatone_high_guy

It has become like LOL. You would never spell the complete thing. Brain just understands pd and it has become a habit, simple as that.

If you go searching, you might find the story of how it actually became like that, but at this point it’s basically the default.

1 day ago
baxte

Its so ingrained now that I'm fairly certain something like this was on our statistics exam and we had to point out the inaccuracies.

22 hours ago
Ulrich_de_Vries
:py::j:

Why do you want to type out numpy.array, etc when you can shorten it to np.array?

Also if you use these libraries, you will usually use many symbols, so it makes more sense to import the entire module than to import only some symbols.

1 day ago
Fritzschmied
:cs::j::js::p::unity:

Because people that are not familiar with the lib and the convention would immediately see what lib was used.

1 day ago
Ulrich_de_Vries
:py::j:

They can see it by checking the imports at the top or by ctrl-clicking the shortened symbol (in most editors anyways). These shortening conventions are pretty well-established to be clear to anyone familiar with these libraries and immediately picked up by anyone getting into them.

On the other hand, e.g. complicated matrix operations would be a syntax hell if you had to write numpy in front of ever damn symbol in the expression. They are often syntax hells as they are ;) .

1 day ago
Fritzschmied
:cs::j::js::p::unity:

I mean it’s Python. The whole thing is a syntax hell by design ;)

1 day ago
Blakut

train = X[:]
test = X[-500:]

1 day ago
anotheridiot-
:g::c::py::bash::js:

One weird trick for good test results.

1 day ago
git0ffmylawnm8
:py::r::jla:

Just got put on Interpol's most wanted list holy fuk

1 day ago
Palpatine

Where is the california proposition 65 label when this is the ONE PLACE where that would be appropriate?

1 day ago
stan_frbd
:py:

The same way for developers in general

alias cd="rm -rf"

1 day ago
RemarkableDisplay988

import numpy as pd

21 hours ago
ShadyGlimmer

This is fucking eyebleach , i saw this 10 minutes ago and now cant think properly now

1 day ago
Mayion

not really familiar. is it the initials being mixed up?

1 day ago
rosuav

Yeah. These are all packages that are VERY frequently imported using well-known aliases, to the extent that people will refer to "np.xyz" without even bothering to mention that they imported numpy as np. I'm sure you can figure out which name NORMALLY goes with which alias here.

1 day ago
Kamwind

Yea. Those are some very standard libraries for data science and it is almost a standard to use those aliases. If you see code that does not use those standard aliases such as using the full name, you know it is someone who does not know what they are doing.

1 day ago
0Pat

OR, they refuse to follow the arbitrary rules enforced by the community. Because they can 🤣

1 day ago
Locellus

Or they learned Python after learning other stuff and before this shit became common

1 day ago
TameTheSparks

Yep, it's the import aliases — totally messed up. Like using plt for TensorFlow or np for matplotlib. Pure chaos for any data scientist.

1 day ago
Memoishi

Pure chaos for very dumb people tho...
I get that's just a joke, but if that was a real life scenario the dumbest dev in the world would prolly get a clue about right clicking this shit and refactor with the correct alias.
This is harmless lol

1 day ago
Equivalent-Swan-4441

Ahhhhhhhhhhhhhh

1 day ago
Odd-Key-2922

Kids were bullied around my block for this kind of behaviour

1 day ago
TheRealGizmo

This is not offensive, but will be a pain in the ass!

1 day ago
Lysol3435

Ew

1 day ago
Jk2EnIe6kE5

Import depression as yes

1 day ago
Away_Elephant_4977

...I just want to hurt something right now...

1 day ago
SkilledApple

This is borderline traumatic

1 day ago
doggiekruger

Hello satan

1 day ago
thies1310

I already get pissed when you shorten Numpy and Pandas, they are Not that Long and the short is confusing me

1 day ago
Annual_Terrible
:py:

good idea on how to fuck with llms

1 day ago
hoexloit

Data scientists just play connect the dots, except they don’t even touch all the dots. My 5 year old niece can do a better job than they can.

22 hours ago
khalcyon2011

19 hours ago
Solobolt

Using Tensorflow instead of pyTorch. Horrific.

18 hours ago
violentartiste

Intended target data scientist, actual target entire coding community 😂

17 hours ago
aok76

I had to deal with code at work where the library was imported as s. Just the letter s. It was diabolical.

I couldn't even change it efficiently because searching for the letter s highlights everywhere in the code.

14 hours ago
-TRlNlTY-

Eewww tensorflow

9 hours ago
LordAmir5
:c::cp::j:

ROR EAX, 1

9 hours ago
Own_Mission4727

This should be considered a war crime 

58 minutes ago
TheTurino

My soul entered attack mode for about 2 seconds there

1 day ago