python

How to specify native library search path for python

I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed. When I use the lxml module how do I tell it (python) where to find the correct version of the libxml2 shared library? ...

disable a block in django

I want to disable a block in development and use it in deployment in google apps in python development. What changes do i need to make in template or main script? ...

Is the pickling process deterministic?

Does Pickle always produce the same output for a certain input value? I suppose there could be a gotcha when pickling dictionaries that have the same contents but different insert/delete histories. My goal is to create a "signature" of function arguments, using Pickle and SHA1, for a memoize implementation. ...

Pythonic way to implement three similar integer range operators?

Hello SO! I am working on a circular problem. In this problem, we have objects that are put on a ring of size MAX, and are assigned IDs from (0 to MAX-1). I have three simple functions to test for range inclusions. inRange(i,j,k) tests if i is in the circular interval [j,k[ (Mnemonic is i inRange(j,k)). And I have the same for ranges ]...

UTF-8 problem in python when reading chars

I'm using Python 2.5. What is going on here? What have I misunderstood? How can I fix it? in.txt: Stäckövérfløw code.py #!/usr/bin/env python # -*- coding: utf-8 -*- print """Content-Type: text/plain; charset="UTF-8"\n""" f = open('in.txt','r') for line in f: print line for i in line: print i, f.close() output: Stäck...

Locale date formatting in Python

How do I get datetime.datetime.now() printed out in the native language? >>> session.deathDate.strftime("%a, %d %b %Y") 'Fri, 12 Jun 2009' I'd like to get the same result but in local language. ...

Django: How can I change a ModelForm's Many2ManyField (select tag) choices verbose values?

For example: I have the follow model class Categories(models.Model): name = models.CharField(max_length=100,verbose_name="Category Name") parent_cat = models.ForeignKey('self',verbose_name="Parent Category",null=True,blank=True,related_name="child_cat") description = models.TextField(verbose_name="Category Description",blan...

Python: How do I pass a variable by reference?

The Python documentation seems unclear about whether parameters are passed by reference or value, and the following code produces the unchanged value 'Original' class PassByReference: def __init__(self): self.variable = 'Original' self.Change(self.variable) print self.variable def Change(self, var): var = 'C...

What does this line mean in Python?

Which CPU information this code is trying to retrieve. This code is part of a larger package. I am not a Python programmer, and I want to convert this code to C#. from ctypes import c_uint, create_string_buffer, CFUNCTYPE, addressof CPUID = create_string_buffer("\x53\x31\xc0\x40\x0f\xa2\x5b\xc3") cpuinfo = CFUNCTYPE(c_uint)(addressof(CP...

Encrypted file or db in python

I have a sqlite3 db which i insert/select from in python. The app works great but i want to tweak it so no one can read from the DB without a password. How can i do this in python? note i have no idea where to start. ...

One stop resource for : Will it play in App Engine/Python?

Information on frameworks, languages, and libraries for GAE/J is maintained at : http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine Is there a similar page for GAE/Py? ...

Experiences of creating Social Network site in Django

I plan to sneak in some Python/Django to my workdays and a possible social network site project seems like a good possibility. Django itself seems excellent, but I am skeptical about the quality of large amount of Django apps that seem to be available. I would like to hear what kind of experiences you may have had with Django in creati...

Python thread exit code

Is there a way to tell if a thread has exited normally or because of an exception? ...

Using pysmbc to read files over samba

I am using the python-smbc library on Ubuntu to access a samba share. I can access the directory structure fine, I am however not sure how to access actual files and their content. The webpage (https://fedorahosted.org/pysmbc/) doesn't mention any thing, the code is in C/C++, with little documentation, so I am not quite sure how to use i...

How do I get a value node moved up to be an attribute of its parent node?

What do I need to change so the Name node under FieldRef is an attribute of FieldRef, and not a child node? Suds currently generates the following soap: <ns0:query> <ns0:Where> <ns0:Eq> <ns0:FieldRef> <ns0:Name>_ows_ID</ns0:Name> </ns0:FieldRef> <ns0:Value>66</ns0:Value> </ns0:Eq> </ns0:Where> </ns...

How can I change a user agent string programmatically?

I would like to write a program that changes my user agent string. How can I do this in Python? ...

adding a **kwarg to a class

class StatusForm(ModelForm): bases = forms.ModelMultipleChoiceField( queryset=Base.objects.all(), #this should get overwritten widget=forms.SelectMultiple, ) class Meta: model = HiringStatus exclude = ('company', 'date') def __init__(self, *args, **kwargs): super(StatusForm, self).__init__(*args, **kwargs) if kwarg...

orbited twisted installation problems

i am geting folloing error when i am trying to start orbited server C:\Python26\Scripts>orbited Traceback (most recent call last): File "C:\Python26\Scripts\orbited-script.py", line 8, in <module> load_entry_point('orbited==0.7.9', 'console_scripts', 'orbited')() File "C:\Python26\lib\site-packages\orbited-0.7.9-py2.6.egg\orbite...

Python's library support

Does Python seem to have greater library support than ruby? (For example, their OWL and RDF libraries seem much more developed. Is this true in general?) ...

How can I change a user agent string programmatically?

I want to write a program that changes the HTTP headers in my requests that are sent by my web-browser. I believe it can be done with a proxy server. So, I'd like to write a proxy server. How can I do this in Python? ...