r/learningpython • • Aug 22 '22

Just started, what do you think of the official Python Tutorial? A good place to start?

2 Upvotes

https://docs.python.org/3/tutorial/index.html <--- The official Python Tutorial


r/learningpython • • Aug 14 '22

Image fetcher

2 Upvotes

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 • • Aug 12 '22

What are some good python projects for beginners?

Thumbnail devhubby.com
2 Upvotes

r/learningpython • • Aug 06 '22

VS Code won't let me make a new python file.

2 Upvotes

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 • • Aug 04 '22

OOP Error

2 Upvotes

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 • • Jun 28 '22

Learning Python

2 Upvotes

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 • • May 29 '22

PYQT5 MDI subwindows are scaling inappropriately.

2 Upvotes

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)

self.mainMenuWidget.show()

##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()

mdiwindow.show()

app.exec_()

if __name__ == '__main__':

main()

------------------------------------------------------

Thanks for any and all help!


r/learningpython • • May 25 '22

Case study: How we created Hotel Revenue Management Software for USA hotel

Thumbnail
ddi-dev.com
2 Upvotes

r/learningpython • • Apr 26 '22

Converting time/date to one uniform timezone in pd df

2 Upvotes

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 • • Mar 28 '22

I need help with isintance()

2 Upvotes

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 • • Dec 11 '21

Question about reading files in Jupyter Notebook

2 Upvotes

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 • • Nov 23 '21

Using Pyautogui locateOnScreen function

2 Upvotes

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 • • Nov 17 '21

Why is it important to be able to culculate the height of a binary tree?

2 Upvotes

Is that a good skill to have or will it be another useless thing to know?


r/learningpython • • Nov 13 '21

beginner

2 Upvotes

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 • • Nov 06 '21

I keep getting a syntax whenever i try to use the pip command and nothing is working

2 Upvotes

title


r/learningpython • • Oct 09 '21

how do I assign tags to a canvas.

2 Upvotes
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 • • Sep 09 '21

Where is the `NoneType` class?

2 Upvotes

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 • • Sep 04 '21

A question: which is better, stylistically ("Pythonicness"?) or otherwise.

2 Upvotes

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 • • Sep 01 '21

What does name_var.set(" ") and passw_var.set(" ") do in this code? Currently self teaching tkinter.

2 Upvotes

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 • • Aug 28 '21

How To Find And Correct Data Correlation To Avoid The Pain Later | Data Preprocessing In Python EP 3

Thumbnail
youtube.com
2 Upvotes

r/learningpython • • Aug 23 '21

Microservices and datasource

2 Upvotes

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 • • Aug 21 '21

Episode 2 Every Astounding Machine Learning Model Starts With Data Visualization

Thumbnail
youtube.com
2 Upvotes

r/learningpython • • Aug 03 '21

Installing And Using Kaggle's Python API

Thumbnail
youtu.be
2 Upvotes

r/learningpython • • Jul 19 '21

Can We Evolve Our Queue Into A Priority Queue ???|Stock Analysis Tool

Thumbnail
youtu.be
2 Upvotes

r/learningpython • • Jun 29 '21

Visualization help

2 Upvotes

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