Python Positional-Only Parameters, has been accepted
[PEP-570](https://www.python.org/dev/peps/pep-0570/) has been accepted. This introduces `/` as a marker to indicate that the arguments to its left are positional only. Similar to how `*` indicates the arguments to the right are keyword only. A couple of simple examples would be,
```python
def name(p1, p2, /): ...
name(1, 2) # Fine
name(1, p2=2) # Not allowed
def name2(p1, p2, /, p_or_kw): ...
name2(1, 2, 3) # Fine
name2(1, 2, p_or_kw=3) # Fine
name2(1, p2=2, p_or_kw=3) # Not allowed
```
(I'm not involved in the PEP, just thought this sub would be interested).
/r/Python
https://redd.it/ba6scp
[PEP-570](https://www.python.org/dev/peps/pep-0570/) has been accepted. This introduces `/` as a marker to indicate that the arguments to its left are positional only. Similar to how `*` indicates the arguments to the right are keyword only. A couple of simple examples would be,
```python
def name(p1, p2, /): ...
name(1, 2) # Fine
name(1, p2=2) # Not allowed
def name2(p1, p2, /, p_or_kw): ...
name2(1, 2, 3) # Fine
name2(1, 2, p_or_kw=3) # Fine
name2(1, p2=2, p_or_kw=3) # Not allowed
```
(I'm not involved in the PEP, just thought this sub would be interested).
/r/Python
https://redd.it/ba6scp
Python Enhancement Proposals (PEPs)
PEP 570 – Python Positional-Only Parameters | peps.python.org
This PEP proposes to introduce a new syntax, /, for specifying positional-only parameters in Python function definitions.
Update on my Bot that creates Youtube-Videos
Hey guys,
I already posted about this once last week, [here](https://old.reddit.com/r/Python/comments/b7siec/i_made_a_video_creating_script_with_python/) ,basically I created a script which takes askreddit threads and makes youtube videos out of them.
Now I did make some improvments, e.g. spaced out the comments so the reader pauses and would be happy to hear some feedback from you guys.
Here are my 2 new videos both on the same askreddit thread, one with old google tts and one with the better google tts although not wavenet:
[Standard](https://www.youtube.com/watch?v=H55aJjQiuXA)
[Newer Google tts](https://www.youtube.com/watch?v=jjKG9uAZwiM)
Looking forward to your feedback :)
/r/Python
https://redd.it/ba85zh
Hey guys,
I already posted about this once last week, [here](https://old.reddit.com/r/Python/comments/b7siec/i_made_a_video_creating_script_with_python/) ,basically I created a script which takes askreddit threads and makes youtube videos out of them.
Now I did make some improvments, e.g. spaced out the comments so the reader pauses and would be happy to hear some feedback from you guys.
Here are my 2 new videos both on the same askreddit thread, one with old google tts and one with the better google tts although not wavenet:
[Standard](https://www.youtube.com/watch?v=H55aJjQiuXA)
[Newer Google tts](https://www.youtube.com/watch?v=jjKG9uAZwiM)
Looking forward to your feedback :)
/r/Python
https://redd.it/ba85zh
reddit
r/Python - I made a video creating script with python
3 votes and 1 comment so far on Reddit
My first open-source project. An ASCII art generator
I've been using python for a while, but I struggle to think of more ambitious projects, so most of my projects are very, very simple. But this time I've tried to make something a little more complicated (granted, it's not that complicated, just a little more complex than my usual project), so I made an ASCII art generator, that takes an image of any type and converts it to ASCII art. This is also the first time I am releasing my code on Github for other people to use.
I'm posting this here to see if anyone can make suggestions on how to improve the code, and see if there is anything wrong with it (so basically a code review).
​
[Github link](https://github.com/purrleterian/Image-to-ASCII-art-converter)
/r/Python
https://redd.it/bab3r9
I've been using python for a while, but I struggle to think of more ambitious projects, so most of my projects are very, very simple. But this time I've tried to make something a little more complicated (granted, it's not that complicated, just a little more complex than my usual project), so I made an ASCII art generator, that takes an image of any type and converts it to ASCII art. This is also the first time I am releasing my code on Github for other people to use.
I'm posting this here to see if anyone can make suggestions on how to improve the code, and see if there is anything wrong with it (so basically a code review).
​
[Github link](https://github.com/purrleterian/Image-to-ASCII-art-converter)
/r/Python
https://redd.it/bab3r9
GitHub
purrleterian/Image-to-ASCII-art-converter
Converts an image of any type to an ASCII art representation of the same image. - purrleterian/Image-to-ASCII-art-converter
[D] Tensoflow 2.0 vs. Keras
Okay I'm just gonna come out and say it. I don't get it. All the marketing and Medium articles make Tensorflow 2.0 sound like everything has been streamlined (which would be greatly appreciated), but if you look at the API documentation nothing seems to have been taken out. The main difference I can see is that the tutorials now use tf.keras as the preferred method of doing things. I'm mostly okay with this as Keras is much more intuitive when it comes to building neural networks, but if they're using the tf.keras namespace, aren't we really just using Keras? I feel like I'm being tricked or something.
Now, I am admittedly something of a relative beginner when it comes to ML and TF especially so maybe I don't understand the nuances, but I would have thought that TF 2.0 would have changed the entire API to be more like that of Keras or PyTorch instead of just changing the docs to tell me to use tf.keras. Am I actually just using Keras with the ability to do more advanced things or is it still Tensorflow?
Sorry if this doesn't make a lot of sense or isn't the right place for this, I
/r/MachineLearning
https://redd.it/ba9h3g
Okay I'm just gonna come out and say it. I don't get it. All the marketing and Medium articles make Tensorflow 2.0 sound like everything has been streamlined (which would be greatly appreciated), but if you look at the API documentation nothing seems to have been taken out. The main difference I can see is that the tutorials now use tf.keras as the preferred method of doing things. I'm mostly okay with this as Keras is much more intuitive when it comes to building neural networks, but if they're using the tf.keras namespace, aren't we really just using Keras? I feel like I'm being tricked or something.
Now, I am admittedly something of a relative beginner when it comes to ML and TF especially so maybe I don't understand the nuances, but I would have thought that TF 2.0 would have changed the entire API to be more like that of Keras or PyTorch instead of just changing the docs to tell me to use tf.keras. Am I actually just using Keras with the ability to do more advanced things or is it still Tensorflow?
Sorry if this doesn't make a lot of sense or isn't the right place for this, I
/r/MachineLearning
https://redd.it/ba9h3g
reddit
r/MachineLearning - [D] Tensoflow 2.0 vs. Keras
88 votes and 32 comments so far on Reddit
Can't create model instances after I tried to "slugify" a model attribute (using a DetailView)
Hi guys,
I have a M2M relationship that uses a through table: a `Publication` has a M2M relationship with an `Author` through a `PublicationAuthor` table. I used to be able to create publications, but I can't anymore, not after I tried to "slugify" the `title` attribute of my `Publication` model to use the title in the URL. I don't know why it won't let me create instances anymore, whether in my console or in the admin panel. I guess there is an issue with my slugifying code. Note that I am using a class-based DetailView in my [views.py](https://views.py) file.
​
Here is my code and the error message I get:
[models.py](https://models.py)
class Publication(models.Model):
author = models.ManyToManyField('Author', through='PublicationAuthor', related_name='publications')
title = models.CharField(max_length=200)
# For slugs
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
return super(Publication, self).save(*args, **kwargs)
class Author(models.Model):
first_name = models.CharField(max_length=30, blank=True, null=True, help_text='If author only has one name (e.g. Aristotle), enter it as a last name')
middle_name = models.CharField(max_length=60, blank=True, null=True)
last_name = models.CharField(max_length=30)
/r/djangolearning
https://redd.it/ba8f3q
Hi guys,
I have a M2M relationship that uses a through table: a `Publication` has a M2M relationship with an `Author` through a `PublicationAuthor` table. I used to be able to create publications, but I can't anymore, not after I tried to "slugify" the `title` attribute of my `Publication` model to use the title in the URL. I don't know why it won't let me create instances anymore, whether in my console or in the admin panel. I guess there is an issue with my slugifying code. Note that I am using a class-based DetailView in my [views.py](https://views.py) file.
​
Here is my code and the error message I get:
[models.py](https://models.py)
class Publication(models.Model):
author = models.ManyToManyField('Author', through='PublicationAuthor', related_name='publications')
title = models.CharField(max_length=200)
# For slugs
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
return super(Publication, self).save(*args, **kwargs)
class Author(models.Model):
first_name = models.CharField(max_length=30, blank=True, null=True, help_text='If author only has one name (e.g. Aristotle), enter it as a last name')
middle_name = models.CharField(max_length=60, blank=True, null=True)
last_name = models.CharField(max_length=30)
/r/djangolearning
https://redd.it/ba8f3q
How did you'll get into contributing to open-source projects?
Hey,
So I've been programming in python for quite some time so I know the basics, the only problem is I don't find enough problems to solve probably because I'm not motivated enough or probably don't look hard enough.
However, I feel that contributing to open source projects is something I would like to get into.
I've tried several times but I'm always so overwhelmed and don't understand where to begin. That's why I want to know how did y'all begin with open-source.
I hope I'm not in the wrong sub, I know python hence I didn't post this in /r/learnpython.
Thanks.
/r/Python
https://redd.it/bad3md
Hey,
So I've been programming in python for quite some time so I know the basics, the only problem is I don't find enough problems to solve probably because I'm not motivated enough or probably don't look hard enough.
However, I feel that contributing to open source projects is something I would like to get into.
I've tried several times but I'm always so overwhelmed and don't understand where to begin. That's why I want to know how did y'all begin with open-source.
I hope I'm not in the wrong sub, I know python hence I didn't post this in /r/learnpython.
Thanks.
/r/Python
https://redd.it/bad3md
reddit
r/Python - How did you'll get into contributing to open-source projects?
0 votes and 6 comments so far on Reddit
I create my first small project using Django (link shortener)
I was kind of stuck on projects I was trying to do, because I needed auth + crud using API. And this auth deal is a bit tricky, I learned how it works in the back end, but I do not know how it works on the front (like uploading user data, checking if it's logged in etc., also because it's decoupled from the backend) .
​
So I decided to do a simple project that uses DRF + something to call API. I tried Axios and lost hours because I was not displaying the data when there was a bad request, since fetch showed me this, and the error is because I was using .textContent instead of .value to get the url inserted in the input. Then the DRF returned a json saying that the field could not be blank.
​
It's a pretty simple project with two pages, and you can find the [source here](https://github.com/marcosroot/django-shortener) and a [video example here](https://vimeo.com/328894613).
​
PS: I already created things like blog, I used wagtail and I made an authentication system with Django. But as things were for their own use and without the least usefulness to others, I did not consider it a "finished project." Also because
/r/django
https://redd.it/bac67f
I was kind of stuck on projects I was trying to do, because I needed auth + crud using API. And this auth deal is a bit tricky, I learned how it works in the back end, but I do not know how it works on the front (like uploading user data, checking if it's logged in etc., also because it's decoupled from the backend) .
​
So I decided to do a simple project that uses DRF + something to call API. I tried Axios and lost hours because I was not displaying the data when there was a bad request, since fetch showed me this, and the error is because I was using .textContent instead of .value to get the url inserted in the input. Then the DRF returned a json saying that the field could not be blank.
​
It's a pretty simple project with two pages, and you can find the [source here](https://github.com/marcosroot/django-shortener) and a [video example here](https://vimeo.com/328894613).
​
PS: I already created things like blog, I used wagtail and I made an authentication system with Django. But as things were for their own use and without the least usefulness to others, I did not consider it a "finished project." Also because
/r/django
https://redd.it/bac67f
GitHub
marcosroot/django-shortener
Link shortener with page for ads, made with Django, Django Rest + Fetch API. - marcosroot/django-shortener
User supplied models
I'm trying to build a small CRM as a side project. I'm currently architecting it and have two issues that I'm not sure how to approach and they're both supposed to be supplied by the user
The CRM would have "contacts" and these contacts would have default fields like name, email etc.
I would also like to allow the client to provide their own custom fields (e.g birthdate, account number, etc. Etc.)
What are some approaches to allowing the end user to supply their own custom fields here?
/r/django
https://redd.it/bae83a
I'm trying to build a small CRM as a side project. I'm currently architecting it and have two issues that I'm not sure how to approach and they're both supposed to be supplied by the user
The CRM would have "contacts" and these contacts would have default fields like name, email etc.
I would also like to allow the client to provide their own custom fields (e.g birthdate, account number, etc. Etc.)
What are some approaches to allowing the end user to supply their own custom fields here?
/r/django
https://redd.it/bae83a
reddit
r/django - User supplied models
2 votes and 1 comment so far on Reddit
How to remove auth headers from 401 response
Google have some bright idea that if you send chrome a 401 with basic in the WWW-Authenticate headers it pops up a login dialog.
For everything except my login view (which takes basic auth and returns a token) this is fine.
I still want to return 401, as it's the correct code, so what options do I have to get WWW-Authenticate out of the response? It's produced by a DRF APIView.
/r/django
https://redd.it/baet30
Google have some bright idea that if you send chrome a 401 with basic in the WWW-Authenticate headers it pops up a login dialog.
For everything except my login view (which takes basic auth and returns a token) this is fine.
I still want to return 401, as it's the correct code, so what options do I have to get WWW-Authenticate out of the response? It's produced by a DRF APIView.
/r/django
https://redd.it/baet30
reddit
r/django - How to remove auth headers from 401 response
0 votes and 1 comment so far on Reddit
WiPhone: A Phone You Can Program in Python
https://www.kickstarter.com/projects/2103809433/wiphone-a-phone-for-hackers-and-makers/
/r/Python
https://redd.it/bagyxv
https://www.kickstarter.com/projects/2103809433/wiphone-a-phone-for-hackers-and-makers/
/r/Python
https://redd.it/bagyxv
Kickstarter
WiPhone, A Phone for Hackers and Makers
WiPhone is a VoIP mobile phone designed for hackers and makers to be easily modified, repurposed, and adapted.
How does Django handle file upload
If a client uploads a file to my Django server and subsequently in the view I upload that file to some other server, does Django handle this asynchronously? Suppose I’m using Gunicorn. What I’m asking is, while I’m uploading the file to the other server, is my gunicorn worker free to handle a different request while the file is being uploaded?
The reason I’m asking is if this is the case, then I’m going to find an alternate solution as I don’t want my server to become unresponsive if all the workers are busy uploading a file.
As an extension question, is the behaviour Django exhibits common? I.e. if I was using Node can I expect the same behaviour?
/r/django
https://redd.it/baj2a8
If a client uploads a file to my Django server and subsequently in the view I upload that file to some other server, does Django handle this asynchronously? Suppose I’m using Gunicorn. What I’m asking is, while I’m uploading the file to the other server, is my gunicorn worker free to handle a different request while the file is being uploaded?
The reason I’m asking is if this is the case, then I’m going to find an alternate solution as I don’t want my server to become unresponsive if all the workers are busy uploading a file.
As an extension question, is the behaviour Django exhibits common? I.e. if I was using Node can I expect the same behaviour?
/r/django
https://redd.it/baj2a8
reddit
r/django - How does Django handle file upload
2 votes and 11 comments so far on Reddit
Deploy Flask app on Heroku with an Example step by step Screenshots
https://alphazeroerror.blogspot.com/2019/04/deploy-flask-app-on-heroku.html
/r/flask
https://redd.it/badvq2
https://alphazeroerror.blogspot.com/2019/04/deploy-flask-app-on-heroku.html
/r/flask
https://redd.it/badvq2
Blogspot
Deploy Flask app on Heroku with example guide
How to deploy a Python flask app to Heroku using by link your github repository to heroku in free of cost, with free domain , gunicorn flask, Application Error on Heroku python flask app
Python++; The Future is Here!
main.pypp:
from pypp import *
#include <iostream>
#include <vector>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx,avx2")
sync_with_stdio(False);
cin.tie(0); cout.tie(0);
cout << "C++ IO in python, guaranteed ";
cout << 200 << " % speedup" << endl;
a = 0;
b = 0;
a <<= cin;
b <<= cin;
c = "";
c <<= cin;
A = vector<<int>>(5);
A <<= cin;
B = vector<<int>>(4,2);
cout << a << ' ' << b << '\n';
cout << c << '\n';
cout << A << '\n' << B << endl;
pypp.py
import sys
/r/Python
https://redd.it/bajfy1
main.pypp:
from pypp import *
#include <iostream>
#include <vector>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx,avx2")
sync_with_stdio(False);
cin.tie(0); cout.tie(0);
cout << "C++ IO in python, guaranteed ";
cout << 200 << " % speedup" << endl;
a = 0;
b = 0;
a <<= cin;
b <<= cin;
c = "";
c <<= cin;
A = vector<<int>>(5);
A <<= cin;
B = vector<<int>>(4,2);
cout << a << ' ' << b << '\n';
cout << c << '\n';
cout << A << '\n' << B << endl;
pypp.py
import sys
/r/Python
https://redd.it/bajfy1
reddit
r/Python - Python++; The Future is Here!
24 votes and 7 comments so far on Reddit
Can someone better explain flask blueprints to me?
I am curious about the use case for blueprints, I am semi familiar with flask basics but I need to learn about blue prints and all the documentation/tutorials I've viewed still seem cryptic about the fundamental issue blueprints resolve.
/r/flask
https://redd.it/bamhop
I am curious about the use case for blueprints, I am semi familiar with flask basics but I need to learn about blue prints and all the documentation/tutorials I've viewed still seem cryptic about the fundamental issue blueprints resolve.
/r/flask
https://redd.it/bamhop
reddit
r/flask - Can someone better explain flask blueprints to me?
6 votes and 4 comments so far on Reddit
After 4 months, I've finally finished a Finance-related academic thesis written entirely in Python. Here's the source code and accompanying pdf.
https://github.com/rdy1107/TA-thesis
/r/Python
https://redd.it/bandug
https://github.com/rdy1107/TA-thesis
/r/Python
https://redd.it/bandug
GitHub
rdy1107/TA-thesis
Contribute to rdy1107/TA-thesis development by creating an account on GitHub.
I feel like I'm understanding limit_choices_to wrong
Hello. I've read the documentation page on it and searched Google/SO for answers but I just can't seem to wrap my head around it.
I've got the following schema:
class MainModel(models.Model):
pass
class Criteria(models.Model):
parent = models.ForeignKey(MainModel, on_delete=models.CASCADE)
class ChildModel(models.Model):
parent = models.ForeignKey(MainModel, on_delete=models.CASCADE)
What I want to do is have a many-to-many relationship between ChildModel and Criteria, and limit the options of the Criteria to the MainModel's criteria set.
So basically the following:
class ChildModel(models.Model):
parent = models.ForeignKey(MainModel, on_delete=models.CASCADE)
criterias = models.ManyToManyField('Criteria', limit_choices_to=parent.criteria_set.all())
// I want to do this ^^^ (criterias isnt the plural form but bear with me)
But I keep getting errors about the parent not having an attribute "criteria_set" (which I assume would be the way to get the parent's list of criteria)
Am I going about this the wrong way? How would I make it work?
If something's unclear in my question please
/r/djangolearning
https://redd.it/bakda6
Hello. I've read the documentation page on it and searched Google/SO for answers but I just can't seem to wrap my head around it.
I've got the following schema:
class MainModel(models.Model):
pass
class Criteria(models.Model):
parent = models.ForeignKey(MainModel, on_delete=models.CASCADE)
class ChildModel(models.Model):
parent = models.ForeignKey(MainModel, on_delete=models.CASCADE)
What I want to do is have a many-to-many relationship between ChildModel and Criteria, and limit the options of the Criteria to the MainModel's criteria set.
So basically the following:
class ChildModel(models.Model):
parent = models.ForeignKey(MainModel, on_delete=models.CASCADE)
criterias = models.ManyToManyField('Criteria', limit_choices_to=parent.criteria_set.all())
// I want to do this ^^^ (criterias isnt the plural form but bear with me)
But I keep getting errors about the parent not having an attribute "criteria_set" (which I assume would be the way to get the parent's list of criteria)
Am I going about this the wrong way? How would I make it work?
If something's unclear in my question please
/r/djangolearning
https://redd.it/bakda6
reddit
r/djangolearning - I feel like I'm understanding limit_choices_to wrong
1 vote and 0 comments so far on Reddit
Hitting back button on Django form wizard causes page expired error(and nukes all data), particularly on Internet Explorer?
Hey all, creating multi-step forms using django form-wizard and on firefox and chrome it seems to work fine hitting the back and forwards buttons(both using provided buttons and with browser). But using IE, when hitting the browser back button, it said 'Page Expired' and all the data previously entered in the forms was lost.
Any idea how to prevent this or what is going wrong? Thanks guys.
/r/django
https://redd.it/bar7tx
Hey all, creating multi-step forms using django form-wizard and on firefox and chrome it seems to work fine hitting the back and forwards buttons(both using provided buttons and with browser). But using IE, when hitting the browser back button, it said 'Page Expired' and all the data previously entered in the forms was lost.
Any idea how to prevent this or what is going wrong? Thanks guys.
/r/django
https://redd.it/bar7tx
reddit
r/django - Hitting back button on Django form wizard causes page expired error(and nukes all data), particularly on Internet Explorer?
0 votes and 0 comments so far on Reddit