I have textmate, but honestly the only thing I can do with it is simply edit a file.
The handy little file browser is aslo useful. (how can I show/hide that file browser anyhow!)
But I have no other knowledge/tricks up my sleeve, care to help me out?
...
I am running Django 1.2.2 and I get the following error when I try to log in to the Django admin:
Forbidden (403) CSRF verification
failed. Request aborted.
Reason given for failure:
No CSRF or session cookie.
** I have made NO customization to the barebones admin and when I inspect the source there is a CSRF token in t...
What's the best way to install two python modules with the same name? I currently depend on two different facebook libraries: pyfacebook and Facebook's new python-sdk. Both of these libraries install themselves as the module 'facebook'. I can think of a bunch of hacky solutions but before I go an hack away I was curious if there was a py...
Hi,
I'm using twisted.internet.serialport to have my program be continuously connected to a device on a serial port.
Unfortunately my serial port is just a usb device, which means it can be disconnected or reset by the OS at any time (port 2 disabled by hub (EMI?), re-enabling... ). I see that pyserial has support for this for a few we...
Hi,
I have several very large zip files available to download on a website. I am using Flask microframework (based on Werkzeug) which uses Python.
Is there a way to show the contents of a zip file (i.e. file and folder names) - to someone on a webpage - without actually downloading it? As in doing the working out server side.
Assume t...
I have two lists, the first of which is guaranteed to contain exactly one more item than the second. I would like to know the most Pythonic way to create a new list whose even-index values come from the first list and whose odd-index values come from the second list.
# example inputs
list1 = ['f', 'o', 'o']
list2 = ['hello', 'world']
#...
I have a simple script that runs in to the cmd screen, the console screen...
how can I let the console screen always on top?
and if it''s possible, re size it?
...
I have a list [5, 90, 23, 12, 34, 89] etc where every two values should be a (ranked) list in the dictionary.
So the list above would become {1: [5, 90], 2: [23, 12], 3: [34, 89]} etc. I've gotten close with list comprehension but haven't cracked it. I tried:
my_list = [5, 90, 23, 12, 34, 89]
my_dict = dict((i+1, [my_list[i], my_list[i...
I'm writing a Google app engine app and obviously the default web app framework is a subset of Django. As such I'm using it's templating engine.
My question is if I have say the following code:
template_values = {
'first':first,
'second':second,
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.resp...
How does:
dict = {}
if key not in dict:
dict[key] = foo
Compare to:
try:
dict[key]
except KeyError:
dict[key] = foo
ie, is the look up of a key in anyway faster than the linear search through dict.keys(), that I assume the first form will do?
...
Hi,
I'm quite new to python (I use python 3), and i'm trying to serialize a class with one string and two lists as members in JSon. I found that there's a json lib in the python standart but it seems that I need to manually implement a serialization method. Is there a JSon encoder where I can simply pass an object, and receive the serial...
If I understand correctly, the __cmp__() function of an object is called in order to evaluate all objects in a collection while determining whether an object is a member, or 'in', the collection.
However, this does not seem to be the case for sets:
class MyObject(object):
def __init__(self, data):
self.data = data
def _...
I have a compiled Python library and API docs that I would like to use from Ruby.
Is it possible to load a Python library, instantiate a class defined in it and call methods on that object from Ruby?
...
I'm running a Django application on Apache with mod_wsgi. Will there be any downtime during an upgrade?
Mod_wsgi is running in daemon mode, so I can reload my code by touching the .wsgi script file, as described in the "ReloadingSourceCode" document: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode. Presumably, that reload requ...
As I work and update a class, I want a class instance that is already created to be updated. How do I go about doing that?
class MyClass:
""" """
def __init__(self):
def myMethod(self, case):
print 'hello'
classInstance = MyClass()
I run Python inside of Maya and on software start the instance is created. When I call classInst...
I have a table with several dependent tables that I want cascade delete. I'm having problems with it cascading too far. Some code will help explain.
class Map(Base):
....
#One to many relationship between the Map and Tile.
#Each Map is made up of many tiles
tiles = relationship('Tile', lazy='joined', backref='map',
...
I needed to write a weighted version of random.choice (each element in the list has a different probability for being selected). This is what I came up with:
def weightedChoice(choices):
"""Like random.choice, but each element can have a different chance of
being selected.
choices can be any iterable containing iterables w...
What I'd like to achieve is the launch of the following shell command:
mysql -h hostAddress -u userName -p userPassword
databaseName < fileName
From within a python 2.4 script with something not unlike:
cmd = ["mysql", "-h", ip, "-u", mysqlUser, dbName, "<", file]
subprocess.call(cmd)
This pukes due to the use of the redirect symb...
Hi,
After much research, I've come up with a list of what I think might be the best way of putting together a Python based social network/cms, but have some questions about how some of these components fit together.
Before I ask about the particular components, here are some of the key features of the site to be built:
a modern almo...
When I print the tuple (u'1S²') I get the predicted output of 1S²
However, when I print the tuple (u'1S²',u'2S¹') I get the output (u'1S\xb2', u'2S\xb9').
Why is this? What can I do about this?
Also, how do I get the number of items in a tuple?
...