Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Federated-Recommendation-Neural-Collaborative-Filtering

Neural Collaborative Filtering (NCF) is a paper published in 2017. It is a common methodology for creating a recommendation system. However, recommendation data might not want to be shared beyond your own device. Therefore, last year, I looked into applying this ML algorithm in a Federated Learning setting, where your data stays on your own devices.


AmanPriyanshu/Federated-Recommendation-Neural-Collaborative-Filtering (github.com)

/r/Python
https://redd.it/12ko8f5
My friend and I created a learning platform to teach kids how to problem solve and create cool projects with Python. We made it incredibly fun, since it's something we wish we had when we were younger.

You can check it out here: codera.app

/r/Python
https://redd.it/12kphmi
My first Django project

Hello everyone, I'm 17 years old and have been learning Python for 6 months, and I've been studying Django for the last 2 months. During this time, I completed my first Django pet project. I'm interested in your opinion about this project. How does it compare to the average statistical project, and what improvements or additions could be made, or vice versa, what should be removed? Overall, I would appreciate hearing your thoughts on it.

Project: https://github.com/FCTL3314/SpecialRecipe

/r/django
https://redd.it/12kpvrp
codecov gone from PyPi

The codecov package (all versions of it) seems to have disappeared from PyPi

https://pypi.org/project/codecov/ <-- 404 :(

I'm assuming this breaks a ton more than just my project (https://github.com/locustio/locust/actions/runs/4687344723/jobs/8315803536)

Does anybody know anything?

/r/Python
https://redd.it/12kukhk
Help on selecting the sum of a specific value

category.current = db.session.query(db.func.sum(`db.select`(Expense.amount).filter_by(category_id=category_id).order_by(Expense.amount))).scalar()

so this is a line of code form a program I'm working on to handle suers purchases. This code mostly works and adds the values to the proper database in the end as this is to compile all the purchases and sum them together based on each category. However for some reason when this line of code is executed it only adds one number to the system instead of summing them all, any help would be much appreciated. Thank you

/r/flask
https://redd.it/12kwt4n
Python quiz game to Flask web app

Hello!

So, I created a python quiz game which is currently running all text based with questions asked, alternatives (1-4) presented and a user input (1-4) checking if the answers are correct.

Basically the questions are presented (one at a time) like this:

Who had a hit with 'St. Elmo's Fire (Man In Motion)' in 1985?

1 : The S.O.S. Band
2 : John Parr
3 : Neil Diamond
4 : New Kids On The Block

Please select 1, 2, 3 or 4:

If the answer is correct the user gains a point. If the user gets a certain amount of points new and harder questions will be available.

I would love to create a Flask web app running this concept but with clickable buttons. Something like this:

&#x200B;

https://preview.redd.it/38y6entg3nta1.jpg?width=800&format=pjpg&auto=webp&v=enabled&s=2342cd98da42e71fcca32627285a71b954e1e684

I guess this would require me to use something like Javascript or similar. That is my guess as I am new to this...

So I guess my question is: Would learning javascript be the way to go? Or are there other (better?) options available?

I know Python and

/r/flask
https://redd.it/12kmb2g
Python File manager

Hi, I recently created a post about a file manager in it's early stages, and got some feedback that I should create a GUI so Ive created a GUI version of the file manager using Tkinter and I've left the command line version too. If anyone wanted to check it out and provide feedback on it I would appreciate it 😃. Here is the link to my github repository:

https://github.com/Tristan296/FileManager

/r/Python
https://redd.it/12l99zp
openaipricinglogger: A Python package to easily log your OpenAI API costs and timestamps

Hey everyone! Ive created a Python package called openai_pricing_logger that helps you log OpenAI API costs and timestamps. It's designed to help you keep track of API usage and related costs, providing an easy way to monitor and analyze the expenses.

&#x200B;

GitHub repo: https://github.com/yachty66/openai\_pricing\_logger

Python package: https://pypi.org/project/openai-pricing-logger/0.0.2/

&#x200B;

Key features:

\- Automatically logs API call costs and timestamps

\- Easy integration with OpenAI's GPT-3.5-turbo and GPT-4 models

\- Lightweight and easy to use

&#x200B;

Thought this might be helpful for anyone working with OpenAI's API. Enjoy!

/r/Python
https://redd.it/12lec2s
Is there any API or anything else that can help extract flight information from a ticket?

So far I tried using OCR.Space to feed the image, extract data from the ticket and try to work with it but it’s not so accurate. I was wondering if there are other way of doing so perhaps an API where you enter flight ticket number and gets you all the information or maybe another way?

/r/djangolearning
https://redd.it/12kahgo
Bing AI made up a package that doesn't, but maybe should, exists and even gave examples of how to use it. Read/Write session splitter for sqlalchemy.

I notched today that my skype has a Bing chatbot built into it now, so I thought I'd see what it had to say about what I'm working on.

https://preview.redd.it/jyepb53opqta1.png?width=1030&format=png&auto=webp&v=enabled&s=9c9a2d68dbbd41a7862e21138f275f07128c6348

As far as I could find, there is no package named sqlalchemy-splitter, or even something that works similar to the way they describe it.

https://preview.redd.it/jzbz3ii7qqta1.png?width=1030&format=png&auto=webp&v=enabled&s=54c2b88f97a79516885086864b055ed92a7f893d

It seems pretty sure of itself. After thinking about it though It seems like a package like this would probably have to do a lot of extra work in order to manage both sessions and move objects between them. Maybe its not as difficult as I'm thinking though?

Either way, when I called it out it immediately back peddled.

&#x200B;

https://preview.redd.it/u5ugk60gtqta1.png?width=1026&format=png&auto=webp&v=enabled&s=4c6110cdf68ee3edfbc52db549e2ca4b7d5864fe

/r/Python
https://redd.it/12lcp6j
Do you discriminate your callback functions in any way?

Callbacks are a hot-topic in pretty much any language, but I generally like them.

However, denoting their "special status" as a callback is a bit of a pain in the ass. Some approaches I tried:

* Mentioning it in the docstrings: hard to enforce

* Prefixing the function name (e.g.: cb_myfunction): ugly

* Using a decorator that does nothing: neat idea but a bit messy, feels overkill

My current solution was to create a callbacks package. Now every function that is used as a callback must reside there. It was a great idea until I started getting circular import errors. Also doesn't work for methods used as callbacks.

What about you guys? How do you keep your callbacks sane and organized?

/r/Python
https://redd.it/12lkuq9
R SEEM: Segment Everything Everywhere All at Once

We introduce SEEM that can Segment Everything Everywhere with Multi-modal prompts all at once. SEEM allows users to easily segment an image using prompts of different types including visual prompts (points, marks, boxes, scribbles and image segments) and language prompts (text and audio), etc. It can also work with any combinations of prompts or generalize to custom prompts!

&#x200B;

https://preview.redd.it/8pkzou248rta1.png?width=1265&format=png&auto=webp&v=enabled&s=644f4e560f4e1f40a9cbd19f172af1165bae94d0

Play with the demo on GitHub! https://github.com/UX-Decoder/Segment-Everything-Everywhere-All-At-Once

We emphasize 4 important features of SEEM below.

1. Versatility: work with various types of prompts, for example, clicks, boxes, polygons, scribbles, texts, and referring image;
2. Compositionaliy: deal with any compositions of prompts;
3. Interactivity: interact with user in multi-rounds, thanks to the memory prompt of SEEM to store the session history;
4. Semantic awareness: give a semantic label to any predicted mask;

🔥Click, scribble to mask

With a simple click or stoke from the user, we can generate the masks and the corresponding category labels for it.

&#x200B;

https://preview.redd.it/tymnl8a58rta1.png?width=1732&format=png&auto=webp&v=enabled&s=a2101364cf8b85f9e114f9cae09c1078f38f030b

🔥Text to mask

SEEM can generate the mask with text input from the user, providing multi-modality interaction with human.

&#x200B;

https://preview.redd.it/jh6h3fb68rta1.png?width=1708&format=png&auto=webp&v=enabled&s=44c628544cf6f19bb4844d2aa8eafdb6e7040fe0

🔥Referring image to mask

With a simple click or stroke on the referring image, the model is able to segment the objects with similar semantics on the target images.

&#x200B;

https://preview.redd.it/vgzrp0y78rta1.png?width=1724&format=png&auto=webp&v=enabled&s=8d08dea79b5de287e801932c4d7a9ca5b8647124

SEEM understands the spatial relationship very well. Look at the three

/r/MachineLearning
https://redd.it/12lf2l3
SQLalchemy question

Say for instance I have two classes. A User and Sport class. They are defined as below:

class User(UserMixin, db.Model):
__tablename__ = "users"

id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(32), index=True, unique=True)

sport_id = db.Column(db.Integer, db.ForeignKey("sports.id"))
attended_sport = db.Column(db.Boolean, default=False)




class Sport(db.Model):
__tablename__ = "sports"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(32))
users = db.relationship("User", backref="sport")
nominal_submitted = db.Column(db.Boolean)



To track the students I have two nominal rolls. One to track the students (let's say by their classrooms) and one for the sports teacher to submit once they have conducted their sport. If the sports nominal roll is submitted, I want the classroom tracker to say if the user attended or not. If the nominal roll is not submitted, I want the tracker to say 'Nominal not submitted'. What would be the best way of going about doing this?

Is there a query I can use - a left join perhaps to capture this query?

/r/flask
https://redd.it/12lrym2
How to assign a function to a field in models.py

So im making a model for the admin page, there is a field

url = models.CharField(maxlength=255, unique=True, verbosename="Download")

in models.py that i want to call a function download_file for downloading a .txt file when clicked on.

How do I assign a function to the field(the url field shows the url while in admins page)? Thanks!

/r/django
https://redd.it/12lu4s1
Pulling Last 3 Comments from database

I am trying to query my database and pull the last (3) comments from the database and am running into some issues.

Models.py

class Comment(models.Model):
post = models.ForeignKey(Post, relatedname="comments",ondelete=models.CASCADE)
name = models.ForeignKey(User, ondelete=models.CASCADE)
body = RichTextUploadingField(blank=True, null=True)
date
added = models.DateTimeField(default=timezone.now)

def str(self):
return '%s - %s' % (self.post.title, self.name)

views.py

def base(request):
lastthreecomments = Comment.objects.orderby('-dateadded'):3
context = {
'lastthreecomments' : lastthreecomments
}
return render(request, 'blog/base.html', context)

base.html

{% for comment in lastthreecomments %}
<li>{{ comment.body}}</li>


/r/djangolearning
https://redd.it/12linbg