@ccc this is nice. I like this. im always learning on here.. did you use .format so you didn't have to put the url in the list comp? much cleaner. thanks
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Best posts made by resserone13v2.0
-
RE: mlb web scarper
-
RE: trying to make parallelograms for Side wall
@cvp no. Never that. Lol. I just pop in and out. I was able to use anchor point. I didn’t use transform yet. I’ll probably finish up getting the room to lineed up correctly and then see if I can figure out how to get a sprite the walk thru it and scale depending on where it is on the screen
-
RE: How do you uninvent multiple lines of code in pythonista?
@cvp I was able to open it on my phone and do all the indenting then open it back up on the Mac. i had to update the iCloud
-
RE: trying to make parallelograms for Side wall
I found this
In parallelogram ABCDABCD {AB} = 10AB=10 and measured angle A = 60. Find {CD}CD
and ask chatgpt to use it to make a parallelogram then mix that with what I had before
it makes a parallelogram and now have to work on the size and placement
import ui from scene import * def parallelogram(a, angle_of_a, color, x_pos, y_pos): b = a # Calculate the coordinates of points B and C angle_A_rad = math.radians(angle_of_a) bx = a by = 0 cx = bx + b * math.cos(angle_A_rad) cy = b * math.sin(angle_A_rad) # Create a path to draw the parallelogram path = ui.Path() path.move_to(bx, by) # Point B path.line_to(cx, cy) # Point C path.line_to(cx - a,cy + a) # Point D path.line_to(bx - a, by + a) # Point A path.close() # Create a shape node with the path parallelogram = ShapeNode(path=path) parallelogram.fill_color = color parallelogram.stroke_color = 'black' parallelogram.position = (x_pos, y_pos) return parallelogram class MyScene(Scene): def setup(self): self.background_color = 'white' self.left_wall = parallelogram(400, 100, 'orange', self.size.w / 2, self.size.h / 2) self.add_child(self.left_wall) if __name__ == '__main__': run(MyScene(), show_fps=False)
Latest posts made by resserone13v2.0
-
RE: help with type hints
@cvp ok. Ill keep make sure all my post are pythonista related.
-
RE: help with type hints
@cvp pc my IDE is spyder. Maybe its the version that spyder is running. No worries. Not a big deal. Ive just been working on making my code more clean. Im sure ill figure it out and the code is doing what i need it to. There is a lot to learn. Not just a language but installing packages running different versions of a language. Storing files. For me its good cuz there is always something new to learn
-
RE: help with type hints
@cvp I think I'm running 3.11.
I typed python -v in the cmd line
printed this
\PythonSoftwareFoundation.Python.3.11_3.11.1008.0_ -
RE: help with type hints
@cvp OK. I will give this a read through and check which version of python I'm running.. thanks
-
help with type hints
When I use type hints like this
def average_streak_len(streak_history: dict [str, str]): # Create a dictionary to store the most common value for each team average_streaks = {} # Iterate through each key-value pair in the input dictionary for team, value_list in streak_history.items(): # Count the occurrences of each value in the value_list value_count = {} for value in value_list: value_count[value] = value_count.get(value, 0) + 1 # Find the value with the maximum count for this team max_value = max(value_count, key=value_count.get) # Store the most common value for this team average_streaks[team] = max_value return average_streaks
I get an error that says
TypeError: 'type' object is not subscriptable
why is this?
-
RE: mlb web scarper
@ccc this is nice. I like this. im always learning on here.. did you use .format so you didn't have to put the url in the list comp? much cleaner. thanks
-
RE: trying to make parallelograms for Side wall
@cvp it should just be a basic room with an emoji that you can move back and forth in the room.
i need to figure out how to use a sprite sheeti wanna use this code to create rooms
def creat_rooms(self, level): amount_of_rooms = game_levels[level] for room in amount_of_rooms: self.rooms.append(room)
class Room(): def __init__(self, furniture_list, items_list): self.exit_to_plane = False self.rooms_furniture = self.decorate_room(furniture_list, items_list) def decorate_room(self, furniture_list, items_list): # Still need to position funiture on the wall in the rooms '''returns a list with 2 list [objects, object names]''' decorated_room = [] random.shuffle(furniture_list) furniture_set = random.sample(furniture_list, 3) furniture_set_names = [] for f in furniture_set: random.shuffle(items_list) random_item = random.choice(items_list) pof = Furniture(f) pof.hide_item(random_item) print(pof.name, pof.has_item) decorated_room.append(pof) furniture_set_names.append(pof.name) return [decorated_room, furniture_set_names] def __str__(self): furniture_str = "\n".join(str(furniture) for furniture in self.rooms_furniture) return f"Room:\n{furniture_str}"
-
RE: trying to make parallelograms for Side wall
@cvp you can switch them with any of the images in pythonista. they are just random images from google. They don't work yet. Just up and down work. I wanted to get most of the code to work then update left and right.
ill try to add the images here
-
mlb web scarper
start Of my web scraper. I wanted to check the dates that the teams play and see if the total hits for the player changes to figure out if they got a hit for the day. I have a script that gets the day the teams play and then I'll eventually have that fed to the other script that checks the date and calculates if they gotta hit among other things I'm gonna add to it
this gets the hits
""" Created on Fri Apr 28 21:04:41 2023 @author: resser """ import datetime import requests from bs4 import BeautifulSoup # for player: #if player_team_played: #run scraper on player # Gets todays date todays_date = datetime.datetime.today() formatted_date = todays_date.strftime("%b %d, %Y") game_dates = ['Jul 12, 2023', 'Jul 14, 2023', 'Jul 15, 2023', 'Jul 16, 2023', 'Jul 17, 2023', 'Aug 5, 2023'] def create_urls(): players_and_ids = { "luis-arraez": 2821318, "randy-arozarena": 2914723, "jose-siri": 2170135 } # # Printable players name for labeling and saving info # printable_player_name = requested_player.split('-') # players_first_name = printable_player_name[0] # players_last_name = printable_player_name[1] # players_full_name = players_first_name + players_last_name url_list = [] for key, value in players_and_ids.items(): player_name = key # Player ids for URL player_id = value # URL template url = f'https://www.cbssports.com/mlb/players/{player_id}/{player_name}/career-stats/' url_list.append(url) return url_list def get_players_hits(urls): stats_list = [] for url in urls: # Sends a GET request to the webpage and saves the response response = requests.get(url) # Creats HTML object to parse soup = BeautifulSoup(response.text, 'html.parser') # Finds the table, row and cells containing the players stats table_body = soup.find("tbody") table_row = table_body.find("tr") # Loops over the row and adds stats to a list for td in table_row: stats_list.append(td.get_text(strip=True)) # Stat variables hits = stats_list[7] rbi = stats_list[11] strike_outs = stats_list[15] #print(f"{players_first_name} {players_last_name} has got {hits} Hits and {rbi} RBI") print(stats_list) players_daily_hits = {} # Save stats to file file_name = "temp" with open(file_name, "a") as f: pass if formatted_date in game_dates: hits_list = get_players_hits(create_urls()) print(hits_list)
gets game dates
""" Created on Tue Jul 11 17:45:29 2023 @author: resse """ import requests from bs4 import BeautifulSoup def get_game_dates(url): game_dates = [] response = requests.get(url) # Creats HTML object to parse soup = BeautifulSoup(response.text, 'html.parser') table_body = soup.find_all("tbody") game_dates_html = table_body[1].find_all("span", {"CellGameDate"}) for gd in game_dates_html: game_dates.append(gd.text.strip()) return game_dates dates = get_game_dates("https://www.cbssports.com/mlb/teams/TB/tampa-bay-rays/schedule/") print(dates)