Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I don't think it's worth washing hogs over. -- Larry Wall in <199710060253.TAA09723@wall.org>


devel / comp.lang.python / Re: sharing data across Examples docstrings

SubjectAuthor
o Re: sharing data across Examples docstringsMartin Di Paola

1
Re: sharing data across Examples docstrings

<mailman.182.1642215225.3079.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16707&group=comp.lang.python#16707

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: martinp....@gmail.com (Martin Di Paola)
Newsgroups: comp.lang.python
Subject: Re: sharing data across Examples docstrings
Date: Sat, 15 Jan 2022 02:53:38 +0000
Lines: 62
Message-ID: <mailman.182.1642215225.3079.python-list@python.org>
References: <87v8ypgc0a.fsf@phoca.sebkatja.org>
<20220115025338.rei6ynyansqtmaxy@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de N89kCQs8U+QxZkdGK3FHHwX02Dftj1ow/Kf89RAcOgKw==
Return-Path: <martinp.dipaola@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=S0CrnrB4;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; '2022': 0.05;
'searching': 0.05; 'class.': 0.07; '"""': 0.09; 'mechanism': 0.09;
'url:github': 0.14; 'url:mailman': 0.15; '--------': 0.16;
'default.': 0.16; 'fixes': 0.16; 'generating': 0.16;
'received:209.85.210.52': 0.16; 'received:mail-
ot1-f52.google.com': 0.16; 'rewrite': 0.16; 'separately': 0.16;
'subject:sharing': 0.16; 'tedious': 0.16; 'wrote:': 0.16;
'message-id:@gmail.com': 0.18; 'tue,': 0.19; 'to:addr:python-
list': 0.20; '(and': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'examples': 0.25; 'url:listinfo': 0.25;
'url-ip:188.166/16': 0.25; '11,': 0.26; 'else': 0.27; '>>>': 0.28;
'received:209.85.210': 0.29; 'url-ip:188/8': 0.31; 'context':
0.32; 'validate': 0.32; 'but': 0.32; "i'm": 0.33; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34; 'running': 0.34;
'bar': 0.35; 'from:addr:gmail.com': 0.35; 'thanks,': 0.36;
'received:209.85': 0.37; 'could': 0.38; 'received:209': 0.39;
'use': 0.39; 'something': 0.40; 'hello,': 0.40; 'want': 0.40;
'try': 0.40; 'sharing': 0.60; 'share': 0.63; 'pass': 0.64; 'let':
0.66; 'natural': 0.69; 'within': 0.69; 'below': 0.69; 'you.':
0.71; 'features': 0.75; 'bias': 0.76; 'martin.': 0.84; 'shares':
0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=date:from:to:subject:message-id:mail-followup-to:'user-agent
:references:mime-version:content-disposition:in-reply-to;
bh=AWDLsD4fxnasNsFjls21VJN4Mx+Zm8Yn0OEmmIcpa3Y=;
b=S0CrnrB4bF0od8NiTtScY1aREAp2nmX1VxkOgwEasTLwVkixt4NVNw2EqiVq0ELbBH
itUCtIFgOXaHWqcl1JufEAH8zP5fEe3GveVTfVQJAf6lXVGQis5ZJq9av/NKIaRBt2vN
STI8PgouzHLV9tN8FeKOnnmV1hv8lqd02RbtJbBAjaLxADAdACSxlN20YUApJkk2otc+
FkIMVyMHeAHth4eUCZosdnDZmmyMtIphJromR6zAuh+tHQe8LWAkMMsCQ2tglmN+49NV
uqcn1UxaASZg83bAx2aBdByFTy9nWcXnmLDUhsKXLfRcozJtmPObWpYlLcfj3NCv2EaW
qi+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to
:'user-agent:references:mime-version:content-disposition:in-reply-to;
bh=AWDLsD4fxnasNsFjls21VJN4Mx+Zm8Yn0OEmmIcpa3Y=;
b=p/vhbfk9otC0iUn/f3ZuMSkd06mUnhP/iztR4lpm1hcPzm0LsmJJox+tPbFx1r1u4Z
3WQy1uREiiNOhacO5mH7byZJhaT7mZS5uKQBHygalyGmSI6UM1VlkaM37X0kS91h6v0N
BPyhBbeKUHACZA7vxMFiSC7Vtl0Ez2m0/qbN3g96pzrBafRmghj/wRw+f0nf47QMgnNT
4gG7sUHkcmIiFplkC4ajOCxwXfCb8pKORUUQ5MBfpKx2gd13k2bRYnhkpfClaSEa39wj
6cEB65t0zfH4sjchPSBog7XnqjqAXPkZ4D1QOhWDxkM1u/td9UMSUy9yu9n89s96UZE7
Y65w==
X-Gm-Message-State: AOAM533Bxa4nQLialDdMVw7r5+ETfas9bGPQ8LzrvbM0zTZxCee0wL52
HKU9ikkqwEqcteZwwjP/pN0QuBvChGjhlQ==
X-Google-Smtp-Source: ABdhPJzZWYPXVlZFkWOCYWj5NCBzdPwZjbeXKu11o/dDtVVpvl1P6NqSTsAlXxSlRG7JXC3yAwqn0A==
X-Received: by 2002:a05:6830:4033:: with SMTP id
i19mr9474120ots.217.1642215222424;
Fri, 14 Jan 2022 18:53:42 -0800 (PST)
Mail-Followup-To: python-list@python.org
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.5.2 Lightning/5.4.5.2'
Content-Disposition: inline
In-Reply-To: <87v8ypgc0a.fsf@phoca.sebkatja.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20220115025338.rei6ynyansqtmaxy@gmail.com>
X-Mailman-Original-References: <87v8ypgc0a.fsf@phoca.sebkatja.org>
 by: Martin Di Paola - Sat, 15 Jan 2022 02:53 UTC

Hello,

I understand that you want to share data across examples (docstrings)
because you are running doctest to validate them (and test).

The doctest implementation evaluates each docstring separately without
sharing the context so the short answer is "no".

This is a limitation of doctest but it is not the only testing engine
that you can use.

You could use "byexample" ( https://byexamples.github.io ) which it
shares the context by default.

byexample has more features and fixes other caveats of doctests, but
don't take me too serious, I have a natural bias because I'm its author.

If you want to go with byexample, you may want to try its "doctest
compatibility mode" first so you don't have to rewrite any test.
( https://byexamples.github.io/byexample/recipes/python-doctest )

Let me know if it is useful for you.

Thanks,
Martin.

On Tue, Jan 11, 2022 at 04:09:57PM -0600, Sebastian Luque wrote:
>Hello,
>
>I am searching for a mechanism for sharing data across Examples sections
>in docstrings within a class. For instance:
>
>class Foo:
>
> def foo(self):
> """Method foo title
>
> The example generating data below may be much more laborious.
>
> Examples
> --------
> >>> x = list("abc") # may be very long and tedious to generate
>
> """
> pass
>
> def bar(self):
> """Method bar title
>
> Examples
> --------
> >>> # do something else with x from foo Example
>
> """
> pass
>
>
>Thanks,
>--
>Seb
>--
>https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor