Descriptors, *args, and **kwargs? #568
sad2project
started this conversation in
General
Replies: 2 comments
-
Hi @sad2project -- yes Codon supports all of these (I'm assuming you mean decorator as opposed to descriptor?): # compiles in Codon
def mydecorator(func):
def wrapper(*args, **kwargs):
print('calling function!')
result = func(*args, **kwargs)
return result
return wrapper
@mydecorator
def foo(a, b, c, **kwargs):
return a + b + c + len(kwargs)
print(foo(12, 3.14, 99, x='hello', y=[1,2,3])) There are a few limitations since we do this all statically at compile time, but for the most part it works just like in Python. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I can see why you thought I meant decorator, but I meant descriptor
…On Thu, Jul 4, 2024, 11:11 AM A. R. Shajii ***@***.***> wrote:
Hi @sad2project <https://github.com/sad2project> -- yes Codon supports
all of these (I'm assuming you mean *decorator* as opposed to *descriptor*
?):
# compiles in Codon
def mydecorator(func):
def wrapper(*args, **kwargs):
print('calling function!')
result = func(*args, **kwargs)
return result
return wrapper
@mydecoratordef foo(a, b, c, **kwargs):
return a + b + c + len(kwargs)
print(foo(12, 3.14, 99, x='hello', y=[1,2,3]))
There are a few limitations since we do this all statically at compile
time, but for the most part it works just like in Python.
—
Reply to this email directly, view it on GitHub
<#568 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABIHBY4LV4IYTWPTB5YUDE3ZKVXZNAVCNFSM6AAAAABKIVLPASVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TSNRQGY2TG>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm curious if this supports Python's descriptors and the use of *args and **kwargs.
Based on your restrictions for tuples, I'm guessing the latter is out, but I can't tell if the lack of descriptors being mentioned is a sign of not being included in the feature set or if you just haven't mentioned it in the docs yet. Even if you don't fully support descriptors, I think support of @Property would be good.
Beta Was this translation helpful? Give feedback.
All reactions