[Tutor] How to perform variable assignment and
Didar Hossain
didar.hossain at gmail.com
Sat Oct 3 07:56:14 CEST 2009
Hi,
I am currently learning Python and I was wondering is there a shorter
way to do the following -
import os
homedir = os.environ.get('HOME')
if homedir:
print "My home directory is %s" % homedir
I do this in Perl -
my $home;
if ($home = $ENV{'HOME'}) { print "My home directory is $home\n"; }
Can I do a similar shortcut statement like the above in Python?
Regards,
Didar
More information about the Tutor
mailing list