codon icon indicating copy to clipboard operation
codon copied to clipboard

Is it possible to change variable type in codon?

Open lyenliang opened this issue 1 year ago • 2 comments

I have a code (test_condon.py) like this.

from python import decimal

foo = 1.5
if type(foo) is float:
    print('convert float to Decimal')
    foo = decimal.Decimal(str(foo))
print('done')

When I run codon run test_codon.py, I got test_codon.py:4:4-22: error: '__new__[...,...]' does not match expected type 'float' error.

It seems that I can't change the type of a variable in codon.

Is there any solution to let codon run the above code?

lyenliang avatar Mar 19 '23 03:03 lyenliang

Hi @lyenliang -- this should work, and it does work with the latest unreleased changes, so whatever issue this was seems to have been resolved. We'll be putting out the new version in a week or two which should have this resolved.

arshajii avatar Mar 20 '23 14:03 arshajii

@arshajii Thank you for your response. I'm looking forward to the new version of codon.

lyenliang avatar Mar 21 '23 00:03 lyenliang

@arshajii Thank you for the good news! Could you tell me when the new version will be released? I just happen to need this feature!

somniumism avatar Mar 30 '23 04:03 somniumism