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
Humble bundle has 15 books on python for 12 bucks right now... Is the potential opportunity I'm looking for?

I'm a project manager and administrative head for about 60 people right now looking for a change. I manage technical people and understand what they do, need, and how to get it but I know I'm coming to a head in where I'm at and if I want to be marketable more than just getting by on a willingness to lead and 8 years experience doing it. I need to be technical as well. I've had Security plus cert and I've taught CCNA mod 1 so I understand computers and basic network design decently enough but I don't feel like if I were to get dumped into the workforce tomorrow I'm viable. My tech education was a mile wide an inch deep so that I could manage techs whose education was an inch wide and a mile deep. Is this humble bundle the potential opportunity a godsend?

/r/Python
https://redd.it/7nmjf6
When should we avoid classes?

I like to read about cool python project blogs and articles. What I have noticed is that many python programmers uses classes even for small projects. Do we need to use classes for every python projects? Do python veterans recommend writing codes only with classes or we can avoid it?

/r/Python
https://redd.it/7nn912
Payment system for monthly subscriptions (SAAS application)

I'm currently building an SPA and wondering if anyone had some tips on the payment system.

* I plan on having monthly and annual plans, where annual plans are the same as monthly but reduced price.

* Using Stripe for payments

* It has a free tier and 3 paid tiers

* Ideally would be easy to change price plans and have that reflected on the billing page for the customer.

Would be nice to hear what packages you used, example models and any do's and don'ts for long-term success.


/r/django
https://redd.it/7nm7hc
Send javascript variables value to flask?

So I'm doing a school project and I have made a web game. I now need to send the score from that game to the backend, so it can be stored in my database. How do I do this?

I've been looking online but they all use forms/input boxes, whereas I need to be able to call a function automatically (not pressing a button) and have that function send it to flask.

Can anyone link me a decent tutorial that does it in the way I need?

cheers.

/r/flask
https://redd.it/7nq8gx
Google's official python tutorial violates PEP8, recommends python 2.4-2.6, and my university just assigned it to us.
https://developers.google.com/edu/python/set-up

/r/Python
https://redd.it/7nr322
Serial Programming [Help]

I tried to send data to a fingerprint sensor but the the write() method just returns different integers if I use different argument hex values.


>>> import serial
>>> ser = serial.Serial('/dev/ttyAMA0', baudrate=9600, timeout=0.5)
>>> ser.write('\x01')
1

The fingerprint doesn't seem to initialize. I tried checking it by cranking up the LED to see if the sensor is initialized, but the LED doesn't seem to work either.

/r/Python
https://redd.it/7ns474
Tkinter or pygame?

Hi everyone,

Currently creating my beginners game design class for 14-15 year old students. The school's IT team is struggling to install pygame and is contemplating giving me a set of *nix laptops as it is much easier to install pygame. However as I will be new at this school I don't want to get the IT team annoyed at me, I am thinking that maybe I should use tkinter instead. I only need to give my students a taste of python as we will be using game maker for the majority of the time ( as the next unit we will be exploring python in depth and will be using cloud 9 edu so I have full control over the environment they are using). My husband who is a professional python programmer hates tkinter (cites a bad experience when he was learning python as his reason) and feels that I should persist and ask for pygame. I haven't had an issue with tkinter but now I am second guessing my choice. Is using tkinter a suitable choice for creating a simple game?

/r/Python
https://redd.it/7nta74
Make python run like an app on terminal

Ok so Im having a really hard time describing what im trying to do but here goes.


So I want to make a countdown thingy. But I want it to do the following things:

1. Empty the screen (including the line that shows the user and the current directory on the terminal)
2. I want to output the the current number in the countdown and only the current number (i want to "erase" the previous number and have the current one appear on the same line)

Im having trouble doing these things because I don't know how to describe what I want to do in a way that I can google it. I don't need anyone to post the code to do those things here, I just need someone to kind of tell me what im trying to do in python terms I guess.

/r/Python
https://redd.it/7nt6vh
Django 2.0 giving Foriegn key constraint error when saving a custom user?

I'm learning how to make a custom user in django, so i followed the guide here : https://docs.djangoproject.com/en/2.0/topics/auth/customizing/

Near the end of the guide it shows a complete sample code on how to make a custom user. I made my own user using the guide and it works fine when i'm creating a superuser in terminal but it throws error when I try to add a new user through the admin.

The error says Integrity Error FOREIGN KEY constraint failed. I really don't understand it. At first I though I had made some mistake in the code so I made another test project and basically copy pasted the code available on the guide and it still throws this error.

Can someone guide me as to what is the reason? I tried looking for the source of error and have had no luck. Would really appreciate your help.

Thanks!

/r/djangolearning
https://redd.it/7ntilf
What is the ForeignObject field type?

So i'm working on some models for a new django project (I'm pretty new to django myself) and I'm wondering what the difference between using

some_field = models.ForeignObject(MyClass)

and this

some_field = models.ForeignKey(MyClass, on_delete=models.CASCADE)

**What are the pros and cons of one over the other?** I control+f'd for ForeignObject in the model documentation for django on their site and I can't seem to find any answers to the above question, and some google searching doesnt turn up any results for the specific term either.

Thoughts?

/r/django
https://redd.it/7nsnzn
Help with the Django Cache Framework

Hey everyone,

I'm wondering if someone could help me get to know the django cache framework for a (hopefully) simple task. I'm developing a [financial analysis application](https://join.lazyfa.com) and I would like to cache some portions of the first load of the page to be reused in other sections of the app. Here's the example I'm trying to figure out right now:

When a user sends a ticker through (e.g. AAPL) this is [the dashboard that pops up](https://imgur.com/GOWqPig). Some parts of that dashboard are done in the dashboard view. Others (for example company SIC, short %, float, profile, etc) are pulled from external sources via ajax calls and a few others (e.g. calculations like burn rate, averages, etc) are populated dynamically by making ajax calls to other views.

That part all works fine. The dashboard loads in a couple seconds and whatever doesn't load gets pulled in via AJAX as the user uses what's available.

Now when a user switches to the red flags > income statement section, I'd like to keep the entire company summary section (Overview, Company Information, Recent News) in cache so it doesn't have to be retrieved again. So in the dashboard view, after doing all the biz logic to return the context used in the ajax calls, I just set a cache key ('context') to the context and store it for some amount of time. For example, just storing it for 60 seconds:

# Do stuff to set all these dicts and stuff that's used on the dashboard, then...

template = 'dashboard.html'
context = {
'ticker': ticker,
'companyInfo' : companyInfo,
'database' : database,
'annual_dict_most_recent' : annual_dict_most_recent,
'quarterly_dict_most_recent' : quarterly_dict_most_recent,
'ttm_dict_most_recent' : ttm_dict_most_recent,
'annual_dict_most_recent' : annual_dict_most_recent,
'quarterly_dict_most_recent' : quarterly_dict_most_recent,
'ttm_dict_most_recent' : ttm_dict_most_recent,
'INCOME_COLLECTION' : INCOME_COLLECTION,
'BALANCE_COLLECTION' : BALANCE_COLLECTION,
'CASHFLOW_COLLECTION' : CASHFLOW_COLLECTION,
'METRICS_COLLECTION' : METRICS_COLLECTION,
'INCOME_Q_COLLECTION' : INCOME_Q_COLLECTION,
'BALANCE_Q_COLLECTION' : BALANCE_Q_COLLECTION,
'CASHFLOW_Q_COLLECTION' : CASHFLOW_Q_COLLECTION,
'METRICS_Q_COLLECTION' : METRICS_Q_COLLECTION,
'jsonTickerList' : jsonTickerList,
}
cache.set('context', context, 60)

return render(request, template, context)

Then when a user clicks the income statement link, I can do this in the relevant view:

context = cache.get('context')
template = 'income.html'
return render(request, template, context)

That works perfectly and loads the whole company summary section from cache, but there's a slight problem: If a user searches for a ticker, then opens a new tab and searches for a new ticker (e.g. TSLA), the cache is overwritten because of the new dashboard load, so if they go back to their previous tab with the dashboard for AAPL on it, when they click the income statement link it will load the company summary for TSLA.

I understand why this is happening but I'm just not sure how to handle it cause I don't fully understand the capabilities of the caching framework or what the best way to handle this would be.

Could someone more familiar shed a bit of light on this for me? Thanks so much!








/r/django
https://redd.it/7nrt3y
[D] Results from Best of Machine Learning 2017 Survey

Results from

https://www.reddit.com/r/MachineLearning/comments/7mjxl4/d_vote_for_best_of_machine_learning_for_2017/

If you missed that thread and there's something you want to mention, post it and I'll put it up. Lots of categories didn't have an entry. You can also make a category yourself.

######**Best Video:**

aurelien geron's capsule networks explanation.

https://youtu.be/pPN8d0E3900

######**Best Blog post:**

Luke Okden-Rayner's criticism of ChestXray14 dataset.

https://lukeoakdenrayner.wordpress.com/2017/12/18/the-chestxray14-dataset-problems/amp/#click=https://t.co/52PSslbAh8

######**Best New Tool:**

Pytorch

"and we all realized what a pain in the ass Tensorflow was and how it didn't need to be that way. In the academic community, it certainly to me feels like pytorch has become the dominant framework (probably not backed up by actual stats... But my school's CV research lab has certainly switched over)"

######**Best Blog Overall:**

Ferenc Huszar's inference.vc

>
> I might have nominated distill.pub instead, but they (and I) consider themselves a journal, which puts them out of the running.
>
> Writing good blog posts is hard, and as such, I feel like it's fair to weight consistent posting. Signal to noise is the primary problem with following blogs (I'd much rather follow a blog that posts one great article a year than a blog that posts 12 articles a year of which 2 are great).
>
> Thus, I've found all of the articles I've read from Ferenc to be insightful.
>
> One other thing: I don't really expect "novel" insights out of blog posts. I think blog posts are best served as a distillation of the current state of research, and sometimes an explanation of ideas. If they have new insights, they'd prolly be writing a paper :)
>
> Some highlights (apologies if there are any highlights from the posts I haven't read):
>
> http://www.inference.vc/my-notes-on-the-numerics-of-gans/
>
> An insightful post into one of the problems GANs face in optimization, framed in the form of vector fields.
>
> http://www.inference.vc/design-patterns/
>
> Really unified and explained to me how all these different machine learning tasks are just optimizing over a loss surface and approximating gradients.
>
> There's a couple other blogs I think deserve honorable mentions, including Sebastian ruder's. I think I might write a meta blog post talking about these other blogs one day.

Runner up:

Berkeley AI Research blog.

http://bair.berkeley.edu/blog/


######**Best Papers:**

Tied

Deep Image Prior

https://dmitryulyanov.github.io/deep_image_prior

Quantile Regression for Distributional RL

https://arxiv.org/abs/1710.10044

######**Best Reddit Post:**

https://www.reddit.com/r/MachineLearning/comments/6l2esd/d_why_cant_you_guys_comment_your_fucking_code/


######**Best Reddit Project:**

https://www.reddit.com/r/MachineLearning/comments/72l4oi/pfinally_managed_to_paint_on_anime_sketch_with/?st=jbqezuqt&sh=a8aa336f

######**Best Course:**

New Andrew Ng deep learning coursera course

######**Best Youtube channel:**

3 way tie

3blue1brown

DanDoesData

2 minute papers

/r/MachineLearning
https://redd.it/7nrzhn