Questions tagged as 'python-2.7'

2
answers

How to Direct Commands to Linux Terminal with Python

I need to create a script in Phyton that when run either by mouse click or 'enter' the keyboard, it opens the Linux terminal itself and executes any command inside it. I've already been able to get it to run the command, but as long as the scrip...
asked by 17.08.2014 / 21:42
1
answer

Recursive function for integer input

I have this code but it does not work very well, that is, if it is integer at first numOfValues is correct, but if not it is with type None , since what is in memory is the first input ( which is not integer). I would like, regardle...
asked by 04.03.2015 / 15:56
1
answer

What are the best practices for working with Legacy Database in Django?

I have a legacy database and would like to know what good practices for naming tables, or tips on how to use inflections (as in Rails) for Django in the latest version.     
asked by 21.01.2014 / 18:34
4
answers

Flatten list of lists. Is a more concise solution possible?

I solved the following Python exercise:    Implement a function that receives a list of length lists   and return a list of one dimension. The solution I was able to do was as follows: #!/usr/bin/env python #-*- coding: utf-8 -*- def l...
asked by 10.03.2018 / 13:44
3
answers

Fibonacci running in parallel? Threads?

def recur_fibo(n): """Recursive function to print Fibonacci sequence""" if n <= 1: return n else: return(recur_fibo(n-1) + recur_fibo(n-2)) This code makes the recursive fibonacci "simple" ... Imagine that I called...
asked by 10.08.2016 / 02:57
1
answer

Write the result of a variable in the mysql database using python passed as parameter

I have a database in mysql that contains a table with multiple expressions. I can extract the expressions through procedure , solve them, but when I want to return the calculation value to the bank with another procedure , thi...
asked by 26.06.2015 / 04:43
1
answer

"AttributeError: __exit__" problem in Python

In a group, I asked them to give me tips on a program to test my knowledge. He told me to create a program that reads a file named "arquive.txt" and manages files CHAR and STAGE , with the file like this: [CHAR] Exemplo = C...
asked by 04.12.2016 / 01:58
1
answer

In Python, how do you explain the expression 'x = not x'

I already know the result, but I would like to understand what happens, why this result ... For example: >>> a = True >>> b = not a >>> print(b) False It's a simple thing, but I feel annoyed to use somethin...
asked by 13.11.2014 / 10:50
3
answers

How to sum list values in tuples?

I have for example a list with tuples, and within these tuples I have 2 lists, where only the second list of each tuple varies: x= [(y, [1, 2]), (y, [3,4]), (y, [5, 6])] How do I add the first values of lists within the tuples, like t...
asked by 17.04.2015 / 16:13
1
answer

Adding a comma to a string

Good personal and possible add comma in an example string: a = '1234567890abcdefghijklmnopqrstuvwxyz_' So that she stays like this a = 1,2,3,4,5,6,7....     
asked by 04.12.2015 / 22:13