Received: from eggs.gnu.org ([2001:4830:134:3::10]:51258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkav0-0005Vs-Mm for qemu-devel@nongnu.org; Thu, 15 Sep 2016 13:57:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkaux-00032D-Gb for qemu-devel@nongnu.org; Thu, 15 Sep 2016 13:57:50 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54041 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkaux-000313-74 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 13:57:47 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8FHqogj018222 for ; Thu, 15 Sep 2016 13:57:46 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 25fmcr532m-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Sep 2016 13:57:45 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Sep 2016 18:57:44 +0100 From: Sascha Silbe In-Reply-To: <28a951bf-d082-a7c8-41af-38cccb0a9185@redhat.com> References: <1471625435-6190-1-git-send-email-kwolf@redhat.com> <1471625435-6190-11-git-send-email-kwolf@redhat.com> <32842c09-6dce-b68b-d95e-de3813099faa@redhat.com> <87mvj9cf4q.fsf@oc4731375738.ibm.com> <87k2edcekp.fsf@oc4731375738.ibm.com> <28a951bf-d082-a7c8-41af-38cccb0a9185@redhat.com> Date: Thu, 15 Sep 2016 19:57:41 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: <87h99hcaga.fsf@oc4731375738.ibm.com> Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Kevin Wolf , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com Dear Eric, Eric Blake writes: > arglist =3D (all other parameters) > if self.device_name: > arglist.append(id=3Dself.device_name) > else: > arglist.append(device=3D'drive0') > invoke(self.vm.qmp, arglist) That would be: qmp_args =3D {'cmd': 'blockdev-change-medium', 'filename': new_img, 'format': iotests.imgfmt} if self.device_name is not None: qmp_args['id'] =3D self.device_name else: qmp_args['device'] =3D 'drive0' result =3D self.vm.qmp(**qmp_args) Or: qmp_args =3D {'filename': new_img, 'format': iotests.imgfmt} if self.device_name is not None: qmp_args['id'] =3D self.device_name else: qmp_args['device'] =3D 'drive0' result =3D self.vm.qmp('blockdev-change-medium', **qmp_args) FWIW these days I tend to use Python magics (like *args / **kwargs) only if there's a _significant_ improvement in either functionality or readability; especially for code bases that are being worked on by developers who don't speak Python "natively". Using magics sparingly also makes it easier for static analysis tools like pylint. Sascha --=20 Softwareentwicklung Sascha Silbe, Niederhofenstra=C3=9Fe 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr. DE281696641