r/pythontips • • Jun 16 '20

Module Here's a quick and easy way to add icons to your Qt GUIs for PySide2/PyQt5

33 Upvotes

I've been using the qtawesome package to add FontAwesome icons to my projects and it's been really fast and convenient. It's built with qtpy so it should really support all Qt bindings (PyQt4, PyQt5, PySide, PySide2).

Here are some examples to get you started: How to add font awesome icons to PyQt and PySide


r/pythontips • • Jan 21 '20

A Cool Python based Project – Learn to Build Image Caption Generator with CNN & LSTM

33 Upvotes

Project based on Python – Image Caption Generator 

You saw an image and your brain can easily tell what the image is about, but can a computer tell what the image is representing? Computer vision researchers worked on this a lot and they considered it impossible until now! With the advancement in Deep learning techniques, availability of huge datasets and computer power, we can build models that can generate captions for an image.

This is what we are going to implement in this Python based project where we will use deep learning techniques of Convolutional Neural Networks and a type of Recurrent Neural Network (LSTM) together.

Below are some of the Python Data Science projects on which you can work later on:

  1. Fake News Detection Python Project

  2. Parkinson’s Disease Detection Python Project

  3. Color Detection Python Project

  4. Speech Emotion Recognition Python Project

  5. Breast Cancer Classification Python Project

  6. Age and Gender Detection Python Project

  7. Handwritten Digit Recognition Python Project

  8. Chatbot Python Project

  9. Driver Drowsiness Detection Python Project

  10. Traffic Signs Recognition Python Project

  11. Image Caption Generator Python Project

Now, let’s quickly start the Python based project by defining the image caption generator.

What is Image Caption Generator?

Image caption generator is a task that involves computer vision and natural language processing concepts to recognize the context of an image and describe them in a natural language like English. Read More


r/pythontips • • Oct 22 '19

Can someone convert the appended .py file to .exe and .app (or at least one of them), so that it can run on a computer that doesn't have python, and then tell me how you did it?

33 Upvotes

SOLUTION:

Run this in cmd:

>>>pip install pyinstaller
>>>pyinstaller --onefile -w C:\path\to\file.py

The error was caused by me having Python 3.8, whilst pyinstaller only works for 3.7 and lower. Downgrading was the solution.

https://gofile.io/?c=qujpGn

It's an example file, using module tkinter. Tell me if the link doesn't work.

I've been trying to convert a .py to .app and .exe with programs such as py2app and py2exe, but I've always received an error. Could someone convert the sample file and send it to me? I have another .py file for a high school project I'd like to convert next, so I would appreciate to know what method worked.


r/pythontips • • Sep 23 '19

The magic __get__ method and how to use it! Enjoy!

33 Upvotes

Video

Hello!

This video is about how you can use the python __get__ method to make your class act like an attribute, and some of the benefits this can provide.

Hopefully you learn something. constructive criticism is welcome as we're all learning, including myself

Enjoy!


r/pythontips • • Sep 21 '19

The fastest way to remove consecutive duplicates from Python List. A comparison of 3 different ways.

33 Upvotes

I have tried to show 3 ways in which you can remove consecutive duplicates from a Python list. I have also shown the fastest out of the 3 different ways of doing it. Check out my blog.
https://www.pylenin.com/blogs/remove-consecutive-duplicates/


r/pythontips • • Jul 02 '19

I created a Python tutorial for beginners. Let me know what you think!

33 Upvotes

r/pythontips • • Apr 18 '19

Flask vs. Django: Choose Your Python Web Framework

33 Upvotes

Flask or Django?

According to the 2018 Python Developers Survey, Flask and Django are, by far, the most popular web frameworks for Python developers. You’ll hardly go wrong with either framework if you’re deciding which one to use for a new web application. While it’s up to you to figure out which one works best for what you’re trying to accomplish, there’s a few major differences you should be aware of when making the decision. Regardless of which framework you end up using, both are very well documented and widely used, so they have ample active and supportive communities. So, without further ado, let’s take a look at what each framework offers and highlight some of their differences and similarities.

TL;DR Flask vs Django Differences

Flask and Django are mature, extensible web frameworks that, at their core, offer similar functionality in handling requests and serving up documents, but differ in their scope of responsibility. Most of the differences between the 2 frameworks stem from this different approach although some also stem from some different core design decisions. Here is a short list of key differences that might impact your decision:

  • The Request Object - Flask uses thread-locals while Django passes the request around where it’s needed.

  • Forms - Django comes with them built-in and they integrate with the ORM and the admin site. Flask has no default support for forms, but you can use WTForms to fill the gap.

  • The Database - Django comes with the Django ORM and a migration system that wants to manage your database. Flask makes no assumptions about a database, but there are tools out there, like SQLAlchemy that provide similar functionality (perhaps more).

  • Authentication & Permissions - Django comes with an authentication app that gives a default implementation for user management and permissions. Flask provides secure cookies as a tool for your own implementation.

  • Admin Site - Django comes with a fully integrated admin interface for managing application data. Flask doesn’t come with anything like it, but Flask-Admin is a popular extension that can be used to create a similar admin tool.

Read more on the Kite blog!


r/pythontips • • Mar 02 '19

Domino effect in 10 lines of Python - Blender 3d tutorial

33 Upvotes

r/pythontips • • Mar 26 '24

Standard_Lib Using the 'zip' function to merge two lists into a dictionary

32 Upvotes

Suppose you have two lists, one containing keys and the other containing values, and you want to merge them into a dictionary.

You can do that with a code like this:

# Original lists
keys = ['name', 'age', 'gender']
values = ['Alice', 25, 'Female']

# Merge the lists into a dictionary using zip
merged_dict = dict(zip(keys, values))

# Print the merged dictionary
print(merged_dict)

# Output:
# {'name': 'Alice', 'age': 25, 'gender': 'Female'}

The zip function returns an iterator that aggregates elements from each of the input iterables, which can be passed to the dict constructor to create a dictionary.


r/pythontips • • Jul 17 '23

Module Learning to actually write my own code

32 Upvotes

I'm (42F) brand new to learning Python. I understand the lessons in my course, but when it comes to solve a problem that involves me writing code, I feel so lost. I very motivated to learn. What can help me learn to think like a programmer? Any tips appreciated!


r/pythontips • • Feb 14 '23

Short_Video 3 Simple Programming Tips for Beginner Python Programmers

32 Upvotes

As a new Python programmer, it can be easy to forgo syntax because this often seems like a less important aspect of programming. You often just want to solve the problem and do not worry about the sloppiness of the code. However, practicing good syntax from the beginning and slowly learning ways to improve your code syntactically can be very important in practice. In this video, I talk about 3 simple ways to instantly improve your code syntactically that are easy to remember and can help you have more professional-looking code in accordance with pep 8 standards.

1-) Organize imports accordingly

2-) Be cognizant of white space in your code

3-) Use f strings when possible (except for logging) as they are superior to previous forms of string formatting.

https://youtu.be/docjgO_1VCQ

Also please give the video a like and subscribe if you enjoy learning simple ways to improve your Python code.

Let me know if you have any questions or concerns. Thanks!


r/pythontips • • Nov 22 '22

Syntax How to schedule a code to run on weekdays only

32 Upvotes

Hi, I have a python code which scans the stock market and give predictions. This script will run every 15 min, which i have done using sleep. Now i want to put this code on cloud. How can i schedule the code to run on weekdays only (so that i dont run out of my hourly capacity for free tier) without using any dynos( they don't come in the free tier mostly)


r/pythontips • • Jul 06 '22

Syntax What's the best way to organize a library of Python scripts?

32 Upvotes

I'm new to Python and my learning project has been rewriting my library of BASH automation scripts that I've been adding to over the years. These scripts do everything from normalizing file names and automatically organizing documents on my computers, to automating services running on my homelab. I am not certain of the pythonic way to roll these out across my many computers that meets the following requirements.

My desired end-state is:

  • N number of standalone scripts which share some common utility functions

  • Scripts can be invoked from within my user's PATH across multiple computers

  • Scripts live in a single git repository and directory structure along-side BASH scripts

  • Easiest path to long-term maintenance as I add to the corpus of scripts and make updates.

Here's a few of the patterns I've tried:

  1. Use PYENV to ensure each computer has the same version of python and installing requirements.txt in the user-space into the PYENV version of Python. Then adding my shared functions to a common directory path and adding it to PYTHONPATH so imports will work. Lastly creating symlinks to the Python scripts to /usr/local/bin so they will be in my user's PATH.

  2. Creating a virtual environment within my script folder and creating a wrapper function in BASH that enters the venv, invokes the script, and then deactivates the venv

  3. Using Setup Tools to create an executable which includes all the requirements. (Read somewhere that this is no longer the preferred method, but :shrug:)

All of the above work but I'm left scratching my head on what the most common and Pythonic solution is. Any help would be greatly appreciated.


r/pythontips • • May 20 '22

Syntax Learning Python

32 Upvotes

Hi guys, I've just registered for a programming course where I am learning Python as a complete novice. I'm a pretty fast learner, so I hope to do well. Wish me luck guys. 🙏🏽 Also, any fast learning tips and tricks will be highly appreciated. 🙏🏽


r/pythontips • • Feb 01 '22

Data_Science How long did it take you to “master” python?

32 Upvotes

Obviously you are never done learning but at what point did you become proficient and confident in it?


r/pythontips • • Sep 07 '21

Short_Video Finding the International Space Station with Python

32 Upvotes

I have created a 5 min video on it.Youtube Link - https://www.youtube.com/watch?v=1S3ccKEyokY

But a quick run down, for people who don't want to watch. I basically use an api to get the latitude and longitude of ISS. Then use openstreetmap.org to plot the marker.

Api - http://api.open-notify.org/iss-now.json


r/pythontips • • Aug 23 '21

Meta Is really worth reading python books even if you have online courses with the same content?

32 Upvotes

I saw a Lot of people talking about python books, but a have online courses with the same content, should I read the books or just stay in the online classes?


r/pythontips • • Aug 01 '21

Short_Video Python Currency Converter | no API needed | Accurate Data

32 Upvotes

Python Currency Converter | no API needed | Accurate Data

Hello friends,

I have made a tutorial on currency converter. There is already a module for that but here I showed that its not uptodate or accurate. But with this script you can get accurate data and no api needed.

How it works

- using requests to get data from url

- translated xml data to json.

- makes a quick python script as an output

- importing the same output as module

- & running the function.

Video Demonstration:- https://www.youtube.com/watch?v=2A7DoJMejlQ


r/pythontips • • Jul 23 '21

Algorithms 🐍 How to make a Twitter Bot in Python using Tweepy

32 Upvotes

🗣 A reply-to-mention Twitter bot that can reply to every tweet where it got mentioned with a specific keyword with an auto-generated image. Read more...


r/pythontips • • Jul 02 '21

Short_Video What Is django? | Learn django | Tutorial #1

32 Upvotes

r/pythontips • • Mar 24 '21

Python3_Specific How to debug in Python?

32 Upvotes

Please share some tips about the title.


r/pythontips • • Feb 25 '21

Syntax suffix = ["st", "nd", "rd"][day % 10 - 1]

32 Upvotes

Can anyone explain what is going on here? Reading the code but don't quite understand what it does


r/pythontips • • Nov 24 '20

Python3_Specific Track the number of Astronauts in Space with the help of Python.

32 Upvotes

r/pythontips • • Oct 04 '20

Module 8 Ways to Drop Columns in Pandas | A Detailed Guide

32 Upvotes