Questions tagged as 'python-2.7'

1
answer

Lists of empty lists (Python)

Using Python 2.7.12 I need to create a list as follows: lista = [[],[],[],[],.........,[]] This list must have a very large number of lists within it (so the ........). I found the following way to accomplish this: lista = [[]]*n Wh...
asked by 15.05.2018 / 01:31
2
answers

Convert a list of lists into a single list

I'm working on Python 2.7. I have this result: Resultado=[['A','B','C'],['D','E','F'],['G','H','I']] How can I make this a list? And get the following: Lista=['A','B','C','D','E','F','G','H','I'] Thank you!     
asked by 30.05.2016 / 16:50
2
answers

In Python, is there any rule or advantage over using 'Self'?

Consider the examples below: Example 1: > class PrintText(): > def __init__(self): > text = 'Funciona!' > self.printa(text) > > def printa(self, text): > print(text) Example 2...
asked by 09.07.2014 / 17:38
6
answers

Convert an array of floats to integer

Suppose the following: import numpy as np a = np.array ( [1.1, 2.2, 3.3] ) How to convert this array to int without having to iterate each element or using another array? Why to: b = int(a) It gives an error because it is on...
asked by 06.01.2014 / 00:50
4
answers

Program that returns the non-common numbers of two lists (python)

I'm trying to make a program, in Python, that returns a list with elements not common between two other lists. I made the following code: def indice(a,b): ind = [] for i in range (len(a)): for w in range (len(b)): i...
asked by 30.03.2017 / 03:33
4
answers

How do I put a Python module in a folder other than my script?

I am trying to run a script in Python ( v2.4 and v2.7 ) and created a module with some methods. Unfortunately this module needs to be in a separate folder. At Python documentation and up to here in Stack Overflow I found numerous post tal...
asked by 25.04.2014 / 22:11
1
answer

Check if list is the same

I have the following list: x = [([1,2], [1, 2]), ([1,2], [4, 5])] And I wanted to check if the first list of each tuple is always the same. Note: List x contains tuples with lists. These tuples may vary, meaning there may be more tuples...
asked by 28.04.2015 / 20:20
4
answers

How to determine the index of elements in a list in another

Work with python 2.7 . Considering the following: S_names=["A", "B", "C", "D", "E", "F", "G"] S_values=[1,3,4,2,5,8,10] other=["Z","W","B","S","A","E","X","T","D","G","L","C","F"] I need to find in what position of other are the...
asked by 23.05.2016 / 20:23
2
answers

How to play audio with PyQt?

Is there any way to run an audio file with PyQt? Is it possible to do this only with PyQt or do you need to install another library?     
asked by 11.11.2016 / 13:48
3
answers

How to run programs written in Python on windows hiding terminal feedback

I have the following situation: I have a program written in python that works with Gtk + webkit + flask. To run such a program I should log in to the CMD and type "python.py file" and it will starta my GUI application normally. Where according t...
asked by 23.12.2015 / 04:46