-
Notifications
You must be signed in to change notification settings - Fork 0
/
2010-02-20-django-ipython.html
201 lines (197 loc) · 14.2 KB
/
2010-02-20-django-ipython.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dimitris Glezos' Personal website</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="pragma" content="cache">
<meta http-equiv="cache-control" content="cache">
<meta http-equiv="vary" content="content-language">
<meta http-equiv="Cache-control" content="max-age=2592000, public">
<meta http-equiv="content-style-type" content="text/css">
<link rel="stylesheet" type="text/css" href="http://dimitris.glezos.com/theme/css/screen.css">
<link rel="stylesheet" type="text/css" href="http://dimitris.glezos.com/theme/css/highlight.css">
<link rel="stylesheet" type="text/css" href="http://dimitris.glezos.com/theme/css/custom.css">
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400" />
<link rel="publisher" href="">
<link rel="apple-touch-startup-image" href="http://dimitris.glezos.com/theme/images/logo.png">
<link type="text/plain" rel="socialmedia" href="http://dimitris.glezos.com/socialmedia.txt">
<link rel="dns-prefetch" href="http://dimitris.glezos.com"/>
<link rel="dns-prefetch" href="//www.gstatic.com"/>
<link rel="dns-prefetch" href="//fonts.gstatic.com"/>
<link rel="dns-prefetch" href="//fonts.googleapis.com"/>
<link rel="dns-prefetch" href="//accounts.google.com"/>
<link rel="dns-prefetch" href="//ssl.google-analytics.com"/>
<link rel="dns-prefetch" href="//www.google-analytics.com"/>
<link rel="dns-prefetch" href="//googleads.g.doubleclick.net"/>
<link rel="dns-prefetch" href="//pagead2.googlesyndication.com"/>
<link rel="dns-prefetch" href="//twemoji.maxcdn.com"/>
<link rel="dns-prefetch" href="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"/>
<link rel="dns-prefetch" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400"/>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="application-name" content="Dimitris Glezos' Personal website"/>
<meta name="msapplication-starturl" content="http:http://dimitris.glezos.com"/>
<meta name="msapplication-tooltip" content=""/>
<meta name="msapplication-window" content="width=1024;height=768"/>
<meta name="msapplication-task" content="name=Dimitris Glezos' Personal website;action-uri=http:http://dimitris.glezos.com;icon-uri=http://dimitris.glezos.com/theme/images/favicon.ico"/>
<meta name="msapplication-TileImage" content="http://dimitris.glezos.com/theme/images/apple-touch-icon-144x144.png"/>
<meta name="msapplication-TileColor" content="#1F1F21"/>
<meta name="application-name" content="Dimitris Glezos' Personal website">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="google-site-verification" content="">
<meta name="alexaVerifyID" content=""/>
<meta name="wot-verification" content=""/>
<meta name="msvalidate.01" content="" />
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="medium" content="mult">
<meta name="adblock" content="disable">
<meta name="rating" content="General">
<meta name="resource-type" content="document">
<meta name="revisit-after" content="1 days">
<meta name="revisit" content="1">
<meta name="robots" content="index,follow">
<meta name="no-email-collection" content="http://www.unspam.com/noemailcollection/">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@">
<meta property="og:site_name" content="Dimitris Glezos' Personal website">
<meta property="og:locale" content="en">
<link rel="canonical" href="http://dimitris.glezos.com/2010-02-20-django-ipython.html">
<meta property="og:type" content="article">
<meta property="og:title" content="Dropping to ipython from Django">
<meta property="og:url" content="2010-02-20-django-ipython.html">
<meta property="og:description" content="Today I wanted to debug some of our unit tests, so I wanted to drop to a shell from inside a test case. Here's how that can be done: import IPython IPython.embed() In previous versions this used to be: from IPython.Shell import IPShellEmbed ipython = IPShellEmbed() ipython() The ...">
<meta property="article:published_time" content="Saturday, February 20, 2010">
<meta name="twitter:title" content="Dropping to ipython from Django">
<meta name="twitter:description" content="Today I wanted to debug some of our unit tests, so I wanted to drop to a shell from inside a test case. Here's how that can be done: import IPython IPython.embed() In previous versions this used to be: from IPython.Shell import IPShellEmbed ipython = IPShellEmbed() ipython() The ...">
<meta name="description" content="Today I wanted to debug some of our unit tests, so I wanted to drop to a shell from inside a test case. Here's how that can be done: import IPython IPython.embed() In previous versions this used to be: from IPython.Shell import IPShellEmbed ipython = IPShellEmbed() ipython() The ...">
<meta name="twitter:creator" content="@">
<meta property="og:image" content="http://dimitris.glezos.com/theme/images/logo.png">
<meta name="twitter:image" content="http://dimitris.glezos.com/theme/images/logo.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="300">
<meta property="og:image:height" content="300">
<meta property="article:section" content="text">
<meta property="article:tag" content="django">
<meta property="article:tag" content="ipython">
<meta property="article:tag" content="tip">
<meta property="article:author" content="glezos-blog">
<script type="text/javascript">(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', '', 'auto');ga('send', 'pageview');var _qevents = _qevents || [];setTimeout(function() { window.onscroll = function() { window.onscroll = null;
ga('send','event','Ajuste de Tasa de Rebote','Scroll despues de 5 segundos');}}, 5000);</script>
<script src="//twemoji.maxcdn.com/twemoji.min.js"></script>
</head>
<body class="post-template nav-closed" itemscope itemtype="http://schema.org/WebPage">
<meta itemprop="name" content="Dimitris Glezos' Personal website">
<meta itemprop="url" content="http://dimitris.glezos.com">
<meta itemprop="headline" content="Dimitris Glezos' Personal website || ">
<meta itemprop="description about" content="">
<meta itemprop="keywords" content="">
<meta itemprop="inLanguage" content="en">
<nav class="nav">
<h3 class="nav-title">Menu</h3>
<a href="#" class="nav-close">
<span class="hidden">Close</span>
</a>
<ul role="menubar">
<li class="" role="presentation"><a href="http://dimitris.glezos.com/index.html" title="Dimitris Glezos' Personal website" itemprop="name" itemprop="significantLink">Home</a></li>
<li role="presentation"><a href="http://www.transifex.com/" title="Transifex" itemprop="name" itemprop="significantLink">Transifex</a></li>
<li role="presentation"><a href="old" title="My really old website" itemprop="name" itemprop="significantLink">My really old website</a></li>
<li class="" role="presentation"><a href="http://dimitris.glezos.com/archives.html" title="Dimitris Glezos' Personal website | Archives" itemprop="name" itemprop="significantLink">Archives</a></li>
</ul>
</nav>
<span class="nav-cover"></span> <div class="site-wrapper">
<header class="main-header post-head" style="background-image: url('http://dimitris.glezos.com/');" itemscope itemtype="http://schema.org/WPHeader">
<div class="vertical">
<div class="main-header-content inner">
<h1 class="page-title" itemprop="headline">Dropping to ipython from Django</h1>
<section class="post-meta">
<time class="post-date" itemprop="datePublished" datetime="2010YYY-50M-%DD">Saturday, February 20, 2010</time>
on <a href="tag/django.html">Django, </a><a href="tag/ipython.html">Ipython, </a><a href="tag/tip.html">Tip</a> </section>
</div>
</div>
<nav class="main-nav overlay clearfix">
<a class="menu-button" href="#">
<span class="burger">☰</span>
<span class="word">Menu</span>
</a>
</nav>
<div class="vertical">
<div class="main-header-content inner">
</div>
</div>
</header>
<main id="content" class="content" role="main">
<article class="post" itemscope="" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
<!-- <header class="post-header">
<h1 class="post-title" itemprop="headline">Dropping to ipython from Django</h1>
<section class="post-meta">
<time class="post-date" itemprop="datePublished" datetime="2010YYY-50M-%DD">Saturday, February 20, 2010</time>
on <a href="tag/django.html">Django, </a><a href="tag/ipython.html">Ipython, </a><a href="tag/tip.html">Tip</a> </section>
</header>-->
<section class="post-content">
<p>Today I wanted to debug some of our unit tests, so I wanted to drop to a shell from inside a test case. Here's how that can be done:</p>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">IPython</span>
<span class="n">IPython</span><span class="o">.</span><span class="n">embed</span><span class="p">()</span>
</pre></div>
<p>In previous versions this used to be:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.Shell</span> <span class="kn">import</span> <span class="n">IPShellEmbed</span>
<span class="n">ipython</span> <span class="o">=</span> <span class="n">IPShellEmbed</span><span class="p">()</span>
<span class="n">ipython</span><span class="p">()</span>
</pre></div>
<p>The first two lines go somewhere in your module and the latter wherever you want to hook up with the shell (tests, models, views). This can serve as a more rich alternative to <code>ipdb.set_trace()</code>.</p>
<p style="text-align: center;"><img src="http://media.tumblr.com/tumblr_ky5odtAqpB1qati3p.jpg" alt="handy" /></p>
<br/>
</section>
<footer class="post-footer">
<figure class="author-image">
<a class="img" href="author/glezos-blog.html" style="background-image: url('/theme/glezos_portrait_square.jpg')"><span class="hidden">glezos-blog's Picture</span></a>
</figure>
<section class="author">
<h4>
<a href="author/glezos-blog.html">glezos-blog</a>
</h4>
<p></p>
<div class="author-meta">
<span class="author-location icon-location"></span>
</div>
</section>
<section class="share">
<h4>Share this post</h4>
<a class="icon-twitter" href="https://twitter.com/share?text=Dropping%20to%20ipython%20from%20Django%20via%20%40&url=http://dimitris.glezos.com/2010-02-20-django-ipython.html" onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
<span class="hidden">Twitter</span>
</a>
<a class="icon-facebook" href="https://www.facebook.com/sharer/sharer.php?u=http://dimitris.glezos.com/2010-02-20-django-ipython.html" onclick="window.open(this.href, 'facebook-share','width=580,height=296');return false;">
<span class="hidden">Facebook</span>
</a>
<a class="icon-google-plus" href="https://plus.google.com/share?url=http://dimitris.glezos.com/2010-02-20-django-ipython.html" onclick="window.open(this.href, 'google-plus-share', 'width=490,height=530');return false;">
<span class="hidden">Google+</span>
</a>
</section>
</footer>
</article>
</main>
<aside class="read-next">
</aside> <footer class="site-footer clearfix" role="contentinfo" itemscope itemtype="http://schema.org/WPFooter">
<!--
<section class="copyright">
<a itemprop="url" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">
CC Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
</section>
-->
<section class="poweredby">
Proudly published with
<a itemprop="url" href="https://getpelican.org" target="_blank">Pelican</a>
</section>
</footer>
</div>
<script type="text/javascript" src="http://dimitris.glezos.com/theme/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="http://dimitris.glezos.com/theme/js/jquery.fitvids.min.js"></script>
<script type="text/javascript" src="http://dimitris.glezos.com/theme/js/index.min.js"></script>
<script>twemoji.parse(document, {"size":16});</script>
</body>
</html>