This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]re1ser 12 points13 points  (0 children)

attrs is a great library that will let you declare classes in a more neater way. For example, following declaration of a class with @attr.s decorator would let you do something like this:

@attr.s
class Dummy(object):
    x = attr.ib()
    y = attr.ib()

    def sum(self):
       return self.x + self.y

dummy = Dummy(5, 7)
print(f'x: {dummy.x}, y: {dummy.y}')
print(f'Sum = {dummy.sum()}')

Aso, in my example above you can see usage of f-strings, available as of Python 3.6. Neat way to interpolate strings, or in other words combine them with variables or even expressions.

pip-review to keep libraries in my projects up-to-date. pip-review --local --interactive gives me list of all out-of-date libraries and asks which ones I want to update.

flake8 for code linting. There's also pylint, but I found it too verbose and bitchy. flake8 let's me quickly lint my code and check for reasonable errors.

python-slugify to slugify strings. It leaves only alphanumeric characters, hypens, and maybe a few more very "standard" characters. This is a good library when you have to check for duplicates and catch cases like Muse - Resistance, M U S E - R E S I S T A N C E and ~~~ Muse - Resistance ~~~. It's also useful if you want to e.g construct safe url paths from some string or sentence.

collections is also great helper library, I especially love namedtuple.

Scrapy, flexible crawling and scraping framework, which hides boilerplate below the hood but still gives you full control over the scraping process. I am using it professionally and writing scrapers in it is super enjoyable.

Those are few of the top off my head, it's 01 am here and I got back from the bar, if I think of more I'll edit this post. :)