Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56315

Re: Variable arguments (*args, **kwargs): seeking elegance

Newsgroups comp.lang.python
Date 2013-10-07 09:26 -0700
References <5783f76c-5565-4089-a6d5-accb0bf329c0@googlegroups.com>
Message-ID <1d56b6ac-e3ee-4a5e-8d58-dfdaa998b7cc@googlegroups.com> (permalink)
Subject Re: Variable arguments (*args, **kwargs): seeking elegance
From John Ladasky <john_ladasky@sbcglobal.net>

Show all headers | View raw


Thanks, everyone, for your replies.  Perhaps I have complicated things unnecessarily?  I was just trying to do some error-checking on the arguments supplied to the class constructor.  Perhaps Python already implements automatically what I am trying to accomplish manually?  I'll tinker around with some minimal code, try to provoke some errors, and see what I get.

Here is one more detail which may be relevant.  The base class for the family of classes I am developing is a numpy.ndarray.  The numpy.ndarray is a C extension type (and if I understand correctly, that means it is immutable by ordinary Python methods).  Subclassing ndarray can get a bit complicated (see http://docs.scipy.org/doc/numpy/user/basics.subclassing.html).  The ndarray.__init__ method is inaccessible, instead one overrides ndarray.__new__.

Making further subclasses of a subclassed numpy.ndarray, each of which may have their own arguments, is what I am trying to accomplish while adhering to the "DRY" principle.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Variable arguments (*args, **kwargs): seeking elegance John Ladasky <john_ladasky@sbcglobal.net> - 2013-10-05 21:04 -0700
  Re: Variable arguments (*args, **kwargs): seeking elegance Peter Otten <__peter__@web.de> - 2013-10-06 09:25 +0200
  Re: Variable arguments (*args, **kwargs): seeking elegance Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-06 14:34 -0700
  Re: Variable arguments (*args, **kwargs): seeking elegance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-07 02:43 +0000
    Re: Variable arguments (*args, **kwargs): seeking elegance Skip Montanaro <skip@pobox.com> - 2013-10-07 08:52 -0500
  Re: Variable arguments (*args, **kwargs): seeking elegance John Ladasky <john_ladasky@sbcglobal.net> - 2013-10-07 09:26 -0700
    Re: Variable arguments (*args, **kwargs): seeking elegance John Ladasky <john_ladasky@sbcglobal.net> - 2013-10-07 09:42 -0700
    Re: Variable arguments (*args, **kwargs): seeking elegance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-07 21:13 +0000
      Re: Variable arguments (*args, **kwargs): seeking elegance John Ladasky <john_ladasky@sbcglobal.net> - 2013-10-07 14:49 -0700
  Re: Variable arguments (*args, **kwargs): seeking elegance Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-07 14:12 -0700
  Re: Variable arguments (*args, **kwargs): seeking elegance Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-08 01:30 -0700

csiph-web