Compare commits

...

410 Commits

Author SHA1 Message Date
Satwik Kansal d2673bba08
Merge pull request #334 from nifadyev/master
Change link to Russian translation (follow up to PR #325)
2024-05-13 19:00:49 +05:30
Vadim Nifadev be4811aeb7 Change link to Russian translation 2024-05-13 09:59:32 +03:00
Satwik Kansal 77af92f780
Merge pull request #325 from nifadyev/master
Add Russian translation
2024-05-10 11:03:39 +05:30
Satwik Kansal 394fa09b07
Merge branch 'master' into master 2024-05-10 11:02:03 +05:30
Satwik Kansal b251f1b150
Merge pull request #330 from Elkiwa/fix/links_and_typos
Fix some outdated links
2024-05-10 10:54:25 +05:30
Jeremy Cheng c7f3849c1a
doc: fix links and typos 2024-05-09 17:16:15 +09:00
Vadim Nifadev d70bf71cb6 Fix link to Russian translation 2024-05-04 20:06:24 +03:00
Vadim Nifadev 8db7d48ad6 Add new link to Russian translation 2024-05-04 20:04:21 +03:00
Vadim Nifadev 39595fc35f Revert README.md 2024-05-04 20:03:28 +03:00
Vadim Nifadev b6fd12efa2 Revert code-of-conduct.md 2024-05-04 20:01:51 +03:00
Vadim Nifadev 0ec5939713 Revert CONTRIBUTING.md 2024-05-04 19:58:56 +03:00
Vadim Nifadev 19fba38556 Fix links to Russian translation 2024-05-04 19:58:02 +03:00
Vadim Nifadev 16628ba071 Minor changes 2024-05-04 19:05:24 +03:00
Vadim Nifadev b1684aaf39 Move translated files to translations/ru-russian 2024-05-04 18:58:57 +03:00
Vadim Nifadev 6f35f00461 Translate Code of Conduct 2024-05-03 09:38:55 +03:00
Vadim Nifadev a2c5a17ca8 Remove extra level of headings from Table of Content 2024-04-29 06:50:59 +03:00
Vadim Nifadev fcb70ba7b9 Change translation for word "section" 2024-04-29 06:43:47 +03:00
Vadim Nifadev 9687de2a67 Translate CONTRIBUTING guide 2024-04-29 06:36:44 +03:00
Vadim Nifadev d0dd3ad2b7 Fix typos and spelling 2024-04-27 12:21:12 +03:00
Vadim Nifadev 5bbdcdd5a5 Translate CONTRIBUTORS, fix Markdown table syntax 2024-04-26 10:44:11 +03:00
Vadim Nifadev 2c623dd33a Actualize Table of contents 2024-04-25 11:12:29 +03:00
Vadim Nifadev f0afccc347 Translate License and remaining info example 2024-04-25 11:08:22 +03:00
Vadim Nifadev d7d7e970d7 Translate Aknowledgements and links example 2024-04-25 11:04:25 +03:00
Vadim Nifadev 05ad6cf2af Translate Contributing example 2024-04-25 11:00:05 +03:00
Vadim Nifadev f71b997a45 Translate Minor ones example 2024-04-24 17:00:05 +03:00
Vadim Nifadev 9e2508ae6a Translate Bloating instance dict's example 2024-04-24 16:28:57 +03:00
Vadim Nifadev 4b4951d755 Translate Slowing down dict lookups example 2024-04-24 16:21:51 +03:00
Vadim Nifadev 00e420fc51 Translate Let's make a giant string! example 2024-04-24 16:16:10 +03:00
Vadim Nifadev ebe5f59a9d Translate += is faster example 2024-04-24 16:06:24 +03:00
Vadim Nifadev 551b251c05 Translate Well, something is fishy example 2024-04-24 16:02:55 +03:00
Vadim Nifadev eab5d5968e Translate Teleportation example 2024-04-24 15:52:39 +03:00
Vadim Nifadev a5f1258275 Translate Skipping lines? example 2024-04-24 15:47:58 +03:00
Vadim Nifadev b5c20d02ea Translate Name mangling example 2024-04-24 15:39:50 +03:00
Vadim Nifadev 3b9d9bdcd1 Translate Inpinity example 2024-04-24 15:29:06 +03:00
Vadim Nifadev be9c3bb0ae Translate Ellipsis example 2024-04-24 12:24:34 +03:00
Vadim Nifadev 193c839163 Translate Yes, it exists example 2024-04-24 12:17:37 +03:00
Vadim Nifadev 664bb038d4 Translate Even Python understands that love is complicated example 2024-04-24 12:12:47 +03:00
Vadim Nifadev e2d0be0e2a Translate Meet Friendly Language Uncle For Life example 2024-04-24 12:09:26 +03:00
Vadim Nifadev 8ab55b7393 Translate Brace yourself example 2024-04-24 12:02:09 +03:00
Vadim Nifadev 124b0f027d Translate goto, but why? example 2024-04-24 11:58:51 +03:00
Vadim Nifadev 662b720b5c Translate Okay Python, can you make me fly? example 2024-04-24 11:47:58 +03:00
Vadim Nifadev 039adfa04a Translate Midnight time does not exist? example 2024-04-24 11:43:00 +03:00
Vadim Nifadev f84272fc5c Translate All sorted? example 2024-04-24 11:39:29 +03:00
Vadim Nifadev 8f60bc1d0b Translate Wild imports example 2024-04-24 11:35:57 +03:00
Vadim Nifadev bbb086a521 Translate Splitsies example 2024-04-24 11:27:46 +03:00
Vadim Nifadev 2043112a9d Translate Needles in a haystack example 2024-04-23 12:32:24 +03:00
Vadim Nifadev 0d28d47f08 Translate Rounding like a banker example 2024-04-23 12:18:36 +03:00
Vadim Nifadev a25fe26adc Translate Name resolution ignoring class scope example 2024-04-23 12:07:47 +03:00
Vadim Nifadev 40503d5ac5 Translate Same operands, different story example 2024-04-23 12:02:54 +03:00
Vadim Nifadev c2dd151ed5 Translate Catching the Exceptions example 2024-04-23 11:45:32 +03:00
Vadim Nifadev 7ce56da1d8 Translate Beware of default mutable arguments example 2024-04-23 11:39:15 +03:00
Vadim Nifadev 473e4229f2 Translate Loop variables leaking out example 2024-04-23 11:23:47 +03:00
Vadim Nifadev 3df9d0e4e3 Translate Lossy zip of iterators example 2024-04-23 11:07:40 +03:00
Vadim Nifadev e8cd593e62 Translate Deleting list item while iterating over it example 2024-04-23 10:58:11 +03:00
Vadim Nifadev 2aa7b37540 Translate The out of scope varibale example 2024-04-23 09:02:25 +03:00
Vadim Nifadev b1a8aadd70 Translate Stubborn operation example 2024-04-23 08:53:40 +03:00
Vadim Nifadev eccd68a4bd Translate Modifying dictionary while iterating over it example 2024-04-22 15:37:59 +03:00
Vadim Nifadev 3fc9e9e028 Translate Exceeds the linit for integer string conversion example 2024-04-22 15:24:31 +03:00
Vadim Nifadev c125f25fb5 Translate Let's see if you can guess this? example 2024-04-22 15:19:58 +03:00
Vadim Nifadev f96f5117c5 Translate The mysterious key type conversion example 2024-04-22 15:08:54 +03:00
Vadim Nifadev 58de881f93 Translate The dissapearing variable from outer scope example 2024-04-22 14:51:49 +03:00
Vadim Nifadev f2b1d7e8c2 Translate Mutating the immutable! example 2024-04-22 14:33:23 +03:00
Vadim Nifadev 495c840254 Translate Nan-reflexivity example 2024-04-22 14:21:35 +03:00
Vadim Nifadev 51d13b87cf Translate Yielding from... return example 2024-04-22 14:13:11 +03:00
Vadim Nifadev ecaab6dca1 Translate Yielding None example 2024-04-22 14:05:53 +03:00
Vadim Nifadev 972d1334fb Translate Class attributes and instance atributes example 2024-04-22 14:03:16 +03:00
Vadim Nifadev a0069d842e Translate What's wrong with booleans? example 2024-04-22 13:58:11 +03:00
Vadim Nifadev 8a1536986f Translate Half triple-quoted strings example 2024-04-22 12:19:28 +03:00
Vadim Nifadev 5eeb1053aa Translate Not knot example 2024-04-22 12:13:13 +03:00
Vadim Nifadev 293575b7c4 Translate String and backslashes example 2024-04-22 12:08:53 +03:00
Vadim Nifadev 191ea8343b Translate The surprising comma example 2024-04-22 12:02:32 +03:00
Vadim Nifadev 6e246d1487 Translate Methods equality and identity example 2024-04-21 10:57:44 +03:00
Vadim Nifadev a32eaca58f Translate Sublass relationships example 2024-04-21 10:41:17 +03:00
Vadim Nifadev 446a3a09bb Translate Chicken egg problem example 2024-04-21 10:32:21 +03:00
Vadim Nifadev 4576463fcc Translate Schrödinger's variable * example 2024-04-19 15:02:10 +03:00
Vadim Nifadev 361ac5f49b Translate A tic-tac-toe where X wins in the first attempt! example 2024-04-19 14:41:30 +03:00
Vadim Nifadev 497b9de72b Translate is not ...is (not ...) example 2024-04-19 14:31:02 +03:00
Vadim Nifadev 259fb23c7b Translate Evaluation time discrepancy example 2024-04-19 14:27:26 +03:00
Vadim Nifadev 654da92e88 Translate For what? example 2024-04-19 12:43:52 +03:00
Vadim Nifadev 83bdff8e33 Translate Keep trying example 2024-04-19 12:36:33 +03:00
Vadim Nifadev 47fa96c31a Translate Disorder within order example 2024-04-19 12:28:37 +03:00
Vadim Nifadev 2840050acb Translate Hash brownies and Deep down, we're all the same examples 2024-04-19 12:10:22 +03:00
Vadim Nifadev a7985b9edc Translate How not to use is operator example 2024-04-18 15:08:23 +03:00
Vadim Nifadev e2d6ee66cc Translate Be careful with chained operations example 2024-04-18 14:45:13 +03:00
Vadim Nifadev c91a6073fb Translate Strings can be tricky sometimes example to russian 2024-01-30 21:33:44 +03:00
Vadim Nifadev 86140390ad Translate First things first! example to russian 2024-01-25 17:01:26 +03:00
Vadim Nifadev b5b8b83c0a Translate usage to russian 2024-01-25 16:43:04 +03:00
Vadim Nifadev 489ccb18a7 Translate Structure of the Examples to russian 2024-01-25 16:34:40 +03:00
Vadim Nifadev 57987cc9d5 Translate header to russian
- As discussed with maintainer, create folder for storing translations
It will give more control, everything will be stored in 1 repository
and it eliminates possible deletion or making translation private
2024-01-25 11:19:34 +03:00
Satwik Kansal 86e78697fb
Merge pull request #320 from Sea-n/master
Invert logo color for dark theme
2023-10-08 01:25:20 +05:30
Sean 1b1b9d4b70 Invert logo color for dark theme 2023-10-05 16:20:26 +08:00
Satwik Kansal 19d4b07515
Merge pull request #314 from raigorx/patch-1
fix: Hashable import
2023-09-01 16:06:23 +05:30
Raigorx Hellscream ab82f9647c
Update README.md
https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable
2023-08-31 17:49:04 -04:00
Satwik Kansal f32e9d36e3
Merge pull request #312 from franciscouzo/master
Fix typo
2023-08-28 01:24:50 +05:30
Satwik Kansal 6010b97d90
Add link to Germany translation 2023-08-28 01:24:20 +05:30
Francisco Couzo acfcfa8808 Fix typo 2023-08-27 14:32:48 +00:00
Satwik Kansal ccf5be1a6f
Update README.md 2023-04-28 12:34:28 +05:30
Satwik Kansal a50839656c
Update README.md 2023-02-26 12:14:52 +05:30
Satwik Kansal f5f5208b12
Merge pull request #243 from vitorsrg/change/no-char-datatype
Improve string indexing result explanation
2022-12-05 09:17:50 +05:30
Satwik Kansal ea1e228407
Merge pull request #300 from frontdevops/patch-2
Update README.md
2022-11-01 14:51:09 +05:30
Alexander Mayorov d8258dbc96
Update README.md
Add new feature: Exceeds the limit for integer string conversion
2022-10-22 00:00:55 +04:00
Satwik Kansal 6a4cd34413
Merge pull request #299 from frontdevops/patch-1
Update README.md, Added a link to the Russian version
2022-09-18 19:40:01 +05:30
Alexander Mayorov feeb410009
Update README.md 2022-09-17 21:13:35 +04:00
Satwik Kansal 6213399144
Merge pull request #292 from jeffreykennethli/master
Update link and add parenthesis to chained operators section
2022-06-03 19:49:29 +05:30
jeffreykennethli d3a25fa14e Update link and add parenthesis to chained operators section 2022-06-03 10:15:21 -04:00
Satwik Kansal e9a49a5527
Merge pull request #290 from mattkohl-flex/master
Update README.md
2022-06-01 09:07:06 +05:30
Matt Kohl be377779b6
Update README.md
Grammatical fix
2022-05-31 15:36:12 +01:00
Satwik Kansal fe9ed47217
Update Spanish translation link 2022-05-11 22:27:47 +05:30
Satwik Kansal 00c5503712
Update link to Chinese translation 2022-04-04 16:02:41 +05:30
Satwik Kansal cd4d7c0e34
Update README.md 2022-01-18 00:00:02 +05:30
Satwik Kansal c8f300fd09
Merge pull request #277 from fluencydoc/trelent-documentation
Added docstrings to several undocumented functions
2021-12-23 12:51:30 +05:30
flencydoc 205c9ede01 Added docstrings to several undocumented functions. 2021-12-23 03:53:28 +00:00
Satwik Kansal f4f501a230
Merge pull request #276 from bwduncan/patch-1
Minor README fixups
2021-10-30 22:56:15 +05:30
bwduncan 043b83a722
Minor README fixups 2021-10-29 20:52:07 +01:00
Satwik Kansal 2e2d65a9ec
Add reference to Korean translation and fix a typo
Closes https://github.com/satwikkansal/wtfpython/issues/271
2021-08-09 18:13:25 +05:30
Satwik Kansal 086be4ed19
Update CONTRIBUTING.md 2021-05-12 00:19:21 +05:30
Satwik Kansal 9fc6db6215
Minor formatting fix 2021-05-11 02:04:55 +05:30
Satwik Kansal 897b915f11
Merge pull request #268 from LiquidFun/master
Add new snippet: banker's rounding
2021-05-11 02:03:45 +05:30
LiquidFun 6642876c64 Add new snippet: banker's rounding
Closes #267
2021-05-10 00:25:26 +02:00
Satwik Kansal b89710a415
Merge pull request #266 from sonlhcsuit/master
Fix small typo
2021-04-28 15:24:45 +05:30
sonlhcsuit aaa74c46a7 fixthings up 2021-04-28 16:10:51 +07:00
Satwik Kansal 1787b50422
Merge pull request #264 from Nucaranlaeg/patch-1
Fix small typo
2021-04-09 16:58:51 +05:30
Sam Benner 5525591601
Fix small typo 2021-04-07 18:46:23 -05:00
Satwik Kansal bfccb718de
Merge pull request #260 from JoseDeFreitas/add-spanish-translation
Add Spanish translation
2021-02-25 07:13:24 +00:00
José De Freitas 95a87484c5
Add myself as contributors 2021-02-24 19:50:43 -05:00
José De Freitas 6e187cf84b
Add Spanish translation reference 2021-02-24 19:49:05 -05:00
Satwik Kansal d6ba3a66a3
Merge pull request #256 from chrismilson/all-true-ation-readability
Update explanation for All-true-ation
2021-02-18 12:53:58 +00:00
Chris Milson f0bd1cb481 Update explanation for All-true-ation
#255
2021-02-18 19:05:40 +09:00
Satwik Kansal 70c03e9801
Merge pull request #254 from umutambyi-gad/master
📝 Fixed simple typos
2021-02-14 05:26:35 +00:00
Umutambyi Gad 9d0ad9ed98
📝 Fixed simple typos 2021-02-14 00:55:41 +01:00
Satwik Kansal 48256e1fe8
Merge pull request #247 from abdnh/patch-1
Fix typo
2021-02-03 07:24:33 +00:00
abdo de4b851c72
Fix typo
getclosurevals -> getclosurevars
2021-02-03 02:01:07 +03:00
Satwik 048a620502 Update notebook 2021-01-17 13:56:41 +05:30
Satwik 2bc1cd61c1 Update the sticy output example
Closes https://github.com/satwikkansal/wtfpython/issues/245
2021-01-17 13:55:35 +05:30
Vitor Santa Rosa d06fcbff1b
Improve string indexing result explanation 2020-11-28 23:25:16 -03:00
Satwik Kansal c954b71f67
Merge pull request #241 from Jongy/methods
Add section on methods equality and identity
2020-11-08 11:03:34 +05:30
Yonatan Goldschmidt 314de9a30b Merge "Non-reflexive class method" into new example 2020-11-08 01:41:59 +02:00
Yonatan Goldschmidt f13b98e6d5 Add section on methods equality and identity
Closes: #233
2020-11-05 01:11:18 +02:00
Satwik Kansal 902ca179eb
Merge pull request #235 from imba-tjd/patch-1
Change Py2 docs to 3
2020-10-27 13:54:16 +05:30
Satwik Kansal 9c42b920ad
Merge pull request #236 from imba-tjd/patch-2
Use https links
2020-10-27 13:53:30 +05:30
Satwik Kansal bb8ce63f68
Merge pull request #237 from imba-tjd/patch-3
fix indentation
2020-10-27 13:50:27 +05:30
谭九鼎 ac63a4fb3a
fix indentation 2020-10-27 12:19:37 +08:00
谭九鼎 c824ed7813
Update README.md 2020-10-27 11:10:44 +08:00
谭九鼎 e5b519149d
Use https links 2020-10-27 11:10:03 +08:00
谭九鼎 435fd5f49e
Change Py2 docs to 3 2020-10-27 11:07:47 +08:00
Satwik Kansal f082e9f22a
Update README.md 2020-10-24 21:57:35 +05:30
Satwik Kansal 33bcfa744a
Minor changes to nonlocal explanation
Closes https://github.com/satwikkansal/wtfpython/issues/193
2020-10-05 20:42:16 +05:30
Diptangsu Goswami 7525e800b8
#193 The out of scope variable, nonlocal (#228)
* fixed link to CONTRIBUTORS.md

* The out of scope variable, nonlocal, #193

* added myself to CONTRIBUTORS.md :D

* Update CONTRIBUTORS.md

* added entry in index

* merged nonlocal to `the out of scope variable` example

Also removed the extra entry from the main index.
2020-10-05 20:35:20 +05:30
Satwik Kansal 9b3f86958a
Merge pull request #227 from amitShindeGit/patch-1
Update README.md
2020-10-01 20:13:07 +05:30
AmitShinde d4ad5a0643
Update README.md 2020-10-01 19:41:25 +05:30
Satwik Kansal 9e28e00123
Update CONTRIBUTING.md 2020-10-01 16:56:40 +05:30
Satwik Kansal 27b66b4f31
Fix typo and minor changes 2020-09-17 17:02:56 +05:30
Satwik Kansal 19e6b7da57
Merge pull request #221 from cl0ne/patch-1
Add link to Python FAQ to "Mutating the immutable"
2020-09-17 07:39:11 +05:30
Vladislav Glinsky be2d537a05
Add link to Python FAQ to "Mutating the immutable" 2020-09-17 03:38:41 +03:00
Satwik 7d06e7b5c1 Add a meme 2020-08-27 00:47:08 +05:30
Satwik Kansal a3baf043bd
Add a note about the asterisks
Fixes https://github.com/satwikkansal/wtfpython/issues/219
2020-08-24 20:10:59 +05:30
Satwik Kansal 03a035a89d
Merge pull request #216 from Jongy/instance-dict-size
Add "bloating instance dicts" section
2020-08-01 17:54:21 +05:30
Yonatan Goldschmidt 87906b9b2f Fix anchor name of "slowing down dict lookups" 2020-07-31 12:34:12 +03:00
Yonatan Goldschmidt ee0696b676 Add "bloating instance dicts" section
Closes: #210
2020-07-31 12:34:12 +03:00
Satwik f72d7325fa Fix uuid and toc 2020-07-10 22:34:22 +05:30
Satwik ee70d52fe4 Add Jongy to the contributors list 2020-07-10 22:30:30 +05:30
Satwik f97cbdd919 Minor updates to slowinig down dict lookups example 2020-07-10 22:28:44 +05:30
Satwik Kansal 098d71f348
Merge pull request #209 from Jongy/dict-loopup-performance
Add "dict lookup performance" section
2020-07-10 22:17:41 +05:30
Yonatan Goldschmidt 0b74f9ba5d Add "dict lookup performance" section
Closes: #208
2020-07-04 18:45:45 +03:00
Satwik Kansal 7457ffb848
Update README.md 2020-06-25 16:28:58 +05:30
Satwik 3ba87fea65 Add link 2020-06-15 16:03:06 +05:30
Satwik 32f14a7e16 Add Vietnamese translation
Closes https://github.com/satwikkansal/wtfpython/issues/195
2020-06-14 10:40:30 +05:30
Satwik Kansal 14600fd19b
Merge pull request #204 from myrmica-habilis/master
Add two missing outputs in the walrus examples
2020-05-16 17:57:52 +05:30
Satwik Kansal 5edef33cae
Merge pull request #203 from secworks/master
'less than 21' is the correct expression.
2020-05-02 21:50:04 +05:30
Joachim Strömbergson 9ff40de544
'less than 21' is the correct expression. Could slso be 'less or equal to 20'. 2020-05-02 08:54:24 +02:00
Satwik Kansal 0684777fa3
Merge pull request #199 from LeafyLi/master
Replace http link with https
2020-04-26 23:38:43 +05:30
zenglifa@msu.edu f735fe3116 Replace http link with https 2020-04-25 15:37:50 -04:00
Satwik Kansal 669ff8c30e
Merge pull request #192 from Jongy/correctify-stubborn-del-explanation
Correctify explanation of "Stubborn `del` operation"
2020-03-25 22:40:42 +05:30
Yonatan Goldschmidt 67f743eddd Correctify explanation of Stubborn `del` operation 2020-03-24 23:12:47 +02:00
myrmica-habilis 78cb5f39f5 Update README.md
- assignment expressions are evaluated and printed by the REPL
2020-03-20 11:00:29 +01:00
Satwik Kansal e9b04d33f7
Merge pull request #181 from Haksell/correct-six-typos
Correct six typos
2020-02-16 02:31:40 +05:30
Satwik Kansal 733061f90d
Merge pull request #183 from Pradhvan/UpdatingDoc
README.md: Update Python version in 'Modifying a dictionary while ite…
2020-02-15 14:35:55 +05:30
Pradhvan 184df9f99d README.md: Update Python version in 'Modifying a dictionary while iterating over it' example 2020-02-15 14:30:05 +05:30
Haksell a4af8a4e0c Correct six typos 2020-02-15 09:04:24 +01:00
Haksell 50265e91fc Correct six typos 2020-02-15 09:03:08 +01:00
Satwik Kansal 6cebc952c3
Fix minor typo in the "is not" example 2020-01-20 14:23:20 +05:30
Satwik Kansal bd7cd4334c
Merge pull request #175 from larsks/fix/is-not
Extend the explanation of the "is not ..." section
2020-01-20 14:20:57 +05:30
Satwik Kansal 97c10e6fda
Merge pull request #177 from larsks/fix/quotes
Clarify for quoting examples
2020-01-20 14:20:22 +05:30
Satwik Kansal 8e6c850f30
Merge pull request #178 from larsks/fix/bad-logic
Fixed logic error in "Beware of default mutable arguments!"
2020-01-20 14:18:41 +05:30
Satwik Kansal e74ccb79d0
Merge pull request #176 from larsks/fix/grammar
A minor grammar correction
2020-01-20 14:17:48 +05:30
Satwik Kansal daf156abf5
Merge pull request #174 from larsks/spelling
Fix spelling (found -> find)
2020-01-20 14:13:23 +05:30
Lars Kellogg-Stedman 16c90f9b24 Fixed logic error in "Beware of default mutable arguments!"
The example showing how using None as a default argument is used
instead of a mutable default argument had reversed logic.  It would
set default_arg to [] whenever the caller passed a non-None argument.
2020-01-19 12:03:30 -05:00
Lars Kellogg-Stedman 3e99005ae4 Clarify for quoting examples
The example of the use of backslash to escape a double-quote makes
more sense when used inside a double-quoted string. If the string is
quoted with single quotes, one could of course just write 'wt"f'
withouth requiring any escaping.
2020-01-19 10:19:17 -05:00
Lars Kellogg-Stedman 8370f3a3b9 A minor grammar correction 2020-01-19 10:16:47 -05:00
Lars Kellogg-Stedman f20be4cfc4 Extend the explanation of the "is not ..." section
I thought that the explanation for "'something' is (not None)" could
be a little more explicit.
2020-01-19 10:13:50 -05:00
Lars Kellogg-Stedman 00a1228ca3 Fix spelling (found -> find)
Noticed a minor spelling error while reading through this fantastic
document.
2020-01-19 10:04:41 -05:00
Satwik Kansal de113d2491
Merge pull request #170 from art049/master
Wild imports typo
2020-01-12 00:34:12 +05:30
Satwik Kansal ffb1599458
Merge pull request #171 from entwanne/needles-haystack-example-6
Fix explanation for 6th example of "Needles in a Haystack"
2020-01-12 00:33:30 +05:30
Antoine Rozo 5f8067df42 Fix explanation for 6th example of "Needles in a Haystack" 2020-01-10 14:39:29 +01:00
Arthur Pastel 30a6623ccd
Wild imports typo 2020-01-10 12:43:16 +01:00
Satwik Kansal 83cac75f41
Merge pull request #169 from kerolloz/master
Fix issue creating link
2020-01-10 14:40:07 +05:30
Kerollos Magdy d1a4144143
Fix issue creating link 2020-01-09 13:12:14 +02:00
Satwik Kansal 3e98cf1ceb
Merge pull request #168 from chrisguox/update-docs
Fixed example input error
2020-01-09 14:50:47 +05:30
Chris Guo 43679ebd1e fix: fix example input error 2020-01-08 00:09:25 +08:00
Satwik Kansal 0d65c00bb6
Merge pull request #166 from louisguitton/patch-1
Fix typo in 'Strings can be tricky sometimes'
2020-01-06 19:39:21 +05:30
Satwik Kansal 255b9a574b
Merge pull request #167 from OdinTech3/patch-1
Fixed mispelling
2020-01-06 19:38:49 +05:30
Nick Muoh 68f6e0217c
Fixed mispelling 2020-01-04 19:49:32 -05:00
Louis Guitton 3d64252310
Fix typo in 'Strings can be tricky sometimes' 2020-01-04 17:16:09 +01:00
Satwik 185d60c1b6 Update hash brownies explanation and the logical order of few examples.
Addresses https://github.com/satwikkansal/wtfpython/pull/76
2019-12-31 16:10:45 +05:30
Satwik Kansal 1b3b2e6c71
Fix typo
Closes https://github.com/satwikkansal/wtfpython/issues/165
2019-12-30 19:20:31 +05:30
Satwik Kansal f98bd4363f
Fix typo
Closes https://github.com/satwikkansal/wtfpython/issues/164
2019-12-30 13:05:38 +05:30
Satwik 2c910351b7 Fix relevant typos detected by codespell
Closes https://github.com/satwikkansal/wtfpython/issues/161
2019-12-27 20:05:17 +05:30
Satwik 9a2718ae3a Fix typo
Closes https://github.com/satwikkansal/wtfpython/issues/162
2019-12-27 20:05:17 +05:30
Satwik Kansal 183e0d9ee5
Merge pull request #160 from vrthra/patch-1
Make sure that default_arg is not passed rather than checking for fal…
2019-12-25 19:21:24 +05:30
Rahul Gopinath 2f2fcf87bc
Make sure that default_arg is not passed rather than checking for falsity
```
if not default_arg:
    ...
```
fails when `default_arg` can be assigned and still be false (implementing a `__bool__` or `__len__` etc). You dont want to overwrite the passed values.
2019-12-25 10:10:53 +01:00
Satwik Kansal 99280f57a0
Merge pull request #159 from boppreh/patch-1
Update README.md
2019-12-25 01:23:18 +05:30
Satwik 7c85a73442 Move discussion thread links to the links section 2019-12-25 00:09:55 +05:30
BoppreH e4f340281c
Update README.md
Fix incorrect output for f-string.
2019-12-24 14:02:22 -03:00
Satwik 6c0ed6e7c5 Add discussion links 2019-12-24 21:47:59 +05:30
Satwik dcc2e6a3d8 Update links 2019-12-24 20:09:12 +05:30
Satwik a1b4f8d521 Put the pdf link back on demand 2019-12-23 23:13:08 +05:30
Satwik Kansal 328168c86f
Merge pull request #158 from rscircus/patch-1
Fix typo in dictionary section
2019-12-23 21:25:38 +05:30
puɐloɹ ʇɹǝqƃǝᴉs 73a1248d04
Fix typo in dictionary section 2019-12-23 16:31:44 +01:00
Satwik a39792bd4b Remove kofi link 2019-12-23 16:27:27 +05:30
Satwik bd45175405 Point colab notebook to the master 2019-12-23 15:59:59 +05:30
Satwik 438f52c3e9 Update notebook with recent changes 2019-12-23 15:58:49 +05:30
Satwik b3387c9dc7 Add indent to the dump for better diff 2019-12-23 15:58:25 +05:30
Satwik Kansal ad39ef8625
Merge pull request #155 from yaph/patch-1
Make hashtags in Twitter link work
2019-12-23 15:33:22 +05:30
Satwik Kansal df8baf9941
Merge pull request #157 from saveriomiroddi/sav-correct_typos
Correct some typos
2019-12-23 15:32:32 +05:30
Saverio Miroddi e35642ed05 Correct some typos
Corrected a handful of typos.
2019-12-23 10:31:40 +01:00
Ramiro Gómez f8aa17c8ba
Make hashtags in Twitter link work
Change URL parameter from `hastags` to  `hashtags`.
2019-12-22 21:11:25 +01:00
Satwik Kansal b8e4cd1693
Merge pull request #154 from satwikkansal/3.0
🎉
2019-12-21 22:38:00 +05:30
Satwik 76d98d9138 Fix line break 2019-12-21 22:12:56 +05:30
Satwik d59db75b4c Add link to other modes 2019-12-21 22:11:55 +05:30
Satwik 734360ff59 Add team trees 2019-12-21 20:38:18 +05:30
Satwik 2fb14be424 Update the notebook 2019-12-21 20:06:48 +05:30
Satwik 483496d97a Aesthetical changes 2019-12-21 20:00:21 +05:30
Satwik f914194a87 Add instructions 2019-12-21 19:39:49 +05:30
Satwik 12b2fc008e Fix TOC and links 2019-12-21 19:39:28 +05:30
Satwik 1b1a5bc10d Add generated notebook 2019-12-21 00:16:34 +05:30
Satwik 49ed35e099 Add hosted notebook instructions 2019-12-21 00:16:19 +05:30
Satwik 56c0347dd1 Minor correction 2019-12-20 23:56:35 +05:30
Satwik 7006084c12 Fix URLs 2019-12-20 23:39:10 +05:30
Satwik a9cbcdd95a Rename json_generator to notebook_generator 2019-12-20 23:27:25 +05:30
Satwik 9fb381c4f3 Fix soo many typos, sigh. 2019-12-20 02:05:53 +05:30
Satwik 264b93a633 Remove every existence of npm 2019-12-20 01:28:49 +05:30
Satwik a7471ca737 Merge branch 'master' into 3.0 2019-12-20 01:26:14 +05:30
Satwik 6e5278e30a More cleanup and another version bump 2019-12-20 01:25:00 +05:30
Satwik 8e798af4fc Ignore IDE files and Bump npm version 2019-12-20 01:25:00 +05:30
Satwik 176bcc8a25 Bump npm version 2019-12-20 01:25:00 +05:30
Satwik 44e885a09c Ignore unnecessary stuff in npm package 2019-12-20 01:25:00 +05:30
Satwik dd3c62d49d Remove npm related stuff 2019-12-20 01:14:09 +05:30
Satwik 68904d3f6f Remove mention of npm package 2019-12-20 01:13:18 +05:30
Satwik f30181a54e Merge remote-tracking branch 'origin/master' into 3.0 2019-12-20 00:52:52 +05:30
Satwik 0c461ee66a Ignore IDE files 2019-12-20 00:36:19 +05:30
Satwik b96e2fb6a9 Respect the read_only rule 2019-12-20 00:31:42 +05:30
Satwik Kansal 2f383f8dc0
Merge pull request #152 from sobolevn/patch-2
Adds wemake-python-styleguide
2019-12-20 00:29:59 +05:30
Satwik ef68d1b482 Add markers for new content 2019-12-20 00:27:21 +05:30
Satwik 8522964105 Read only meta tag, and minor fixes 2019-12-19 21:47:20 +05:30
Satwik f3c7afebd7 Minor corrections 2019-12-19 15:49:52 +05:30
Satwik d7c8b73731 Remove lobby link 2019-12-19 15:49:40 +05:30
Nikita Sobolev e899e38553
Adds wemake-python-styleguide
Link: https://github.com/wemake-services/wemake-python-styleguide
Docs: https://wemake-python-stylegui.de/en/latest/
2019-12-01 15:51:18 +03:00
Satwik d9e71224e2 Add minor example 2019-11-07 17:27:52 +05:30
Satwik 65c8a9ef8c Update contributors list. 2019-11-04 23:19:13 +05:30
Satwik 888c9e1261 Fix indenting, add a minor example, and update contributing message 2019-11-04 23:18:52 +05:30
Satwik e18e56eba3 Working experimental notebook generator 2019-11-03 00:54:27 +05:30
Satwik 2cd7e3fccd Fix broken links 2019-11-03 00:54:04 +05:30
Satwik 2161c48e8e Parse nested examples 2019-11-02 23:25:58 +05:30
Satwik 321e7196d0 Some change of example orders 2019-11-02 23:02:47 +05:30
Satwik 08302ba0c8 Ignore environment and checkpoint files 2019-10-31 23:51:47 +05:30
Satwik 2160dad717 Use dynamic path instead of fixed one 2019-10-31 23:50:50 +05:30
Satwik a553ea0070 Some meta tags and corrections after running on Python 3.8 2019-10-31 23:50:23 +05:30
Satwik d4021862f0 Add no longer working note. 2019-10-31 01:07:04 +05:30
Satwik 1d467287ef Move stuff to obsolete package.
Not deleting it for quick future reference for contributors and myself.
2019-10-31 01:05:23 +05:30
Satwik 0160d5019b Remove un-necessary file 2019-10-31 01:01:45 +05:30
Satwik a5593c42e0 Update comments 2019-10-31 00:59:57 +05:30
Satwik 7df49cd818 Change section name to Slippery Slopes and modify nan-reflexivity example 2019-10-31 00:51:48 +05:30
Satwik af6d1799d9 Add more details to compile time optimisation snippets. 2019-10-30 23:24:07 +05:30
Satwik 5bf46f66af Bring compiler optimisation stuff back, and add minor updates. 2019-10-30 23:04:50 +05:30
Satwik 312c5d542c Add non reflexive class method and the matmul operator examples 2019-10-30 01:03:07 +05:30
Satwik 4af4f9debf Add more examples 2019-10-29 23:53:42 +05:30
Satwik b10b3ad346 Add another needle-like example
Closes https://github.com/satwikkansal/wtfpython/issues/137
2019-10-29 22:31:58 +05:30
Satwik 133baac11c Add minor snippet related to output buffer flushing
Closes https://github.com/satwikkansal/wtfpython/issues/140
2019-10-29 22:31:58 +05:30
Satwik 34e97d53fb Add example related to the Walrus operator
Closes https://github.com/satwikkansal/wtfpython/issues/145
2019-10-29 01:07:28 +05:30
Satwik bd798f2966 Update alignment 2019-10-28 22:51:03 +05:30
Satwik ce8adb0417 Update TOC 2019-10-28 22:48:15 +05:30
Satwik 28bcbfd311 More changes to order and aesthetics 2019-10-28 22:40:32 +05:30
Satwik 82c37ccb32 Perhaps some editing 2019-10-28 22:17:26 +05:30
Satwik 43355e2498 Merge branch 'master' into 3.0 2019-10-28 19:34:20 +05:30
Satwik 45a2cb5ddd Merge remote-tracking branch 'origin/3.0' into 3.0 2019-10-28 19:30:53 +05:30
Satwik d823aa9220 Ignore DS_Store 2019-10-28 19:23:06 +05:30
Satwik Kansal 8135cbb99c
README.md Fix typos 2019-10-25 19:52:52 +05:30
monujee bef3f2a33d
Update README.md
Typo corrected.
2019-10-25 14:28:25 +05:30
Satwik Kansal f8acf49d05
Update README.md 2019-10-09 18:48:41 +05:30
Satwik Kansal 88ccda2bcd
Merge pull request #141 from mitcom/space-invader-operator
Add space-invader operator case
2019-10-09 18:43:28 +05:30
mitcom d143f972b8 Add space-invader operator case 2019-10-06 13:12:35 +02:00
Satwik Kansal fc491c5dd6 Commit insert_ids script 2019-09-13 15:25:57 +05:30
Satwik Kansal 6223715725 change order 2019-09-13 15:25:57 +05:30
Satwik Kansal 2a1c28ee4d Fix toc 2019-09-13 15:25:57 +05:30
Satwik Kansal d6b735768c Remove asterisks and carets from titles 2019-09-13 15:24:43 +05:30
Satwik Kansal e8fcce27c2 Fix uuid comments 2019-09-13 15:24:01 +05:30
Satwik Kansal 45638fa6b1 Add uuids to examples 2019-09-13 15:24:01 +05:30
Satwik Kansal 162458c88e Update TOC 2019-09-13 15:24:01 +05:30
Satwik Kansal edeb98f406 Update the booleans example
Fix some technically incorrect terminologies and snippets.
2019-09-13 15:22:40 +05:30
Satwik Kansal 9939ff6a1f Add new example: Wild imports 2019-09-13 15:22:40 +05:30
Satwik Kansal 6934d94222 Some minor changes, and add assertion example 2019-09-13 15:22:01 +05:30
Satwik Kansal 7b22f84f97 Add new example: Disorder within order
Resolves https://github.com/satwikkansal/wtfpython/issues/77
2019-09-13 15:21:05 +05:30
Satwik Kansal 055bd0246d New example: Lossy zip of iterators
Resolves https://github.com/satwikkansal/wtfpython/issues/121
2019-09-13 15:21:05 +05:30
Satwik Kansal 330f7da1d3 String can be tricky: Remove outdated snippet
Related to https://github.com/satwikkansal/wtfpython/issues/120
2019-09-13 15:21:05 +05:30
Satwik Kansal ae05101d70 Brace yourself: Add to explanation
Resolves https://github.com/satwikkansal/wtfpython/issues/114
2019-09-13 15:18:48 +05:30
Satwik Kansal 2295fb24b7 Let's make a giant string: Use %timeit for measuring time
Fixes https://github.com/satwikkansal/wtfpython/issues/106
2019-09-13 15:18:48 +05:30
Satwik Kansal f365271df3 New example: The chicken-egg problem
Closes https://github.com/satwikkansal/wtfpython/issues/101
2019-09-13 15:18:48 +05:30
Satwik Kansal 9b3b367b45 Update example "is is not what it is"
Related to https://github.com/satwikkansal/wtfpython/issues/100
2019-09-13 15:18:48 +05:30
Satwik Kansal 5373d0f184 Add example: Ellipsis
Resolves https://github.com/satwikkansal/wtfpython/issues/96
2019-09-13 15:18:48 +05:30
Satwik Kansal 89c56c2366 Let's meet Friendly Language Uncle For Life: Add notes for non-interactive evn
Resolves https://github.com/satwikkansal/wtfpython/issues/94
2019-09-13 15:18:48 +05:30
Satwik Kansal e3118ed4da Add new snippet: Splitsies
Resolves https://github.com/satwikkansal/wtfpython/issues/80
2019-09-13 15:18:48 +05:30
Satwik Kansal f3b96e4d7f Expand strings and backslashes
Resolves https://github.com/satwikkansal/wtfpython/issues/69
2019-09-13 15:18:48 +05:30
Satwik Kansal a0832c4459 Modifying a dictionary while iterating over it: Add note
Resolves https://github.com/satwikkansal/wtfpython/issues/53
2019-09-13 15:18:48 +05:30
Satwik Kansal dbbabbe564 Update evaluation time discrepency example: Add another snippet
Resolves https://github.com/satwikkansal/wtfpython/issues/41
2019-09-13 15:18:48 +05:30
Satwik Kansal f8a7d38b70 Update content.md 2019-09-13 15:18:47 +05:30
Satwik Kansal 810dbe1582 Some hideous typora corrections and a new snippets added
Also closes https://github.com/satwikkansal/wtfpython/issues/73
2019-09-13 15:18:47 +05:30
Satwik Kansal a5e7cd7cf8 Add todos 2019-09-13 15:18:47 +05:30
Satwik Kansal efdac8f9ca Get the generator in a working state 2019-09-13 15:18:47 +05:30
Satwik Kansal 3479b2befb Use absolute path for the pager.
Fixes https://github.com/satwikkansal/wtfpython/issues/119
2019-09-13 15:18:47 +05:30
Satwik Kansal 290921fe12 Add json generator 2019-09-13 15:16:18 +05:30
Satwik 03719dea45 Add few pointers for contributing well 2019-09-13 15:15:31 +05:30
Satwik c5665da81d Nitpicks in the new example 2019-09-13 15:01:45 +05:30
Satwik Kansal 0fa3067e5f
Merge pull request #138 from scidam/master
New snippet: yielding from... return!
2019-09-13 14:33:20 +05:30
Kislov Dmitry cedbfba829 New snippet: yielding from... return! 2019-09-13 12:03:27 +10:00
Satwik Kansal 9f5dbbe4e9
Merge pull request #134 from sobolevn/patch-1
Fixes code highlight
2019-08-04 12:56:24 +05:30
Nikita Sobolev b0622a10ad
Fixes code highlight 2019-07-30 00:34:58 +03:00
Satwik Kansal ffe6438576 Commit insert_ids script 2019-07-21 18:57:01 +05:30
Satwik Kansal 772a96c36f change order 2019-07-13 22:41:27 +05:30
Satwik Kansal d3157d61a3 Fix toc 2019-07-08 22:24:37 +05:30
Satwik Kansal 4618bed5f6 Remove asterisks and carets from titles 2019-07-08 22:01:41 +05:30
Satwik Kansal 863e1f4512 Fix uuid comments 2019-07-08 03:00:33 +05:30
Satwik Kansal 98701351c6 Add uuids to examples 2019-07-08 02:54:49 +05:30
Satwik Kansal c30e0d2ed6 Merge remote-tracking branch 'origin/master' into 3.0 2019-07-08 02:33:38 +05:30
Satwik Kansal 4d8e5795a3 Update TOC 2019-07-07 22:18:35 +05:30
Satwik Kansal 96455422ef Update the booleans example
Fix some technically incorrect terminologies and snippets.
2019-07-07 22:17:33 +05:30
Satwik Kansal e6eac17ef5
Merge pull request #126 from cclauss/patch-2
Use ==/!= to compare str, bytes, and int literals
2019-07-06 13:34:28 +05:30
Satwik Kansal 151d0ec93a
Merge pull request #127 from zachkirsch/patch-1
Fix typos in README.md, CONTRIBUTORS.md
2019-07-03 22:29:39 +05:30
Zach Kirsch 12a1ac10cb Fix github URL typos in CONTRIBUTORS.md 2019-07-03 11:46:31 -04:00
zachkirsch e611f24e7f
Change constant-folding max from <20 to <=20 2019-07-03 11:39:57 -04:00
cclauss a4776a6b67
Use ==/!= to compare str, bytes, and int literals
Identity is not the same thing as equality in Python.

$ __[flake8](http://flake8.pycqa.org)  . --count --select=E9,F63,F7,F82 --show-source --statistics__
```
    if resp.status_code is 200:
       ^
1     F632 use ==/!= to compare str, bytes, and int literals
1
```
2019-07-02 15:36:23 +02:00
Satwik Kansal a83349d0cc
Merge pull request #124 from cclauss/patch-1
Add automated testing using Travis CI
2019-07-02 17:45:11 +05:30
cclauss 14e03a3766
Add automated testing using Travis CI
The repo switch would need to be turned on at https://travis-ci.com/satwikkansal/wtfpython to enable free automated testing of all code changes.
2019-06-28 07:03:12 +02:00
Satwik Kansal 8b4bbb2196 Add new example: Wild imports 2019-06-11 00:43:32 +05:30
Satwik Kansal c6e0d795ff Some minor changes, and add assertion example 2019-06-10 23:22:08 +05:30
Satwik Kansal 362447a5d2 Add new example: Disorder within order
Resolves https://github.com/satwikkansal/wtfpython/issues/77
2019-06-10 00:14:01 +05:30
Satwik Kansal 4d5a2f0d97 New example: Lossy zip of iterators
Resolves https://github.com/satwikkansal/wtfpython/issues/121
2019-06-09 19:45:13 +05:30
Satwik Kansal bf967b0332 String can be tricky: Remove outdated snippet
Related to https://github.com/satwikkansal/wtfpython/issues/120
2019-06-09 17:56:36 +05:30
Satwik Kansal 80a969a556 Brace yourself: Add to explanation
Resolves https://github.com/satwikkansal/wtfpython/issues/114
2019-06-09 17:34:50 +05:30
Satwik Kansal 2bfa6d2e5b Let's make a giant string: Use %timeit for measuring time
Fixes https://github.com/satwikkansal/wtfpython/issues/106
2019-06-09 03:59:09 +05:30
Satwik Kansal 9ea7ab0c5a New example: The chicken-egg problem
Closes https://github.com/satwikkansal/wtfpython/issues/101
2019-06-09 00:07:02 +05:30
Satwik Kansal 72e39d3248 Update example "is is not what it is"
Related to https://github.com/satwikkansal/wtfpython/issues/100
2019-06-08 23:25:37 +05:30
Satwik Kansal 6164ce065d Merge remote-tracking branch 'origin/master' into 3.0 2019-06-08 22:41:05 +05:30
Satwik Kansal 85352fc45d Add example: Ellipsis
Resolves https://github.com/satwikkansal/wtfpython/issues/96
2019-06-08 16:30:53 +05:30
Satwik Kansal a33f715b26 Let's meet Friendly Language Uncle For Life: Add notes for non-interactive evn
Resolves https://github.com/satwikkansal/wtfpython/issues/94
2019-06-08 14:49:59 +05:30
Satwik Kansal c52919b9ec Add new snippet: Splitsies
Resolves https://github.com/satwikkansal/wtfpython/issues/80
2019-06-08 14:21:22 +05:30
Satwik Kansal 092dd096bf Expand strings and backslashes
Resolves https://github.com/satwikkansal/wtfpython/issues/69
2019-06-08 02:53:53 +05:30
Satwik Kansal e0cb30bf3b Modifying a dictionary while iterating over it: Add note
Resolves https://github.com/satwikkansal/wtfpython/issues/53
2019-06-08 00:41:58 +05:30
Satwik Kansal bc68ae0ff3 Update evaluation time discrepency example: Add another snippet
Resolves https://github.com/satwikkansal/wtfpython/issues/41
2019-06-08 00:23:57 +05:30
Satwik Kansal 3806284f78 Update content.md 2019-06-07 23:59:19 +05:30
Satwik Kansal f03f7dcad9 Some hideous typora corrections and a new snippets added
Also closes https://github.com/satwikkansal/wtfpython/issues/73
2019-06-07 23:59:06 +05:30
hippie 31dcd9b062 add encoding (#122)
if not set encoding attr,there maybe have some exceptions when open reading.
2019-06-06 23:45:34 +05:30
Satwik Kansal 45bec627d1 Add todos 2019-05-06 23:49:57 +05:30
Satwik Kansal 5c8c4c5843 Get the generator in a working state 2019-05-06 23:47:24 +05:30
Satwik Kansal c475cbfe82 Use absolute path for the pager.
Fixes https://github.com/satwikkansal/wtfpython/issues/119
2019-05-01 19:55:46 +05:30
Satwik Kansal 596186d81c Add json generator 2019-05-01 19:12:17 +05:30
Satwik Kansal 54883f5134
Use http instead of https
This will avoid CERTIFICATE_VERIFY_FAILED errors due to SSL.
2019-03-31 19:08:19 +05:30
Satwik Kansal b262f29756
Add reference to chinese translation 2018-12-16 16:23:39 +05:30
kyblockstacking 30e05a5973 Rephrase sentence to make more sense (#109) 2018-12-09 20:23:28 +05:30
1f604 64b310953a fix typo (#107) 2018-12-07 00:24:45 +05:30
Hannes 9c5f26e758 match order of display to if/else order (#105)
I was WTFing for way too long until I realised that the results were displayed in opposite order of the if/else statement.
2018-12-06 01:20:17 +05:30
Hannes b0e7a816ec make the function *call* more visible (#104)
It is easy to overlook the () in that appending operation, I propose adding a short comment.
2018-12-06 01:15:59 +05:30
Satwik Kansal d7477885b8
Update broken link 2018-12-05 04:16:32 +05:30
Chris J 145a194c8b Update README.md (#95)
Fixed a small typo
2018-10-03 13:37:17 +05:30
Vibhu Agarwal ac379c9c03 Fixed input-output of 4th example explanation code (#92)
Ref. example: Deep down, we're all the same
2018-08-28 14:24:54 +05:30
cclauss 2fb04501f7 Fix Python 3 compatibility in the irrelevant code! (#86) 2018-06-22 01:17:51 +05:30
Satwik Kansal 07861a045d Fix an error in the irrelevant code!
Fixes https://github.com/satwikkansal/wtfpython/issues/85
2018-06-19 01:05:32 +05:30
Satwik Kansal 5484680721 Fix incorrect output in "Mysterious key type conversion" example
Fixes https://github.com/satwikkansal/wtfpython/issues/84
2018-06-15 00:48:50 +05:30
Satwik Kansal d2507c2ff3
Simplify explanation 2018-05-30 00:29:56 +05:30
BOOK 2188fa30cd Update README.md (#82)
Improve explanation for "Strings can be tricky sometimes"
2018-05-30 00:22:49 +05:30
Satwik Kansal 3df9152ec9
Update README.md 2018-05-28 18:05:21 +05:30
Satwik Kansal 518881c70e Correct the snippet in Tic-tac-toe explanation
Fixes https://github.com/satwikkansal/wtfpython/issues/81
2018-05-23 18:16:25 +05:30
Harmon 169fa2fb5e Fix grammatical error (#75) 2018-03-07 02:24:36 +05:30
Mélanie Chauvel db35390786 Fix a syntax error and some spelling errors (#72) 2018-03-01 02:07:48 +05:30
Satwik Kansal ea5fc2f47f Update contents 2018-02-26 00:39:01 +05:30
Satwik Kansal c13ce9701a Add sohaibfarooqi to the contributors 2018-02-26 00:37:49 +05:30
Satwik Kansal 0c9acdcc8e Update TOC 2018-02-26 00:36:22 +05:30
Satwik Kansal 9608b2fcfc Merge examples 2018-02-26 00:34:22 +05:30
Sohaib Farooqi 70fe61737b Generator with Slice assignment trick 2018-02-26 00:18:56 +05:30
Satwik Kansal 240e216c51 Update explanation: Tic tac toe
Fixes https://github.com/satwikkansal/wtfpython/issues/68
2018-02-26 00:03:37 +05:30
Satwik Kansal a0100a8b48 Update explanation: Strings can be tricky sometimes
Related to https://github.com/satwikkansal/wtfpython/issues/67
2018-02-25 23:31:46 +05:30
Semen Zhydenko 17e49ee9db Fix typos 2018-01-31 01:08:22 +05:30
7664476e51 Fix typo 2018-01-29 22:37:52 +05:30
Tom Ritchford a9e72e03f4 Fix code sample for "65539 local variables" example 2018-01-29 15:40:02 +05:30
Tom Swirly 54ed75f77d Format and grammar tweak
* Tweaked a line break so a section number was correctly formatted
* Tweaked grammar to be slightly more natural
2018-01-29 15:36:02 +05:30
Connor Devlin 12e517b0e3 Added a contributor's code of conduct. 2018-01-27 10:04:49 +05:30
Satwik Kansal 2fda1ef070 Fix missing statement
Fixes https://github.com/satwikkansal/wtfpython/issues/57
2018-01-26 11:22:50 +05:30
Satwik Kansal fc262f2444 Fix broken TOC links 2018-01-26 11:22:50 +05:30
Srdjan Grubor 5d2e377487 Removed byte-compiled and cached files
These should never be commited to repos and they're also now on
gitignore.
2018-01-26 10:18:19 +05:30
Satwik Kansal c28b292184 Update version 2018-01-25 18:59:07 +05:30
Satwik Kansal 98ef2dad4a Reorder the sections 2018-01-26 00:13:40 +05:30
Satwik Kansal 86462ed1e5
Update README.md 2018-01-25 21:13:04 +05:30
Satwik Kansal 9d713f0fa5
Fix formatting 2018-01-25 20:45:14 +05:30
Satwik Kansal 79d396a1fb Update description 2018-01-23 15:34:06 +05:30
Satwik Kansal f7db9aace7 Relase 0.2.0 🎉 2018-01-23 14:44:45 +05:30
Satwik Kansal 054e88f7b2 Change case 2018-01-23 14:42:45 +05:30
Satwik Kansal 674fc891b4 Add figure related to string intern 2018-01-23 14:40:49 +05:30
Satwik Kansal 9ac6470efc Add logo image 2018-01-23 14:33:49 +05:30
Satwik Kansal 5061af0b6e Add new images 2018-01-23 14:32:02 +05:30
Satwik Kansal 980798fd36 Update guidelines 2018-01-23 14:31:44 +05:30
Satwik Kansal b362cc9d0a Add new links 2018-01-23 14:31:31 +05:30
36 changed files with 22496 additions and 2724 deletions

13
.gitignore vendored
View File

@ -1,5 +1,18 @@
.DS_Store
node_modules
npm-debug.log
wtfpython-pypi/build/
wtfpython-pypi/dist/
wtfpython-pypi/wtfpython.egg-info
# Python-specific byte-compiled files should be ignored
__pycache__/
*.py[cod]
*$py.class
irrelevant/.ipynb_checkpoints/
irrelevant/.python-version
.idea/

1
.npmignore vendored
View File

@ -1 +0,0 @@
irrelevant/

3
.travis.yml vendored Normal file
View File

@ -0,0 +1,3 @@
language: python
install: pip install flake8
script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

41
CONTRIBUTING.md vendored
View File

@ -1,10 +1,8 @@
All kinds of patches are welcome. Feel free to even suggest some catchy and funny titles for the existing Examples. The goal is to make this collection as interesting to read as possible.
All kinds of patches are welcome. Feel free to even suggest some catchy and funny titles for the existing Examples. The goal is to make this collection as interesting to read as possible. Here are a few ways through which you can contribute,
If the changes you suggest are siginificant, filing an issue before submitting the actual patch will be appreciated. If you'd like to work on the issue (highly encouraged), you can mention that you're interested in working on it while creating the issue and get assigned to it.
If you're adding a new example, please do create an issue to discuss it before submitting a patch.
You can use the following template for adding a new example:
- If you are interested in translating the project to another language (some people have done that in the past), please feel free to open up an issue, and let me know if you need any kind of help.
- If the changes you suggest are significant, filing an issue before submitting the actual patch will be appreciated. If you'd like to work on the issue (highly encouraged), you can mention that you're interested in working on it while creating the issue and get assigned to it.
- If you're adding a new example, it is highly recommended to create an issue to discuss it before submitting a patch. You can use the following template for adding a new example:
<pre>
### ▶ Some fancy Title *
@ -27,10 +25,39 @@ Probably unexpected output
```py
Setting up examples for clarification (if necessary)
```
**Outupt:**
**Output:**
```py
>>> trigger # some example that makes it easy to unveil the magic
# some justified output
```
```
</pre>
Few things that you can consider while writing an example,
- If you are choosing to submit a new example without creating an issue and discussing, please check the project to make sure there aren't similar examples already.
- Try to be consistent with the namings and the values you use with the variables. For instance, most variable names in the project are along the lines of `some_string`, `some_list`, `some_dict`, etc. You'd see a lot of `x`s for single letter variable names, and `"wtf"` as values for strings. There's no strictly enforced scheme in the project as such, but you can take a glance at other examples to get a gist.
- Try to be as creative as possible to add that element of "surprise" in the setting up part of an example. Sometimes this may mean writing a snippet a sane programmer would never write.
- Also, feel free to add your name to the [contributors list](/CONTRIBUTORS.md).
**Some FAQs**
What is is this after every snippet title (###) in the README: <!-- Example ID: 30f1d3fc-e267-4b30-84ef-4d9e7091ac1a --->? Should it be added manually or can it be ignored when creating new snippets?
That's a random UUID, it is used to keep identify the examples across multiple translations of the project. As a contributor, you don't have to worry about behind the scenes of how it is used, you just have to add a new random UUID to new examples in that format.
Where should new snippets be added? Top/bottom of the section, doesn't ?
There are multiple things that are considered to decide the order (the dependency on the other examples, difficulty level, category, etc). I'd suggest simply adding the new example at the bottom of a section you find more fitting (or just add it to the Miscellaneous section). Its order will be taken care of in future revisions.
What's the difference between the sections (the first two feel very similar)?
The section "Strain your brain" contains more contrived examples that you may not really encounter in real life, whereas the section "Slippery Slopes" contains examples that have the potential to be encountered more frequently while programming.
Before the table of contents it says that markdown-toc -i README.md --maxdepth 3 was used to create it. The pip package markdown-toc does not contain either -i or --maxdepth flags. Which package is meant, or what version of that package?
Should the new table of contents entry for the snippet be created with the above command or created manually (in case the above command does more than only add the entry)?
We use the [markdown-toc](https://www.npmjs.com/package/markdown-toc) npm package to generate ToC. It has some issues with special characters though (I'm not sure if it's fixed yet). More often than not, I just end up inserting the toc link manually at the right place. The tool is handy when I have to big reordering, otherwise just updating toc manually is more convenient imo.
If you have any questions feel free to ask on [this issue](https://github.com/satwikkansal/wtfpython/issues/269) (thanks to [@LiquidFun](https://github.com/LiquidFun) for starting it).

47
CONTRIBUTORS.md vendored
View File

@ -1,13 +1,42 @@
I'm really greatful to all the contributors. Following are the wonderful people (in no specific order) who have contributed their examples to wtfpython.
Following are the wonderful people (in no specific order) who have contributed their examples to wtfpython.
| Contributor | Github | Issues |
|-------------|--------|--------|
| Lucas-C | [Lucas-C](https://github.com/Lucas-C) | [#36](https:/github.com/satwikkansal/wtfpython/issues/36) |
| MittalAshok | [MittalAshok](https://github.com/MittalAshok) | [#23](https:/github.com/satwikkansal/wtfpython/issues/23) |
| asottile | [asottile](https://github.com/asottile) | [#40](https:/github.com/satwikkansal/wtfpython/issues/40) |
| MostAwesomeDude | [MostAwesomeDude](https://github.com/MostAwesomeDude) | [#1](https:/github.com/satwikkansal/wtfpython/issues/1) |
| tukkek | [tukkek](https://github.com/tukkek) | [#11](https:/github.com/satwikkansal/wtfpython/issues/11), [#26](https:/github.com/satwikkansal/wtfpython/issues/26) |
| PiaFraus | [PiaFraus](https://github.com/PiaFraus) | [#9](https:/github.com/satwikkansal/wtfpython/issues/9) |
| chris-rands | [chris-rands](https://github.com/chris-rands) | [#32](https:/github.com/satwikkansal/wtfpython/issues/32) |
| Lucas-C | [Lucas-C](https://github.com/Lucas-C) | [#36](https://github.com/satwikkansal/wtfpython/issues/36) |
| MittalAshok | [MittalAshok](https://github.com/MittalAshok) | [#23](https://github.com/satwikkansal/wtfpython/issues/23) |
| asottile | [asottile](https://github.com/asottile) | [#40](https://github.com/satwikkansal/wtfpython/issues/40) |
| MostAwesomeDude | [MostAwesomeDude](https://github.com/MostAwesomeDude) | [#1](https://github.com/satwikkansal/wtfpython/issues/1) |
| tukkek | [tukkek](https://github.com/tukkek) | [#11](https://github.com/satwikkansal/wtfpython/issues/11), [#26](https://github.com/satwikkansal/wtfpython/issues/26) |
| PiaFraus | [PiaFraus](https://github.com/PiaFraus) | [#9](https://github.com/satwikkansal/wtfpython/issues/9) |
| chris-rands | [chris-rands](https://github.com/chris-rands) | [#32](https://github.com/satwikkansal/wtfpython/issues/32) |
| sohaibfarooqi | [sohaibfarooqi](https://github.com/sohaibfarooqi) | [#63](https://github.com/satwikkansal/wtfpython/issues/63) |
| ipid | [ipid](https://github.com/ipid) | [#145](https://github.com/satwikkansal/wtfpython/issues/145) |
| roshnet | [roshnet](https://github.com/roshnet) | [#140](https://github.com/satwikkansal/wtfpython/issues/140) |
| daidai21 | [daidai21](https://github.com/daidai21) | [#137](https://github.com/satwikkansal/wtfpython/issues/137) |
| scidam | [scidam](https://github.com/scidam) | [#136](https://github.com/satwikkansal/wtfpython/issues/136) |
| pmjpawelec | [pmjpawelec](https://github.com/pmjpawelec) | [#121](https://github.com/satwikkansal/wtfpython/issues/121) |
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [#112](https://github.com/satwikkansal/wtfpython/issues/112) |
| mishaturnbull | [mishaturnbull](https://github.com/mishaturnbull) | [#108](https://github.com/satwikkansal/wtfpython/issues/108) |
| MuseBoy | [MuseBoy](https://github.com/MuseBoy) | [#101](https://github.com/satwikkansal/wtfpython/issues/101) |
| Ghost account | N/A | [#96](https://github.com/satwikkansal/wtfpython/issues/96) |
| koddo | [koddo](https://github.com/koddo) | [#80](https://github.com/satwikkansal/wtfpython/issues/80), [#73](https://github.com/satwikkansal/wtfpython/issues/73) |
| jab | [jab](https://github.com/jab) | [#77](https://github.com/satwikkansal/wtfpython/issues/77) |
| Jongy | [Jongy](https://github.com/Jongy) | [#208](https://github.com/satwikkansal/wtfpython/issues/208), [#210](https://github.com/satwikkansal/wtfpython/issues/210), [#233](https://github.com/satwikkansal/wtfpython/issues/233) |
| Diptangsu Goswami | [diptangsu](https://github.com/diptangsu) | [#193](https://github.com/satwikkansal/wtfpython/issues/193) |
| Charles | [charles-l](https://github.com/charles-l) | [#245](https://github.com/satwikkansal/wtfpython/issues/245) |
| LiquidFun | [LiquidFun](https://github.com/LiquidFun) | [#267](https://github.com/satwikkansal/wtfpython/issues/267) |
Thank you all for taking out time, and helping to make this project awesome! :smile:
---
**Translations**
| Translator | Github | Language |
|-------------|--------|--------|
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [Chinese](https://github.com/leisurelicht/wtfpython-cn) |
| vuduclyunitn | [vuduclyunitn](https://github.com/vuduclyunitn) | [Vietnamese](https://github.com/vuduclyunitn/wtfptyhon-vi) |
| José De Freitas | [JoseDeFreitas](https://github.com/JoseDeFreitas) | [Spanish](https://github.com/JoseDeFreitas/wtfpython-es) |
| Vadim Nifadev | [nifadyev](https://github.com/nifadyev) | [Russian](https://github.com/satwikkansal/wtfpython/tree/master/translations/ru-russian) |
Thank you all for your time and making wtfpython more awesome! :smile:
PS: This list is updated after every major release, if I forgot to add your contribution here, please feel free to raise a Pull request.

3640
README.md vendored

File diff suppressed because it is too large Load Diff

74
code-of-conduct.md vendored Normal file
View File

@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

BIN
images/expanding-brain-meme.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

BIN
images/logo-dark.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/logo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
images/string-intern/string_intern.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
images/tic-tac-toe.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

24
irrelevant/insert_ids.py Normal file
View File

@ -0,0 +1,24 @@
import uuid
new_file = []
original_file = []
fname = "../README.md"
def generate_random_id_comment():
random_id = uuid.uuid4()
return f"<!-- Example ID: {random_id} --!>"
with open(fname, "r") as f:
original_file = f.readlines()
for line in original_file:
new_file.append(line)
if line.strip().startswith("### "):
new_file.append(generate_random_id_comment())
with open(fname, "w") as f:
f.write("".join(new_file))

View File

@ -0,0 +1,397 @@
"""
An inefficient monolithic piece of code that'll generate jupyter notebook
from the projects main README.
PS: If you are a recruiter, please don't judge me by this piece of code. I wrote it
in hurry. I know this is messy and can be simplified, but I don't want to change it
much because it just works.
Simplifictions and improvements through patches are more than welcome however :)
#TODOs
- CLI arguments for running this thing
- Add it to prepush hook
- Add support for skip comments, to skip examples that are not meant for notebook environment.
- Use templates?
"""
import json
import os
import pprint
fpath = os.path.join(os.path.dirname( __file__ ), '..', 'README.md')
examples = []
# The globals
current_example = 1
sequence_num = 1
current_section_name = ""
STATEMENT_PREFIXES = ["...", ">>> ", "$ "]
HOSTED_NOTEBOOK_INSTRUCTIONS = """
## Hosted notebook instructions
This is just an experimental attempt of browsing wtfpython through jupyter notebooks. Some examples are read-only because,
- they either require a version of Python that's not supported in the hosted runtime.
- or they can't be reproduced in the notebook envrinonment.
The expected outputs are already present in collapsed cells following the code cells. The Google colab provides Python2 (2.7) and Python3 (3.6, default) runtimes. You can switch among these for Python2 specific examples. For examples specific to other minor versions, you can simply refer to collapsed outputs (it's not possible to control the minor version in hosted notebooks as of now). You can check the active version using
```py
>>> import sys
>>> sys.version
# Prints out Python version here.
```
That being said, most of the examples do work as expected. If you face any trouble, feel free to consult the original content on wtfpython and create an issue in the repo. Have fun!
---
"""
def generate_code_block(statements, output):
"""
Generates a code block that executes the given statements.
:param statements: The list of statements to execute.
:type statements: list(str)
"""
global sequence_num
result = {
"type": "code",
"sequence_num": sequence_num,
"statements": statements,
"output": output
}
sequence_num += 1
return result
def generate_markdown_block(lines):
"""
Generates a markdown block from a list of lines.
"""
global sequence_num
result = {
"type": "markdown",
"sequence_num": sequence_num,
"value": lines
}
sequence_num += 1
return result
def is_interactive_statement(line):
for prefix in STATEMENT_PREFIXES:
if line.lstrip().startswith(prefix):
return True
return False
def parse_example_parts(lines, title, current_line):
"""
Parse the given lines and return a dictionary with two keys:
build_up, which contains all the text before an H4 (explanation) is encountered,
and
explanation, which contains all the text after build_up until --- or another H3 is encountered.
"""
parts = {
"build_up": [],
"explanation": []
}
content = [title]
statements_so_far = []
output_so_far = []
next_line = current_line
# store build_up till an H4 (explanation) is encountered
while not (next_line.startswith("#### ")or next_line.startswith('---')):
# Watching out for the snippets
if next_line.startswith("```py"):
# It's a snippet, whatever found until now is text
is_interactive = False
output_encountered = False
if content:
parts["build_up"].append(generate_markdown_block(content))
content = []
next_line = next(lines)
while not next_line.startswith("```"):
if is_interactive_statement(next_line):
is_interactive = True
if (output_so_far):
parts["build_up"].append(generate_code_block(statements_so_far, output_so_far))
statements_so_far, output_so_far = [], []
statements_so_far.append(next_line)
else:
# can be either output or normal code
if is_interactive:
output_so_far.append(next_line)
elif output_encountered:
output_so_far.append(next_line)
else:
statements_so_far.append(next_line)
next_line = next(lines)
# Snippet is over
parts["build_up"].append(generate_code_block(statements_so_far, output_so_far))
statements_so_far, output_so_far = [], []
next_line = next(lines)
else:
# It's a text, go on.
content.append(next_line)
next_line = next(lines)
# Explanation encountered, save any content till now (if any)
if content:
parts["build_up"].append(generate_markdown_block(content))
# Reset stuff
content = []
statements_so_far, output_so_far = [], []
# store lines again until --- or another H3 is encountered
while not (next_line.startswith("---") or
next_line.startswith("### ")):
if next_line.lstrip().startswith("```py"):
# It's a snippet, whatever found until now is text
is_interactive = False
if content:
parts["explanation"].append(generate_markdown_block(content))
content = []
next_line = next(lines)
while not next_line.lstrip().startswith("```"):
if is_interactive_statement(next_line):
is_interactive = True
if (output_so_far):
parts["explanation"].append(generate_code_block(statements_so_far, output_so_far))
statements_so_far, output_so_far = [], []
statements_so_far.append(next_line)
else:
# can be either output or normal code
if is_interactive:
output_so_far.append(next_line)
else:
statements_so_far.append(next_line)
next_line = next(lines)
# Snippet is over
parts["explanation"].append(generate_code_block(statements_so_far, output_so_far))
statements_so_far, output_so_far = [], []
next_line = next(lines)
else:
# It's a text, go on.
content.append(next_line)
next_line = next(lines)
# All done
if content:
parts["explanation"].append(generate_markdown_block(content))
return next_line, parts
def remove_from_beginning(tokens, line):
for token in tokens:
if line.lstrip().startswith(token):
line = line.replace(token, "")
return line
def inspect_and_sanitize_code_lines(lines):
"""
Remove lines from the beginning of a code block that are not statements.
:param lines: A list of strings, each representing a line in the code block.
:returns is_print_present, sanitized_lines: A boolean indicating whether print was present in the original code and a list of strings representing
sanitized lines. The latter may be an empty list if all input lines were removed as comments or whitespace (and thus did not contain any statements).
This function does not remove blank lines at the end of `lines`.
"""
tokens_to_remove = STATEMENT_PREFIXES
result = []
is_print_present = False
for line in lines:
line = remove_from_beginning(tokens_to_remove, line)
if line.startswith("print ") or line.startswith("print("):
is_print_present = True
result.append(line)
return is_print_present, result
def convert_to_cells(cell_contents, read_only):
"""
Converts a list of dictionaries containing markdown and code cells into a Jupyter notebook.
:param cell_contents: A list of dictionaries, each
dictionary representing either a markdown or code cell. Each dictionary should have the following keys: "type", which is either "markdown" or "code",
and "value". The value for type = 'markdown' is the content as string, whereas the value for type = 'code' is another dictionary with two keys,
statements and output. The statements key contains all lines in between ```py\n``` (including) until ```\n```, while output contains all lines after
```.output py\n```.
:type cell_contents: List[Dict]
:param read_only (optional): If True then only print outputs are included in converted
cells. Default False
:type read_only (optional): bool
:returns A Jupyter notebook containing all cells from input parameter `cell_contents`.
Each converted cell has metadata attribute collapsed set to true if it's code-cell otherwise None if it's markdow-cell.
"""
cells = []
for stuff in cell_contents:
if stuff["type"] == "markdown":
# todo add metadata later
cells.append(
{
"cell_type": "markdown",
"metadata": {},
"source": stuff["value"]
}
)
elif stuff["type"] == "code":
if read_only:
# Skip read only
# TODO: Fix
cells.append(
{
"cell_type": "markdown",
"metadata": {},
"source": ["```py\n"] + stuff["statements"] + ["```\n"] + ["```py\n"] + stuff['output'] + ["```\n"]
}
)
continue
is_print_present, sanitized_code = inspect_and_sanitize_code_lines(stuff["statements"])
if is_print_present:
cells.append(
{
"cell_type": "code",
"metadata": {
"collapsed": True,
},
"execution_count": None,
"outputs": [{
"name": "stdout",
"output_type": "stream",
"text": stuff["output"]
}],
"source": sanitized_code
}
)
else:
cells.append(
{
"cell_type": "code",
"execution_count": None,
"metadata": {
"collapsed": True
},
"outputs": [{
"data": {
"text/plain": stuff["output"]
},
"output_type": "execute_result",
"metadata": {},
"execution_count": None
}],
"source": sanitized_code
}
)
return cells
def convert_to_notebook(pre_examples_content, parsed_json, post_examples_content):
"""
Convert a JSON file containing the examples to a Jupyter Notebook.
"""
result = {
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
notebook_path = "wtf.ipynb"
result["cells"] += convert_to_cells([generate_markdown_block(pre_examples_content)], False)
for example in parsed_json:
parts = example["parts"]
build_up = parts.get("build_up")
explanation = parts.get("explanation")
read_only = example.get("read_only")
if build_up:
result["cells"] += convert_to_cells(build_up, read_only)
if explanation:
result["cells"] += convert_to_cells(explanation, read_only)
result["cells"] += convert_to_cells([generate_markdown_block(post_examples_content)], False)
#pprint.pprint(result, indent=2)
with open(notebook_path, "w") as f:
json.dump(result, f, indent=2)
with open(fpath, 'r+', encoding="utf-8") as f:
lines = iter(f.readlines())
line = next(lines)
result = []
pre_examples_phase = True
pre_stuff = []
post_stuff = []
try:
while True:
if line.startswith("## "):
pre_examples_phase = False
# A section is encountered
current_section_name = line.replace("## ", "").strip()
section_text = []
line = next(lines)
# Until a new section is encountered
while not (line.startswith("## ") or line.startswith("# ")):
# check if it's a H3
if line.startswith("### "):
# An example is encountered
title_line = line
line = next(lines)
read_only = False
while line.strip() == "" or line.startswith('<!--'):
#TODO: Capture example ID here using regex.
if '<!-- read-only -->' in line:
read_only = True
line = next(lines)
example_details = {
"id": current_example,
"title": title_line.replace("### ", ""),
"section": current_section_name,
"read_only": read_only
}
line, example_details["parts"] = parse_example_parts(lines, title_line, line)
result.append(example_details)
current_example += 1
else:
section_text.append(line)
line = next(lines)
else:
if pre_examples_phase:
pre_stuff.append(line)
else:
post_stuff.append(line)
line = next(lines)
except StopIteration as e:
#pprint.pprint(result, indent=2)
pre_stuff.append(HOSTED_NOTEBOOK_INSTRUCTIONS)
result.sort(key = lambda x: x["read_only"])
convert_to_notebook(pre_stuff, result, post_stuff)

7
irrelevant/notebook_instructions.md vendored Normal file
View File

@ -0,0 +1,7 @@
## Generating the notebook
- Expand the relative links in README.md to absolute ones
- Remove the TOC in README.md (because Google colab generates its own anyway)
- Reorder the examples, so that the ones that work are upfront.
- Run the `notebook_generator.py`, it will generate a notebook named `wtf.ipynb`
- Revert the README.md changes (optional)

View File

@ -139,7 +139,7 @@ f*
Half triple-quoted strings
f
Implicity key type conversion
Implicit key type conversion
f*
Stubborn `del` operator

View File

@ -1,6 +1,8 @@
"""
Parses the README.md and generated the table
This script parses the README.md and generates the table
`CONTRIBUTORS.md`.
No longer works since we've moved on contributors to CONTRIBUTORS.md entirely.
"""
import pprint
@ -39,7 +41,7 @@ for handle, issues in contribs.items():
issue_string = ', '.join([issue_format.format(i, i) for i in issues])
resp = requests.get(github_rest_api.format(handle))
name = handle
if resp.status_code is 200:
if resp.status_code == 200:
pprint.pprint(resp.json()['name'])
else:
print(handle, resp.content)
@ -48,4 +50,4 @@ for handle, issues in contribs.items():
handle,
issue_string))
print(table_header + "\n".join(rows_so_far))
print(table_header + "\n".join(rows_so_far))

View File

@ -2,7 +2,7 @@
"""
This inefficient module would parse the README.md in the initial version of
WTFPython, and enabl me to categorize and reorder a hell lot of examples with
WTFPython, and enable me to categorize and reorder a hell lot of examples with
the help of the file `add_categories` (part of which is automatically
generated).
@ -10,6 +10,12 @@ After the refactor, this module would not work now with necessary updates in
the code.
"""
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
fname = "README.md"
snippets = []
@ -80,6 +86,7 @@ with open("add_categories", "r") as f:
}
content.next()
except StopIteration:
pass
for idx, snip in enumerate(snippets):
snippets[idx]["category"] = snips_by_title[snip["title"]]["category"]

13478
irrelevant/wtf.ipynb vendored Normal file

File diff suppressed because it is too large Load Diff

41
package.json vendored
View File

@ -1,41 +0,0 @@
{
"name": "wtfpython",
"version": "2.0.0",
"description": "A collection of trick Python snippets and lesser known features",
"bin": "wtfpython",
"scripts": {
"postpublish": "git push origin master",
"toc": "doctoc --github --title '# Table of Contents' --maxlevel 3 README.md"
},
"repository": {
"type": "git",
"url": "git+https://github.com/satwikkansal/wtfPython.git"
},
"keywords": [
"python",
"specification",
"notes",
"wtf",
"learning",
"guide",
"handbook"
],
"author": "Satwik Kansal <satwikkansal@gmail.com> (https://satwikkansal.xyz)",
"license": "WTFPL 2.0",
"bugs": {
"url": "https://github.com/satwikkansal/wtfPython/issues"
},
"homepage": "https://github.com/satwikkansal/wtfPython#readme",
"devDependencies": {
"doctoc": "^1.3.0"
},
"dependencies": {
"boxen": "^1.1.0",
"chalk": "^1.1.1",
"default-pager": "^1.1.0",
"meow": "^3.7.0",
"msee": "^0.3.3",
"through2": "^2.0.2",
"update-notifier": "^2.0.0"
}
}

63
translations/ru-russian/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,63 @@
Приветствуются все виды изменений. Не стесняйтесь предлагать броские и смешные названия для существующих примеров. Цель - сделать эту коллекцию как можно более интересной для чтения. Вот несколько способов, с помощью которых вы можете внести свой вклад,
- Если вы заинтересованы в переводе проекта на другой язык (некоторые люди уже делали это в прошлом), пожалуйста, не стесняйтесь открыть тему и дайте мне знать, если вам нужна какая-либо помощь.
- Если изменения, которые вы предлагаете, значительны, то создание issue перед внесением изменений будет оценено по достоинству. Если вы хотите поработать над issue (это очень рекомендуется), выразите свою заинтересованность и вы будете назначены исполнителем.
- Если вы добавляете новый пример, настоятельно рекомендуется создать issue, чтобы обсудить ее перед отправкой изменений. Для добавления нового примера вы можете использовать следующий шаблон:
<pre>
### ▶ Какое-то причудливое название. *
* в конце названия означает, что пример был добавлен недавно.
```py
# Подготовка кода.
# Подготовка к волшебству...
```
**Вывод (версия Python):**
```py
>>> triggering_statement
Вероятно, неожиданный вывод
```
(Необязательно): Одна строка, описывающая неожиданный вывод.
#### 💡 Объяснение:
* Краткое объяснение того, что происходит и почему это происходит.
```py
Подготовка примеров для пояснения (при необходимости)
```
**Вывод:**
```py
>>> trigger # пример, облегчающий понимание магии
# обоснованный вывод
```
</pre>
Несколько моментов, которые стоит учитывать при написании примера,
- Если вы решили отправить новый пример без создания issue и обсуждения, пожалуйста, проверьте проект, чтобы убедиться, что в нем уже нет похожих примеров.
- Старайтесь быть последовательными в именах и значениях, которые вы используете для переменных. Например, большинство имен переменных в проекте имеют вид `some_string`, `some_list`, `some_dict` и т.д. Вы увидите много `x` для однобуквенных имен переменных, и `"wtf"` в качестве значений для строк. В проекте нет строгой схемы, как таковой, но вы можете взглянуть на другие примеры, чтобы понять суть.
- Старайтесь быть как можно более креативными, чтобы добавить элемент "сюрприза" во время подготовки примеров. Иногда это может означать написание фрагмента, который здравомыслящий программист никогда бы не написал.
- Также не стесняйтесь добавлять свое имя в список [контрибьюторов](/CONTRIBUTORS.md).
**Некоторые часто задаваемые вопросы**
Что это такое после каждого заголовка сниппета (###) в README: <!-- ID примера: 30f1d3fc-e267-4b30-84ef-4d9e7091ac1a --->? Нужно ли его добавлять вручную или можно игнорировать при создании новых сниппетов?
Это случайный UUID, он используется для идентификации примеров в нескольких переводах проекта. Как контрибьютор, вы не должны беспокоиться о том, как он используется, вы просто должны добавлять новый случайный UUID к новым примерам в этом формате.
Куда следует добавлять новые сниппеты? В начало/в конец раздела?
При определении порядка учитывается множество факторов (зависимость от других примеров, уровень сложности, категория и т.д.). Я бы предложил просто добавить новый пример в конец раздела, который вы считаете более подходящим (или просто добавить его в раздел "Разное"). О его порядке можно будет позаботиться в будущих редакциях.
В чем разница между разделами (первые два очень похожи)?
Раздел "Напрягите мозг" содержит более надуманные примеры, с которыми вы не столкнетесь в реальной жизни, в то время как раздел "Скользкие склоны" содержит примеры, с которыми можно чаще сталкиваться при программировании.
Перед оглавлением написано, что для его создания использовался markdown-toc -i README.md --maxdepth 3. Пакет pip markdown-toc не содержит ни флагов -i, ни --maxdepth. Какой пакет имеется в виду, или какая версия этого пакета?
Должна ли новая запись в оглавлении для фрагмента быть создана с помощью вышеуказанной команды или вручную (в случае, если вышеуказанная команда делает больше, чем просто добавляет запись)?
Мы используем пакет [markdown-toc](https://www.npmjs.com/package/markdown-toc) npm для создания ToC (содержание). Однако у него есть некоторые проблемы со специальными символами (не уверен, что они уже исправлены). Чаще всего я просто вставляю ссылку toc вручную в нужное место. Инструмент удобен, когда мне нужно сделать большую перестановку, в остальных случаях просто обновлять toc вручную удобнее.
Если у вас есть вопросы, не стесняйтесь спрашивать в [issue](https://github.com/satwikkansal/wtfpython/issues/269) (спасибо [@LiquidFun](https://github.com/LiquidFun) за ее создание).

42
translations/ru-russian/CONTRIBUTORS.md vendored Normal file
View File

@ -0,0 +1,42 @@
Ниже перечислены (без определенного порядка) замечательные люди, которые внесли вклад в развитие wtfpython.
| Автор | Github | Issues |
|-------------|--------|--------|
| Lucas-C | [Lucas-C](https://github.com/Lucas-C) | [#36](https://github.com/satwikkansal/wtfpython/issues/36) |
| MittalAshok | [MittalAshok](https://github.com/MittalAshok) | [#23](https://github.com/satwikkansal/wtfpython/issues/23) |
| asottile | [asottile](https://github.com/asottile) | [#40](https://github.com/satwikkansal/wtfpython/issues/40) |
| MostAwesomeDude | [MostAwesomeDude](https://github.com/MostAwesomeDude) | [#1](https://github.com/satwikkansal/wtfpython/issues/1) |
| tukkek | [tukkek](https://github.com/tukkek) | [#11](https://github.com/satwikkansal/wtfpython/issues/11), [#26](https://github.com/satwikkansal/wtfpython/issues/26) |
| PiaFraus | [PiaFraus](https://github.com/PiaFraus) | [#9](https://github.com/satwikkansal/wtfpython/issues/9) |
| chris-rands | [chris-rands](https://github.com/chris-rands) | [#32](https://github.com/satwikkansal/wtfpython/issues/32) |
| sohaibfarooqi | [sohaibfarooqi](https://github.com/sohaibfarooqi) | [#63](https://github.com/satwikkansal/wtfpython/issues/63) |
| ipid | [ipid](https://github.com/ipid) | [#145](https://github.com/satwikkansal/wtfpython/issues/145) |
| roshnet | [roshnet](https://github.com/roshnet) | [#140](https://github.com/satwikkansal/wtfpython/issues/140) |
| daidai21 | [daidai21](https://github.com/daidai21) | [#137](https://github.com/satwikkansal/wtfpython/issues/137) |
| scidam | [scidam](https://github.com/scidam) | [#136](https://github.com/satwikkansal/wtfpython/issues/136) |
| pmjpawelec | [pmjpawelec](https://github.com/pmjpawelec) | [#121](https://github.com/satwikkansal/wtfpython/issues/121) |
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [#112](https://github.com/satwikkansal/wtfpython/issues/112) |
| mishaturnbull | [mishaturnbull](https://github.com/mishaturnbull) | [#108](https://github.com/satwikkansal/wtfpython/issues/108) |
| MuseBoy | [MuseBoy](https://github.com/MuseBoy) | [#101](https://github.com/satwikkansal/wtfpython/issues/101) |
| Ghost account | N/A | [#96](https://github.com/satwikkansal/wtfpython/issues/96) |
| koddo | [koddo](https://github.com/koddo) | [#80](https://github.com/satwikkansal/wtfpython/issues/80), [#73](https://github.com/satwikkansal/wtfpython/issues/73) |
| jab | [jab](https://github.com/jab) | [#77](https://github.com/satwikkansal/wtfpython/issues/77) |
| Jongy | [Jongy](https://github.com/Jongy) | [#208](https://github.com/satwikkansal/wtfpython/issues/208), [#210](https://github.com/satwikkansal/wtfpython/issues/210), [#233](https://github.com/satwikkansal/wtfpython/issues/233) |
| Diptangsu Goswami | [diptangsu](https://github.com/diptangsu) | [#193](https://github.com/satwikkansal/wtfpython/issues/193) |
| Charles | [charles-l](https://github.com/charles-l) | [#245](https://github.com/satwikkansal/wtfpython/issues/245) |
| LiquidFun | [LiquidFun](https://github.com/LiquidFun) | [#267](https://github.com/satwikkansal/wtfpython/issues/267) |
---
**Переводчики**
| Переводчик | Github | Язык |
|-------------|--------|--------|
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [Chinese](https://github.com/leisurelicht/wtfpython-cn) |
| vuduclyunitn | [vuduclyunitn](https://github.com/vuduclyunitn) | [Vietnamese](https://github.com/vuduclyunitn/wtfptyhon-vi) |
| José De Freitas | [JoseDeFreitas](https://github.com/JoseDeFreitas) | [Spanish](https://github.com/JoseDeFreitas/wtfpython-es) |
| Vadim Nifadev | [nifadyev](https://github.com/nifadyev) | [Russian](https://github.com/satwikkansal/wtfpython/tree/master/translations/ru-russian) |
Спасибо всем за ваше время и за то, что делаете wtfpython еще более потрясающим! :smile:
PS: Этот список обновляется после каждого крупного релиза, если я забыл добавить сюда ваш вклад, пожалуйста, не стесняйтесь сделать Pull request.

3948
translations/ru-russian/README.md vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,70 @@
# Кодекс Поведения участника
## Наши обязательства
Мы, как участники, авторы и лидеры обязуемся сделать участие в сообществе
свободным от притеснений для всех, независимо от возраста, телосложения,
видимых или невидимых ограничений способности, этнической принадлежности,
половых признаков, гендерной идентичности и выражения, уровня опыта,
образования, социально-экономического статуса, национальности, внешности,
расы, религии, или сексуальной идентичности и ориентации.
Мы обещаем действовать и взаимодействовать таким образом, чтобы вносить вклад в открытое,
дружелюбное, многообразное, инклюзивное и здоровое сообщество.
## Наши стандарты
Примеры поведения, создающие условия для благоприятных взаимоотношений включают в себя:
* Проявление доброты и эмпатии к другим участникам проекта
* Уважение к чужой точке зрения и опыту
* Конструктивная критика и принятие конструктивной критики
* Принятие ответственности, принесение извинений тем, кто пострадал от наших ошибок
и извлечение уроков из опыта
* Ориентирование на то, что лучше подходит для сообщества, а не только для нас лично
Примеры неприемлемого поведения участников включают в себя:
* Использование выражений или изображений сексуального характера и нежелательное сексуальное внимание или домогательство в любой форме
* Троллинг, оскорбительные или уничижительные комментарии, переход на личности или затрагивание политических убеждений
* Публичное или приватное домогательство
* Публикация личной информации других лиц, например, физического или электронного адреса, без явного разрешения
* Иное поведение, которое обоснованно считать неуместным в профессиональной обстановке
## Обязанности
Лидеры сообщества отвечают за разъяснение и применение наших стандартов приемлемого
поведения и будут предпринимать соответствующие и честные меры по исправлению положения
в ответ на любое поведение, которое они сочтут неприемлемым, угрожающим, оскорбительным или вредным.
Лидеры сообщества обладают правом и обязанностью удалять, редактировать или отклонять
комментарии, коммиты, код, изменения в вики, вопросы и другой вклад, который не совпадает
с Кодексом Поведения, и предоставят причины принятого решения, когда сочтут нужным.
## Область применения
Данный Кодекс Поведения применим во всех публичных физических и цифровых пространства сообщества,
а также когда человек официально представляет сообщество в публичных местах.
Примеры представления проекта или сообщества включают использование официальной электронной почты,
публикации в официальном аккаунте в социальных сетях,
или упоминания как представителя в онлайн или офлайн мероприятии.
## Приведение в исполнение
О случаях домогательства, а так же оскорбительного или иного другого неприемлемого
поведения можно сообщить ответственным лидерам сообщества с помощью email.
Все жалобы будут рассмотрены и расследованы оперативно и беспристрастно.
Все лидеры сообщества обязаны уважать неприкосновенность частной жизни и личную
неприкосновенность автора сообщения.
## Атрибуция
Данный Кодекс Поведения основан на [Кодекс Поведения участника][homepage],
версии 2.0, доступной по адресу
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Принципы Воздействия в Сообществе были вдохновлены [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org

85
wtfpython vendored
View File

@ -1,85 +0,0 @@
#!/usr/bin/env node
const fs = require('fs');
const obj = require('through2').obj;
const pager = require('default-pager');
const msee = require('msee');
const join = require('path').join;
const boxen = require('boxen');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const pkg = require('./package.json');
const meow = require('meow');
const cli = meow([
'Usage',
' bash-handbook',
'',
'Options',
' --lang, -l Translation language',
'',
'Examples',
' bash-handbook',
' bash-handbook --lang pt-br'
], {
string: [
'lang'
],
alias: {
l: 'lang',
h: 'help'
},
default: {
lang: ''
}
});
const boxenOpts = {
borderColor: 'yellow',
margin: {
bottom: 1
},
padding: {
right: 1,
left: 1
}
};
const mseeOpts = {
paragraphEnd: '\n\n'
};
const notifier = updateNotifier({ pkg });
process.env.PAGER = process.env.PAGER || 'less';
process.env.LESS = process.env.LESS || 'FRX';
const lang = cli.flags.lang
.toLowerCase()
.split('-')
.map((l, i) => i === 0 ? l : l.toUpperCase())
.join('-');
const translation = join(__dirname, !lang ? './README.md' : `./README-${lang}.md`);
fs.stat(translation, function (err, stats) {
if (err) {
console.log('The %s translation does not exist', chalk.bold(lang));
return;
}
fs.createReadStream(translation)
.pipe(obj(function (chunk, enc, cb) {
const message = [];
if (notifier.update) {
message.push(`Update available: {green.bold ${notifier.update.latest}} {dim current: ${notifier.update.current}}`);
message.push(`Run {blue npm install -g ${pkg.name}} to update.`);
this.push(boxen(message.join('\n'), boxenOpts));
}
this.push(msee.parse(chunk.toString(), mseeOpts));
cb();
}))
.pipe(pager());
});

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
if __name__ == "__main__":
setup(name='wtfpython',
version='0.1.3',
version='0.2',
description='What the f*ck Python!',
author="Satwik Kansal",
maintainer="Satwik Kansal",

Binary file not shown.

View File

@ -1,18 +1,25 @@
from os.path import dirname, join, realpath
import pydoc
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
url = ("https://raw.githubusercontent.com/satwikkansal/"
url = ("http://raw.githubusercontent.com/satwikkansal/"
"wtfpython/master/README.md")
file_name = "content.md"
file_path = join(dirname(dirname(realpath(__file__))), "content.md")
def fetch_updated_doc():
"""
Fetch the latest version of the file at `url` and save it to `file_path`.
If anything goes wrong, do nothing.
"""
try:
print("Fetching the latest version...")
urlretrieve(url, file_name)
urlretrieve(url, file_path)
print("Done!")
except Exception as e:
print(e)
@ -21,7 +28,7 @@ def fetch_updated_doc():
def render_doc():
with open(file_name, 'r') as f:
with open(file_path, 'r', encoding="utf-8") as f:
content = f.read()
pydoc.pager(content)

Binary file not shown.