Python Forum
Search a List of Dictionaries by Key-Value Pair; Return Dictionary/ies Containing KV
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search a List of Dictionaries by Key-Value Pair; Return Dictionary/ies Containing KV
#17
@michalmonday - don't wont to start PEP war.
The point of the quote is - if you are joining developed (already in progress) project - consistency has precedent over PEP recommendations. In this case there is nothing to be consistent with...

And also, quote the full section

Quote:In particular: do not break backwards compatibility just to comply with this PEP!

Some other good reasons to ignore a particular guideline:

When applying the guideline would make the code less readable, even for someone who is used to reading code that follows this PEP.
To be consistent with surrounding code that also breaks it (maybe for historic reasons) -- although this is also an opportunity to clean up someone else's mess (in true XP style).
Because the code in question predates the introduction of the guideline and there is no other reason to be modifying that code.
When the code needs to remain compatible with older versions of Python that don't support the feature recommended by the style guide.

nothing of this apply...

In this case we have a snippet that is not part of developed project. @heiner just brings in idiom that they find better in other languages. OP is a relatively new to the language. Given all of this it's better to point out to them what python community consider best practice. It's up to them to decide if they want to follow or not. In long term (if they stick with the language) they will find PEP8 is de-facto considered community standard (i.e. if they follow it's more likely to be consistent when contribute to new and existing projects, than not)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Search a List of Dictionaries by Key-Value Pair; Return Dictionary/ies Containing KV - by buran - May-28-2019, 02:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sort a list of dictionaries by the only dictionary key Calab 2 652 Apr-29-2024, 04:38 PM
Last Post: Calab
  How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 8 15,822 Jan-05-2024, 08:30 PM
Last Post: sgrey
  Dictionary in a list bashage 2 608 Dec-27-2023, 04:04 PM
Last Post: deanhystad
  filtering a list of dictionary as per given criteria jss 5 758 Dec-23-2023, 08:47 AM
Last Post: Gribouillis
  Search Excel File with a list of values huzzug 4 1,310 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Access list of dictionaries britesc 4 1,123 Jul-26-2023, 05:00 AM
Last Post: Pedroski55
  How to add list to dictionary? Kull_Khan 3 1,057 Apr-04-2023, 08:35 AM
Last Post: ClaytonMorrison
  search a list or tuple for a specific type ot class Skaperen 8 1,996 Jul-22-2022, 10:29 PM
Last Post: Skaperen
  check if element is in a list in a dictionary value ambrozote 4 2,046 May-11-2022, 06:05 PM
Last Post: deanhystad
  Dictionary from a list failed, help needed leoahum 7 2,054 Apr-28-2022, 06:59 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020