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
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" which provides a list of projects and the code to make them work.

/r/Python
https://redd.it/y5vw8a
Unable to add web scraper

If anyone is able to help thatd be great. Im learning web scraping for a data analytics class and when importing this code:

from splinter import Browser

from bs4 import BeautifulSoup as soup

from webdriver_manager.chrome import ChromeDriverManager

executable_path = {'executable_path': ChromeDriverManager().install()}

browser = Browser('chrome', **executable_path, headless=False)

i get this error:

TypeError Traceback (most recent call last) \~\\AppData\\Local\\Temp\\ipykernel_35972\\2830222817.py in <module> 1 executable_path = {'executable_path': ChromeDriverManager().install()} ----> 2 browser = Browser('chrome', **executable_path, headless=False) \~\\anaconda3\\envs\\PythonData\\lib\\site-packages\\splinter\\browser.py in Browser(driver_name, retry_count, *args, **kwargs) 119 raise DriverNotFoundError("No driver for %s" % driver_name) 120 --> 121 return get_driver(driver, retry_count=retry_count, *args, **kwargs) \~\\anaconda3\\envs\\PythonData\\lib\\site-packages\\splinter\\browser.py in get_driver(driver, retry_count, *args, **kwargs) 90 for _ in range(retry_count): 91 try: ---> 92 return driver(*args, **kwargs) 93 except driver_exceptions as e: 94 err = e TypeError: 'NoneType' object is not

/r/JupyterNotebooks
https://redd.it/vq5loq
Puff - Python GraphQL engine and WSGI Runtime - Use Django on Rust's Tokio

Hello,

I wanted to share with you my recent experiment for Django, Puff: https://github.com/hansonkd/puff

The idea for the project is that there are an incredible amount of Django resources and developers out there and that Django makes it so easy to get an app running that it should be used as the primary developer layer for managing DB tables, Admin, Auth, etc.

But understanding Python performance means understanding the GIL. For parts of your code that are performance critical, as much work should be handed off to Rust as possible to avoid locking the GIL If you are constructing a response with thousands of rows, it doesn't make sense to iterate through that in Python creating a python dictionary only to convert it to JSON. This holds the GIL in the least effective way.

Puff is designed to allow you to pass off Python Objects to Rust to take advantage of Rust's async runtime. For example, in Puff's GraphQL engine you can hand off pure SQL strings from Python to be executed entirely in Rust, transformed to JSON bytes, and sent as an HTTP response without locking the GIL again.

You can write your own Rust functions that use any Rust library. Even when you

/r/django
https://redd.it/y5to33
jupyter_nbextensions_configurator - error messages in JupyterLab startup

Any info on how to make these error messages go away?

*(I posted this same question into* r/JupyterLab *a couple of days back, but have not got any responses so far. I presume this* r/JupyterNotebooks *Subreddit can also consider JupyterLab questions).*

TBH not serious in that I am not aware of any components not actually working - but I prefer not to have nuisance errors in logfiles, lest they obscure items of real concern.

There are various lines in the JupyterLab server startup log relating to the configuration of jupyter\_nbextensions\_configurator - with the last one indicating that it failed to load. Console log below.

Versions of components in use listed below - as far as I know they are up to date (with Python 3.10.5). I have tried deleting and re-adding components with conda. Does not improve things.

Any info on....

\* what this failure to load actually implies (I am not aware of anything not working)

\* how to make this error message go away

thanks

\-----------------------------------------------------------------

Starting up Jupyter - first it suggests moving the extension...

[I 2022-06-28 11:56:49.588 ServerApp] jupyter_nbextensions_configurator | extension was found and enabled by notebook_shim. Consider moving the extension to Jupyter Server's extension paths.

But manages to link it ok



/r/JupyterNotebooks
https://redd.it/vo4f6i
Dynamically update periodic tasks in Celery and Django

I'm working on uptime monitoring web app (with Django, of course). It is a simple web app that pings the server and sends an email when the server is down. During the development, I need dynamic periodic tasks in Celery. My use case was:

- user adds server for monitoring with time interval - she creates a new periodic task,

- user changes the interval or pause monitoring - she updates the periodic task,

- user deletes the monitor - she deletes the periodic tasks.


I was looking for a nice way to manipulate periodic tasks in Celery. I found an amazing `django-celery-beat` package that provides PeriodicTask database objects. With PeriodicTask objects, you can dynamically add/remove/update periodic tasks in Celery. I want to share my approach. I've created an example GitHub repository and wrote step-by-step article.


What is your approach for dynamic periodic tasks in Celery and Django?

/r/django
https://redd.it/y6bvtx
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