I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com
I'm using a brute force method, where the computer generates some ... |
What's the easiest way to shuffle an array with python?
|
How to create big array in python, how efficient creating that
in C/C++:
byte *data = (byte*)memalloc(10000);
or
byte *data = new byte[10000];
in python...?
|
View are useful constructions of Python 3. For those who never noticed (like me): for a dictionary d you can write k = d.keys() and even if you update ... |
I'm trying to create an array of all .asm files I need to build except for one that is causing me trouble right now. Here's what I have, based on the ... |
Let's say I have an array or list of words, something like this:
[The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog]
I'd like to generate an array of arrays, with each array containing 3 of the words, but with a ... |
I have a question, as I perform mathematical operations with an array of lists such as I get the sum of each array list getting a new list with the Valar ... |
|
I wrote a method to calculate the cosine distance between two arrays:
def cosine_distance(a, b):
if len(a) != len(b):
return False
numerator ...
|
I am still a beginner but I want to write a character-recognition-program. This program isn't ready yet. And I edited a lot, therefor the comments may not match exactly. I will ... |
I need to dynamically create com objects from an activex dll and each of the objects can raise events which should be handled with event handlers.
I can do this easily with ... |
i have an array of 27 elements,and i don't want to generate all permutations of array (27!)
i need 5000 randomly choosed permutations,any tip will be useful...
|
I have a problem with python here. If I pass an array through a recursive function that adds something to the array each time it is called, the array is modified ... |
Using comtypes to drive Python, it seems some magic is happening behind the scenes that is not converting tuples and lists to VARIANT types:
# RANGE(“C14:D21”) has values
# Setting the ...
|
I'm just getting started with pylons, and am trying to figure out how to view the contents of variables for debugging without rendering the template.
For example:
class IndexController(BaseController):
def index(self):
...
|
What is an efficient way to initialize and access elements of a large array in Python?
I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized ... |
How does time.localtime() work exactly? I can call up the "array" (tupple, I think it is called - because it is immutable?) and reference/index components of it. For example:
>>> ...
|
I am working on a project built on python 2.4 (It is an embedded python project, so I don't have a choice on the version of python used). Throughout the ... |
$$I need to get the numbers of one line randomly, and put each line in other array,then get the numbers of one col.
I have a big file, more than 400M. In ... |
I have an array of files. I'd like to be able to break that array down into one array with multiple subarrays, each subarray contains files that were created on the ... |
As part of the last assignment in a beginner python programing class, I have been assigned a traveling sales man problem. I settled on a recursive function to find each permutation ... |
in c++ I can wrote:
int someArray[8][8];
for (int i=0; i < 7; i++)
for (int j=0; j < 7; j++)
someArray[i][j] = 0;
And how can ... |
I have an array that I have to add a new value to array value. I am new to arrays.
how do I loop thru the array and add to the ... |
I am using this code:
def startThreads(arrayofkeywords):
global i
i = 0
while len(arrayofkeywords):
try:
...
|
my code is :
class demo(BaseRequestHandler):
def get(self):
a=[[1,2,3],[3,6,9]]
self.render_template('map/a.html',{'geo':a})
and the html is :
{% ...
|
Hey guys, how would you erase a whole array, as in it has no items. I want to do this so I could store new values (a new set of 100 ... |
Hi Everyone today i just noted that C# 3.5 have a interesting feature which is useful and available in python as well and may be other languages.
It is the trailing comma(,) ... |
I'm currently in the process of writing a client server app as an exercise and I've gotten pretty much everything to work so far, but there is a mental hurdle that ... |
I am making a program in python and I am having an error that I cannot solve.
This is the problem:
I have a set to points in 3D space, and I am ... |
How do you do an os.path.join with an array in python? Basically, I want to be able to run that command with an array as an argument. Any help is highly ... |
How could I create arrays for items in a list
something like
list = ["a","b","c"]
for thing in list:
thing = []
|
I'm getting a array from plpgsql that looks like this:
[0:2]={"(ab023500-ceef-41d6-af33-635964dbffde,Koen,\"\",Schmeets,{koen@heizoo.com},{31631205427},\"{\"\"Test categorie\"\"}\",{ff0000})","(384cb1e9-58b9-4bdf-9da6-eb3d9355471b,Marc,\"\",Vrijhof,{},{},\"{\"\"Test categorie\"\"}\",{ff0000})","(9c19ec5c-6b95-456a-af6f-c3388835b780,Michael,\"\",\"Baas ;)\",{},{},\"{\"\"Subcategorie test\"\",\"\"Test categorie\"\"}\",\"{NULL,ff0000}\")"}
I have built my own interpeter to get the array in a list of pyton, but it ... |
I was wondering which gui library would be appropriate to display a maze (a NxN array) and being able to fill each cell with a colour to represent states of that ... |
Here is the link to my assignment:
http://www.cas.mcmaster.ca/~soltys/cs2me3-w11/a1.pdf
So frankly I am not sure where to start off, or how to implement the code. I am a complete beginner at Python, ... |
In Python I have this statement:
blog_ids = [c.blog_id for c in connections]
Which basically tells Python to create an array of all the blog IDs in the connections. Unfortunately, if the connections ... |
I have this array:
>>> print raw_data
['LEVEL 1',
'SUBJECT A',
'GROUP X',
'COMMENT i',
'COMMENT ii',
'COMMENT iii',
'GROUP Y',
'COMMENT iv',
'COMMENT v',
'COMMENT vi',
'LEVEL 2',
'SUBJECT B',
'GROUP Z',
'COMMENT vii',
'COMMENT viii',
'COMMENT ix',
'SUBJECT C',
'GROUP X2',
'COMMENT x',
'COMMENT xi',
'COMMENT xii',
'COMMENT xiii',
'GROUP Y2',
'COMMENT xiv',
'COMMENT xv',
'COMMENT ...
|
I have two arrays
A = [a, b, c, d]
and
B = [a1, a2, b1, b2, b3, c1, c2, c3, d1, d2, d3, d4]
I want to match between the two arrays.
Match Result:
[a : ...
|
How to check is the array is not empty? I did this:
if not self.table[5] is None:
Is this the right way?
Thanks
|
I have different type of data for example:
4.5,3.5,U1
4.5,10.5,U2
4.5,6,U1
3.5,10.5,U2
3.5,10.5,U2
5,7,U1
7,6.5,U1
I need output:
'U1': [['4.5', '3.5'], ['4.5', '6'], ['5', '7'], ['7', '6.5']]
'U2': [['4.5', '10.5'], ['3.5', '10.5'], ['3.5', '10.5']]
So my code is:
import csv
reader = csv.reader(open('test.data', 'r'))
result ...
|
I'm writing my own sparse (one-dimensional) array class but I'm running into some performance issues. Profiling suggests that one of the bottlenecks is my __getitem__ and __setitem__ implementations, and in particular, ... |
I am currently working on a released bot for a game in the hopes of learning more about programming. Unfortunately, a new command i was adding that seemed simple at first ... |
I need a scalable NoSql solution to store data as arrays for many fields & time stamps, where the key is a combination of a field and a timestamp.
Data would be ... |
I have 2 arrays:
arr1 = [a,b,c,d,e]
arr2 = [c,d,e]
I want to give array arr1 except arr2.
|
I'm generating many largish 'random' files (~500MB) in which the contents are the output of repeated calls to random.randint(...). I'd like to preallocate a large buffer, write longs to that buffer, ... |
This is continued from thread:
Python array multiply
I need to multiply array vs array. I don't want to use "numpy". From previous thread, I learned how to multiply
number*array:
hh=[[82.5], [168.5]]
N=1./5
ll = ...
|
I'm comming from php where $_GET [ 'filter' ] on a url such as example.com/?filter[0][field]=username&filter[0][data][type]=string&filter[0][data][value]=someusername will return an array which can be parsed as:
foreach ( $_GET [ 'filter' ] as $k ...
|
I am using 2.5 on GAE using some of the Crypto modules from gdata python modules. I am able to use hashAndSign on a string, but the function returns an array.array ... |
I know that python is a crazy language because of it's cycles constructions :)
So, I have an array of numbers but in string type:
a = ['1', '40', '356', '...']
I need this ... |
it is a python code..whether implementing using linked list .... is efficient in this way...........
data = [] # data storage ...
|
Is this the correct way to declare and iterate through an array in Python, where each element is multiplied by a constant value?
timeArray = array([0]*1000)
for x in timeArray:
...
|
I havn't played in Python for quite some time and I have totally lost all my past knowledge of the subject.
I'm getting "invalid syntax" errors pointing to the "in" statement. Whats ... |
i have a list that looks like this:
list = [1,2,3,4]
I would like to add 12 to each value. In PHP you can use array_walk to process each item in the array. ... |
i want to use python in combination with tcpdump to put the generated stream from tcpdump into a more readable way. There are some fields in the streams with interesting values.
I ... |
hello I am trying to load coordinates for plotting from a text file and I keep getting an error I don't understand. The coordinates look like this in the ... |
I’m trying to change non-adjacent values of an array simultaneously, and it doesn’t seem to be working. Trying the example below, the code does not break, but the values do ... |
sorry for the easy question but I'm new to Python.
I have a set of points with these coordinates:
x=part.points[:,0]
y=part.points[:,1]
z=part.points[:,2]
And I'd like to select only the points with z>0.5 and z<0.6. I guess ... |
Hashing arrays are often very useful, and right now i am in need of hashing an array, i googled it and some said that hash of arrays were deleted from python, ... |
I'm trying to write a project that will have some autonomous components. One of these is the need to diff two folders and spit out the different files into an array ... |
I want to store a bunch of arrays for future use, how can I do this in python? I usually use
append() method for element storage but this doesn't work with ... |
I have a project to create a circular array class, and the language I will be using is python. I am new to classes in python, but after reading through some ... |
There is a python script which reads a benchmark name from command line like this:
-b benchname1
The code for this perpose is:
import optparse
import Mybench
parser = optparse.OptionParser()
# Benchmark options
parser.add_option("-b", "--benchmark", default="", help="The benchmark ...
|
I'm trying to create a look-up table between two arrays which I've created from a text file.
One is letters, LET = '[AS, DF, EG, ET, AS]'
The other is numbers, NUM = ... |
Trying to import a series of base pairs into an array.
I want it in the form ['AA','AT','AG','AC'...]
Here's my code:
paths = [str(x[4:7]) for x in mm_start]
paths
['A A', 'A T', 'A G', 'A ...
|
Using regexp I am searching through text file which contains data. I get output similar to this.
Here's what I get for example:
36
37
36
36
36
76
39
36
68
36
56
36
36
36
...
I need all those 36 to be in array like ... |
What's the quickest way to get an array of colors in python? Something I can index and pass to as the "color=" argument plotting in pylab.
The best I can come up ... |
I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','.
I am wondering how to interpret this.
Thanks.
... |
Hi I am new to python and want to take input in an array. The python doc is not well described about arrays. Also I think I have some hiccups with ... |
I am a python newbie and am attempting to write code for sieve of Eratosthenes. For this I have to initialize a list of empty sets. I tried doing this factors=[set()]*1001, ... |
I know in php I could just use $_GET['key1']['key2'] to retrieve get data that is sent in the form of an array but is that something possible in python as I ... |
I know i can use GetSelection() to get the selected tab, however it will return the tab number, i would like to get the tab label.
I am using
print self.GetSelection()
|
I have a jQuery post something like
var arr = ['some', 'string', 'array'];
jQuery.post('saveTheValues', { 'values': arr },
function(data)
...
|
|
|
|
|
|
|
Hi, I was wondering if you could help me again....How do I add something to numpy array? Say I have : >>> a= numpy.zeros(0) Then I want to start adding elements to a. By the end I want a to look something like this a=[[1, 2], [4]]. I have no problem doing it with the actual python lists. |
|
|
There's another test you can make: test = (2,3) import cPickle testpickle = cPickle.dumps(test,2) testpickle print testpickle The last two commands are very different. When you type just testpickle, you get something like: '\x80\x02K\x02K\x03\x86q\x01.' when you type 'print testpickle', you get: K K q . There are spaces between the elements. These are the spaces I am mentioning here. ... |
Hello I'd like to know what the right way is to access an item in a row as returned by a database: ===== import apsw connection=apsw.Connection("test.sqlite") cursor=connection.cursor() rows=cursor.execute("SELECT isbn,price FROM books WHERE price IS NULL") for row in rows: #Is this right? for isbn in row: if isbn: print "Found price = " + price connection.close(True) ===== Thank you. |
|
It's been awhile since I used Python. I want to make a 2D array or something, but the size of the array (and the sub arrays) is given by the user, and I want to fill the array. But, when I try looking up about arrays in Python, I keep seeing stuff like [2,3,5,[2,3],6] but I don't think I can do ... |
Hi, I'm trying to write a Python Program, not really asking for code, but more or less how to design it. The thing I'm having problems with is how to get a bunch of inputs, and get the output to display in columns. Example: First Name Last Name Gross Pay Net Pay Jack Smith 2500 1750 Elaine Donaldson 3600 2100 Total ... |
|
|
Is there some limited size for arrays used in Python? I'm importing a fortran code with three (50,10000) real arrays, which is evidently too much for Python. The same error occurs when the three arrays are divided to several smaller ones. I tested reducing array size so, that the overall number of elements was smaller (e.g. three (50,2000) arrays) and the ... |
Hi there, i'm green as can be with python... in regards to arrays, can we not store an array of strings? from what i'm reading, I can store an array of characters, so then do i need to store my array of characters inside another array? for i in range(0, 2): Buffers_15000m_shp[i] = "C:\\Development\\ConflagTool\\sampleDataSets\\sampleOutputs\\Buffers_15000m"+str(i)+".shp" Buffers_8000m_shp[i] = "C:\\Development\\ConflagTool\\sampleDataSets\\sampleOutputs\\Buffers_8000m"+str(i)+".shp" ................more code else: print ... |
Hello all, I'm a newbie to python. Plenty of experience in VB6 and assembler on various brands and broods of microcontrollers. Back when I was actively programming in VB, I quite often had to create multiple check boxes, option boxes, text boxes etc, but with quite generic functionality. The easy way to do this, was with control arrays... may sound like ... |
>>> import numpy as np >>> b = np.zeros([3,3,3],float) >>> b array([[[ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]], [[ 0., 0., 0.], ... |
91. Array help python-forum.orgOk so I guess I should mention that I'm loading in arrays from files, the arrays have the same number of columns but different number of rows. and Im using pylab mlab.load(filename) to load my files into my arrays. I tried both the a+b and the a.extend(b) and even a.append(b) but none of those worked. Any suggestions? |
Creating an array of files by blivori Mon Aug 08, 2011 6:34 am Hi, I created a script using PyPDF that automatically merges all the pdf files in a directory and it's sub-directories to one, and renames the output PDF according to the folder name. Its working apart from the fact that its not compatible with every PDF file. For ... |
a = [1,2,3] #a is a list, you can add, remove, change a value a[0] = 4 # a =[4,2,3] a.append(5) # a = [4,2,3,5] b = (1,2,3) # b is a tuple, and is immutable, once defined nothing can change c = {'a':1, 'd':7} #This is a dictionary it is a hashmap. you access the values by user defined key ... |
|
I am new to python and have the following code, I am just beginning to develop nine men's morris the object of this portion was just to change the color when clicking the circle and its not working, does anyone have any ideas? Thank you! CODE: ###################################################################### coords=[50,150, 200, 250, 300, 350, 450] color=(255,255,255) color2=(255,255,255) radius=(10) while True: for event in ... |
Hi, is there an easy way or even any implemented function to drop lines from a record array? E.g. I have a record array with lots of columns and lines. One column is named "name". Can I compare a list of names with the record array's column "name" and drop all (complete) lines of the record array where it contains a ... |
Re: Python Arrays by xwr3ksh0px Tue Apr 26, 2011 1:21 pm Ok this helps but I'm trying to get the output to look like this. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ... |
>>> mat = [[0 for i in xrange(12)] for j in xrange(8)] >>> for row in mat: ... print row ... [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ... |
|
I'm making a sudoku solver for my Year 12 computing project, it's not coursework just for programming experience. This means that my programming doesn't have to be perfect and so please do not criticise the way I've gone about this problem. One method I am using in order to solve a sudoku grid is the 'brute force' method in which if ... |