I am hoping this is a simple stupid noob mistake that can be fixed with the addition of a single line of code somewhere.
I'm using pySerial to read in serial data from a USB port and print it out to standard output. I'm running Mac OSX 10.6. I open terminal and type "python", then the following:
>>> import serial;
>>> ser = serial.Seri...
I have a set of data (csv files) in the following 3 column format:
A, B, C
3277,4733,54.1
3278,4741,51.0
3278,4750,28.4
3278,4768,36.0
3278,4776,50.1
3278,4784,51.4
3279,4792,82.6
3279,4806,78.2
3279,4814,36.4
And I need to get a three-way contingency table like: (sorry, this doesn't look completely good)
A /B 4733 ...
I have a python3 program that I'm making which uses a sqlite database with several tables, I want to create a selector module to allow me to chose which table to pull data from.
I have found out that I can't use paramater substitution for a table name as shown bellow, so I'm looking for some alternative methods to accomplish this.
c.ex...
could anyone please explain what's wrong with it ? am I doing something wrong ?
>>> class qw:
... def f2x(par1, par2, par3):
... print par1, par2, par3
...
>>> obj = qw()
>>> obj.f2x("123", 13, "wert") Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f2x() takes exactly 3 arguments (...
I'm trying to use URLLIB2 to open a URL and read back the contents into an array. The issue seems to be that you cannot use string interpolation in a URL that has formating characters such as %20 for space, %3C for '<'. The URL in question has spaces and a bit of xml in it.
My code is pretty simple, looks something like this:
#Python s...
For a small timer app I want to write a GTK interface where I can set the desired time. Here is a picture of the interface:
However, I am having trouble reading out the fields of the spin buttons. My envisaged procedure for this is the following:
Read out the buttons using methods for each button
Here is one of the methods that d...
Simplified version of my code:
sequence = [['WT_1', 'AAAAAAAA'], ['WT_2', 'BBBBBBB']]
def speciate(sequence):
lineage_1 = []
lineage_2 = []
for i in sequence:
lineage_1.append(i)
for k in sequence:
lineage_2.append(k)
lineage_1[0][0] = 'L1_A'
lineage_1[1][0] = 'L1_B'
lineage_2[0][0] = 'L2_A...
I have a date string of the following format '%Y%m%d%H%M%S' for example '19981024103115'
and another string of the UTC local offset for example '+0100'
What's the best way in python to convert it to the GMT time
So the result will be '1998-10-24 09:31:15'
...
Hi,
I'm a beginner in PyQt. I was trying to create a simple app to try some of the toolkit's many features. My question is, how can I hide the app icon from the taskbar?
I don't want the user to be able to see the icon in taskbar and to minimize it using this icon. Is there any window flags that I can use to achieve this?
...
Hi, I have two models like below:-
class Food(db.Model):
foodname=db.StringProperty()
cook=db.StringProperty()
class FoodReview(db.Model):
thereview=db.StringProperty()
reviews=db.ReferenceProperty(Food,collections_name='thefoodreviews')
I go ahead and create an entity:-
s=Food(foodname='apple',cook='Alice')`...
Technically not a django question, more a python question.
In urls.py I've got the following:
urlpatterns = patterns('locate.views',
url(r'^', 'index.index'),
)
And a directory structure like this:
locate/
views/
__init__.py
index.py # where there is "def index(request) : ...."
What I would like to do is avoid...
I have a class that contains only fields and no methods, like this:
class Request(object):
def __init__(self, environ):
self.environ = environ
self.request_method = environ.get('REQUEST_METHOD', None)
self.url_scheme = environ.get('wsgi.url_scheme', None)
self.request_uri = wsgiref.util.request_uri(e...
Possible Duplicate:
Python - Parse String to Float or Int
I want to know how I can multiply raw input by a certain number. This is what I have so far:
dog = raw_input("Dog:")
multiply = (dog * 2)
print multiply
The result is (let's say I chose 10 as the raw input):
1010
I know why I'm getting this, because python is taki...
I have a large SQL script that creates my database (multiple tables, triggers, and such. Using MySQL), and I need to execute that script from within a python program. My old code did this:
sql_file = open(os.path.join(self.path_to_sql, filename), 'r')
sql_text = sql_file.read()
sql_stmts = sql_text.split(';')
for s in sql_stmts:
c...
In Python, what is the "one [...] obvious way" to add all items of an iterable to an extant set?
...
class a(object):
def __init__(self):
self.b = 1
self.c = 2
This gives the error: NameError: name 'self' is not defined
I looked at a previous post, but the error was for a different reason. Any help with this?
...
As mentioned in the title, my paginator doesn't show anything when I click to go to a page beyond the first.
First, let me describe my page in general:
Its function is to get a request input from the user specifying the period interval from which he wants to see a bunch of "call records" along with other filters (this is important). So e...
I am running Python 3.1.2 with IDLE 3.1.2 on Windows 7. When I try to use the Stack Viewer, blue text and a new window briefly appear before all open IDLE windows exit (I don't have time to read the text or new window). This is the first time I have used Stack Viewer.
Is this normal behavior? How can I get the Stack Viewer to stay open?...
The update method of wx.ProgressDialog has a newmsg argument that is supposed to give a textual update on what is happening in each step of the process, but my code is not doing this properly.
Here is the link to the documentation for wx.ProgressDialog http://www.wxpython.org/docs/api/wx.ProgressDialog-class.html
Also, when I run my co...
I have two lists of strings, which have the following format:
[x1,x2,x3,x4,...] [y1,y2,y3,y4...]
Call it lst1.
lst2 would be:
[x1',x2',x3',x4',...] [y1,y2,y3,y4,...]
you can assume that each string in lst1 has matching y's in the corresponding element in lst2, and the same number of x's, but it would be great to throw an error if ...