r/pythontips • u/thomasbbbb • May 20 '21
Meta Challenge website
This week I discovered this coding challenge website: https://app.codility.com/programmers/lessons/1-iterations/
Do you know any other?
r/pythontips • u/thomasbbbb • May 20 '21
This week I discovered this coding challenge website: https://app.codility.com/programmers/lessons/1-iterations/
Do you know any other?
r/pythontips • u/[deleted] • Apr 18 '21
I want to make a python program into an executable. I have heard that you have to use pyinstaller, but I just want to know if there is any other way that I can it without pyinstaller.
r/pythontips • u/harshit_roy_python • Apr 06 '21
I have created this python program that has 2 parts first is to send an SMS with 4 Digit OTP to the registered mobile number and the second part is to check wether the user is entering the same OTP that was sent to him and all this is handled with a Tkinter GUI
r/pythontips • u/theautomationbro • Feb 07 '21
In this video (https://youtu.be/uZ-sgPTM0eM), we will learn how we can use SeleniumBase Setup & Teardown methods to optimize our tests even further. If you are not familiar with setup & teardown concepts, essentially, it allows you to run certain steps before and after your actual test.
To learn more about Selenium Python, you can check out the full playlist here.
r/pythontips • u/Mmetr • Jul 28 '20
Every morning I wake up and receive 4 emails from this company.
I have to open up each email and download each attachment.
Once I have each attachment, I have to put them into the same spreadsheet. They are sent in 4 emails because the excel sheet is huge.
From there I run a simple vlookup to see if the row of data needs to be worked on or not based on the columns for that row.
I would imagine I could write a python script for this, but to be honest I’m not a master software engineer. Just a guy that knows how to dabble with this stuff.
Posting in here for any tips from the community!
r/pythontips • u/CrayonConstantinople • Jun 04 '16
In Python, we don't like using getters and setters. People can just overwrite variables as they see fit. However, if you'd like the functionality of getters and setters without making your users have to use them. Use properties instead:
class OneNamePerson(object):
"""
Creates an object to reflect a Person who can only have one name.
"""
def __init__(self, name=None):
self._name = name
# called when someone accesses name from the object
# example: person.name
@property
def name(self):
return self._name
# called when someone assigns a value to name
# example: person.name = "Tom"
@name.setter
def name(self, new_name):
if self._name == None:
self._name = new_name
else:
raise Exception("Can't rename OneNamePerson. "
"Name must remain as {}.".format(self._name))
# called when someone calls del on the name
# example: del person.name
@name.deleter
def name(self):
raise Exception("Can't delete name.")Now lets see how this works in action:
a = OneNamePerson()
a.name = "Frank"
print a.name # Frank
a.name = "James"
# Exception: Can't rename OneNamePerson. Name must remain as Frank.
del a.name
# Exception: Can't delete name.r/pythontips • u/Ok-Desk6305 • Sep 20 '22
Hi everyone!
I wanted to share with you a repo that I just published. It basically replicates how a stock exchange works, and you can add multiple agents (traders, market-makers, HFTs), each with its own custom behavior, and analyze how they interact with each other through the pricing mechanism of an order book.
It is a pretty niche topic, and I think that its applications are mostly academic, but since some of you are at the intersection of computer science and financial markets, I thought you might be one of the few people that could be interested! Needless to say, I would really appreciate your feedback also! https://github.com/QMResearch/qmrExchange
r/pythontips • u/Successful-Aide3077 • Aug 09 '22
Will cover three game changing Python programming language tips in 30 seconds. The IDE used was Visual Studio Code. https://www.youtube.com/shorts/_OgcxUA-E_k
Tip 1: Swapping Two Variables
Tip 2: List Comprehension
Tip 3: Merging DIctionaires
#python #pythonprogramming #vscode
r/pythontips • u/Ok-Craft-9908 • Apr 26 '22
Friends & I are sick of online tutorials so we’re running a group for learning to code with competitive team games
Hi, we’re a group of 4 friends and want to hear what you think about what we’re working on! We’re super early so really want feedback - if you want this to exist, register interest on https://delta-academy.xyz :)
The best experiences we had when learning Python were working on projects and hackathons. We also benefited from having a peer group (e.g. at University) - the friends we made have often lasted.
Delta Academy combines these two elements - live competitive coding games with a cohort of peers. The cohort will be ~20 people. It’s the format we wanted but couldn’t find online - so we’re creating it!
We would have to charge for running cohorts (initially just to cover the prizes!), but haven’t figured out how much yet - just want to know first if this is something people want!
Really keen to hear feedback, both positive and negative! :)
r/pythontips • u/geekyhumans • Oct 31 '21
I created a small tutorial which can help you to integrate weather information in your Python application: https://geekyhumans.com/get-weather-information-using-python/
r/pythontips • u/ajuman • Jul 24 '21
I run all of my apps in windows...use Manjaro for gaming ... It was simple... But now coding... What is the best choice and what should I learn.
She's non-tech and just got the course because I was thinking about it after I told her I had some free time to learn something.
I need to learn something new though... It's been almost 8 years that I didn't do something new.
r/pythontips • u/HotFireBall • May 09 '21
I want to start coding and python seems to be a promising start. Any tips? Setup config, helpful shortcuts, and the commands and their functions, etc. I know a little bit of linux but idk if that will help me learn faster
r/pythontips • u/[deleted] • Mar 07 '21
I want to design tools for students when it comes to discrete mathematics and number theory, but I barely have any experience with code, and all of these free boot camps are often way outdated, and or useless exercises. Where can I find practical training programs designed to help self-taught individuals? Where are the real goldmines of information? I'm one of these people that has to have an over-complicated understanding of something, so I need intricate, but concise: Like that one teacher we had or wished we'd had that could explain something once, and then you knew the whole subject.
r/pythontips • u/[deleted] • Mar 20 '20
r/pythontips • u/pylenin • Aug 09 '19
A simple and cool project for everyone to try.
Instead of using the input function to prompt the user to enter a password, we can use the get pass library, which does pretty much the same thing, except the input is not echoed to the console like with the input method.
https://youtu.be/Wd5if91Bt3g
r/pythontips • u/Moondra2017 • Mar 25 '19
r/pythontips • u/Moondra2017 • Mar 15 '19
This is playlist I made a little while ago but I want to know if anything is missing so I can fully complete it:
https://www.youtube.com/playlist?list=PLGKQkV4guDKH1TpfM-FvPGLUyjsPGdXOg&disable_polymer=true
r/pythontips • u/attreya12 • Jan 28 '19
In this series of 30 videos we learn how to create a Music Player from scratch using Python.
Youtube Playlist - https://www.youtube.com/playlist?list=PLhTjy8cBISEp6lNKUO3iwbB1DKAkRwutl
r/pythontips • u/SpendFamous7668 • Nov 02 '22
Hi, I made a new tutorial for Streamlit beginners. It’s currently 68 pages and contains 35 minimal app examples, with a large section about using basic SQL together with Streamlit to build simple full-stack CRUD apps:
I hope it’s useful!
r/pythontips • u/aitosumankolosky • May 14 '22
li=[[0]*4]*4
for i in range(0,4):
if(i==0):
li[i][0]= 4
print(li)Why is the output this
[[4, 0, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0], [4, 0, 0, 0]]
and not
[[4, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
r/pythontips • u/TechKrazy • Jan 27 '21
r/pythontips • u/uta44 • Jun 01 '20
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
playing = True
#Establishing a connection
my_url = 'https://ron.fxexchangerate.com'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
# Grabbing the first set of ratings from the Currency Pair Side Table
container = page_soup.find('div', class_='sider')
numbers = container.findAll('span')
USD_EURalpha = numbers[1].text
GBP_USDalpha = numbers[2].text
USD_EUR = float(USD_EURalpha) # ~0.897
GBP_USD = float(GBP_USDalpha) # ~1.240
EUR_GBPalpha = numbers[7].text
EUR_GBP = float(EUR_GBPalpha) # ~0.897
#Grabbing the second set of ratings from the Main Table
container_two = page_soup.find('tbody',class_='project')
numbers_ron = container_two.text
RON_USD = float(numbers_ron[27:33]) # ~ 0.229
RON_EUR = float(numbers_ron[63:70]) # ~ 0.205
RON_GBP = float(numbers_ron[108:114]) # ~ 0.184
#Inverting the rates
EUR_USD = 1 / USD_EUR
USD_GBP = 1 / GBP_USD
USD_RON = 1 / RON_USD
EUR_RON = 1 / RON_EUR
GBP_RON = 1 / RON_GBP
GBP_EUR = 1 / EUR_GBP
#Setting the loop
def program():
while playing == True :
first_input = input(" Welcome, please select the currency you want to convert from: \\n press 'd' for dollar \\n press 'l' for lei \\n press 'e' for euro \\n press 'p' for pounds ")
second_input = input("Following the same patern as before, please select the currency you want to convert to: ")
suma = float(input("Please type the ammount in numbers "))
def result():
result = \[\]
if first_input.lower()\[0\] == 'e' and second_input.lower()\[0\] == 'l':result = float(suma) * EUR_RON
elif first_input.lower()\[0\] == 'd' and second_input.lower()\[0\] == 'l':result = float(suma) * USD_RON
elif first_input.lower()\[0\] == 'l' and second_input.lower()\[0\] == 'e':result = float(suma) * RON_EUR
elif first_input.lower()\[0\] == 'l' and second_input.lower()\[0\] == 'd':result = float(suma) * RON_USD
elif first_input.lower()\[0\] == 'e' and second_input.lower()\[0\] == 'd':result = float(suma) * EUR_USD
elif first_input.lower()\[0\] == 'd' and second_input.lower()\[0\] == 'e':result = float(suma) * USD_EUR
elif first_input.lower()\[0\] == 'd' and second_input.lower()\[0\] == 'p':result = float(suma) * USD_GBP
elif first_input.lower()\[0\] == 'p' and second_input.lower()\[0\] == 'd':result = float(suma) * GBP_USD
elif first_input.lower()\[0\] == 'e' and second_input.lower()\[0\] == 'p':result = float(suma) * EUR_GBP
elif first_input.lower()\[0\] == 'p' and second_input.lower()\[0\] == 'e':result = float(suma) * GBP_EUR
elif first_input.lower()\[0\] == 'l' and second_input.lower()\[0\] == 'p':result = float(suma) * RON_GBP
elif first_input.lower()\[0\] == 'p' and second_input.lower()\[0\] == 'l':result = float(suma) * GBP_RON
else:print ("Please choose between 'l','d','p' or 'e' ")
print (f'result = {result}')
result()
continuare = input("Go again? 'y' or 'n'")
if continuare.lower()\[0\] == 'n':
playing == False
break
else:
playing == Trueprogram()
r/pythontips • u/_leznets • Mar 04 '20
Here's the link: https://www.youtube.com/watch?v=-K6A2XP0rK8
If there are any specific questions you guys need help with, let us know and we'll make more videos.
r/pythontips • u/tcas71 • Jan 06 '20
The str.splitlines() method is pretty neat. Up until a week ago I had a habit of always applying str.rstrip() before splitting lines. I thought I would otherwise get empty lines at the end of my data if it ended with a trailing newline. Turns out I did not need to:
>>> string = "Hello\nWorld!\n"
>>> string.splitlines()
['Hello', 'World!']This is unlike .split("\n") that I see used fairly often:
>>> string.split("\n")
['Hello', 'World!', '']If there is more than one empty trailing lines, only one is trimmed. Empty first lines are also kept. Finally, an empty line with spaces (& friends) is not considered empty.
>>> "Hello\n\n".splitlines()
['Hello', '']
>>> "\nHello".splitlines()
['', 'Hello']
>>> "Hello\n ".splitlines()
['Hello', ' ']While on the topic of str.splitlines, it is also compatible with CRLF line ends which is essential if you care about Windows compatibility (among other things):
>>> "Hello\r\nWorld!".splitlines()
['Hello', 'World!']The official documentation for str.splitlines() has a full list of the supported separators:
https://docs.python.org/3/library/stdtypes.html#str.splitlines
P.S.: I am posting a Python tip on r/pythontips… This is how it works, right? The vast majority of posts here suggest otherwise.