pythondaily | Education

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

Subscribe to a channel

Python Daily

I updated my script that allows you to store any file in an image. Now you don't need the original image to extract the file!

# Link to the repo

This 1.7MP image contains an encrypted 0.93MB .zip file and its filename stored as noise.

https://preview.redd.it/m0budolml5y91.png?width=1520&format=png&auto=webp&s=d626b98e2a02a97edcc5d2c6e84fdfe4088bde36

/r/Python
https://redd.it/ymxrvl

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

Python Daily

Sunday Daily Thread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/ynawx5

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

Python Daily

I wrote a script to periodically change my Desktop background to live satellite images!

Supports EVERY publicly available earthbound satellite as well as some solar ones.

https://github.com/lennart-rth/Live-Earth-Wallpapers

/r/Python
https://redd.it/ymtija

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

Python Daily

Saturday Daily Thread: Resource Request and Sharing! Daily Thread

Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?

Use this thread to chat about and share Python resources!

/r/Python
https://redd.it/ymejxk

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

Python Daily

P Learn diffusion models with Hugging Face course 🧨

Hi there, it's Lewis here from the open-source team at Hugging Face 👋

Since the release of Dalle-Mini and Stable Diffusion a few months ago, you may have seen your timelines filled with impressive text-generated images like the one below:

Image generated with textual inversion and Stable Diffusion

These images are generated by an exciting branch of research called diffusion models, which is rapidly being applied to generate novel structures in computer vision, audio, and even molecular biology 🤯!

To help the community get up to speed on this fast-moving field, we've joined forces with the awesome Jonathan Whitaker to launch a free course on all aspects of diffusion models 🔥

In this course, you will:

👩‍🎓 Study the theory behind diffusion models
🧨 Learn how to generate images and audio with the popular 🤗 Diffusers library
🏋️‍♂️ Train your own diffusion models from scratch
📻 Fine-tune existing diffusion models on new datasets
🗺 Explore conditional generation and guidance
🧑‍🔬 Create your own custom diffusion model pipelines

The course will be released in a few weeks and you can register via the signup form here: https://huggingface.us17.list-manage.com/subscribe?u=7f57e683fa28b51bfc493d048&id=ef963b4162

Looking forward to meeting you all in the course 🤗!

/r/MachineLearning
https://redd.it/ylz2wh

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

Python Daily

Updating a Django 1. project in production

Hi all, I’ve been using Django for a while now, but I now have the task at work of updating a production Django 1.
project to Django 4. I’ve been able to fix the majority of the bugs, but the biggest hurdle is dealing with the database. This thing has a couple of models with millions of rows each and it was made before migrations were a thing in Django.

Do any of you have any experience in dealing with this type of thing with minimum downtime? How did you approach it?

/r/django
https://redd.it/ylspdz

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

Python Daily

Methods for dynamically loading test db data

I'm looking for a more efficient way to quickly and dynamically load data into sqlite (in memory) for my testing. I came across Flask-Fixtures but the project hasn't been updated in a few years and has several deprecation warnings for SQLAlchemy and Flask APIs.

I started writing my own `Loader` class which parses some JSON files into memory, but I'm fighting app context errors when using application factories.

Are there other libraries or frameworks which make loading test data easier that you use? Any tips would be great.

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

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

Python Daily

Ploomber Cloud - Parametrizing and running notebooks in the cloud in parallel

Hi r/IPython!

I want to share what we've been working on at Ploomber, and we're releasing today!

We started with an open-source framework to help data practitioners make their work reproducible. However, after months of building and learning from our community, we realized that many needed help with the setup: getting Python installed, getting dependencies, running experiments locally, etc.

So we decided to work on a complementary cloud product to solve these issues. Ploomber Cloud (there is a free tier!) allows you to parametrize a notebook and spins up parallel jobs without configuring infrastructure. It works like this:

1. Add a cell at the top of your notebook with the parameters you want
2. Submit the notebook from the command-line interface
3. We parse your notebook's content to get the packages you need and create a Docker image
4. We push the Docker image and spin instances to run your jobs in parallel (one per each parameter combination)
5. We upload the results to cloud storage so you can review them later

We've seen our community use it for a wide range of applications. Here are the most common use cases:

1. Fit computationally intensive models (e.g., Bayesian modeling, time series forecasting)
2. Tune hyperparameters (i.e., spin up 100 jobs to

/r/IPython
https://redd.it/yl5hpx

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

Python Daily

How to install and deploy OpenAI Whisper with Python

Hello,

If you are interested in automatic speech recognition (speech-to-text), you are most likely going to try OpenAI Whisper.

If that's the case, here is an article I just made about how to install and deploy Whisper with Python: https://nlpcloud.com/how-to-install-and-deploy-whisper-the-best-open-source-alternative-to-google-speech-to-text.html

I hope it will be useful!

Julien

/r/Python
https://redd.it/yl3813

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

Python Daily

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

Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!

This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.

/r/Python
https://redd.it/ykmhax

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

Python Daily

how the fuck do you disable auto complete on tab press

I don't know what the fuck I pressed but I was formatting my code and now all of a sudden TAB doesn't work as a spacer but instead pulls down an autocomplete menu and it's fucking annoying
How do I turn it off

/r/JupyterNotebooks
https://redd.it/yjov4s

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

Python Daily

Sending files from Flask to React Frontend



I am creating a reactjs (frontend) and flask server (Backend) and I am experiencing some issues with sending files from flask to react.

My application work this way:

1. On Page 1, I upload files from react js to flask (followed a tutorial on this) upon cllicking the 'upload' button
2. Clicking the 'upload' button will call a function from the flask server to process the file and the return value should be a pdf file.
3. Upon clicking to Page 2, the processed file will then displayed on my pdf viewer on page 2. So I would require the returned file from function called in Page 1 to be viewed when i click Next page to Page 2, the pdf viewer.

However, I am having troubles with the flow. I am now sure how I can return a file in the function in flask on the upload function called in page 1, which will be shown on my frontend only when I click to page 2. I have been very unsuccessful at all my attempts...

I tried to redirect to another function which returns a send_file function to a different app route but this does not work at all. I have also looked at

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

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

Python Daily

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/yjpo00

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

Python Daily

Flask App works on development server but not on IIS running on 2008r2


I have a flask app that runs some API calls to a meraki cloud environment. The app runs perfectly using flasks built in development server on the 2008 r2 server. I have the server running using IIS and fastcgi.

The site will come up via my URL and the site looks like it works. As soon as I click the button to trigger the api calls in the app I immediately get “Internal Server Error, The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.” I am confused because the flask app runs the api calls fine on the same machine, in the same folder location using flasks built in server but not using IIS. Which leads me to believe the code works. The IIS logs I know of do not show any more info. I am thinking I must have missed something for deployment. I have already thought of trying a different hosting method but I need to use this specific machine and I need ad integrated authentication which is very easy in IIS, it seems there isn’t many options.

Anyone experience something

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

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

Python Daily

Run waitress in background on windows server.

Can someone point me in the right direction to run waitress without a console on a windows server?

This project is for a manufacturing production environment. The server is on the network of application that is calling the HTTP request so there is no security concerns. Currently I'm running waitress-serve from the command line to get the flask application to work. I'm able to send request and get data, which I'm very excited about getting this far, but now I want to run it without the console and without me being logged in. What is the best way to do this?

Thanks.

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

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

Python Daily

2,000 free sign ups available for the "Automate the Boring Stuff with Python" online course. (Nov 2022)

UPDATE: The codes are used up. You can still watch the first 15 videos on YouTube). You can also go to the course page and click "Expand All Sections" and click the "Preview" link for each video to watch them on the site.

If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):

~~https:// udemy. com/course/automate/?couponCode=NOV2022FREE~~

~~https:// udemy. com/course/automate/?couponCode=NOV2022FREE2~~

Udemy has changed their promo code and severely limited the number of sign ups I can provide each month, so only sign up if you are reasonably certain you can eventually finish the course. The first 15 of the course's 50 videos are free on YouTube if you want to preview them.

YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.

Instead of having unlimited free sign ups for 6 days

/r/Python
https://redd.it/yn13m2

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

Python Daily

Help! Can't get Flask to detect packages

Hi, bit of a newbie here, trying to get my first Flask project up and running. I've got hello world down, now I've written a small project, which uses a couple of packages like dateutil and pytz. I got the packages installed in a virtual environment, and if I write a non-Flask script it runs just fine.

But if I try and do flask run then I get for example

ModuleNotFoundError: No module named 'pytz'


It's almost like flask isn't running in the venv or something? Does anyone know what I've done wrong and how to fix it?

A super-quick example:

hello.py:

from flask import Flask
import pytz
print(pytz.timezone('UTC')) #stupid but just to show things work
app = Flask(__name__)

@app.route("/")

def hello_world():
return "<p>Hello, World!</p>"

Then I run:

venv\Scripts\activate
python hello.py
#prints "UTC" as expected

set FLASK_APP=hello
set FLASK_ENV=development
flask run
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.


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

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

Python Daily

Do you follow the official DRF layout?

Maybe a weird question as I most likely should follow the official documentation, but I have made already one simple project following Django's standard layout where every app sits alongside <yourprojectname> directory containing urls.py, seetings.py etc. instead of being installed inside that <yourprojectname> directory as recommended by the official DRF quickstart guide and I didn't came across any problem. So what's the standard?

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

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

Python Daily

D ICLR 2023 reviews are out. How was your experience ?

Link: https://openreview.net/group?id=ICLR.cc/2023/Conference

A thread for ICLR '23 review related discussion.

1. What's your score?
2. Are you satisfied?
3. Other comments about the review process?

/r/MachineLearning
https://redd.it/ymctqy

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

Python Daily

Pydantic 2 rewritten in Rust was merged
https://github.com/pydantic/pydantic/pull/4516

/r/Python
https://redd.it/yleubq

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

Python Daily

DALL·E 2 now available as public API for Python!

[DALL·E 2\] is now available as API for Python. Check out this project.

Create images from the command line: https://github.com/alxschwrz/dalle2\_python

https://openai.com/blog/dall-e-api-now-available-in-public-beta/

/r/Python
https://redd.it/ylp60v

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

Python Daily

Opinion needed: react or vue as front end framework with Django?

Hi,

I'm thinking about using either react or vue as a front end framework. I'm just wanting to know peoples opinion about using either with Django or any experience they've had with it. Also do you use the client-side routing that is available in both frameworks? What's the advantage of using a front end framework over just straight HTML/CSS with bootstrap? Thanks

/r/django
https://redd.it/yld8mz

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

Python Daily

How can I select multiple dates on Django admin or wagtail admin and store them in the database.


class EventsModel(Page):
locationchoices = [
        ('A','Name1'),
        ('B','Name2l'),
        ('C', 'Name3')
        ]
eventName = models.CharField(max
length=500)
Location = models.CharField(maxlength=1, choices=locationchoices, default='A')
time = models.TimeField()
# below I want to store list of selected dates
date = models.DateField()

contentpanels = Page.contentpanels + FieldPanel('eventName'),
              FieldPanel('Location'),
              FieldPanel('time'),
              FieldPanel('date'),

/r/django
https://redd.it/yl58m1

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

Python Daily

Jupyter Notebook + Excel + Github Copilot

/r/JupyterNotebooks
https://redd.it/ykkks1

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

Python Daily

Should I code directly on my linux server or should I use an editor on my computer ?

I always run into problems when I want to deploy my webpage and I am so fed up with this. Now I deployed my page first and plan to code everything on my server. This way my database, apache2 etc. is already working and I do not need to worry about this later. Does anyone has experience with this approach and what do you think ? Thanks

/r/django
https://redd.it/yk84kd

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

Python Daily

I built a simple Airbnb scraper to analyze cleaning fees so you don't have to. Nothing fancy. Hopefully, it's useful.
https://deepnote.com/workspace/datafantic-3bd1a992-4cfb-4c56-aaaf-931ce087ce8c/project/2022-10-21-Whats-up-with-Airbnb-fees-3a09bbfb-7f5f-46b3-8fa0-788f71b2887f/notebook/01%20-%20Data%20Collection-6e5070b071084882953fadbc939609f3

/r/Python
https://redd.it/yjw3ji

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

Python Daily

Django & Stripe Ecomm (Updated) - MIT / Products pulled from Stripe / Image Upload / Better UX
https://www.youtube.com/watch?v=7U9qRKR-src

/r/django
https://redd.it/yk0g3n

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

Python Daily

Confused about 400 Bad Request for POST endpoint

Hello

I am trying to process a simple POST request on my Flask server.

flaskapp.py :

from flask import Flask, request

app = Flask(name)

@app.route("/")
def hello():
return "Welcome to Flask Application!"

@app.route('/webhook', methods='POST')
def webhook():
if request.method == 'POST':
print("Data received from Webhook is: ", request.json)
return "Webhook received!"

if name == "main":
app.run(host='0.0.0.0')

My root endpoint works fine as shown in the screenshot below, but my POST endpoint is returning a 400 Bad Request. This is confusing to me since it seems like it's all been formatted correctly. Does anyone see an obvious issue here? thanks.

&#x200B;

https://preview.redd.it/8w99ryl376x91.png?width=2174&amp;format=png&amp;auto=webp&amp;s=692c9816f663833a0a8909229234acea15da5e61

https://preview.redd.it/j0rse1m376x91.png?width=2174&amp;format=png&amp;auto=webp&amp;s=5e463a269de2aa72a0eba29ff896aebf69920f13

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

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

Python Daily

Anybody out there willing to spend some one on one time with a newbie?

I am currently working on my first website, and using/learning Django had been a fantastic experience. I am stepping up my game and working on intergrating Stripe to sell services on my website, and I am struggling using such a complex API.

The level of intricacy makes it feel impossible to ask a question on the matter without needing an entire walkthrough. Is there anybody out there who would be willing to hop on Discord for an hour or two and take a look at my code/provide some suggestions for Stripe intergration? Thanks in advance!

/r/django
https://redd.it/yjnaqy

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

Python Daily

Do all web apps in Flask require a database?

Is it possible to make a web app where you don't need a database? Like taking input from a user - can my script take user's input from the browser, so there is no need to send it into a database? its not clear for me if having a database is mandatory in all cases.

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

Читать полностью…
Subscribe to a channel