Questions tagged as 'python'

1
answer

How to "generate" multiple TCP clients using Threads in the same script?

I wrote the code for a simple TCP client: from socket import * # Configurações de conexão do servidor # O nome do servidor pode ser o endereço de # IP ou o domínio (ola.python.net) serverHost = 'localhost'#ip do servidor serverPort = 50008 #...
asked by 17.08.2016 / 21:31
1
answer

Function returning None

I'm trying to calculate the area of a file using Python with the following function: from __future__ import division import ogr import osr def transform_geometries(datasource, src_epsg, dst_espg): src_srs = osr.SpatialReference() sr...
asked by 26.10.2016 / 01:41
1
answer

How to make a class or test function with pytest?

Be a program in Python, such as fibonacci calculus: def fibR(n): if n==1 or n==2: return 1 return fib(n-1)+fib(n-2) print (fibR(5)) How to make a test class / function using pytest, for example?     
asked by 06.08.2016 / 03:38
1
answer

How to print a function in Python?

I'm trying to make this code work but I'm not getting it. Enter the name and year of birth, and return the correct values dps, but not able to return the number of years ... What is my error? print 'Digite seu nome:' nome = raw_input() pri...
asked by 19.09.2016 / 04:35
1
answer

Python - PHPSESSID

I'm trying to create a script that enters a website without having to log in through the requests library. I want to do this using the PHPSESSID cookie. How can I do this?     
asked by 01.08.2016 / 15:53
1
answer

"NameError: [word that I typed in] is not defined" when trying to read from the keyboard

I was following a small tutorial. I did everything exactly as indicated in the tutorial and gave me a variable definition error whereas in the tutorial it did not work. Can someone explain the error? Code: print "hello wolrd" myName = in...
asked by 02.08.2016 / 01:58
2
answers

Choose an index from a list

I have a list: l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] I would like to choose a value between indexes 6 and 14 from this list, but do this 5 times and store those values in another list. How do I? If it were of any index,...
asked by 16.07.2016 / 12:48
1
answer

Python - "Error: IndexError: list index out of range"

I can not find the cause of the error. The program runs fine, it displays all the rows of the table, however, this error message appears. import re import xlrd wb = xlrd.open_workbook('exemplo.xls', encoding_override="cp1252", ragged_rows=Tru...
asked by 17.07.2016 / 18:27
1
answer

Variable not set in for-loop in Python

I'm having a problem with a code that should read 4 values using raw.input().split() and then a for-loop to transform those values into float . The interpreter returns me:    "name 'val' is not defined" Follow the code...
asked by 26.08.2016 / 00:46
1
answer

Problem with float python (uri 1098)

I'm trying to solve this problem and when I run the code, at some point it stops working correctly . I think it's because of rounding, but when that part is removed, the code executes to infinity. i = 0 j = 1 while(i != 2.2): print('I=%...
asked by 21.08.2016 / 00:42