Posts by Ed S • 2,057 points
164 posts
-
0
votes1
answer483
viewsA: How to do a class or test function with pytest?
def fibR(n): if n==1 or n==2: return 1 return fibR(n-1)+fibR(n-2) In the same directory:test_fib.py: import pytest from fib import fibR def test_fib_1_equals_1(): assert fibR(1) == 1 def…
-
0
votes1
answer483
viewsQ: How to do a class or test function with pytest?
Be a Python program, for example, the calculation of Fibonnaci: def fibR(n): if n==1 or n==2: return 1 return fib(n-1)+fib(n-2) print (fibR(5)) How to do a test class/function using pytest, for…
-
6
votes1
answer1263
viewsQ: How to avoid buffer overflow in C/C++
The program below allows the occurrence of memory overflow, as it is possible to overwrite the variable zero, placing a value "large" in the variable buffer. How to make a safe program by avoiding…
-
0
votes2
answers2753
viewsQ: Capturing user keystrokes in Python on Linux
import pyHook import pythoncom def tecla_pressionada(evento): # print("Alguma tecla pressionada") print (chr(evento.Ascii)) hook = pyHook.HookManager() hook.KeyDown = tecla_pressionada #sem ()…
-
1
votes1
answer828
viewsQ: Creating an executable file of a python program in windows 10
I am a Backbox Linux user but I need to generate an executable for a program written in Python. I installed Windows 10 Pro on Vmware with Python 2.7 and Python 3.4. I use Pycharm and IDLE IDE. I…
-
3
votes2
answers466
viewsQ: Changing Key in Windows 10 Registry
The code below is giving "Registry error", that is, it does not create the key in the Windows registry. Does anyone have any idea how to resolve? import socket import time import subprocess…
-
4
votes2
answers890
viewsQ: How to add parallelism in execution with the subprocess module?
The code will be used in 2 testing virtual machines (Linux and Windows). The code below works but every time I run a program, for example the notepad, the prompt is stuck until I close the program.…
-
1
votes1
answer761
viewsQ: Creating a program to get important news on a website
from bs4 import BeautifulSoup import requests url = 'http://g1.com.br/' header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) '…
-
4
votes1
answer5651
viewsQ: How to take screenshot of the screen in Python?
I would like to make a program that screenshots the screen ( screen photo) in Python. I found the following code: import pyscreenshot as ImageGrab if __name__ == "__main__": # fullscreen…
-
1
votes2
answers670
viewsQ: Building a python Crawler web. I need help adding threads
I am trying to develop a Rawler web for studies. It is very simple and I would like to improve it. How to use threads to accelerate/improve the process? The program could make multiple links in…
-
2
votes2
answers1231
viewsQ: Regular expression (regex) for links to web pages using Python
I am trying to learn how to create a webcrawler. Part of the code will be to extract links on a web page (links starting with http or https): import re urls = re.findall(r'href=[\'"]?([^\'"…
-
1
votes1
answer270
viewsQ: Developing a BOT for polls with wordpress plugin Polldaddy
I tried to follow: https://github.com/dado3212/PollDaddyHack import requests dados ={"poll_id" : "9484127", "answer_id" :"43276282", "number_of_votes" : "1000"} url =…
-
11
votes1
answer15048
viewsQ: Understanding the concept of Threads in practice (in Python)
from threading import Thread import time def carrinho(velocidade,nome): distancia = 0 while distancia <= 1000: print("Carrinho :",nome,distancia) distancia += velocidade time.sleep(0.3) carrinho1…
-
3
votes3
answers6679
viewsQ: creating a python voting bot
import requests dados = {"action": "polls", "view":"process", "poll_id":"2", "poll_2":"6", "poll_2_nonce":"e29cc82a53"} url = "http://soulegal.byethost7.com/wp/wp-admin/admin-ajax.php"…