News for hackers. Stuff that matters.

pizzaburek

Re:Stop Writing Dead Programs (Transcript) on Wednesday October 19, 2022 @10:12AM (#33262482)
For my personal Python projects I set a hard limit in the 94-96 range. That's wide enough that I actualy adhere to it instead of just ignoring it.

PEP8's and Google style guide's limits of 79 and 80 are way to narrow for a language with 4 space identation. However PEP says that "it is okay to increase the line length limit up to 99 characters" while Google's 80 is just a soft limit that can be broken in certain cases like long URLs.

Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @12:08PM (#19078102)
My personal opinion is that `list_` is among the worst possible variable names (together with `bar` and `foo`). It's non-descriptive, ugly, hard to recognize, looks scary to beginners and maybe worst of all it's easy to forget the underscore when typing.
Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @11:27AM (#19077610)
Yes, although there is a saying that "every generator is an iterator, but not every iterator is a generator". But then again generator has a bunch of methods (close, gi_frame, gi_yieldfrom, throw, gi_code, gi_running, send) that iterators don't have... I really don't know if <iter> is correct enough here, or should I use <genr> (that I don't use anywhere else and could be confusing).
Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @10:47AM (#19077208)

   MIND = BLOWN
Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @09:25AM (#19076552)
Will look into it, thanks for info.
Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @07:42AM (#19075826)
The whole cheatsheet is clearly in Python 3, where the same doc page that you linked states:

   Performing list(d) on a dictionary returns a list of all the keys used in the dictionary, in 
   insertion order ...
Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @07:25AM (#19075712)
Because it's rendered directly from README.md. That way it's easier for me, because I don't have to render it every time I make a change (I make a lot of little edits all the time), and project's Github page (https://github.com/gto76/python-cheatsheet) always has the same content as webpage.
Re:Comprehensive Python Cheatsheet (2018) on Monday February 04, 2019 @07:15AM (#19075660)

   >>> list(dict.fromkeys([3, 2, 1]))
   [3, 2, 1]
   >>> list(set([3, 2, 1]))
   [1, 2, 3]
Re:62% of Americans Have Under $1,000 in Savings, Survey Finds on Thursday October 08, 2015 @02:13PM (#10354765)
Too bad that a far more interesting discussion about Libertarian communism got flagged (or at least is not visible on a main page). https://news.ycombinator.com/item?id=10351830
Re:Comp Mark II: Simple 4-bit/1 Hz Virtual Computer on Sunday October 04, 2015 @10:52AM (#10327681)
It takes too long to compile otherwise, and I didn't want people to give up during compilation... You can run 'make optimize' to use -O1