Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: A pickle problem! Date: Fri, 22 Apr 2016 14:33:39 -0600 Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de wDhIi0ioccRTjiSzUYBJDA/W6bkbiv946xijhqyzZ6jQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; '21,': 0.07; 'attributes': 0.07; '22,': 0.09; 'derived': 0.09; 'dict': 0.09; 'thu,': 0.15; '2016': 0.16; 'customizing': 0.16; 'paulo': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subclasses.': 0.16; 'underscores': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'keys': 0.22; 'subject:problem': 0.22; 'header:In-Reply- To:1': 0.24; 'fri,': 0.27; 'possibility': 0.27; 'message- id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'looks': 0.29; 'pickle': 0.29; 'probably': 0.31; 'class': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'instance': 0.35; 'there': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'no,': 0.38; 'received:209': 0.38; 'thank': 0.38; 'to:addr:python.org': 0.40; 'your': 0.60; 'behavior': 0.61; 'you.': 0.64; 'account': 0.66; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=Yrx6YU0XEfbqIVMWpBdaBZO0Ktf07wD4hx5yUIcRj6c=; b=XkQPeoQ/VND80Ivp8hGfAStRtqE3aK5GX4QVLoChYBuS1w02eREs6RX4lhQFfWVcu0 eVQ/WpFOSlbaoDnTLVF6KSMqJdbb5ZnDvN0zKPz0Z8JbNaCXYa/QY9QWhIH5/sMAlDKU 4yxkBLzh8e5QjtrXq0VbqL1lNGBsbojrSJXqKPGZTjAz/h9+ldKX3yjlAPeo2BXYiUt3 UMU0zfkwZ4Af5O84vTJWSqvkKqVunHP4ap1muQ1OnJSIfNbzPnBnnHCYAFsheItbAKv0 KdIi3wzSnRyp4lhOII/Zz1RyXHpsD4kNreUbD+dsfXtGYPEJS6g5CwgMyrZTN9n90RhT LLlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=Yrx6YU0XEfbqIVMWpBdaBZO0Ktf07wD4hx5yUIcRj6c=; b=hLwhKF0inm1OoYaQPqs2BXsh2+Ay5WoDNWmO2bptixC79EW5iR4Ve0L/NwF8qlC7/g heav9Y9Tjs7awOIjmpgd7TTS7nsWbfRZEehBUc34cWKxtwprB5L9/9P4oBbLpWRaIKeo C1djE0r8ylwXdNYMg/nbKKC0g1YL3zHJxLXo97/x6k/h4dUAIAJInnWff/ZlXAiUzGnn +sjBq98CQOXje/wgeCKCsIXQ8K75uXJvVhYxPqocpjwVTfjxL5sL0QfNtIZtc4KxfZ6N CgWV9SHyE8WcOVfhcPF4XTXOtT2M+D1L9spYn399wQZhvj/UFg3vBlAdXEHdz6iWgZq2 yKcA== X-Gm-Message-State: AOPr4FWAEXW4k5G486qO7xomBdLNob7DsnejfgZNLeZ/j/ayEi4zv5IFtnjSwMcPfZ6bMJ/p6s2RJHsWm+M5kg== X-Received: by 10.107.10.87 with SMTP id u84mr25515270ioi.188.1461357259129; Fri, 22 Apr 2016 13:34:19 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:107509 On Fri, Apr 22, 2016 at 2:21 PM, Paulo da Silva wrote: > =C3=80s 17:27 de 22-04-2016, Ian Kelly escreveu: >> On Thu, Apr 21, 2016 at 7:52 PM, Paulo da Silva >> wrote: >>> =C3=80s 22:43 de 21-04-2016, Paulo da Silva escreveu: > ... > >> >> Probably this is necessary because the DataFrame class is already >> customizing its pickle behavior without taking into account the >> possibility of added attributes by subclasses. I think that your >> solution of wrapping the state of the superclass looks fine. >> > Thank you. > > For any other vars ... > Is there a way to get the vars of only the derived class? If they start with two underscores then you could use the name mangling to find them. If the class name is MyClass then look for any keys in the instance dict that start with '_MyClass__'. Otherwise no, you'd have to list them explicitly.