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
How to share my REST API?

Hi.

I'm new to REST API and I just created some API for my blog but I want share it with someone to work with in front side with react.

How Can I share it? because if I give him the project It's wrong surly. cause he should Install python django pipenv and so on. There must be a way.

/r/django
https://redd.it/az0r8x
Python looping through multiple receipts of users, and printing the output content with printer?

How can i do that with django and python.

I found printd library and its printURL function but it does not work in a good way. I looking a new solution for me. I tried to make a loop and use this function.

Printd library : [https://github.com/joseluisq/printd](https://github.com/joseluisq/printd)

​

I have a system where users pay their debts. And i need to print receipts of users. At the end of the month, i will send them their receipts.

/r/django
https://redd.it/az16nd
I teach Python in realtime, using Live YT / FB Live and a Chrome extension. I'll expand to reddit if this post gains interest.

Hi r/python,

Redditor of 10+ years here.

I've started teaching live & realtime, using Youtube Live & Facebook Live, and an extension-based IDE.

The group sessions are lots of fun. You can find one [here](https://www.facebook.com/codebasetech/videos/400550887157128).

So far I'm on meetup.com, and Facebook. Reddit is my next big step (please be nice to me, i've invested a lot of my time and effort into this).

I do have paying members, but am putting out content for free, and am not entirely decided on whether to be a paying service or a free service (only been up since November).

You can either join us on Codebase for a live Python session at 7pm London time this Sunday: [https://fb.com/codebasetech](https://fb.com/codebasetech) or if this post gains enough traction, i'll see if i can embed a live video in reddit, so we can have live sessions either in this sub, or in /r/codebase.

Would love to hear your thoughts.

Thanks,

cpplinuxdude


/r/Python
https://redd.it/az3ikn
Python Code Generation Tools

What do you guys use to generate Python code? I saw that a lot of people just use Jinja2 with some templates, which looks simple and powerful. You still have to generate the environments and write the templates. Now I'm looking around whether someone already did the work of generalizing that step (thinking about fields in classes, inheritance, constructors etc. and how to map that data to the environment) or whether I have to do it myself.

TLDR: Are there simple but powerful Python code generation "frameworks"?

EDIT:

* I found [pymultigen](https://pypi.org/project/pymultigen/). Seems like it helps with creating code in multiple files.
* Looks like [pyecoregen](https://github.com/pyecore/pyecoregen) is a specialized multi-file code generator based on pymultigen.

/r/Python
https://redd.it/az4mce
Real-world, practical business uses for Python?

There is a lot of information online and how and why to use Python, but I have found very little information about practical, specific business uses. How do you use Python to make your life easier at work, or to make money on the side?

I have spent several months learning the R programming language, and I have hit a point where I am questioning how practical it is. Truthfully, I can do 99% of what I can do in R using Microsoft Excel - without spending 15 minutes adjusting tick marks on a bar chart.

I am strongly considering switching to Python. I hear so much about its ease of use and many appplications. I just can't find much about specific problems that it can be used to solve.

/r/Python
https://redd.it/az6nic
What framework to use to build a MOOC website ?

Hi !

As the title says, I need to build a MOOCs website (website that presents a series of online video courses). I know some django, I use it for simple websites, I thought I could built it using simply Django, but then I saw the python-based CMS (mezzanine, django-cms ...etc ) but I'm not sure if I should use them.

​

My project should include :

\- Courses : each course has a number of pages, each page contains either a video or some notes.

\- playlists : a way to play all videos in one course in a row

\- Editing capabilities for "old school" teachers who have no idea what programming is

\- Commenting ! students should be able to have their own accounts and courses follow ups.

\- And some kind of a discussion forum for students to ask questions and get answered by other students or the teachers

​

I took few hours reading about some solutions, and I think Django-CMS could be great for this.

What do you guys think about it ? do you have any experience with different python-CMSs ?
Thanks a lot !


/r/django
https://redd.it/az2c63
Not trusted when using remote jupiter notebook

Hi,

I am using jupiter notebook remotely using my universities remote computer system. This was all working fine but now when I login with my token and try to work on the files they are read only. There is also a message saying they are 'not trusted'. Any advice on how to fix this?

I have tried to use the 'jupyter trust notebook.iymb' command but I get a

​

\> Error executing Jupyter command 'trust': \[Errno 2\] No such file or directory

​

error message. Thanks for the help!

/r/IPython
https://redd.it/az61yk
Problem with trailing slashes ("/") while building a website using Frozen Flask

I'm using Flask & Frozen Flask to generate a website, though for some reason the trailing "/" it uses to get the reference to the stylesheet as well as other images seem to break the website from being able to retrieve it.

I'm using `url_for('static', filename='style.css')` within the jinja templates to retrieve the file path.

This generates the URL: `/static/style.css`

This works perfectly fine while the server is running, though after freezing the website using Frozen Flask, Chrome & Firefox both have issues loading the required files, and the stylesheet nor the images load at all.

After removing the trailing slash within the URLs using Inspect Element, the frozen website is able to load the files just fine: `static/style.css`

Does anyone know a way to remove the trailing slash while freezing with Frozen Flask, or at least can enlighten me on why this problem is happening?

Thanks.

/r/flask
https://redd.it/az8wu7
[D] The Promise of Hierarchical Reinforcement Learning

PhD student Yannis Flet-Berliac gives a comprehensive overview of the latest in Hierarchical Reinforcement Learning. [https://thegradient.pub/the-promise-of-hierarchical-reinforcement-learning/](https://thegradient.pub/the-promise-of-hierarchical-reinforcement-learning/)

/r/MachineLearning
https://redd.it/az7pi9
Blog Post: React with Django (Part 1)

Hello!

I put up a new blog post that talks about integrating React and Django.

[https://www.codexplore.io/blog/integrating-react-and-django/](https://www.codexplore.io/blog/integrating-react-and-django/)

I am also interested in hearing how you all integrate the two.

/r/django
https://redd.it/az8nil
I wrote a proof of concept pastejacker which replaces semicolon with Greek Question Mark as soon as any text is copied to clipboard. GitHub - aydwi/chaos

Hi

A few months back, I read about a malicious [clipboard hijacker discovered in PyPi](https://medium.com/@bertusk/cryptocurrency-clipboard-hijacker-discovered-in-pypi-repository-b66b8a534a8), and decided to write a tool that demonstrates how easy it is for a rogue program to mess with your system clipboard without you knowing.

To make things interesting, I built this tool around the [classic idea](https://twitter.com/peterritchie/status/534011965132120064) of replacing semicolon with a similar looking unicode character "Greek Question Mark", so that many, if not all compilers will throw cryptic error messages when such (modified) code is compiled. I've named this monstrosity `chaos`.

-------------------------------------------------------------

##### Repository: https://github.com/aydwi/chaos

--------------------------------------------------------------

Once executed, `chaos` runs as a silent daemon process and monitors the operating system clipboard. Once a change is detected, it reads, modifies and rewrites the clipboard data while preserving formatting and making sure it only ever touches textual data. So, **you copy something, but you paste something else**, without any indication of what happened.

Implementation wise, I decided to use [Qt](https://www.qt.io/) to write this, particularly because it's [QClipboard](https://doc.qt.io/qt-5/qclipboard.html) class is way more powerful that anything else I could find, and it has widely used Python bindings ([PyQt](https://riverbankcomputing.com/software/pyqt/intro)) available.

Find more details on the GitHub repo. Check it out and let me know what do you think. I'd be glad if you decide to take a

/r/Python
https://redd.it/az8m1m
Keep only the ​last day of the month in the list of dates and filter all other dates in multiple year lists​.

Lets say I have a list of all the dates in the year 2016 and 2017. Now I want to find out the last dates of months from those list of dates and remove all others.
What would be a best way to achieve this?

/r/django
https://redd.it/az6d6p
[D] Undergrad student: better to focus on one area (e.g. NLP) or diversify?

As an undergrad student interested in ML and with some experience in NLP, should I continue focusing on this area in my future projects and research positions? Or would it be better to diversify and seek out some projects or research involving things like computer vision? One reason I am wondering is because a lot of companies are working with computer vision in areas such as robotics and self driving vehicles so I am wondering if it would lead to better job prospects in the future. Also, which would likely be more useful for grad school (which is my main goal at the moment)?

/r/MachineLearning
https://redd.it/aza3nv
How to update value on associate table in many to many relationship?

I have a follow model, but I don't know how to update value rating (I want user can rate the story), can I update rating value with this or I must re-declare my user\_story using class?

class Story(db.Model):
id = db.Column(db.Integer, primary_key=True)
users = db.relationship(
'User',
secondary=user_story,
lazy='subquery',
backref=db.backref('stories', lazy=True)
)

class User(db.Model):
id = db.Column(db.Integer, primary_key=True)

user_story = db.Table('user_story',
db.Column('user_id', db.Integer, db.ForeignKey('user.id'), primary_key=True),
db.Column('story_id', db.Integer, db.ForeignKey('story.id'), primary_key=True),

db.Column('rating', db.Integer)
)

​

/r/flask
https://redd.it/azc43h