Message from Python discussions

November 2018

— I thought it's some big library 😅😅😜
but i found out it just a simple and small module

— 

Hi folks.

I've done some research online to find out wether is possible or not to use a decorator for
checking a variable value, but apparently there's nothing easy to find.

The situation is this:

stop_when_6
Class PointlessExample():
self.a = 2
def increase():
for self.a in range(12):
self.a += 2
def success():
print("a is now 6")

Is there a way to create a stop_when_6 decorator that calls the PointlessExample.success method
when the a variable inside the increase method reaches 6 ?

What I've tried to do is this, but it's not working:
def stop_when_6():
def wrapper(*args):
if args[0].a == 6:
args[0].success()

— But if you didn't get an answer, it's because:
1) you didn't make a smart question
2) you're asking for homework solution
3) your question can easily be solved using google
4) you're expecting someone to give you code that fits your needs magically

Message permanent page

— Wget is C, so it is just a ctypes wrapped or something

— No

— Edited

— It means:
0 - No, it's impossible
1 - No, this is not the way to ask questions here

?

— No, the example is convoluted and not a usecase for a decorator

— State the REAL thing you wanna do

— This is NOT hard, 1st write it in english: several digits optionally followed by a dash and several digits, and more of the same after a comma, endless times

Message permanent page

— Now write the regex, covering each part of the sentence

— \d+(-\d+)?(,\d+(-\d+)?)* ezpz