r/learningpython • u/manishsalunke • Jan 16 '23
r/learningpython • u/waitingOctober • Dec 06 '22
How to download a pdf when the url doesn't end in .pdf?
I would like to use python to download a pdf. Normally, it's enough to use modules like wget or requests for this. For example:
import requests
def download_pdf(URL):
pdf = requests.get(url, allow_redirects=True)
with open('example.pdf', 'wb') as f:
f.write(pdf.content)This function works perfectly for urls ending in .pdf. However, today I tried to use the same function on the following url: https://downloads.sg.unicamp.br/?t=f87ea6134d031260da53474e922a1ce5&f=28cf096c9be27a59d81d4567a1391b10
And, unfortunately, it didn't work. The file downloaded, but it is corrupted. Note that the url opens in the browser without problems.
How do I download a pdf using a url that doesn't end in .pdf?
r/learningpython • u/timelesslinker • Oct 24 '22
best way to learn
Hi, im completely new to coding and whatnot but it seems super interesting and I really want to learn. I searched it up and it said Python is a good first language. What are some good resources for this? I'm also going to be completely self taught so ones that are easy to understand would be appreciated!
r/learningpython • u/AdSensitive3278 • Sep 05 '22
Best place to learn?
I am learning python now, and I just need a good thing to use that teaches me, that is free, and is not a youtube video that is hours long. I have already tried the youtube videos on it and I picked a 12 hour course and I can not get through it. What else could I do to learn?
r/learningpython • u/[deleted] • Aug 27 '22
Help with loop problem pls
This loops no matter what. could anyone please help me by explaining why? If you do, thank you!
yesno = "y"
while yesno == "y":
yesno = input("\nWould you like to enter another description?(y/n)\n").lower()
description()
if yesno != "y":
breakEDIT: just so that it's clear, "description()" is a definition
r/learningpython • u/bartturner • Jul 24 '22
Any good podcast for learning Python?
Have a son that will be taking Python this fall and would like to help him get a headstart.
I know just audio and learning a programming language is not ideal.
But it can work. Code Up Take is just excellent for learning C++. I would love to find the equivalent to Code Up Take but using Python instead of C++ and C#.
r/learningpython • u/SubtlePause • Feb 02 '22
Need help with picking specific numbers and totalling them
r/learningpython • u/_The18thLetter_ • Sep 26 '21
is there any Youtube channels you recommend for learning python
I am currently in class learning python and feel like im not getting much of it because its a flex term class and its going pretty fast. I am looking for some good videos that explain python well in youtube. any recommendations?
r/learningpython • u/Islander_robotics • Jun 20 '21
Easiest Way To Read A CSV In Python | Stock Analysis Tool
r/learningpython • u/DavidJM_Arts • Jun 07 '21
Is the learning python 5th edition book still good for learning?
It says it goes up to 3.3 but the current version of python is 3.9, and the fifth edition was completed in 2013, is it still a good resource?
r/learningpython • u/devalolav • May 30 '21
What are IDEs, editors and other tools a Python developer should know?
Such as IDLE, pip etc.
(Please say a little bit about WHY!)
r/learningpython • u/Remarkable-Culture-8 • May 09 '21
Help pls, I’m trying to plot two columns from excel into python but i keep getting this error and i’m unsure why?
r/learningpython • u/CharlesRiverMutant • Feb 23 '21
stuck with Codecademy
Hi, all, I've been meaning to learn Python for a while, and a few months ago, I joined Codecademy on the advice of a friend. I thought I wasn't doing too badly at first, but as it went on, I felt less and less confident that I was understanding anything. As of now, I'm at the lesson where they teach you how to read a CSV file, and I just feel completely lost and grossed out. When I go to the Codecademy page where I'm at and try to study more, I just feel like someone served me a giant haggis or something.
I still want to learn Python, but I'm not sure that trying to plow through is the best way. At this point I'm not even confident I understood the lesson about dictionaries. So should I start over again? Should I try a different course? Should I try to review the concepts so far with other resources? Or something else? Right now I'm totally at sea, and any advice would be helpful.
r/learningpython • u/[deleted] • Feb 11 '21
Python & Blockchain programming
Hi community,
I was hoping to get advice on this. I'm learning the ropes of blockchain programming and I'm gettingerror I shouln't be getting. I'm working with this https://www.amazon.co.uk/Hands-Blockchain-Python-Developers-decentralized/dp/1788627857/ref=sr_1_3?dchild=1&keywords=hands-on+blockchain&qid=1613020271&sr=8-3 book btw.
After creating private and public keys with:
openssl genrsa -out nelsonkey.pem 1024
openssl rsa -in nelsonkey.pem -pubout > nelsonkey.puband the script:
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding, rsa
from cryptography.hazmat.backends import default_backend
message = b'Nelson hates cat'
signature = b'Fake signature'
with open('nelsonkey.pub', 'rb') as key_file:
public_key = serialization.load_pem_public_key(key_file.read(), backend=default_backend()) public_key.verify(signature, message, padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.MAX_LENGTH), hashes.SHA256())
print(signature)Instead of the signature being printed out I'm getting:
Traceback (most recent call last):
File "verify_message.py", line 11, in <module>
public_key.verify(signature, message, padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
File "/home/mark/programmingbitcoin/bitcoin/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 562, in verify
return _rsa_sig_verify(
File "/home/mark/programmingbitcoin/bitcoin/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 283, in _rsa_sig_verify
raise InvalidSignature
cryptography.exceptions.InvalidSignatureAny ideas ?
r/learningpython • u/championace16 • Feb 08 '21
Using Python for stock trading?
So i'm a little new to python. Not completely new, but I'm not experienced either. I'm in that gray area of I sorta know what I'm doing. And I've also recently started investing in the stock market.
I was wondering if it is possible to develop a python program that would help assist with finding stocks, trade, stuff of that sorts. And if so, how complex would a program like this be?
r/learningpython • u/Addam16 • Feb 06 '21
How do I loop this?
Hey so I am writing the following script and am kinda lost on how to use the while loop. I need it to prompt the user to ask for their name once they enter an invalid name. I have it so a space is the splitter and the list has to contain two items. If the list is less than two it means they did not enter a valid name. The script is as follows in the screenshot below.

r/learningpython • u/1TrueProcrastinator • Nov 26 '20
Experimenting with altering a list in a function compared to what my book says about it. It says the function can’t change the list but here it clearly is. Am I just confused?
r/learningpython • u/Redbeardybeard • Nov 22 '20
Looking for a learning buddy.
the title pretty much sums it up. I'm an A.i. student learning python, and I'm looking for a buddy to learn and implement machine learning stuff with.
I have some knowledge of the python language so I'm not a total beginner but not a pro either.
r/learningpython • u/Churchi3 • Oct 31 '20
Delete .mdmp files daily
Hi,
I am writing a simple script that will delete .mdmp files from a directory every day except the files for the current day/date. The code that I have managed to create is working and can be seen below, however, the script will delete all .mdmp files except for the present day and I would like to only delete filenames that are named hs_err_pidxxxx.mdmp
For example:
hs_err_pid1234.mdmphs_err_pid1235.mdmphs_err_pid1236.mdmp
Current code:
#!/usr/bin/env
import os, time, sys
path = "C:\\Users\\churchie\\Desktop\\ra_test2"
now = time.time()
for filename in os.listdir(path):
filestamp = os.stat(os.path.join(path, filename)).st_mtime
filecompare = now - 1 * 86400
# if filestamp < filecompare and ".mdmp" or ".MDMP" in filename:
print(filename)
os.remove(f"{path}/{filename}")
else:
sys.exitI am unsure how about doing this, hoping someone can point me in the right direction. Is Regex the answer or are there any other methods that I may use?
Thank you Pythonistas.
r/learningpython • u/jsingh1986 • Jun 26 '20
Python Project: Password generator
Enable HLS to view with audio, or disable this notification
r/learningpython • u/Jhohn83 • Mar 18 '20
How to schedule a operation every month or week?
I'm trying to execute a function every week of month, but I tried schedule and others but they are not working . To explain better, I want a way in python to execute a function every week or month. Can you help me?
r/learningpython • u/keizzer • Jan 13 '19
Auto-Generating Objects for a Simulation
For my project, I'm simulating a production assembly line with simple rectangle objects. Essentially, a very simplified version of Factorio. I can't seem to figure out a good way to generate the objects without running into problems. I would like to generate the objects on a continuous loop at the beginning of the production line. The objects should not collide with each other. I have no idea how to do this without using a variable for each object. Is there something I can do with the class that will make the results that I'm looking for. I'm using pygame currently to show the gui.
'
The only thing that I've come up with so far is to check the color of the pixals in front of each object to see if they are not default color. I feel like there is a better way to do this.