You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Occasionally, you may need to import Python purely for its side-effects.
238
+
Occasionally, you may need to import Python purely for its side-effects.
239
239
240
240
For this, use `importSideEffects`.
241
241
@@ -285,33 +285,33 @@ The content of `Emit` will not be checked by the F# compiler so it's not advised
285
285
Now let's work with Emit and look at a new example with the following `my_class.py`:
286
286
287
287
```py
288
-
import math
288
+
import math
289
289
290
290
classMyClass:
291
291
# Note the constructor accepts an object
292
292
# with the `value` and `awesomeness` fields
293
293
def__init__(self, value, awesomeness):
294
294
self._value = value
295
295
self._awesomeness = awesomeness
296
-
296
+
297
297
@property
298
298
defvalue()
299
299
return this._value
300
-
300
+
301
301
302
302
@value.setter
303
303
defset_value(self, new_alue)
304
304
self._value = new_value
305
-
305
+
306
306
307
307
defis_awesome(self):
308
308
return this._value == this._awesomeness
309
-
309
+
310
310
311
311
@staticmethod
312
312
defgetPI():
313
313
return math.pi
314
-
314
+
315
315
316
316
```
317
317
@@ -436,7 +436,7 @@ myMethod(U3.Case3 testValue)
436
436
When passing arguments to a method accepting `U2`, `U3`... you can use the `!^` as syntax sugar so you don't need to type the exact case (the argument will still be type checked):
437
437
438
438
```fsharp
439
-
open Fable.Core.JsInterop
439
+
open Fable.Core.PyInterop
440
440
441
441
myMethod !^5 // Equivalent to: myMethod(U3.Case2 5)
<p>or we could use the <codeclass="docutils literal notranslate"><spanclass="pre">importMember</span></code> helper function to directly map the Python function to the F# function.</p>
749
-
<divclass="highlight-fsharp notranslate"><divclass="highlight"><pre><span></span><spanclass="k">open</span><spanclass="w"></span><spanclass="nn">Fable.Core.JsInterop</span><spanclass="w"></span><spanclass="c1">// needed to call interop tools</span><spanclass="w"></span>
749
+
<divclass="highlight-fsharp notranslate"><divclass="highlight"><pre><span></span><spanclass="k">open</span><spanclass="w"></span><spanclass="nn">Fable.Core.PyInterop</span><spanclass="w"></span><spanclass="c1">// needed to call interop tools</span><spanclass="w"></span>
<spanclass="w"></span><spanclass="c1">// here we just import a member function from canvas.js called drawSmiley.</span><spanclass="w"></span>
@@ -815,33 +815,33 @@ <h2>Emit, when F# is not enough<a class="headerlink" href="#emit-when-f-is-not-e
815
815
<sectionid="let-s-do-it-use-emit">
816
816
<h3>Let’s do it! Use Emit<aclass="headerlink" href="#let-s-do-it-use-emit" title="Permalink to this headline">#</a></h3>
817
817
<p>Now let’s work with Emit and look at a new example with the following <codeclass="docutils literal notranslate"><spanclass="pre">my_class.py</span></code>:</p>
<p>When passing arguments to a method accepting <codeclass="docutils literal notranslate"><spanclass="pre">U2</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">U3</span></code>… you can use the <codeclass="docutils literal notranslate"><spanclass="pre">!^</span></code> as syntax sugar so you don’t need to type the exact case (the argument will still be type checked):</p>
<spanclass="n">myMethod</span><spanclass="w"></span><spanclass="o">!^</span><spanclass="mi">5</span><spanclass="w"></span><spanclass="c1">// Equivalent to: myMethod(U3.Case2 5)</span><spanclass="w"></span>
0 commit comments