---
title: "Discussion on \"Why name spacing using filenames is broken?\" | Hashnode"
description: "Discussion on \"Why name spacing using filenames is broken?\". Two other titles I debated between are \"Why library code should always use absolute imports\" and the click bait \"How I broke python using two simple (innocent) lines of code\"\nHere is the code:\nimport logging\n\nlogger = logging.getLogger(__name__)\n\nNot..."
url: "https://hashnode.com/posts/why-name-spacing-using-filenames-is-broken/5f62242a456ff01582e81120"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why name spacing using filenames is broken?](https://rahem027.hashnode.dev/why-name-spacing-using-filenames-is-broken?utm_source=hashnode&utm_medium=feed)

Two other titles I debated between are "Why library code should always use absolute imports" and the click bait "How I broke python using two simple (innocent) lines of code" Here is the code: import logging logger = logging.getLogger(\_\_name\_\_) Not...

Sep 16, 2020 · 2 min read · rahem027.hashnode.dev  
Read the article

## Written by

[Hemil Ruparel](https://hashnode.com/@rahem027)

@rahem027

  
[View profile](https://hashnode.com/@rahem027)

Would love to help you

## Responses 1

Markdown supported · ⌘↵ to post

[Sean Charles](https://hashnode.com/@emacstheviking)

[Sep 16, 2020](https://hashnode.com/posts/why-name-spacing-using-filenames-is-broken/5f62242a456ff01582e81120/comment/5f626552939cf216bcb35149)

If you really really really, ...really... dive deep down into the implementation of the Python module loading system you might get the impression this might be --intentional-- as the smart code mechanisms that allow the really clever introspection stuff to run, mock patching etc. wouldn't work methinks.

But... it should at least say something to you about using reserved names for your own stuff maybe something like a 'strict' mode or -Wall sort of thing.

Tread carefully! LMAO

[Hemil Ruparel](https://hashnode.com/@rahem027)

[Sep 17, 2020](https://hashnode.com/posts/why-name-spacing-using-filenames-is-broken/5f62242a456ff01582e81120/comment/5f626552939cf216bcb35149#reply-5f62d2e61d914f19b97de456)

I dont know about the clever introspection or mocking, but the strict mode, yes.

It was absolutely unintentional. I didnt know the default python string is in string.py lol.

[Hemil Ruparel](https://hashnode.com/@rahem027)

[Sep 17, 2020](https://hashnode.com/posts/why-name-spacing-using-filenames-is-broken/5f62242a456ff01582e81120/comment/5f626552939cf216bcb35149#reply-5f62d8bb0f115919981fca70)

I can think of how it will be useful for mocking. By defining a string in the same directory, we can subtitute the mock implementation pretty easily.

But can you expand more on the clever introspection
