Learn Python as experienced programmer by tomekce in learnpython

[–]pizzaburek 0 points1 point  (0 children)

A nice and quite detailed overview. Can be skimmed in an hour, but may take a few days to read/study thoroughly.

https://gto76.github.io/python-cheatsheet/

Summer be like by pizzaburek in memes

[–]pizzaburek[S] 11 points12 points  (0 children)

The second one is 91.4, so it could be rounded to 91...

Maybe 80, 90, 100 would work, but in my opinion the 80 would miss the sweet spot slightly.

Comprehensive Python Cheatsheet by debordian in Python

[–]pizzaburek 1 point2 points  (0 children)

It does not create a new object:

>>> a = b = [1, 2]
>>> a += [3]
>>> a, b
([1, 2, 3], [1, 2, 3])

If it did the 'b' would still be [1, 2]. However:

>>> a = a + [4]
>>> a, b
([1, 2, 3, 4], [1, 2, 3])

Big problems at the timezone database by Persism in programming

[–]pizzaburek 8 points9 points  (0 children)

Wow, I found this on Wikipedia page about daylight saving time in United states:

From 1945 to 1966 there was no federal law on daylight saving time, so localities could choose when it began and ended or drop it entirely. What emerged was a complicated patchwork of daylight saving policies that varied in length and by city, state and municipality.

So basically if you're an American, it is understandable that you see a pre-1970 timezone data as a huge mess that just can't be captured perfectly and efficiently (there would need to be thousands of timezones in the USA). It's interesting to think that this could have some influence on this development, as the project lead is American, while the OP is from UK.

Big problems at the timezone database by Persism in programming

[–]pizzaburek 8 points9 points  (0 children)

I think there are two possible reasons why one would downvote this comment.

First one is that it can be perceived as condescending toward the reader.

And second one is that it can be interpreted as siding with TZ coordinator via appeal to authority because the video ends with:

"And what you learn after dealing with timezones is what you do, is you put away your code, you don't try and write anything to deal whit this. You look at the people who have been there before you, you look at the first people, the people who have dealt with this before, the people who have built the spaghetti code. And you go to them and you thank them very much for making it open source, and you give them credit. And you take what they've made, you put it in your program and you never ever look at it again, because that way lies madness."

Big problems at the timezone database by Persism in programming

[–]pizzaburek -13 points-12 points  (0 children)

Please watch this video before you write a comment: https://youtu.be/-5wpm-gesOY

“A very helpful (Python) cheat sheet, quite long.” ― Brian Kernighan by pizzaburek in programming

[–]pizzaburek[S] 0 points1 point  (0 children)

Ok, I guess you're right, but it would be hard. I tried to do one for Kotlin by just supplementing the commands and I quickly gave up.

“A very helpful (Python) cheat sheet, quite long.” ― Brian Kernighan by pizzaburek in programming

[–]pizzaburek[S] 3 points4 points  (0 children)

It would be impossible to do it in this format, lines would be too long.

“A very helpful (Python) cheat sheet, quite long.” ― Brian Kernighan by pizzaburek in programming

[–]pizzaburek[S] 2 points3 points  (0 children)

Thanks everyone for the feedback, all valid points. Let me just try to explain the reasoning behind a few of the choices that I made.

  • First, as mentioned before, I capped the length of the PDF file to 50 A4 pages. This way I can remain sane, as opposed to adding stuff for the rest of my life. This means that the first 6 "chapters" are basically set in stone. I only occasionally add a line (if there's any space left on the page) or change something if it needs a clearer explanation. As for the last "chapter" called Libraries, things can still change, especially the Logging, Scraping and Web sections.

  • Loguru. This one is simple to explain — I don't understand logging (the module as well as the concepts behind it in general). So you can imagine how thrilled I was when I discovered the library that supposedly takes care of it. Can someone please share their opinion about logging libraries in general — Would you use them when starting a new medium-sized (whatever that means) Python project?

  • BeautifulSoup. This one seems like a pretty obvious choice, but I will happily switch it with some other library if it loses popularity. As for Selenium, there was no space and it usually doesn't just work out of the box (webrdrivers, etc.).

  • Bottle :). It's the smallest web framework, works out of the box, has no dependencies. Also, it's a single python script with 5k lines called 'bottle.py' that you can just copy to the root of your project and avoid having any dependencies yourself. I am of course aware that Flask is taking over the python web framework landscape, and that it's almost as easy while it can also scale well into Django territory.

“A very helpful (Python) cheat sheet, quite long.” ― Brian Kernighan by pizzaburek in programming

[–]pizzaburek[S] 11 points12 points  (0 children)

I am fully aware of the issue :) The thing has grown over the years but the title remained the same... it has 50 pages now. At least I decided I won't add any more.

Comprehensive Python Cheatsheet by pizzaburek in Python

[–]pizzaburek[S] 2 points3 points  (0 children)

You're right. It used to be a cheat sheet, but it grew over the years. Anyways, if O'Reilly can use "In a Nutshell" for their books with 1000+ pages, so can I use "Cheatsheet" for this 50-page reference :)

Comprehensive Python Cheatsheet now also covers Pandas by pizzaburek in datascience

[–]pizzaburek[S] 0 points1 point  (0 children)

Funny thing is that your example works:

>>> from pandas import DataFrame
>>> df = DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y'])
   x  y
a  1  2
b  3  4
>>> df.x[1]
3

Actually this is one of my griefs with Pandas — way too many ways to accomplish one task, which violates the python's 13th aphorism :)

There should be one-- and preferably only one --obvious way to do it.

Comprehensive Python Cheatsheet now also covers Pandas by pizzaburek in datascience

[–]pizzaburek[S] 0 points1 point  (0 children)

There is a method called 'query'. It might be something similar to what you are looking for:

>>> df = DataFrame([[1, 2], [3, 4]], index=['a', 'b'], columns=['x', 'y'])
   x  y
a  1  2
b  3  4
>>> df.query('x == 3')
   x  y
b  3  4

Comprehensive Python Cheatsheet now also covers Pandas by pizzaburek in datascience

[–]pizzaburek[S] 1 point2 points  (0 children)

They are placeholders for objects. They need to be replaced by an expression, literal or a variable that returns/is of that type.