I'm trying to expose this function to Python using SWIG:
std::vector<int> get_match_stats();
And I want SWIG to generate wrapping code for Python so I can see it as a list of integers.
Adding this ... |
A function should select rows in a table based on the row name (column 2 in this case). It should be able to take either a single name or a list ... |
I have a list of numbers that i would like to send out onto a socket connection as binary data.
As an example, i start off with the following list:
data = ...
|
I am new to Python. Here's what I am trying to do:
- Slice a long binary string into 3 digit-long chunks.
- Store each "chunk" into a list called row.
- Convert each ...
|
I have read a file in and converted each line into a list. A sample of the list looks like:
['15', '2', '0'], ['63', '3', '445', '456' '0'], ['23', '4', '0']
i want ... |
If i had a list of numbers and some maybe negative, how would i ensure all numbers in my list were positive? I can covert the items in the list to ... |
Let's say I have a list of 10 integers and I want the result of multiplying the first 5 together. Is there a pythonic way of doing this? Python ... |
|
What is the easiest way to convert list with str into list with int in python? =)
For example, we have to convert ['1','2','3'] to [1,2,3]. Of course, we can use ... |
testGroupList is a list of integer.
I need to check the numbers in testGroupList is sequential and not duplicate numbers. Ignore the negative integer.
For example, [1,2,-1,2,3,4] is an error as 2 ... |
coinCount = [2 for i in range(4)]
total = sum(coinCount)
This gives me
TypeError: 'int' object is not callable
I don't understand why because
print type(coinCount)
Gives me
type <'list'>
|
>>> LISTL = []
>>> VAR1 = 0
>>> def foo():
... VAR1 += 1
... return VAR1
...
On calling foo(), I get this error:
UnboundLocalError: local variable ...
|
I have a list with numeric strings, like so:
numbers = ['1', '5', '10', '8'];
I would like to convert every list element to integer, so it would look like this:
numbers = [1, ...
|
This should be a fairly straight forward python question, but I'm getting stuck getting the syntax right.
Let's say I have a string:
"1:a,b,c::2:e,f,g::3:h,i,j"
and I want to convert this to a map like ... |
I would need to use the map function in Python(2.4.4) to add 1 to each item in the list, so I tried converting the strings into integers.
line=[['10', '13\n'], ['3', '4\n'], ['5', ...
|
I have a list:
['Jack', 18, 'IM-101', 99.9]
How do I filter it to get only the integers from it??
I tried
map(int, x) but it gives error.
ValueError: invalid literal for ... |
I have a list like ['-1', '1,2,3', '2'] and I want to extract all the integers in it.
I don't know the number of integers in each position of the list ie ... |
I have a list of integers and I was wondering if it would be possible to add to individual integers in this list. This is for a College Project, so if ... |
What I want to do is print the integers 0 through 5 in the code below but all I get is an address of the iterator?
def main():
l ...
|
# Assign list "time" with the following time values.
time = [15, 27, 32, 36.5, 38.5, 40.5, 41.5, 42, 43.5, 45.5, 47.5, 52.5]
# Remove 1st value(0) from the ...
|
Trying to remove single quotes from around numbers. I'm working with third paty data that's not well typed.
lst = [ ('text','2','3','4'), ('text2','4','5','6') ]
y= [map(int,i) ...
|
Can I make a list of numbers from 1 to 6 in one line without a loop?
goal:
[1,2,3,4,5,6]
|
I'm looking to write a function that takes the integers within a list, such as [1, 2, 3], and returns a new list with the squared integers; [1, 4, 9]
How would ... |
How should I configure import_transform and export_transform im my configuration yaml file to be able to export and import multiple integer property?
|
All,
I want define an int(987654321) <=> [9, 8, 7, 6, 5, 4, 3, 2, 1] convertor, if the length of int number < 9, for example 10 the list will ... |
I'm trying to do something usefull with some itens in list in the following code:
IPS=['10.254.243.83','10.254.243.82']
def commands(cmd):
command = Popen(cmd, shell=True, stdout=PIPE)
command_strip = command.stdout.read().strip()
...
|
def minmax (actual, min, max):
print 'actual', actual, type(actual)
print 'min', min, type(min)
print 'max', max, type(max)
if actual:
...
|
I have "2,5,7-9,12" string.
I want to get [2, 5, 7, 8, 9, 12] list from it.
Is there any built-in function for it in python?
Thanks.
UPD. I suppose, the straight answer is No. ... |
I've been tinkering in python this week and I got stuck on something.
If I had a 2D list like this:
myList = [[1,2],[3,4],[5,6]]
and I did this
>>>myList.index([3,4])
it would return
1
However, I want the ... |
there is my problem:
i'm trying to get all numbers from a Tkinter's text widget(get's the text from a file) this way:
text = self.text_field.get(1.0, 'end')
s = re.findall("\d+", text)
s ... |
I have a problem with my program and I was able to reproduce this unexpected (at least unexpected to me) behavior in a small scale so now I'm certain it is ... |
Say I have a list of numbers. How would I do to check that every item in the list is an int?
I have searched around, but haven't been able to find ... |
Working in Python, given a list of N sets of integers from the range range(s,n), how can I build a list that groups all these integers according to their set memberships? ... |
I wish to write a function foo to produce the following output:
foo(0) -> "01 00"
foo(1) -> "01 01"
foo([0]) -> "01 00"
foo([1]) -> "01 01"
foo([0,1]) -> "02 00 01"
foo([0,1,10]) -> "03 00 ... |
I've got a very long ( 1000 digit ) number.
I want to convert it into a list , how would you go about it since :
list(n)
TypeError: 'long' ... |
I am trying to subclass type in order to create a class allowing to build specialized types. e.g. a ListType :
>>> ListOfInt = ListType(list, value_type=int)
>>> issubclass(ListOfInt, list)
True
>>> issubclass(list, ListOfInt)
False
>>> # And ...
|
In my python Script I have:
user = nuke.getInput("Frames Turned On")
userLst = [user]
print userLst
Result: ['12,33,223']
I was wondering How I would remove the ' in the list, or somehow convert it into int?
... |
As an example:
>> s = '0123456'
>> list(s)
['0', '1', '2', '3', '4', '5', '6']
I have come up with this:
>> map( lambda x:int(x), list(s) )
[0, 1, 2, 3, 4, 5, 6]
Can this ... |
Can't seem to find a clue to this online and can't figure it out myself so:
How would I go about slicing a list so that I return a list of slices ... |
I am trying to call a reduce on a list that contains ints and longs. For example,
reduce( int.__mul__, [ 231212312412L, 3 ], 1 )
but I get an unimplemented error. and when ... |
Possible Duplicate:
How to convert strings into integers in python?
I need to change a list of strings into a list of integers how do i ... |
I not familiar with python and need help to convert a list containing strings and numbers (all represented as strings!) to a new list that include only the numbers.
|
|
I am using a python script and gflags to iterate over a list of possible config values for a project, write them to configuration files, and run the project.
I'm currently doing ... |
Sorry for the poor title, basically I want to access a list item based on another list item:
catList = [john, james, jack]
dateList = [1y, 2y, 3m]
for item in catList:
...
|
I am trying to add together two lists so the first item of one list is added to the first item of the other list, second to second and so on ... |
Ok so I made a method in python that does exactly what I want it to but its really ugly and repetitive, all it needs to do is get the first ... |
|
|
yeah I was trying to scale the data to look better on the program that my school offers. What I ended up doing was changing the list to an integer, like so. int(Col1[b]) * -3 which worked when I was using a positive data scheme. My new problem seems to be when working with negative data input it gives me an ... |
TypeError: list indices must be integers, not dict fix? by TheRake Sun May 01, 2011 8:51 am For my delete function, which is number 4. It comes up with a type error. Can anyone help fix my code so it works again? Thanks. Code: Select all #Updated Film Database records = [] #User Input user =" " while user !="0": ... |
I am getting "list index out of range" for index values within the range of the referenced list. For example, list[0] fails whereas list[list.index('valueInList')] succeeds. Where 'valueInList' is extracted from the list during a loop. Here's the code Code: Select all for line in inFile.readlines(): if line.find('POLB') : line = line.strip() ... |
|
Hello all, I am writing an interpreter for the Brainf**k(It's a real thing, look it up) programming language in Python and this is the only part of the interpreter that doesn't function correctly. My question is: When I run the program and I do this: , b . Why doesn't it print "b"? Thanks in advance! Code: Select ... |
|
|
New python user here, and I need a bit of help with manipulating lists of homemade objects. I have two object classes ("Drift" and "Quad") that both inherit from the same superclass. I'm attempting to build a large list of these, and, since this list contains a lot of repetition, I'd like to build this list by first creating a smaller ... |
|
How are we to know if it's one massive list or a bunch of separate lists? Try a for loop, if it allows you to do an int on the variable within your for loop it's a single list. If not try another loop within the first loop and so on. What code have you got so far? Also please change ... |
flags = [0, 0, 0, 0] def change_flag(event): for ix,button in enumerate(buttons): if event.widget == button: flag[ix] = not flag[ix] buttons = [] for i in flags: button = Button(...) ... |