ProgrammerHumor

importPainAsHumor

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

Discussion

TameTheSparks

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

6 hours ago
ChaiiWithCharm

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

6 hours ago
Badass-19

Exactly my reaction. Tf?

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

The fuk?

2 hours ago
SnuggleMoonz

I am not data scientist and this offends me

6 hours ago
CherryCozyPop

This is just pure evil

6 hours ago
Free-Employment-9776

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

5 hours ago
rosuav

Team Fortress 3 confirmed!!

5 hours ago
ANTONIN118
:js:

Titanfall 3 ?!!

3 hours ago
Doctor429

Where's hl3?

5 hours ago
rosuav

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

5 hours ago
0Pat

import hail as hl3

4 hours ago
lemonickous

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

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

5 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

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

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

5 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

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

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

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

Thx. Makes sense

4 hours ago
Flat_Initial_1823

Tbf, typing pandas every time is goofy af.

2 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 hour 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
4 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.

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

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

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

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

27 minutes ago
ANTONIN118
:js:

define true false

3 hours ago
ShadyGlimmer

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

6 hours ago
Mayion

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

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

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

5 hours ago
0Pat

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

4 hours ago
Locellus

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

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

6 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

4 hours ago
Blakut

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

6 hours ago
Equivalent-Swan-4441

Ahhhhhhhhhhhhhh

4 hours ago
Odd-Key-2922

Kids were bullied around my block for this kind of behaviour

4 hours ago
TheRealGizmo

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

3 hours ago
Lysol3435

Ew

3 hours ago
Jk2EnIe6kE5

Import depression as yes

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

import satan as jesus

2 hours ago
git0ffmylawnm8
:py::r::jla:

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

1 hour ago
Palpatine

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

1 hour ago
Away_Elephant_4977

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

32 minutes ago
TheTurino

My soul entered attack mode for about 2 seconds there

6 hours ago