Python Daily


Гео и язык канала: не указан, не указан
Категория: не указана


Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels

Связанные каналы  |  Похожие каналы

Гео и язык канала
не указан, не указан
Категория
не указана
Статистика
Фильтр публикаций


Today I wrote my first password generator.

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


Flask with React

I've been programming with python for a while, but I have always been a disaster on web development.

Lately I am studying Flask for Rest API, and I like to work with React on my Node projects, so I tried my best on connecting Flask with React.

I wanted to create several routes with Flask (get,post,put,delete for each object), but I can't find a way to use more than one route on flask connected with React.

I am new to it, so I want a clarification on what I am missing on the equation.



If I am going to use React Router, then how do I create the render\_template on Flask for each route?

Sorry if this question is beyond dumb.

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


The third part of my Python Course is out.

I'm a Game Developer that learned everything I know for free, so I'm giving back. And making a free course that will take anyone from not knowing any programming to making an RPG or similar game, with Python.

So far the course is still only about learning Basic Python, though I use Video Game examples to explain programming concepts. And the exercises are mostly game related.

____

[Everything you need to know BEFORE learning how to Code.](https://www.youtube.com/playlist?list=PLpclOk10VM7gIWyirriII1z4Z7Y-u344n)
This is Episode 0, lots of preamble that I whish someone had told me before I started.

____

[Basics of Python Part 1.](https://www.youtube.com/playlist?list=PLpclOk10VM7inp3AmpFHMDyEJ1RZeleF8)
Variables, Sequences, Conditionals, and loops. It ends with an exercise to make a written adventure game.

____

[Basics of Python Part 2](https://www.youtube.com/playlist?list=PLpclOk10VM7iTl5YuZw8uRfjVYVob9a4l)
Functions, Classes, and Imports. As well as two exercises. The first to refactor the code of the previous exercise using Functions and Classes.
The second to make a TicTacToe game.

The three tutorial videos in part 2, [Functions](https://youtu.be/gtW256tB8wA), [Classes](https://youtu.be/Qdb3r1izA6I), and [Imports](https://youtu.be/2e62ASEQtEM) are all stand-alone, if anyone just wants to learn about those concepts.

____

Learning in this way

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


Best Django Host

I'm working on side project and when it comes to where to deploy it, I still asking myself:

**How can I choose the best host?**

Anyone here knew the best between AWS, [Divio](https://www.divio.com/) or Heroku?

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


I created my first game

So I've been learning to use python for 2 days and I decided to make a simple game, I created a typical snake game, I followed a tutorial but I changed and added things by my own, here's the download link if you guys want to to test it and give me your opinion, projects like this sure helps to learn!

https://www.mediafire.com/file/1ubo85rre10evym/serpientosa.rar/file

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


UI as seperate app

I manage a Django site which has evolved over the years from a single model "god" class to a multi app relational design. The migrations have been painful but it's been worth it. I may now have to merge it with a second teams site.

I'm currently thinking of a break. Build from scratch following best practices throughout. However the one bit I'm struggling with is the UI. I find that i want common elements across all, a toolbar for example, that reference all apps. My current cludge is a placeholder app providing a base template with blocks which are then overridden later by the final app.

I'm tempted to break the entire UI out in to a separate app. Nothing but views, templates and urls. I see this as similar to using an external angular / react interface, but I'm wondering on others views. Does this seem sane or am i going to regret it?

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


How do I improve myself at work? (Django REST API)

I am a fresher and it has been 3 months I have joined a renowned software company here. Now 3 months later, the HR is telling me I am underperforming very much and might get kicked out soon if I don't improve myself. I have been learning and trying to apply my knowledge on my project as much as I can. I have identified my problem which is :

I have to work in an existing project where I have to work in Django and Django REST Framework. I have no prior knowledge of web development and I have never worked with API's. I have watched my tutorials, know the basics. But the project seems completely different and I often lose clue how to proceed. I have to ask for help every now and then as I don't know how to think, as I have no prior experience with API or web development. Even the juniors joining my team are performing very well as they have freelancing experience, but all I have is problem solving experience.. which is making me frustrated. How to improve this situation ?
n.b. I am very frustrated so please answer and don't mock, thanks :)

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


SQLAlchemy: how to incorporate IF ELSE statements (without 'cases')?

I'm trying to check to see if an entry exists in my database with a certain value in order to determine whether or not it needs to be added (using sessions).


Googling around showed me some simple examples of using . \\where 'cases' however I do not think that is what I'm trying to do either. The only thing I could think of off the top of my head is try/except statements (ie. 'try' to find it within the table, 'if' excepts-- do something else) but that seems unnecessarily sloppy.


What's the simplest way to achieve this?

if is_valid is True:
print(extension_type, 'is supported!')

# this doesn't seem to do anything
session.query([SupportedExtensions]). \
where(
case(


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


Is Flask good for my use case to build live question and answer application?

Hi All,



I am doing side project with flask. (Initially was thinking to do with django by using django-channel but I tried some flask tutorial earlier and liked the simplicity. )

The app is:

Live question and answer application where there can be multiple simultaneous room.

Each room will have speakers (who answers questions) and moderators (who assigns questions from users) and obviously users who will be posting questions.

flask-socketio looks good for my use case but I would also like to store the questions and answers (and changes) in database(so maybe async calls to store questions and answers in DB). But from question [https://www.reddit.com/r/flask/comments/c7myty/async\_and\_await\_with\_flask/](https://www.reddit.com/r/flask/comments/c7myty/async_and_await_with_flask/) people are saying flask is not designed for IO. So should I rethink of using flask? As I am keeping scalability in mind, like will the DB calls be bottleneck if I have 1000 concurrent users?

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


error in this code - do i not have something installed?

just following a youtube video and my code is producing errors even though his is not.



do i not have something installed?



[my code](https://imgur.com/a/aExH83S)

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






Using Python to find a prime number that looks like the python logo (or any other image) from far away [OC]

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






Recommendation for passing location info from front end geolication to back end

Hi folks, once I've got my user's location via the geolocation api:
https://www.w3schools.com/html/html5_geolocation.asp
What's the recommended way to make that latitude and longitude result available to Django. I assume via Ajax, but could someone post a short example of what it should look like?

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


[R] - Exploring the Lottery Ticket Hypothesis

Hi all, I published a summary of a recent paper published by researchers from MIT, University of Toronto and Cambridge. It takes a deeper look into the Lottery Ticket Hypothesis, an idea that neural networks have a pruned version which can train just as well as the original version with significantly less size, when applying the right weights (this is a "winning ticket"). The result could help better understand "winning tickets" and is generally interesting. I hope you'll like it and happy to get feedback. Full summary here: [https://www.lyrn.ai/2019/07/02/exploring-the-lottery-ticket-hypothesis/](https://www.lyrn.ai/2019/07/02/exploring-the-lottery-ticket-hypothesis/)

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




[R] Layer rotation: a surprisingly powerful indicator of generalization in deep networks?

Sharing our latest work presented at the ICML workshop "Identifying and Understanding Deep Learning Phenomena":

*Layer rotation: a surprisingly powerful indicator of generalization in deep networks?* ([arxiv link](https://arxiv.org/abs/1806.01603v2))



We're pretty excited about it: we really believe layer rotation (the metric we study) is somehow related to a fundamental aspect of deep learning, and that it is worth much more investigation. For the moment, our work demonstrates that layer rotation's relation with generalization exhibits a remarkable

* consistency : a rule of thumb that is widely applicable, explaining ***differences of up to 30% test accuracy***,
* simplicity : ***a network-independent optimum w.r.t. generalization***, and
* explanatory power: ***novel insights around widely used techniques*** (weight decay, adaptive gradient methods, learning rate warmups,...).

We also provide preliminary evidence that layer rotations correlate with the degree to which intermediate features are learned during the training procedure.



Since we also provide tools to monitor and control layer rotation during training, our work could also greatly reduce the current hyperparameter tuning struggle. Code available! [Here](https://github.com/ispgroupucl/layer-rotation-paper-experiments) and [here](https://github.com/ispgroupucl/layer-rotation-tools).



Looking forward to your feedback!



**Abstract**:

Our work presents extensive empirical evidence that layer rotation, i.e. the evolution across training of the cosine distance between each layer's weight vector and its initialization, constitutes an

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


NSException while using matplotlib

I am trying to plot a simple graph on my webpage using matplotlib but I keep getting the NSException, the error says "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!' \*\*\* First throw call stack:"



Is there any ways around this?

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

Показано 20 последних публикаций.

712

подписчиков
Статистика канала