Imagine this scenario:
I made a small application in Python for Google App Engine for general use.
Users can login to my app, update their profile, change address and change the picture among many other things.
A user can export the models to PDF, YAML and JSON, save the file on his computer.
You can download any available format...
I wrote what I thought was a straightforward Python script to traverse a given directory and tabulate all the file suffixes it finds. The output looks like this:
OTUS-ASIO:face fish$ sufs
>>> /Users/fish/Dropbox/ost2/face (total 194)
=== 1 1 -
=== css 16 -----
=== ...
This might sound like a strange question, but bear with me...
I have a dictionary in Python with values like so:
'B': 23.6
'D': 0.6
'F': 35.9
'H': 35.9
I need to do an if-else with these values to do different things depending which one is > 30. The code I have at the moment is along the lines of:
if angles['B'] > 30:
# Do stuff
e...
Is it possible to declare functions in python and define them later or in a separate file?
I have some code like:
class tata:
def method1(self):
def func1():
# This local function will be only used in method1, so there is no use to
# define it outside.
# Some code for func1.
# Some code for m...
Does anyone know how to parse the format as described in the title using Pythons strptime method?
I have something similar to this:
import datetime
date = datetime.datetime.strptime(entry.published.text, '%Y-%m-%dT%H:%M:%S.Z')
I can't seem to figure out what kind of timeformat this is. By the way, I'm a newbie at the Python langu...
I know how to parse xml with sax in python, but how would I go about inserting elements into the document i'm parsing? Do I have to create a separate file?
Could someone provide a simple example or alter the one I've put below. Thanks.
from xml.sax.handler import ContentHandler
from xml.sax import make_parser
import sys
class aHand...
Hi I have a ton of data in multiple csv files and filter out a data set using grep:
user@machine:~/$ cat data.csv | grep -a "63[789]\...;"
637.05;1450.2
637.32;1448.7
637.60;1447.7
637.87;1451.5
638.14;1454.2
638.41;1448.6
638.69;1445.8
638.96;1440.0
639.23;1431.9
639.50;1428.8
639.77;1427.3
I want to figure out the data set which has...
I've got a program/joke that needs a reasonably large data structure to operate, (a dictionary that takes a few seconds to construct) and I would like to create and pickle it into the installation dir when running python setup.py install.
setup() in distutils.core looks like it shouldn't exit, so I thought that I could just import my mo...
I use a custom auth backend in my django application that allows users to login with ther emails.
But when I try to login in the admin I get the message: "usernames cant contain the '@' char"
I suppose this error is raised before it reaches the auth backend, so its a form issue, right ?
...
i'm using
data=urllib2.urlopen(url).read()
i want to know:
how to know a url is gzipped
dose urllib2 will automaticly uncompress the gzipped data if a url is gzip,so the data is always a string?
...
I'm getting a slightly weird result from calling subprocess.Popen that I suspect has a lot to do with me being brand-new to Python.
args = [ 'cscript', '%USERPROFILE%\\tools\\jslint.js','%USERPROFILE%\\tools\\jslint.js' ]
p = Popen(args, stdout=PIPE, shell=True).communicate()[0]
Results in output like the following (the trailing doubl...
I want to delete all files in a folder that are less than 200 in size.
Just want to be sure here, when i do a ls -la on my macbook, the file size says 171 or 143, I am assuming this is kb correct?
...
I have a long tuple like
(2, 2, 10, 10, 344, 344, 45, 43, 2, 2, 10, 10, 12, 8, 2, 10)
and i am trying to split it into a tuple of tuples like
((2, 2, 10, 10), (344, 344, 45, 43), (2, 2, 10, 10), (12, 8, 2, 10))
I am new to python and am not very good with tuples o(2, 2, 10, 10, 344, 344, 45, 43, 2, 2, 10, 10, 12, 8, 2, 10)r lists. ...
Hello everyone,
I am deploying twisted as a web server for my site. I am looking into possibilities of reverse proxying.
I have the following code right now hooked up to my reactor for django. I am using comet, and I realize that I absolutely must use port 80 hence I am looking into possibilities of reverse proxying. On this site, I fo...
I'm developing on Google App Engine. I am using WingIDE (a python IDE) to debug on the development server. I have several thousand entities in my datastore and I can see that when the development server starts up, it has to go through DatastoreFileStub.Read() and do something which each entity.
The problem is, when I run the development...
I have a series of unit tests that I'm running with nose. For some of my tests, I'd like to remove a module's path from the sys.path so there is no conflict with what I am testing.
sys.path.remove('/path/to/remove/from/sys/path')
If I run the Python interpreter and call sys.path, the '/path/to/remove/from/sys/path' is there in the li...
I am trying to get my website to have a simple checkout flow where the person is able to create an account and pay for the product. I want to record this in the datastore so that the account gets created only when the payment has gone through and the person should be able to get back to the profile/personal page once done. I looked at gc...
# I have 3 lists:
L1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
L2 = [4, 7, 8]
L3 = [5, 2, 9]
# I want to create another that is L1 minus L2's memebers and L3's memebers, so:
L4 = (L1 - L2) - L3 # Of course this isn't going to work
I'm wondering, what is the "correct" way to do this. I can do it many different ways, but Python's style guide says t...
run("if [ -d data.bak ];then mv data.bak data;fi;")
sudo('....')
sudo('')
i use fabric deploy my project to web,and i want to find a way to didn't do the left command,if didn't find data.bak directory,so is there some way to achieve this on fabric
...
I have a appengine webapp where i need to set HTTP Location variable to redirect to another page in the same webapp. For that i need to produce a absolute link. for portability reason i cannot use directly the domain name which i am currently using.
Is it possible to produce the domain name on which the webapp is hosted in the python co...