ProgrammerHumor

importPainAsHumor

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

Discussion

TameTheSparks

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

14 hours ago
ChaiiWithCharm

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

14 hours ago
Badass-19

Exactly my reaction. Tf?

13 hours ago
Vas1le
:ansible::g::py::bash::terraform:

The fuk?

9 hours ago
GotBanned3rdTime

whu lee fuk

2 hours ago
catfroman

Supposed to be all jumbled - tf would typically be tensorflow

1 hour ago
SnuggleMoonz

I am not data scientist and this offends me

14 hours ago
CherryCozyPop

This is just pure evil

14 hours ago
Free-Employment-9776

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

13 hours ago
rosuav

Team Fortress 3 confirmed!!

13 hours ago
ANTONIN118
:js:

Titanfall 3 ?!!

11 hours ago
Doctor429

Where's hl3?

13 hours ago
rosuav

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

13 hours ago
0Pat

import hail as hl3

12 hours ago
ANTONIN118
:js:

define true false

11 hours ago
anotheridiot-
:g::c::py::bash::js:

```

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

```

7 hours ago
Nodebunny
:py::cp::js::bash::snoo_putback::table_flip:

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

6 hours ago
ANTONIN118
:js:

Bro woke up and choosed violence

6 hours ago
lemonickous

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

14 hours 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.

13 hours 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

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

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

13 hours 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.

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

Thx. Makes sense

12 hours 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

13 hours 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.

13 hours ago
Flat_Initial_1823

Tbf, typing pandas every time is goofy af.

10 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.

9 hours 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

15 minutes ago
Zymosan99

Makes writing it easier

53 minutes 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
12 hours 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.

12 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.

8 hours 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.

4 hours 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.

7 minutes 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.

8 hours 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.

8 hours 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 ;) .

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

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

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

import satan as jesus

10 hours ago
Blakut

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

13 hours ago
anotheridiot-
:g::c::py::bash::js:

One weird trick for good test results.

7 hours ago
ShadyGlimmer

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

14 hours ago
Mayion

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

14 hours 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.

13 hours 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.

13 hours ago
0Pat

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

12 hours ago
Locellus

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

10 hours 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.

13 hours 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

12 hours ago
Equivalent-Swan-4441

Ahhhhhhhhhhhhhh

12 hours ago
Odd-Key-2922

Kids were bullied around my block for this kind of behaviour

12 hours ago
TheRealGizmo

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

11 hours ago
Lysol3435

Ew

11 hours ago
Jk2EnIe6kE5

Import depression as yes

11 hours ago
git0ffmylawnm8
:py::r::jla:

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

9 hours ago
Palpatine

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

9 hours ago
Away_Elephant_4977

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

8 hours ago
stan_frbd
:py:

The same way for developers in general

alias cd="rm -rf"

7 hours ago
SkilledApple

This is borderline traumatic

6 hours ago
doggiekruger

Hello satan

6 hours ago
thies1310

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

5 hours ago
Annual_Terrible
:py:

good idea on how to fuck with llms

4 hours 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.

12 minutes ago
TheTurino

My soul entered attack mode for about 2 seconds there

13 hours ago