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 | I fixed python traceback real quick | ​
https://preview.redd.it/yqvg54ml9sn81.png?width=2000&format=png&auto=webp&s=575484421b18464c240d3f384d3a1c7e3f4e3a34
yourprog = "whatever.py"
from subprocess import check_output, STDOUT
def abrT(r):
return r
o = ""
# I don't care about unreadable code I am writing this during lunch break
for line in r.split("\n"):
if "Traceback" in line:
o += "Traceback:\n\n"
elif "File" in line:
a = line[line.find(", ")+2:] + "\n"
a = a.replace(", in <module>", "")
o += " " + a
elif ":" in line:
o += "\n " + line.split(": ")[0] + ":\n " + line.split(": ")[1] + "\n"
else:
o += line + "\n"
return o[:-1]
result = str(check_output(f"python3 {yourprog}; echo -n", shell=1, stderr=STDOUT), 'utf-8')
print(abrT(result)) | 0.69 | t3_tfnswk | 1,647,452,918 |
Python | Scrape Google Books in Python | This blog post uses [`parsel`](https://parsel.readthedocs.io/) as an HTML/XML parser that supports full XPath, instead of [`bs4`](https://www.crummy.com/software/BeautifulSoup/bs4/doc/).
Shows how to scrape:
- title
- link
- displayed link
- snippet
- author
- publication date
- thumbnail
- preview, and more editions.
If you need a step-by-step explanation, you can visit [Scrape Google Books in Python](https://serpapi.com/blog/scrape-google-books-in-python/) blog post at SerpApi, otherwise:
```python
from parsel import Selector
import requests, json, re
params = {
"q": "richard branson",
"tbm": "bks",
"gl": "us",
"hl": "en"
}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.87 Safari/537.36",
}
html = requests.get("https://www.google.com/search", params=params, headers=headers, timeout=30)
selector = Selector(text=html.text)
books_results = []
# https://regex101.com/r/mapBs4/1
book_thumbnails = re.findall(r"s=\\'data:image/jpg;base64,(.*?)\\'", str(selector.css("script").getall()), re.DOTALL)
for book_thumbnail, book_result in zip(book_thumbnails, selector.css(".Yr5TG")):
title = book_result.css(".DKV0Md::text").get()
link = book_result.css(".bHexk a::attr(href)").get()
displayed_link = book_result.css(".tjvcx::text").get()
snippet = book_result.css(".cmlJmd span::text").get()
author = book_result.css(".fl span::text").get()
author_link = f'https://www.google.com/search{book_result.css(".N96wpd .fl::attr(href)").get()}'
date_published = book_result.css(".fl+ span::text").get()
preview_link = book_result.css(".R1n8Q a.yKioRe:nth-child(1)::attr(href)").get()
more_editions_link = book_result.css(".R1n8Q a.yKioRe:nth-child(2)::attr(href)").get()
books_results.append({
"title": title,
"link": link,
"displayed_link": displayed_link,
"snippet": snippet,
"author": author,
"author_link": author_link,
"date_published": date_published,
"preview_link": preview_link,
"more_editions_link": f"https://www.google.com{more_editions_link}" if more_editions_link is not None else None,
"thumbnail": bytes(bytes(book_thumbnail, "ascii").decode("unicode-escape"), "ascii").decode("unicode-escape")
})
``` | 0.5 | t3_tfm16q | 1,647,448,203 |
Python | OpenTelemetry and Distributed Tracing in Python - Introduction | 0.33 | t3_tflm99 | 1,647,447,107 |
|
Python | Add jemalloc to your Python Docker images | 1 | t3_tflf1p | 1,647,446,556 |
|
Python | What's your favorite module/library/package? | Just wondering what's your favorite module and package which you like to use them? Mine is re.
You can tell multiple, by the way. | 0.5 | t3_tfkh8z | 1,647,445,189 |
Python | Writing production grade pandas with hamilton! | While Pandas is incredibly flexible and easy to get started with, it doesn't lend itself to writing good quality, extensible code. This is usually fine. Lots of it is thrown away -- written in notebooks and never seen again. However, a lot amount of it ends up making it into production ETLs, services, etc..
At Stitch Fix, we had a *lot* of monolithic, messy pandas scripts. We built [hamilton](https://github.com/stitchfix/hamilton/) to solve this problem. A programmer represents transforms on dataframes as a series of python functions. The parameter names are used to specify upstream dependencies, and the whole thing gets wired into a dependency graph.
In short -- instead of writing:
df['a'] = df['b'] + df['c']
You'd write:
def a(b: pd.Series, c: pd.Series) -> pd.Series:
return b+c
Then you use a *driver* to customize execution, pass in paraemeters, etc... Note that its not at all limited to pandas -- while that was the initial use-case, it can handle any sort of python datatype!
We've opened up this internal tool we're excited about to the outside world -- we'd love feedback, contribution, and use-cases!
[https://github.com/stitchfix/hamilton/](https://github.com/stitchfix/hamilton/) | 0.8 | t3_tfkahz | 1,647,444,723 |
Python | First time I used python | I'm coding with python for half a month now, in the beginning I was a bit sceptical what I would use it for but today I used it for the first time.
To cure boredom, me and my friends are doing typeraces where we have to type as fast as possible. I'm pretty good at that but there is someone in my class that is just a little better. Its just because I type upper cases with shiftlock and she types with shift.
So I wanted to learn to type with shift so I could type faster. But because I never did it that way I had to practice it so I wrote a little python program that generates a letter and then you have to type that letter.
I was very happy how it turned out and I now I understand python can and will be very useful . | 0.84 | t3_tfiry5 | 1,647,440,485 |
Python | OPToggles - a feature flag Open Source project | Hey r/Python! Just wanted to share our open source project launching today. Thought some of you might find it useful, and we would love to hear your feedback.
As devs, we often want our frontend to reflect the permissions enforced by the backend - i.e. if a user is not allowed to run the action behind a button - don't show the button.
[OPToggles](https://github.com/permitio/OPToggles) uses[ Open Policy Agent](https://github.com/open-policy-agent/opa) to automatically enhance feature flag solutions by creating user-targeted feature flags. It already supports LaunchDarkly and a generic REST API. | 0.76 | t3_tfil3b | 1,647,439,946 |
Python | How do you really share constants across your project in a Pythonic way? | Assuming i have a package i created who get input text, and return a huge dictionary with 50+ keys.
Since *all other packages* in the program are using this dictionary and play with those keys, I don't want to hard code the keys, but keep them as global **constants**.
So here are my options and i feel uncomfortable with both of them:
1. Put all constants vars in a separate folder/package in root folder, and *import them to each package* that use them. To my eyes it makes the code **hairy and uncapsulated.** I love the SW engineering where you have a package that depend on nothing outside.
2. Pass all arguments in this config package to *each* package who need it - which also make things ugly hairy and confusing, and require putting all constants in a class(there are no structures.)
&#x200B;
I know that most people go with **1**, but my code has like 10+ packages i wrote, each package has multiple files, ***each*** depend on these constants(50+), and if i import the constants (even with **absolute import**) to each, it makes me feel uncomfortable.
What if i want to give my package to another developer ? i need to gather all these dependencies?
**How is this done in huge multi developers programs ?** | 0.57 | t3_tfhvue | 1,647,437,921 |
Python | Import of modules is slowing down executable. Can it be imported locally or what can be done differently ? | I am importing the following modules/libraries which is causing the exe to take a few minutes to start. How can I store them locally or what can I do differently so that the exe starts quickly? When I run this from the Notebook it the application runs without any delay. I wonder if there is a way to speed up the exe.
import time
import openpyxl
from os import path
from selenium import webdriver
from openpyxl.styles import Alignment
from webdriver\_manager.chrome import ChromeDriverManager
from openpyxl.styles.borders import Border, Side
from selenium.webdriver.support.ui import Select
import os
import math
import win32com.client as client
from PIL import ImageGrab
&#x200B;
Thank you in advance. | 1 | t3_tfh1l5 | 1,647,435,382 |
Python | Stylistic choice of validation functions | Hey all! Got a question. I’m working on a validation script for work verifying some supplied input against required values. I’m wondering, stylistically, if there’s a “preferred way” to write these functions.
An example function…
Def name_max_length(name):
if 1 < len(name) <= 128:
return None
else:
raise ValidationError(“Names length fell outside of max range.”)
Apologies if Reddit mobile mangled that code but it’s short enough that I think everyone can still grok it.
If you were working on a project would you want to see the above? Or would you rather read a single if statement, without an else, checking to see if it fell outside of the valid range and if so raise the exception.
I thought PEP-8 had a stylistic recommendation about positive vs negative checking for if statements but I gave it a quick scan and didn’t see anything. I’m going to be writing a lot of these, so I’d like to get a solid stylistic choice under me.
I’m also curious, would you rather see these ranges hard coded in the if statement, or see two local variables (min/max) and have “if”compare against those? | 1 | t3_tfgida | 1,647,433,601 |
Python | what to do after practice python. org? | Helo I'm a beginner and I've finished the exercises from practice python org and I m clueless as to what my next step should be. What do you recommend, I tried advent of code but a lot of the exercises are way too hard for me. thanks very much | 0.79 | t3_tfflsy | 1,647,430,590 |
Python | Create a hello world app using django | 0.75 | t3_tffh4r | 1,647,430,119 |
|
Python | My first ever Python Project!! I named it tagSearch | I saw a twitter post the other day "Is there a tool that I can get meta tags off of a web site? I couldn't find any".
I thought to myself, there probably is, but I should do one too for at least practice.
So I made this small script called tagsearch, basically it collects wanted tags off a site. It can also scrape certain tags that have a wanted attribute, like span tags but only if they have class attr.
I also added regex support meaning one can make regex search on the scraped tags. My GitHub repo:
[https://github.com/teooman/tagsearch](https://github.com/teooman/tagsearch)
Example image
https://preview.redd.it/5ic7krt7aqn81.png?width=1419&format=png&auto=webp&s=afabf3817e73dc2075bbf2be6017c2bc76d36298
Any feedback would be highly appreciated!! | 0.67 | t3_tff544 | 1,647,428,851 |
Python | created a small utility to automatically activate Poetry virtualenvs when changing directories | [https://github.com/tvaintrob/auto-poetry-env](https://github.com/tvaintrob/auto-poetry-env)
tested only on MacOS with zsh, heavily inspired by pyenv-venv's auto activation, please share any thoughts and suggestions! | 0.75 | t3_tfdemi | 1,647,421,875 |
Python | GitHub - jamalex/notion-py: Unofficial Python API client for Notion.so | 0.67 | t3_tfcksk | 1,647,418,317 |
|
Python | Which logic for if-else inside a function is better or more pythonic? | The logic between f1 and f2 is exactly the same, but the syntax is slightly different. This type of function shows up everywhere. Is one easier to read, or preferred in some way?
Side note: I thought it was interesting that f2 is slightly faster than f1.
import numpy as np
arr = np.random.choice(['a','b','c'],100)
def f1(cond):
if cond == 'a':
return 'a'
if cond == 'b':
return 'b'
return 'c'
def f2(cond):
if cond == 'a':
return 'a'
elif cond == 'b':
return 'b'
else:
return 'c'
f1 timeit:
In [1]: %%timeit
...: for i in arr:
...: f1(i)
...:
40.6 µs ± 804 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
f2 timeit:
In [2]: %%timeit
...: for i in arr:
...: f2(i)
...:
40.2 µs ± 729 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
edit: u/hai_wim pointed out that the speeds are fully equal (difference is within stdev tolerance), as the byte code is exactly the same. So the question really comes down to readability and standardization. | 0.53 | t3_tfbvh6 | 1,647,415,266 |
Python | Approach H2kinfosys to Learn Python Course Effectively | This [**python certification online**](https://www.h2kinfosys.com/courses/python-online-training) course is created for complete beginners, so you don't need any prior programming experience to complete it. The outline is designed to cover the basics of the programming language as well as some advanced topics. | 0.67 | t3_tfbsr5 | 1,647,414,945 |
Python | macOS 12.3 finally deletes its own Python 2, which even die-hard Python fans applaud | 0.96 | t3_tfbgoe | 1,647,413,504 |
|
Python | Tool to get path to JSON in python format | I found a tool that you can paste JSON into, provide the key to look for, and the value expected for the key (partial values works too). The result is the path to the value.
Wanted to share as I found this useful.
https://xenosoftwaresolutions.com/json
sample JSON:
{
"test": [
{
"item": true,
"checked": false,
"info": {
"hello": "world"
},
"products": []
}
]
}
result when looking for hello as key and world as value:
["test"][0]["info"]["hello"] | 0.78 | t3_tf6b85 | 1,647,395,272 |
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. | 0.67 | t3_tf45nb | 1,647,388,810 |
Python | Approximate Pi with 7 lines of code (arctangent series) | [https://www.youtube.com/watch?v=h63eSCNtJLg](https://www.youtube.com/watch?v=h63eSCNtJLg) | 0.58 | t3_tf2yrl | 1,647,385,408 |
Python | Article: Build a webhook in Python to interact with GitLab. | 0.79 | t3_tf1c39 | 1,647,380,997 |
|
Python | Which is more Pythonic? | if event_region in match regions:
return True
else:
return False`
Or...
`Return True if event_region in match_regions else False`
Or...
`return event_region in match_regions`
Where "event_region" is a string and "match_regions" is a list of strings | 0.87 | t3_tezqe5 | 1,647,376,725 |
Python | Django Email Signals - Django App that Actually Solves a Business Problem | In my workplace we make a lot of Django apps and for a number of these Django apps, we configure a lots of emails to be sent.
Whenever something changes in the database that meets some condition we send an email. The emails have their own context and each email can be a time consuming to setup.
There has to be a better way I thought. And so, I built [django-email-signals](https://github.com/Salaah01/django-email-signals).
I build this app to be as plug-and-play as possible with minimal configuration. This Django app allows you to setup email signals right from the admin page
Here is a breakdown of what the app currently lets you do:
* Configure emails to be sent when some data in some model is changed.
* Set some constraints to determine if indeed an email can be sent.
* Either write up your email content when setting up a new email signal, or provide a path to a template.
* Be able to reference objects and attributes such `instance.user.first_name` right from where you would set your constraints or the email HTML itself. | 1 | t3_teyws8 | 1,647,374,670 |
Python | Introducing Typesplainer: a python type-hint explainer | ## What
Typesplainer is a Python type hint explainer that explains python type hints in plain English. It is very fast, accurate, and easy to use and understand. Available as a CLI, on the web, and as a Visual Studio Code extension
## Where
Website: https://typesplainer.herokuapp.com/\
CLI: https://pypi.org/project/typesplainer/\
Visual Studio Code extension (Alpha): https://marketplace.visualstudio.com/items?itemName=WasiMaster.typesplainer
## Why
Wondering WTF is an `Callable[[List[int]], Dict[int, List[Union[str, None]]]]`? typesplainer has got you covered. It's a callable that accepts a list of integers and returns a dictionary that maps integers onto a list of optional strings. Understanding type hints can be hard and time-consuming, especially if they are very big like the example above. This tool helps you understand things like that more easily and faster.
## How
Just use the cli if you want to use it anytime and anywhere. Use the website to test the tool before installing or if you want a graphical interface. And since the vscode extension is still in development, I won't recommend that at the moment. | 0.84 | t3_tevyc4 | 1,647,368,487 |
Python | Demystifying Apache Arrow: what is it and when should you use it? | 0.91 | t3_tettmu | 1,647,363,875 |
|
Python | Python Web Frameworks | 0.67 | t3_tehw7k | 1,647,322,911 |
|
Python | The Boilerplate for Logging in Python | ## Use this logging template in your next big project
Finding bugs is a common problem in any programming project. To make it easier to find bugs, you probably want to write some print statements to help you debug.
Is it helpful? yes. Is it the right way to track events in your code, especially in a big project? no.
Python has a built-in logging module that you can use to log messages. Logging not only helps you debug the issues in your code. It also helps you understand the flow of your code especially when you ship to production.
It is a very useful tool to identify how your code is behaving whether it is working as expected or not. If not, it can show you different hierarchies of how severe the issue is whether it is an error, a warning, or a debug mode.
Without having logging, it's difficult to keep your code maintainable for a long time. Especially when this code is mature.
In this tutorial, I'll show you a boilerplate for logging that you can use in your next project. Instead of looking at the documentation every time.
## Division Example
Let's take this division example especially when we divide by zero:
```python
def divide(dividend, divisor):
try:
return dividend / divisor
except ZeroDivisionError:
return "Zero Division error."
print(divide(6, 0))
```
In this case, when we divided 6 by 0 we returned a message string. This message shows that a zero division error during the `ZeroDivisionError` exception occurred.
What's the problem with that? The issue here is that we don't know when that happened and how severe the issue is. Is it a warning? an error? or just a piece of information you're printing to the console?
The built-in Python's `logging` module helps you better log your code with its features. Let's see how we can use it in this context:
```python
import logging
# Define a logger instance
logger = logging.getLogger(__name__)
# Define a stream handler for the console output
handler = logging.StreamHandler()
# Customize the formatter on the console
formatter = logging.Formatter(
"%(asctime)s - %(name)s: %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S"
)
# Add the formatter to the handler
handler.setFormatter(formatter)
# Add the stream handler to the logger that we will use
logger.addHandler(handler)
# Set the level of logging to be INFO instead of the default WARNING
logger.setLevel(logging.INFO)
def divide(dividend, divisor):
try:
logger.info(f"Dividing {dividend} by {divisor}")
return dividend / divisor
except ZeroDivisionError:
logger.info("Zero Division error.")
print(divide(6, 0))
```
which would return helpful information like this:
```
2022-02-23 13:24:41 - __main__: INFO - Dividing 6 by 0
2022-02-23 13:24:41 - __main__: INFO - Zero Division error.
```
## Wrap Up
In this boilerplate, you've seen how to log messages to the console. You've formatted the logs to start with a date and time followed by the name of the module, level of logging, and the log message itself.
Check out the [logger module here](https://gist.github.com/EzzEddin/0e8c517a47e678da6a60cc21fdbc5788) and let me know if you have any feedback, thanks! | 1 | t3_terbh0 | 1,647,357,423 |
Python | Python vs SQL for Data Analysis: comparing performance, functionality and dev XP | The clean division of data analysis labor between Python and SQL seems to be fading with tools like dbt, Snowpark and dask-sql. The article shared below compares the two languages in terms of performance, functionality and developer XP.
Quick summary:
**Performance**
Running SQL code on data warehouses is generally faster than Python for querying data and doing basic aggregations. This is because SQL queries move code to data instead of data to code. That said, parallel computing solutions like Dask and others that scale Python code to larger-than-memory datasets can significantly lower processing times compared to traditional libraries like pandas.
**Functionality**
SQL’s greatest strength is also its weakness: simplicity. For example, writing SQL code to perform iterative exploratory data analysis, data science or machine learning tasks can quickly get lengthy and hard to read. Python lets you write free-form experimental data analysis code and complex mathematical and/or ML code. The absence of a vibrant and reliable third-party library community for SQL is also a problem compared to Python.
**Developer XP**
Python makes debugging and unit-testing a lot easier and more reliable. While dbt has added code versioning by forcing the use of Git, SQL diffs are still harder to read and manipulate than diffs in Python IMO.
**Conclusion**
While it's tempting to frame the debate between SQL and Python as a stand-off, the two languages in fact excel at different parts of the data-processing pipeline. One potential rule of thumb to take from this is to **use SQL for simple queries that need to run fast** on a data warehouse, **dbt for organizing more complex SQL models**, and **Python with distributed computing libraries like Dask for free-form exploratory analysis and machine learning code** and/or code that needs to be reliably unit tested.
Full article:
[https://airbyte.com/blog/sql-vs-python-data-analysis](https://airbyte.com/blog/sql-vs-python-data-analysis) | 0.69 | t3_tequ97 | 1,647,356,144 |
Python | Use Python to Transcribe an Audio File in an S3 Bucket in 3 Steps | Hey guys! I wrote a [mini-article](https://www.assemblyai.com/blog/transcribing-audio-files-in-an-s3-bucket-with-assemblyai/) on **how to transcribe an audio file in an S3 bucket in 3 simple steps**.
Figured it might be helpful for people learning to use Python, JSON, AWS, etc.! | 0.95 | t3_teqkc2 | 1,647,355,373 |
Python | Processing large JSON files in Python without running out memory | nan | 0.95 | t3_tepn58 | 1,647,352,799 |
Python | Python Class Constructors: Control Your Object Instantiation – Real Python | nan | 0.67 | t3_teozl2 | 1,647,350,835 |
Python | Flask -> FastAPI | I'm happy with Flask and do not see the need to switch to FastAPI. Change my mind & (ideally) point me to a nice tutorial that does just that in a demo project. | 0.25 | t3_ubiv0a | 1,650,885,862 |
Python | Ping Sweeper In Python | 0.84 | t3_ubhkg4 | 1,650,880,947 |
|
Python | Text Summarization with Huggingface Transformers and Python | 0.81 | t3_ubgv0x | 1,650,877,984 |
|
Python | GitHub - helblazer811/ManimML: ManimML is a project focused on providing animations and visualizations of common machine learning concepts with the Manim Community Library. | 1 | t3_ubfsl4 | 1,650,873,375 |
|
Python | How do you write iOS apps in Python? | ? | 0.44 | t3_ubehfi | 1,650,867,723 |
Python | Making a list of advanced topics in Python | I'm preparing for a technical interview. I failed the first one a week ago. I noticed the excercises were tagged as (advanced python). 2 coding questions, one from decorators and the other from SQL.
I'm taking a month to prepare for my second chance at it. And I'm making a list of advanced topics/concepts in python. I don't want to be taken by surprise again.
List comprehension
Anonymous function
Decorators
Generators
Exception handling
Inheritance
Encapsulation
Unit testing
Regex
I need suggestions just in case I'm missing anything. I do practice coding excercises on hackerank. | 0.6 | t3_ubd7xt | 1,650,862,809 |
Python | Port scanning with Python | Lately I've been learning a bit about communicating over a network with Python and thought it might be fun to create a simple TCP port scanner. Had a lot of fun playing around with this on my home network.
The full project write up and code can be found [here](https://sheldonbarry.com/2022/04/24/port-scanning-with-python/). | 0.63 | t3_ubakvn | 1,650,853,507 |
Python | Python 3.11 Preview: Task and Exception Groups – Real Python | 0.98 | t3_ub9elz | 1,650,849,707 |
|
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. | 0.73 | t3_ub7ugb | 1,650,844,811 |
Python | 2-Button UI engine in MicroPython with "Apps" on a TTGO T-Display | https://youtu.be/wR3AkhD0nEg
More of a demo than anything at this point, but I've got working text entry, menus, loadable apps(any file named app_AppName.py is detected as an app).
I also have sleep modes, and wakelock-like functionality(Including modem sleep), and the ability for one app to launch another, with arguments and return values.
In screen-off sleep mode, it uses 6mA without Wi-Fi(The USB chip and charge led takes some power, probably more like 0.5mA on battery). With Wi-Fi it's around 7mA with spikes every few seconds.
With the screen on, you get 45mA with spikes up to 65mA. Probably room to improve that. But I'm impressed by the low power capabilities of MP(Once you add some assorted pull requests from the internet).
The Calculator app actually just launches the text entry app, and evals the text you enter.
There's a stopwatch and a tally counter, and a settings menu where you can customize things like the colors, and set an app to auto-load as soon as it boots up.
In the future, I'll add password protection to prevent exiting the default app, and I'd like to eventually have some kind of mobile "App store" Android app for uploading new content, and maybe the ability to configure WiFi/MDNS/MQTT from the settings menu.
The original idea for this was to be a replacement for Logitech's Harmony remotes. I think it would be awesome to have an open source home automation remote, that used an app-capable OS, that could also be a replacement for smart wall switches.
Another fun thing I'd like to do is some kind of programming feature, so you could edit the logic for a little robot just with a 2 or 3 button menu.
If MicroPython ever gets BLE bonding, making a wireless keyboard emulator for media or presentations might be another fun app. | 0.76 | t3_ub6l4g | 1,650,840,886 |
Python | In-Depth Analysis of Moonbirds NFTs using Python and Alchemy | 0.25 | t3_ub5plk | 1,650,838,236 |
|
Python | Anyone know the history of why strings are iterable? | I think every intermediate Python programmer has had to learn the gotcha that you can't really duck-type iterables, because if you accidentally iterate over a string, Python will chug along perfectly fine despite it almost certainly not being the intended behavior. Even worse, because of the way collections ABCs are defined, a typing check like `isinstance("a string", collections.abc.Collection)` will still return True despite it almost certainly not being what is intended.
My question is whether anyone knows *the history* of why this is the case. Given the direction that the language was moving in, I would've thought it'd be a prime candidate for removal in the 2-to-3 transition. Obviously, there are use cases for iterating along elements of a string, but with Python 3 strings being unicode-by-default, the rich standard library, and the general high-level nature of the language, I don't see much of a use case at all. Certainly, I don't think it's contentious to say the drawbacks of making it the default behavior outweigh the benefits, with any real use cases easily accommodated by more specific `str.characters` or `str.bytes` methods.
So, what gives? Has this issue ever been actively discussed in the development of the language? Is it just a case of a holdover from earlier languages that was never really a big enough deal to get challenged? And why was it made even more formal with the introduction of `collections.abc`? Google-ing hasn't really provided any strong answers, so any stories or nuggets of info greatly appreciated!
**edit:** Maybe should have made it more clear that the question is really why strings are *still* iterable by default. I understand the history of strings as character arrays, and don't have a hard time imagining how that naturally made it into the language. But why that is still the case in Python 3 given that:
* It is a gotcha new users frequently run into (just search for people asking how to properly handle a `str` vs a `[str]` in a function argument)
* It doesn't *really* fit with how we think about the datatypes in Python (I doubt many Python programmers day-to-day think of a `str` as "an ordered collection of `str` objects")
* The uses for iterable-by-default seem limited given the wide builtin and standard library functionality available for `str` objects. | 0.31 | t3_ub53ge | 1,650,836,526 |
Python | Breaking Anti-Cheat With Electronics & Python | 0.4 | t3_ub4yc3 | 1,650,836,115 |
|
Python | James Bond film details | import random
import numpy
from statistics import mode
import matplotlib.pyplot as plt
import csv
import collections
##dictionary of films
from numpy import ndarray
films_info_dic = {
'Films':[
{
"Name": "Dr. No",
"Actor":"Sean Connery",
"Running Time": 109,
"Year": "1962"
},
{
"Name": "From Russia with Love",
"Actor":"Sean Connery",
"Running Time": 115,
"Year": "1963"
},
{
"Name": "Goldfinger",
"Actor": "Sean Connery",
"Running Time": 110,
"Year": "1964"
},
{
"Name": "Thunderball",
"Actor": "Sean Connery",
"Running Time": 130,
"Year": "1965"
},
{
"Name": "You Only Live Twice",
"Actor": "Sean Connery",
"Running Time": 117,
"Year": "1967"
},
{
"Name": "On Her Majesty's Secret Service",
"Actor": "George Lazenby",
"Running Time": 140,
"Year": "1969"
},
{
"Name": "Diamonds Are Forever",
"Actor": "Sean Connery",
"Running Time": 120,
"Year": "1971"
},
{
"Name": "Live and Let Die",
"Actor": "Roger Moore",
"Running Time": 121,
"Year": "1973"
},
{
"Name": "The Man with the Golden Gun",
"Actor": "Roger Moore",
"Running Time": 125,
"Year": "1974"
},
{
"Name": "The Spy Who Loved Me",
"Actor": "Roger Moore",
"Running Time": 125,
"Year": "1977"
},
{
"Name": "Moonraker",
"Actor": "Roger Moore",
"Running Time": 126,
"Year": "1979"
},
{
"Name": "For Your Eyes Only",
"Actor": "Roger Moore",
"Running Time": 127,
"Year": "1981"
},
{
"Name": "Octopussy",
"Actor": "Roger Moore",
"Running Time": 131,
"Year": "1983"
},
{
"Name": "A View to a Kill",
"Actor": "Roger Moore",
"Running Time": 131,
"Year": "1985"
},
{
"Name": "The Living Daylights",
"Actor": "Timothy Dalton",
"Running Time": 130,
"Year": "1987"
},
{
"Name": "Licence to Kill",
"Actor": "Timothy Dalton",
"Running Time": 133,
"Year": "1989"
},
{
"Name": "GoldenEye",
"Actor": "Pierce Brosnan",
"Running Time": 128,
"Year": "1995"
},
{
"Name": "Tomorrow Never Dies",
"Actor": "Pierce Brosnan",
"Running Time": 119,
"Year": "1997"
},
{
"Name": "The World Is Not Enough",
"Actor": "Pierce Brosnan",
"Running Time": 128,
"Year": "1999"
},
{
"Name": "Die Another Day",
"Actor": "Pierce Brosnan",
"Running Time": 133,
"Year": "2002"
},
{
"Name": "Casino Royale",
"Actor": "Daniel Craig",
"Running Time": 144,
"Year": "2006"
},
{
"Name": "Quantum of Solace",
"Actor": "Daniel Craig",
"Running Time": 106,
"Year": "2008"
},
{
"Name": "Skyfall",
"Actor": "Daniel Craig",
"Running Time": 143,
"Year": "2012"
},
{
"Name": "Spectre",
"Actor": "Daniel Craig",
"Running Time": 148,
"Year": "2015"
},
{
"Name": "No Time to Die",
"Actor": "Daniel Craig",
"Running Time": 163,
"Year": "2021"
},
]
}
##print values of running time
times_list = []
##Running Time list
for item in films_info_dic["Films"]:
times=item["Running Time"]
times_list.append(times)
##List of Actors
actor_list = []
for item in films_info_dic["Films"]:
Actors=item["Actor"]
actor_list.append(Actors)
##Remove duplicates
actor_list = list(dict.fromkeys(actor_list))
def get_film_details(actor_name,decade):
films_actor_counter=0
films_decade_counter = 0
##actors
for item in films_info_dic["Films"]:
if item["Actor"] == actor_name:
times = item["Running Time"]
times_list.append(times)
# Mean, median and mode of runnint times list
mean_time = numpy.mean(times_list)
median_time = numpy.median(times_list)
mode_time = mode(times_list)
films_actor_counter=films_actor_counter+1
##write to notepad
with open((actor_name)+".txt", 'w') as f:
f.write(f"The mean running time for {actor_name} is {mean_time}\n")
f.write(f"The median running time for {actor_name} is {median_time}\n")
f.write(f"The mode running time for {actor_name} is {mode_time}\n")
f.write(f"{actor_name} starred in {films_actor_counter} number of films.\n")
##decades
Film_Year=item["Year"]
Film_decade=Film_Year[2]
Test_film=decade[2]
if Film_decade == Test_film:
times = item["Running Time"]
times_list.append(times)
# Mean, median and mode of runnint times list
mean_time = numpy.mean(times_list)
median_time = numpy.median(times_list)
mode_time = mode(times_list)
films_decade_counter=films_decade_counter+1
##write to notepad
with open((decade)+"s.txt", 'w') as f:
f.write(f"The mean running time for {decade}s is {mean_time}\n")
f.write(f"The median running time for {decade}s is {median_time}\n")
f.write(f"The mode running time for {decade}s is {mode_time}\n")
f.write(f"{decade}s had {films_decade_counter} number of films.\n")
##call method for each actor
decade_list =["1960", "1970", "1980", "1990", "2000", "2010", "2020"]
for actor,decade in zip(actor_list, decade_list):
get_film_details(actor,decade)
print(times_list)
print(actor_list)
#Mean, median and mode of runnint times list
mean_time=numpy.mean(times_list)
median_time=numpy.median(times_list)
mode_time=mode(times_list)
print(f"The mean running time is {mean_time}")
print(f"The median running is {median_time}")
print(f"The mode running is {mode_time}") | 0.43 | t3_ub2fqt | 1,650,829,006 |
Python | Development of Desktop apps with Python | If you are developing desktop apps and are familiar with environment variables and shortcuts, did you realized that there are no packages that would make it easy for cross compatible and easy management of this stuff ?
After searching and making my own package i decided to make it public so it can potentially help somebody with the same stuff i was struggling before, feel free to check it out:Github: [https://github.com/jiri-otoupal/pycrosskit](https://github.com/jiri-otoupal/pycrosskit)
If you would star my repo for the work I do, it would make my day much better :)
I will be glad if it will make your life easier, Cheers ! | 0.76 | t3_ub2c8w | 1,650,828,730 |
Python | Weekly Code - Week 4: Digit Subtraction! | This week I decided to use OEIS entry A185107: difference of digits of the nth prime. This one is pretty exciting, and I think I may make a library featuring this Digit Subtraction and what not. It's fairly compelling. I don't know what I'd use it for, but I'm sure there'd be some kind of use out there.
This week is documented here:
[https://youtu.be/pHip9F5H8Zc](https://youtu.be/pHip9F5H8Zc)
[https://github.com/F35H/WeeklyCode](https://github.com/F35H/WeeklyCode)
Here's the OEIS entry:
[https://oeis.org/A185107](https://oeis.org/A185107) | 0.67 | t3_ub1ppc | 1,650,826,915 |
Python | I made a game that let's you play any MIDI file with arrow keys! | Video Preview: [https://streamable.com/zhc909](https://streamable.com/zhc909)
It's like dance dance revolution but you can play any song you want, all you need is a midi file. You can specify which instruments you want to play on each difficulty in JSON files.
Source code: [https://github.com/ravenkls/Midi-Arrow-Rush](https://github.com/ravenkls/Midi-Arrow-Rush) | 1 | t3_ub1p3g | 1,650,826,868 |
Python | Possible career in Python as a Bilingual | Hi! I am working right now as a bilingual for Spanish and English in a tech company. I don't have skills in tech such as programming etc. But just recently I decided to study Python to upskill myself and have greater opportunities. But I am not sure if there's a career such as a software developer where I could still use my skill as a Bilingual.
Hoping for your insight.
Thanks | 0.5 | t3_uazva3 | 1,650,821,777 |
Python | I am intermediate, how to take python (programming skills) to next level? | About me: I know basic programming and problem solving. I already made 2 websites (basic todo-app) using python (Django) as backend and free web templates for frontend. I also made some basic projects with MySQL and python. Made some spammer bots with [selenium](https://selenium-python.readthedocs.io/). I worked with file creation and manipulation. Most of the times I use functions (I'm not comfy with classes)
But, at this stage, it feels `something's` off.. I don't know what.. but it feels like I'm stuck at this level.
(*I don't have a job*) | 0.82 | t3_uazm1g | 1,650,821,027 |
Python | Set Types in Python — set, frozenset [Documentation - made easy to read] | 0.67 | t3_uaz839 | 1,650,819,918 |
|
Python | Game of life | Hi,
I've build a small "Game of Life" project, using pygame for display, based first on Conway's rules, and then many other rules (\~20 for now).
It's available on PyPI:
[https://pypi.org/project/conway-pygame/](https://pypi.org/project/conway-pygame/)
and on gitlab.com:
[https://gitlab.com/frague59/conway](https://gitlab.com/frague59/conway)
Enjoy ! | 0.79 | t3_uaxzr5 | 1,650,816,367 |
Python | The Python Graph Gallery | 0.97 | t3_uaxm35 | 1,650,815,307 |
|
Python | Useful tricks with pip install URL and GitHub | 0.75 | t3_uawxuo | 1,650,813,388 |
|
Python | How to use MicroPython on Docker! | 0.79 | t3_uawlsz | 1,650,812,439 |
|
Python | Speeding up python CLI's! | so yesterday I was trying to make a python CLI that needed to be fast.
no matter what I did (`python -S`, pyinstaller, cx_freeze, bytecode compiling) it wouldnt be as fast as I needed it and some even made it slower like cx_freeze.
well I found a way to make running it much much faster (nearly instantaneous).
by using an asynchronous socket server and using netcat as input, you can give input to the server and recieve output immediately, since the script is already running
it works for windows and linux, but you may need cygwin on windows unless there is a built in timeout and netcat command I do not know about
how it works (on linux) is you define a bash function with this:
`hithere(){ printf "$@" | timeout 0.1 nc 127.0.0.1 50200; }`
and run the script:
`python pyspeedtest.py`
to send input you run `hithere Mum` and you get `hi, Mum`
pyspeedtest.py
```
import pyspeed
class myhandler(pyspeed.pyspeed_handler):
def handle_request(self, *argv):
return f"hi, {argv[1]}"
handle = myhandler()
handle.run()
```
pyspeed.py
```python
import asyncio, socket
class pyspeed_handler:
async def run_server(self, address, port, handle):
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((address, port))
server.listen(8)
server.setblocking(False)
loop = asyncio.get_event_loop()
while True:
client, _ = await loop.sock_accept(server)
loop.create_task(handle(client))
async def handle_client(self, client):
loop = asyncio.get_event_loop()
request = None
try:
while request != 'quit':
request = (await loop.sock_recv(client, 255)).decode('utf8')
response = self.handle_request(*([''] + str(request).split(' '))) + '\n'
await loop.sock_sendall(client, response.encode('utf8'))
client.close()
except BrokenPipeError:
pass
def handle_request(self, *argv):
return ''.join(argv)
def run(self, address="localhost", port=50200):
asyncio.run(self.run_server(address, port, self.handle_client))
```
``` | 0.5 | t3_uavrnn | 1,650,809,995 |
Python | ga-extractor - CLI tool for extracting Google Analytics data | Hi /r/Python,
I've created a simple CLI tool in Python for extracting Google Analytics data. It can be handy if you want to retrieve some analytics data without dealing with Google's APIs.
The tool can also transform the data into more readable CSV output.
PyPI package: https://pypi.org/project/ga-extractor/
GitHub repository: https://github.com/MartinHeinz/ga-extractor
Feedback is very much appreciated! | 0.76 | t3_uau4ci | 1,650,804,648 |
Python | Get total time spent watching movies logged on to Letterboxd | [Github Link \[Letterboxd Movie Runtimes\]](https://github.com/HighnessAtharva/Letterboxd-Movie-Runtimes)
You can now get the total time you have spent watching all the movies that you have logged on your Letterboxd Profile and export it to a CSV using this simple Python Script.
Could not find a tool on the internet that did this for me so I built it myself. Enjoy :) | 0.8 | t3_uau2nl | 1,650,804,488 |
Python | Logging facility for Python - Documentation, made easy to read | 0.43 | t3_uatomd | 1,650,803,132 |
|
Python | Building a Soccer Shot Map for Spain | Salve Jason and the Pythonauts!
I've created a tutorial on building a shot map for soccer games. It uses data from Statsbompy and my own library of todofcpy. You can view it here:
[https://www.youtube.com/watch?v=99FVmANPNXI](https://www.youtube.com/watch?v=99FVmANPNXI) | 0.86 | t3_uatfhp | 1,650,802,234 |
Python | borb vs fpdf2 - comparing 2 PDF generation libs: features & benchmark | 0.78 | t3_uasf5r | 1,650,798,393 |
|
Python | I made my first Discord Bot with Python! | Hello everyone! Over the past 2 weeks I have been working on Discord Bot using [discord.py](https://discord.py) and Python! Inspired by r/place I decided to make a simple bot where users and place pixels on a large canvas. Commands include:
$add\_pixel: Add a pixel to the grid at a specified coordinate and rgb color value
$playback: Create a video showing the full canvas history
$ban: Bans a user from placing new pixels (Admin only)
$unban: Unbans a user allowing them to place pixels again (Admin only)
One of the reasons I started with project was to learn how to use the MongoDB database as well as learn discord.py Here is a small example of the bot being used on my server
https://i.redd.it/m1ure9744gv81.gif
If you are interested feel free to add the bot to your server with this link: [https://discord.com/api/oauth2/authorize?client\_id=964251008115019847&permissions=116736&scope=bot](https://discord.com/api/oauth2/authorize?client_id=964251008115019847&permissions=116736&scope=bot) Also DM me (ScriptLine Studios#8597) if you need help or run into issues!
Thanks everyone! | 0.9 | t3_uar1v9 | 1,650,792,599 |
Python | Open source daily Capybara Website built with Python | Ever wondered "If a random Capybara was assigned to Today, what Capybara would it be?" Well wonder no more, [Capy.life](https://capy.life/) has your back!
[Capy.life](https://Capy.life) is a free & open source website built with Svelte & Python, what also has a Discord, Matrix & Twitter bot written in Python.
The Capybara submitting process uses perceptual hash to ensure two Capybara images aren't too much alike.
# Source code
* [Website](https://github.com/capylife/capyend) (Any PRs or Stars are appreciated)
* [Twitter bot](https://github.com/capylife/flappycapy)
* [Discord bot](https://github.com/capylife/capycord)
* [Matrix bot](https://github.com/capylife/neocapy)
# Previews
[Home page](https://preview.redd.it/yuq91y504gv81.png?width=1668&format=png&auto=webp&s=f7245094ddacf37ac8e0047f7854979cb35e40d8)
[Admin Page](https://preview.redd.it/9bnjcl614gv81.png?width=1668&format=png&auto=webp&s=fd72626f13a76e3bc8e2c6b450c9ff5c9975d26d) | 0.67 | t3_uar10e | 1,650,792,493 |
Python | GitHub - roniemartinez/browsers: Python library for detecting and launching browsers | 0.61 | t3_uaqavx | 1,650,789,380 |
|
Python | What's your favorite GUI library and why? I'll start, mine is TKinter because its the first one I learned and I found it easy for basic display | 0.93 | t3_uapobr | 1,650,786,701 |
|
Python | Python Selenium Tutorial #10 - Scrape Websites with Infinite Scrolling | 0.83 | t3_uapb3n | 1,650,785,148 |
|
Python | Extracting WhatsApp messages from an iOS backup | 0.95 | t3_ualvg6 | 1,650,771,297 |
|
Python | What to do next after learning basic python grammar | Hello everyone, I am from China. My daily job is to do sales. I am interested in programming, but I will not apply for programmers. I just want to make programming as a hobby. I have just finished learning the basics of python. What should I learn or what can I do next? I mainly think about using python or programming to do some fun things or interesting things in life. I hope friends who have the same interest, thank you | 0.72 | t3_ualp72 | 1,650,770,659 |
Python | Program to document code snippets and control under-development projects | Hey there,
I wrote a **Tkinter** program specifically for developers based on two concepts:
* Giving the developer the ability to document (their/others) knowledge and important **code snippets** in an easy, readable, and organized manner.
* Grouping the under-development **projects in one place** for easy access and control, provided the directory path.
Please, feel free to have a look at the [Source Code](https://github.com/shehab-fekry/Developer-WorkSpace) and tell me what you think :)
There will be further features to be added.
&#x200B;
https://preview.redd.it/p94e69l4xdv81.png?width=899&format=png&auto=webp&s=26e1359e3f2ac793765cfed2b05b9a3fa55c9c5a
https://preview.redd.it/llglv803xdv81.png?width=899&format=png&auto=webp&s=9bfc8a963025fdc9ecd7bc41829babdc6631ebac | 0.78 | t3_uaknmh | 1,650,766,926 |
Python | just want to bury | I do not speak English so well so I will write with the help of google translator, I started studying programming for now and I'm having difficulty understanding the makes something object-oriented and something variable I hope not to be talking wrong i realized that often the staff talks about symbols and numbers as whole and letters as variable is right if I think that way ? | 0.4 | t3_uak5ot | 1,650,765,192 |
Python | Pons, an async Ethereum RPC client library | I've been waiting a long time for async support in `web3`, and now that it started to appear, it only supports `asyncio` (while I use `trio` in my application), and is in general not quite finished. So I decided to write an RPC client of my own with convenient contract calls, simple structure (instead of a hundred levels of indirection in `web3`) and strictly typed. Still a lot of possible enhancements possible, but it is already useful (well, I use it, at least :).
Repo: https://github.com/fjarri/pons
A simple example:
import trio
from eth_account import Account
from pons import Client, HTTPProvider, AccountSigner, Address, Amount
async def main():
provider = HTTPProvider("<your provider's https endpoint>")
client = Client(provider)
acc = Account.from_key("0x<your secret key>")
signer = AccountSigner(acc)
async with client.session() as session:
my_balance = await session.eth_get_balance(signer.address)
print(my_balance)
another_address = Address.from_hex("0x<some address>")
await session.transfer(signer, another_address, Amount.ether(1.5))
my_balance = await session.eth_get_balance(signer.address)
print(my_balance)
trio.run(main)
More in the [Tutorial](https://pons.readthedocs.io/en/latest/tutorial.html#tutorial) (not very extensive for now, but hopefully gives an idea of how to use it), and of course there's always the [API reference](https://pons.readthedocs.io/en/latest/api.html).
I am sure there are a lot of usage scenarios I haven't even considered, so I would be especially grateful for complaints about this or that method/parameters/naming being inconvenient, counterintuitive, confusing, or out of place. | 0.33 | t3_uaj86y | 1,650,761,986 |
Python | Sunday Daily Thread: What's everyone working on this week? | Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share. | 0.78 | t3_uai5y5 | 1,650,758,410 |
Python | Deciding what to use among Cython / Pypy / Numba | So I want to experiment and speed up my code. I have studied the basics of Cython and Numba but Pypy only has 10 year onld videos.
What I have found:
- Cython converts Python into C and makes the code useable in both Python and C
- Numba directly converts Python into Machine code and is useful for Math operations (numpy)
- Numba is JIT compiler
- Both Cython and Numba don't support 3rd party libraries like Pandas and spacy..
- Pypy is an implementation of Python. Normally the Python we use when we write python abc.exe in cmd is Cpython(not Cython).
- Numba and Cython speed up the code a lot if the code is compatible... things like list don't work with Numba...
Would be super helpful if someone can please explain the difference between Numba, Cython and Pypy and when to use which.
Even pointing me to the resources would be great!
Thanks in advance. | 0.84 | t3_uafu40 | 1,650,751,007 |
Python | Discussion: What is the most pythonic way to print an extra line break? | Which of these four equivalent methods do you prefer and why?
print('Beginning processing ...\n')
or
print('Beginning processing ...', '\n')
or
print('Beginning processing ...', end='\n\n')
or
print('Beginning processing ...')
print()
Is any of them more or less pythonic than another? | 0.92 | t3_uadbi3 | 1,650,743,421 |
Python | A simple python library that can be used to run large Web3 queries on Ethereum blockchain concurrently as per Ethereum JSON-RPC specification. | A simple python library that can be used to run large Web3 queries on Ethereum blockchain concurrently as per Ethereum JSON-RPC specification.
The library provides a bare minimal framework for expressing raw JSON-RPC queries as described in the Ethereum Specification and execute them together either concurrently (off-chain on the client side) or together as a batch (JSON-RPC batch specification on-chain). This method greatly reduces the time required to run large queries sequentially and thus can be used for use-cases where we need to index large number of transactions happening on ethereum blockchain in a local database for faster Web2 queries.
Source code: [GitHub](https://github.com/Narasimha1997/aio-eth)
PyPi: [aio-eth](https://pypi.org/project/aio-eth/) | 0.27 | t3_uad9mx | 1,650,743,270 |
Python | Face detection algorithms comparison | I selected 5 ready-made algorithms for face detection and compared them with each other by such metrics as Precision, Recall, IOU and time on the dataset I marked up. I am ready to accept your Pull Request with your solutions(algorithms) and results!
Blog post: [https://habr.com/ru/post/661671/](https://habr.com/ru/post/661671/)
GitHub: [https://github.com/wb-08/face-detection-algorithms-comparison](https://github.com/wb-08/face-detection-algorithms-comparison) | 0.67 | t3_uacer5 | 1,650,740,697 |
Python | GitHub - plasma-umass/slipcover: Near Zero-Overhead Python Code Coverage | 0.87 | t3_ua8sgx | 1,650,730,255 |
|
Python | deferred-import: Lazy import and install on demand Python packages |
Lazy import and install on demand Python packages.
1. Package will be loaded only when you use it in the first time. Deferring it makes module loading much faster.
1. If module is missed, the package will be automatically installed. It allows to make some project dependencies optional and install them on demand.
https://github.com/orsinium-labs/deferred-import | 0.59 | t3_ua7bsz | 1,650,726,123 |
Python | Parking space counter created using OpenCV and Python | Hello!
I created a simple two-step parking space counter:
\- first, you mark the positions of all parking spaces you are interested in using "parking\_space\_picker.py";
\- second, you run "parking\_space\_counter.py" to check if the parking space is vacant or not and count them.
[RESULT](https://youtu.be/LERHWFmSSdM)
[CODE](https://github.com/codegiovanni/Parking_space_counter)
&#x200B;
Video used in the code:
Tom Berrigan [https://www.youtube.com/watch?v=yojapmOkIfg&list=LL&index=10](https://www.youtube.com/watch?v=yojapmOkIfg&list=LL&index=10)
&#x200B;
The code is inspired by:
Murtaza's Workshop - Robotics and AI [https://www.youtube.com/watch?v=caKnQlCMIYI](https://www.youtube.com/watch?v=caKnQlCMIYI) | 0.94 | t3_ua6xh2 | 1,650,724,972 |
Python | Step by step explanation of Insertion Sort in Python | 0.54 | t3_ua6x8j | 1,650,724,949 |
|
Python | Space Science: Autoencoder latent space visualization of asteroid spectra | Hey Everyone,
Last time, I introduced Autoencoders (using Keras) to develop a deep learning architecture that learns a low-dimensional representation of asteroid reflectance spectra.
Although I compressed the 49-dimensional spectra to only 2 dimensions, the results were quite fair. So... why did I compress it so ridiculously high? Well, a 2-D space can easily be visualized!
And this visualization is being done today. In today's tutorial, we'll use Matplotlib for a static display of the data, and ipwidgets, to create an interactive widget within our notebook on Google Colab! Let's see whether our 25-fold compression leads to some proper latent space, where the asteroid classes can be distinguished:
GitHub Link: [https://github.com/ThomasAlbin/Astroniz-YT-Tutorials/blob/main/%5BML1%5D-Asteroid-Spectra/12\_dl\_autoencoder\_latent\_space.ipynb](https://github.com/ThomasAlbin/Astroniz-YT-Tutorials/blob/main/%5BML1%5D-Asteroid-Spectra/12_dl_autoencoder_latent_space.ipynb)
YouTube Link: [https://www.youtube.com/watch?v=h26O2qbc5DA](https://www.youtube.com/watch?v=h26O2qbc5DA)
The next session will be the final one of the asteroid science project. There, we will create a higher dimensional latent space and apply some clustering algorithm to determine the number of asteroid classes from a data-scientific perspective. Stay tuned!
Thomas | 0.78 | t3_ua6sq9 | 1,650,724,581 |
Python | What makes a good programmer? | I recently started a python course and I'm currently just focused on it but I feel like this is wrong and I'm missing something | 0.53 | t3_ua64gc | 1,650,722,585 |
Python | Python matplotlib and numpy New Playlist | 0.25 | t3_ua2fpl | 1,650,709,546 |
|
Python | How do you manage conflicting packages in your requirements.txt ? | Hi,
Let's say you have in your requirements.txt :
package_A
package_B
package_C
package_D
but `package_A` requires `some_dependency<=1.5` and `package_B` requires `some_dependency>=2.2` . How do you handle that (knowing that I might have tens of conflicting packages)?
I don't think virtualenvs would be a good solution here since the project has one entry point and packages are imported in the same code ...
Thank you !:) | 0.96 | t3_ua2a7k | 1,650,708,904 |
Python | "Community is essential to programmers" - Eric Matthes | I've just started working my way through Eric Matthes' Python Crash Course. In his introduction he states, " Community is essential to programers because programming isn't a solitary pursuit.... Having a well connected community is critical in helping you solve problems, and the Python community is fully supportive of people like you who are learning python as your first programming language."
&#x200B;
I've dabbled a bit in the basic front end languages and I'm currently playing around with Vue so I wouldn't say it's my first language. However, I did feel compelled to reach out to this community after reading that.
If you have any advice for someone starting to pick up python, I'm happy to listen and learn. | 0.84 | t3_ua1z3n | 1,650,707,604 |
Python | 10 examples of using Python for big data analysis | 0.8 | t3_ua1kfl | 1,650,705,802 |
|
Python | MNE — Open-source Python package for exploring, visualizing, and analyzing human neurophysiological data: MEG, EEG, sEEG, ECoG, NIRS, and more | 0.97 | t3_ua0faz | 1,650,700,833 |
|
Python | Python Tips and Tricks — Write Better Python Code | 0.64 | t3_u9ziwb | 1,650,697,016 |
|
Python | freeCodeCamp: Gradio Course - Create User Interfaces for Machine Learning Models in Python | 0.87 | t3_u9y93f | 1,650,691,784 |
|
Python | PCEP Certification exam - Python | Hi All,
Did anybody take PCEP certification exam? If it took you more than one try, did you have to pay $59 every time you attempt? Or one time was enough?
I am making this post because couldn't find the answer on google. | 0.6 | t3_u9x1e4 | 1,650,687,186 |
Python | Call me naive, but would it not be possible to create a tool for python the auto adds type hints at run time? | I’m going to learn python over the summer, but coming from Java & c# in IDE’s where casting etc can auto completed within the problem pane when making newb mistakes, and also knowing the pain of PHP runtime errors, I’m hoping the dynamic experience will be smoother with python.
I’m ranting.. would this be feasible ? Just a thought. | 0.33 | t3_u9sdwa | 1,650,672,030 |
Python | Saturday Daily Thread: Resource Request and Sharing! Daily Thread | Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?
Use this thread to chat about and share Python resources! | 1 | t3_u9sdh3 | 1,650,672,009 |
Python | I have multiple interdependent Python services & modules for my work. I use conventional commits (changetype: scope: …) allowing automated changelogs. I think I need to go monorepo and add the changed service to the commit structure (service: changetype: scope). Does this look like a good strategy? | 0.8 | t3_u9rgzf | 1,650,669,201 |
|
Python | What is a good, pure Python alternative to lxml's objectify? | Reference: https://lxml.de/objectify.html
> Accessing the children of an XML element deploys object attribute access. If there are multiple children with the same name, slicing and indexing can be used. Python data types are extracted from XML content automatically and made available to the normal Python operators. | 1 | t3_u9qp2k | 1,650,666,983 |
Python | Proper launch of python packages | 0.75 | t3_u9q8tx | 1,650,665,684 |
|
Python | Coding an Intelligent Battleship Agent | 0.5 | t3_u9pn6u | 1,650,664,027 |
|
Python | rashell (Relational Algebra Shell) | Hi all.
I've uploaded my project on Pypi. It is called **rashell** which stands for **R**elational **A**lgebra **S**hell. It provides a command line interface and a DSL to define, fill and query a relational model. This tool is intended for educational use only, to illustrate the underlying concepts of relational databases in a more interactive way. It can be installed via pip :
$ pip install rashell
Please refer to Readme on gitlab to know how to use it.
[https://gitlab.com/skebir/rashell](https://gitlab.com/skebir/rashell)
[https://pypi.org/project/rashell/](https://pypi.org/project/rashell/)
I would like to have your opinion on it. Thank you in advance. | 0.84 | t3_u9p9g6 | 1,650,662,976 |
Python | Does anyone know what editor this is or what sorts of editors have this feature? | [The editor is linked here](https://i.imgur.com/9HcadwR.gif)
Basically allowing you to similar parts to multiple lines of code by clicking and then hitting backspace? | 0.5 | t3_u9obb5 | 1,650,660,405 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.