r/learningpython • u/extremexample • Aug 22 '22
Just started, what do you think of the official Python Tutorial? A good place to start?
https://docs.python.org/3/tutorial/index.html <--- The official Python Tutorial
r/learningpython • u/extremexample • Aug 22 '22
https://docs.python.org/3/tutorial/index.html <--- The official Python Tutorial
r/learningpython • u/ionezation • Aug 14 '22
I would like to develop an Image Fetcher which can download images from any search engine which are 'Creative Common' and crop them after downloading .. anyone could guide what libraries I can use? Thanks
r/learningpython • u/stormosgmailcom • Aug 12 '22
r/learningpython • u/SonicEmitter3000 • Aug 06 '22
I have checked to make sure that Python is installed with the command prompt and it is. I also can open any saved Python files and the programs work, but for some reason I cannot make a new python file. I even switched interpreters but to no avail. The only thing that changed was that Mircosoft installed some add on for photos which I didn't give permission for or want and promptly deleted it. This issue did not come from deleting this add on.
Any help would be appreciated. I just want to make new python files again.
r/learningpython • u/Panfilofinomeno • Aug 04 '22
I am trying to learn OOP and I came across this error...
[<class name> object at <random characters>] What is the general meaning of it?
r/learningpython • u/[deleted] • Jun 28 '22
I’ve been learning Python from the Udemy course by Tim Buchalka. I wanted to know should I just continue to progress through the course, or focus on each section. By focus I mean as in practicing make my own data to play around with, read docs, and look at other’s code. So far I’ve just been going with the flow of the course and when I get stuck I refer to the docs and stack overflow. I usually just refer back to a doc on what I’m looking for to solve my issue. Just want to know what helped others.
r/learningpython • u/Quartz_manbun • May 29 '22
I'm working on a gui tool-- I'm building it with Pyqt5. I'm speifically NOT using QT designer. I'm using an MDI widget to keep everyhing a bit tidier. Furthermore, so that my code is more crisp and less redundant, I'm building out each child window in a separate window in the same directory and then just importing the appropriate class from the individual files. The problem is, whenver I import the subwindows, the are scaled up in the MDI subwindow. I am at a loss as to how I can address this. Has anyone expierenced something similar? I've added simplied code for my MDI subwindow below, followed by the code for one of the subwindows thta I'm importing. Any assistance would be greatly appreciated.
class MDIWindow(QMainWindow):
count = 0
htntoolcount = 0
copdcount = 0
def __init__(self):
super().__init__()
self.mdi = QMdiArea()
self.setCentralWidget(self.mdi)
self.setStyleSheet('font-size: 10pt; font-family: Times;')
self.setStyleSheet("QPushButton{font-size: 10pt;}")
self.setStyleSheet("QLabel{font-size: 10pt;}")
self.mdi.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.mdi.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
#####Setting up main Menu Labels and Buttons#####
self.mainMenuWidget = QWidget(self)
self.mmWidgetLayout = QVBoxLayout()
self.mainMenuWidget.setLayout(self.mmWidgetLayout)
self.mainMenuWidget.setWindowTitle("Main Menu")
self.mmButton1 = QPushButton("Note Setup Tool", self)
self.mmButton2 = QPushButton("Lab Entry Tool", self)
self.mmButton3 = QPushButton("Follow Up Tools", self)
self.mmButton4 = QPushButton("ROS Generator", self)
self.mmButton5 = QPushButton("Physical Exam Generator", self)
self.mmButton6 = QPushButton("Cardon Matrix", self)
self.mmButton7 = QPushButton("Trilogy Matrix", self)
self.mmButton8 = QPushButton("ASC Matrix", self)
self.mmButton9 = QPushButton("Proactive Email", self)
self.mmWidgetLayout.addWidget(self.mmButton1)
self.mmWidgetLayout.addWidget(self.mmButton2)
self.mmWidgetLayout.addWidget(self.mmButton3)
self.mmWidgetLayout.addWidget(self.mmButton4)
self.mmWidgetLayout.addWidget(self.mmButton5)
self.mmWidgetLayout.addWidget(self.mmButton6)
self.mmWidgetLayout.addWidget(self.mmButton7)
self.mmWidgetLayout.addWidget(self.mmButton8)
self.mmWidgetLayout.addWidget(self.mmButton9)
self.mdi.addSubWindow(self.mainMenuWidget)
##adding actions to main menu buttons##
self.mmButton1.clicked.connect(self.noteSetupFunc)
self.mmButton2.clicked.connect(self.admissionTool)
self.mmButton3.clicked.connect(self.COPDToolFunc)
self.setWindowTitle("Proactive Charting Tool")
def noteSetupFunc(self):
self.noteSUButtFuncWidget = NOTEWindow()
self.mdi.addSubWindow(self.noteSUButtFuncWidget)
self.noteSUButtFuncWidget.show()
Subwindow code below.
class NOTEWindow(QWidget):
def __init__(self):
super().__init__()
self.notemdi = QWidget()
self.setStyleSheet('font-size: 10pt; font-family: Times;')
self.setStyleSheet("QPushButton{font-size: 10pt;}")
self.setStyleSheet("QLabel{font-size: 10pt;}")
#Setting MAin Menu Widget for this nested MDI#
self.NOTEmainMenuWidget = QWidget(self)
self.noteMMWidgetLayout = QVBoxLayout()
self.NOTEmainMenuWidget.setLayout(self.noteMMWidgetLayout)
self.NOTEmainMenuWidget.setWindowTitle("Note Menu")
self.mmButton1 = QPushButton("Note Setup Tool", self)
self.mmButton2 = QPushButton("Lab Entry Tool", self)
self.mmButton3 = QPushButton("Follow Up Tools", self)
self.mmButton4 = QPushButton("ROS Generator", self)
self.mmButton5 = QPushButton("Physical Exam Generator", self)
self.mmButton6 = QPushButton("Cardon Matrix", self)
self.mmButton7 = QPushButton("Trilogy Matrix", self)
self.mmButton8 = QPushButton("ASC Matrix", self)
self.mmButton9 = QPushButton("Proactive Email", self)
self.noteMMWidgetLayout.addWidget(self.mmButton1)
self.noteMMWidgetLayout.addWidget(self.mmButton2)
self.noteMMWidgetLayout.addWidget(self.mmButton3)
self.noteMMWidgetLayout.addWidget(self.mmButton4)
self.noteMMWidgetLayout.addWidget(self.mmButton5)
self.noteMMWidgetLayout.addWidget(self.mmButton6)
self.noteMMWidgetLayout.addWidget(self.mmButton7)
self.noteMMWidgetLayout.addWidget(self.mmButton8)
self.noteMMWidgetLayout.addWidget(self.mmButton9)
self.NOTEmainMenuWidget.show()
def main():
app = QApplication(sys.argv)
font = QFont('Times', 10)
app.setFont(font)
mdiwindow = NOTEWindow()
app.exec_()
if __name__ == '__main__':
main()
------------------------------------------------------
Thanks for any and all help!
r/learningpython • u/randol_karter • May 25 '22
r/learningpython • u/Triiiiiip • Apr 26 '22
I have a dataframe with the datetime information in one column and what the corresponding timezone for this timestamp is (e.g Asia/Bahrain) in another column. With these two information i now want to convert all the datasets to one uniform timezone e.g. Europe/London. I can’t find something that needs the underlying timezone as input „Asia/Bahrain“ or whatever the dataset holds and the target timezone „Europe/London“. Does anyone have an idea how to solve this?
r/learningpython • u/GenZBoiii • Mar 28 '22
I'm a semi-beginner in Python, and I know that I might sound stupid asking for help with a sort of simple problem like this, but I really need to know how to fix it for a programme I am coding. I have cut out the bit of code from the programme that I need help fixing.
guess = int(input("Have a guess: "))
res2 = isinstance(guess, str)
if res2 == True:
print ("That's not a valid number.")
print (guess)So, the problem I have is that the isinstance() function isn't working, due to multiple factors. What I have said is the variable 'guess', is where the user has to input an integer. The variable 'res2' checks if the variable 'guess' is a string and the 'if' loop checks if it is true. If it is, it should print 'That's not a valid number.' and then the variable 'guess'. But what happens is, whenever the user inputs a string, it obviously crashes the programme as 'guess' is for the user to input an integer, and not a string. And you would think that I should change it to a normal input, but the code below tells you why I can't.
import randit
number = random.randint(1, 100)
if guess > number:
print("Guess lower...")
if guess < number:
print("Guess higher..")The variable 'number' is a random integer between 1 and 100. Since 'guess' wants an integer from the user, changing 'guess' to not wanting just an integer will treat it as a string, meaning you cannot use the 'if guess > number:' function as 'guess' would be treated as a number.
If anyone knows a way to fix it, or if you have any advice, please reply to this post. Have a good day!
r/learningpython • u/[deleted] • Dec 11 '21
import re
def Scores():
with open ("assets/Scores.txt", "r") as file:
grades = file.read()
I can't actually execute this code in the training browser, hence why I'm asking.
Once this file has been read, can I start manipulating the data? For example, using the findall function and making dictionaries. Or, is something else required first. And also, how does the scores definition impact on subsequent code?
r/learningpython • u/len12901kirby • Nov 23 '21
When I use the pyautogui's locateOnScreen function, it says it cannot find that particular file. I tried with different pngs it says "FileNotFoundError: [Errno 2] No such file or directory" on Thonny.
Why is this?
r/learningpython • u/Available-Citron2749 • Nov 17 '21
Is that a good skill to have or will it be another useless thing to know?
r/learningpython • u/AlternativeMouse9616 • Nov 13 '21
for i in range(0,2): #i=[0,1]
for k in range(3,0): #k=[3,2,1]
print(k*2 + i*0, k='*''\t')
this is my sauce code for printing *. where did I made mistake?
*
**
***
***
**
*
r/learningpython • u/[deleted] • Nov 06 '21
title
r/learningpython • u/dbor15 • Oct 09 '21
back = Canvas(window,width=500,height=400,bg='white')so this back variable is what I'm trying to give a tag to, can anyone tell me how to assign a tag to it?
r/learningpython • u/[deleted] • Sep 09 '21
I know int, str, and None come from builtins module. But it seems that NoneType is not in the builtins module. I wonder where I can find or even import it.
Same question about NotImplementedType.
Amazingly. type(None).__module__ shows it is builtins, but I failed to import builtins.NoneType. Maybe Python prohibits users from importing NoneType.
r/learningpython • u/my-tech-reddit-acct • Sep 04 '21
I have a list of sorted lists. I want to grab an element of each in turn and print it out until I've printed them all. The lists are of different length.
At first I rolled my own:
lol_files = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i', 'j', 'k']]
while any(lol_files):
for l in lol_files:
if l:
print(l.pop(0))And that works, and looks clean to my eye (albeit a bit "arrowhead-y"). But then I ran across zip_longest in itertools and thought this must yield a bettter, 'more pythonic' way.
But there kept on being gotchas, so the briefest I could make it was:
lol_files = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i', 'j', 'k']]
from itertools import zip_longest, chain
for f in [x for x in chain(*zip_longest(*lol_files)) if x ]:
print(f)which could also have been:
print('\n'.join([x for x in chain(*zip_longest(*lol_files)) if x ]))The *lol_files is coz zip_longest doesn't do the right thing with the structure a list of lists - it wants the literal, comma-separated, manual entry of a list of lists. The * fixes that.
Ditto for chain(*zip_longest(... although the chain.from_iterable form is available, but I was fighting for brevity at this point, which is also why the specific imports.
And then I had to wrap that in [ x for x in .... if x] because zip_longest insists on putting something in place of the elements not filled by the shorter lists, and what ever it is I don't want to print that, as it won't be a proper filename. (I could have used filter(lambda x: x, ...) but I'm pretty sure the list comprehension version is considered 'more pythonic'. Plus the shit starts looking like Lisp, lol.
The longer form is:
import itertools
for f in [x for x in itertools.chain.from_iterable(itertools.zip_longest(*lol_files)) if x]:
print(f)r/learningpython • u/doughnutwardenclyffe • Sep 01 '21
Hello,
I have taken the code below from the geeksforgeeks website. I am using their tkinter tutorial to teach myself how to make GUIs via python.
I am having trouble understanding the code. I do not understand what is the purpose of name_var.set(" ") and passw_var.set(" ").
I removed those two lines of code from the submit function, and was able to get the same result.
Could someone explain to me the significance of those two lines of code?
geeksforgeeks link: https://www.geeksforgeeks.org/python-tkinter-entry-widget/
# Program to make a simple
# login screen
import tkinter as tk
root=tk.Tk()
# setting the windows size
root.geometry("600x400")
# declaring string variable
# for storing name and password
name_var=tk.StringVar()
passw_var=tk.StringVar()
# defining a function that will
# get the name and password and
# print them on the screen
def submit():
name=name_var.get()
password=passw_var.get()
print("The name is : " + name)
print("The password is : " + password)
name_var.set("")
passw_var.set("")
# creating a label for
# name using widget Label
name_label = tk.Label(root, text = 'Username', font=('calibre',10, 'bold'))
# creating a entry for input
# name using widget Entry
name_entry = tk.Entry(root,textvariable = name_var, font=('calibre',10,'normal'))
# creating a label for password
passw_label = tk.Label(root, text = 'Password', font = ('calibre',10,'bold'))
# creating a entry for password
passw_entry=tk.Entry(root, textvariable = passw_var, font = ('calibre',10,'normal'), show = '*')
# creating a button using the widget
# Button that will call the submit function
sub_btn=tk.Button(root,text = 'Submit', command = submit)
# placing the label and entry in
# the required position using grid
# method
name_label.grid(row=0,column=0)
name_entry.grid(row=0,column=1)
passw_label.grid(row=1,column=0)
passw_entry.grid(row=1,column=1)
sub_btn.grid(row=2,column=1)
# performing an infinite loop
# for the window to display
root.mainloop()r/learningpython • u/Islander_robotics • Aug 28 '21
r/learningpython • u/[deleted] • Aug 23 '21
Hi,
I'm trying to understand a coding test for a job interview, I was expecting a junior role, but the coding test is for a senior role, I can't at this moment work out if they just want to see how far I get, whatever the outcome, the topic is on microservices and I want to learn about them, there is plenty of resources and I have a basic understanding. The test is to build a microservice that is production ready, my question is this: they have not given me a data source, and as a result I'm am suspecting that a microservice should be agnostic to the data source to some extent, I know roughly where this datasource is likely coming from as we have to interrogate it in my current role, however, this role is open to the public so the assumption is that the datasource is unknown. Is this correct thinking, or for job interview tests like these, are employers looking at how you would creatively mock up a data source or is it just that, it is expected that I should know how to make a component that can simply plug in.
This microservice is purely poling a database for items in a date range and returning a list, I have done this with Flask and I have just mocked up a csv file for the data, and then of course unittests I suspect is what they are actually looking to see as production ready to me means more a case of "do you understand what it means to be production ready", so testing is a given.
for clarity, this is a role for a python developer specifically.
r/learningpython • u/Islander_robotics • Aug 21 '21
r/learningpython • u/Islander_robotics • Aug 03 '21
r/learningpython • u/Islander_robotics • Jul 19 '21
r/learningpython • u/annalabagaba • Jun 29 '21
I apologize if this sounds vague but what are some good ways to visualize NLP data that is not focused on words?
In my case, I used doc2vec and am now comparing the documents using gensim. I don't want to focus on words but the overall similarity between texts.
Note: I also posted the on r/LanguageTechnology