Conversation
python Coding Question
Show content

Hey fedi I have a coding question for you today. I would basically want to know if this “something” I have in my brain right now.

The basics are, that I am wrinting a little Program with pyQT that should help me with some character sheets for the trpg I am playing.

Decided to ask here since I don’t really can put my finger on exactly I am looking for that makes search kinda hard atm.

Here is a link to the code. It is a kinda long snippet so I uploaded to privatebin: https://privatebin.net/?570a6d8ea9dbe90c#FQkCQf8jkq85xW7YQ2MFfRdAqD1antmduFFMFaEerRsf

So the basic gist is I have some Code for some QT-Dropdowns which works generally (very proud of that btw)

My “problem is that I have a lot of duplicated code in there right now. I do almost the same thing for the left hand and right hand resepectably.

I have to do the same for 100 Skill Blocks as well and having the same code blocks 100 times does scream to me some way.

Is there maybe a way I can reuse a function in python with different names?

Like renaming def change_equipment_list_right_hand(self): to def change_equipment_list_x_hand(self): and then kind of replace the “x” in the whole function with something else?

I hope I somehow got across what I am looking for. It is kinda hard for me to ask smart question about this stuff since I am really a novice with python (just dabbling in it here and there)

#python #coding #question

0
1
1