VocabReminder
Easily build a great vocabulary without studying! Now on the App Store!
Click here for more info about the app

Posts Tagged with "Python"

How to send email with Python, smtplib and Postmark

Here is a quick code snippet showing how to send email via SMTP with Postmark without any dependencies. It assumes you are using Heroku and have added...


Using Selenium to Drive Firefox Browser for Web Automation

There are a lot of practical uses for automating user behavior in a browser. Everything from testing your web application to logging into Twitter and...


Reshape an Array of Form Inputs for Flask with getlist()

This is how to reshape an array using Python without Numpy. This is a fairly simple task but it can be a little confusing to wrap your head around....


Trigrams, Bigrams and Ngrams in Python for Text Analysis

Creating trigrams in Python is very simple trigrams = lambda a: zip(a, a[1:], a[2:]) trigrams(('a', 'b', 'c', 'd', 'e', 'f')) # => [('a', 'b',...


How to Decorate Imported Libs in Python for Jinja Template Filters in Flask

To decorate an imported function in Python you would do something like this # in ./lib.py def function_name(): # function body And then in...


Get Method Name as String in Python

Here is how to get the string representation of a method in Python def my_method_name(): print "Hello World" my_method_name.__name__ #...


Destructuring Dictionaries in Python

Here is a quick and dirty way to destructure dictionaries in [Python] d = {'a':'Apple', 'b':'Banana','c':'Carrot'} a,b,c = [d[k] for k in ('a',...


How to Fix Pypi Upload failed (403): Invalid or non-existent authentication information.

If you run into authentication failure when trying to upload packages Submitting dist/ to https://upload.pypi.org/legacy/ Upload...


How to Create a Slug in Python with the Re Module

There are a few 3rd party modules that do this sort of thing. But there is a pretty solution using out of the box Python functionality. You don't have...


My First Python Package on PyPi - Command Line Blog

I wrote my first Python package over the weekend. It is a simple package that adds a basic blog API to an existing Flask application. It's called...


How To Get A Dict from Flask Request Form

You just call `to_dict` on the `request.form` object and you get a dictionary you can work with.


Python String Format Precision of Float

You can use string interpolation in combination with a dictionary for simple formatting. print "My name is %(name)s and I have $%(change)0.2f in...


How To Install Pyscopg2 Python Postgres Driver on Mac OSX with Homebrew, Postgres.app and VirtualEnv

You might have to append the path of the Postgres.app bin directory to your path in order to install the Python driver for Posgres. export PATH=$P...


How to Create A Unix Timestamp or the Epoch in Python

It's a little convoluted. Seeing as it's a pretty common thing you use when programming computers one might think that there would be a quick and easy...


How to Fix Line Wrap Bug in iPython Terminal on OS X Mavericks

There is annoying line wrap issue present after installing iPython on OS X Mavericks for the first time. The issue has to do with readline being missi...


Pretty Formatted JSON from the Command Line

Sometimes you want to see JSON from the command line. I'm sure there are better tools for the job, but here is a little snippet you can throw in your...


How to Create a Date Time Snippet in Sublime Text 2 (Dynamic Signature with Time Stamp)

You'll have to create a new plugin. From the menu bar select Tools > New Plugin Copy the Python script from the signature.py file. Remember to r...


Installing MatPlotLib on OS X for Python Version 2.6.1 with PIP and VirtualEnv

If you thought you had installed matplotlib only to find this File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-unive...


Mod_Python and Web.py on Ubuntu

Download First install mod_python for Apache and then restart/reload the server. apt-get install libapache2-mod-python /etc/init.d/apac...


SHA1 or MD5 Hashing in Python

import hashlib print hashlib.sha1("My wonderful string").hexdigest() print hashlib.md5("My other wonderful string").hexdigest()...


Dynamic Attributes in Python Model Class

class Bar(): def __init__(self, **args): for key in args: self.__dict__[key] = args[key] b = Bar(fullname="Monty Python...


Python Zlib Compress DeCompress

import zlib regular_string = 'this is my string' compressed_string = zlib.compress(regular_string) decompressed_string = zlib.decompress(compres...


Pickle Python Objects

import pickle entity = { "user_id": "1", "title": "Natural Dog Training", "link": "http://naturaldogtraining.com", } pickled_entity = pickle....


Install MySQLdb for Python on Mac OS X

I don't do much python development. I really like the language and there are a lot of great software projects out there for it. Tornado, for example,...


Why Doesn't Google Offer Dedicated Virtual Hosting?

AppEngine is nice, but it's a little limiting. No cron jobs, filesystem use nor customization with third party libraries, software, databases, languag...