eugeneyan / eugeneyan-comments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

https://eugeneyan.com/writing/uncommon-python/

utterances-bot opened this issue · comments

Uncommon Uses of Python in Commonly Used Libraries

Some off-the-beaten uses of Python learned from reading libraries.

https://eugeneyan.com/writing/uncommon-python/

This content is good! Thanks for writing more advanced content.

That said, is there a reason not to use relative imports? Please comment below!

Regarding relative imports vs absolute imports I find this StackOverflow answer quite useful.

I personally prefer the absolute imports syntax, but it might be just due to been used to it. Rearrange the structure of the packages is not that hard using an IDE to refactor the imports. Regarding the modules inside packages issue, I personally dislike having modules inside packages instead of having them installable with pip. What would be a case where having modules inside a package would be preferred to publish it in pypi (either public or private)?

Thanks a lot of the content, very interesting details that are not widely known. Most of the things were new to me.

The latter states that it’s better to have a simple but slightly incomplete solution than a comprehensive but hard-to-maintain design.

100% agree. As a developer is sometimes hard to remove your own code complexity, I guess that is where working in teams and doing PR reviews gets handy as it is easy to suggest removing not needed complexity in some other's code I think.

Thanks for the content! I just needed to read this today

Thanks for this blog, super informative!

In this section is there a reason why you used relative imports in the models example

from .tree import DecisionTree, RandomForest
from .bandit import Bandit, TSBandit

and not in the app example?

from model_implementation import SimpleModel
from data_implementation import SimpleDataLoader

@siddheshmhatre Good point—updated!

@xinofekuator

What would be a case where having modules inside a package would be preferred to publish it in pypi (either public or private)?

In this case, I'm referring to .py files in packages as modules which may not be reusable by the public and thus not worth the effort to publish to pypi.

@eugeneyan I don't know if this is of interest to you, but James Lamb (a maintainer of LightGBM) talked about why we shouldn't publish tests/artifacts/etc. in SciPy here. A bit expected, but going into the numbers helps give insight to the problems end users face.

Hey I really enjoyed this content. Keep up the good work. I came for the first paragraph about Using super() in base classes and was able to follow along and understand by playing with the sample code. Keep that up I would have liked to have done the same thing with When to Use a Mixin.