Hi All,
Warning, this is a sheer-laziness query! As my project develops, so also do the number of functions within a class. I also have a number of classes per .py file. So what I would like to do is re-sort them to that the function names are organised [sorry, UK here, I've already compromised hugely with the 'z' in Alphabetizing ;-)] ...
I have a python/django application that runs on the google app engine.
My views.py file has some imports...
from commands.userCommands import RegisterUserCommand
from commands.accountCommands import CreateNewAccountCommand, RenameAccountCommand
These imports work fine on my development environment (local machine). But when I upload t...
Say i have a several list if ints:
x = [['48', '5', '0'], ['77', '56', '0'],
['23', '76', '34', '0']]
I want this list to be converted to a single number, but the the single number type is still an integer i.e.:
4850775602376340
i have been using this code to carry out the process:
num = int(''.join(map(str,x)))
but i keep gett...
I'm trying to write the Haskel function 'splitEvery' in Python. Here is it's definition:
splitEvery :: Int -> [e] -> [[e]]
@'splitEvery' n@ splits a list into length-n pieces. The last
piece will be shorter if @n@ does not evenly divide the length of
the list.
The basic version of this works fine, but I want a version tha...
If i had a list of list of integers say:
[['12' '-4' '66' '0'], ['23' '4' '-5'
'0'], ['23' '77' '89' '-1' '0']]
I wanted to convert the numbers to their absolute values and then to a single number, so the output would be:
1246602345023778910
thanks
...
The documentation doesn't guarantee that. Is there any other place that it is documented?
I'm guessing it might be stable since the sort method on lists is guaranteed to be stable (Notes 9th point: "Starting with Python 2.3, the sort() method is guaranteed to be stable"), and sorted is functionally similar. However, I'm not able to fin...
I have a collections.defaultdict(int) that I'm building to keep count of how many times a key shows up in a set of data. I later want to be able to sort it (obviously by turning it into a list first) in a descending fashion, ordered with the highest values first. I created my dictionary like the following:
adict = defaultdict(int)
lat...
A python descriptor that I'm working with is sharing it's value across all instances of it's owner class. how can I make each instances descriptor contain it's own internal values?
class Desc(object):
def __init__(self, initval=None,name='val'):
self.val = initval
self.name = name
def __get__(self,obj,objtype):
...
I'd like to use with statement in Python 2.5 in some production code. It was backported, should I expect any problems (e.g. with availability/compatibility on other machines/etc)?
Is this code
from __future__ import with_statement
compatible with Python 2.6?
...
I want to load info from another site (this part is done), but i am doing this every time the page is loaded and that wont do. So i was thinking of having a variable in a table of settings like 'last checked bbc site' and when the page loads it would check if its been long enough since last check to check again. Is there anything silly a...
I've got some apps I would like to make visible with zeroconf.
Is there an easy scriptable way to do this?
Is there anything that needs to be done by my network admin to enable this?
Python or sh would be preferrable. OS-specific suggestions welcome for Linux and OS X.
...
I have an SCons project set up as follows:
Project/
SConstruct # "SConscript('stuff/SConscript', variant_dir = 'build')
stuff/
SConscript # "import configuration"
configuration/
__init__.py
Thing.py
When building, the SConscript is copied to the build directory, but the "configuration" ...
I have an SConscript which is being copied to a build directory (variant_dir = ...) for construction. As a workaround for not being able to express dependencies, I'm trying to copy some additional files into the build directory.
How do I determine what the current build directory is, within an SConscript?
For instance, in the following...
I am writing a small forensics python app and I am having trouble converting a List entry to Hex. I have tried the encode/decode methood but get bogus conversions or odd-length string Type Errors. I have pasted the code below, and as you can see I need the address in hex, so I can add the count to it.
def location_finder(line):
coun...
Lets say I have three django model classes - lets call them A, B and C. If A and B are abstract, I can do something like:
class C(A,B):
pass
What if they aren't abstract and I do the same? Will everything still work correctly or no? Or have I got it wrong and this should not be done with abstract models either?
I'm having some is...
Whilst developing I want to handle some things slight differently than I will when I eventually upload to the Google servers.
Is there a quick test that I can do to find out if I'm in the SDK or live?
...
If i had a list of numbers and some maybe negative, how would i ensure all numbers in my list were positive? I can covert the items in the list to integers thats no problem.
Another question, I want to compare items in my list to an integer value say 'x' and sum all the values in my list that are less than x.
Thank you.
...
using python 2.5.2 and linux debian i'm trying to get the content from a spanish url that contains a spanish char ('í'):
import urllib
url = u'http://mydomain.es/índice.html'
content = urllib.urlopen(url).read()
I'm getting this error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 8: ordinal not in range...
I want to screen-scrape a web-site that uses JavaScript.
There is mechanize, the programmatic web browser for Python. However, it (understandably) doesn't interpret javascript. Is there any programmatic browser for Python which does? If not, is there any JavaScript implementation in Python that I could use to attempt to create one?
...
I want to make image in my QMainWindow so when you click on it you have a signal translating like qpushbutton I use this:
self.quit=QtGui.QPushButton(self)
self.quit.setIcon(QtGui.QIcon('images/9.bmp'))
But the problem is whene I resize the window qpushbutton resized too but not his icon have you solution of my pro...