[Python-de] hostname aus os.environ

Andreas Röhler andreas.roehler at online.de
Mo Mär 18 15:15:00 CET 2013


Am 18.03.2013 13:23, schrieb Max Brauer:
> Hallo Andreas,
>
> Am 18.03.2013 13:10, schrieb Andreas Röhler:
>> I.Ü., das funktioniert hier auch
>>
>> os.environ.get('HOSTNAME')
>>
>> Kann jemand das Verhältnis zu
>>
>> os.environ['HOSTNAME']
>>
>> erklären?
>
> os.environ ist ein Dictionary. Bei einem Dictionary existiert auch die
> Möglichkeit, mit "get" auf die Values zuzugreifen:
>
> Python 2.7.3 (default, Jan  2 2013, 13:56:14)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> foo = {'bar': 'batz'}
>>>> foo['bar']
> 'batz'
>>>> foo.get('bar')
> 'batz'
>
> Liebe Grüße,
>
> Max
> _______________________________________________

Danke!




Mehr Informationen über die Mailingliste python-de