0

I want to import the number extensions from the compiled C# assembly to the IronPython code. Various extension methods seem to be imported ok, but not the ones for the number types.

I have defined int, double and float extensions, but code like 50.Seconds() gives an unexpected token (Seconds) error. Is there any workaround to add a number type extension?

0

2 Answers 2

3
(1).__index__()

may work.It is a part of the language when you put braces.I can't check that for IronPython right now :)

0
2

Calling methods on literals isn't part of the Python language:

>>> x = 1
>>> 1.conjugate()
  File "<stdin>", line 1
    1.conjugate()
          ^
SyntaxError: invalid syntax
>>> x.conjugate()
1
>>>

The extension methods should work on variables, just not literals.

1
  • Thanks, I have guessed so, but thought that there is a workaround for literals too. Mar 15, 2012 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.