Questions tagged as 'python'

1
answer

How to run another program by python?

I'm trying to make a calculation engine in Python . For example, I have a program named engine.py , which takes an equation and returns the roots. I wanted to write another program named interface.py , which would just take the...
asked by 30.10.2015 / 14:51
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
2
answers

"Deep Copy" without importing the "copy" module?

Is there any other way to perform a "Deep Copy" of objects in Python without using deepcopy() of the default library copy ? Could the code below be spelled otherwise? import copy class Xpto: pass lst = [ Xpto(), Xpto(...
asked by 21.10.2017 / 02:02
3
answers

How to merge multiple lists into one array

As a way to merge two lists into an array, where each column in the array represents one of those lists. Example: a = ["Laranja", "Maçã", "Uva"] b = [40, 50, 2, 45, 56] Expected result: x = (["Laranja", 40], ["Maça", 50], ["Uva", 2], [...
asked by 09.11.2016 / 23:27
4
answers

How to remove an element from an XML with Python?

The case is that I have a file produced by a Garmin (GPS device for physical exercise) and I want to remove all the fields related to the heart beat to pass the file to an athlete who did the exercise with me. The file is in GPX format and looks...
asked by 09.01.2014 / 19:44
2
answers

How to get the set of all arguments in Python?

Python has both positional and named parameters as * and ** operators that allow you to receive an arbitrary number of additional arguments: def foo(a, b, c=1, *args, **kwargs): print(a, b, c, args, kwargs) foo(1, 2)...
asked by 24.11.2015 / 08:29
1
answer

In Python 2 is it more pervasive to use range or xrange?

The programming language I use most is : (), and after it has been implemented Generators in version 5.5, it is said to be faster to use for generating numbers in sequence than with the function range - which creates a array with...
asked by 17.12.2015 / 19:43
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
1
answer

Machine Learning Chart

I'm having a problem generating a graph using Python - Machine Learning - Naive Bayes model - I would plot an F1 for the different values of K, below we have the classifier that gives me the following outputs:    Mean Accuracy: 0.896551724138...
asked by 01.09.2017 / 02:26