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

Django bugfix release: 4.1.3
https://www.djangoproject.com/weblog/2022/nov/01/bugfix-release/

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

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

Python Daily

jinja IF statements not working for me

Hello

once again i must turn to the best community i know :D

​

I am trying to have a status bar for my website, where it changes color and text depending on the status message that was posted.

I am doing a FOR loop to check for messages, then i use IF statements to check for type of message.

When a condition is met i change the text varible for the Div element and use <style></style> to set the background-color.

&#x200B;

but right now it shows the color of critical(red) but the text for no issues detected ("Ingen problemer")

what am i doing wrong ? maybe you guys can help me out.

&#x200B;



{% for post in posts %}


{% if post.pstatus=='Kritisk' %}
{% set ptext='Kritisk' %}
<style>
.statusDiv {
background-color: red;
  }
</style>
{% elif post.pstatus=='Advarsel' %}
{% set ptext='Advarsel' %}
<style>
.statusDiv {
background-color: yellow;
  }
</style>
{% else %}
{% set ptext='Ingen problemer' %}
<style>
.statusDiv {
background-color: green;
  }
</style>
<div class="container-md statusDiv">
<p>{{ ptext

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

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

Python Daily

Need Help creating and reading text files

&#x200B;

https://preview.redd.it/c8kry86b66x91.png?width=699&amp;format=png&amp;auto=webp&amp;s=faf3d6d50aa768be6310929237b67660da41b524

I know the commands to add and read a file in pyhton IDLE, but the same method doesnt work in Jupyter. Please Help thanks.

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

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

Python Daily

Serverless Jupyter Labs with GPUs, CPUs and high-speed storage



I'm looking to validate my new SaaS idea so sharing the landing page to see if I can build some interest.

Kiku Labs offers a way to get Jupyter Labs with powerful compute and storage for experimenting with your data science projects. The labs are saved and restored between sessions, and you're charged based on the usage.

Feel free to ask any questions.

Please join the waiting list if you're interested in the product.

&#x200B;

https://kikulabs.com/

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

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

Python Daily

Looking for a library to aid with creating APIs for graphs, charts, etc

I'm looking for a library than can aid with creating APIs for bar charts, stacked bar charts, etc. Also a plus if it can deal with date range filters, group by month, day, year, etc.

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

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

Python Daily

[P] Explain Paper - A Better Way to Read Academic Papers
https://twitter.com/amanjha__/status/1584628485510733825

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

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

Python Daily

Best Practice for Duplicate Application with Different Routing?

The post title is probably confusing but I will try my best to explain what I am looking for...

Currently, we have a Flask application that is hosted on AWS with a domain name (I will call it foo.bar.edu as my example). It is basically an organization registration system, which sends its data to a Google Sheet. My mentor wants to present and demo this software to other companies. As a result, he wants foo.bar.edu/membership and foo.bar.edu/demo as separate instances. The /membership route will be for organizational use, and the /demo route will be for presentations. They will have the same backend logic, but the main difference is that the /demo version will have different frontend and point to a different Google Sheet.

I could think of different ways for doing this, but I wanted to ask what is the best practice. Should I just be copy pasting the blueprints then changing route names? Should I be running them on separate ports? Running two separate Flask instances multithreaded?

This part also hurts my head to think about, but if someone could answer then that would be great... with Flask-admin, how would I be able to achieve foo.bar.edu/membership/admin and foo.bar.edu/demo/admin? I know I could

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

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

Python Daily

Best resource to learn test driven development?

I tried to learn from obey the testing goat but it is very outdated & I face some error at every step so was wondering what will be the best alternative.

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

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

Python Daily

GitHub - rnd-team-dev/plotoptix: Data visualisation and ray tracing in Python based on OptiX 7.5 framework.
https://github.com/rnd-team-dev/plotoptix

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

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

Python Daily

Make table break across pages in PDF

How do I make a table start immediately instead of on a new page when I print the HTML as PDF. (The HTML>PDF is less strict about starting on new pages than direct>PDF but I would like it to never start on new pages.)

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

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

Python Daily

Is there a way to cross-reference a pandas dataframe output on Jupyter Notebook?

I was reading this section:https://jupyterbook.org/en/stable/content/references.html#reference-tables

I want to create automatic references/indexes for some printed pandas df but I don't want to paste the text in the cell to use the {table} chunk. Is there a way I can directly reference the output of some Python code?

EDIT: I can't render/reproduce the glue examples from this page: https://jupyterbook.org/en/stable/content/executable/output-insert.html#the-glue-figure-directive

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

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

Python Daily

Is OOP required before learning Django?

I want to create a web app with a minamalistic design. I understand I’ll need to know HTML / CSS. On the backend, from what I’ve researched, I’ll need to know Django.

How much OOP knowledge is required before learning Django? I’m assuming I’ll have to learn OOP, then learn Django if I want to be able to create my web app, correct?

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

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

Python Daily

Show text after post was made.

So, I don't want to use messages. I want to show a <p> html tag after a request.

&#x200B;

I'm trying to do so like this

return render(request, 'index.html', {"form": form, "buttondisabled": buttondisabled,
"songinformation": songinformation.songinformation})

with song\
information.song_information being the element I'm trying to pass in as text.

&#x200B;

{% if songinformation %}

<p>{{song
information.songname}} </p>

{% else %}

<p>Song information...</p>

{% endif %}


However, once it's refreshed the text set through song\
information is reseted with the page. Is there a way to set text once a post request is called?

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

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

Python Daily

Day 2 of trying to make a 3D engine and failing miserably

&#x200B;

https://preview.redd.it/a0gysyrtplw91.png?width=402&amp;format=png&amp;auto=webp&amp;s=c2574c7a022bb60c925480a9a3aac666fff34dd5

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

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

Python Daily

How to exporte notebook (.ipynb) from jupyter to PDF?

I’m m trying to export a (.ipynb) file to a pdf in jupyter and the steps are: File-> Download as -> PDF via LaTex (.pdf) but when I do this appears this error: nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.

I use a macOS and I already installed the MacTeX (I’ve only installed it, I’m not sure if I need to do anything else) and it keeps giving me the same error.

Thanks in advance!

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

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

Python Daily

Running Jupyter in Any Cloud (AWS, Azure, GCP, or K8s) With TPI Terraform Plugin
https://dev.to/casperdcl/how-to-run-jupyter-in-any-cloud-with-one-command-52me

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

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

Python Daily

In Matplotlib, is it possible to specify positional x,y coords for text on a plot (not relatively to axes)

ax.text(x, y, "My Text", fontsize=10, ha='left', va='top') <-- x, y here refer positions on the data axes and so will be different for each plot.

&#x200B;

Is there a way to generically say "top left". ha, va seem to be ignored.

Cheers!

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

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

Python Daily

Creating Dynamic URLs from Form Submission.

Hello guys,

I've tried for too long, creating dynamic urls, that are supposed to be extra simple - yet I've been trying for days now and nothing changed.

TL;DR - A user accessed the Form template on ('hunting'), inserted details inside the form, when pressing "Submit" he will be redirected towards "localhost:80/hunting/<int:pk>"

Longer version:

Views.py:

class Hunting(LoginRequiredMixin, View):
contextobjectname = 'huntlist'
def get(self, request):
form = HuntForm()
random
id = random.randint(1,100)
obj = HuntingModel.objects.get(id=randomid)
print('Access Hunting')
return render(request, 'home/hunting.html', {'form': form})
def post(self, request):
model = HuntingModel
random
id = random.randint(1, 100)
obj = HuntingModel.objects.get(id)
form = HuntForm(request.POST, request.FILES)
name = request.POST'name'
limit = request.POST'limit'
os = request.POST.getlist('os')


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

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

Python Daily

Asyncio vs Threading vs Multiprocessing use cases
https://www.youtube.com/watch?v=X7vBbelRXn0

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

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

Python Daily

High performance profiling for Python 3.11

I am delighted to announce the 3.4 release of Austin. If you haven't heard of Austin before, it is an open-source frame stack sampler for CPython, distributed under the GPLv3 license. It can be used to obtain statistical profiling data out of a running Python application without a single line of instrumentation. This means that you can start profiling a Python application straight away, even while it's running in a production environment, with minimal impact on performance.

https://github.com/P403n1x87/austin

The Austin VS Code extension provides a smooth interactive profiling experience, with interactive flame graphs straight into the text editor to allow you to quickly jump to the source code with a simple click. You can find the extension on the Visual Studio Marketplace and install it directly from VS Code:

https://marketplace.visualstudio.com/items?itemName=p403n1x87.austin-vscode

To see how to make the best of Austin with VS Code to find and fix performance issues, check out this blog post, which shows you the editor extension in action on a real Python project:

https://p403n1x87.github.io/how-to-bust-python-performance-issues.html

This latest release builds on top of the significant performance improvements introduced in the 3.3 release. Benchmarking figures (see https://github.com/P403n1x87/austin/pull/126#issuecomment-1279765640 for some of the numbers) show that Austin 3.4 continues to provide a high sample rate at low sampling

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

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

Python Daily

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

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

Python Daily

Looking at Django for future work

Hi! I've been looking at jumping into the world of Python and Django for some personal projects and (hopefully) use it for doing some freelance/side projects. I work a full time job as a developer and this would be separate from my 9-5. I've worked as a developer / IT generalist for 20+years but never thought to look at python. I've done a bunch of Ruby on Rails and Grails over the years and I expect Django is in the same ballpark. As far as learning it I dont think that will be an issue - I enjoy digging into something new (for me)! As far as future freelance-type opportunities go do you think Django is a good choice nowadays?

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

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

Python Daily

What is the biggest challenge you face as a Django developer in your daily work?

Hi Django developers friend, my name is Brandon a Django developer too, I just finished working on djangojob.com and now I'm looking for my next project to work on, but this time instead of building the first idea that comes to my mind and jumping into the code right away, I would like to start asking the community what is the biggest challenge you face as a Django developer every day? (answer could be related to work, personal projects, life, etc. there's no wrong answer)

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

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

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

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

Python Daily

OKTA SSO for Django

Hi, has anyone here configured an sso for django backend using Okta?
I have a django backend and a flutter frontend and am trying to set up a sso for it on Okta. I am having trouble understanding how to connect my django auth system with Okta. I have a lot of permission based APIs so in order to maintain that with flutter I need to set up some sort of auth between my django backend and flutter frontend. I would really appreciate it if someone could point me towards helpful resources or if I could talk to some one who has already worked on it. Thanks!

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

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

Python Daily

Prettier for Django templates

Really started loving Prettier to auto-format HTML / JavaScript on save in PyCharm. However it doesn't seem to play nice with the Django templating language – curious what everyone else is using to auto-format their Django templates on save.

tl;dr: What to use instead of Prettier with Django templates?

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

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

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

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

Python Daily

I built this site with Python and django for NHL hockey bettors featuring head to head team stats, starting goalies season/career stats and injuries for every game, daily.
https://www.hockeyforecast.com/

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

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

Python Daily

Machine Learning with Django

Hi All!

Today I updated my website with a tutorial on how to deploy Machine Learning models with Django (DRF), and I would like to share it with you.

This tutorial covers the basics which should be enough to build your ML system:

- can handle many API endpoints,

- each API endpoint can have several ML algorithms with different versions,

- ML code and artifacts (files with ML parameters) are stored in the code repository (git),

- supports fast deployments and continuous integration (tests for both: server and ML code),

- supports monitoring and algorithm diagnostic (support A/B tests),

- is scalable (deployed with containers),


The tutorial website: https://www.deploymachinelearning.com/

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

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

Python Daily

A brief explanation of Python dependency management
https://github.com/alexpdp7/alexpdp7/blob/master/programming/python/dependency_handling.md

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

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