a friend of mine wrote this little progam.
the textFile is 1.2GB in size (7 years worth of newspapers).
He successfully manages to create the dictionary but he cannot write it to a file using pickle(program hangs).
import sys
import string
import cPickle as pickle
biGramDict = {}
textFile = open(str(sys.argv[1]), 'r')
biGramDictFile =...
<example>
<login>
<id>1</id>
<username>kites</username>
<password>kites</password>
</login>
</example>
How can i update password using lxml?
and now can i add one more record to the same file?
please provide me a sample code
...
hi..
can anyone explain me steps using openid library which is mentioned here.
i have import all package of janrain openid in my programe but i cant understand actual flow of code.
The process should basically follow this plan:
Add an OpenID login field somewhere on your site. When an OpenID is entered in that field and the form is su...
Pylint gives me an error like this very frequently.
shabda@jazzy ~/uswaretech_uswaretechsite> pylint -e utpages/forms.py
No config file found, using default configuration
Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in <type 'exceptions.RuntimeError'> ignored
The logalib mailing list discuss...
I got strange error message when tried to save first_name, last_name to Django's auth_user model.
Failed examples
user = User.object.create_user(username, email, password)
user.first_name = u'Rytis'
user.last_name = u'Slatkevičius'
user.save()
>>> Incorrect string value: '\xC4\x8Dius' for column 'last_name' at row 104
user.first_name ...
Does anyone know of a library - ideally Python, that can have a stab at pulling dates out of text?
"Shall we go to the library today" -> 21 Jan 10
"Starting on the 1st of January" -> 1 Jan 10
"Anytime between 3nd and 5th of Feb 2009" -> 3 Feb 09, 5 Feb 09
It's a tough problem and probably why I havn't found anything!
Already using N...
I've just recently switched over to using 64-bit Python 2.6.1 on Mac OS X 10.6 (Snow Leopard). IPython won't work with Django anymore, but IPython works from the command-line.
The error says:
shell = IPython.Shell.IPShell(argv=[])
AttributeError: 'module' object has no attribute 'Shell'
I could use the ./manage.py --plain option...
I'm trying to create a very large image (25000x25000) by pasting together many smaller images. Upon calling Image.new() with such large dimensions, python runs out of memory and I get a MemoryError.
Is there a way to write out an image like this incrementally, without having the whole thing resident in RAM?
EDIT:
Using ImageMagick's m...
So I'm representing a token ring network (doing the simulation in SimPy), I'm a totally newbie to matplotlib, but I was told that it'd be really good for representing my simulation visually.
So I googled around and found out how to draw shapes and lines - using add_patch and add_line respectively to the axes (I believe). So now I have t...
Hi,
I'm using the contenttypes framework to create a "featured content" feature on my site. I've basically done this by defining a model like so:
class FeaturedContent(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_ty...
Hey,
I want to model the following situation. I have a table of items, and a table of players, and a player can have many items and have multiple copies of the same item. I can easily model the player having multiple items:
class Item(models.Model):
name = models.CharField(max_length = 200, blank = False)
class Player(models.Model...
I need to rename a whole heap of files on a Windows file server - I don't mind what language I use really as long it's quick and easy!
I know it's basic but just to clarify - in pseudo-code...
server = login (fileserver, creds)
foreach (file in server.navigateToDir(dir))
rename(file)
I know how to do this in Python/C# if I was a...
So I have a huge list of entries in a DB (MySql)
I'm using Python and Django in the creation of my web application.
This is the base Django model I'm using:
class DJ(models.Model):
alias = models.CharField(max_length=255)
#other fields...
In my DB I have now duplicates
eg. Above & Beyond, Above and Beyond, Above Beyond, ...
Simple question. I have bunch of django views. Is there a way to tell django that for each view, use foo(view) instead? Example:
Instead of writing
@foo
@bar
@baz
def view(request):
# do something
all the time, I'd like to have
def view(request):
markers = ['some', 'markers']
and hook this into django:
for view in all_the...
Hi folk,
I'm using django-haystack at the moment
with apache-solr as the backend.
Problem is I cannot get the app to perform the search functionality I'm looking for
Searching for sub-parts in a word
eg. Searching for "buntu" does not give me "ubuntu"
Searching for similar words
eg. Searching for "ubantu" would give "ubuntu...
I put
print 'Hello world!'
into __init__.py in my django project. When I run ./manage.py runserver now, I get
gruszczy@gruszczy-laptop:~/Programy/project$ ./manage.py runserver
Hello world!
Hello world!
Validating models...
0 errors found
Why is __init__.py run twice? It should be loaded only once.
...
So I've finally successfully installed PIL (after many difficulties) on RHEL5 with Django (development version) and Python 2.6 installed at /opt/python2.6.
Running selftest.py shows that everything appears to be installed correctly:
$ python2.6 selftest.py
57 tests passed.
I can upload .png files and .gif files without difficulties,...
I am trying to use the zipfile module in Python to create simple zip files:
import zipfile
files = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
zip_file_name = 'zipfile_test.zip'
zfh = zipfile.ZipFile(zip_file_name, 'w')
for file in files:
print 'Archiving file %s' % file
zfh.write(zip_file_name)
zfh.close()
The files a-h are in my ...
I have this code:
def GetSteamAccts(): #Get list of steam logins on this computer.
templist = []
Steamapp_Folders = ["C:\\Program Files (x86)\\Steam\\steamapps\\", "C:\\Program Files\\Steam\\steamapps\\"] #Check both of these directories.
for SF_i in range(len(Steamapp_Folders)):
if os.path.exists(Steamapp_Folders[SF...
Hello,
I have a test suite and I am trying to get it to work with the tests I have created. The test work if I run them individually but I want to run them all in a test suite. The code below show the test suite created:
import unittest
def suite():
modules_to_test = ('TestAbsoluteMove', 'TestContinuousMove') # and so on
allte...