This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xml.etree import ElementTree as ET | |
import urllib | |
dbpedia_endpoint = "http://dbpedia.org/sparql?" | |
ns = {'ns': '{http://www.w3.org/2005/sparql-results#}'} | |
result_xpath ='%(ns)sresults/%(ns)sresult/%(ns)sbinding/%(ns)sliteral' % ns | |
def wikipedia_abstract_from_dbpedia(dbpedia_key): | |
sparql = """ | |
SELECT ?abstract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class x(object): | |
... def __call__(self): | |
... print "Hello, World!" | |
... | |
>>> x() | |
<__main__.x object at 0x9a5a1ac> | |
>>> x()() | |
Hello, World! | |
>>> type(x) | |
<type 'type'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====================================================== | |
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10 | |
====================================================== | |
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu | |
8.10. The article is targeted at a production environment, but keep in mind | |
this is a more generalized environment. You may have different requirements, | |
but this article should at least provide the stepping stones. | |
The article will use distribution packages where nesscary. As of 8.10 the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
................................................................................S..............F.F.. | |
====================================================================== | |
FAIL: Test that object's __del__ methods are called on exit. | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/usr/local/lib/python2.6/dist-packages/nose/case.py", line 183, in runTest | |
self.test(*self.arg) | |
File "/home/ub/Downloads/ipython-0.11.bzr.r1340-py2.6.egg_FILES/IPython/testing/decorators.py", line 225, in skipper_func | |
return f(*args, **kwargs) | |
File "/home/ub/Downloads/ipython-0.11.bzr.r1340-py2.6.egg_FILES/IPython/core/tests/test_run.py", line 160, in test_obj_del |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
********************************************************************** | |
IPython test group: IPython.config | |
/usr/local/lib/python2.6/dist-packages/nose/plugins/manager.py:391: UserWarning: Module pkg_resources was already imported from /usr/lib/python2.6/dist-packages/pkg_resources.pyc, but /usr/local/lib/python2.6/dist-packages is being added to sys.path | |
import pkg_resources | |
/usr/local/lib/python2.6/dist-packages/nose/plugins/manager.py:391: UserWarning: Module site was already imported from /usr/lib/python2.6/site.pyc, but /usr/local/lib/python2.6/dist-packages is being added to sys.path | |
import pkg_resources | |
.......... | |
---------------------------------------------------------------------- | |
Ran 10 tests in 0.013s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<QueryDict: {u'genericcontentblock_set-10-content': [u''], u'genericcontentblock_set-11-title': [u''], u'page_title': [u''], u'genericcontentblock_set-0-title': [u'adasdasd'], u'genericcontentblock_set-11-content': [u''], u'genericcontentblock_set-3-content': [u''], u'genericcontentblock_set-1-data': [u'dsadasdasd'], u'genericcontentblock_set-4-data': [u'Madhapur, Hyderabad'], u'genericcontentblock_set-8-id': [u'307'], u'genericcontentblock_set-1-id': [u'300'], u'genericcontentblock_set-5-data': [u'hyderabad'], u'genericcontentblock_set-4-revision': [u'286'], u'genericcontentblock_set-0-content': [u''], u'genericcontentblock_set-1-content': [u''], u'genericcontentblock_set-5-title': [u''], u'genericcontentblock_set-6-id': [u'305'], u'genericcontentblock_set-4-content': [u''], u'genericcontentblock_set-2-id': [u'301'], u'genericcontentblock_set-11-id': [u''], u'genericcontentblock_set-9-content': [u''], u'genericcontentblock_set-7-title': [u''], u'genericcontentblock_set-INITIAL_FORMS': [u'9'], u'genericconten |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render_to_response | |
from django.template.context import RequestContext | |
def eb_render(request, *args, **kwargs): | |
""" | |
Replacement for render_to_response that uses RequestContext and sets an | |
extra template variable, TEMPLATE_NAME. | |
""" | |
kwargs['context_instance'] = RequestContext(request) | |
return render_to_response(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(request, template_name, args=None, kwargs=None): | |
context = dict([ (var, locals()[var]) for var in args ]) if args else {} | |
context.update(kwargs) if kwargs else pass | |
return render_to_response(template_name,context,RequestContext(request)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(): | |
def __new__(cls,i): | |
class C(cls,B): | |
pass | |
print C | |
self = C() | |
print self | |
return self | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ids = ['4153869960', | |
'4160152863', | |
'4165131655', | |
'4164906099', | |
'4165892330', | |
'4165146115'] | |
import urllib | |
import json |