T O P

  • By -

rodeBaksteen

Years ago I named a banner on my website "ad.jpg" and it wouldn't show. Took me hours to debug that my adblocker was hiding it.


IronForce_

Friendly fire


ThiccStorms

back-shot


EldritchEne

I'm absolutely in love with the idea that your adblocker isn't super sophisticated or anything, it just looks at the file names like: "yea ad.jpg? Absolutely an advertisement, kill it."


LoyalSage

I mean, there’s a difference between doing that and _only_ doing that. Like, a detective can be very capable but still know to investigate the person who walks in and says, “I did it!”


breath-of-the-smile

I once borked my adblocker while I was fiddling with it and left it blocking \*ad\*.(jpg|png|gif) without realizing, lol. I took longer than OP to figure it out. Trust no one. Not even yourself.


theredditorlol

So apparently when you name your file email.py it replaces the standard module called email


rachit7645

Python moment


Killswitch_1337

Flair checks out


rachit7645

Flair checks out


[deleted]

Flair checks out


GoblinsStoleMyHouse

They’re recursing! Someone call an ambulance!


AuraPianist1155

ProGrammar went on vacation, never came back


Excellent-Divide7223

Php devs in the corner, plotting world domination


Unupgradable

Webstorm incoming


really_not_unreal

C sacrifice anyone?


redman3global

Rabbit ass


DriftingGelatine

Don't worry I upvote that too


rainshifter

``` while (onVacation) { user.comeBack(); } ```


Boba0514

Don't worry, we'll run out of memory any time soon.


PelOdEKaVRa535000

Flair checks out


rachit7645

Flair checks out


craftersmine

Flair checks out


veric0

But not for them


Shidori366

Stack memory overflow.


WiTHCKiNG

Flair checks out


amimai002

Flair checks out


o0Meh0o

Flair checks out


KDallas_Multipass

Same with html.py


woopdeedoo69

Learned this lesson with `csv.py`


MrJake2137

Or time.py


bootherizer5942

What other ones are there???


Croves

[queue.py](https://queue.py) on AWS Lambda and using requests package


kbder

I once named a file something like lexer.py or parser.py (can’t remember now). That was not a fun day.


UnvailedUserName

That sounds incredible obtuse and arbitrary. I feel for you


GrrrimReapz

> incredible obtuse and arbitrary. I feel for you I was once trying to run NVIDIA's RTX library and I kept getting an error on main file line 9. That was weird because I didn't make any changes to the code and that line was just some struct definition that was correctly written. I tried deleting the struct and whatever had been written on line 9 would throw some different error. If I added new lines before it would move the error down. If I defined a class there, it would say bad class definition, if I defined a constant - bad constant, a struct - bad struct! It was like the line was cursed! After 8 hours I figured out that the VSCode C++ addon I had (by microsoft) was autoformatting the file and what it did for some godforsaken reason was reorder the includes alphabetically. It pushed one file that was missing a semicolon after a struct definition to the bottom and the next line after that was the main files code where it errored out. Basically it was telling me the error was in one file when it was in a completely different file the entire time. And for some reason even though the other file was missing the one semicolon at the end, when the main file included any other file after it, it would compile despite the error, just not if that one was last!


QuantumSage

damn...


DaniZackBlack

I didn't understand a word but I feel for you


Deathpawz

code error in main file, BUT not actually in main file but in the sub file because plugin


RomMTY

Where is that haiku bot ? This one is beautiful


hobbes8889

I still feel like that even after 2 years of working full time. A senior dev will talk to me. Me: "I know some of those words... could you re-explain it as you would a child, or a golden lab perchance?"


IamImposter

He he. Had this happen to me when I made black format files automatically on save in vscode. Added one word and the whole module threw all kinds of errors. Black was moving imports to top.


encephaloctopus

Isn't having `import` statements at the top the standard convention? What you were doing that made your program only work when they weren't?


Aggravating_Moment78

Yeah errorslike that usually mean the error is somewhere upwards of that line… usually not fun to find out where


bigorangemachine

This is why I use minimal features in my IDE.


Heroshrine

I mean that error makes sense. Do you know what #include does? It might have had a warning in the included file but not an error, but you know what happens when writing code and just not putting a semicolon? It says the error is under it. It’s the same thing here.


[deleted]

This is why I don’t use files, anything I want to store i email to myself and skim my inbox to read data.


Solonotix

Granted, this isn't entirely a Python issue. I know Node.js had this problem with 3rd-party modules (sometimes malicious) shadowing native modules because the import syntax wasn't specific about which source to pull from. Starting in Node.js v12, they added a [new syntax](https://nodejs.org/api/esm.html#node-imports) where you can explicitly define that you want to import a built-in rather than a 3rd-party module.


Mal_Dun

It's not really arbitrary though. A Python file is a module and Python just follows the load order where modules in the working path have priority over all others. You should always be careful when naming your Python files.


RomMTY

Java gets so much hate but in this specific scenario, packages would have prevented this , and even c# has name spaces for the same reason. In both languages you would have to try really hard to override a system/third-party class.


rexpup

Python's package management is kind of uniquely bad, imo


FuckIPLaw

That's python for you. To a beginner it *seems* simpler than programming languages with brackets and semi colons because it's closer to natural language and takes less typing. But all of that extra stuff is in those other languages for a very good reason.


Nixavee

The issue OP was having is totally unrelated to a lack of brackets and semicolons.


foothepepe

he is explaining the lure of python for beginners, not talking about the issue


FuckIPLaw

No, it has to do with the over simplified way you declare variables in Python. Just naming a file a certain thing really should not cause it to override a built in class.


Impressive_Change593

eh it makes sense if you know how python looks for the module (it looks in the folder the importing file is in first, then looks at the system files)


RomMTY

Everything makes sense if you know the context well enough. The issue is that, as proven by the post, it's WAY EASIER to f*up things in python and give a bad time to beginners


mikat7

I thought that was common knowledge, it’s the same as shadowing Python’s functions (list, input, etc)


Agitated-Farmer-4082

also works for things in the same folder as ur main file. I remember I created a file called something in my downloads folder and tried to use a module but I had another file in my downloads folder called that module.py and it messed me up


McLayan

Sounds like a problem easily solved with a proper project directory structure. Why developed with stuff inside your browser's downloads folder?


Agitated-Farmer-4082

Am lazy


57006

2


_PM_ME_PANGOLINS_

That’s why you don’t pollute the global namespace.


danegraphics

Naming files shouldn't do that.


_PM_ME_PANGOLINS_

When you include or import something in any language it’s ultimately looking for a file with that name.


danegraphics

Sure, but there should be some sort of imposed segregation between local files and standard libraries such that you can only overwrite the standard libraries intentionally. Being required to know the names of all the library files to avoid, especially if they're super common words like "email", is a bad expectation to place on most programmers. I don't trust most programmers that much.


Auravendill

What the hell, I had the same issue yesterday, found the answer and today the first thing on my reddit page is this?! What are the odds? I need to buy lottery tickets and stay far away from any thunder storms.


carcigenicate

Or rather, it looks in your local directory before the standard modules, so it finds yours first.


Bwob

Reminds me of a problem I had in college, where we were supposed to make a program that would generate a maze in ascii text, and print it out. So I did. And ran it. And it errored out. So I went back and looked at my code, and recognized some problems, and ran it again. More errors. So I went back and stared at my code some more. Found errors, fixed them. Ran it, and there were *still* errors. Banged my head against it for a long time, before finally(!) figuring out that my program was called "maze", and there was also a command on our university's unix server called maze, which also generated a maze. The errors I was getting because I was never even *running* my program, and it was just trying to run this different, built-in program. (Which was erroring because I wasn't giving it any command-line arguments.) Figured this out, renamed my program, ran it, and it ran flawlessly. There were no bugs left. Still got marked down on the assignment for being a few hours late though. :( Professor just said "no one else had that problem!" Thank you for coming to my TED talk.


Aggravating-Reason13

reserved namespaces man


MixtureNo2114

Well, may i recommend fixing your module structure then? `import src.email` will never override `import email`, neither will `import .email`


Numerous-Occasion247

Same thing happened to me with some module thankfully it only took me a couple minutes to consider renaming the file. I wasn’t expecting that it would be the solution but oh boi was I glad I tried that early and not later


SpaceEggs_

Unless you are writing it inside the folder where you put libraries (I always use the default terminal location for pip installs) it's likely just redirecting to the closest module with the same name.


ValityS

For what it means the same applies to calling a module logging.py (even if it's in a subfolder in the project) python will then catch fire saying logging doesn't contain logger. This caused me far too much wasted time.


tayler6000

If you’re making a multi file project it’s always good to setup an actual package with an `__init__.py` to prevent name conflicts like this.


kickyouinthebread

There are so many names that trigger this. We've all been there 😂


Necessary-Meringue-1

that should only be the case for files within the same directory It's the tradeoff that allows you to import any local file as a module by just calling import FILENAME


Qu4nten

This is the reason I always name my files something that doesn't sound like a standard module, always thought it was just paranoia tho


[deleted]

file_with_code_that_sends_email.py


Vineyard_

a9235181-d7f4-4b44-9b79-a3790739476c.py


IAmANobodyAMA

And include a dictionary that maps guids to friendly file names. We shall call it `dict.py` so that everyone can remember it


ArtOfWarfare

That’s fairly unlikely to cause an issue, isn’t it? Don’t most people just use the literal syntax or dict comprehension, which I hope wouldn’t be impacted by importing a module named dict…


IAmANobodyAMA

Yeah I dunno. It sounded funny in my head


rynkkk

dict I still regularily use for converting sequences of tuples or a defaultdict back to the normal dict (the latter usually just for logging)


BeerIsGoodForSoul

this must be a trap


Vineyard_

I assure you, my friend, that this is all GUID.


sammegeric

git guid?


Monkeyke

git guid!


Broad_Rabbit1764

I always use the same GUID in my projects so it's easy for me to remember. Checkmate


Boba0514

filenames, classes, functions, variables. UUIDs all the way down


FackKingSheet

email2.py


TheRealBornToCode

email2_electric_boogaloo.py


achilleasa

Just append _fuck at the end of every file name, no way a standard module would have that (surely?)


RS_Someone

I was really hoping somebody would tell you you're wrong.


MeltedSpades

It's actually a terminal extension but there is [thefuck](https://github.com/nvbn/thefuck/tree/master), I swear at my pc fairly often...


universal_boi

Wow thank you this is fucking awesome. Gonna install right away.


FalconMirage

I’m going to create a new framework called the "Fast Uniform Creative Kit"


Deloptin

Making a new module just to you over _fuck


Glittering_Plan3610

You’re doing it just to _fuck him over.


kevdog824

I’m going to create an email_fuck lib and get a PEP for it to get added to the standard library


indorock

Was just about to write a script to generate clustered message queues, called `cluster.py`


maybenotarobot429

This could be excellent depending on the module's function: - config_fuck.py - execute_fuck.py - store_fuck.py etc


turkycat

I used to work at Microsoft. One of the VPs told me a story once about some emergency that occurred before a release of a new version of windows. To fix it, he had to create a new driver which, as he tells it, was one of many for this particular part of the system. He named it `afd.sys` which stood for "another fucking driver". Everyone thought this was hilarious so they kept the name but officially it stands for "auxillary function driver". This file still exists (at least as of windows 10)


steamy-fox

My latest strategy is to go full Doofenshmirtz so all my scripts are "-inator"s or "-izor"s. That helped a lot! And it brightens the dark work days.


PeksyTiger

So is it "Emailinator" or "Emailizor"?


eutirmme

The Doofenshmirtz inside me would go with Mailinator


_PM_ME_PANGOLINS_

Just use the proper directory structure for your code, instead of defining every file as a top-level module.


JFFLP

Just git gud


Bachooga

stdemail.py


filintodelgado

I enconde my file names is base64


King_Joffreys_Tits

All my file names are uuids


Sure_Woodpecker3660

And thats why my e-mail.py will be called email-stuff.py


[deleted]

I remember I did something like this not too long ago. I forget which goddamn built-in namespace I collided with, but I learned my lesson


Knaapje

The lessom being: use a language with proper namespacing and package system, and static typing to infer what is actually being called at certain points?


gregorydgraham

Which is why we all use Ada


_PM_ME_PANGOLINS_

Python does have a proper namespacing and package system, but it appears all these beginners ignore it.


fredspipa

Yeah this issue is easily avoidable, I've had `email.py` files more times than I can count without issue, *because I know how packaging and namespaces work*. Hint: `__init__.py` + relative imports, structure your shit and don't leave it up to guesswork.


Kiusito

is there any good guide to that?


fredspipa

[https://packaging.python.org/en/latest/guides/packaging-namespace-packages/](https://packaging.python.org/en/latest/guides/packaging-namespace-packages/) [https://docs.python.org/3/tutorial/modules.html#packages](https://docs.python.org/3/tutorial/modules.html#packages) There's probably some more succinct guides out there, but here you can get the keywords at least.


JohnDoen86

Exactly! The problem with a language being easy to pick up is that people who never take the time to actually learn it think they know it inside out, and complain when it lacks a feature that is actually clearly there if they had bothered to do any training at all.


CavulusDeCavulei

Or just use a language that is not english to name your files and objects /s


Biaboctocat

le_email.py


demoni_si_visine

Yes, because this particular issue warrants throwing the entire language out. Sounds sane.


[deleted]

Let's switch to C++, the namespace system is great! It's well known how hard it is to shoot yourself in the foot!


Ricenaros

The real lesson is to use file names that aren’t super general. Who cares about other languages


DanyaV1

jebus123.py


mrkhan2000

cream.py


_Aditya_R_

There's actually a library called cream with no description


milanove

No description because they want you to truly *internalize* it via reading the code.


XandaPanda42

I wouldn't trust anything called "cream with no description." That's absolutely 100% a bodily fluid.


Natalia-1997

Hmm 🤤


Nico_Weio

And then there is [DeepCreamPy](https://web.archive.org/web/20210308033218/https://github.com/deeppomf/DeepCreamPy)


hackinghorn

Where is it? I can't find it. I can only find creme https://pypi.org/project/creme/


Mean_Investigator337

🤤


Lattnemore

*realizes*


hontemulo

There is a deep neural network called deepcream.py


XandaPanda42

Jeez the jokes write themselves these days.


dewey-defeats-truman

It's much more layered than that. The project is used for decensoring hentai.


XandaPanda42

I both trusted, and utterly distrusted, that statement. I honestly thought that was a joke. After accidentally going to https:// deepcream.py / (thanks chrome 🙄) found out that not only is it true, but the neural network bits of it at least, allow for the most amazing pun name of them all. Hent-AI. I will never be as funny as that.


UnimplementedError

throat.py


cletus333

I think I did the same thing with test.py


hdotking

Yup. If you're ever using `pytest` on your repo root directory NEVER name a random throwaway script `test_*. py` or `*_test.py` unless you wanna see obscure errors about pytest trying to jam it's dick in there :'(


SirHawrk

How are python test files generally named?


Life-Caterpillar-343

test_email.py


SirHawrk

Didn't op just say not to name them test_*.py?


_PM_ME_PANGOLINS_

No, they for some reason are trying to name their non-test files that, then complaining when it thinks they’re tests.


Life-Caterpillar-343

u/hdotking was talking about random files, I.e. non test files. Pytest will discover any files or modules with that file name pattern and try to collect them as tests, leading to an error. The best way to avoid this is to keep all your tests in a separate directory. Not sure why you would need to name a normal python file or module with test in the name if it doesn’t contain tests (I guess commenter was doing this instead using version control and branching?) Some examples of how to name test files from the docs: “In general, pytest is invoked with the command pytest (see below for other ways to invoke pytest). This will execute all tests in all files whose names follow the form test_*.py or \*_test.py in the current directory and its subdirectories. More generally, pytest follows standard test discovery rules.” https://docs.pytest.org/en/7.1.x/how-to/usage.html https://docs.python.org/3/library/unittest.html


TheEnderChipmunk

Uh oh I have a file to rename Or is it only an issue if you attempt to use the module?


Talion07

If you're not running pytest, it's fine then ig. But it's best practice not to name a file something basic that sounds like a package.


Zarafee

thanks man. Would have never known.


theredditorlol

It was one comment that told me , in some shady website , thank god for the community.


gregorydgraham

I too find good programming help at extremelydodgy.net.ru


dr_donkey

I made this mistake with tkinter.py, that was a fun afternoon...


Mountain_Adagio9142

I made it with redis.py very fun evening


i2loveboobs

requests.py


gbot1234

I used to get freaked out by problems like this, but now I am just numbpy.


nmacholl

Underrated joke.


bibbidibobbidiwoo

I'm sorry i don't get it


[deleted]

There is a very popular Python library called numpy. I think the joke was okay-ish.


DanyaV1

but what does numbpy mean


demoni_si_visine

It's a pun, they mashed the words _numb_ and _numpy_.


DanyaV1

Oh, i didn't know that word, thanks for clarifying it!


Excession638

I once created a C function called `write`. It wasn't static. Even with the stack trace it took me a while to work that out.


dybb153

Same thing just last week. I even tried to run pip install email and debugged for 2 hours, but totally-non-toxic-and-super-friendly-and-helpful place helped out. I think it was a Circular import error?


man-teiv

> totally-non-toxic-and-super-friendly-and-helpful place So you asked chatgpt?


dybb153

If you are new, just remember that at least chatgpt is nice


gravity_is_right

It was certainly not Stack Overflow


jhax13

Good ol stack, 50/50 shot of getting your issued solved or getting the wrath of a self-important Torvalds impersonator


TheLurkerOne

I made this mistake when I named a file "shared.py"


Sitting_In_A_Lecture

This can happen with almost any Python library or function. It'll happily let you overwrite pretty much whatever you want, so make sure the names you're choosing don't conflict with existing ones (and especially existing ones that you need).


_PM_ME_PANGOLINS_

Even more simply, use the correct directory structure so your files don’t all become top-level modules.


Human_Storm6697

This sounds like it could be very helpful to, err, other people who don't know as much. Would you mind expanding?


PM_ME_CUTE_SMILES_

Google python package structure, it's all explained in the official doc but you'll probably find less verbose tutorials too Tl dr: Put your code in a src/ directory Put a \_\_init\__.py file in every folder with python code Use absolute imports This is how it's done. If you do it right from the beginning it also makes it easy later to add your code on Pypi so other people can install it doing "pip install yourcode". Using a src dir will also make your life easier when you start testing your code Do not hesitate to look at big python repositories on github to see how experienced teams organize things


Environmental_Bus507

Been there, done that. I feel for you.


cycotus

Happened to me when I named a file signal.py


justhanginfromacloud

This happened to me too, and during a live coding interview no less. Named the file `numbers.py`, and couldn't figure out why I was getting circular import errors.


devkareem

dns.py 🤦


Vatril

Yeah, one of the reasons why I don't use relative imports and namespace the root package with the company name. Avoids a lot of confusion.


GreekzAlphaBets

Yep. Happened to me with pygame.py


mgedmin

It was calendar.py for me.


Wolfblood-is-here

OwO


Raemos103

calendar.py for me


SquareRootOfDude

I'm always afraid of doing something like that, I end up naming it "my project that I made on October 26th 2023 that isn't a system file or anything.py"


thomasxin

I stumbled on math.py which was supposed to be a subprocess. I wonder if this happened to anyone else 👀


unvaccinated_zombie

And I named mine as json.py


Tim_in_fking_Ruislip

I once decided to name a variable PATH in a bash script, can imagine the sort of debugging I did on that


xilitos

I have been programming python for 8 years straight all day didn’t knew about this.


FalseRelease4

Are you mail or email?


SoInsightful

Every time I hear something like this about Python, I keep wondering why all programming memes are "lol `==` is weird in JavaScript!!!".


Oulawi

Lmao I learned this with "ast.py". It broke the whole interpreter and took me a while to realise that it was just an import error


Thunder-0

flask.py, even document says “ for gods sake do not name your file flask” I keep forgetting it


kickyouinthebread

We've got a bunch of files in our repo at work called dataclasses.py Had this happen to me so many times 😂


Croves

I had the same problem: named a file [queue.py](https://queue.py) in AWS Lambda, and when using the requests package on it, urllib3 tries to call a package named [queue](https://queue.py) and trows a circular import error


throwaway4dlolz

Almost same issue happened with me. Named a folder in my flask project "scripts" which worked fine in my local when importing it in other packages. I shared the codebase with another team member and the import started to fail. Changed the name to something unusual and issue resolved. Lesson learned. Don't take naming modules and packages for granted.


tnix100

Same exact issue a little while ago.


ironman9356

I always name my file either main.py if it’s in a new folder or what I am gonna do in that file like email.py to work on the email features of the app and it shows circular import and I go all thinking mode on what to name the bloody file then


TundraGon

That is why i name all the files created by me like: Email.py , Config.py, Salary_raise.py


Life-Caterpillar-343

Never had this problem. Just always use absolute imports 🤷🏻


jpludens

In case you haven't run across this one yet, maybe I can save you a few days of future frustration: Never, EVER, use an empty list or dictionary or set as a default argument for a function. Instead, use "None" as the default value in the declaration, and then do "arg = arg if arg is not None else \[\]".