################################################################
# There is no 'Switch' statement in Python, but we can use the following example to simulate switch case.
# We can use dictionary in python to simulate the switch case
################################################################
def f1():
print("Hello f1")
def f2():
print("Hello f2")
funcdict = {
0: f1,
1: f2
}
selection = 1
funcdict.get(selection)()
My 2cent tips & tricks on computer technology & Application Virtualization ...
Friday, March 26, 2010
Tips: Python: Switch in Python
################################################################
# There is no 'Switch' statement in Python, but we can use the following example to simulate switch case.
# We can use dictionary in python to simulate the switch case
################################################################
def f1():
print("Hello f1")
def f2():
print("Hello f2")
funcdict = {
0: f1,
1: f2
}
selection = 1
funcdict.get(selection)()
# There is no 'Switch' statement in Python, but we can use the following example to simulate switch case.
# We can use dictionary in python to simulate the switch case
################################################################
def f1():
print("Hello f1")
def f2():
print("Hello f2")
funcdict = {
0: f1,
1: f2
}
selection = 1
funcdict.get(selection)()
Tuesday, March 9, 2010
Tips: Python: How to get the full username in Windows
import win32com,win32com.client,pythoncom
sDomain ="ES"
sUser ="johrim"
sADSPath= sDomain + sUser
oUser=win32com.client.GetObject("WinNT://%s,user" % sADSPath )
print (oUser.FullName)
Monday, March 8, 2010
Tips: VBScript: Get Full NT User Name using VBScript
Set oNetwork = CreateObject("WScript.Network")
sDomain = "test"
sUser = "johri"
sADSPath= sDomain & "/" & sUser
Set oUser = GetObject("WinNT://" & sADSPath & ",user")
WScript.Echo oUser.FullName
sDomain = "test"
sUser = "johri"
sADSPath= sDomain & "/" & sUser
Set oUser = GetObject("WinNT://" & sADSPath & ",user")
WScript.Echo oUser.FullName
Saturday, March 6, 2010
Tips: Python : wxFormBuilder v3.1.67-beta (Febuary 18, 2010) Python Update
Latest version of wxFormBuilder does not support wxAdditions fully, thus I have updated few XML files to support FlatNotebook & wx.propgrid widgets.
I did not tried to update these files for other widgets but it should be similar.
- Download wx.propgrid and install it.
- Download the XML.Zip folder and extract it in plugins\wxAdditions\xml folder.
- Restart the wxformbuilder.
I did not tried to update these files for other widgets but it should be similar.
Subscribe to:
Comments (Atom)