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
Charts and data visualization

Hello! I am working on my first real django project so bare with me, im new to this! I am pretty new to python too but I have some basic knowledge! HTML and CSS is solid for me!

I am trying to create web app that users could create new ”tables” and input data to them. Then each table would have it’s own linechart showing the data they entered. What would be the way to go with this?

Only chart im able to get to show on my page is google charts with some dummy data and it felt a bit weak.. I have also tried fusioncharts but I was not able to get it to work and I cannot affor the commercial license.

I dont need library as poweful as fusioncharts but I need very very good and simple documentation. Any suggestions?

/r/django
https://redd.it/aw64y6
[AF] WTForms/Flask: Dynamic min_entries

I'm looking to use the min_entries WTForms parameter dynamically i.e. without hardcoding numbers.

It would look something like this in the form.py:

class TestSpecForm(FlaskForm):
student_number = IntegerField('Number of Students')


class StudentForm(FlaskForm):
answer = StringField('')


class TestInputForm(FlaskForm):
students = FieldList(FormField(StudentForm)) # I'd like to insert the dynamic min_entries here
submit = SubmitField('Submit')

and something like this in the views.py:

def input(key_id):
key = Testspecs.query.get_or_404(key_id)
student_number = key.student_number


/r/flask
https://redd.it/aw9ys9
Useful Python tricks

So, I saw a while ago somebody posted a thread asking for ways that people have used python to automate their lives or just make it easier in general. Most of the replies as can be expected involved making tasks at work easier etc, which don't really apply to someone like me who doesn't have an office job or anything similar.

So, what are some cool uses for python for maybe younger people or just people without office jobs in general? It would be fun to find a project to work on or something that I can use python for in my daily life but as far as I'm aware i can't really think of anything that I need automated.

Thanks!

/r/Python
https://redd.it/awb9v5
Pipenv and Poetry are both in the weeds - what can we do to help?

I discovered that neither project has merged a PR in roughly a month. Meanwhile, PR's and Issues are flowing in much faster than they're getting resolved. Intrigued by this, I checked dependency/package managers in other languages, and didn't see the same problems (Python/Conda, Rust/Cargo, Ruby/Bundler, Node/npm).

I think this is a big issue. It doesn't just mean that bugs aren't getting fixed, but that they're not accepting help from the community.

Is it a matter of the project owners needing to delegate more? I.e., one person, or a tiny group, is responsible for all decisions? Is there something that we, the stakeholders -- who aren't the maintainers -- can do to help?

\-----

Source: I used my opensource repocheck app to collect the data. E.g.:

* [Analysis: Pipenv](https://repocheck.com/#https%3A%2F%2Fgithub.com%2Fpypa%2Fpipenv) score: **1.6** out of 10
* [Analysis: Poetry](https://repocheck.com/#https%3A%2F%2Fgithub.com%2Fsdispater%2Fpoetry) score: **2.8** out of 10
* [Analysis: Conda](https://repocheck.com/#https%3A%2F%2Fgithub.com%2Fconda%2Fconda) score: 6.4 out of 10
* [Analysis: Ruby Bundler](https://repocheck.com/#https%3A%2F%2Fgithub.com%2Fbundler%2Fbundler) score: 7.0 out of 10

/r/Python
https://redd.it/awbr99
What are some well designed PyQT apps?

I’m looking for some design inspiration / best practices for developing a PyQT app.

/r/Python
https://redd.it/awavhh
Django Object Persistence

Hey guys, so here's the issue I'm facing: I have a function that interpolates datasets via a scipy object. Generating these datasets takes ~7 seconds each time.

I don't have a database for the object and can't find a reliable way to just call the function one time and use its dicts repeatedly.

How can I store this object/keep persistence so that I can call it for a view function? Trying to lower the amount of time that it takes to run functions for users.

Thanks

/r/django
https://redd.it/awas61
VPython : [Moon Orbiting Earth] : A Physics Demonstration

Here's a neat example I made of the Moon orbiting around the Earth! I originally wrote the code in a Jupyter notebook, but I converted it so that it could run in the Trinket IDE (i.e. GlowScript), which is far better at handling the 3D animations. Some of the physical assumptions made include:

* C.o.M. located at the center of the Earth
* Earth remains positionally fixed
* No G.R. induced orbital precession

​

Personally, I think the trinket version I converted from Jupyter is the cooler of the two. I added the ability to change the point of view of the camera in trinket during the orbit using keyboard commands:

​

s : system \\ e : earth \\ m : moon

​

Please find below the link for the trinket animation (DM for source code) and underneath the source code for a Jupyter notebook.

​

\---- Enjoy!! ----

​

<> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <>

Trinket link: [https://ballinpicard.trinket.io/sites/moon-orbits-earth](https://ballinpicard.trinket.io/sites/moon-orbits-earth)

<> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <>

Jupyter Notebook Code (put in one cell block

/r/IPython
https://redd.it/awcju5
Is it better to use multiple ForeignKey in an intermediate table than using ManyToManyField?

I read some codes that choose to use multiple ForeignKey(s) and its own table instead of using ManyToManyField.
1. What do you think?
2. In what situation do you choose to use multiple ForeignKey(s) and its own table instead of ManyToManyField?

Thanks.

/r/django
https://redd.it/awgt3q
Best tutorial for machine learning?

I recently finished learning python and have been coding a lot in it lately. I wanted to do some machine learning and was wondering how to go about teaching myself how to do it. What are your suggestions? Should I even teach myself machine learning yet?

/r/Python
https://redd.it/awie4e
Jupyter Kernel Gateway 2.2.0 and NB2KG 0.5.0 are available
https://groups.google.com/forum/#!topic/jupyter/i513ryU3rm8

/r/IPython
https://redd.it/awinbx
I just built my portfolio in Django and NES.css
http://www.scheding.com.au/

/r/django
https://redd.it/awfzs7
Post request not working with Inline formset

I'm trying to create an Inline formset where I can create an event and have all the bookings show within that event in the /admin.

I've managed to build it but I'm having issues getting the form data to show in the /admin. As if the form, in the front-end, isn't doing anything.

[See admin section here.](https://i.postimg.cc/L5bgnY7D/asdasdasdasd.png) Notice that no data is in "*C EVENT BOOKINGS*"

The console log says a POST request was submitted but no actual data is going into my model. No 4** or 5** errors.

See code below.

Worth noting that I had to add "default=None, null=False," in my C Event Form Model. Wouldn't let me migrate or submit to form otherwise. Not really sure what it does and is very likely part of the issue.


**Admin.py**

from django.contrib import admin

from .models import *

# Register your models here.

class CEventBookingsInline(admin.TabularInline):
model = CEventBookings
list_display = ('full_name', 'email', 'phone_number', 'adult_tickets', 'children_tickets')

class CEventAdmin(admin.ModelAdmin):


/r/djangolearning
https://redd.it/awhkbd
Can't generate new instance of a random hash unless restarting server

Hello,

&#x200B;

While working on my email verification functionality on my website I noticed an odd bug.

&#x200B;

In my User model, for when I register a new user I have the following line of code.

\`email\_verification\_hash = db.Column(db.String(40), default = hashlib.md5(os.urandom(32)).hexdigest())\`

&#x200B;

In theory, for every new user a random hash should generate.

&#x200B;

but what I noticed was no matter how many users I register, that hash remains the same for every new user, UNLESS I shut down the server restart it and then make a new user, then only after that will the next user have a unique hash different from the one before it; that is of course unless i make another user under that same server instance for which itll be the same as the one before.

&#x200B;

For example:

Server Started: Server Instance A:

Register User Bob: Bob.hash = 54050

Register User Tom: Tom.hash = 54050

Register User Admin: Admin.hash = 54050

&#x200B;

Server Turned Off, Restarted: Server Instance B

Register User Greg: Greg.hash = 10383

Register User Tom: Tom.hash = 10383

Register User Admin: Admin.hash = 10383

&#x200B;

Server Turned Off, Restarted: Server Instance C

Register User Greg: Greg.hash = 5859860

Register User Tom: Tom.hash = 5859860

Register User Admin: Admin.hash = 5859860

&#x200B;

&#x200B;

All I want is for every new user to have a random and unique hash without

/r/flask
https://redd.it/awo87c
Celery and Python 3.X. Has anyone had any success?

Hi all,

I'm building a new web app whilst following the (excellent) course on Flask web apps by Nick Janetakis. I'm following his tutorial but at the same time am building my own app, piece by piece as I learn.

In doing this I'm trying to use newer tools. For example, I want to use Python 3.x for future proofing the app, but I have an issue where Celery and Python 3.X won't want to work together.

Just checking in if anyone has had any success with getting a Python 3.x to work with any Celery versions or am I resigned to falling back to Python 2.x?

Thanks a tonne...

/r/Python
https://redd.it/awoahu
[D] How long are we from: Voice Style Transfer | Voice to Voice, Male to Female, Adding and Removing Accents, & Swapping Vocalists in Music

I'm coming over from /r/MediaSynthesis with the titular question. I'm well aware of previous experiments, but I'm eagerly awaiting future developments in this field of media manipulation.

I've played around with sex-changing voice changers in the past, and the common limitation among all of them is that there is nothing being done besides raising or dropping the pitch, and this doesn't lead to a believable effect since gendered speaking patterns exist in most societies. Without accounting for differences in cadences, you merely wind up with voices that sound like chipmunks or homosexual demons. This requires neural networks, but I haven't found many good ones.

In comes GANs. What's more, GANs might also allow for some creative applications, such as [musical style transfer](https://www.youtube.com/watch?v=YQAupr7JxNY). My go-to theoretical examples are "TLC's *Waterfalls*, but as a barbershop quartet", The Beatles' *I Am The Walrus*, but as an opera", and "Black Sabbath's *Iron Man*, but with Justin Bieber".

Even 2 years ago, I'd have said this was many decades out, but now I'm not so sure. I feel I could say "We'll see something like this by 2029" and then someone demonstrates the exact same thing within 6 months. I say this because it's exactly what happened

/r/MachineLearning
https://redd.it/awmjm8
PSA: Check your ALLOWED_HOSTS

I've seen a huge uptick in malicious entities trying to gain access across my django sites over the past 48 hours or so. Maybe it's just at my servers, but I suspect these attacks are widespread. This is a good time to verify that your production settings are not:

ALLOWED_HOSTS=['*']

(Edit: Also, while I'm at it, you should ALWAYS have **DEBUG=False** in production, and never commit your **SECRET_KEY** to git/svn)

If you're new to django, [Security in Django](https://docs.djangoproject.com/en/2.1/topics/security/) is the relevant docs page for this topic.

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