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
IPython terminal would display a string with \n in the same line, how to change this behavior?

given a snippet in IPython terminal

s = 'AAA\nBBB'
s

it would give 'AAA\nBBB' as output.

I have to call print(s) to get

AAA
BBB

Is there some config to make IPython's display to show the \n in a string as linebreak?

/r/IPython
https://redd.it/y6ce9p
P Awesome Image Segmentation Project Based on Deep Learning (5.6k star)

Hi, I'd like to introduce PaddleSeg, which provides the ability of designing, training and deploying segmentation models.

This might be some help to you. Hope you enjoy it.

Code and docs: https://github.com/PaddlePaddle/PaddleSeg

Features Set:

Support several tasks: Semantic Segmentation, Interactive Segmentation, Panoptic Segmentation, Image Matting, etc.
Provide 40+ state-of-art semantic segmentation models and 140+ high-quality pre-training models
Provide efficient interactive segmentation tool (EISeg) for annotating segmentation images
Release a variety of human matting and portrait segmentation models for practical application without training
Support 3D medical image segmentation
etc

https://i.redd.it/pi0pjee2ncu91.gif

https://i.redd.it/7cuiqre3ncu91.gif

/r/MachineLearning
https://redd.it/y68dzn
Jupyter Notebooks on EC2 Windows Instance

I have googled this for a good hour now and can't find any mention of running Jupyter Notebooks on an EC2 Windows Instance - specifically running Jupyter after remote-ing into the machine.

1 - Is this possible?
2a - If not - why not?
2a - If not - what is an alternative notebook that will work on an EC2 Windows Instance?
3 - If so, any one know of a guide to get it up and running somewhere?

Thanks in Advance.

/r/JupyterNotebooks
https://redd.it/vn4ajp
Auto import for VSCode

How to make possible auto imports from Django Rest Framework in VSCode.

I have Pylance extension but it doesn't work

/r/django
https://redd.it/y6gsic
Text Corpus Tagging System

I have a feature idea for an app I'm helping develop, and I'm wondering if it makes sense before I go too deep down the rabbit hole.

I want to find a way for a front-end user to edit a large text document and add a custom ID tag to a certain section of text of arbitrary length. My initial idea is to store the text as HTML and use a WYSIWYG editor with most of the functionality disabled, and just leave the ability to highlight a range of text and choose an ID attribute from a pre-defined list to add to a <span> tag or something like that. Would that work? If so, any recommendations on a WYSIWYG editor that would work well with this? Or is there a better way to accomplish this?

/r/django
https://redd.it/y6q5bd
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/y6qyo5
SSL certificate

My django app on an EC2 instance works fine with http://IP.address. I also used Route 53 to link up with a domain and now http://domain.com works

But why does https://domain.com not work? The domain had been previously linked with an SSL certificate. HTTPS is allowed on my EC2s security group. Do I need another SSL ?

/r/django
https://redd.it/y6xanb
PYTHON CHARTS: the Python data visualization site with more than 500 different charts with reproducible code and color tools

Link: https://python-charts.com/
Link (spanish version): https://python-charts.com/es/


This site provides tutorials divided into chart types and graphic libraries:

https://preview.redd.it/6yk59rxp8eu91.png?width=748&format=png&auto=webp&s=0581694dcacd8d7e9e7909b2c13dd0b76f7bd64c

&#x200B;

The graphs can be filtered based on the library or chart type:

&#x200B;

https://preview.redd.it/dyo2btgz8eu91.png?width=1058&format=png&auto=webp&s=a22b43408411950c2351367a96e871279f368acc

&#x200B;

Each post contains detailed instructions about how to create and customize each chart. All the examples provide reproducible code and can be copied with a single click:

https://preview.redd.it/d681tn319eu91.png?width=1553&format=png&auto=webp&s=05fd21d7a896082753c55cec461df67460ee07fb

&#x200B;

The site also provides a color tool which allows copying the named, colors or its HEX reference:


&#x200B;

https://preview.redd.it/ptwelwb99eu91.png?width=1299&format=png&auto=webp&s=54bc17e012790a55d62604f1d8a5fcb6565ab381


There is also a quick search feature which allows looking for charts:


&#x200B;

https://preview.redd.it/gpoz93wd9eu91.png?width=1013&format=png&auto=webp&s=fa3af72c6b2ef43444278e74032a0ebae3d9c143


Hope you like it!

/r/Python
https://redd.it/y6fumv
Why is X not defined?

import numpy as np

&#x200B;

a = float(input("oppgi nedre grense, a, på intervallet:"))

b = float(input("oppgi øvre grense, b, på intervallet"))

n = int(input("oppgi ønsket antall partisjoner (delintervaller) (Husk partall):"))

ant_des = int(input("oppgi ønsket antall desimalet i svaret:"))

&#x200B;

h = (b-a)/n

&#x200B;

\#simpsons metode

x_vektor = np.linspace (a,b,n+1)

y_vektor = 1/ 1 + x**6



&#x200B;

vekt = np.ones(len(x_vektor))

for i in range (1,n):

if i % 2 == 0:

vekt [i\] = 2

else:

vekt [i\] = 4

&#x200B;

print ("Komponenten vektes etter flg system", vekt)

&#x200B;

skalarprodukt = y_vektor * vekt

Sum= skalarprodukt * h/3

print (round(sum,ant_des))

&#x200B;

I dont understand why this code dosent work. its a code thats suppose to give you the numbers to simpsons methode in math

/r/JupyterNotebooks
https://redd.it/y77txv
Real life examples of complex applications

Are there some good examples of real applications (not hello world todo/blog post or tutorials) of Flask applications, from where a new flask user could learn best practices from?

Flask doesn't force any design patterns or specific ways to do anything on me, and that leaves me wondering about what are the best ways to do something. How do I split up the routes file from all-routes-in-a-file.py to something more manageable, how do I validate input requests coming from a JS front-end, what are the best practices for doing thing X and Y, that I haven't even thought about yet.

Background information: I am writing a back-end api for a Vue frontend, there are no templates in the flask app, I am using JWT for authentication already. I think I don't need blueprints, because I don't have any templates to separate from the other things. I just don't want to bunch all my routes together in a huge file, like.. all the examples on the internet do.

I have found some open-source flask examples, but they seemed to be doing something weird, or.. were really outdated.

Or should I just write my back-end in Java and Spring, since that is used at work,

/r/flask
https://redd.it/y7hkgo
Can i host my django app under 10$?

So i am trying to create a project for my portfolio and it will be a simple blog application and i want to know if i will be able to host it under 10$ a month if only me and maybe 5-10 of my friends will visit it(not daily maybe once or twice a week).

English is not my first language so sorry if i did not express my thoughts clearly.

/r/django
https://redd.it/y7lmtd
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 where you stand a better chance of receiving a response.

/r/Python
https://redd.it/y7n3gz
Django + async: delete from DB

Django version 4.1.2

I just used the following code snippet:
r = await mymodel.objects.aget(some_name=myname)
await r.adelete()

This fails with: "AttributeError: 'mymodel' object has no attribute 'adelete'

But this does work though:

r = await mymodel.objects.aget(some_name=myname)
await sync_to_async(r.delete)()


Any fix for this?

/r/django
https://redd.it/y7w5dm
Call for questions for Guido van Rossum from Lex Fridman

Hi, my name is Lex Fridman. I host a podcast and I've previously interviewed Guido van Rossum (4 years ago). I'm talking to him again soon and would like to hear if you have questions/topic suggestions, including technical and philosophical ones, on Python or programming in general.

/r/Python
https://redd.it/y7q4gv
django creating new record when update existing record

this is a strange issue, and cant trace it.whenver i am updating a field in my existing record django creats another new record with updated value. what could be the reason?below is my edit view

@cachecontrol(nocache=True, mustrevalidate=True,nostore=True)
@loginrequired(loginurl="login")
def edittonerdetailssave(request):
if request.method == "POST":
tonerdetailsid = request.POST.get("tonerdetailsid")

employeename = request.POST.get("employeename")
employeedesignation = request.POST.get("employeedesignation")

status = request.POST.get("status")

# issuedtoid = request.POST.get("issuedto")
# issued
to = Prosecutions.objects.get(id=issuedtoid)

tonermodelid = request.POST.get("tonermodel")
toner
model = Toners.objects.get(id=tonermodelid)



/r/django
https://redd.it/y86jjd
Choosing between options for presenting Plotly figures on a website (Python/Jupyter)

I'm looking to share some of my charts (Plotly) (on a Github webpage first and later on, on a personal website - not the notebooks, but the charts by themselves. I have spent a lot of time and found it surprisingly difficult to get started, and would very much like some input.

The options that I see would be the most relevant are:

1. Export from Jupyter Notebooks/labs to HTML - limited interactivity?
2. Dash
3. Panel/HvPlot

I have started out following a YouTube tutorial on option 3. This didn't present a way to actually show the plots on a website. For this option, the order of operations seems to be:

Python/Pandas -> Make plotly figures and interactive dataframes -> use HvPlot -> Use Panel (or similar) -> host this in Heroku/MyBinder/similar.

Am I on the right track here?

/r/JupyterNotebooks
https://redd.it/vlohr8
django creating new record when update existing record

this is a strange issue, and cant trace it.whenver i am updating a field in my existing record django creats another new record with updated value. what could be the reason?below is my edit view

@cachecontrol(nocache=True, mustrevalidate=True,nostore=True)
@loginrequired(loginurl="login")
def edittonerdetailssave(request):
if request.method == "POST":
tonerdetailsid = request.POST.get("tonerdetailsid")

employeename = request.POST.get("employeename")
employeedesignation = request.POST.get("employeedesignation")

status = request.POST.get("status")

# issuedtoid = request.POST.get("issuedto")
# issued
to = Prosecutions.objects.get(id=issuedtoid)

tonermodelid = request.POST.get("tonermodel")
toner
model = Toners.objects.get(id=tonermodelid)


/r/djangolearning
https://redd.it/y86gkt