The Python example is completely broken. It'd be something like:
import os
if 'vmware' in os.popen('dmidecode').upper():
print 'this is a vmware vm'
else:
print 'this is not a vmware vm'
I like regexps as much as the next ex-Perl hacker, but sometimes a little string manipulation is a lot better.