pythondaily | Образование

Telegram-канал pythondaily - Python Daily

1102

Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels

Подписаться на канал

Python Daily

Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1enldf3

Читать полностью…

Python Daily

Where to deploy flask apps with autoscale other than replit, pythonanywhere?

I used to deploy it on Pythonanywhere but I saw that not all libraries exist and the requests library has a lot of errors when making HTML calls.
then I moved to Replit which has a nice UI and any feature in a normal IDE (locally).
It was great, I used to deploy my apps with autoscale and used to pay around 2 to 5$ monthly because my apps are only for a few users.
But now replit Autoscale and reserved VM require replit CORE which is 20$ a month and I don't want to pay that much for a small app.
So is there another platform with:
- good UI and IDE (not necessarily but it would be good)
- work the same as local IDE (has all libraries)
- making HTML calls normally like when I make locally without any problem
- has autoscale payment without the need to subscribe to a special plan
- a 24/7 run option (I need to scrape data to my database every 1 hour)

/r/flask
https://redd.it/1enfbb9

Читать полностью…

Python Daily

What are the real downsides of python? And can you really do everything with it?

Im new to coding and I've been interested in making a project I've always wanted to make (A Digital Audio Workstation aka Music Software) but I'm not quite sure python is an option I can go with since the internet apparently keeps saying python is more ideal for simpler software, data analysis, etc.

(im not trying to get hanz zimmer to switch to switch to my app btw, the idea is just a simpler software to get your ideas running so it wouldn't be very cpu consuming I imagine)

/r/Python
https://redd.it/1en1rl2

Читать полностью…

Python Daily

What's your go-to method of debugging a django endpoint?

As a typescript developer, I've inherited a django project that doesn't have any documentation or tests. One of the endpoints is behaving weirdly, but the only way to debug it is to spin up a local server and start hitting the endpoint!

In my typescript codebase, if I want to mess around and run different functions in isolation, I just make a script that imports the ORM (and whatever other dependencies), imports my functions, and runs em. It's really nice to be able to run different bits of code willy-nilly without having to hit endpoints. It seems like django admin commands might fill that role in django, but it doesn't seem like that's a common practice, so I'm not sure I want to spend the time setting it up if there's something better.

How do y'all typically debug stuff in a django project?

/r/django
https://redd.it/1en7bb9

Читать полностью…

Python Daily

Deploying a Django project. Need some guidance!!

Deploying my first project/MVP. The stack is Django, HTML, Tailwind CSS and probably using Postgres. I’m about speed and want to get this out before next week. So I’m thinking of deploying it on a docker container and have the container on a VM. Does this sounds about right? I have my domain! Just need guidance!

/r/django
https://redd.it/1emt1m8

Читать полностью…

Python Daily

Free Python Camp Aug 25-30

SIGN UP: https://docs.google.com/forms/d/e/1FAIpQLSd3lpMmRSlLqMfCaAVkc-RY4h3MZBLjJdDr6QwaZBiGe3GHw/viewform

Code Catalyst Academy (August Session) is a FREE online summer coding camp for people of all ages. The camp will be held from August 25 to 30 at 5-6 PM CST. We will be exploring Python fundamentals as well as some more advanced topics. You must join our Discord server as that is where we will conduct the camp. The discord link is in the following form where you can sign up:
https://docs.google.com/forms/d/e/1FAIpQLSd3lpMmRSlLqMfCaAVkc-RY4h3MZBLjJdDr6QwaZBiGe3GHw/viewform.

/r/Python
https://redd.it/1emw2sq

Читать полностью…

Python Daily

Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1emrh0k

Читать полностью…

Python Daily

Research The Puzzling Failure of Multimodal AI Chatbots

https://preview.redd.it/ummnvenf1ahd1.png?width=2592&format=png&auto=webp&s=7115ba5de026ada17b0636ec2fa3c3151b3e5eb6

Chatbot models such as GPT-4o and Gemini have demonstrated impressive capabilities in understanding both images and texts. However, it is not clear whether they can emulate the general intelligence and reasoning ability of humans. To this end, PuzzleVQA is a new benchmark of multimodal puzzles to explore the limits of current models. As shown above, even models such as GPT-4V struggle to understand simple abstract patterns that a child could grasp.

https://preview.redd.it/7l5fmuys1ahd1.png?width=2716&format=png&auto=webp&s=337118dbc55230637cec1b08b90ae943746ddbb0

Despite the apparent simplicity of the puzzles, we observe surprisingly poor performance for current multimodal AI models. Notably, there remains a massive gap towards human performance. Thus, the natural question arises: what caused the failure of the models? To answer this question, we ran a bottleneck analysis by progressively providing ground-truth "hints" to the models, such as image captions for perception or reasoning explanations. As shown above, we found that leading models face key challenges in visual perception and inductive reasoning. This means that they are not able to accurately perceive the objects in the images, and they are also poor at recognizing the correct patterns.

https://arxiv.org/abs/2403.13315

/r/MachineLearning
https://redd.it/1emi095

Читать полностью…

Python Daily

Django 5.1 released
https://www.djangoproject.com/weblog/2024/aug/07/django-51-released/

/r/django
https://redd.it/1emckvw

Читать полностью…

Python Daily

Saving media folder

Hello everyone, Where do you save your media files in a server or VPS given you are not using storage buckets or other file storage services?

/r/django
https://redd.it/1em5of9

Читать полностью…

Python Daily

Heroku Flask Deployment w/ Gunicorn errors

So I have my Procfile set up as such

web: gunicorn app:app

and my flask run set up as

port = int(os.environ.get("PORT", 5000))
app.run(host="0.0.0.0", port=port)

but when i deploy to heroku i still get the defualt 'this is a development server' message. i dont know what i am doing wrong.

/r/flask
https://redd.it/1elxvc2

Читать полностью…

Python Daily

Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1elxc34

Читать полностью…

Python Daily

[P] Grounded SAM 2: Ground and Track Anything

https://preview.redd.it/13854j03q2hd1.jpg?width=1280&format=pjpg&auto=webp&s=0735848ae40c2591111fa4ed91d2c28ea829c0ac

With the release of SAM 2, we have taken the opportunity to update our Grounded SAM algorithm. The biggest improvement in SAM 2 compared to SAM is the expansion of its segmentation capabilities to video, allowing users to interactively segment any object and track it in video. However, the main issue with SAM 2 is that the segmented and tracked objects do not contain semantic information. To address this, we have continued the approach of Grounded SAM by **incorporating an open-set detection model**, Grounding DINO. This enables us to extend 2D open-set detection to video object segmentation and tracking.

We have release our code in

[https://github.com/IDEA-Research/Grounded-SAM-2](https://github.com/IDEA-Research/Grounded-SAM-2)

with **very easy implementations**, which is convenient for users.

Project Highlights:

In this repo, we've supported the following demo with **simple implementations**:

* **Ground and Segment Anything** with Grounding DINO, Grounding DINO 1.5 & 1.6 and SAM 2
* **Ground and Track Anything** with Grounding DINO, Grounding DINO 1.5 & 1.6 and SAM 2
* **Detect, Segment and Track Visualization** based on the powerful [https://github.com/roboflow/supervision](https://github.com/roboflow/supervision) library.

And we will continue update our code to make it easier for users.

/r/MachineLearning
https://redd.it/1elmxnq

Читать полностью…

Python Daily

New Tool Easily Convert YouTube Videos to MP!

Hey everyone!

I’m super excited to share a new tool I’ve been working on: YouTube to MP Converter! This little app makes it super easy to turn your favorite YouTube videos into MP3 files. Whether you want to jam out to your favorite songs offline or save some educational videos as files, this tool has you covered.

# What My Project Does?

The YouTube to MP Converter is a simple, user-friendly application that allows you to convert YouTube videos into high-quality MP files. It supports various MP formats and lets you choose where to save the files on your computer. Plus, it comes with some cool customization options to tweak the user interface according to your preferences.

# Target Audience

This tool is perfect for anyone who:

Loves listening to music or podcasts from YouTube offline.
Wants an easy way to save educational videos as files.
Prefers a customizable user interface to suit their style.
Is looking for a straightforward, reliable way to convert YouTube videos to MP3.

# Comparison

Compared to other YouTube to MP converters, my tool stands out because of its:

Customization Options: Personalize the user interface to make the app look just how you like it.
Simplicity and Ease of Use: The intuitive

/r/Python
https://redd.it/1elh7nr

Читать полностью…

Python Daily

Database suggestion

For a machine learning project I am looking into different database backends to store my data. The data is a sparse time series matrix (example at the end). Also, the sensor names are dynamic and could change in the future

Further, FastAPI is used for the backend.

What database like TimescaleDB or InfluxDB do you have experience with and which one do you recommend?



data = {
    "entry_id": "61da2b48-7526-418b-b4d2-0c87a9fb7237",
    "data": {
        "2024-08-01 00:00:00": {
            "sensor_1": 0.0,
            "sensor_2": 10.0
        },
        "2024-08-01 01:00:00": {
            "sensor_1": 1.0
        },
        "2024-08-01 02:00:00": {
            "sensor_1": 1.0,
            "sensor_2": 11.0,
            "sensor_3": 30.0
     

/r/Python
https://redd.it/1elctrz

Читать полностью…

Python Daily

Help needed with Gunicorn config

I basically have the following gunicorn command:

gunicorn -k gevent -w 4 -b myapp:app0.0.0.0:8000

Now the thing is sometimes the DB calls take 10 sec to execute or 1 sec when the load increases/decreases. Most of the times I get this error:

https://preview.redd.it/13x9vvwfs6hd1.png?width=1284&format=png&auto=webp&s=281e81a40ceaa03d8e304a613434171ca0c57d43

Why do I get this? I also have set my connection pool to 10 and i mean, the site gets started loading slow after I hit refresh 6 times then it is suddenly slow like a turtle with workers crashing. Why? What am I doing wrong?

I need to know why my workers are getting exhausted? Even the data I am giving is paginated too so I did not understand...

/r/flask
https://redd.it/1em4utq

Читать полностью…

Python Daily

I made my first ecommerce and what I have got so far

Hi, I build my own ecommerce website using django, DRF, Next.js I can’t share the site because of security reason. However, I want to share what I have got so far..

Reason why I built by myself while there are so many good ecommerce solutions because I thought if I use Next.js, it would dramatically increase sales rate.

In reality, Single page app doesnt make much differences..

Here is the report,

Ad spent: $300
Sales: $200
Total Amount in Cart: $1000
Purchase Rate from cart: 20%
Purchase Rate from ad: 1.6%
Ad click: 2.3%

I am focusing on Purchase rate.. so many people add to cart but few people buy..



/r/django
https://redd.it/1encgd3

Читать полностью…

Python Daily

Unable to get flask login to work with flutter

I'm trying to get flask login to work with my mobile flutter app, but it doesn't seem like flutter sends the cookies with the request resulting in 401 whenever I log in and try to access a login required resource.

What I have tried:
In my flutter frontend, on first reponse manually save cookies and set in for all subsequent requests. The cookie seems to be correctly set when I debug in my backend, but I still somehow get 401.

I've also tried a cookie management library for flutter, dio_cookie_manager, but to no avail. The cookies don't seem to be properly set.

Any idea? Should I switch to JWT or something else? Ideally I'd like to keep using flask login and figure out a way to make it work with my flutter mobile app. Thanks

/r/flask
https://redd.it/1emrqp3

Читать полностью…

Python Daily

Career Advice: Mid-Senior Django Developer

Hey guys, I've been in IT for few years now. I've been trying to switch into Development side. I need your suggestion what topics or expectations you have from Mid/Senior Django Developer.
It would be great if you can mention those topics as well.
Thank You all in advance 🙂

/r/django
https://redd.it/1en2tzc

Читать полностью…

Python Daily

What “enchants” you about Python?

For those more experienced who work with python or really like this language:

What sparked your interest in Python rather than any other language? What possibilities motivated you and what positions did/do you aspire to when dedicating yourself to this language?



/r/Python
https://redd.it/1em0heb

Читать полностью…

Python Daily

Which one should I use, for a login service?

I'm trying to decide between these approaches:

The endpoint:

data = request.get_json()
response, status = auth_service.login(data)
return jsonify(response), status

1:

if not validate_credentials(email, password):
logger.warning(......)
create_audit(......)
abort(401, description="Email or Password Incorrect")


# errors_handler.py
u/errors_blueprint.app_errorhandler(401)
def unauthorized(error):
    response = {
        "success": False,
        "error": "Unauthorized",
        "description": error.description,
    }
    return jsonify(response), 401

2:

if not validate_credentials(email, password):
raise InvalidCredential("Email or Password Incorrect")



# Create an error handler for exception, including status code into custom exception
# and a default message, include logging and audit

3:

if not validate_credentials(email, password):
logger.warning(......)


/r/flask
https://redd.it/1emsh7r

Читать полностью…

Python Daily

Confused about the delete route in my blueprint

So I'm making a book tracking application based off the flask tutorial with a few extra features (like allowing the user to input their current page and calculating a completion status)

Right now, my delete function is acting funny. The blog delete function takes me to a route
"POST /3/delete HTTP/1.1"
My version returns
"POST /anonymous/to%20be%20deleted/update HTTP/1.1"
Notice how it the url_for function builds the route for update instead?
This is my book.delete function I have in the book blueprint....

@bp.route("/<book_author>/<book_title>/delete", methods=('POST',))
def delete(book_author, book_title):

#updated_book = get_author_book(book_title, book_author)
book_id = returnIdFromTitleAndAuthor(book_title, book_author)

print("book_id currently is: " + book_id['id'])

if book_id is None:
flash("No book of that title + author to delete.")

db = get_db()
db.execute("DELETE FROM books WHERE books.id = ?", (book_id['id'],))
db.commit()

#print("Book is outta here")
flash("Book Deleted")
return redirect(url_for("book.index"))

None of the print statements are showing, meaning the function isn't being called. Here is

/r/flask
https://redd.it/1emtg60

Читать полностью…

Python Daily

Header duplicate issue

So I'm trying to do a post request through curl to my flask server. I coded the headers into it. I coded the header "Connection" value to be "keep-alive"
And well it works but somehow its also showing another header called "Connection" with the value "close" How to solve this? Because It should only show keep-alive.


/r/flask
https://redd.it/1emn9h9

Читать полностью…

Python Daily

What’s the best way to integrate a shared PostGreSQL DB in development?

Hello,

We’re working on a large university group project which aims to develop a webapp with Django that will eventually be hosted on a virtual host provided by the university.

The server is running with Apache, Ubuntu Linux combined with a PostgreSQL DB.

So far we‘re in the development stage, programming locally on our devices, using Gitlab as version control. We currently use the default SQLite3 DB and upload it to Gitlab together with the code.

I already have access to the virtual host but haven’t played around with it much since that’s not really my expert field.

Now, I’ve read in several sources that it would be smarter to imitate the server tech stack, even in early development phases. That means, instead of using SQLite, we should be already using a PostgreSQL DB instead, even if we only work with dummy data so far.

Now here’s my question. What is the best practice to use a PostgreSQL DB, that synchronizes existing data between the different people involved in programming?

Obviously if I change something, i.e. adding a new user, I want my colleague to also have access to this newly created user the next time he makes changes to the project.

I googled this question

/r/django
https://redd.it/1em9s9b

Читать полностью…

Python Daily

need a django minor project

hello developers, I need a unique django project (minor project) please. please share a project, I need help, I've to submit it to my college but i've zero time left to make it. so please guys

/r/django
https://redd.it/1em4621

Читать полностью…

Python Daily

Useful automations using Slack, GitHub, Jira, Google tools and more

What My Project Does

Build relatively simple but useful automations in Python deployed on AutoKitteh using integrations to various applications such as GitHub, Slack, Jira, Google Calendar, Google sheets and more. For example:

Categorize new emails in your Gmail inbox using ChatGPT and send notifications to the appropriate Slack channel.
Automatically set JIRA ticket assignees based on Google Calendar events.
Scan your Copilot users and request them to free up licenses if not used for two weeks.
"Break Glass" - Using Slack to orchestrate a temporal elevation of privileges in AWS. A developer asks for privileges in Slack using Slash command, the IT team can approve on deny in Slack form. If approved, the workflow elevates privileges in AWS and reduces back after some period of time.

All written in Python, very short and easy to modify: https://github.com/autokitteh/kittehub

Target Audience 

Can be used by any developer or in production.

You can install the platform and run automation on your PC / Cloud or ask access for the cloud service.

Comparison

Workflows in no-code/low code platforms like Zapier, 8n8 and more. The main difference is that it's a developer first platform (write workflows in code), and it supports durable execution. What is means is that you can write

/r/Python
https://redd.it/1elttxs

Читать полностью…

Python Daily

What do you guys think of how I'm handling this endpoint?

I'm wondering if maybe I can handle this differently, it really seems very repetitive.

Also what else can I add to the custom exceptions, right now they are just helping me handle separate errors appropriately, but I think I'm missing a way of getting more out of them.
Would adding the status code to them be a good idea?

I also read something about f strings when using logging and how it can impact the log message. The proper way is using this `logger.info("Text %s", data)` right?

try:
    response, status = auth_service.login(data)
    logger.info(f"Login Successful: {data['email']}")
    create_audit_log(data["user_id"], "Login", "Login Attempt Successful")
    return jsonify(response), status

except InvalidCredentials as e:
    logger.warning(f"Login Attempt Failed: {data['email']} - Invalid Credentials")
create_audit_log(data["user_id"], "Login", "Login Attempt Failed: Invalid Credentials")
    abort(401, description="Email Or Password Is Incorrect")

except DatabaseQueryError as e:
    logger.error(f"Login Attempt Failed: {data['email']} - {traceback.format_exc()}")
 

/r/flask
https://redd.it/1elnply

Читать полностью…

Python Daily

Just Launched my first public project! looking for feedback and tips

Hi everyone,
I just launched my first project, "RecAnthology" – a recommendation system for books, movies, and TV shows! I'd love to hear your thoughts and get some tips.
I uploaded it to a public repo ( https://github.com/karar-hayder/RecAnthology ) and hosted it on pythonanywehere ( https://recanthology.pythonanywhere.com ).
Any feedback, ideas and tips are much appreciated

https://preview.redd.it/fufv5mx7lxgd1.png?width=714&amp;format=png&amp;auto=webp&amp;s=94985cf2dad810d1e7ab8790da1a92297c701c94

https://preview.redd.it/z7peklx7lxgd1.png?width=1269&amp;format=png&amp;auto=webp&amp;s=a18bfcc29a1e610fb85b42fd9208574dfb5b8d2c

/r/djangolearning
https://redd.it/1el61gz

Читать полностью…

Python Daily

A Simple sync FastAPI Boilerplate with minimal overhead

Why? To keep myself building the same thing again and again. Lot of great boilerplate projects already out there but many a times they have certain extra features, atleast for me, or use some other 3rd party packages which are not needed by all the projects.

If it helps anyone else too to get the ground running - https://github.com/keshavagrawal89/fastapi\_boilerplate
Quick README: https://github.com/keshavagrawal89/fastapi\_boilerplate/blob/main/README.md

There are so many things which could have been added here but were intentionally left out because sometimes adding features to simple boilerplate kind of defeats the concept of boilerplate. If anyone wants to contribute or fork it out to add any required features - they are welcome to do so.

Although nginx, celery scope is also added in docker-compose but not necessary.
Supabase is used for authentication and Postgres as Database. Should be enough for most of the applications.

/r/Python
https://redd.it/1eldpb3

Читать полностью…

Python Daily

How would you implement a "10% off for first-time customers" coupon?

I need to create a coupon that shouldn't be able to be reused.

I've thought of cookies, IP, emails/authentication, fingerprinting, etc., but nothing is really bulletproof.

How would you approach this?

Edit: This is for an ecommerce platform, so assume no user database since guest checkouts are a must.

/r/django
https://redd.it/1ekxcom

Читать полностью…
Подписаться на канал