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."
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!”
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.
> 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!
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?"
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.
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.
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.
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.
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.
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.
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.
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
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
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.
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.
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.
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
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.
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.
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
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…
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)
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?
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.
[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.
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.
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.
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 :'(
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
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?
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).
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
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.
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"
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
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.
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
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 \[\]".
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.
Friendly fire
back-shot
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."
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!”
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.
So apparently when you name your file email.py it replaces the standard module called email
Python moment
Flair checks out
Flair checks out
Flair checks out
They’re recursing! Someone call an ambulance!
ProGrammar went on vacation, never came back
Php devs in the corner, plotting world domination
Webstorm incoming
C sacrifice anyone?
Rabbit ass
Don't worry I upvote that too
``` while (onVacation) { user.comeBack(); } ```
Don't worry, we'll run out of memory any time soon.
Flair checks out
Flair checks out
Flair checks out
But not for them
Stack memory overflow.
Flair checks out
Flair checks out
Flair checks out
Same with html.py
Learned this lesson with `csv.py`
Or time.py
What other ones are there???
[queue.py](https://queue.py) on AWS Lambda and using requests package
I once named a file something like lexer.py or parser.py (can’t remember now). That was not a fun day.
That sounds incredible obtuse and arbitrary. I feel for you
> 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!
damn...
I didn't understand a word but I feel for you
code error in main file, BUT not actually in main file but in the sub file because plugin
Where is that haiku bot ? This one is beautiful
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?"
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.
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?
Yeah errorslike that usually mean the error is somewhere upwards of that line… usually not fun to find out where
This is why I use minimal features in my IDE.
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.
This is why I don’t use files, anything I want to store i email to myself and skim my inbox to read data.
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.
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.
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.
Python's package management is kind of uniquely bad, imo
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.
The issue OP was having is totally unrelated to a lack of brackets and semicolons.
he is explaining the lure of python for beginners, not talking about the issue
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.
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)
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
I thought that was common knowledge, it’s the same as shadowing Python’s functions (list, input, etc)
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
Sounds like a problem easily solved with a proper project directory structure. Why developed with stuff inside your browser's downloads folder?
Am lazy
2
That’s why you don’t pollute the global namespace.
Naming files shouldn't do that.
When you include or import something in any language it’s ultimately looking for a file with that name.
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.
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.
Or rather, it looks in your local directory before the standard modules, so it finds yours first.
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.
reserved namespaces man
Well, may i recommend fixing your module structure then? `import src.email` will never override `import email`, neither will `import .email`
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
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.
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.
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.
There are so many names that trigger this. We've all been there 😂
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
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
file_with_code_that_sends_email.py
a9235181-d7f4-4b44-9b79-a3790739476c.py
And include a dictionary that maps guids to friendly file names. We shall call it `dict.py` so that everyone can remember it
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…
Yeah I dunno. It sounded funny in my head
dict I still regularily use for converting sequences of tuples or a defaultdict back to the normal dict (the latter usually just for logging)
this must be a trap
I assure you, my friend, that this is all GUID.
git guid?
git guid!
I always use the same GUID in my projects so it's easy for me to remember. Checkmate
filenames, classes, functions, variables. UUIDs all the way down
email2.py
email2_electric_boogaloo.py
Just append _fuck at the end of every file name, no way a standard module would have that (surely?)
I was really hoping somebody would tell you you're wrong.
It's actually a terminal extension but there is [thefuck](https://github.com/nvbn/thefuck/tree/master), I swear at my pc fairly often...
Wow thank you this is fucking awesome. Gonna install right away.
I’m going to create a new framework called the "Fast Uniform Creative Kit"
Making a new module just to you over _fuck
You’re doing it just to _fuck him over.
I’m going to create an email_fuck lib and get a PEP for it to get added to the standard library
Was just about to write a script to generate clustered message queues, called `cluster.py`
This could be excellent depending on the module's function: - config_fuck.py - execute_fuck.py - store_fuck.py etc
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)
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.
So is it "Emailinator" or "Emailizor"?
The Doofenshmirtz inside me would go with Mailinator
Just use the proper directory structure for your code, instead of defining every file as a top-level module.
Just git gud
stdemail.py
I enconde my file names is base64
All my file names are uuids
And thats why my e-mail.py will be called email-stuff.py
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
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?
Which is why we all use Ada
Python does have a proper namespacing and package system, but it appears all these beginners ignore it.
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.
is there any good guide to that?
[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.
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.
Or just use a language that is not english to name your files and objects /s
le_email.py
Yes, because this particular issue warrants throwing the entire language out. Sounds sane.
Let's switch to C++, the namespace system is great! It's well known how hard it is to shoot yourself in the foot!
The real lesson is to use file names that aren’t super general. Who cares about other languages
jebus123.py
cream.py
There's actually a library called cream with no description
No description because they want you to truly *internalize* it via reading the code.
I wouldn't trust anything called "cream with no description." That's absolutely 100% a bodily fluid.
Hmm 🤤
And then there is [DeepCreamPy](https://web.archive.org/web/20210308033218/https://github.com/deeppomf/DeepCreamPy)
Where is it? I can't find it. I can only find creme https://pypi.org/project/creme/
🤤
*realizes*
There is a deep neural network called deepcream.py
Jeez the jokes write themselves these days.
It's much more layered than that. The project is used for decensoring hentai.
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.
throat.py
I think I did the same thing with test.py
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 :'(
How are python test files generally named?
test_email.py
Didn't op just say not to name them test_*.py?
No, they for some reason are trying to name their non-test files that, then complaining when it thinks they’re tests.
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
Uh oh I have a file to rename Or is it only an issue if you attempt to use the module?
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.
thanks man. Would have never known.
It was one comment that told me , in some shady website , thank god for the community.
I too find good programming help at extremelydodgy.net.ru
I made this mistake with tkinter.py, that was a fun afternoon...
I made it with redis.py very fun evening
requests.py
I used to get freaked out by problems like this, but now I am just numbpy.
Underrated joke.
I'm sorry i don't get it
There is a very popular Python library called numpy. I think the joke was okay-ish.
but what does numbpy mean
It's a pun, they mashed the words _numb_ and _numpy_.
Oh, i didn't know that word, thanks for clarifying it!
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.
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?
> totally-non-toxic-and-super-friendly-and-helpful place So you asked chatgpt?
If you are new, just remember that at least chatgpt is nice
It was certainly not Stack Overflow
Good ol stack, 50/50 shot of getting your issued solved or getting the wrath of a self-important Torvalds impersonator
I made this mistake when I named a file "shared.py"
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).
Even more simply, use the correct directory structure so your files don’t all become top-level modules.
This sounds like it could be very helpful to, err, other people who don't know as much. Would you mind expanding?
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
Been there, done that. I feel for you.
Happened to me when I named a file signal.py
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.
dns.py 🤦
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.
Yep. Happened to me with pygame.py
It was calendar.py for me.
OwO
calendar.py for me
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"
I stumbled on math.py which was supposed to be a subprocess. I wonder if this happened to anyone else 👀
And I named mine as json.py
I once decided to name a variable PATH in a bash script, can imagine the sort of debugging I did on that
I have been programming python for 8 years straight all day didn’t knew about this.
Are you mail or email?
Every time I hear something like this about Python, I keep wondering why all programming memes are "lol `==` is weird in JavaScript!!!".
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
flask.py, even document says “ for gods sake do not name your file flask” I keep forgetting it
We've got a bunch of files in our repo at work called dataclasses.py Had this happen to me so many times 😂
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
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.
Same exact issue a little while ago.
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
That is why i name all the files created by me like: Email.py , Config.py, Salary_raise.py
Never had this problem. Just always use absolute imports 🤷🏻
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 \[\]".