Curious why there is no mention of conda and its fast alternative mamba (micromamba). In my experience, conda is much more robust in managing. dependencies conflict (thanks to AWS and especially boto3) compared to pip.
Python Modern Practices
41–50 of 56 posts
Re: Python Modern Practices
#42I've been using conda+poetry as my goto combo for years now and it's served me very well. Sure it's said poetry doesn't follow certain standards, but it just abstracts away so much that I don't see myself needing anything else really. If I want to share a non-poetry artifact, it's a simple `poetry build` to create a wheel. I did come across a weird dependency confusion issue recently when I tried using it on a server…
Re: Python Modern Practices
#43Earlier quoted context omitted.
Was going to comment the same thing. Would love to hear the author expand further on why not use Poetry. I've found it to be pretty solid and continue to use Poetry + Pyenv for all my projects, but open to hearing the case for PDM or Hatch.
I've never worked on a team that uses Poetry, but in my current company another team uses it, and I haven't found it really as slick as I would have imagined, primarily because you need to create a venv and install poetry into that before you even get started, which by that point why not just pip install the rest anyway? For standalone applications it just seems like an unnecessary extra step. It doesn't even mandate…
Re: Python Modern Practices
#44>Avoid using Poetry for new projects. Poetry predates many standards for Python tooling. This means that it uses non-standard implementations of key features, such as the dependency resolver and configuration formats in pyproject.toml files. What? This is the first I've heard of this.
pyenv? great! then just use pip with requirements.txt... what's wrong with pip freeze? why are there so many competing tools? it's very anti-python IMO.
Aside from all the obvious issues of having no distinction between transitive and direct dependencies, it completely breaks cross-platform support if any of your dependencies have platform-specific sub-dependencies (which is not uncommon in python).
Re: Python Modern Practices
#45Earlier quoted context omitted.
pyenv? great! then just use pip with requirements.txt... what's wrong with pip freeze? why are there so many competing tools? it's very anti-python IMO.
> what's wrong with pip freeze? I prefer my requirements.txt to include only the packages I install with pip myself (and not their dependencies).
Re: Python Modern Practices
#46Sad to not see Attrs mentioned. Dataclasses are cool, I guess, but Attrs is seriously great.
It's interesting to me that dataclasses seemed to be a slimmed down attrs but in practice I find it replaces namedtuple not attrs For my use the key is how easily you can add simple conversion of values to attrs. IIRC this was intentionally omitted from dataclasses. For a 1-off using a factory with a dataclass is easy but repeated uses send me back to attrs
Most people don't need, say, a[-3] as an alias for a.field_name.
Otherwise, for those who want the standard library, use a dataclass with frozen=True for immutability.
Re: Python Modern Practices
#47Re: Python Modern Practices
#48I'm surprised the post doesn't mention uv, which did quite well on HN a few months ago. Any experience? https://github.com/astral-sh/uv https://news.ycombinator.com/item?id=39387641
Re: Python Modern Practices
#49what are the pros and cons with pydantic models vs data classes? i like the runtime validation in pydantic models. the pattern i landed on is that 1) only use primitive data types such as str, int, pydantic models and pandas dataframes to present data. 2) no classes with methods, no polymorphism, only use module functions.
The power of Pydantic models comes with benefits in terms of what they're able to do out of the box. But this comes at a significant cost of speed, which does matter for some applications. There are plenty of applications where it simply doesn't make sense to validate types every time you stand up a class.
Sure you can turn some of that off with Pydantic, etc, etc, but the fact that dataclasses don't require a third party install and are efficient and easy out of the box makes them useful and non-duplicative.
Re: Python Modern Practices
#50Earlier quoted context omitted.
Was going to comment the same thing. Would love to hear the author expand further on why not use Poetry. I've found it to be pretty solid and continue to use Poetry + Pyenv for all my projects, but open to hearing the case for PDM or Hatch.
I've never worked on a team that uses Poetry, but in my current company another team uses it, and I haven't found it really as slick as I would have imagined, primarily because you need to create a venv and install poetry into that before you even get started, which by that point why not just pip install the rest anyway? For standalone applications it just seems like an unnecessary extra step. It doesn't even mandate…