Re: sharing data across Examples docstrings

2022-01-11 Thread Sebastian Luque
On Wed, 12 Jan 2022 09:28:16 +1100,
Cameron Simpson  wrote:

[...]

> Personally I'd be inclined to put long identical examples in the class
> docstring instead of the method, but that may not be appropriate.

Good point, and perhaps it's best to put a comprehensive example in the
class docstring, rather than scatter it across the methods' docstrings.
The situation is one in which the methods are typically (but not always)
intended to be used as part of a pipeline of operations; e.g. Foo.foo()
would almost always be used before Foo.bar().

Thanks,
-- 
Seb
-- 
https://mail.python.org/mailman/listinfo/python-list


sharing data across Examples docstrings

2022-01-11 Thread Sebastian Luque
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


Re: debugging during package development

2015-08-01 Thread Sebastian Luque
On Sat, 01 Aug 2015 15:30:34 +1000,
Ben Finney ben+pyt...@benfinney.id.au wrote:

 Seb splu...@gmail.com writes:
 With lots of debugging to do, the last thing I'd want is to worry
 about the search path.

 Short answer: you need ‘python3 ./setup.py develop’.

 Medium-length answer: you need to add some infrastructure to get your
 project to the point where you can run ‘python3 ./setup.py develop’.

 Longer answer below.

 So I've been searching for better ways to work, but I can't seem hit
 the right keywords and come with all sorts of tangentially related
 stuff.

 The Python module search path is an abstraction, with only a partial
 relationship to the location of modules files in the filesystem.

 The expectation is that a module (or a package of modules) will be
 *installed* to a location already in the module search path (with
 ‘python ./setup.py .

 This allows for cross-platform package management, especially on
 systems that don't have a working OS package manager. The trouble is
 that it does cause a significant learning curve for Python
 programmers, and is an ongoing sore point of Python.

 I'm sure there must be some tool that sets up the development
 environment when the package source is not on `sys.path`. Any advice
 on this topic would be appreciated.

 What you need is to tell Distutils which Python modules form your
 project URL:https://docs.python.org/3/library/distutils.html.

 Once you've got a working ‘setup.py’ for your project, run ‘python3
 ./setup.py develop’ to allow your packages to be run in-place while
 you develop them.

This sounds exactly like what I was looking for.  I was growing tired of
doing 'python setup.py install', every time I wanted to debug something.
The subpackages' modules have inter-dependencies, which require the
whole package to be in `sys.path`.  Unfortunately, I have to stick with
Python 2.7...

Thank you,

-- 
Seb

-- 
https://mail.python.org/mailman/listinfo/python-list