Sujet : Re: New VSI post on Youtube
De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj)
Groupes : comp.os.vmsDate : 27. Aug 2024, 19:30:00
Autres entêtes
Organisation : SunSITE.dk - Supporting Open source
Message-ID : <66ce1b27$0$715$14726298@news.sunsite.dk>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Mozilla Thunderbird
On 8/25/2024 8:40 PM, Arne Vajhøj wrote:
VB.NET:
Imports x
is not the equivalent of Python:
import x
It is (mostly) the equivalent to the difference between:
import x
and:
from x import *
And in case somebody wonder what I am trying to explain.
Python (on VMS):
$ type x.py
class A(object):
def __str__(self):
return 'I am an A'
class B(object):
def __str__(self):
return 'I am a B'
$ type tst1.py
import x
oa = x.A()
print(oa)
ob = x.B()
print(ob)
$ python tst1.py
I am an A
I am a B
$ type tst2.py
from x import *
oa = A()
print(oa)
ob = B()
print(ob)
$ python tst2.py
I am an A
I am a B
(x.py may not be good Python, but it shows the point)
VB.NET (not on VMS):
C:\Work\vb>type Stuff.vb
NameSpace X
Public Class A
Public Overrides Function ToString() As String
Return "I am an A"
End Function
End Class
Public Class B
Public Overrides Function ToString() As String
Return "I am a B"
End Function
End Class
End NameSpace
C:\Work\vb>vbc /t:library Stuff.vb
C:\Work\vb>type Tst1.vb
Imports System
Module Tst1
Sub Main()
Dim oa = New X.A
Console.WriteLine(oa)
Dim ob = New X.B
Console.WriteLine(ob)
End Sub
End Module
C:\Work\vb>vbc /r:Stuff.dll Tst1.vb
C:\Work\vb>Tst1
I am an A
I am a B
C:\Work\vb>type Tst2.vb
Imports System
Imports X
Module Tst1
Sub Main()
Dim oa = New A
Console.WriteLine(oa)
Dim ob = New B
Console.WriteLine(ob)
End Sub
End Module
C:\Work\vb>vbc /r:Stuff.dll Tst2.vb
C:\Work\vb>Tst2
I am an A
I am a B
Arne