Hi everybody,
I'm just starting to play around with IronPython and am having a hard time using it with custom types created in C#. I can get IronPython to load in assemblies from C# classes, but I'm struggling without the help of intellisense. If I have a class in C# as defined below, how can I make it so that IronPython will be able to...
Hi all.
My question concerns the output of this statement:
for x in range(4), y in range(4):
print x
print y
Results in:
[0, 1, 2, 3]
2
True
2
It seems there is a comparison involved, I just can't figure out why the output is structured like this.
...
The situation:
Each page I scrape has <input> elements with a title= and a value=
I don't know what is going to be on the page.
I want to have all my collected data in a single table at the end, with a column for each title.
So basically, I need each row of data to line up with all the others, and if a row doesn't have a certain elem...
import datetime
start = datetime.datetime(2009, 1, 31)
end = datetime.datetime(2009, 2, 1)
print end-start
>>1 day, 0:00:00//output
How to get the output in minutes
Thanks,
...
As per the title, I have a nested lists like so (the nested list is a fixed length):
# ID, Name, Value
list1 = [[ 1, "foo", 10],
[ 2, "bar", None],
[ 3, "fizz", 57],
[ 4, "buzz", None]]
I'd like to return a list (the number of items equal to the length of a sub-list from list1), where the sub-...
I have a function foo that takes a NxM numpy array as an argument and returns a scalar value. I have a AxNxM numpy array data, over which I'd like to map foo to give me a resultant numpy array of length A.
Curently, I'm doing this:
result = numpy.array([foo(x) for x in data])
It works, but it seems like I'm not taking advantage of t...
I'm trying to sync my db from a view, something like this:
from django import http
from django.core import management
def syncdb(request):
management.call_command('syncdb')
return http.HttpResponse('Database synced.')
The issue is, it will block the dev server by asking for user input from the terminal. How can I pass it the ...
I've been struggling all morning to get PIL installed on Cygwin. The errors I get are not consistent with common errors I find using Google. Perhaps a linux guru can see an obvious problem in this output:
$ python setup.py install
running install
running build
running build_py
running build_ext
building '_imaging' extension
gcc -fno-str...
Is it possible to replace the following with a list comprehension?
res = []
for a, _, c in myList:
for i in c:
res.append((a, i))
For example:
# Input
myList = [("Foo", None, [1, 2, 3]), ("Bar", None, ["i", "j"])]
# Output
res = [("Foo", 1), ("Foo", 2), ("Foo", 3), ("Bar", "i"), ("Bar", "j")]
...
I'm trying to use ModelAdmin.filter_horizontal and ModelAdmin.filter_vertical for ManyToMany field instead of select multiple box but all I get is:
My model:
class Title(models.Model):
#...
production_companies = models.ManyToManyField(Company, verbose_name="компании-производители")
#...
My admin:
class TitleAdmin(ad...
I want to process the data in the file "output.log" and feed it to graphdata['eth0]
I have done this but it process only the first line:
logread = open("output.log", "r").readlines()
for line in logread:
print "line", line
i = line.rstrip("\n")
b = float(i)
colors = [ (0.2, 03, .65), (0.5, 0.7, .1), (.35...
Hello,
I have a list of dicts and I want to compare each dict in that list with a dict in a resulting list, add it to the result list if it's not there, and if it's there, update a counter associated with that dict.
At first I wanted to use the solution described at http://stackoverflow.com/questions/1692388/python-list-of-dict-if-exis...
Hello.
I have a Python script that reads a file (typically from optical media) marking the unreadable sectors, to allow a re-attempt to read said unreadable sectors on a different optical reader.
I discovered that my script does not work with block devices (e.g. /dev/sr0), in order to create a copy of the contained ISO9660/UDF filesyst...
I have implemented the following data structure:
class Node(object):
"""Rules:
A node's child is ONLY an iterable of nodes
A leaf node must NOT have children and MUST have word
"""
def __init__(self, tag, children=[], word=u""):
assert isinstance(tag, unicode) and isinstance(word, unicode)
self.tag=ta...
Hi all
I have some data represented in a 1300x1341 matrix. I would like to split this matrix in several pieces (e.g. 9) so that I can loop over and process them. The data needs to stay ordered in the sense that x[0,1] stays below (or above if you like) x[0,0] and besides x[1,1].
Just like if you had imaged the data, you could draw 2 ver...
Hello,
I would like to know if there are some libraries/algorithms/techniques (python, if at all possible) that help to extract features from accelerometer data (extracted from and android phone, btw), like periodicity of movements, energy of acceleration and the like. Has anyone done this kind of task before?
Thank you very much in adv...
This is probably a rudimentary question, but I'm new to threaded programming in Python and am not entirely sure what the correct practice is.
Should I be creating a single lock object (either globally or being passed around) and using that everywhere that I need to do locking? Or, should I be creating multiple lock instances in each...
I need to be able to block the urls that are stored in a text file on the hard disk using Python. If the url the user tries to visit is in the file, it redirects them to another page instead. How is this done?
...
I am attempting to write some tests using webtest to test out my python GAE application. The problem I am running into is that the application is listening on port 8080 but I cannot configure webtest to hit that port.
For example, I want to use app.get('/getreport') to hit http://localhost:8080/getreport. Obviously, it hits just thits...
Hi
i've a problem with JSON in python.
in fact if i try to execute this code, python gives me a sorted JSON string!!
values = {'profile' : 'testprofile',
'format': 'RSA_RC4_Sealed',
'enc_key' : base64.b64encode(chiave_da_inviare),
'request' : base64.b64encode(data)
}
values_json = json.dumps(va...