I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.
For example:
object1: tags(1,3,4)
object2: tags(2)
object3: tags(3,4)
object4: tags(5)
and so on.
Query parameter is a set on integers, lets try q(3,4,5)
object1 does not match ('1' not in '3,4,5')
object2 does not match ('2' not i...
Hi,
i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to pickle, but pickle is not human-friendly. Other options that come to my mind are YAML (through PyYAML and JSON (through simplejson) serializers.
Any other option that comes to your mind?
T...
First, let me say that I'm a complete beginner at Python. I've never learned the language, I just thought "how hard can it be" when Google turned up nothing but Python snippets to solve my problem. :)
I have a bunch of mailboxes in Maildir format (a backup from the mail server on my old web host), and I need to extract the emails from t...
Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?
I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The system is expected to store huge a...
I have the following data structure (a list of lists)
[
['4', '21', '1', '14', '2008-10-24 15:42:58'],
['3', '22', '4', '2somename', '2008-10-24 15:22:03'],
['5', '21', '3', '19', '2008-10-24 15:45:45'],
['6', '21', '1', '1somename', '2008-10-24 15:45:49'],
['7', '22', '3', '2somename', '2008-10-24 15:45:51']
]
I would like t...
I have a Python function in which I am doing some sanitisation of the input parameters:
def func(param1, param2, param3):
param1 = param1 or ''
param2 = param2 or ''
param3 = param3 or ''
This caters for the arguments being passed as None rather than empty strings. Is there an easier/more concise way to loop round the func...
This particular example relates to Django in Python, but should apply to any language supporting exceptions:
try:
object = ModelClass.objects.get(search=value)
except DoesNotExist:
pass
if object:
# do stuff
The Django model class provides a simple method get which allows me to search for one and only one object from the ...
I'd like to know what versions of Python and wxPython correspond to each version of OSX. I'm interested to know exactly how far back some of my apps will remain compatible on a mac before having to install newer versions of Python and wxPython.
...
I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:
for b in bool_list:
b = False
I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference to the bool, not its value. So I rewrote as:
for i i...
I am using google's appengine api
from google.appengine.api import urlfetch
to fetch a webpage. The result of
result = urlfetch.fetch("http://www.example.com/index.html")
is a string of the html content (in result.content). The problem is the data that I want to parse is not really in HTML form, so I don't think using a python HT...
I recently saw a bit of code that looked like this (with sock being a socket object of course):
sock.shutdown(socket.SHUT_RDWR)
sock.close()
What exactly is the purpose of calling shutdown on the socket and then closing it? If it makes a difference, this socket is being used for non-blocking IO.
...
I've been using mutagen for reading and writing MP3 tags, but I want to be able to embed album art directly into the file.
...
Hi,
I'm new to Python, reason I'm learning it right now is because of the Django framework. I have been a Perl programmer for a number of years and I'm so used to Perl's tools. One of the things that I really miss is Perl's CPAN and its tools. Is there anything equivalent in Python? I would like to be able to search, install and mai...
For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?
...
I'd like a way to show natural times for dated items in Python. Similar to how Twitter will show a message from "a moment ago", "a few minutes ago", "two hours ago", "three days ago", etc.
Django 1.0 has a "humanize" method in django.contrib. I'm not using the Django framework, and even if I were, it's more limited than what I'd like.
...
I'm trying to write a small wsgi application which will put some objects to an external queue after each request. I want to make this in batch, ie. make the webserver put the object to a buffer-like structure in memory, and another thread and/or process for sending these objects to the queue in batch, when buffer is big enough or after c...
I'm working on a Django-based application in a corporate environment and would like to use the existing Active Directory system for authentication of users (so they don't get yet another login/password combo). I would also like to continue to use Django's user authorization / permission system to manage user capabilities.
Does anyone h...
I want to spawn another process to display an error message asynchronously while the rest of the application continues. I'm using the multiprocessing module in Python 2.6 to create the process and I'm trying to display the window with TKinter. This code worked okay on Windows, but running it on Linux the TKinter window does not appear if...
Whats the 7n5lu in the reddit URL
http://www.reddit.com/r/reddit.com/comments/7n5lu/man_can_fly_if_you_watch_one_video_in_2
how is it generated?
update:
@Gerald, Thanks for the code. I initially thought this is some obfuscation of the id.
But, it is just doing the conversion from integer to a more compact representation. I am thinkin...
Maybe I'm old school, but when I sit down to really tackle a new language I like to buy whatever the definitive book is for that language rather than mess around with tutorials and online intro "toys" to the language.
Python in a Nutshell has gotten glowing reviews on Amazon, but it's written around Python 2.5. So far it looks like Prog...