python tricks
Python hosting: Host, run, and code Python in the cloud!
Dive into these awesome Python tricks! Whether you’re a novice or seasoned developer, you’ll find these Python 3 tips and tricks invaluable. Not only do they simplify your coding routine, but some also add a bit of fun to your programming experience.
Highlighted Offer:
Elevate your Python skills with the Python Programming Bootcamp: Go from zero to hero.
Start a Simple HTTP Web Server in Python
Did you know you can set up an HTTP Server in Python within seconds? Here’s how:
For Python2:python -m SimpleHTTPServer
For Python3:python -m http.server
After initiating, simply visit http://127.0.0.1:8000/. Your browser will display the current directory’s content.
Uncover a Hidden Python Poem
Unravel a delightful poem by Tim Peters using this one-liner:
import this |
XKCD Web Comic Easter Egg in Python
Access an XKCD comic straight from your Python environment. Try:
import antigravity |
Effortlessly Combine Arrays using Zip in Python
Merging two arrays? Use zip
for a straightforward solution:
b = [[1, 2, 3, 4], [6, 5, 4, 3]] |
Reversing a List Made Simple
No need to craft a separate function to reverse a list. Python has got you covered:
b = [1,2,3,4,5] |
Reverse a String with Python’s Slicing Feature
Get the reversed version of any string effortlessly:
s = "Hello world" |
Swap Variables in Python without Temp Variables
Python elegantly lets you swap values without the fuss of using temporary variables:
a = 1 |
Enjoyed these Python tricks? Feel free to share yours in the comments. Together, we make the Python community richer!
Recommended for You:
Take your Python journey to the next level with the Python Programming Bootcamp: Go from zero to hero.
Leave a Reply:
There are tons of those:
- http://www.siafoo.net/artic...
- http://python.net/~goodger/...
- http://stackoverflow.com/qu...
- http://nbviewer.ipython.org...
-- http://www.abclinuxu.cz/blo...
Hello Frank!
I wanted to know in which order should I study the tutorials in your website(I mean,after Beginner)
Hi, after beginner tutorials you could learn:
Flask (web apps)
GUI programming (pick one of the modules)
Databases
I will create intermediate and more tutorials, stay tuned :-)