sub
stringclasses 1
value | title
stringlengths 7
303
| selftext
stringlengths 0
8.65k
| upvote_ratio
float64 0.08
1
| id
stringlengths 9
9
| created_utc
float64 1.65B
1.65B
|
---|---|---|---|---|---|
Python | If an exception is raised but not handled would the process definitely stop/crash? I have seen some programs that keep printing stack trace to cli but don't crash and keep trying. | EDIT: thanks i think i got my answer.
```py
while True:
try:
something_that_raises_exception()
except as e:
logger.error(e)
``` | 0.87 | t3_tsux1z | 1,648,714,032 |
Python | Print Emoji's using Python. | 0.38 | t3_tsusc7 | 1,648,713,463 |
|
Python | Real Time Speech Recognition | 0.83 | t3_tst6rj | 1,648,706,438 |
|
Python | Demo for game made with Pygame | 0.91 | t3_tssu7d | 1,648,705,022 |
|
Python | First Python Application - Blackjack Strategy Trainer - Seeking Feedback | Hi everyone! I just finished my initial beta for a blackjack training simulator. The application helps the user practice basic blackjack strategy. If you check it out and have some feedback for improvement, I would love to hear it! Thanks and enjoy!
​
[https://github.com/lrassbach/blackjack-training-simulator/releases](https://github.com/lrassbach/blackjack-training-simulator/releases) | 0.78 | t3_tsrmiu | 1,648,700,446 |
Python | I made a utility library for downloading Wikimedia Data Dumps for analysis | I created a small utility library that exposes the directory structure of Wikimedia’s data dump site (and its mirrors).
It includes a method to easily download and decompress data dumps using Python’s built in libraries - this proved to be an especially difficult problem because the data dumps are sometimes several times larger than the system’s memory.
[Source code here.](https://github.com/jon-edward/wiki_dump) | 0.83 | t3_tsq2c8 | 1,648,695,137 |
Python | Tuple Reuse Quirks | I was testing tuple reuse today and noticed some strange behavior. If you run all the code below together as a script, 1) a and b have different IDs, as do c and d; but when you enter them in the interpreter line by line: 2) a and b have the same IDs, 3)c and d have the same IDs.
Of the 3 observations, only 2) matches my expectation based on my understanding of tuple reuse, which is that Python moves tuples with fewer than 20 items to a "free list" after their reference count reach 0, (to make them available for potential reassignment later)
Could someone explain why 1) and 3) happen? Thank you!
`a = (1,2,3)`
`print(id(a))`
`del a`
`b = (1,2,3)`
`print(id(b))`
​
`c = (4,5,6)`
`print(id(c))`
`del c`
`d = (7,8,9)`
`print(id(d))` | 0.75 | t3_tso711 | 1,648,689,060 |
Python | Thursday Daily Thread: Python Careers, Courses, and Furthering Education! | Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!
**This thread is not for recruitment, please see** r/PythonJobs **or the thread in the sidebar for that.** | 0.84 | t3_tsmv9p | 1,648,684,810 |
Python | Python or R? | I searched some differences but not found definite answer. So, I ask you. Which one is better for business?
My company has over 3 million customer and tons of data expectedly. I will study in a different department after 3 or 2 years later and it will be about data analysis of costumers. Which one should I start with? Python or R? | 0.3 | t3_tsjvib | 1,648,676,061 |
Python | Pollen Robotics' Reachy VR Digital Twin in Python (proof of concept) | Demonstration of a **"Reachy"** **digital twin** in **virtual reality**, based on **Python** and **HARFANG**.
The goal of this P.O.C is to demonstrate that a simple digital twin of an existing robot can be implemented in less than 500 lines of **Python**. This digital twin shows a **VR** experience that could serve to bootstrap a **tele-operation** project :
\- the user can see what the robot sees, using the 3D simulation in **virtual reality**
\- the user can move his hands around, the **arms** of the **robot** will follow
\- it helps to test the **challenge** of a tele-operation process
The robot in this demonstration is a **Reachy, developped by the French company Pollen Robotics**.
The physics & inverse kinematic solver is handled by PyBullet.
The VR is simulated by HARFANG 3D.
[https://www.youtube.com/watch?v=TBAjNGPpMfc](https://www.youtube.com/watch?v=TBAjNGPpMfc) | 0.84 | t3_tsjsaf | 1,648,675,816 |
Python | pymac: Install and manage macOS Python.org installers from the command line | 0.99 | t3_tsjhe7 | 1,648,675,001 |
|
Python | A simple Snooker 3D game in Python | Hi there,
I would like to share a tiny **game** project all made in **Python** : a **Snooker simulator.**
The gameplay is rather limited, as the aim of this project is to focus on the simulation aspect : how to produce a realistic snooker physics, with a visual rich enough to be on part with nowadays standards ?
To reach this goal, this project relies on 2 major **features** :
\- a **physics** engine, running at high frequency to handle the friction of the balls
\- a **3D rendering** engine, with 2 quality modes, the highest quality mode including realtime reflections and radiosity (doesn't require a RTX GPU).
I hope you folks will enjoy the project, can **learn** from it and maybe be turn it into something bigger!
[https://github.com/harfang3d/snooker-python-hg2](https://github.com/harfang3d/snooker-python-hg2) | 0.89 | t3_tsixth | 1,648,673,568 |
Python | Introducing Slap: A CLI to assist in the Python development process | I would like to share a project with you that I have been working on and actively using for over 1.5 years to streamline my day-to-day tasks developing Python projects. I use Slap tens to hundreds of times a day and would not want to miss it anymore.
**Slap streamlines Python development tasks**
>[Slap](https://niklasrosenstein.github.io/slap/) is a command-line tool to assist in the development of Python projects independent of the [PEP 517](https://peps.python.org/pep-0517/) build backend being used, capable of managing single- and multi-project repositories.
Among the things that Slap can do, here is a short selection:
* Perform development installs of your project (even for Poetry projects)
* Manage local & global virtual environments
* Bump version numbers (not just in `pyproject.toml`)
* Publish to PyPI
* Manage structured changelogs in TOML format
* All while capable of handling mono-repositories that consist of more than one Python project
*--- Check out the* [*Getting started*](https://niklasrosenstein.github.io/slap/getting-started/) *page in the documentation to get a more in-depth look into what Slap can do for you. ---*
**Slap seems similar to the Poetry CLI, what's different?**
Some people might find this similar to tools like Poetry, and while there is some overlap in functionality, Slap is **not a build backend** and is more targeted towards library development. Most of my projects use Poetry as the build backend but I never even once interact with the Poetry CLI throughout the lifetime of the project.
The most notable differences to Poetry are
* Slap supports mono-repositories (i.e. multiple related Python projects in the same repository), to the extent that it bumps version numbers of project inter-dependencies and installs your projects in topological order
* Slap supports development installs independent of the build backend (yes; this means you can install Poetry packages in editable mode even though the Poetry backend right now does not support editable installs)
* Slap's version bump command (`slap release`) updates the version not just in your `pyproject.toml` but also the `__version__` in your source code as well as in related projects (see mono-repositories above) and any additional references you can configure via Regex patterns
* Slap does not automagically create a virtual environment for you when installing your project(s); instead, it errors when you try to install into a non-virtual Python environment and gives you an easy-to-use tool to create and activate virtual environments (and allowing multiple environments per project as well as global environments)
* Slap uses Pip to install your project(s), unlike Poetry which comes with its own dependency resolver and package installer (which I have been having a lot of issues with in the past).
* Slap does not have a concept of lock files
**Ideas / Suggestions / Contributions**
Slap is currently very opinionated by the fact alone that I built it as my personal workflow tool, but I welcome suggestions and contributions, and I am hopeful it will be useful to a wider audience than myself.
**Links**
* Documentation: [https://niklasrosenstein.github.io/slap/](https://niklasrosenstein.github.io/slap/)
* GitHub: [https://github.com/NiklasRosenstein/slap](https://github.com/NiklasRosenstein/slap)
* PyPI: [https://pypi.org/project/slap-cli/](https://pypi.org/project/slap-cli/)
**Edit**: I've added an in-depth [Getting started](https://niklasrosenstein.github.io/slap/getting-started/) guide to the documentation. | 0.84 | t3_tsgavg | 1,648,669,463 |
Python | Python Tutorial - How to create a Screen Recorder using Python? | Hey Everyone! I created a short Python Tutorial explaining how I created a Screen Recorder using Python.
[https://www.youtube.com/watch?v=449c5lsGKKw](https://www.youtube.com/watch?v=449c5lsGKKw)
https://preview.redd.it/ro2g0wc5hkq81.png?width=2880&format=png&auto=webp&s=649c062e96554d29b4348c07eb076a767b3d929b | 0.74 | t3_tsdftv | 1,648,666,101 |
Python | [GUI] DyCall - Run exported functions from dynamic libraries | 0.75 | t3_tsdcn8 | 1,648,665,866 |
|
Python | I Created a Simple Pushup Counter Using Mediapipe Python | 0.77 | t3_tsb1mf | 1,648,659,632 |
|
Python | Any good Machine learning udemy courses ? | I recently took python course and I’m learning python I want to get into machine learning and ai is there any good udemy courses for this? I see an A-Z machine learning course but is it good ? If anyone has taken it can you tell me what it exactly teaches you or does it just skip important points thanks | 0.71 | t3_ts9m9n | 1,648,655,819 |
Python | Scrape Google Scholar Metrics Results to CSV with Python | Full code:
```python
import requests, lxml
from bs4 import BeautifulSoup
import pandas as pd
def scrape_all_metrics_top_publications():
params = {
"view_op": "top_venues", # top publications results
"hl": "en" # or other lang: pt, sp, de, ru, fr, ja, ko, pl, uk, id
}
# https://docs.python-requests.org/en/master/user/quickstart/#custom-headers
# whatismybrowser.com/detect/what-is-my-user-agent
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Safari/537.36"
}
html = requests.get("https://scholar.google.com/citations", params=params, headers=headers, timeout=30)
soup = BeautifulSoup(html.text, "lxml").find("table")
df = pd.DataFrame(pd.read_html(str(soup))[0])
df.drop(df.columns[0], axis=1, inplace=True)
df.insert(loc=2,
column="h5-index link",
value=[f'https://scholar.google.com/{link.a["href"]}' for link in soup.select(".gsc_mvt_t+ td")])
df.to_csv("google_scholar_metrics_top_publications.csv", index=False)
# save to csv for specific language
# df.to_csv(f"google_scholar_metrics_top_publications_lang_{params['hl']}.csv", index=False)
def scrape_all_metrics_public_mandates():
params = {
"view_op": "mandates_leaderboard", # public access mandates results
"hl": "en" # or other lang: pt, sp, de, ru, fr, ja, ko, pl, uk, id
}
# https://docs.python-requests.org/en/master/user/quickstart/#custom-headers
# whatismybrowser.com/detect/what-is-my-user-agent
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Safari/537.36"
}
html = requests.get("https://scholar.google.com/citations", params=params, headers=headers, timeout=30)
soup = BeautifulSoup(html.text, "lxml").find("table")
df = pd.DataFrame(pd.read_html(str(soup))[0])
df.drop(df.columns[[0, 2]], axis=1, inplace=True)
df.insert(loc=1, column="Funder Link", value=[link.a["href"] for link in soup.select("td.gsc_mlt_t")])
df.to_csv("google_scholar_metrics_public_access_mandates.csv", index=False)
# save to csv for specific language
# df.to_csv(f"google_scholar_metrics_public_access_mandates_lang_{params['hl']}.csv", index=False)
```
If you need an in-depth explanation, have a look at [Scrape Google Scholar Metrics Results to CSV with Python](https://serpapi.com/blog/scrape-google-scholar-metrics-results-to-csv-with-python/) blog post at SerpApi. | 0.4 | t3_ts9lzb | 1,648,655,795 |
Python | Building a Full Stack Flask HTMx Application | 0.75 | t3_ts8x51 | 1,648,653,894 |
|
Python | I created 80 Python and Pandas Challenges with Video Solutions | 0.84 | t3_ts8hpw | 1,648,652,727 |
|
Python | Transcribe Speech to Text with Python for Free | 0.67 | t3_ts6whh | 1,648,648,258 |
|
Python | What to expect from Python 3.11? | 0.95 | t3_ts6idv | 1,648,647,068 |
|
Python | GitLab Webhooks [Python and Google Chat Example] | 1 | t3_ts66bz | 1,648,646,050 |
|
Python | I made a video about efficient memory use in pandas dataframes! | 0.96 | t3_ts5mmf | 1,648,644,350 |
|
Python | Create a google account in Python |
I would like to be able to create google account with a python script. I've try with Mechanize but nothing conclusive. Do you have any idea to how to do that ?
I tried with the library Mechanize. I get the first form with:
* FirstName
* LastName
* UserName
* Password
I submit it, but impossible to get the second form... | 0.5 | t3_ts5l04 | 1,648,644,210 |
Python | Python program to find day of any date.(Yes any! from 1000 AD - 9999 AD) | ​
[Program in action!](https://preview.redd.it/5eorq0mfniq81.png?width=1484&format=png&auto=webp&s=426f40c1b36cd85844c3f1565b8906da58c404f2) | 0.65 | t3_ts5ij2 | 1,648,643,992 |
Python | ABCMeta library to limit derived classes their methods to follow the same signature as the parent | Python metaclass and abstract method library with restrictions.
This library provides a restricted way to validate abstract methods. The Python's default abstract method library only validates the methods that exist in the derived classes and nothing else. What this library provides is apart from that validation it provides validations over the method's signature. All you need is to import ABCMeta and abstractmethod from this library.
[https://github.com/mortymacs/abcmeta](https://github.com/mortymacs/abcmeta) | 1 | t3_ts4ooj | 1,648,641,121 |
Python | Authoring Opportunity: Developing a Python book with Packt Publishing | Hi all,
I am a Product Manager at Packt Publishing.
Packt is a publishing company helping the world put software to work in new ways, through the delivery of effective learning and information services to IT professionals.
We are planning to publish a book on Python to address the challenges and requirements of the Python community.
We are looking for an expert experienced Python developer who could share their valuable insights on the topic and collaborate with us in developing content for a book that we are planning to publish.
If you feel you might be interested in this opportunity please send me a direct message on or before 7th April 2022.
PS: Content development experience in terms of writing a blog or anything else is appreciated but not required. | 0.33 | t3_ts4caw | 1,648,639,896 |
Python | br4nch 1.2.1 - Data Structure Tree Builder for Python. | ***New patch released (1.2.1) that improves alot of features!***
​
`br4nch` is created to provide an efficient implementation of tree data structure in ***Python***.
​
The **libary** is built on pure python so you don't need **ANY** other libaries.
The amount of features are endless such as: **adding**, **deleting**, **renaming**, **moving**, **copying**, **painting**, **sizing**, **change symbols**, **importing folder structure**, **exporting to txt and br4nch file**, etc..
​
*PyPi*: [https://pypi.org/project/br4nch/](https://pypi.org/project/br4nch/)
*Documentation*: [https://docs.br4nch.com/](https://docs.br4nch.com/)
*Github*: [https://github.com/TRSTN4/br4nch](https://github.com/TRSTN4/br4nch) | 0.75 | t3_ts4avc | 1,648,639,752 |
Python | python dictionary comprehension | 0.67 | t3_ts3lg7 | 1,648,637,091 |
|
Python | Do you have experience with stocks prices analysis? | I am about to start a hobby project, mainly for learning and curiosity. I want to analyze stocks data and try to learn some basic concepts about investing and machine learning. The flow should be following:
\- Use some free API to get historic stocks data.
\- Store data in the database (probably PostgreSQL hosted on Heroku).
\- Train neural network to predict stocks prices (here, I have the biggest knowledge gap).
\- Use some free API to get real-time stocks data.
\- Store real-time data in the database.
\- Compare predicted stocks prices with actual stock prices in BI tools like GoodData, or Looker.
I know it is not rocket science, but as I said, my motivation is to learn something new. Before I start, I would like to ask you if you have experience with such a similar project and if there is something you might recommend to me. | 0.71 | t3_ts2ujz | 1,648,633,956 |
Python | How to document python functions? | Link: [https://www.youtube.com/watch?v=fU6qB06rkz0](https://www.youtube.com/watch?v=fU6qB06rkz0) | 0.33 | t3_ts2t1f | 1,648,633,755 |
Python | Froyo: A Python GUI utility for downloading works from Archive Of Our Own/AO3 (made in Python with Dear PyGui): a fast, responsive graphical user interface results in a user-friendly tool | ​
[Froyo: A Python GUI utility for downloading works from Archive Of Our Own\/AO3 \(made in Python with Dear PyGui\): a fast, responsive and user-friendly tool](https://i.redd.it/xyrdfo9zahq81.gif)
Froyo is a small graphical application for downloading works from Archive Of Our Own (AO3). It supports batch downloading of works to supported formats (AZW3, EPUB, HTML, MOBI, PDF). The app is small, fast and functional, a perfect fit for Dear PyGui. Not every app has to be complex. Sometimes a tool just needs to get the job done. | 0.89 | t3_ts1iat | 1,648,627,758 |
Python | Programming languages: Python just got a boost from Facebook's Meta | 0.4 | t3_ts1al4 | 1,648,626,768 |
|
Python | Understanding __init__ Method in Python | 0.73 | t3_ts0cgt | 1,648,622,580 |
|
Python | How do you define beginner, intermediate, and advanced? |
These terms are used frequently, but many seem to often disagree on them. Could be used to describe a persons knowledge, competence, or the qualiry od code/codebase etc.
I would say a beginner is just someone who is learning the actual language, syntax, just learning to code. Maybe touching on the common built-in libraries, learning classes, and basic OOP.
Intermediate is past the syntax and basic concepts and is using libraries. Intermediate is a lot longer phase, I think. Intermediate is learning about programming concepts, practices, patterns, design, libraries, ...
Advanced (again, in my perspective) is not a wizard who knows Python internals and corners of the python object model. It's someone who can create useful, well-structured programs from the ground up properly, using the right tools and libraries. Not just doing practice projects, but a larger product properly. Able to pretty much learn any technology needed for a project.
What do you think? What do you disagree with? | 0.92 | t3_try32l | 1,648,613,843 |
Python | ipyvizzu - create animated charts in Jupyter Notebook using Python with this open-source tool | Hey,
We've built and released a new integration of our open-source charting library Vizzu. We hope this will help data scientists and analysts share their insights easier by utilizing animation for storytelling with data. We'd love to know what you think about it.
More info, tutorial & examples: [https://github.com/vizzuhq/ipyvizzu](https://github.com/vizzuhq/ipyvizzu)
Here's a short video illustrating how ipyvizzu works.
https://reddit.com/link/trxyg5/video/j6rd94q6mcq81/player | 0.77 | t3_trxyg5 | 1,648,613,371 |
Python | Wednesday Daily Thread: Beginner questions | New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at [https://discord.gg/python](https://discord.gg/python) where you stand a better chance of receiving a response. | 1 | t3_trtfcd | 1,648,598,410 |
Python | Looking for tips | I made a program to try and simplify square root radicals with python. I would like to get some feedback and tips on how to write some better code.
[https://github.com/Falt-b/simpliify-radicals](https://github.com/Falt-b/simpliify-radicals) | 0.8 | t3_trlofs | 1,648,587,916 |
Python | I made a web-based Instagram bot that scrapes people's usernames and follows/unfollow them | ​
https://reddit.com/link/tre7to/video/nf7rtqni9dq81/player | 0.86 | t3_tre7to | 1,648,579,177 |
Python | Multi-threaded Omegle bot with proxy support and other neat features, like content spinning and typo generator. | [https://github.com/embium/Omeglebot](https://github.com/embium/Omeglebot)
# Omeglebot
Multi-threaded Omegle bot with proxy support and other neat features, like content spinning and typo generator.
I'm not even sure it's possible to run without proxies.
I could sell this but I rather release it publicly.
This supported me financially for a few years. Enjoy. | 0.76 | t3_tre8z9 | 1,648,579,265 |
Python | pync - Netcat for Python | Hi, I've been reading Black Hat Python and decided to try and make a Netcat library for Python developers.
It's not fully there yet (there's a few things I still need to do), but I thought I'd share it anyway in hopes that someone might find it useful.
Anyway, here's the [GitHub repo](https://github.com/brenw0rth/pync) for the project if you're interested.
Any feedback or criticism is welcome, thank you. 😊 | 0.84 | t3_tre60y | 1,648,579,046 |
Python | Any idea when Spyder Notebook will be stable and running for Spyder 5? | I would like to use it | 0.33 | t3_trbyzk | 1,648,577,411 |
Python | Tomorrow: a live 45-minutes session on the fundamentals of observability, OpenTelemetry, and distributed tracing in Python | Hi everyone, a quick reminder about the live OpenTelemetry and observability fundamentals session - in 2 days, Wednesday, March 30 at 11 AM PST.
You will learn how to instrument your apps to capture traces with OpenTelemetry in Python.
This session is at no cost and vendor-neutral.
You can expect in this session: 45 minutes of core concepts, how to deploy it yourself hands-on + Q&A.
If you are interested in observability, OpenTelemetry, and tracing - join!
Register here [https://www.aspecto.io/get-started-with-opentelemetry/](https://www.aspecto.io/get-started-with-opentelemetry/?utm_source=post&utm_medium=reddit&utm_campaign=r-python-opentelemetry-workshop-pyhon-march-30-2022) | 0.87 | t3_tra9f1 | 1,648,574,859 |
Python | I built a real-time stock tracker using Python + Fast API, Alpaca, Next.js, and Redis Stack. Check it out! | 0.67 | t3_tra4u1 | 1,648,574,515 |
|
Python | I love type annotations, so I made a quick tutorial on how to add types to Flask SQLAlchemy | 1 | t3_tr9r9n | 1,648,573,518 |
|
Python | IndiePython.com - content about indie projects using Python (specially gamedev) | Hello, I'd like to present a website ([indiepython.com](http://indiepython.com)) I created to publish content about my indie Python projects including apps and games. It is still a work in progress, but it already has a lot of content about projects I'll be releasing, including, for instance, a node editor to be released on June 2022 like you can see below. My apps and their source code are free of charge and will be released to the public domain, both on github and pypi (can be installed via "pip install" command).
[Nodezator \(node editor to be released on June 2022 to the public domain\)](https://reddit.com/link/tr5l1q/video/qfelxkvcicq81/player)
It should feature other content like tutorials/articles as well in the future. Thanks for your time. | 0.6 | t3_tr5l1q | 1,648,569,821 |
Python | If a person posts Python code to Amazon Web Services can it run all the normal Python libraries? I was thinking to a greater extent about moviepy.editor. | If a person posts Python code to Amazon Web Services can it run all the normal Python libraries? I was thinking to a greater extent about moviepy.editor. | 0.55 | t3_tr43cm | 1,648,566,871 |
Python | Boss told me to learn python. | Got told I need to learn python from my boss, where should I start? Codeacademy? Like how they are teaching you there. But how good is it? Better places to learn?
*Edit*
My boss wants me to learn to program for robots and different task for automation of tasks. He told me I should learn the basics and then more about that field. Thinking something like making bots should be a good project?
Current knowledge is Visual Basic some years ago. | 0.83 | t3_tr31rs | 1,648,566,271 |
Python | Garmin Connect File Manager | Hey everyone,
I put together [this project](https://github.com/lucas-nelson-uiuc/garmin-connect-file-manager/tree/main) to help me store (and, in the future, analyze) activities recorded on my Garmin to my local computer. It builds off the popular [gcexport](https://github.com/kjkjava/garmin-connect-export) repo with additional functionality including summary/geographical data extraction as well as activity-based sorting.
Feel free to look things over if you're looking to critique someone's code today and/or implement this in your Garmin data backup routine. | 0.6 | t3_tr2oml | 1,648,566,073 |
Python | Pagination for a User-Friendly Django App – Real Python | 1 | t3_tr1m2y | 1,648,564,625 |
|
Python | Loading config from the environment in Quart & Flask | 1 | t3_tqz50j | 1,648,558,577 |
|
Python | What is a Lambda function and its applications in Python | In this short article, I'm gonna explain Python's lambda functions in detail. A lambda function is a small anonymous function that can take any number of arguments but can only have one expression. Here is its syntax:
**lambda arguments : expression**
The expression is executed and the result is returned.
## Example:
Add 10 to argument a, and return the result:
x = lambda a : a + 10
print(x(5))
The result would be 15. (You could try this in a python IDE such as vs code)
=========================================================================
Lambda functions can take any number of arguments:
## Example:
Multiply argument a with argument b and return the result:
x = lambda a, b : a * b
print(x(5, 6))
The result would be 30.
=========================================================================
**Why Use Lambda Functions?**
The power of lambda is better shown when you use them as an anonymous function inside another function. Say you have a function definition that takes one argument, and that argument will be multiplied by an unknown number:
def myfunc(n):
return lambda a : a * n
Use that function definition to make a function that always doubles the number you send in:
## Example:
def myfunc(n):
return lambda a : a * n
mydoubler = myfunc(2)
print(mydoubler(11))
The result would be 22.
=========================================================================
Use lambda functions when an anonymous function is required for a short period of time.
If you would like to watch the video version of this tutorial, you could click on the following link:
[https://www.youtube.com/watch?v=DGUl5Uwz3g8](https://www.youtube.com/watch?v=DGUl5Uwz3g8)
**#python** **#pythonlambda** **#lambdafunction** | 0.44 | t3_tqyil5 | 1,648,556,436 |
Python | My first coding project: Twitter Plays Wordle | After starting my coding journey 3 months ago, I've finally made something that isn't a terminal calculator app :0
So I made [Twitter Plays Wordle](https://twitter.com/WordleGame_Bot) ([github](https://github.com/afnzmn/twitter-plays-wordle)), a twitter bot that uses replies to its tweet as guesses for a Wordle game.
The bot first checks if it's a fresh game. If yes, it tweets a blank Wordle grid. If it isn't, then it searches for the replies to its newest tweet, and checks to see if it has a guess in it. This can either be a reply with just a five letter word, or a five letter \[guess\] contained in square brackets. It adds this to a replies.csv. Then, it sorts the guesses by the likes, and uses the most liked valid reply as the guess. It then plugs the guess into a Wordle function, which just runs an algorithm for detecting what coloured square goes where, and adding it to a list. The list then gets joined and pushed out with other Wordle things for the Twitter bot to tweet. Finally, it adds the Wordle grid into a text file, and updates a csv on the current row position, the word number, and the win state to be used for the next tweet.
If you want to play it, here's the most [recent tweet](https://twitter.com/WordleGame_Bot/status/1508769809550434309)
Currently, I'm just running this on my old laptop since I can't really buy a hosting service, and iirc Heroku wouldn't run for the entire month with its free plan. If someone has an alternative, please let me know! (also if you wanna roast my code, you're welcome to do so) | 0.6 | t3_tqxx94 | 1,648,554,369 |
Python | The history of performing functions in Django | A question from a beginner.
The [article](https://russianblogs.com/article/45611627794/) discusses what happens after the command is called *manage.p**y runserver*
Is there any way to see this in the form of a "log" or similar functionality, not only after calling this particular command, but also after any actions, for example, in the admin panel, etc.? | 1 | t3_tqxkg9 | 1,648,553,092 |
Python | Sourcepy: source python files straight from the shell | Hey folks, sharing a project I built just for fun, Sourcepy: [https://github.com/dchevell/sourcepy](https://github.com/dchevell/sourcepy)
I was writing some increasingly messy shell functions and thought it would be nice if I could just write Python functions/variables/etc. instead and source them from the shell. So … that's what this is. It uses a mix of importlib and inspect machinery to "source" files (in reality, generating shell stubs that hook back into a bridging interface, and aliasing \`source\` so it works just like you’d expect).
Along the way I ended up deep diving into type annotations and turning plain python functions into dynamic command line apps that can coerce to native values, handle stdin, work with a large variety of types & objects and do a number of other interesting things - all without your code having to know a thing about Sourcepy. You write plain old python functions, add typehints to the parameters for the best results, and in most cases it should "just work".\*
This is still a work in progress - its use case is largely for folks like me who like excuses to mess around in Python and customise their environment and toolset to an unnecessary degree.
Try it out, share any suggestions (or bugs, or criticism). I've poked around looking for similar projects and the only similar thing I could find required running a daemon which wasn't an approach I liked, so hopefully you'll find some novelty here.
^(\*not a guarantee) | 0.95 | t3_tqwyrh | 1,648,550,680 |
Python | Actual unique fun project ideas: Beginner | Intermediate | Advanced | Beginner:
- Write a python function that creates 10 folders numbered 1-10 (hint: use context managers)
- Using PILLOW, generate simple white noise images by randomly toggling individual pixel Colours between black and white in an MxN image (hint: use nested for loops)
- Write a script that prints “Hello World” in red coloured text in the terminal. (hint: look up ANSI escape codes and run this script in the terminal)
- Create a virtual environment with the built in venv library. Activate this environment. pip install pandas. Confirm the install with pip ls. pip uninstall pandas. (hint: you’ll learn about environments)
Intermediate:
- Using PILLOW, again generate simple white noise images, but this time by randomly toggling individual pixel Colours between any possible RGB value in an MxN image (hint: use nested for loops)
- Create a python decorator to run any function you define in an infinite loop (hint: @)
- Write a script that can simply parse large json files (1GB+) (hint: you’ll learn about memory management and memory allocation errors)
- Create a bare minimum Flask app to convert temperatures (F to C) - no CSS. (You’ll learn a bit about packages and HTML)
- Create a Bash Makefile.sh that automates the creation and activation of a virtual environment, and also pip installs pandas. Run this bash file. (hint: assumes Linux)
Advanced:
- Using PILLOW and any coloured image as INPUT, write an algorithm that gradually decreases the brightness of an image radially towards the centre pixel
- Create a bare minimum python based inverted index (like Elasticsearch) (hint: you’ll learn about Classes, NLP, and basic algorithms)
- Create a Selenium bot to enter random characters into any <input> HTML element on any website (hint: learn about “inspect element” in the browser) | 0.9 | t3_tqvytp | 1,648,546,376 |
Python | EXPENSE-TRACKER -> An application to keep your expenses organized | Hey all, few days ago, I have made a post of making an expense tracker - [here](https://www.reddit.com/r/Python/comments/slbhbi/expensetracker_an_application_to_keep_your/).
And you all have helped me improving it. Thanks to all.
# MODIFICATION
SO, I thought to change the entire project into a package which can be used by installing it through pip.
First of all, I change the code structure to classes and objects.
then add one decent functionality -
Currency converter
Previously, to show the expenses more clearly I use graphs.
Now, I made another option of changing the currency of your expenses and compare it from the previous. Here, I have used tan API.
# INSTALLATION AND CODE
You can see the code as usual on github - [here](https://github.com/Shreejan-35/EXPENSE-TRACKER). Here you can get all information.
You can install it using pip by the following ways -
```
pip install expense-tracker
```
OR
```
pip3 install exprense-tracker
```
Then run,
```
expense-tracker
```
I was lucky that no one has till now taken **expense-tracker** as a name.
That's all to say.
You can follow me on instagram - [@star_cyber_warrior](https://www.instagram.com/star_cyber_warrior/) | 0.57 | t3_tqvrl9 | 1,648,545,457 |
Python | How To Hire a Python Web Development Company for Your Project? | 0.25 | t3_tqv3v9 | 1,648,542,428 |
|
Python | Top 10 Python Data Science Projects with Source Code | 0.71 | t3_tqu35m | 1,648,537,849 |
|
Python | I'm presenting live in 9 hours at Microsoft Reactor online about Python and Kubernetes. Let me know your questions in advance | 0.85 | t3_tqta40 | 1,648,534,367 |
|
Python | My python git binding | hi, i know there are already great python library for git. but i need simple library and working with all git & python 3 version, so i made this binding [https://github.com/guangrei/Gitpybinding](https://github.com/guangrei/Gitpybinding)
glad to hear your thoughts 🙏 | 0.88 | t3_tqolbm | 1,648,517,515 |
Python | First Full Stack, Mobile Friendly App (Flask) | Yet To Be Named Poll Based Matching App: [http://54.198.186.121:8080/](http://54.198.186.121:8080/)
I was listening to a podcast at a company I want to work for and the host was talking about this idea for an app. I ended up building it to get my foot in the door and build out my project portfolio.
This is my first production deployment ever. I'd like to get a little foot-traffic and feedback which is what brings me here.
Currently, signup is required to view anything, however, user authentication is by the book using various flask based modules so all sensitive user data is encrypted.
I think it's a tremendous example of what python is capable of. The whole app is 500ish python lines coupled with a few HTML pages, SQL queries, and a CSS stylesheet.
With that said, I encourage you to sign up, and either make or take a poll.
All feedback is welcome in the comments! | 1 | t3_tqn48r | 1,648,512,727 |
Python | Tuesday Daily Thread: Advanced questions | Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.
**If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.**
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at [https://discord.gg/python](https://discord.gg/python) where you stand a better chance of receiving a response. | 0.85 | t3_tqmvv4 | 1,648,512,009 |
Python | Question: best ways to build Python command line utilities | I have two medium size (less than 1000 lines each) code bases that I would like to make into two command line utilities. Two obvious approaches are:
1. Add a \_\_main\_\_.py file and a [setup.py](https://setup.py) to a module, and do a python [setup.ps](https://setup.ps) install
2. Copy all source files into a single Python source file that starts with *#!/usr/bin/env python, and put script in PATH.*
To complicate matters, I use several different condo environments that I switch between. Is there an accepted best practice for this? | 0.85 | t3_tqgwm3 | 1,648,494,868 |
Python | ONNX to PyTorch | We have released our Python Open Source tool for conversion ONNX models to PyTorch. Almost all Computer Vision neural networks architectures are supported. Please try it.
[https://github.com/ENOT-AutoDL/onnx2torch](https://github.com/ENOT-AutoDL/onnx2torch?fbclid=IwAR1HpWxialVy-ILdHUYR8CJ_EsUyxbjhrMkZbWPWkQ0DuNuwvYDEpNVuhqc)
I ask the Data Science community to support the project with a star on GitHub. | 0.88 | t3_tqgjsk | 1,648,493,932 |
Python | Software Engineering Tools and Best Practices for Data Science | 0.5 | t3_tqfr47 | 1,648,491,771 |
|
Python | A zoo for decorators | Hello there! First time posting here :)
Last week I worked on a small python library and wanted to share it!
Reason for the library is that I found myself copy-pasting some python decorators over and over across multiple projects.
Library is called deczoo (a zoo for decorators) and it's pip-installable.
docs: [https://fbruzzesi.github.io/deczoo/](https://fbruzzesi.github.io/deczoo/)
repo: [https://github.com/FBruzzesi/deczoo](https://github.com/FBruzzesi/deczoo) | 0.5 | t3_tqefp4 | 1,648,488,239 |
Python | I made my own Task Deadline Tracker using Python! | Hi all, I'm really excited to share this little project I've finally finished! Meet Tasky, a program made using tkinter that will track the deadlines for the task you feed in and show you the time remaining for your tasks (for example 3d 2h 57m left for some task). I use it regularly to track my own tasks and thus plan accordingly. It's been really helpful to me. You can add, delete and edit tasks in it too.
Hope you all like it :)
[Image showing Labelled Parts of Tasky](https://user-images.githubusercontent.com/68178267/160485795-411c9ccb-a133-4eea-a3ac-213c91ae2669.png)
More info and features: [Github Repo](https://github.com/AbhiK002/Tasky/)
&#x200B;
[It comes in 2 themes as well!](https://preview.redd.it/3dcztj22p5q81.png?width=965&format=png&auto=webp&s=618c3f6e291f9e84a3816a675f6d3bb9dd416379) | 0.94 | t3_tqe3tx | 1,648,487,360 |
Python | Python project that swipes for me on Tinder | demo link: [https://youtu.be/mRbEcqf1xLw](https://youtu.be/mRbEcqf1xLw)
(the code breakdown link is in the description of the demo) | 0.6 | t3_tqdf63 | 1,648,485,556 |
Python | In 2 days, running a live 45-minutes session on the fundamentals of observability, OpenTelemetry, and distributed tracing in Python | Hi everyone, there's a live OpenTelemetry and observability fundamentals session - in 2 days, Wednesday, March 30 at 11 AM PST.
**You will learn how to instrument your apps to capture traces with OpenTelemetry in Python.**
This session is at no cost and vendor-neutral.
You can expect in this session: 45 minutes of core concepts, how to deploy it yourself hands-on + Q&A.
If you are interested in observability, OpenTelemetry, and tracing - this is the place to be!
Register here [https://www.aspecto.io/get-started-with-opentelemetry/](https://www.aspecto.io/get-started-with-opentelemetry/?utm_source=post&utm_medium=reddit&utm_campaign=r-python-opentelemetry-workshop-pyhon-march-30-2022) | 0.66 | t3_tqd44k | 1,648,484,744 |
Python | Solverecaptchas - An async Python library to automate solving ReCAPTCHA v2 using Playwright. | [https://github.com/embium/solverecaptchas](https://github.com/embium/solverecaptchas)
Solves audio and image types!
## Compatibility
Linux, macOS, and Windows!
## Installation
$ pip install solverecaptchas
## Usage
import asyncio
import sys
from solverecaptchas.solver import Solver
if len(sys.argv) == 4:
pageurl, sitekey, proxy = sys.argv[1:]
else:
print('Invalid number of arguments (pageurl, sitekey, proxy)')
sys.exit(0)
if proxy.lower() == "none":
proxy = None
client = Solver(pageurl, sitekey, proxy=proxy)
result = asyncio.run(client.start())
if result:
print(result) | 1 | t3_tqcsdg | 1,648,483,853 |
Python | I made a Twitter bot that hates you! | I've messed around in Python on and off for a couple of years now. Most of what I've made has been exceptionally dumb (poorly written text adventures, a thing that used turtle to draw different colored spirals, a Garfield comic generator) and left unfinished. Until now!
[Insult Ivan](https://twitter.com/InsultIvan) is a twitter bot I've created using Tweepy, and marks the first one of my exceptionally dumb projects to actually be done enough to function. All it does is pull words from four large lists (one with phrases to start the insult, and then three words to make up the insult itself), and then tweets this out once a day. It saves insults to a text file, so it won't repeat itself. It also responds to mentions with an insult that it will then only ever use for that user, reusing it in response to subsequent mentions from the same user.
Anyway, the code is an absolute mess (I'm kind of assuming? I don't really know.), and I'm sure there is so much that I could have done better. But it functions and I love it and I wanted to share this beautifully idiotic thing I made.
Code isn't available anywhere if that's okay (I can maybe mess around and see if I can make that happen if anyone really wants it). I'm happy to answer any questions though! | 0.67 | t3_tqc8pe | 1,648,482,379 |
Python | PYTHON CERTIFICATIONS LIST - BEST OF 2022 | [Python Certification](https://www.sprintzeal.com/blog/python-certifications) is an established general-purpose high-level programming language. It was established by Guido van Rossum in 1991, further developments were done by Python Software Foundation. The primary position in python is given to code readability. Because by using its syntax programmers will be able to create concepts with fewer lines of code. | 0.17 | t3_tqbfx0 | 1,648,480,156 |
Python | A roadmap of the free CS curriculum on Qvault (JS, Python, Go) | 0.82 | t3_tqaff4 | 1,648,477,395 |
|
Python | Feedback Requested - First Script that Calls API and Posts to MS Teams | Looking for feedback regarding my first script. Overall it calls a API, cleans the data a bit and then makes a post to MS Teams.
https://imgur.com/a/5MkAsGu
Anything I'm doing terrible? Something I could do better? More efficient? | 0.5 | t3_tq9d4k | 1,648,474,241 |
Python | The counter-intuitive rise of Python in scientific computing | 0.93 | t3_tq8jzp | 1,648,471,730 |
|
Python | X-Cash crypto now has a Python wrapper Library | 0.23 | t3_tq8csg | 1,648,471,059 |
|
Python | PYTHON CERTIFICATIONS LIST - BEST OF 2022 | Benefits of Python Certification
Following are the benefits one would get through python certification,
**Easy to learn**
The key benefit of python certification is the programming language of python is easy to learn. **Python certification** can be used as a channel to a career, where learning other programming languages and frameworks will start to seem interesting.
If one is a complete beginner and wants to learn about programming, python will help to start better. Python is a simple and easy-to-understand programming language. And once the course is completed and you get the python certification, you will be confident enough to explore more about the programming world.
**Expertise in Python**
When it comes to recruiting python programmers, recruiters always expect good skills and what is the unique skill that makes the candidate stand out from the rest of the crowd. **Python certification** will help in such situations, if you are one of the candidates applying for a position and you have a certificate you will have better chances to get selected.
Hence, having [python certification](https://www.sprintzeal.com/blog/python-certifications) will prove that you know better and will help you gain the recruiter's interest. | 1 | t3_tq7crh | 1,648,467,751 |
Python | py.quit it | 0.35 | t3_tq6wo3 | 1,648,465,973 |
|
Python | Scrape all Naver Video Results using pagination in Python | Using [`parsel`](https://parsel.readthedocs.io/):
```python
import requests, json
from parsel import Selector
params = {
"start": 0, # page number
"display": "48", # videos to display. Hard limit.
"query": "minecraft", # search query
"where": "video", # Naver videos search engine
"sort": "rel", # sorted as you would see in the browser
"video_more": "1" # required to receive a JSON data
}
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
}
video_results = []
html = requests.get("https://s.search.naver.com/p/video/search.naver", params=params, headers=headers, timeout=30)
json_data = json.loads(html.text.replace("( {", "{").replace("]})", "]}"))
html_data = json_data["aData"]
while params["start"] <= int(json_data["maxCount"]):
for result in html_data:
selector = Selector(result)
for video in selector.css(".video_bx"):
title = video.css(".text").xpath("normalize-space()").get().strip()
link = video.css(".info_title::attr(href)").get()
thumbnail = video.css(".thumb_area img::attr(src)").get()
channel = video.css(".channel::text").get()
origin = video.css(".origin::text").get()
video_duration = video.css(".time::text").get()
views = video.css(".desc_group .desc:nth-child(1)::text").get()
date_published = video.css(".desc_group .desc:nth-child(2)::text").get()
video_results.append({
"title": title,
"link": link,
"thumbnail": thumbnail,
"channel": channel,
"origin": origin,
"video_duration": video_duration,
"views": views,
"date_published": date_published
})
params["start"] += 48
html = requests.get("https://s.search.naver.com/p/video/search.naver", params=params, headers=headers, timeout=30)
html_data = json.loads(html.text.replace("( {", "{").replace("]})", "]}"))["aData"]
print(json.dumps(video_results, indent=2, ensure_ascii=False))
Output:
[
{
"title": "Minecraft : 🏰 How to build a Survival Castle Tower house",
"link": "https://www.youtube.com/watch?v=iU-xjhgU2vQ",
"thumbnail": "https://search.pstatic.net/common/?src=https%3A%2F%2Fi.ytimg.com%2Fvi%2FiU-xjhgU2vQ%2Fmqdefault.jpg&type=ac612_350",
"channel": "소피 Sopypie",
"origin": "Youtube",
"video_duration": "25:27",
"views": "126",
"date_published": "1일 전"
},
{
"title": "조금 혼란스러울 수 있는 마인크래프트 [ Minecraft ASMR Tower ]",
"link": "https://www.youtube.com/watch?v=y8x8oDAek_w",
"thumbnail": "https://search.pstatic.net/common/?src=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fy8x8oDAek_w%2Fmqdefault.jpg&type=ac612_350",
"channel": "세빈 XEBIN",
"origin": "Youtube",
"video_duration": "00:58",
"views": "1,262",
"date_published": "2021.11.13."
}
]
```
Using [`playwright`](https://playwright.dev/python/) browser automation:
```python
from playwright.sync_api import sync_playwright
import json
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
page.goto("https://search.naver.com/search.naver?where=video&query=minecraft")
video_results = []
not_reached_end = True
while not_reached_end:
page.evaluate("""let scrollingElement = (document.scrollingElement || document.body);
scrollingElement.scrollTop = scrollingElement scrollHeight;""")
if page.locator("#video_max_display").is_visible():
not_reached_end = False
for index, video in enumerate(page.query_selector_all(".video_bx"), start=1):
title = video.query_selector(".text").inner_text()
link = video.query_selector(".info_title").get_attribute("href")
thumbnail = video.query_selector(".thumb_area img").get_attribute("src")
channel = None if video.query_selector(".channel") is None else video.query_selector(".channel").inner_text()
origin = video.query_selector(".origin").inner_text()
video_duration = video.query_selector(".time").inner_text()
views = video.query_selector(".desc_group .desc:nth-child(1)").inner_text()
date_published = None if video.query_selector(".desc_group .desc:nth-child(2)") is None else \
video.query_selector(".desc_group .desc:nth-child(2)").inner_text()
video_results.append({
"position": index,
"title": title,
"link": link,
"thumbnail": thumbnail,
"channel": channel,
"origin": origin,
"video_duration": video_duration,
"views": views,
"date_published": date_published
})
print(json.dumps(video_results, indent=2, ensure_ascii=False))
browser.close()
```
Output:
```json
[
{
"position": 1,
"title": "Minecraft : 🏰 How to build a Survival Castle Tower house",
"link": "https://www.youtube.com/watch?v=iU-xjhgU2vQ",
"thumbnail": "https://search.pstatic.net/common/?src=https%3A%2F%2Fi.ytimg.com%2Fvi%2FiU-xjhgU2vQ%2Fmqdefault.jpg&type=ac612_350",
"channel": "소피 Sopypie",
"origin": "Youtube",
"video_duration": "25:27",
"views": "재생수126",
"date_published": "20시간 전"
},
{
"position": 1008,
"title": "Titanic [Minecraft] V3 | 타이타닉 [마인크래프트] V3",
"link": "https://www.youtube.com/watch?v=K39joThAoC0",
"thumbnail": "https://search.pstatic.net/common/?src=https%3A%2F%2Fi.ytimg.com%2Fvi%2FK39joThAoC0%2Fmqdefault.jpg&type=ac612_350",
"channel": "나이아Naia",
"origin": "Youtube",
"video_duration": "02:40",
"views": "재생수22",
"date_published": "2021.11.11."
}
]
```
If you need a more in-depth explanation, you can visit the blog post at SerpApi: https://serpapi.com/blog/scrape-all-naver-video-results-using-pagination-in-python/#full_code | 0.4 | t3_tq6vg2 | 1,648,465,829 |
Python | Open-source tool to make awesome-looking docs | [https://mkdocs-magicspace.alnoda.org/](https://mkdocs-magicspace.alnoda.org/)
This is a free tool I made. It will help to make beautiful docs for any Python project, and host them on GitHub pages.
Based on MkDocs, I extended it with lots of plugins and extensions. And created tutorials.
I hope you find it useful. | 0.82 | t3_tq6sgn | 1,648,465,502 |
Python | GitHub - enthought/traits: Observable typed attributes for Python classes | 0.78 | t3_tq4p5h | 1,648,456,356 |
|
Python | Top python libraries/ frameworks that you suggest every one | Hit your answer I wonder is there any hidden treasure. | 0.81 | t3_tq483b | 1,648,454,163 |
Python | Top 5 Python Time Series Libraries | 0.75 | t3_tq3cjf | 1,648,450,342 |
|
Python | Master Python Comprehensions | Hi folks,
Wrote something down about Python Comprehensions, focusing on simplicity and readability.
You can have a look here [https://towardsdatascience.com/master-python-comprehensions-4ef1c66b452d](https://towardsdatascience.com/master-python-comprehensions-4ef1c66b452d)
Happy to discuss :)
Thanks! | 0.75 | t3_tq2ain | 1,648,445,882 |
Python | a lightweight DNS traffic flow monitor | Hi, I wrote a lightweight DNS traffic query / response monitor by using Scapy. It will print each transaction per line. Here's the source code link: [https://github.com/meow-watermelon/dns-flow](https://github.com/meow-watermelon/dns-flow) I attached a screenshot to show the output example. Any suggestions are welcome. Thanks!
https://preview.redd.it/8ky0mi6z02q81.png?width=2560&format=png&auto=webp&s=051e9591b484ff58d26eafd43b4ed3188faa7ba1 | 0.67 | t3_tq1g8u | 1,648,442,658 |
Python | What type of language is Python? | I use python in all my classes and got into a discussion with my students about what type of language python is.
Initially, I thought python is a completely "non-typed" language because we are able to suppress types while declaring variables and parameters:
*def func(a, b): ...*
But then I found out that it's possible to type things up explicitly:
*def func(a: int, b: int) -> int: ...*
I ended up categorizing python as an "implicitly typed" language, and the interpreter must fill the types I don't explicitly add to the code. However, one of my students pointed out that, as python admits dynamic typing, it is a "dynamically typed language", which is the official classification (?).
However, I have failed to wrap my mind around the fact that I can explicitly set the types, but the interpreter won't bat an eye in case I recast my variables:
*def func(a: int, b: int) -> int:*
*...c: int = a + b*
*...return c*
*d: int = func(1, 2)*
*print(d)*
*d = "dynamically typed?"*
*print(d)*
Is "weakly-typed dynamic language" a possible way to classify python? | 0.63 | t3_tpzl61 | 1,648,435,995 |
Python | List comprehension vs multiplying a list differences? | Is there any difference between the following code?:
arr = [[]] * 10
arr = [[] for x in range(10)]
I used the first method to initiate a list on a hackerank problem and I kept getting wrong answer. When I googled the answer and saw the person use the second method, so I tried it and got the right answer?? `[[]] * 10 == [[] for x in range(10)]` returns True. Why would the way I initiate this list cause a different result?
If anyone wants to try it themselves.. it's a real head scratcher for me.
[https://programs.programmingoneonone.com/2021/05/hackerrank-dynamic-array-solution.html](https://programs.programmingoneonone.com/2021/05/hackerrank-dynamic-array-solution.html)
def dynamicArray(n, queries):
# Write your code here
arr = [[] for x in range(n)]
#Now try using the code below to initiate arr. This fails it for me.
#arr = [[]] * n
lastAnswer = 0
answers = []
for x in queries:
idx = (x[1]^lastAnswer) % n
if x[0] == 1:
arr[idx].append(x[2])
else:
lastAnswer = arr[idx][x[2] % len(arr[idx])]
answers.append(lastAnswer)
return answers | 0.59 | t3_tpz8kn | 1,648,434,777 |
Python | Monday Daily Thread: Project ideas! | Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, ["The Big Book of Small Python Projects"](https://inventwithpython.com/bigbookpython/) which provides a list of projects and the code to make them work. | 1 | t3_tpwknx | 1,648,425,608 |
Python | 3D Render engine, written in 100% Python, No external libraries. *EPILEPSY WARNING* | EDIT: I have fixed the flickering issue! As long as you use the latest version there should be no flickering at all!
Video of it running: [https://youtu.be/7J2Pn8me7m8](https://youtu.be/7J2Pn8me7m8)
Github link: [https://github.com/E-Parker/Terminal-3D-Render/releases](https://github.com/E-Parker/Terminal-3D-Render/releases)
I've been working on this for a little while, it's a simple 3D render engine that uses only the built-in python libraries.
NOTE: If you suffer from any conditions that cause sensitivity to flashing lights do not use PREVIOUS versions of this program. The latest version is safe and free of flickering.Because the print command is very slow sometimes the screen will refresh before python is done drawing the frame, this causes the image to flicker occasionally. The effect worsens the faster your monitor's refresh rate is.
The features of this version are:- BMP decoding
\- OBJ decoding
\- Perspective Texture mapping
\- Depth buffer
\- Simple directional lighting
\- 231 colours!
I don't think there is much to be learned from this other than how not to write a render engine, I spent a lot of time working out how to do things like decoding .bmp files when there are already solutions that are way faster and much less of a pain to work with. This was mostly an exercise to see how far I could go without any tools.
Also, do keep in mind this is the 4th project I've made with python, I'm not super experienced so don't expect the code to be very good-looking. | 0.93 | t3_tpv7hs | 1,648,421,114 |
Python | How did your coding style in python change after you learned another language? | Different languages make you write different code, but im curious if the way you wrote python changed due to coding in another language! | 0.96 | t3_tpu9p2 | 1,648,418,231 |
Python | Build signed .aab with Kivy, Buildozer for Google Play Store (Windows & ... | 0.67 | t3_tppdqx | 1,648,404,134 |
|
Python | Made a Flask boilerplate using a services oriented structure | 0.88 | t3_tpp9y4 | 1,648,403,841 |
|
Python | Apilytics open-source middleware available for Flask! Install in 5 minutes and visualize all important metrics from your Flask backend | 0.72 | t3_tpntm0 | 1,648,399,539 |
|
Python | Actionable Notification with Callback in Python | 0.81 | t3_tpmfni | 1,648,395,499 |
|
Python | Django 4 0 with Amazon RDS & Elastic Beanstalk Full Course | 0.79 | t3_tpky84 | 1,648,390,913 |
|
Python | Improved version of Al Sweigart's swordfish program | Yesterday, I worked on improving Al Sweigart's *swordfish* program to limit to three the attempts a user can input their name and password. I'm proud of my work, although I ran into several bugs which left me scratching my head for a while. A big Thank You to Al for writing such a good introduction to Python!
https://preview.redd.it/lldmgux5nxp81.png?width=1494&format=png&auto=webp&s=1a881647b5ffd69fc9b2c921db059c636ca15d2b | 0.64 | t3_tpkr49 | 1,648,390,282 |
Python | Learn Blockchain Concepts Practically With Python | 0.41 | t3_tpjodl | 1,648,386,792 |
|
Python | PYVAULT - PYVAULT is a python program with which you can secure your precious passwords very easily. | Hi guys. So, I have made a python script which can store your passwords in a database and you can encrypt it with a secret key which is generated by the script only. Actually, with this , we can store our passwords pretty securely until our key is exposed.
So, I have used -
i. sqlite3 (Used for database)
ii. cryptograhy (To work with encryption and decryption using the key)
These are the libraries.
I used fernet to generate the key and to encrypt and decrypt the passwords and storing it in the database.
The script provides a list of options -
i. Create a database
ii. Work with previous database
iii. Generate key
iv. Load key
v. Retrive passwords
You can see the code here - [https://github.com/Shreejan-35/PYVAULT/](https://github.com/Shreejan-35/PYVAULT/)
All the contribution are welcome.
I have done the project by learning from a video about password manager from a youtube channel - neuralnine. But, I worked with database and tried to take it to some advance steps.
&#x200B;
Edit 1:
Guys I have uploaded this as a package on [pypi.org](https://pypi.org) as vaulter-py.
You can install it by typing -
**pip install vaulter-py**
&#x200B;
Thanks | 0.4 | t3_tpic7y | 1,648,381,816 |
Subsets and Splits