Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# vim: set ft=python :
from __future__ import print_function
import json
import sys
import datetime
from redis import StrictRedis as Redis
r = Redis()
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")
try:
from app import models
from django.conf import settings
except:
print("\nCould not import Django modules.")
else:
print("\nImported Django modules.")
try:
from dateutil.parser import parse as parse_date
except ImportError:
print("\nCould not import dateutil.")
@Wilfred

This comment has been minimized.

Copy link

Wilfred commented Sep 11, 2014

Have you considered ipython? That would let you just typing in import dj then press up, and you can see all the previous imports you've done that start with that string.

If you install ipython, manage.py shell will use it automatically.

@dlo

This comment has been minimized.

Copy link
Owner Author

dlo commented Sep 11, 2014

@Wilfred Yep, I have (and I use ipython even with this .pythonrc). I say, why press up when it can be automatic?

@rmariano

This comment has been minimized.

Copy link

rmariano commented Dec 14, 2014

Very nice. I didn't know this either, and I agree with you on that it's easier and faster. Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.