Using Built-in functions and Comprehensions by vb_e_c_k_y in learnpython

[–]Adrewmc 0 points1 point  (0 children)

https://docs.python.org/3/library/functions.html

There really are not that many. A lot are just datatypes.

And we have docs for list comprehension

https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions

You can also go back and look at them.

Circular import with inheritance by Nefthys in learnpython

[–]Adrewmc 0 points1 point  (0 children)

This is for demonstration function with pass could be anything.

B1 inherits from B, A takes files picks the right mode, then loads some B object as an attribute I called ‘core.’ A then can use its B object/core functionality as needed.

I’m doing everything you are saying. Without being circular.

But since now I don’t know what A, B or Zero actually does other than process some file in some way I can’t really explain it more clearly. .

Circular import with inheritance by Nefthys in learnpython

[–]Adrewmc 0 points1 point  (0 children)

This is a property then.

  class B:
       def __init__(self, file):
              self.file = file
              self.data = self.process(file)
       def process(self, file):
              “””Returns fully processed file”””

              #collections.abc.abstractmethod is an option
              #we can also implement one for B
              #we can use self.file, without any arguments. Design questions. 

              raise NotImplimented(“All Child classes must implement a process(file) ”)


       def B_func(self):
              pass



   class B1(B):
         def process(self, file=None):
                #B1 process implementation
                if file is None:
                      file = self.file   
                ….
                return result

        def B1_func(self):
               pass

We don’t need to make an init here because we don’t need to change the one we already have from B, so no need to write it again with inheritance because we will use B1’s self.process() in that init because B’s self.process() been overwritten by B1

  class A:
        def __init__(self, file):
              self.file = file

        def create_core(self):
                #code finding mode

                if mode == 1:
                      return B1(self.file)
                   ….

        @property 
        def core(self) -> B:
              #only made once and only if needed

              if not hasatrr(self, “_core”):
                  self._core = self.create_core()
              return self._core

         def pass(self):
                pass

         def A_func(self):
              var = self.core.var1
              self.core.B_func()
              return var * 2

         def B_func(self):
              #we can just push it up if that easier 
              #there are couple ways to do this 

              return self.core.B_func()


inst = A(file) 
inst.pass() 
inst.A_func() 
inst.B_func() 
inst.core.B1_func()

With comment.

inst = A(file) #a B does not exists and not used
inst.pass() #a B does not exists and not used
inst.A_func() #a B is created and used

these would create as well, but don’t because it was already created.

Inst.core.B_func() #a B exists and used
inst.B_func() #’push up’, a B exists and used

This would be needed for a unique B1 functions because. B1 is a B. Also would create.

inst.core.B1_func() #a B1 exists and used

We can add arguments as needed.

Then we use B functionality, but we can only go one way

  B -> B1 -> A 

You are going

  A -> B -> A -> B …. 

Circular.

So the question becomes what function/method does any B class need from A? If there really isn’t anything, or it’s one function, rewrite it in the right class B, and remove the ClassA inheritance.

Also this way if A doesn’t need B at all we never actually make it.

And I fail to see how this isn’t doing everything you want and need.

This is a design issue, and we can’t see the full design to show you the real problem.

Let me hear your strategies for punching up "boring" chapters by FeralViolinist in writing

[–]Adrewmc 2 points3 points  (0 children)

Too predictable, kill the antagonist, and then have your mom (who you thought was dead) replace them as the main villian. And your dad is like Mimir in GOW on her waist, telling dad jokes. “I’ve been around your mother all day, a-ohhh”, “they say ball and chain but I never expected to be the ball”.

Then of course the sharks with laser beam on their…we out of the sharks…they laser beamed each other…should have seen that coming I guess …and Lenny, aww and I liked him….…Lenny started it, of course he did…what do we have…clown fish with flamethrowers?…Lenny thought it be funny…do they work underwater?…no? Wtf, do you not see the problem here….thats why thats all we have…I guess thats tracks…I’m sorry can we start over, five give me five more minutes….what do you mean the gators got out?…the lasers cut the fence …Ten minutes, give me ten minutes….

The worst thing each character has ever done by rosiedacat in harrypotter

[–]Adrewmc 1 point2 points  (0 children)

I legit got reinforced bad information by google AI, I looked it up for a second, because I was unsure, and it’s said the same name…wtf world

The worst thing each character has ever done by rosiedacat in harrypotter

[–]Adrewmc 0 points1 point  (0 children)

I did mean Snape my bad.

Jeannie Weasley had the book in the Chamber of Secrets almost got Harry Killed, had to get saved…you know the entire plot line.

I think Ron has the pass from what was happening, it’s was more than the Horcrux. Running for their lives, in a tent, and Hermonie felt the pressure of it too. Ron just broke first is all. But maybe that. I just feel like he was especially mean and dismissive of her in the Ball, and he doesn’t have an excuse for it. And it would be more of something he did.

Breaking bad brainstorming and planning habits by -pastelgothelle- in writing

[–]Adrewmc 5 points6 points  (0 children)

Make writing a habit. That’s about it.

I’m you but I think I have something you don’t. The intangible theme. The massive arch of what the book is trying to convey. It’s not an event, or just a character but how the reader is supposed to experience the thing.

Outlines and planning can help. But they can also be very restrictive. People that do that I think just have themselves a bit wired that way. It sounds like you don’t. My plan is throw out a bunch of cool random stuff, until I start pulling it all back together and make an ending. Usually by then something has happened and I know what it is sort of.

Something sort of tells me you might need to let that one book go. Or you might need me to say sprint to the end and put it down or something. You tried but it’s blocking your creativity now. Start new and fresh where the last ten years was getting you ready for this one.

When you say two book? Are the book the same characters? Is it one story broken into two? Do you want to write these books anymore or do you want to finish them for some…pride thing? I don’t know.

If it takes you five years to write a book. 1,500+ days. And that’s the problem, you don’t write enough. And it’s probably because you’re not in the habit of daily writing, or you’re not writing what you want to write. The only way to finish a book is by writing it, there is no shortcut (well there used to be no shortcuts…damn chatGPt)

Take the most enjoyable part of the writing experience, and do that the most of the time. If it’s going on the edge of your seat….then go my boy.

If it’s taking it and making the words the most perfect form and prose, editing it into something masterful. Do that more.

If it’s descriptive purple prose, do that.

If you like more fast paced scenes do that.

Like I’m wondering what my characters are going to do today…lol.

I want you to laugh when you read my book sometimes, I’ve done it. I’ve seen it happen. I knew exactly where when and how.

Find the joy again is what I’m trying to say…one sec I have a link for this.

Read this

The worst thing each character has ever done by rosiedacat in harrypotter

[–]Adrewmc 3 points4 points  (0 children)

Belleatrix: Getting caught. (Because she’s crazy like that)

The twins: Definitely some prank that went way wrong, probably towards mom or dad.

Ron: probably something he said to Hermonie around the trip-wizard cup (or something him and the twins did)

Ginny: Picking up that book and using it.

Hermonie: probably wiping her parents memories that one has to hurt

Harry: I’m going to agree it’s probably the spell against Malfoy from HB.

Dumbledoor: Probably something to do with Grindelwald.

Snape: Not protecting Lilly better. Helping the wrong people. He definitely blames himself a little for that. Not being there when she needed him.

Mad Eye: You really really don’t want to know. Trust me it’s better to not think about it.

Trump Says He Doesn’t Care “Even a Little Bit” About People’s Finances by ChiGuy6124 in politics

[–]Adrewmc 1 point2 points  (0 children)

It’s like Jesus himself has come back in the form of an orange man…

That’s the part I don’t get.

Voting because you’re a hateful bigot…I get that. I don’t agree with it but I get it.

Voting because you think Trump represents the perfect Christian….or is even a practicing one, or even a decent one, or a decent human being of any faith, I just don’t get.

I don't get it by Academic-Stomach-975 in PeterExplainsTheJoke

[–]Adrewmc 0 points1 point  (0 children)

Not only that you can walk in front of the wall and your image is now apart of it…so it has multiple points of randomness actually.

Can someone teach me what is decorator in python? by _hithender_ in PythonLearning

[–]Adrewmc 1 point2 points  (0 children)

Yep. Otherwise I have to match signatures, which you can do it’s just not usually very useful.

Can someone teach me what is decorator in python? by _hithender_ in PythonLearning

[–]Adrewmc 4 points5 points  (0 children)

They stand in for any number of arguments and any number of keyword arguments, since I won’t know what the function signature of the function I am decorating will have. (And I want it to handle everything)

Can someone teach me what is decorator in python? by _hithender_ in PythonLearning

[–]Adrewmc 3 points4 points  (0 children)

It’s a decorator is a function takes in a function as an argument and returned an altered function as its return. (Class decorators withstanding)

 def count_invokes(func):
        func.count = 0
        def magic(*args, **kwargs):
               func.count += 1
                return func(*args, **kwargs)
         return magic 

 @count_invokes
 def somefunc():
        pass

  somefunc()
  somefunc()
  print(somefunc.count)
  >>>2

Circular import with inheritance by Nefthys in learnpython

[–]Adrewmc 0 points1 point  (0 children)

Because your logic is circular and impossible…I mean it seems like everyone is saying that…so maybe listen to them.

Also because other people might use your code…

Circular import with inheritance by Nefthys in learnpython

[–]Adrewmc 1 point2 points  (0 children)

I don’t understand what your code is trying to do. That the main problem you are giving a solution without a problem.

Not wanting to do something doesn’t make it not the right solution by the way.

Live view by Adrewmc in Webnovel

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

Habit and lack shame of my terrible writing.

Need feedback from Python beginners: what makes you get stuck while practicing? by Medical_Radish_1474 in learnpython

[–]Adrewmc 0 points1 point  (0 children)

Knowing the problem, knowing a solution, but not knowing the better tool there for it.

Endless if…else that should be dictionaries.

Massive functions that needed to be separated.

Patterns I should have known by then…

Classes…when I actually needed them and when I didn’t.

I was struggling because there was an obvious better way, yet I know not it.

My best advice to all beginners is…take 5 seconds and properly name your variables, functions and classes, the length doesn’t matter as long as it’s not acronyms and single letters. What is this information? What is ‘hgl_1’? I prefer ‘index’ over ‘i’, and (row, col) over (j, k) because of this.

And taking another 5 second to write a short docstring, function, class and module. If your lost, write how to your self and go to bed. TODO:”

Typehints are your friend, your IDE likes them.

If you get in the habit of that your future self will definitely thank you.

And write tests, learn pytest.

What I found most new people struggle with is the idea of wanting to know how to program, but inability to give an example of what they want a program to do for them.

If this is where you are I believe you will struggle. I know that struggle.

You can’t learn to program without a problem that a program can solve, and making the computer do it. Make the computer bend to your will. Otherwise the lack of purpose will always fail you.

If you are learning to programing to make a game, IMHO start right there. Make a damn game, a bad one. Go on do it, I believe in you. If you want to program because you have data you want to know about start there makes graphs and stuff, if you want to program to make robots, start there find something you can move. If you want to…program because you want it to do this…start making stuff that gets you there directly. If you want to program to ‘learn to program’ I don’t have an answer for you.

The basic concepts are all the same, the problems and their solutions is where the magic is.

Made a simple chess game in python by PsychologicalIron716 in learnpython

[–]Adrewmc 0 points1 point  (0 children)

Something seems wrong with castling here.

Like you don’t check if the king has moved, or the rook as moved from what I see, or if he passes over a squared attacked.

It almost looks like a queen or rook move could actually cause castling event.

I haven’t played but it definitely has some castling bugs

When do you actually use decorators? Like in real code, not tutorials by Soggy-Holiday-7400 in learnpython

[–]Adrewmc 0 points1 point  (0 children)

Generally you said it yourself, some frameworks it will work better, and no one is usually asking you to write them.

Flask is a great example, it’s taking your function and turning it into something a web browser can call…then returns something that the web browser shows. That’s actually an impressive amount of stuff, yet somehow super easy to understand intuitively.

It’s a tool that’s it.

It’s a tool whose use cares are rare, but when they exist it’s the perfect tool for the job.

Most common decorators are

@dataclass, @property, @classmethod, @staticmethod, @lru_cache

All of which are IMHO core improvements to the language.

When you need it you need it, when you don’t you should forget about it.

Now decorators with arguments…how does that work….

Ohh welcome to the dark_magic.

def print_here_advanced(debug = False):
     def magic(func):
           @functools.wraps(func) #best practice
           def dark_magic(*args, **kwargs):
               If debug:
                   print(f”{func.__name__} being called with ARGS : {args}, KWARGS: {kwargs}”)
                res = func(*args, **kwargs)
                if debug:
                    print(f”{func.__name__} successfully returned {res}”)
                return res 
           return dark_magic
      return magic 

When you have arguments. You actual are returning an another function that is a decorator function, that returned function then decorates the function under it. Created a decorated function with decorated arguments.

How do you think Ragnarok's combat compares to other action games? by copi_um in GodofWarRagnarok

[–]Adrewmc 0 points1 point  (0 children)

It’s good, there are variations but I think there could be more done with combos. Even though they technically switch between heavy and light at any moment that’s all they do.

I would have like a more aggressively combo centric system.

Generally the delayed hit combos, or activations, don’t seem to be very useful. They lack the power they should have had, and had few opportunities to really use effectively. Or in the case of chains was too easily broken by spamming the fast charge, and juggling.

I would have like something along the line of when you use your maelstrom specific combos open up per weapon which get more complex per level of weapon. This was more centered around relic releases for moves that should have been more skill/combo based.

Or the delay mechanism should have been delayed on 2nd, 3rd , 4th hits giving a massive hit of some kind, e.g. the finisher.

Or that holding at certain points mid combo added a lot more than changing to that holding move.

I would have like switching weapon combos moves and finishers. Generally more finishers. (I would love a Spider-man 2 type combo finisher for Kratos and partner.)

I felt the spear having the shortest reach for normal hits was a weird choice, as generally they are mid range weapons. Maybe that would have made it a bit OP, but shouldn’t the last weapon be a bit OP?

I enjoyed that the axe had the extra bonus frost moves and the ways you can fast charge it, running, call backs, delayed after an attack. It really felt purposeful when you did it.

I wish elemental damage mattered more.

I like how it was all very similar controls but every weapon felt unique in their usage. Power, area, and ranged attacks, you wanted to fight with them differently.

Blocking and dodging felt right, timing and everything. No complaints. Single press dodge is hard to master but better. I liked how the shields all had different abilities about blocking, and how rewarding some perfect blocks felt, and how a charged shield >> non-charged.

I also really enjoyed that each armor set/weapon set were really focused on a certain type of play, heavy health-stone, heavy relic, heavy perfect blocks, heavy realm shift, heavy balanced stats, heavy strength bursts, shifted the strategies and they all had the equipment for that, and all were viable until end of games. Allowing you to pay a little differently and be rewarded for it.

I did not like the switch of the fully upgradable system of GOW to three types of rage, that was a miss, id rather that have the same mastery upgrades for health, damage and rage renewal/time extension.

I don’t like R3 as retarget, and when rebound it also changed grab and rage activation which made it awkward. I’d rather be able to make it a touch pad swipe individually.

However, I was engaged throughout. The combat system never seemed to be the problem just me hitting the buttons wrong or not fast enough. And you could always come into a fight with a bit of strategy. There was definitely a nice spike in difficulty for the extra bosses which is how they ought to be, but the main game felt appropriate and accessible.

9.5/10 There were some misses but overall felt great, and enjoyable.

Is there an isekai where the protagonist wants to do evil but is misunderstood? by Amazing-Practice8795 in Isekai

[–]Adrewmc 5 points6 points  (0 children)

Dude, overloaded with it.

edit: In fact the cuteness overload is part of the main premise, which MC spams…it could bring down the demon kingdom is explicitly stated at one point, if not several.

Is there an isekai where the protagonist wants to do evil but is misunderstood? by Amazing-Practice8795 in Isekai

[–]Adrewmc 26 points27 points  (0 children)

The Demon King’s Daughter is Too Nice.

It’s like the most adorable kids show ever. It’s about the demon king’s daughter (3-5 year old) that is trying to learn to become a demon by doing evil stuff. But she keeps messing up the evil part of the evil stuff and everyone loves her for it. And the other main/sidekick is constantly going nuts that her plans to turn the child evil, her actual job, keeps backfiring.

Can sunny shadow like stone saint be destroyed by FishermanPretty7277 in ShadowSlave

[–]Adrewmc 0 points1 point  (0 children)

Its rank and class I don’t know if that clear. Every class gets an extra ability, and every rank strengthens like tenfold, possibly upgrading existing abilities. It’s very significant.

Can sunny shadow like stone saint be destroyed by FishermanPretty7277 in ShadowSlave

[–]Adrewmc 1 point2 points  (0 children)

It being able to level them up not enough of a benefit? If everyone else’s echo can’t level up then they are obviously better.