I was studying the difference between lists and tuples (in Python). An obvious one is that tuples are immutable (the values cannot be changed after initial assignment), while lists are mutable.
A sentence in the article got me:
Only immutable elements can be used as
dictionary keys, and hence only tuples
and not lists can be us...
class p1(object): pass
class p2(p1): pass
So p2 is the subclass of p1. Is there a way to find out programmatically that p1 is [one of] the superclass[es] of p2 ?
...
Hi,
My program uses PyOpenGL (so it's Python) with psyco.
I have around 21,000 line segments which I need to render in each frame of my render (unless the user zooms in, in which case line segments are culled and not sent to the card at all). This is currently taking around 1.5 seconds each frame to complete. That's just not good enoug...
I have a big csv file which lists connections between nodes in a graph. example:
0001,95784
0001,98743
0002,00082
0002,00091
So this means that node id 0001 is connected to node 95784 and 98743 and so on.
I need to read this into a sparse matrix in numpy. How can i do this?
I am new to python so tutorials on this would also help.
...
I installed Pydev 1.5.3 (so that I could get the merged version of Pydev Extensions in core PyDev) in an EasyEclipse 1.3.1 installation. After this, Compare with > Base revision etc. comparison operations stopped working. I had to disable the PyDev 1.5.3 and revert back to the pre-installed Pydev 1.3.13 (part of EasyEclipse 1.3.1).
Has...
I've import contacts from gmail by using gdata api,
and is there any apis like that for hotmail/live/Aol ?
...
hi,
I want to change the resolution of the .bmp image in python. ( i.e. the pixel/inch information) . Using PIL, for jpg image, for instance, the following code works fine
import Image
im = Image.open("myImg.jpg)
im.save("output.jpg", dpi = (75, 75) )
If you view this in some image editing software like GIMP, it shows the Pixel per...
I am using the following code, with nested generators, to iterate over a text document and return training examples using get_train_minibatch(). I would like to persist (pickle) the generators, so I can get back to the same place in the text document. However, you cannot pickle generators.
Is there a simple workaround, so that I can sa...
Hi, I need to send a file to another server using oauth and webpy. For now I'll ignore the oauth part as sending the file itself is already a challenge.
Here's my partial code:
class create_video:
def POST(self):
x = web.input(video_original={})
At this point I want to send the file over the network using urllib2. Note that I a...
i don't know what__setstate__ __getstate__ does ,so help me use a simple example,thanks
__setstate__ __getstate__
...
Hi Guys,
I'm going to write first code for handling ssh commands on python and I did search over the stackoverflow and see that there are several python libraries that can be used for handling commands passed through ssh, like paramiko, pexpect and perhaps some others.
Particulary, I will need to read content of the files from the remo...
Is it possible to install python on Sony Ericsson mobile phones?
...
I'm trying to execute the following
>> from numpy import *
>> x = array([[3,2,3],[4,4,4]])
>> y = set(x)
TypeError: unhashable type: 'numpy.ndarray'
How can I easily and efficiently create a set from a numpy array?
...
Hello,
I am new to python and I'm trying to create a program that creates a directory with todays date, create a sandbox into that directory and run the make file in the sandbox. I am having trouble getting the variables to be picked up in the os.path lines. The code is posted below:
#!/usr/bin/python
import mks_function
from mks_f...
I am generating class names dynamically and then want to import that class by its name to access a static method.
This is the class to import in "the_module.py":
class ToImport(object):
@classmethod
def initialize(cls, parameter):
print parameter
According to a Blog post this is as far as I came:
theModule = __impor...
Hello,
I'm running Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32
When I'm asking Python
>>> "u11-Phrase 099.wav" < "u11-Phrase 1000.wav"
True
That's fine. When I ask
>>> "u11-Phrase 100.wav" < "u11-Phrase 1000.wav"
True
That's fine, too. But when I ask
>>> "u11-Phrase 101.wav" < "u11-Phr...
Is there any way to use xbmc plugins in .net? im thinking about those plugins that provide access to media content like GameTrailers and stuff like that..
...
Hi,
I want to dynamically update the scatter plot based on the y-axis data received from a socket connection. I used python matplot lib in interactive mode to do this, but during dynamic updation if i move the window to a different location or minimize the window then the plot updation stops abruptly. Please let me know how to do this?
...
Hey,
Currently, I am trying to do a small project with sockets in Python, a two-user chatting system.
import socket
import threading
#Callback. Print doesn't work across threads
def data_recieved(data):
print data
#Thread class to gather input
class socket_read(threading.Thread):
sock = object
def __init__(self, sock):
...
I want to alter properties of a model field inherited from a base class. The way I try this below does not seem to have any effect. Any ideas?
def __init__(self, *args, **kwargs):
super(SomeModel, self).__init__(*args, **kwargs)
f = self._meta.get_field('some_field')
f.blank = True
f.help_text = 'This is optional'
...