[Python-announce] plum-py 0.7.2 release (Pack / Unpack Memory bytes)

2021-11-10 Thread Dan Gass
I am pleased to announce the availability of beta release 0.7.2 of the "plum
-py" package.

This pure Python package provides classes and utility functions to
transform byte sequences into Python objects and back. While similar
in purpose to Python's standard library ``struct`` module, this
package provides a larger set of format specifiers and is extensible,
allowing you to easily create complex ones of your own.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum
Install: pip install plum-py

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

Change List
=

- Support packing ``bytearray()`` with ``ItemsX`` transforms.
- Previously when an exception occurred during pack/unpack operation and the
  dump records were half baked, creating dump representation for exception
  message resulted in a different error and didn't allow the dump to be
  seen and used.
- Add ``AttrDict`` and ``AttrDictX`` for packing/unpacking dictionaries
  where members are accessible via attribute syntax.
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[Python-announce] plum-py 0.7.1 release (Pack / Unpack Memory bytes)

2021-11-02 Thread Dan Gass
I am pleased to announce the availability of beta release 0.7.1 of the "plum
-py" package.

This pure Python package provides classes and utility functions to
transform byte sequences into Python objects and back. While similar
in purpose to Python's standard library ``struct`` module, this
package provides a larger set of format specifiers and is extensible,
allowing you to easily create complex ones of your own.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum
Install: pip install plum-py

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

Change List
=

- Support ``BitFields`` usage as ``typ`` in structure ``bitfield_member()``.
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


plum-py 0.6.0 release (Pack / Unpack Memory bytes)

2021-05-20 Thread Dan Gass
I am pleased to announce the availability of beta release 0.6.0 of
the "plum-py" package.

This pure Python package provides classes and utility functions to
transform byte sequences into Python objects and back. While similar
in purpose to Python's standard library ``struct`` module, this
package provides a larger set of format specifiers and is extensible,
allowing you to easily create complex ones of your own.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum
Install: pip install plum-py

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

Change List
=

- Add support to ArrayX for packing/unpacking an array with a dims
header.
- Add SizedX transform for packing/unpacking an object with a size
header.
- Fix anomalous NameError exception which occurred when unpacking a
structure
  member which has a default and set to "readonly" (occurred for cases
where
  the eval of the string representation of default value is not the same
  object as the default value itself).
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


plum-py 0.5.0 released

2021-05-10 Thread Dan Gass
I am pleased to announce the availability of beta release 0.5.0 of
the "plum-py" package. While this release contains many breaking changes,
the API should now remain relatively stable until the anticipated 1.0.0
release expected later this year.

This pure Python package provides classes and utility functions to
transform byte sequences into Python objects and back. While similar
in purpose to Python's standard library ``struct`` module, this
package provides a larger set of format specifiers and is extensible,
allowing you to easily create complex ones of your own.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

Change List
=

- This beta release contains many breaking changes! This release note
  entry attempts to summarize most breaking changes. Please read the
  extensively rewritten documentation to assess in detail what has
changed.

- Python 3.6 support dropped.

- Changed most plum constructs (e.g. `Int`, `Float`, etc.) from being
  a data store type (with transform properties) into a simple
  transform type (e.g. `IntX`, `FloatX`, etc.). Instead of subclassing
  to obtain a custom transform, now instantiate the transform.

- `ByteArray` data store eliminated and replaced with `BytesX`
transform.

- Added `ItemsX` transform for specifying dict, list, tuple formats.

- Structure & BitFields changes
- Bitfield members `cls` argument name changed to `typ`.
- Member `cls` argument name changed to `fmt`.
- Type annotations no longer used for the member format transform
  (previously if `cls` was unspecified, the annotation was used).
- Pack operations no longer accept dictionaries.
- Reduced number of member definition classes (same abilities exist,
  but features were added to standard `Member` to accomodate them).
- `pack()` now only usable as a class method. `ipack()` introduced
  for usage on instances.

- Pack operations now return `bytes` instead of `bytearray`.

- Unpack operations no longer support File I/O as input buffer.

- `pack()` and `unpack()` functions/methods offer more flexibility for
  specifying data transform format.

- `pack_into()` eliminated.

- `unpack_from()` eliminated (use `Buffer` construct instead).
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[baseline 1.2.0] Easy String Baseline

2020-12-22 Thread Dan Gass
I am pleased to announce the availability of a new backwards compatible
feature in the "baseline" package (releases 1.2.0). This release includes
support for Python 3.9 and removal of support for Python 3.4 and 3.5.

This tool facilitates streamlining the creation and maintenance of tests
which compare string
output against a baseline. It offers a mechanism to compare a string against
a baselined copy and update the baselined copy to match the new value when a
mismatch occurs. The update process includes a manual step to facilitate a
review of the change before acceptance. The tool uses multi-line string
format
for string baselines to improve readability for human review.

Docs: https://baseline.readthedocs.io/en/latest/
PyPi: https://pypi.org/project/baseline/
Repo: https://github.com/dmgass/baseline

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)


*
1.2.0 2020-DEC-22
*

+ Add ``--force`` command line option to suppress acknowledgement
  prompt.

+ Add Python 3.9 support advertisement. (Regression testing
  added to the release process.)

+ Remove Python 3.4 and 3.5 support advertisement. (Regression testing
  removed from release process.) Nothing blocks installation, but no
  promise exists that the package works with those interpreter versions.
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[baseline 1.1.2] Easy String Baseline

2020-05-10 Thread Dan Gass
I am please to announce the availability of new backwards compatible
features and fixes in the "baseline" package (releases 1.1.0, 1.1.1, 1.1.2).

This tool streamlines creation and maintenance of tests which compare string
output against a baseline. It offers a mechanism to compare a string against
a baselined copy and update the baselined copy to match the new value when a
mismatch occurs. The update process includes a manual step to facilitate a
review of the change before acceptance. The tool uses multi-line string
format
for string baselines to improve readability for human review.

Docs: https://baseline.readthedocs.io/en/latest/
PyPi: https://pypi.org/project/baseline/
Repo: https://github.com/dmgass/baseline

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

**
1.1.2 2020-MAY-02
*

+ Maintain file permissions and owner (both when generating update
  file and when applying update file to original script). Previously,
  file owner and permissions were set based on permission levels of
  execution context which caused issues when executing under elevated
  permission levels (e.g. sudo).


*
1.1.1 2020-MAY-02
*

+ Improve experimental feature to support specifying an alternative
  location. Add ``BASELINE_MOVE_UPDATES`` environment variable that
  when set to ``YES``, enables specifying an alternative location to
  write update files. This master switch facilitates allowing CI/CD
  systems to enable the feature while leaving the feature off in
  local development while still using CI/CD resources (e.g. tox).


*
1.1.0 2020-MAY-01
*

+ Add ``--clean`` (`-c`) option to baseline command line tool to
  remove update files.

+ Add ``--diff`` (`-d`) option to baseline command line tool that
  shows difference and queries for overwrite permission for each
  updated file.

+ Change update file extension to ``.py.update`` so that testing
  frameworks such as ``unittest`` or ``pytest`` ignore them.

+ Add experimental feature to support specifying an alternative
  location to write update files with the ``BASELINE_UPDATES_PATH``
  environment variable. (Note, ``BASELINE_RELPATH_BASE`` must be
  set when using this feature.)

+ Add experimental feature to print contextual differences whenever
  a baseline mis-compare occurs. The feature may be turned on by
  setting the environment variable (``BASELINE_PRINT_DIFFS="YES"``)
  or overriding the class attribute (``Baseline.PRINT_DIFFS = True``).
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[plum-boost 0.1.0] Pack/Unpack Memory Performance Enhancer

2020-05-10 Thread Dan Gass
I am please to announce the first beta release of the "plum-boost" package.

The "plum-py" Python package provides strictly Python based classes and
utility functions to efficiently pack and unpack bytes. When installed, the
"C" based implementations in "plum-boost" are leveraged by the "plum-py"
package to improve packing and unpacking performance in the following areas:

- Integers (including Enums, Bit Fields, and Bit Flags)
- Floats
- Structures (fixed sized)

Docs: https://gitlab.com/dangass/plum/-/blob/master/boost/README.rst
PyPi: https://pypi.org/project/plum-boost/
<https://pypi.org/project/plum-py/>
Repo: https://gitlab.com/dangass/plum

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[plum-py 0.3.1] Pack/Unpack Memory

2020-04-13 Thread Dan Gass
I am please to announce the availability of beta release 0.3.1 of the
"plum-py" package.

This package provides classes and utility functions to efficiently pack and
unpack bytes similar to what the standard library `struct` module offers.
This package expands significantly on that capability with much more
powerful and convenient access and control of bytes within a buffer
(including handling variable size/type relationships within the buffer
data).

The package provides a large number of fundamental types (e.g.
numbers, structures, arrays, etc.) for specifying buffer data structure.
Each type conforms to a "plug-and-play" architecture facilitating the
ability to be combined in any way, including deeply nested structures of
arbitrary type. You may also write your own custom types that conform to
the "plug-and-play" architecture API and use them in combination with any
of the fundamental types provided.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

Change List
=

- Add support for passing a factory function as the ``cls`` argument
  for following variable member definitions:

+ ``VariableDimsMember``
+ ``VariableSizeMember``

- Improve structure representation of enumeration members.
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[plum-py 0.3.0] Pack/Unpack Memory

2020-03-31 Thread Dan Gass
I am please to announce the availability of beta release 0.3.0 of the
"plum-py" package.

This package provides classes and utility functions to efficiently pack and
unpack bytes similar to what the standard library `struct` module offers.
This package expands significantly on that capability with much more
powerful and convenient access and control of bytes within a buffer
(including handling variable size/type relationships within the buffer
data).

The package provides a large number of fundamental types (e.g.
numbers, structures, arrays, etc.) for specifying buffer data structure.
Each type conforms to a "plug-and-play" architecture facilitating the
ability to be combined in any way, including deeply nested structures of
arbitrary type. You may also write your own custom types that conform to
the "plug-and-play" architecture API and use them in combination with any
of the fundamental types provided.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

Change List
=

   - Add ``plum.items`` module for collections of typed items for data
   packing applications where the item structure is not predefined.
   - Add support to ``ByteArray`` to restrict instances to a specific size
   during unpacking (add ``nbytes`` parameter to ``__unpack__``).
   - Change ``plum.structure.Structure`` behaviors as follows:
  - Remove support for accepting typed items (use ``plum.items``
  instead).
  - Block subclasses from redefining members when inheriting from a
  class with members already defined.
  - Generate ``__init__`` method only when not overridden (previously
  it generated ``__init__`` only if an override was not present in the new
  structure class, now it also checks the base classes).
  - Facilitate subclassing structure base class without defining
  members as well as subclassing a structure that has defined members.
  - Eliminate restrictions on mutating structures (e.g. ``append()``,
  ``extend()``, etc.)
   - Simplifications:
  - Remove ``cls`` argument in ``getbytes()`` function (backward
  incompatible change).
  - Eliminate need to set ``dump.cls`` in ``__pack__`` and
  ``__unpack__`` methods (it is now the responsibility of those calling
  ``add_record()`` dump method).
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[baseline 1.0.0] Easy String Baseline

2020-03-30 Thread Dan Gass
I am please to announce the availability of the first major release of the
"baseline" package.

This tool streamlines creation and maintenance of tests which compare string
output against a baseline. It offers a mechanism to compare a string against
a baselined copy and update the baselined copy to match the new value when a
mismatch occurs. The update process includes a manual step to facilitate a
review of the change before acceptance. The tool uses multi-line string
format
for string baselines to improve readability for human review.

Docs: https://baseline.readthedocs.io/en/latest/
PyPi: https://pypi.org/project/baseline/
Repo: https://github.com/dmgass/baseline

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)

***
Changes
***

The following summarizes changes since the previous "beta" release (the
major revision bump signifies backwards incompatible changes):

+ Improve baseline update when multiple values compared against the
  same baseline. Generate a single multi-line baseline with headers
  between the various alternative values. This facilitates updating
  the baseline again.

+ Support Python 3.8. Previously, when run using 3.8, the baseline
  update tool misplaced baseline updates in the first triple quoted
  string found above the baseline. (Python 3.8 stack frames now
  report the line number of the first line in a statement rather
  than the last.)

+ Change behavior of ``Baseline`` to use raw strings when updating
  baselines when possible to improve readability.

+ Deprecate ``RawBaseline`` since ``Baseline`` now incorporates
  its behavior.


***
Quick Start
***

Create an empty baseline with a triple quoted multi-line string. Place
the ending triple quote on a separate line and indent it to the level
you wish the string baseline update to be indented to. Add a compare of
the string being tested to the baseline string. Then save the file as
``fox.py``:

.. code-block:: python

from baseline import Baseline

expected = Baseline("""
""")

test_string = """THE QUICK BROWN FOX
JUMPS
OVER THE LAZY DOG."""

assert test_string == expected


Run ``fox.py`` and observe that the ``assert`` raises an exception since
the strings are not equal.  Because the comparison failed, the tool located
the triple quoted baseline string in the source file and updated it with the
mis-compared value. When the interpreter exited, the tool saved the updated
source file but changed the file name to ``fox.update.py``:

.. code-block:: python

from baseline import Baseline

expected = Baseline("""
THE QUICK BROWN FOX
JUMPS
OVER THE LAZY DOG.
""")

test_string = """THE QUICK BROWN FOX
JUMPS
OVER THE LAZY DOG."""

assert test_string == expected


After reviewing the change with your favorite file differencing tool,
accept the change by either manually overwriting the original file or use
the ``baseline`` command line tool to scan the directory for updated
scripts and accept them:

.. code-block:: shell

$ python -m baseline *
Found updates for:
  fox.py

Hit [ENTER] to update, [Ctrl-C] to cancel

fox.update.py -> fox.py


Run ``fox.py`` again and observe the ``assert`` does not raise an exception
nor is a source file update generated. If in the future the test value
changes, the ``assert`` will raise an exception and cause a new source file
update to be generated. Simply repeat the review and acceptance step and you
are back in business!


https://baseline.readthedocs.io/en/latest/
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[plum-py 0.2.0] Pack/Unpack Memory

2020-03-11 Thread Dan Gass
I am please to announce the availability of the first beta release of the
"plum-py" package.

This package provides classes and utility functions to efficiently pack and
unpack bytes similar to what the standard library `struct` module offers.
This package expands significantly on that capability with much more
powerful and convenient access and control of bytes within a buffer
(including handling variable size/type relationships within the buffer
data).

The package provides a large number of fundamental types (e.g.
numbers, structures, arrays, etc.) for specifying buffer data structure.
Each type conforms to a "plug-and-play" architecture facilitating the
ability to be combined in any way, including deeply nested structures of
arbitrary
type. You may also write your own custom types that conform to
the "plug-and-play" architecture API and use them in combination with any
of the fundamental types provided.

Docs: https://plum-py.readthedocs.io/en/latest/index.html
PyPi: https://pypi.org/project/plum-py/
Repo: https://gitlab.com/dangass/plum

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue39451] enum.Enum reference count leaks

2020-01-26 Thread Dan Gass


Dan Gass  added the comment:

Sorry for not thinking of trying this sooner. Running garbage collection, 
import gc; gc.collect(), releases the resources and restores the expected 
reference counts.

>From my perspective, this is satisfactory and could justify closing this bug 
>report. 

The exception logic in Enum.__new__ could potentially be cleaned up for this 
use case, just not sure if that would introduce risk for other use cases. 

I am guessing (from the perspective of the larger Python exception handling 
design and implementation) what this bug report demonstrates had been 
previously thought through.

--

___
Python tracker 
<https://bugs.python.org/issue39451>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39451] enum.Enum reference count leaks

2020-01-24 Thread Dan Gass


New submission from Dan Gass :

Given
(1) instantiation of an enumeration class with an invalid value
(2) a try/except around the instantiation where the exception is ignored

Then:
An unneeded reference to the bad value is lost (as well as other values that I 
suspect are local variables within a participating method)

When run, the attached sample script shows before and after reference counts 
which demonstrate the potential resource leaks. The sample script includes the 
output from running the script on Python version 3.7.5 within the module 
docstring.

The root cause appears to be in the exception handling in the Enum.__new__ 
method (in the area where it calls the _missing_ hook). The attached sample 
script includes a simplified version of those methods that should help pinpoint 
the code in question and confirm the root cause.

Not being an exception nitty-gritty expert, I have suspicions that users should 
be warned about using this pattern of exception handling. I suspect this 
pattern would be worth avoiding in the Enum implementation.

I am willing to take a stab at submitting a patch for Enum. I hesitate slightly 
not knowing if there are specific reasons for the code existing in its current 
form. Alternatively, I plan on being at PyCon2020 for the sprints and could be 
available then to work on it.

--
components: Library (Lib)
files: sample.py
messages: 360670
nosy: dan.g...@gmail.com
priority: normal
severity: normal
status: open
title: enum.Enum reference count leaks
type: resource usage
versions: Python 3.7
Added file: https://bugs.python.org/file48863/sample.py

___
Python tracker 
<https://bugs.python.org/issue39451>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[baseline 0.2.1] Easy String Baseline

2018-06-08 Thread Dan Gass
I am please to announce the availability of the "baseline" package.

This tool streamlines creation and maintenance of tests which compare string
output against a baseline. It offers a mechanism to compare a string against
a baselined copy and update the baselined copy to match the new value when a
mismatch occurs. The update process includes a manual step to facilitate a
review of the change before acceptance. The tool uses multi-line string
format
for string baselines to improve readability for human review.

Docs: https://baseline.readthedocs.io/en/latest/
PyPi: https://pypi.org/project/baseline/
Repo: https://github.com/dmgass/baseline

License: MIT

With Regards,
Dan Gass
(dan.gass at gmail)


***
Quick Start
***

Create an empty baseline with a triple quoted multi-line string. Place
the ending triple quote on a separate line and indent it to the level
you wish the string baseline update to be indented to. Add a compare of
the string being tested to the baseline string. Then save the file as
``fox.py``:

.. code-block:: python

from baseline import Baseline

expected = Baseline("""
""")

test_string = "THE QUICK BROWN FOX\nJUMPS\nOVER THE LAZY DOG."

assert test_string == expected


Run ``fox.py`` and observe that the ``assert`` raises an exception since
the strings are not equal.  Because the comparison failed, the tool located
the triple quoted baseline string in the source file and updated it with the
miscompared value. When the interpretter exited, the tool saved the updated
source file but changed the file name to ``fox.update.py``:

.. code-block:: python

from baseline import Baseline

expected = Baseline("""
THE QUICK BROWN FOX
JUMPS
OVER THE LAZY DOG.
""")

test_string = "THE QUICK BROWN FOX\nJUMPS\nOVER THE LAZY DOG."

assert test_string == expected


After reviewing the change with your favorite file differencing tool,
accept the change by either manually overwriting the original file or use
the ``baseline`` command line tool to scan the directory for updated
scripts and accept them:

.. code-block:: shell

$ python -m baseline *
Found updates for:
  fox.py

Hit [ENTER] to update, [Ctrl-C] to cancel

fox.update.py -> fox.py


Run ``fox.py`` again and observe the ``assert`` does not raise an exception
nor is a source file update generated. If in the future the test value
changes, the ``assert`` will raise an exception and cause a new source file
update to be generated. Simply repeat the review and acceptance step and you
are back in business!


https://baseline.readthedocs.io/en/latest/;>
baseline 0.2.1 - Easy String Baseline (07-Jun-18)
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: self question

2006-07-25 Thread dan . gass
 cnt = 1
 def foo():
   global cnt
   cnt += 1
   return cnt

 def bar(x=foo()):
   print x

 bar() # 2
 bar() # 2
 bar() # 2

Looks to me like you want to use the following programming pattern to
get dynamic default arguments:

cnt = 1
def foo():
global cnt
cnt += 1
return cnt

def bar(x=None):
if x is None:
x = foo()
print x
 
bar()   # 2
bar()   # 3
bar()   # 4

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


Re: An optparse question

2006-07-21 Thread dan . gass
 No, that affects the string printed only *after* the usage =  string.
  What I would like to do is insert some string *before* the usage = 
 string, which is right after the command I type at the command prompt.
 So I would like to make it look like this:

The example was fine (except for a typo) as far as demonstrating the
concept.  Try this corrected version:

from optparse import OptionParser

usage = ' THIS IS NEWLY INSERTED STRING
\nusage: %prog [options] input_file'
parser = OptionParser(usage=usage)
parser.print_help()

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


Re: An optparse question

2006-07-21 Thread dan . gass

 Nope.  That only *nearly* does what T wants.  The usage message will
 still be printed immediately *after* the 'usage: ' string.

  parser = OptionParser(usage=usage)
  parser.print_help()
 usage:  THIS IS NEWLY INSERTED STRING
 usage: lopts.py [options] input_file

 options:
   -h, --help  show this help message and exit

Yes, I see what T meant now.  Behavior expectations (assumptions) has a
way of clouding one's vision.

Thanks

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


Re: Which is More Efficient?

2006-05-18 Thread dan . gass
Measure it and find out.  Sounds like a little investment in your time
learning how to measure performance may pay dividends for you.

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


Re: using breakpoints in a normal interactive session

2006-02-23 Thread dan . gass
Carl -- Perfect!  That is exactly what I want.  I hoped it would be
that easy.  Thanks for taking the time to post the solution.

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


using breakpoints in a normal interactive session

2006-02-22 Thread dan . gass
Is there a way to temporarily halt execution of a script (without using
a debugger) and have it put you in an interactive session where you
have access to the locals?  And possibly resume?  For example:

 def a():
...   x = 1
...   magic_breakpoint()
...   y = 1
...   print got here
...
 a()
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 3, in a
  File stdin, line 2, in magic_breakpoint
 x
1
 y
Traceback (most recent call last):
  File stdin, line 1, in ?
NameError: name 'y' is not defined
 magic_resume()
got here
 x
Traceback (most recent call last):
  File stdin, line 1, in ?
NameError: name 'x' is not defined

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


Re: Making mouse wheel work with pmw ScrolledCanvas widget

2006-02-19 Thread dan . gass
This looks like it has nothing to do with Pmw (Mega widgets) but is
really a basic Tkinter problem.

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


Making mouse wheel work with pmw ScrolledCanvas widget

2006-02-18 Thread dan . gass
Hi,

I am using the pmw tkinter package and having trouble getting the
ScrolledCanvas widget to respond to the mouse wheel.  I am running
Windows XP.  I've Googled it and came up empty.  I believe it should be
possible because Idle's editor window supports scrolling with a mouse
wheel.

Thanks in advance,

Dan Gass

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


[Python-Announce] cfgparse v01_01 released

2005-03-23 Thread Dan Gass
I'm pleased to announce the V01_01 release of cfgparse.

Whats New
-
1) Exception argument added to the Configuration parser initializer so
that exceptions may be raised when user errors are encountered instead
of the default call to sys.exit() that doesn't provide traceback.
2) Error messages were enhanced giving more detailed information.

Background
-
cfgparse is a more convenient, flexible, and powerful module for
parsing configuration files than the standard library ConfigParser
module. cfgparse uses a more declarative style modelled after the
popular optparse standard library module.

cfgparse can optionally cooperate with the optparse module to provide
coordination between command line and configuration file options. In
addition, the cooperation can be used to allow the user to control
features of the parser from the command line.

URLs
-
Documentation: http://cfgparse.sourceforge.net/
Download: http://sourceforge.net/projects/cfgparse/

Feature Summary
-
+ Simple ini style configuration syntax.
+ Type checking with error handling and help messages.
+ Help summary modelled after that in optparse.
+ Round trip - read, modify, write configuration files with comment retention.
+ Cooperates with optparse so options may be overridden from command line.
+ Supports heirarchically organized option settings.
   * User may store multiple option settings in a arbitrarily deep
keyed dictionary.
   * Application uses a key list to walk into the dictionary to obtain
a setting.
   * User controls key list with setting in configuration file.
   * Keys may be added to the list using command line or environment variables.
+ Supports allowing user control of configuration files used.
   * Environment variables may be used to specify a default configuration file.
   * Command line may be used to specify additional configuration files.
   * Configuration files may include other configuration files.
+ Configuration files may alternatively be written in Python.
   * Full power and flexibility of Python available for creation of
option settings.
   * Allows options settings to be real Python objects.
   * This feature is NOT enabled by default.
+ May be extended to support syntax such as XML.

Enjoy,
Dan Gass
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


[Python-Announce] cfgparse v01_01 released

2005-03-23 Thread Dan Gass
I'm pleased to announce the V01_01 release of cfgparse.

Whats New
-
1) Exception argument added to the Configuration parser initializer so
that exceptions may be raised when user errors are encountered instead
of the default call to sys.exit() that doesn't provide traceback.
2) Error messages were enhanced giving more detailed information.

Background
-
cfgparse is a more convenient, flexible, and powerful module for
parsing configuration files than the standard library ConfigParser
module. cfgparse uses a more declarative style modelled after the
popular optparse standard library module.

cfgparse can optionally cooperate with the optparse module to provide
coordination between command line and configuration file options. In
addition, the cooperation can be used to allow the user to control
features of the parser from the command line.

URLs
-
Documentation: http://cfgparse.sourceforge.net/
Download: http://sourceforge.net/projects/cfgparse/

Feature Summary
-
+ Simple ini style configuration syntax.
+ Type checking with error handling and help messages.
+ Help summary modelled after that in optparse.
+ Round trip - read, modify, write configuration files with comment retention.
+ Cooperates with optparse so options may be overridden from command line.
+ Supports heirarchically organized option settings.
   * User may store multiple option settings in a arbitrarily deep
keyed dictionary.
   * Application uses a key list to walk into the dictionary to obtain
a setting.
   * User controls key list with setting in configuration file.
   * Keys may be added to the list using command line or environment variables.
+ Supports allowing user control of configuration files used.
   * Environment variables may be used to specify a default configuration file.
   * Command line may be used to specify additional configuration files.
   * Configuration files may include other configuration files.
+ Configuration files may alternatively be written in Python.
   * Full power and flexibility of Python available for creation of
option settings.
   * Allows options settings to be real Python objects.
   * This feature is NOT enabled by default.
+ May be extended to support syntax such as XML.

Enjoy,
Dan Gass
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wanted: C++ parser written in Python

2005-02-25 Thread dan . gass
You can look at the techniques and regular expressions in the
testgen.c.unit test module that is part of a generic test framework
called TestGen.  TestGen uses a parser to automatically stub / copy
functions for testing purposes.  The parser is capable of identifying
the function/method name as well as the parameters and return type.
The only caveat with using regular expressions is the function/method's
closing } must be in column zero.  If you figure out a different way to
get around the restriction or other improvements to the parser let me
know.

I'm about to release a newer version, but the area that you would be
looking at is not changing so I would go ahead and download the latest
that is there.  TestGen can be found at
sourceforge.net/projects/testgen

Regards,
Dan Gass

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


Re: cfgparse v01_00 released

2005-02-01 Thread dan . gass
 I like this, its really nice that it fits well with optparse.

Thanks.

 I read through the docs, mostly it seems very logical, the following
 things stood out to me as not really fitting:

 http://cfgparse.sourceforge.net/cfgparse-round-trip-set.html
 It doesn't seem logical that in order to modify the option in the
 desired section correctly, you need to pass the config file in. The
keys
 argument in the option itself should be able to determine this.

There is a lot of necessary flexibility built into the interfaces for
round trip and it sounds like it is tripping you up.  The user may
choose to split their configuration up into multiple files and use
include to pull it all together.  When you program your application
you have a choice.  Don't pass in a config file object and let it set
the option where ever the user has it --OR-- pass in the configuration
file object where you want it set and it won't matter where the user
put it.  BTW, since you may not know where the user put the setting,
the set() method returns the config file object that was updated so
that you may write its contents out.  I just noticed this is
undocumented and I will fix that in the next release.

 http://cfgparse.sourceforge.net/node24.html
 The use of b and v for quoting seems obscure. Would it not be
better
 to use pythonic triple-quoted strings?
 On first glance they look like markup tags rather than multi-line
 continuations (particularly b looks like bold).

I did consider triple quotes but decided against it for the following
reasons:

1) I couldn't think of a good way to distinguish between blocks and
verbatim blocks without it being too subtle.
2) XML encapsulation may be more understandable to the majority of end
users (of which many are not Python programmers).
3) XML offers a style that will be extensible for future additions.

I'm not opposed to changing this area but it will need good a argument
and consensus.


 The fact that lines without an equals sign are ignored seems a bit
 lenient ...

Perhaps.  If I get good arguments as to why it should be more stringent
and a consensus is formed this could be changed.


 It also seems strange how different the structure is between the
 ini-style and the Python-style formats:
 http://cfgparse.sourceforge.net/cfgparse-python.html

 driver = 'ethernet'
 path = { 'DEFAULT' : '192.168.0.99',
   'DEV0': '192.168.0.0',
   'DEV1': '192.168.0.1' }

 Is equivalent to:

 [DEFAULT]
 driver = 'ethernet'
 path = 192.168.0.99
 [DEV0]
 path = 192.168.0.0
 [DEV1]
 path = 192.168.0.1

 I wonder whether it would be better to use Python classes to
represent
 the same thing:

 class DEFAULT:
driver = 'ethernet'
path = '192.168.0.99'

 class DEV0(DEFAULT):
path = '192.168.0.0'

 class DEV1(DEFAULT):
path = '192.168.0.1'

 This seems to me to bear more logical structure resemblance to the
 ini-style format.

Classes cannot be used because they have a restricted character set.
The INI style was implemented to be similar to what is already in the
standard library and has the benefits of simplicity yet maitains a lot
of flexibility.  Because of this I'm anticipating it to be the style of
choice by the vast majority.  The Python style is for power users.  I
believe both styles lend themselves to visualizing how all the settings
get blended together in a master dictionary.

I'm open to tweaking the Python syntax if there are good arguments and
concensus.


 Otherwise really cool!

Thanks again for your feedback.  It is appreciated.  I've spent a fair
amount of time implementing and testing features that I don't really
use in order to be able to contribute this to the Python community.  If
you would like to see it (or see specific features it has) in the
standard library I encourage you to make comments at
http://www.python.org/moin/ConfigParserShootout

Regards,
Dan Gass

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


[Python-Announce] cfgparse v01_00 released

2005-01-30 Thread Dan Gass
I'm pleased to announce the initial release of cfgparse (V01_00)
 
Background
-
cfgparse is a more convenient, flexible, and powerful module for
parsing configuration files than the standard library ConfigParser
module. cfgparse uses a more declarative style modelled after the
popular optparse standard library module.

cfgparse can optionally cooperate with the optparse module to provide
coordination between command line and configuration file options. In
addition, the cooperation can be used to allow the user to control
features of the parser from the command line.

URLs
-
Docs/home page: http://cfgparse.sourceforge.net/
Download: http://sourceforge.net/projects/cfgparse/

Feature Summary
-
+ Simple ini style configuration syntax
+ Type checking with error handling and help messages
+ Help summary modelled after that in optparse
+ Round trip - read, modify, write configuration files with comment retention
+ Cooperates with optparse for configuration file options that should be 
overridden by command line options
+ Supports heirarchically organized option settings
* User may store multiple option settings in a arbitrarily deep
keyed dictionary.
* Application uses a key list to walk into the dictionary to
obtain a setting.
* User controls key list with setting in configuration file.
* Supports adding keys to the list through a command line option or from 
environment variables.
+ Supports allowing user control of configuration files used.
* Environment variables may be used to allow user to specify a default 
configuration file.
* Command line options to specify configuration file supported.
* Configuration files may include other configuration files where where 
sections are read in parallel.
* Configuration files may be nested heirarchically by including
configuration
files from within a section or subsection.
+ Configuration files may alternatively be written in Python.
* full power and flexibility of Python available for creation of
option settings
* allows options settings to be real Python objects
* this feature is NOT enabled by default
+ May be extended to support syntax such as XML.

Enjoy,
Dan Gass
-- 
http://mail.python.org/mailman/listinfo/python-list