Hi
I have a very rudimentary question.
Assume I call a function, e.g.,
def foo():
x = 'hello world'
How do I get the function to return x in such a way that I can use it as the input for another function or use the variable within the body of a program?
When I use return and call the variable within another functions I get a Na...
If I have an entity derived from db.Expando I can write Dynamic property by just assigning a value to a new property, e.g. "y" in this example:
class MyEntity(db.Expando):
x = db.IntegerProperty()
my_entity = MyEntity(x=1)
my_entity.y = 2
But suppose I have the name of the dynamic property in a variable... how can I (1) rea...
when I am using the wave_read.readframes() I am getting the result in binary data such as /x00/x00/x00:/x16#/x05" etc a very long string
when asked for single frame it gives @/x00 or \xe3\xff or so
I want this individual frame data in integer how can I convert them into integer to store them into array.
...
In models,
class Getdata(models.Model):
title = models.CharField(max_length=255)
state = models.CharField(max_length=2, choices=STATE, default="0")
name = models.ForeignKey(School)
created_by = models.ForeignKey(profile)
def __unicode__(self):
return self.id()
In templates
<form>
<input type="submit" s...
Say I have the folowing code:
class Class1(object):
def __init__(self):
self.my_attr = 1
self.my_other_attr = 2
class Class2(Class1):
def __init__(self):
super(Class1,self).__init__()
Why does Class2 not inherit the attributes of Class1?
...
Hi, I'm developing a small media player in Python. A problem I have run into is that my thread which plays the .wav file never exits. I've provided the thread class, and how I handle the create of thread below.
class myThread (threading.Thread):
def __init__(self, threadID, wf):
self.threadID = threadID
s...
I want to have two custom made app dealing with two different tasks.
i have a page(template) where the data from the both app come together.
how to deploy url for that, in the common urls.py so that the two app work together. how to integrate the views from both app to return data to same template simultaneously. is that possible?
I fou...
Is there any way to read metadata - watermarks from image files with Python?
Thanks.
...
Hi. I am new to Python so please don't flame me if I ask something too noobish :)
1.
Consider I have a class:
class Test:
def __init__(self, x, y):
self.x = x
self.y = y
def wow():
print 5 * 5
Now I try to create an object of the class:
x = Test(3, 4)
This works as expected. However, when I try to ...
Possible Duplicate:
How do you programmatically set an attribute in Python?
Hey, here's a dumb question: how can I set an object property given its name in a string. I have a dictionary being passed to me and I wish to transfer its values into namesake properties using code like this:
for entry in src_dict:
if e...
Question: How do you write data to an already existing file at the beginning of the file with out writing over what's already there and with out reading the entire file into memory? (e.g. prepend)
Info:
I'm working on a project right now where the program frequently dumps data into a file. this file will very quickly balloon up to 3-...
In case of views that contain login or logout,
this sessionid is different from the one submitted in request's Coockie header.
I need to retrieve it before returning response for some purpose.
How can I do this ?
...
I currently have some python code I'd like to port to C++ as it's currently slower than I'd like it to be. Problem is that I'm using a dictionary in it where the key is a tuple consisting of an object and a string (e.g. (obj, "word")). How on earth do I write something similar in C++? Maybe my algorithm is horrendous and there is some wa...
I use the following block of code to read lines out of a file 'f' into a nested list:
for data in f:
clean_data = data.rstrip()
data = clean_data.split('\t')
t += [data[0]]
strmat += [data[1:]]
Sometimes, however, the data is incomplete and a row may look like this:
['955.159', '62.8168', '', '', '', '', '', ''...
Hi, I am using:
from __future__ import division
To perform a division in which I need some percision. However, it gives a long number, like:
1.876543820098765
I only need the the first two numbers after "." => 1.87
How can I do that?
...
*edited 6/17/10
I'm trying to understand how to improve my code (make it more pythonic). Also, I'm interested in writing more intuitive 'conditionals' that would describe scenarios that are commonplace in biochemistry. The conditional criteria in the below program I've explained in Answer #2, but I am not satisfied with the code- it wor...
Hi!
I'm trying to learn python and have encountered some strange behaviour. I am experimenting with ctypes and a self-made (very simple) DLL.
This is Python script I'm trying to run:
from ctypes import *
myLib = CDLL("libDlltest")
myLib.hello()
myLib.goodbye()
print 'I am a line'
myLib.goodbye()
I've configured eclipse according t...
I am able to establish the initial telnet session. But from this session I need to create a second. Basically I can not telnet directly to the device I need to access. Interactively this is not an issue but I am attempting to setup an automated test using python.
Does anyone know who to accomplish this?
...
I want to take my mockups and export them to code using any python GUI library (wxpython, pyqt, etc). For example, this capability already exists for mockups->HTML/Javascript here:
http://www.balsamiq.com/products/mockups/community
I need a fast, easy, high level mockup tool like balsamiq, not a slow, low level tool like boa constructo...
I am performing a least squares regression as below (univariate). I would like to express the significance of the result in terms of R^2. Numpy returns a value of unscaled residual, what would be a sensible way of normalizing this.
field_clean,back_clean = rid_zeros(backscatter,field_data)
num_vals = len(field_clean)
x = field_clean[:,r...