r/pythontips • u/pbqre • May 21 '21
Short_Video Sublime text 4 released
After 3 years, we finally have sublime text 4.
r/pythontips • u/pbqre • May 21 '21
After 3 years, we finally have sublime text 4.
r/pythontips • u/thomasbbbb • May 11 '20
Hello,
If you're new to both Python and Github, you should follow Github's introduction and intermediate trainings:
r/pythontips • u/[deleted] • Jun 05 '16
Other people are seeing this, right? The scores on comments say things like "• 2 points".
Seeing the string †is a big hint about what went wrong. It means that a Unicode character that was supposed to be in UTF-8 was decoded as Windows-1252 instead, which then got encoded in UTF-8 again when it was entered into Reddit.
This is called mojibake, Japanese for "character corruption", and they got to name the word because they have to deal with the most of it.
Some kinds of mojibake, like this one, are really obvious when they happen, and ftfy is a library that can fix them, with a really low rate of false positives. Let's pip install ftfy and try it out:
(Important note: these examples are in Python 3. In Python 2 you should say from __future__ import unicode_literals to make these examples work, but you'll still get ugly representations in the output.)
>>> import ftfy
>>> ftfy.fix_encoding('•')
'•'What sequence of encoding and decoding did it just do to fix it?
>>> ftfy.fixes.fix_encoding_and_explain('•')
('•', [('encode', 'sloppy-windows-1252', 0), ('decode', 'utf-8', 0)])('sloppy-windows-1252' is an encoding that ftfy adds to Python to make it cope with real-world mistakes better.)
And what are we looking at, anyway?
>>> ftfy.explain_unicode('•')
U+00E2 â [Ll] LATIN SMALL LETTER A WITH CIRCUMFLEX
U+20AC € [Sc] EURO SIGN
U+00A2 ¢ [Sc] CENT SIGN
>>> ftfy.explain_unicode(ftfy.fix_encoding('•'))
U+2022 • [Po] BULLETI hope this has been informative. ftfy can do more than that, and here's the documentation.
r/pythontips • u/yangzhou1993 • May 06 '21
In Python, nested loops are not inevitable, assistant variables are not necessary, and we can even customise a for loop by ourselves.
More details:
r/pythontips • u/misha_sv • Apr 03 '21
A good way to start learning Python is with some small projects that are useful. Here is one of them and a complete walk through with examples how to build a simple keylogger using Python: https://pyshark.com/create-a-keylogger-using-python/
r/pythontips • u/DrawFit8234 • Dec 26 '25
Not talking about advanced stuff — more like small details that cause a lot of confusion early on.
The kind of thing that takes 10 seconds to explain once you know it, but feels really confusing before that.
Just curious what examples people have seen or experienced.
r/pythontips • u/atreadw • Apr 16 '21
Python's collections library provides extra data structures beyond base Python's sets, lists, and dictionaries. This post gives a tutorial on how to use the package: http://theautomatic.net/2021/04/14/python-collections-tutorial/
r/pythontips • u/pylenin • Feb 01 '21
For those who are interested, we are organizing this Python Bootcamp for beginners on Pylenin.
Who is this Bootcamp for?
Complete beginners to Python
Programmers knowing the basics and wanting to level up their skills in Python.
Programmers coming from a different programming language.
To learn more, Check out the official page for the Bootcamp.
This introductory video should help you with all the information you need to know to finish the Bootcamp requirements in time. Hope to see you all there.
r/pythontips • u/ritesh_ks • Jan 29 '21
If you have a question that
Python for beginners 2021 or How to learn python? This is a Path to learn python.
First of all, we have to start from the basics. Python version 3 is current python and python version 2 has ended in 2020 due to a pandemic. Support ends in 2020. So start learning python 3 do not go with python 2 tutorials or course.
Here I am going to give you a basic introduction to the python program which can help you start easily.
Python3 - How to install Python | Beginners First video [Linux and Windows] #1
First, learn how to install python after that you can able to run the command
https://www.youtube.com/watch?v=0Wz6Y0tK9GI&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=2
Python3 - Introduction To Python 3 | Absolute Beginner #2
Python is built with c++ this does not mean you learn c++ because you are not going to make any new language or OS. If yes then c++,c is a better option but now we have more than 100 OS, thanks to Linux.
https://www.youtube.com/watch?v=uULduNSMqhg&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=3
Python3 - Variable In Python3 | Absolute Beginner #3
Every program has variables without it program means nothing.
https://www.youtube.com/watch?v=jRupXxrNsms&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=4
Python3 - String Variable In Python3 | Absolute Beginner #4
If you are dealing with integers then no issue but in the case of string, you have to learn how to manipulate it.
https://www.youtube.com/watch?v=A3wV38jFLpo&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=5
Python3 - List In Python3 | Absolute Beginner #5
List, tuple, and the set is very important to work on data otherwise you have to write a huge program for every single character.
https://www.youtube.com/watch?v=QBIiQpBcS5w&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=6
Python3 - Tuple and Set in Python3 | Absolute Beginner #6
https://www.youtube.com/watch?v=3H6PIVL8XQY&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=7
Python3 - Dictionary In Python3 | Absolute Beginner #7
This is the main part where you can store any data with key, even you can store list type and set with a key.
https://www.youtube.com/watch?v=eMV0wFUpL84&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=8
Python3 - Boolean Concepts In Python | Absolute Beginner #8
Boolean will help you decide what is right or wrong . True or false.
https://www.youtube.com/watch?v=-yVAdaVvtqI&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=9
How to install Python3 and VS Code in Windows 10 | VS Code Setup with Python | Absolute Beginner #9
Hope you have installed python and stared writing code but a ide will help you write correct code at time of writing and help you write faster. Visual studio is developed by Microsoft and very good IDE. Learn how to setup with python
https://www.youtube.com/watch?v=bxfje9B6qro&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=10
Python3 - How to Run First Code in Visual Studio Code | Plugin and Extensions |Absolute Beginner #10
Some plugin and setting required to setup for python .
https://www.youtube.com/watch?v=Npqkoqlpvlg&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=11
Python3 - Python Programming in Linux| How to run python file | Absolute Beginner #11
If you are a Linux OS user then you need to know how to run python program in Linux
https://www.youtube.com/watch?v=ylwFXKgqx0E&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=12
Python3 - Data Type Conversion | Absolute Beginner #12
Data is very important and python is best for data management. So you need to know how to manage data or convert it to another.
https://www.youtube.com/watch?v=LsT1CGJJh3U&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=13
Python3 - Keywords In Python3 | ABC of python |Absolute Beginner #13
Actually, there are only 33 to 39 keywords in python according to your version. you can say this is the ABC of python language.
https://www.youtube.com/watch?v=LsT1CGJJh3U&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=13
Python3 - Help In Python3 | Get Offline Help | Absolute Beginner #14
In case you got a job in an MNC security or datacenter. You will not have the internet at work. So you have to know how to get help from the inbuilt help function.
https://www.youtube.com/watch?v=D1liCvSUQH0&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=15
Python3 - Import Modules in Python 3 | How Import Work In Python | Absolute Beginner #3
Python is based on modules this makes our work very easy. But we need to know how to work with the module and how to import in your program.
https://www.youtube.com/watch?v=mmeGs9qp6o4&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=16
Python3- First program with Import module, User Input, Data Conversion, Math | Absolute Beginner #16
If you know the above things you can start writing a program. Starting is always matters. If you started you will reach your destination. So learn how to write your first code in python
https://www.youtube.com/watch?v=MGoTRvKK3iI&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=17
Python3 - If-Else Conditional Statement In Python | |Absolute Beginner #17
Every program based on login is the first logic you have to learn if and else. This will work if you have 2 condition.
https://www.youtube.com/watch?v=7DEx3rWZSVE&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=18
Python3 - If Elif Else Conditional Statement In Python | |Absolute Beginner #18
What will you do if you have more than 2 conditions here elif will come to the picture. You can use as much you required elif.
https://www.youtube.com/watch?v=lrUtpBkYeGw&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=19
Python3 - If Elif Else Nested Conditional Statement In Python | |Absolute Beginner #19
Think of a condition where you have a dependent condition if this is yes then another will work. The solution is nested if-else.
https://www.youtube.com/watch?v=2BIiaBMVEsk&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=22
Python3 - For Loop In Python3 | हिंदी में पाइथन | Absolute Beginner #20
If you want to do an operation on a list or more than one variable you need to know about for loop.
https://www.youtube.com/watch?v=qI44xU0diYc&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=20
Python3 - While loop in Python3 | Very Easy |Absolute Beginner #21
What if you have a to-do operation until you get the desired result. Here while the loop will work it will run the program until got your desired result.
https://www.youtube.com/watch?v=ZimdJ0NPXtk&list=PL266JHFih3oIsBjMNC0eoL9_1xLpPMqYX&index=21
If you know all of this you are not a beginner. Now you can decide which way you want to go.
Now you can choose Automation, Data Science, Machine learning, Artificial Intelligence. Now learn in that direction because you can not be master in all. You can say after this you have completed your SSC or intermediate. Now you have to choose your future stream.
r/pythontips • u/MinerOfIdeas • Jun 06 '24
Because I am doing a lot of library reading but if I do not use it immediately, I forget it.
r/pythontips • u/KneeReaper420 • Jan 28 '24
So I am learning Python for an OOP class and so far I am finding it more enjoyable and user friendly than C, C++ and Java at least when it comes to syntax so far.
One thing I was very surprised to learn was that incrementing is
i +=1
Whereas in Java and others you can increment with
i++
Maybe it’s just my own bias but i++ is more efficient and easier to read.
Why is this?
r/pythontips • u/restinworld • Jul 07 '21
r/pythontips • u/Mdeano1 • Jul 19 '22
when I learned matlab I had similar issues with directories.
i'm just needing to set the current working directory for a program i'm trying to write. so any output from that program will be saved in the correct location.
import os
wrkng = os.getcwd
print("Current working directory: {0}".format(wrkng))
returns this:
Current working directory: <built-in function getcwd>
i'm using visual studio.
what did I mess up.
r/pythontips • u/rhiever • Jun 05 '16
We've all done it. We've been running a long for loop and want to keep track of the loop's progress. Maybe we'll write something like:
for loop_count, item in enumerate(long_list):
if loop_count % 10 == 0:
print(loop_count)
# do something with itemIf you find yourself regularly writing code like that, tqdm was made for you! Now all you have to write is:
from tqdm import tqdm
for item in tqdm(long_list):
# do something with itemand you'll have a beautiful progress bar that even estimates how much longer the loop will take.
Take a look at the tqdm docs for more examples. tqdm is surprisingly advanced, and even integrates with the Jupyter Notebook and pandas groupby operations.
r/pythontips • u/ClickOk5811 • Sep 16 '26
Used to write this everywhere I needed to clean up a temp file that might or might not exist yet:
import os
try:
os.remove(path)
except FileNotFoundError:
passPath.unlink does this in one line with missing_ok:
from pathlib import Path
Path(path).unlink(missing_ok=True)No exception ever gets raised if the file isn't there, so there's nothing to catch or pass on. Same behavior, one line instead of four, and it reads as "delete this if it exists" instead of "try to delete this and hope for the best."
Small thing, but it comes up constantly in any script that's cleaning up intermediate files, cache entries, or output from a previous run.
r/pythontips • u/MinerOfIdeas • Jun 06 '24
Because I am studying the best practices, only most important point. It’s hard to expected that a developer uses and accepts all PEP8 suggestions.
So, What is your favorite “best practice” on python and why?
r/pythontips • u/misha_sv • Jun 28 '21
Most of us came across a problem of reading some interesting research or text in PDF format which had tables with useful data. So we want to extract the data but don't know how. Thanks to tabula-py library package, you can extract tables from PDF files in a few lines of code!
r/pythontips • u/geekyhumans • Apr 24 '21
I created a small password generator which uses Secrets module not the Random module which makes it more secured:
https://geekyhumans.com/generate-passwords-using-python-and-secrets/
r/pythontips • u/brendanmcd96 • Oct 30 '19
Decorators are an advanced feature of the python language that allow you to modify the behavior of a function or method without touching its code. This video will teach you why decorators work and how to create your own. It will also walk through a few examples to give you a better idea of where to use python decorators.
r/pythontips • u/nathanalderson • Jul 15 '21
The else clause executes only if the for-loop completed without hitting a break statement. The typical use case is for searching a list and handling the case where you didn't find the thing:
for item in some_list:
if is_special(item):
print(f"Found a special item: {item}")
break
else:
print("No special item found")The syntax is a bit obscure, though, so I would generally favor something clearer like:
try:
special_item = next(item for item in some_list if is_special(item))
print(f"Found special item: {special_item}")
except StopIteration:
print("No special item found")r/pythontips • u/pylenin • Jul 11 '19
Printing is the first thing people learn when they enter the world of programming. but sadly, not many articles or videos cover all the aspects associated with print. I have tried to cover print by diving deeper into various aspects associated with it. Hope you like it !
https://www.pylenin.com/blogs/python-print/
r/pythontips • u/pylenin • Jun 07 '19
I realized that some people like to read blogs over watching a video. Therefore I have started to write blogs about every youtube video I am making.
Check out my blog on A Step-by-Step guide to Python Logging
r/pythontips • u/wilfredinni • Apr 17 '19
Anyone can forget how to make character classes for a regex, slice a list or do a for loop. This cheat sheet tries to provide a basic reference for beginner and advanced developers, lower the entry barrier for newcomers and help veterans refresh the old tricks.
r/pythontips • u/wyhjsbyb • May 26 '26
Python 3.15 has reached beta 1, which means no new features will be added before the final release.
I went through the official docs and wrote up the updates I think Python developers should actually care about in daily work.
Some of my favorites:
- lazy imports for faster startup
- frozendict for immutable mappings
- sentinel for cleaner missing-value APIs
- unpacking in comprehensions
- UTF-8 as the default encoding
- Tachyon, the new sampling profiler
- better error messages
- JIT compiler improvements
- better typing features
Curious which feature people here think will matter most in real projects.