Skip to main content

All Questions

0 votes
1 answer
35 views

What is the best way to have different entry points for a list of iterative commands?

I have a list of iterative Python commands: def command_list(start_at): step1 step2 step3 # ... stepN Now I want to start_at different steps in this list of commands and then ...
Sur3's user avatar
  • 31
0 votes
2 answers
42 views

Create almost similar classes based on conditions, without too much repetion of code

I have three cases say: Case1, Case2, Case3: I have to define three classes depending on which case is true. All the classes have almost the same methods except for some pre-processing depending on ...
junfan02's user avatar
  • 161
0 votes
1 answer
265 views

Seeking Cython Optimization for Conditional Branching: Is There an Equivalent to switch?

I am currently working on a Python project that I need to rewrite in Cython to enhance performance. In this Python code, there is a segment that uses a series of if/elif statements to determine the ...
maplemaple's user avatar
  • 1,435
0 votes
1 answer
121 views

Python Match Case: How can I match a case no matter if the letters are capitalized or not easily?

I have the next code (in Python): lang = input("What's the programming language you want to learn? ").upper() match lang: case "JavaScript".upper(): print("You ...
boludoz's user avatar
  • 70
0 votes
0 answers
532 views

Why am I getting an error message in Python for using match?

I am receiving a syntax error in Python when I type the word Match. I even have the latest version of Python 3.11.4 http_status = 200 if http_status == 200 or http_status == 201: print("...
lexi_roro's user avatar
0 votes
2 answers
188 views

Selenium Python Scraping impossible to switch to iframe

I use VSCode and Python 3.11.4 64-bit. HTLM where i need to switch frame and click on element: enter image description here The code I'm using for instant: from selenium import webdriver from ...
dhiya-eddine Nadour's user avatar
3 votes
1 answer
1k views

How to match multiple different cases in Python

Using the match statement, one can specify multiple patterns for the same case\ match value: case 1 | 2 | 3: do_a() case 4: do(b) What I want to do is the inverse, I want to match ...
Tomáš Kořistka's user avatar
1 vote
1 answer
413 views

How to convert 'if the do' from SAS to Pyspark

I've a df like this: Zip City 'River' 'London' ' ' 'Rome' 'River' 'Berlin' 'River' 'Madrid' ' ' 'Munich' ' ' 'Paris' SAS code below which I've converted in Pyspark if Zip = '' then do ...
Marco Pasqua's user avatar
0 votes
2 answers
377 views

Using lambda function to switch between different functions in python gives TypeError if invalid function name is given with argument

I recently learned lambda functions and switch case and I'm playing with them to understand better. Here, I'm trying to use lambda function to switch between different functions in python like the ...
cerjq's user avatar
  • 3
0 votes
2 answers
204 views

Can you make a switch-case-type list without conditions in Python where it just chooses a random case?

This is a question that is just about convenience (/laziness) of writing. I know I will spend more time writing this question than how much I will save, but I'm curious. EDIT: I am aware that it might ...
MikeA's user avatar
  • 45
0 votes
1 answer
76 views

Python/Kivy: initialize switch after startup (w/o running on_active)

I am facing a problem with the Kivy widget Switch and was not able to find a solution. Each topic on the Internet deals with "Working with the active property", which is understandable to me....
DevelopAndPop's user avatar
0 votes
1 answer
111 views

Can I use list slicing on my match/case term in Python3

To elaborate I have a string x that will be in the structure of "Test_Case_Box 1" "Test_Case_Box 2" "Test_Case_Circle 1" I was using if and elif statements by checking ...
stopbanningmelmao123's user avatar
3 votes
2 answers
6k views

How to check if list includes an element using match case?

I'm trying to check if a single element is in a list using match case. I'm not very familiar with these new keywords so 90% sure I'm using them wrong. Regardless, is there a way to do this? This is my ...
Among Us's user avatar
1 vote
1 answer
478 views

How do I use a match statement to pattern match the class of multiple values in python?

I have a union type, and I can create a value for it like so: import random class X: s: str = 'ab' MyType = int | X def get_value() -> MyType: if random.random() > 0.5: return ...
Zantier's user avatar
  • 865
0 votes
0 answers
45 views

Kivy: How to make a Switch in RecycleView unique?

I'm new to Kivy and I stumbled upon an issue when using the RecycleViw. Basically, I have a switch for every entry in my recycle view to activate or deactivate the text input. This said, when I ...
RitaFuchs's user avatar

15 30 50 per page
1
2 3 4 5
16