Daily Python Snippet
@python_snippets
Not a bot. Daily curated Python snippets and tips for new and experienced Python developers. Tweet your best snippets!
คุณอาจชื่นชอบ
Robert Wilson's top 5 Python modules of 2015. My favorite - tqdm - adds a progress bar with only one line of code. j.mp/1Vd71Zz
Using mocks? Read this! engineeringblog.yelp.com/2015/02/assert… Everyone has this. :-(
Ever wanted to use a GOTO statement in your Python code? Now it's possible! Insane decorator patches your bytecode: j.mp/1OKLy9c
TIOBE Index for September 2015: j.mp/1KnyowT
Whoa, Python is ahead of PHP on the Tiobe index now?! :-)
Yeah, so Python 3.5.0 is really out! python.org/downloads/rele… Thanks all Python core contributors!
It's today! Tickets will be on sale at 3pm UTC! Yay! Check time here: time.is/compare/1500_1…. See you in November! 🚗🎸
Thinking about organizing a #DjangoGirls event in your city, but not sure what's involved? There's a manual for that! organize.djangogirls.org
IPython 4.0 is out, completing the initial transition to Jupyter blog.jupyter.org/2015/08/12/fir…
A great decorator that retries a function until it returns True. Configurable retries, delay & exponential backoff: j.mp/1IBAi8P
Want to memoize (see previous tip) in Python 2? The memoized class is very convenient. Snippet from the Python wiki: j.mp/1MVzhPc
Memoizing your Python function? Python 3 has the functools.lru_cache decorator. j.mp/1IBz90T
#python tip: In Python 3, you can simulate the Python 2 cmp(a,b) function with: (a > b) - (a < b)
"The __init__.py files are required to make Python treat the directories as containing packages"
Create multiple independent iterators from a single iterator using itertools.tee. Partitioning a collection: j.mp/1MVvZeK
#python tip: s.rstrip() # remove all whitespace (spaces, tabs, newlines, etc) s.rstrip(' ') # remove only space characters
#python tip: The str.startswith() and endswith() methods support an argument tuple: supported = url.endswith(('.html', '.xml', '.css'))
You can modify globals(), but never locals(). You can modify x locally using exec("x=y"), but only in Python 2, not 3 j.mp/1hifQ68
United States เทรนด์
- 1. #heatedrivalry 58.2K posts
- 2. shane 78.3K posts
- 3. Expedition 33 227K posts
- 4. ilya 62K posts
- 5. GOTY 74.3K posts
- 6. Falcons 39.1K posts
- 7. Kyle Pitts 20.1K posts
- 8. #TheGameAwards 456K posts
- 9. Bucs 24.7K posts
- 10. YOONMIN 21.4K posts
- 11. Mega Man 41.7K posts
- 12. Todd Bowles 6,105 posts
- 13. Good Friday 38.1K posts
- 14. #TheEndOfAnEra N/A
- 15. Deadpool 38.4K posts
- 16. Baker 24.3K posts
- 17. Silksong 53.5K posts
- 18. Geoff 74.6K posts
- 19. Leon 201K posts
- 20. jacob tierney 3,121 posts
Something went wrong.
Something went wrong.