I have a list which has repeating items and I want a list of the unique items with their frequency.
For example, I have ['a', 'a', 'b', 'b', 'b'], and I want [('a', 2), ('b', 3)]
Looking for a simple way to do this without looping twice.
...
I need to set properties related to Remote Desktop Services on Active Directory users in .NET (i.e., via System.DirectoryServices), but I can't see that these properties are exposed by the API? I know there is a COM interface for this purpose, IADsTSUserEx. Please show me how I can get at these properties in .NET :) Bear in mind that the...
Where do I find the full JID value after connecting and authenticating against a Jabber server when using the xmpppy library?
I need the full JID for a subsequent Iq call to the server. Specifying the bare JID ([email protected]) results in the following error:
If set, the 'from' attribute must be set to the user's full JID
I have ...
I'm running Ubuntu to compile a set of code which requires python 2.4.
How can I setup a terminal launcher so that when I open that launcher all python related commands will use python 2.4 instead of the python 2.6 that is defaulted in Ubuntu?
...
I have a .py file with lots of classes:
class First(Second):
#code
class Third(Fourth):
#code
Is it possible to sort the definitions by class name in vim?
...
I have a for loop which references a dictionary and prints out the value associated with the key. Code is below:
for i in data:
if i in dict:
print dict[i],
How would i format the output so a new line is created every 60 characters? and with the character count along the side for example:
0001
MRQLLLISDLDNTWVGDQQALEH...
Hi,
I've been reading on the django docs about the comments framework and how to customize it (http://docs.djangoproject.com/en/1.1/ref/contrib/comments/custom/)
In that page, it shows how to add new fields to a form. But what I want to do is to remove unnecesary fields, like URL, email (amongst other minor mods.)
On that same doc page ...
I found a suggestion on a Stack Overflow topic about problems beginners should do to learn a new language. A user posted a very nice list of problems from Beginner to advanced that should help you get to know a language. One of the problems is to create a phone book, with random phone numbers and random people on the phone book, and a us...
I'm trying to find examples of PyGTKSpell usage. Googling isn't turning much up. Where can I find some?
...
I have a web scraping script that gets new data once every minute, but over the course of a couple of days, the script ends up using 200mb or more of memory, and I found out it's because mechanize is keeping an infinite browser history for the .back() function to use.
I have looked in the docstrings, and I found the clear_history() func...
What is the pythonic way of iterating simultaneously over two lists?
Suppose I want to compare two files line by line (compare each ith line in one file with the ith line of the other file), I would want to do something like this:
file1 = csv.reader(open(filename1),...)
file2 = csv.reader(open(filename2),...)
for line1 in file1 and li...
I'm trying to find a good "python GUI framework" for Mac OS X, but I haven't found anything good until now, only wxWidgets which I don't like and it's also unstable.
Any suggestions?
...
Is there a library for Python that will allow me to parse c++ code?
For example, let's say I want to parse some c++ code and find the names of all classes and their member functions/variables.
I can think of a few ways to hack it together using regular expressions, but if there is an existing library it would be more helpful.
...
My code worked fine when it was all in one file. Now, I'm splitting up classes into different modules. The modules have been given the same name as the classes. Perhaps this is a problem, because MainPage is failing when it is loaded. Does it think that I'm trying to inherit from a module? Can module/class namespace collisions happen?
M...
I have the following code:
import string
import random
d =[random.choice(string.uppercase) for x in xrange(3355)]
s = "".join(d)
print s
At the moment it prints out a random sequence of letters from the alphabet. But, i need it to print out a sequence of letters containing only four letters for example 'A', 'C', 'U', 'G'. How would ...
Is there a way to see how many items in a dictionary share the same value in Python?
Let's say that I have a dictionary like:
{"a": 600, "b": 75, "c": 75, "d": 90}
I'd like to get a resulting dictionary like:
{600: 1, 75: 2, 90: 1}
My first naive attempt would be to just use a nested-for loop and for each value then I would iterat...
I am working with html documents and ripping out tables to parse them if they turn out to be the correct tables. I am happy with the results - my extraction process successfully maps row labels and column headings in over 95% of the cases and in the cases it does not we can identify the problems and use other approaches.
In my scanni...
Hi all,
I have a Python / Django application which is supposed to call an external windows binary and get its output at some point. And it does so when tested via 'python manage.py shell'.
But when it is run from within the web browser, which is served by IIS, the external application is not executed.
Is IIS blocking something on the...
What's the simplest way to determine if a date is a U.S. bank holiday in Python? There seem to be various calendars and webservices listing holidays for various countries, but I haven't found anything specific to banks in the U.S.
...
Is there a way to write a callback function for pycurl's READFUNCTION that does not return a string? I am planning on sending blocks of binary data via pycurl. i tried writing a callback function that does this:
def read_callback(self, size):
for block in data:
yield block
but pycurl exits with an error that says the return type...