A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/102014.html below:

With or Using

With or Using With or UsingKonrad Hinsen hinsen at cnrs-orleans.fr
Tue Apr 17 04:32:01 EDT 2001
Tim Howarth <tim at worthy.demon.co.uk> writes:

> Have a "with" or "using" block,
> 
> with jim:
>     born=1960
>     haircolour='Brown'
>     eyecolour='Green'

How about this syntax:

  set_attributes(jim,
		 born = 1960,
		 haircolour = 'Brown',
		 eyecolour = 'Green')

All it takes is a short function definition:

  def set_attributes(object, **arguments):
      for name, value in arguments.items():
	  setattr(object, name, value)

-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4