{"id":13498168,"url":"https://github.com/judy2k/stupid-python-tricks","last_synced_at":"2025-08-20T22:31:17.092Z","repository":{"id":33168971,"uuid":"36810011","full_name":"judy2k/stupid-python-tricks","owner":"judy2k","description":"Stupid Python tricks.","archived":false,"fork":false,"pushed_at":"2024-03-02T16:10:12.000Z","size":3500,"stargazers_count":145,"open_issues_count":5,"forks_count":27,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-12-15T23:43:41.662Z","etag":null,"topics":["decorators","ish","language-features","metaclass","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ocelma/python-itunes","license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/judy2k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-03T14:44:33.000Z","updated_at":"2024-11-29T04:34:12.000Z","dependencies_parsed_at":"2024-10-31T14:31:52.059Z","dependency_job_id":"9268401d-fb49-459c-91da-f1dd5170e24b","html_url":"https://github.com/judy2k/stupid-python-tricks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/judy2k%2Fstupid-python-tricks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/judy2k%2Fstupid-python-tricks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/judy2k%2Fstupid-python-tricks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/judy2k%2Fstupid-python-tricks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/judy2k","download_url":"https://codeload.github.com/judy2k/stupid-python-tricks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230462906,"owners_count":18229864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorators","ish","language-features","metaclass","python"],"created_at":"2024-07-31T20:00:52.870Z","updated_at":"2024-12-19T16:11:02.340Z","avatar_url":"https://github.com/judy2k.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Stupid Python Tricks\n\nThis is (or will be) a consolidated repository of all the stupid Python tricks\nI have written (and can still find).\n\nA *stupid python trick* is usually an experiment with an advanced language\nfeature; ostensibly to learn how it works, but usually in order to abuse that\nfeature to write something truly horrible.\n\nI used to be a Perl programmer.\n\nI am also [no longer](CONTRIBUTORS.md) the only person responsible for all of this.\n\n\n## fizz_buzz_abomination\n\nThis one got out of hand. It is an attempt to write Fizz Buzz, using as many\nlanguage features as possible. It uses a bunch of functional techniques, a\nstrategy pattern implementation, and dynamically named closures (I was\nespecially proud of that).\n\nIt is PEP-8 compliant.\n\n## one_line_regex\n\nA friend of mine used to complain that he couldn't run a regex as part of an\n`if` statement's expression if he wanted to use the returned groups (you can\nin Perl using implicit variables).\n\nI worked out how to modify the caller's scope to dynamically add a variable\ncontaining the result of the pattern match. *Mission accomplished*.\n\n## Ish\n\nIsh is a stupid library that allows you to test if a variable is `tru-ish` or\n`false-ish`. *Ish has graduated to its own [repository](https://github.com/judy2k/ish)!*\n\n## marge_simpson\n\nI wanted to see if I could create an emoticon that was valid Python syntax.\nIt turns out I could! `OOO[:-P]`\n\n## clever_path_ob\n\nSubclass `str`, add a bunch of interesting properties and methods, and *voila*,\neasy path management, if a little bit too much voodoo.\n\n**Note:** I'm not 100% sure I wrote this. Some of it doesn't seem like my style.\nIt's possible I came up with inspiration from looking at someone else's code.\n\n## decorator_experiments\n\nContains an 'everlasting cache' (which is not very useful), and a (crazy)\ndecorator-based dependency calling mechanism. Warning, may cause seizures!\n\n## stupid_metaclass_tricks\n\nOnly one trick! A metaclass that automatically replaces `get_` and `set_`\nmethods with properties that call the methods. Too much magic, but a neat trick,\nI think.\n\n## super_considered_obligatory\n\nEver forget to call `tearDown` your test's superclass?\nNow you can ensure that any class inheriting fro you doesn't forget to call\n`super().method` _implicitly_.\n\nIf that's too much magic, there is also a decorator you can put on a method\nto ensure that we call `super()`.\n\n## true_false\n\nYou've all heard of the classic `#define TRUE FALSE` trick in C, right?\n\n## gradually_worse_pi\n\nImport this module, then import `math` and print out `pi` in a loop. I guarantee you'll be surprised!\n\n## autoargs\n\nIt's so tiresome writing constructors that copy all their arguments to `self`. Now you can just use this very clever `@autoargs` decorator, and all will be done for you!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjudy2k%2Fstupid-python-tricks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjudy2k%2Fstupid-python-tricks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjudy2k%2Fstupid-python-tricks/lists"}