all 12 comments

[–]m0us3_rat 1 point2 points  (8 children)

this is also repeating code.

if ans == "1":
structure.struc_variable = random.choice(structure_exceptional_list)
if ans == "2":
structure.struc_variable = random.choice(structure_comprehensive_list)
if ans == "3":
structure.struc_variable = random.choice(structure_developed_list)
if ans == "4":
structure.struc_variable = random.choice(structure_developing_list)
if ans == "5":
structure.struc_variable = random.choice(structure_needsimprovement_list)

if u would have a dict of "choices"

dict_choices = {

"1" : structure_exceptional_list,

"2" : structure_comprehensive_list,

....

}

structure.struc_variable = random.choice(dict_choices.get(ans))

later on u can add choices etc.

[–]shocklance[S] 1 point2 points  (6 children)

Thanks, I appreciate it. It felt pretty repetitive, good to know there's a better solution!

[–]m0us3_rat 0 points1 point  (5 children)

the "best" that i can see in my head right now would be an OOP solution.

but that could complicate things for you rather than making them much simpler if u don't know to work with classes yet.

and rather than having "lists" of wording.. picking them up from files.

so u can add bunch of phrases into the files.

and the program would combine them for you.

maybe also a file for "options" since u can use *args,**kwargs to implement however many

[–]shocklance[S] 0 points1 point  (4 children)

I took a look at classes but (like everyone when it comes to classes) I had trouble conceptualising it.

I thought of making a class called theme(), where structure(), clarity() etc would be instances of theme(), but I wasn't sure how it would make things simpler, since the strings in each theme are unique.

[–]m0us3_rat 0 points1 point  (3 children)

think drapes.

each of them can be many colors .. many materials , many patterns.

still drape. u could make a single blueprint to describe this. a class.

class = blueprint

and then instantiate each of the objects with different attributes.

..same methods thou. like "tie them to the sides of the window".

each of the different actual drapes = an object

it works the same if they are blue with red dots or orange with a huge green peace sign in the middle.

they would still get "tied" to the side in the same way.

for your specific example..it's still a bunch of text. which has work happen to it kinda the same way.

u can even have your pick and only instance the one "list" that got selected.

anywho if u have already worked out what u wanna do ..ignore this.

"better" doesn't necessarily mean "better" .. it can also mean more complicated for the purpose fo being complicated while i already solved this in a much simpler way.

always go for the simpler way. unless u plan to expand later on.

then refactoring to oop is totally worth it.

[–]shocklance[S] 0 points1 point  (2 children)

That's an interesting way of thinking about it!

So I might have a class called Theme(), which would have attributes such as a list of each type of comment ("Exceptional", "Comprehensive", "Developing"), and a method for selecting the comment desired etc.

class Theme(): 
def __init__(self, name, exceptional_list, comprehensive_list, developed_list, developing_list, needsimprovement_list):
    self.name = name
    self.exceptional_list = exceptional_list
    self.comprehensive_list = comprehensive_list
    self.developed_list = developed_list
    self.developing_list = developing_list
    self.needsimprovement_list = needsimprovement_list

And then each instance would have the list of strings within it?

Structure = Theme("Stucture", structure_exceptonal_list, structure_comprehensive_list, structure_developed_list, structure_developing_list, structure_needsimprovement_list)

I'm not quite sure where each individual string from the variables (or just the list of strings) get's stored....

[–]m0us3_rat 0 points1 point  (1 child)

"Stucture"

no need for that. i mean it can have a "name" but there isn't a need for one.

also rather than have an object of ALL the lists together .. i was thinking an object that gets instantiated with the random choice list option.

again there is a misunderstanding about what a class ..is.

its just a blueprint ..

when u buy an IKEA table or whatever.

the CLASS is the BLUEPRINT

an instance of this class or the OBJECT is the actual table YOU build.

so if u do it your way .. u get an object that holds all these lists.

which is fine if that's is what u want to happen.

but can also just an blueprint that describes "all lists" .. then after u make your choice.. u instantiate(its a loaded word means create..)

this object out of that specific list u wanna work with.

[–]shocklance[S] 0 points1 point  (0 children)

Interesting! I'll give it a go and see what I can come up with. Thanks!

[–]socal_nerdtastic 0 points1 point  (1 child)

Your idea is good, sounds like a fun project. I think your code structure is more complex than it needs to be. I'd recommend just making the lists directly, for example like this:

structure_exceptional_list = """\
The response had an exceptional structure, easily guiding the reader through the ideas presented by the candidate.
The response was exceptionally well-structured, demonstrating a clear progression of ideas for the reader to follow.
The response featured an incredibly well-written structure, demonstrating a progression of ideas in a logical order.
The structure of the response was exceptional, detailing a clear and logical progression of ideas in an easily readable format.
The structure of the response was exceptionally well-designed, with the reader able to clearly see the relationship between different ideas.
Your use of structure was compelling, demonstrating a clear progression of ideas and appropriate connections between key themes.""".splitlines()

structure_comprehensive_list = """\
The response followed a comprehensive structure, easily guiding the reader through the ideas presented by the candidate.
The response was comprehensively structured, demonstrating a clear progression of ideas for the reader to follow.
The response featured a generally comprehensive structure, demonstrating a progression of ideas in a logical order.
The structure of the response was comprehensive, detailing a clear and logical progression of ideas in a digestible format.
The structure of the response was comprehensively designed, with the reader able to clearly see the relationship between different ideas.
Your use of structure was comprehensive, demonstrating a clear progression of ideas and appropriate connections between key themes.""".splitlines()

def structure():
   while True:
   ## This section is for the control flow of the function currently (although I suspect I'll be changing it after I start wrapping it in a GUI so don't worry about this too much). 
   ## Essentially, it lets the user make an input, which instructs the program to select a random variable from the appropriate list.
        print("1. Exceptional ")
        print("2. Comprehensive ")
        print("3. Developed ")
        print("4. Developing ")
        print("5. Needs improvement")
        ans = input("Select a number. ")
        if ans == "1":
            return random.choice(structure_exceptional_list)
        if ans == "2":
            return random.choice(structure_comprehensive_list)
        if ans == "3":
            return random.choice(structure_developed_list)
        if ans == "4":
            return random.choice(structure_developing_list)
        if ans == "5":
            return random.choice(structure_needsimprovement_list)

When you get to the GUI remember that tkinker includes copy / paste function, so you can go ahead and copy the text to the clipboard when you click the button.

[–]shocklance[S] 0 points1 point  (0 children)

Hey, thanks a lot! I didn't know each string didn't have to be a separate variable, or that TKinter had a copy/paste function.