list « integer « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » integer » list 

1. How to expose std::vector as a Python list using SWIG?    stackoverflow.com

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 ...

2. Handle either a list or single integer as an argument    stackoverflow.com

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 ...

3. Converting list of integers into a binary "string" in python    stackoverflow.com

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 = ...

4. Convert binary string to list of integers using Python    stackoverflow.com

I am new to Python. Here's what I am trying to do:

  1. Slice a long binary string into 3 digit-long chunks.
  2. Store each "chunk" into a list called row.
  3. Convert each ...

5. Python: List to integers    stackoverflow.com

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 ...

6. List and Integer query    stackoverflow.com

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 ...

7. Multiplying a subset of a list of integers together in python    stackoverflow.com

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 ...

8. What is the easiest way to convert list with str into list with int? =)    stackoverflow.com

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 ...

9. Check if the integer in a list is not duplicated, and sequential    stackoverflow.com

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 ...

10. 'int' object is not callable when the object is a list? Python    stackoverflow.com

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'>

11. Unable to modify a global int, but can modify a list. How?    stackoverflow.com

>>> LISTL = []
>>> VAR1 = 0
>>> def foo():
...     VAR1 += 1
...     return VAR1
... 
On calling foo(), I get this error:
UnboundLocalError: local variable ...

12. Call int() function on every list element in Python    stackoverflow.com

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, ...

13. Parse a map of int -> list from a string    stackoverflow.com

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 ...

14. How to use map function on nested lists and converting strings to integers?    stackoverflow.com

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', ...

15. Filter a list in python get integers    stackoverflow.com

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 ...

16. Extract integer from a list    stackoverflow.com

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 ...

17. Add to integers in a list    stackoverflow.com

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 ...

18. Using an iterator to print integers    stackoverflow.com

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 ...

19. Python - How to clear a integer from a list completely?    stackoverflow.com

# 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 ...

20. How to change string to Integers in python    stackoverflow.com

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) ...

21. Python - Quick Integer List Creation    stackoverflow.com

Can I make a list of numbers from 1 to 6 in one line without a loop? goal:

[1,2,3,4,5,6]

22. Using python to return a list of squared integers    stackoverflow.com

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 ...

23. Bulkloader import list of integers    stackoverflow.com

How should I configure import_transform and export_transform im my configuration yaml file to be able to export and import multiple integer property?

24. convert an int to list of individual digitals more faster?    stackoverflow.com

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 ...

25. TypeError: can only concatenate list (not "int") to list    stackoverflow.com

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()
  ...

26. Python min() apparently not accepting list of ints    stackoverflow.com

def minmax (actual, min, max):
    print 'actual', actual, type(actual)
    print 'min', min, type(min)
    print 'max', max, type(max)
    if actual:
 ...

27. parse string of integer sets with intervals to list    stackoverflow.com

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. ...

28. Python: Return 2 ints for index in 2D lists given item    stackoverflow.com

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 ...

29. Python error: list indices must be integers, not unicode    stackoverflow.com

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 ...

30. Unexpected import behavior, treating integers and lists differently    stackoverflow.com

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 ...

31. How to test if every item in a list of type 'int'?    stackoverflow.com

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 ...

32. Grouping integers by set membership in Python    stackoverflow.com

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? ...

33. Mixing ints and lists    stackoverflow.com

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 ...

34. Create a list from a long int    stackoverflow.com

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' ...

35. Python : subclass `type` to create specialized types (e.g. a "list of int")    stackoverflow.com

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 ...

36. How to convert a string list into an integer in python    stackoverflow.com

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? ...

37. Looking for a snippet to convert a string into a list of integers    stackoverflow.com

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 ...

38. How to slice list into contiguous groups of non-zero integers in Python    stackoverflow.com

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 ...

39. I want to call a reduce with a list that contains longs an ints in python    stackoverflow.com

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 ...

40. How to change a list of strings to integers - Python    stackoverflow.com

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 ...

41. convert a mixed list of strings to a list of integer    stackoverflow.com

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.

  • input string : ...

43. using python gflags to take in a list of ints    stackoverflow.com

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 ...

44. Python, Lists - Use 'Item' as integer variable    stackoverflow.com

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:
   ...

45. Python - Add two lists    stackoverflow.com

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 ...

46. Python: Getting ints from a string    stackoverflow.com

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 ...

49. Multiplying a list object with a negative integer.    bytes.com

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 ...

50. TypeError: list indices must be integers, not dict fix?    python-forum.org

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": ...

51. indexing list with static int fails while list.index succeed    python-forum.org

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() ...

52. str to int conversion in a 2D list [Solved]    python-forum.org

53. Manipulating integer lists    python-forum.org

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 ...

54. multiply list by integer?    python-forum.org

56. Multiplying a list of home-made objects by an integer    python-forum.org

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 ...

57. list indices must be integers, not str    python-forum.org

58. converting lists with strings in them to integers    python-forum.org

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 ...

59. Pass element of integer list by reference    python-forum.org

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(...) ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.