Python Regular Expressions -part #13 - Word Boundaries
https://www.youtube.com/watch?v=WbtFUuFE9hg&feature=share
/r/Python
https://redd.it/6xbhhe
https://www.youtube.com/watch?v=WbtFUuFE9hg&feature=share
/r/Python
https://redd.it/6xbhhe
YouTube
Python Regular Expressions -part #13 - Word Boundaries
In this video series, we will be tackling Python Regular Expressions. This video goes over: 1) the concept of boundaries \b Don't forget to comment on what y...
[R] Transformer: A Novel Neural Network Architecture for Language Understanding
https://research.googleblog.com/2017/08/transformer-novel-neural-network.html
/r/MachineLearning
https://redd.it/6xao51
https://research.googleblog.com/2017/08/transformer-novel-neural-network.html
/r/MachineLearning
https://redd.it/6xao51
research.google
Transformer: A Novel Neural Network Architecture for Language Understanding
Posted by Jakob Uszkoreit, Software Engineer, Natural Language Understanding Neural networks, in particular recurrent neural networks (RNNs), are n...
Pycharm and Flask
Hi everyone! I wanted to learn flask for quite a time and decide now to dive into it. I’ve written some simple and small apps with VS Code and the terminal. Now I want to grew for the next step: Databases
I find it quite hard to get a grasp on it(where exactly to start, what do I have write for code, how do I set up a database etc.) but I noticed pyCharm has a flask and database integration.
So I opend my flask project in pyCharm and try run it (which of course not work because of the flask run command (I guess)).
Is there a way to get the project work with flask without setting a complete new flask project?
I use a virtualenv with flask and all modules installed. Also tried to google for an solution but everything is just about setting up a new project. ;(
Thanks for your help!
Edit: Thank you for the answers! The main error was a missing:
if __name__ == '__main__':
app.run()
/r/flask
https://redd.it/6x6vdy
Hi everyone! I wanted to learn flask for quite a time and decide now to dive into it. I’ve written some simple and small apps with VS Code and the terminal. Now I want to grew for the next step: Databases
I find it quite hard to get a grasp on it(where exactly to start, what do I have write for code, how do I set up a database etc.) but I noticed pyCharm has a flask and database integration.
So I opend my flask project in pyCharm and try run it (which of course not work because of the flask run command (I guess)).
Is there a way to get the project work with flask without setting a complete new flask project?
I use a virtualenv with flask and all modules installed. Also tried to google for an solution but everything is just about setting up a new project. ;(
Thanks for your help!
Edit: Thank you for the answers! The main error was a missing:
if __name__ == '__main__':
app.run()
/r/flask
https://redd.it/6x6vdy
reddit
Pycharm and Flask • r/flask
Hi everyone! I wanted to learn flask for quite a time and decide now to dive into it. I’ve written some simple and small apps with VS Code and...
Quickly review changed functions in your Python pull requests
https://github.com/blog/2424-quickly-review-changed-functions-in-your-python-pull-requests
/r/Python
https://redd.it/6xdmmv
https://github.com/blog/2424-quickly-review-changed-functions-in-your-python-pull-requests
/r/Python
https://redd.it/6xdmmv
GitHub
Quickly review changed functions in your Python pull requests
Last month, we released a new way to quickly review pull requests by listing the changed functions or methods in the pull request file finder. Now Python enthusiasts can quickly identify changed fu...
PyFiddle: a free lightweight Python IDE to run and share Python scripts with some nifty features
https://pyfiddle.io/
/r/Python
https://redd.it/6xdamk
https://pyfiddle.io/
/r/Python
https://redd.it/6xdamk
reddit
PyFiddle: a free lightweight Python IDE to run and... • r/Python
10 points and 0 comments so far on reddit
What data type is returned from request.form.get when applied to a html "date" input ?
/r/flask
https://redd.it/6x6bqx
/r/flask
https://redd.it/6x6bqx
reddit
What data type is returned from request.form.get when... • r/flask
1 points and 4 comments so far on reddit
The UK's National Health Service Picks Wagtail
https://wagtail.io/blog/nhs-picks-wagtail/
/r/django
https://redd.it/6xe11c
https://wagtail.io/blog/nhs-picks-wagtail/
/r/django
https://redd.it/6xe11c
Wagtail CMS
The NHS picks Wagtail | Wagtail CMS
NHS.uk will be running Wagtail from autumn 2017
new to class based views and have a question
I have a working app and am playing around with class based views and I want to add a check on agency_count in AgencyFullView. Here's my working views without the check:
class AgencyFullMixin(ContextMixin):
def get_context_data(self, pk, **kwargs):
context_data = super(AgencyFullMixin, self).get_context_data(**kwargs)
agency = Agencies.objects.filter(pk=pk)
context_data["agency"] = agency
agency_count = agency.count()
context_data["agency_count"] = agency_count
return context_data
class AgencyFullView(TemplateView, AgencyFullMixin):
template_name = 'myapp/agency_full.html'
def get_context_data(self, **kwargs):
context_data = super(AgencyFullView, self).get_context_data(**kwargs)
return context_data
What I want to do is add a check on the agency_count and if it's 0 direct to one template, if not, to another template. Basic stuff but I'm not quite sure how to do it here. I tried the following but I get "name 'agency_count' is not defined" error :
class AgencyFullView(TemplateView, AgencyFullMixin):
if agency_count == 0:
template_name = 'myapp/not_valid.html'
else:
template_name = 'myapp/agency_full.html'
def get_context_data(self, **kwargs):
context_data = super(AgencyFullView, self).get_context_data(**kwargs)
return context_data
/r/django
https://redd.it/6xht2k
I have a working app and am playing around with class based views and I want to add a check on agency_count in AgencyFullView. Here's my working views without the check:
class AgencyFullMixin(ContextMixin):
def get_context_data(self, pk, **kwargs):
context_data = super(AgencyFullMixin, self).get_context_data(**kwargs)
agency = Agencies.objects.filter(pk=pk)
context_data["agency"] = agency
agency_count = agency.count()
context_data["agency_count"] = agency_count
return context_data
class AgencyFullView(TemplateView, AgencyFullMixin):
template_name = 'myapp/agency_full.html'
def get_context_data(self, **kwargs):
context_data = super(AgencyFullView, self).get_context_data(**kwargs)
return context_data
What I want to do is add a check on the agency_count and if it's 0 direct to one template, if not, to another template. Basic stuff but I'm not quite sure how to do it here. I tried the following but I get "name 'agency_count' is not defined" error :
class AgencyFullView(TemplateView, AgencyFullMixin):
if agency_count == 0:
template_name = 'myapp/not_valid.html'
else:
template_name = 'myapp/agency_full.html'
def get_context_data(self, **kwargs):
context_data = super(AgencyFullView, self).get_context_data(**kwargs)
return context_data
/r/django
https://redd.it/6xht2k
reddit
new to class based views and have a question • r/django
I have a working app and am playing around with class based views and I want to add a check on agency_count in AgencyFullView. Here's my working...
How to Show Calculated Field in Django Admin
Let's say I have a model Invoice.
class Invoice(models.Model):
labor_hour_quantity = models.DecimalField(max_digits=9, decimal_places=1)
labor_descrip = models.TextField(blank=True)
labor_hour_cost = models.DecimalField(max_digits=9, decimal_places=2)
Within the model I have a property defined as such.
@property
def labor_total(self):
return self.labor_hour_quantity * self.labor_hour_cost
How do I get this displayed on Django Admin when I look at an invoice I create? Currently it doesn't even display a DecimalField or value of the return after saving the invoice.
/r/django
https://redd.it/6xigr3
Let's say I have a model Invoice.
class Invoice(models.Model):
labor_hour_quantity = models.DecimalField(max_digits=9, decimal_places=1)
labor_descrip = models.TextField(blank=True)
labor_hour_cost = models.DecimalField(max_digits=9, decimal_places=2)
Within the model I have a property defined as such.
@property
def labor_total(self):
return self.labor_hour_quantity * self.labor_hour_cost
How do I get this displayed on Django Admin when I look at an invoice I create? Currently it doesn't even display a DecimalField or value of the return after saving the invoice.
/r/django
https://redd.it/6xigr3
reddit
How to Show Calculated Field in Django Admin • r/django
Let's say I have a model Invoice. class Invoice(models.Model): labor_hour_quantity = models.DecimalField(max_digits=9, ...
Flask-mail adding data to email
Hello again guys i have a invoice that im generating but in that invoice i want to add data from database how can i add that data to a template to be send as a email, i am using render_template() but how to make does values persist when that email is sent.
render_template('template.html', var='var')
In the template I'm calling
{{var}} # but it doesn't display the value of var in gmail
Thanks in advance.
/r/flask
https://redd.it/6xfvn7
Hello again guys i have a invoice that im generating but in that invoice i want to add data from database how can i add that data to a template to be send as a email, i am using render_template() but how to make does values persist when that email is sent.
render_template('template.html', var='var')
In the template I'm calling
{{var}} # but it doesn't display the value of var in gmail
Thanks in advance.
/r/flask
https://redd.it/6xfvn7
reddit
Flask-mail adding data to email • r/flask
Hello again guys i have a invoice that im generating but in that invoice i want to add data from database how can i add that data to a template to...
New to Python/Django; following the Tutorial but it seems to take issue with SQLite?
This tutorial: [Link]( https://docs.djangoproject.com/en/1.11/intro/tutorial02/ ) - I'm stuck right before "Introducing the Django Admin"
I created the database according to the instructions, and I used SQLite3 because it was recommended. I wanted MySQL, but alas, I chose SQLite, which seems to cause issues - now I believe the model/migration (?) does not contain the proper FOREIGN_KEY, so I cannot continue. How do I fix this?
manage.py sqlmigrate only shows the CREATE_TABLE commands, the foreign key was mentioned but it seems there was no constraint added alongside it, and as a result the choice_set does not exist (i.e., there's no Related Manager attached, according to Google).
Apparently constraints were disabled by default for SQLite3 (why would the tutorial recommend it and not mention that?) - but it was also supposedly fixed years ago ([Link](https://code.djangoproject.com/ticket/14204) and [Link 2](https://code.djangoproject.com/ticket/14204))
That is as far as googling got me. I have considerable programming experience, but none in Python/with Django, and so I am unable to find the solution on my own. Would anybody be willing to help?
/r/django
https://redd.it/6xg5ks
This tutorial: [Link]( https://docs.djangoproject.com/en/1.11/intro/tutorial02/ ) - I'm stuck right before "Introducing the Django Admin"
I created the database according to the instructions, and I used SQLite3 because it was recommended. I wanted MySQL, but alas, I chose SQLite, which seems to cause issues - now I believe the model/migration (?) does not contain the proper FOREIGN_KEY, so I cannot continue. How do I fix this?
manage.py sqlmigrate only shows the CREATE_TABLE commands, the foreign key was mentioned but it seems there was no constraint added alongside it, and as a result the choice_set does not exist (i.e., there's no Related Manager attached, according to Google).
Apparently constraints were disabled by default for SQLite3 (why would the tutorial recommend it and not mention that?) - but it was also supposedly fixed years ago ([Link](https://code.djangoproject.com/ticket/14204) and [Link 2](https://code.djangoproject.com/ticket/14204))
That is as far as googling got me. I have considerable programming experience, but none in Python/with Django, and so I am unable to find the solution on my own. Would anybody be willing to help?
/r/django
https://redd.it/6xg5ks
Help me understand get_object_or_404 better
Hey folks,
I have a couple of FBVs in a couple of learning projects, where I have get_object_or_404() functions, and I'd like to understand it better where it takes the argument from.
Does it always get the argument from the url pattern? I guess I think about url patterns as just a slug definer, and not as part of the core code.
This one adds a picture to a given project:
FBV:
> @login_required
def adicionar_post_ao_projeto(request, pk):
projeto = get_object_or_404(Projeto, pk=pk)
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.projeto = projeto
post.user = request.user
post.save()
return redirect('posts:single', pk=post.pk)
else:
form = PostForm()
return render(request, 'post_form.html', {'form': form})
URL pattern:
> url(r"(?P<pk>\d+)/novafoto$",views.adicionar_post_ao_projeto,name="adicionar_foto_ao_projeto"),
Sorry if my logic thinking here is not clear enough.
/r/django
https://redd.it/6xf116
Hey folks,
I have a couple of FBVs in a couple of learning projects, where I have get_object_or_404() functions, and I'd like to understand it better where it takes the argument from.
Does it always get the argument from the url pattern? I guess I think about url patterns as just a slug definer, and not as part of the core code.
This one adds a picture to a given project:
FBV:
> @login_required
def adicionar_post_ao_projeto(request, pk):
projeto = get_object_or_404(Projeto, pk=pk)
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.projeto = projeto
post.user = request.user
post.save()
return redirect('posts:single', pk=post.pk)
else:
form = PostForm()
return render(request, 'post_form.html', {'form': form})
URL pattern:
> url(r"(?P<pk>\d+)/novafoto$",views.adicionar_post_ao_projeto,name="adicionar_foto_ao_projeto"),
Sorry if my logic thinking here is not clear enough.
/r/django
https://redd.it/6xf116
reddit
Help me understand get_object_or_404 better • r/django
Hey folks, I have a couple of FBVs in a couple of learning projects, where I have get_object_or_404() functions, and I'd like to understand it...
Exploiting misuse of Python's "pickle"
https://blog.nelhage.com/2011/03/exploiting-pickle/
/r/Python
https://redd.it/6xgd5a
https://blog.nelhage.com/2011/03/exploiting-pickle/
/r/Python
https://redd.it/6xgd5a
reddit
Exploiting misuse of Python's "pickle" • r/Python
168 points and 18 comments so far on reddit
Raymond Hettinger, Keynote on Concurrency, PyBay 2017
https://www.youtube.com/watch?v=9zinZmE3Ogk
/r/Python
https://redd.it/6xkvaz
https://www.youtube.com/watch?v=9zinZmE3Ogk
/r/Python
https://redd.it/6xkvaz
YouTube
Raymond Hettinger, Keynote on Concurrency, PyBay 2017
Keynote for https://pybay.com, 2nd annual Regional Python Conference in SF.
Slides: http://pybay.com/site_media/slides/raymond2017-keynote/index.html
Slides: http://pybay.com/site_media/slides/raymond2017-keynote/index.html
What is the best python implementation to optimize a lot of gridsearch iterations?
Hello,
I have a small dataset that needs to be trained using different ML algorithm. Also those algorithms need to be tuned using gridsearch. In native python running the script can take up to a day.
I need to choose the environment that will be best fit to run such a task.
What would be your suggestion? Native Python, Pyspark or some different implementation of python? Maybe splitting the tasks?
/r/Python
https://redd.it/6xkeq0
Hello,
I have a small dataset that needs to be trained using different ML algorithm. Also those algorithms need to be tuned using gridsearch. In native python running the script can take up to a day.
I need to choose the environment that will be best fit to run such a task.
What would be your suggestion? Native Python, Pyspark or some different implementation of python? Maybe splitting the tasks?
/r/Python
https://redd.it/6xkeq0
reddit
What is the best python implementation to optimize a... • r/Python
Hello, I have a small dataset that needs to be trained using different ML algorithm. Also those algorithms need to be tuned using gridsearch. In...
pyvips 1.0 released: fast, low memory use image handling for all Python runtimes
pyvips 1.0 has just been released:
https://jcupitt.github.io/libvips/2017/09/01/libvips-for-Python.html
It's a binding for the libvips image processing library. On this benchmark at least, pyvips is more than 4x faster than Pillow-SIMD and needs less than 1/4 of the memory:
https://github.com/jcupitt/libvips/wiki/Speed-and-memory-use
libvips has included a Python binding for a long time, but it's been very annoying to install and has had limited documentation.
This new binding is based on cffi, so as long as you can get the libvips shared library on to your system (via apt, yum, homebrew, or a download of the win binary), it's just "pip install pyvips". There are dynamic docs with help(), and also full on-line docs:
https://jcupitt.github.io/pyvips/
/r/Python
https://redd.it/6xldgs
pyvips 1.0 has just been released:
https://jcupitt.github.io/libvips/2017/09/01/libvips-for-Python.html
It's a binding for the libvips image processing library. On this benchmark at least, pyvips is more than 4x faster than Pillow-SIMD and needs less than 1/4 of the memory:
https://github.com/jcupitt/libvips/wiki/Speed-and-memory-use
libvips has included a Python binding for a long time, but it's been very annoying to install and has had limited documentation.
This new binding is based on cffi, so as long as you can get the libvips shared library on to your system (via apt, yum, homebrew, or a download of the win binary), it's just "pip install pyvips". There are dynamic docs with help(), and also full on-line docs:
https://jcupitt.github.io/pyvips/
/r/Python
https://redd.it/6xldgs
jcupitt.github.io
libvips for Python
A fast image processing library with low memory needs.
0–100 in Django: The Perfect Environment
https://medium.com/@jeremytiki/0-100-in-django-the-perfect-environment-a906827028fc
/r/django
https://redd.it/6xh24k
https://medium.com/@jeremytiki/0-100-in-django-the-perfect-environment-a906827028fc
/r/django
https://redd.it/6xh24k
Medium
0–100 in Django: The Perfect Environment
If you have worked with Django for any amount of time you have probably seen many articles about how to setup your development environment…