[Python-announce] Re: [Python-Dev] [RELEASE] The last Python 3.11 alpha (3.11.0a7) is available - Prepare for beta freeze

2022-04-06 Thread Finn Mason
For whatever reason, the links for two PEPs wouldn't work, so here are
working ones:

* [PEP 646](https://peps.python.org/pep-0646/)
* [PEP 675](https://peps.python.org/pep-0675)

--
Finn (Mobile)

On Wed, Apr 6, 2022, 4:31 AM Pablo Galindo Salgado 
wrote:

> Br. do you feel that? That's the chill of *beta freeze* coming
> closer. Meanwhile, your friendly CPython release team doesn’t
> rest and we have prepared a shiny new release for you: Python 3.11.0a7.
>
>
> 
> Dear fellow core developer:
> This alpha is the last release before feature freeze (Friday, 2022-05-06),
> so make sure that all new features and PEPs are landed in the master branch
> before we
> release the first beta. Please, be specially mindfully to check the CI and
> the buildbots, maybe even using the test-with-buildbots label in GitHub
> before
> merging so the release team don’t need to fix a bunch of reference leaks
> or platform-specific problems on the first beta release.
>
> 
>
>
> *Go get the new alpha here:*
> https://www.python.org/downloads/release/python-3110a7/
>
> **This is an early developer preview of Python 3.11**
>
> # Major new features of the 3.11 series, compared to 3.10
>
> Python 3.11 is still in development.  This release, 3.11.0a7 is the last
> of seven planned alpha releases.
>
> Alpha releases are intended to make it easier to test the current state of
> new features and bug fixes and to test the release process.
>
> During the alpha phase, features may be added up until the start of the
> beta phase (2022-05-06) and, if necessary, may be modified or deleted up
> until the release candidate phase (2022-08-01).  Please keep in mind that
> this is a preview release and its use is **not** recommended for production
> environments.
>
> Many new features for Python 3.11 are still being planned and written.
> Among the new major new features and changes so far:
>
> * [PEP 657](https://www.python.org/dev/peps/pep-0657/) -- Include
> Fine-Grained Error Locations in Tracebacks
> * [PEP 654](https://www.python.org/dev/peps/pep-0654/) -- Exception
> Groups and except*
> * [PEP 673](https://www.python.org/dev/peps/pep-0673/)  -- Self Type
> * [PEP 646](https://www.python.org/dev/peps/pep-0646/)-- Variadic Generics
> * [PEP 680](https://www.python.org/dev/peps/pep-0680/)-- tomllib: Support
> for Parsing TOML in the Standard Library
> * [PEP 675](https://www.python.org/dev/peps/pep-0675/)-- Arbitrary
> Literal String Type
> * [PEP 655](https://www.python.org/dev/peps/pep-0655/)-- Marking
> individual TypedDict items as required or potentially-missing
> * [bpo-46752](https://bugs.python.org/issue46752)-- Introduce task groups
> to asyncio
> * The [Faster Cpython Project](https://github.com/faster-cpython) is
> already yielding some exciting results: this version of CPython 3.11 is
> ~12% faster on the geometric mean of the [PyPerformance benchmarks](
> speed.python.org), compared to 3.10.0.
>  * Hey, **fellow core developer,** if a feature you find important is
> missing from this list, let me know.
>
> The next pre-release of Python 3.11 will be 3.11.0b1, currently scheduled
> for Friday, 2022-05-06.
>
> # More resources
>
> * [Online Documentation](https://docs.python.org/3.11/)
> * [PEP 664](https://www.python.org/dev/peps/pep-0664/), 3.11 Release
> Schedule
> * Report bugs at [https://bugs.python.org](https://bugs.python.org).
> * [Help fund Python and its community](/psf/donations/).
>
> # And now for something completely different
>
> In mathematics, the Dirac delta distribution (δ distribution) is a
> generalized function or distribution over the real numbers, whose value is
> zero everywhere except at zero, and whose integral over the entire real
> line is equal to one. The current understanding of the impulse is as a
> linear functional that maps every continuous function to its value at zero.
> The delta function was introduced by physicist Paul Dirac as a tool for the
> normalization of state vectors. It also has uses in probability theory and
> signal processing. Its validity was disputed until Laurent Schwartz
> developed the theory of distributions where it is defined as a linear form
> acting on functions. Defining this distribution as a "function" as many
> physicist do is known to be one of the easier ways to annoy mathematicians
> :)
>
> # We hope you enjoy those new releases!
>
> Thanks to all of the many volunteers who help make Python Development and
> these releases possible! Please consider supporting our efforts by
> volunteering yourself or through organization contributions to the Python
> Software Foundation.
>
> Your friendly release team,
> Pablo Galindo @pablogsal
> Ned Deily @nad
> 

[issue44941] Add check_methods function to standard library

2021-08-20 Thread Finn Mason


Finn Mason  added the comment:

Thank you for the suggestions.

>From what I could tell, the cited python-ideas discussion was more about 
>checking the signature of a method. However, an issue cited by the ex-BDFL 
>(issue9731) was helpful. It's a similar idea that verifies that a class 
>implements an ABC. However, I'm looking at a function that simplifies writing 
>the ABC itself.

I will post the idea to python-ideas and see what people think.

--

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



[issue44941] Add check_methods function to standard library

2021-08-18 Thread Finn Mason


Finn Mason  added the comment:

I strongly feel that `check_methods` shouldn't be in collections.abc, even 
though that's where it's originally found, because it's not related 
specifically to collections but to ABCs and classes in general. I would prefer 
for it to be implemented in `abc` or similar.

I'm reverting to the original title until a module is decided on.

I'd be happy to do the implementation and pull request once approval is given 
and a module is decided on.

--
title: Add check_methods function to collections.abc in standard library -> Add 
check_methods function to standard library

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



[issue44941] Add check_methods function to standard library

2021-08-17 Thread Finn Mason


New submission from Finn Mason :

In _collections_abc.py is a private function titled `_check_methods`. It takes 
a class and a number of method names (as strings), checks if the class has all 
of the methods, and returns NotImplemented if any are missing. The code is 
below:

```
def _check_methods(C, *methods):
mro = C.__mro__
for method in methods:
for B in mro:
if method in B.__dict__:
if B.__dict__[method] is None:
return NotImplemented
break
else:
return NotImplemented
return True
```

This is an incredibly convenient function (referred to as check_methods here on 
out) for creating abstract base classes, and is much simpler than using 
`hasattr` for each method you want to check. For example:

```
>>> from abc import ABCMeta
>>> # Without check_methods
>>> class A(metaclass=ABCMeta):
... @classmethod
... def __subclasshook__(cls, subclass):
... return (hasattr(subclass, 'foo') and
... callable(subclass.foo) and
... hasattr(subclass, 'bar') and
... callable(subclass.bar) or
... NotImplemented)
...
>>> # With check_methods
>>> class B(metaclass=ABCMeta):
... @classmethod
... def __subclasshook(cls, subclass):
... return check_methods(subclass, 'foo', 'bar')
...
>>>
```

This would be a great function to add to the standard lib, perhaps in the `abc` 
module.

One problem with `check_methods` as defined in _collections_abc.py is that it 
doesn't check if the name is callable. Also, type hints and more readable 
variables may be desirable. The final code, if implemented, may look something 
like this:

```
# In imports section: from typing import Literal
def check_methods(Class: type, *methods: str) -> Literal[True, NotImplemented]:
"""Check if class `Class` has methods `methods`."""
mro = Class.__mro__
for method in methods:
for Base in mro:
if (attr := getattr(Base, method, None)) is not None:
if not callable(attr):
return NotImplemented
break
else:
return NotImplemented
return True
```

Again, this would be a great function to add to the `abc` module or a similar 
one.

--
components: Library (Lib)
messages: 399814
nosy: finnjavier08
priority: normal
severity: normal
status: open
title: Add check_methods function to standard library
type: enhancement

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



[issue42560] Improve Tkinter Documentation

2021-08-12 Thread Mason Ginter


Mason Ginter  added the comment:

Those changes sound great to me, Mark. I've been busy with work and don't think 
I'll have the time to implement those changes. If you or someone else would 
like to work on this, I would gladly let you take over.

--

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



[issue44341] Conflict between re.match and match keyword

2021-06-07 Thread Finn Mason


Change by Finn Mason :


--
nosy:  -finnjavier08

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



[issue44341] Conflict between re.match and match keyword

2021-06-07 Thread Finn Mason


New submission from Finn Mason :

>>> import re
>>> re.match('str', 'str').group()
'str'
>>> match 'str':
... case 'str':
... print('match!')
...
match!
>>> from re import match
>>> match


As the above example demonstrates, while re.match doesn't raise an error 
despite having a keyword name, importing re.match directly into __main__ 
replaces the keyword with the function. The obvious solution is to rename 
re.match, but this would break many, many pieces of code.

--
components: Library (Lib), Regular Expressions
messages: 395295
nosy: ezio.melotti, finnjavier08, mrabarnett
priority: normal
severity: normal
status: open
title: Conflict between re.match and match keyword
type: behavior
versions: Python 3.10, Python 3.11

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



[issue42560] Improve Tkinter Documentation

2020-12-09 Thread Mason Ginter


Mason Ginter  added the comment:

Would it then be a good idea to add a link to the archive.org version of 
effbot? If so how best to add it to the documentation. The only other instances 
I can find links to archive.org in the documentation reference webpages that 
are down permanently, unlike effbot.

Docs/library/unittest.rst:55
Docs/library/xmlrpc.client.rst:52
Docs/using/windows.rst:1088

In the documentation, should we clarify that effbot is temporarily down and 
link to the archive.org, or just change the hyperlink (as in other instances 
above)?

--

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



[issue42560] Improve Tkinter Documentation

2020-12-03 Thread Mason Ginter


New submission from Mason Ginter :

Online python Tkinter documentation 
(https://docs.python.org/3/library/tkinter.html) lacks many features. The main 
part I find lacking is documentation on methods, as many of them either aren't 
listed in the documentation and/or take *args as the only parameter, rather 
than defined parameters. 

Not sure how in-depth docs from effbot were, but those are not currently 
available.

Existing documentation in the source code 
(https://github.com/python/cpython/blob/3.9/Lib/tkinter/__init__.py) seems to 
be a good start to adding to the online documentation.

--
assignee: docs@python
components: Documentation
messages: 382437
nosy: docs@python, mason2
priority: normal
severity: normal
status: open
title: Improve Tkinter Documentation
type: enhancement

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



[issue5710] ctypes should return composite types from callbacks

2013-09-27 Thread Mason Bially

Mason Bially added the comment:

I agree with Amaury that this is purely a user side concern. While I think it's 
important to note the behaviour of ctypes in the case that Thomas describes, I 
believe it's more important to fully support the range of behaviours allowed by 
C function callbacks.

I see the use cases for complex return types that don't fall under the concerns 
raised by Thomas as the following:

* Returning a pointer to already existing memory.
* Returning complex value types (structs of ints, doubles, chars, ect). This is 
especially important from a compatibility standpoint for C libraries which 
expect such return types.

Because I need this for my current project I will work on writing a patch.

--
nosy: +Mason.Bially

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5710
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Calling Python functions from Excel

2009-11-16 Thread Darcy Mason
On Nov 15, 2:20 am, Cannonbiker lusve...@gmail.com wrote:

 Please I need Calling Python functions from Excel and receive result
 back in Excel. Can me somebody advise simplest solution please? I am
 more VBA programmer than Python.

A couple of years ago I used MSScriptControl for this. Couldn't find a
great reference just now, but here is a discussion which should give
enough information:
http://www.velocityreviews.com/forums/t319222-re-python-in-excel.html

Check from around message 3 on.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue6636] Non-existant directory in sys.path prevents further imports

2009-08-03 Thread Charles Mason

New submission from Charles Mason cemaso...@gmail.com:

Steps to reproduce:

1) Add to sys.path a path that does not exist
2) Import a module, any module.  This invokes get_path_importer over
every element of sys.path.  The NullImporter __init__ method is called
and an instance created for each non-existing path element in sys.path.
3) Create the path and put a valid module in said path
4) Try to import that module.

Behavior is that the interpreter fails to import.  This behavior seems
local to import.c only.

Attached a test case that shows failed for 2.5, 2.6, 3.0. 3.1rc1+.  I
have yet to test on the trunk but I can/will do that if necessary.

I believe I can fix this myself but I want to verify this is incorrect
behavior (a bug) and not an Undocumented Feature (or hell, maybe it
*is* documented somewhere).  I've skimmed over PEP 302 and didn't see
any relevant information.

If someone gives me the go ahead (or at least doesn't give me reason not
to), I'll get a patch put together, perhaps for several different fixes.

--
components: Interpreter Core
files: test.py
messages: 91241
nosy: cemasoniv
severity: normal
status: open
title: Non-existant directory in sys.path prevents further imports
type: behavior
versions: Python 2.5, Python 2.6, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file14640/test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6636
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Michael M Mason


Dave Angel da...@ieee.org wrote in message 
news:mailman.4120.1249172970.8015.python-l...@python.org...

Michael M Mason wrote:
div class=moz-text-flowed style=font-family: -moz-fixedI'm running 
Python 3.1 on Vista and I can't figure out how to add my own directory to 
sys.path.


Thanks to Jon, Piet, David and Dave for the responses.


sys.path gets its values from several places.


Ah, I'd misunderstood the docs: I thought it came from just one place (which 
I couldn't find).


Anyway, I'd suggest adding it to PythonPath, and if it's empty, just 
create it with the directory you need.


Thanks--that worked!

I'm hoping you know you can also add to sys.path directly during script 
initialization.  It's just a list, and is writeable.


Yes, but I'm mainly playing in IDLE and I was getting a bit fed up of 
repeatedly typing

 import sys
 sys.path.append('C:/Users/Michael/Code/Python')
 import mystuff

--
Michael


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


Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Michael M Mason
Mark Lawrence breamore...@yahoo.co.uk wrote in message 
news:mailman.4130.1249203322.8015.python-l...@python.org...
Be careful, I'm screwed things up on several occasions by placing a file 
on PYTHONPATH that overrides a file in the standard library, test.py being 
my favourite!


Thanks.  Sure enough, I've already got my own test.py but I hadn't 
discovered it was a problem yet...


--
Michael 


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


Newbie thwarted by sys.path on Vista

2009-08-01 Thread Michael M Mason
I'm running Python 3.1 on Vista and I can't figure out how to add my own 
directory to  sys.path.


The docs suggest that I can either add it to the PYTHONPATH environment 
variable or to the PythonPath key in the registry.  However, PYTHONPATH 
doesn't exist, and updating the registry key has no effect (and in any case 
the contents aren't the same as sys.path).


So where does sys.path get its value from, and how do I change it?

--
Michael 


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


Re: Running all unit tests

2009-02-06 Thread Darcy Mason
On Feb 6, 9:11 pm, Jason Voegele ja...@jvoegele.com wrote:
 I'm working on my first substantial Python project, and I'm following a fully
 test-first approach.  I'd like to know how Pythonistas typically go about
 running all of their tests to ensure that my application stays green.

 In Ruby, I would have a Rake task so that I could say rake test and all
 tests would be executed.  In C or C++ I would have a make target so I could
 run all my tests with make test.  In Java it would be an Ant task and ant
 test.  And so forth and so on.

 What's the recommended approach for Python programs?  I'm sure I could write
 a shell script (or a Python script even) that scans my test directory for
 test cases and runs them, but I'm wondering if there's something already
 built in that could do this for me.

 --
 Jason Voegele
 Only fools are quoted.
                 -- Anonymous

I don't know about the recommended approach, but I've done something
like you suggest in a library I authored. Any files named test*.py are
found and added to the unittest test suite.
See 
http://code.google.com/p/pydicom/source/browse/trunk/source/dicom/test/run_tests.py.
HTH
Darcy
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dummy explanation to win32com needed

2008-10-22 Thread Darcy Mason
On Oct 22, 3:43 pm, korean_dave [EMAIL PROTECTED] wrote:
 Hi. I need a dummy's explanation to utilizing the win32com component
 to access Microsoft Excel.

 So far, I have this code.

     import win32com.client
     xl = win32com.client.Dispatch(Excel.Application)
     xl.Visible = 1

     workbook = xl.Workbooks.Open(C:\test.xls)

 Now, my question is, where do I find the snytax I can use to access
 such functions like workbook.ActiveSheet.Cells(1,1).Value etc...

 I need a reference to the API I can utilize.

 Where can I find this?

 Thanks guys,
 -Dave

I haven't used this in quite some time, but if I recall correctly, it
simply follows the object model as found in Excel Help | Visual Basic
Reference, or go into the Excel code editor (alt-F11)and use the
object browser. One thing to be aware of, IIRC, is that in VB you can
leave out some default names (like .Value, .Item for collections) but
these must be explicitly referenced when called using win32com.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Imaging Library (PIL) question

2008-10-20 Thread Darcy Mason
On Oct 20, 2:14 pm, Sid [EMAIL PROTECTED] wrote:
 Hi,

   I am tryin to copy an image into my own data structure(a sort of 2d array  
 for further FFT). I've banged my head over the code for a couple of hours  
 now. The simplified version of  my problem is below.

 #-Code

 import Image
 pic = Image.open(Images/a.jpg)
 (picdata,width,height)  = (pic.load(),pic.size[0],pic.size[1])

 picMap = [[0] * width ] * height        #matrix needed for FFT

 print --Printing PIC MAP--
 for h in range(0,height):
      for w in range(0,width):
          print picMap[h][w], , #everything initialized to ZERO...this is  
 ok
      print \n

 print --Copying to  PIC MAP--
 for h in range(0, height):
      for w in range(0, width):
          picMap[h][w] = picdata[w,h] #problem lies here
          print picMap[h][w], ,  #Seems to copy perfectly here as the  
 output shows
      print \n

 print --Printing PIC MAP AGAIN--
 for h in range(0,height):
      for w in range(0,width):
          print picMap[h][w], ,  #Should print the values as above, but  
 doesn't
      print \n

 #-Code End

 Hopefully someone would take a look and let me know what i'm doing  
 something wrong here.

 Thanks a lot
 -Sid

The problem is likely to do with the line
picMap = [[0] * width ] * height

The first [0]*width creates a list, then the *height repeats the
reference to the same list. See, for example
http://mail.python.org/pipermail/tutor/2001-December/010414.html. It
prints okay in the middle section because the items have just been
stored. Later iterations in that same loop are replacing array
elements that have already been printed. The link explains the problem
and shows a way to avoid this. You might also consider using Numpy, it
has explicit functions to zero any dimension array.

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


convert binary to float

2008-06-01 Thread Mason
I have tried and tried...

I'd like to read in a binary file, convert it's 4 byte values into
floats, and then save as a .txt file.

This works from the command line (import struct);

In [1]: f = open(test2.pc0, rb)
In [2]: tagData = f.read(4)
In [3]: tagData
Out[3]: '\x00\x00\xc0@'

I can then do the following in order to convert it to a float:

In [4]: struct.unpack(f, \x00\x00\xc0@)
Out[4]: (6.0,)

But when I run the same code from my .py file:

f = open(test2.pc0, rb)
tagData = f.read(4)
print tagData

I get this (ASCII??):
└@

I only know how to work with '\x00\x00\xc0@'.

I don't understand why the output isn't the same. I need a solution
that will allow me to convert my binary file into floats. Am I close?
Can anyone point me in the right direction?

Thanks,
Mason




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

Re: convert binary to float

2008-06-01 Thread Mason
On Jun 1, 6:41 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Sun, 1 Jun 2008 12:55:45 -0700 (PDT), Mason
 [EMAIL PROTECTED] declaimed the following in
 comp.lang.python:

  I have tried and tried...

  I'd like to read in a binary file, convert it's 4 byte values into
  floats, and then save as a .txt file.

  This works from the command line (import struct);

  In [1]: f = open(test2.pc0, rb)
  In [2]: tagData = f.read(4)
  In [3]: tagData

 Interpreter display of raw object name uses repr()

  Out[3]: '\x00\x00\xc0@'

  I can then do the following in order to convert it to a float:

  In [4]: struct.unpack(f, \x00\x00\xc0@)
  Out[4]: (6.0,)

  But when I run the same code from my .py file:

  f = open(test2.pc0, rb)
  tagData = f.read(4)
  print tagData

 Display from a print statement uses str()

  I get this (ASCII??):
  „@

 Probably not ASCII -- ASCII doesn't have that spanish (?) bottom row
 quote... And a pair of null bytes don't take up screen space.

  I only know how to work with '\x00\x00\xc0@'.

  I don't understand why the output isn't the same. I need a solution
  that will allow me to convert my binary file into floats. Am I close?
  Can anyone point me in the right direction?

 Why do you have to /see/ the byte representation in the first
 place... just feed the four bytes to the struct module directly.

 import struct
 fin = open(test2.pc0, rb)
 tagFloat = struct.unpack(f, fin.read(4))[0]
 print tagFloat
 --
 WulfraedDennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED]  [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff:   [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/

Thanks Dennis, I'm OK now. I just sort of dropped the ball for a
bit :).

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


Re: convert binary to float

2008-06-01 Thread Mason
On Jun 1, 5:12 pm, George Sakkis [EMAIL PROTECTED] wrote:
 On Jun 1, 3:55 pm, Mason [EMAIL PROTECTED] wrote:



  I have tried and tried...

  I'd like to read in a binary file, convert it's 4 byte values into
  floats, and then save as a .txt file.

  This works from the command line (import struct);

  In [1]: f = open(test2.pc0, rb)
  In [2]: tagData = f.read(4)
  In [3]: tagData
  Out[3]: '\x00\x00\xc0@'

  I can then do the following in order to convert it to a float:

  In [4]: struct.unpack(f, \x00\x00\xc0@)
  Out[4]: (6.0,)

  But when I run the same code from my .py file:

  f = open(test2.pc0, rb)
  tagData = f.read(4)
  print tagData

  I get this (ASCII??):
  „@

 Remembering to put that struct.unpack() call in your module might
 help ;-)

 George

Wow ... I did have it in there, but I forgot include it in my post.
Anyway, this works just fine:

f = open(test2.pc0, rb)
tagData = f.read(4)
print struct.unpack(f, tagData)

Thanks for waking me up George!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Data structure recommendation?

2008-04-07 Thread Charles Mason
If you can imply a partial order on your ranges then you can get O(n lg n)
random access using a heap data structure.

You'll have to implement your own heap, but heap search is easy to implement
(it's Heapify that might require a little thinking).

This will only work, of course, if your ranges are disjoint.

C


On Mon, Apr 7, 2008 at 4:58 PM, Steve Holden [EMAIL PROTECTED] wrote:

 Steven Clark wrote:
  Hi all-
 
  I'm looking for a data structure that is a bit like a dictionary or a
  hash map. In particular, I want a mapping of floats to objects.
  However, I want to map a RANGE of floats to an object.
 
  This will be used for timestamped storage / lookup, where the float
  represents the timestamp.
  get(x) should return the object with the newest (biggest) timestamp
  y = x, if it exists.
  Example:
 
  foo = Foo()
 
  foo.get(1.5)
  - None
  foo.put(1.3, 'a')
  foo.put(2.6, 'b')
  foo.get(1.5)
  - 'a'
  foo.get(7.8)
  - 'b'
  foo.put(5.0, 'c')
  foo.get(7.8)
  - 'c'
 
  In otherwords, by the end here, for foo.get(x),
  x  1.3 maps to None,
  1.3 = x  2.6 maps to 'a',
  2.6 = x  5.0 maps to 'b',
  5.0 = x maps to 'c'.
 
  I know that foo.get() will be called many times for each foo.put(). Is
  there any way to achieve O(1) performance for foo.get(), maybe via
  some kind of hash function? Or is the best thing to use some kind of
  binary search?
 
 I believe the best way to implement this would be a binary search
 (bisect?) on the actual times, which would be O(log N). Though since
 they are timestamps they should be monotonically increasing, in which
 case at least you don't have to go to the expense of sorting them.

 Some kind of hash function won't hack it, since the purpose of a hash
 function is to map a large number of (possibly) evenly-distributed
 (potential) keys as nearly as possible randomly across a much smaller
 set of actual values.

 You might try messing around with reducing the precision of the numbers
 to home in on a gross region, but I am not convinced that does anything
 other than re-spell binary search if carried to extremes.

 regards
  Steve
 --
 Steve Holden+1 571 484 6266   +1 800 494 3119
 Holden Web LLC  http://www.holdenweb.com/

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

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

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Charles Mason
And for such a behavior they've termed monkeying

Thus, the coinage Monkeypatching for what you want to do:

http://mail.python.org/pipermail/python-dev/2008-January/076194.html

There are a group of people who think monkeypatching is destroying ruby.

You still probably should avoid it for production code.

On Fri, Apr 4, 2008 at 11:25 AM, John Nagle [EMAIL PROTECTED] wrote:

 Bruno Desthuilliers wrote:
  Paul Rubin a écrit :
  Brian Vanderburg II [EMAIL PROTECTED] writes:
  I've checked out some ways to get this to work.  I want to be able to
  add a new function to an instance of an object.
 
  Ugh.  Avoid that if you can.
 
  Why so ? OO is about objects, not classes, and adding methods on a
  per-object basis is perfectly legitimate.

It's what professional programmers call a l33t feature,
 one not suitable for production code.  Typically such features
 are used by programmers with about two years experience,
 trying too hard to prove that they're cool.

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

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

[issue2038] win32pdh.EnumObjects fails on Windows Server 2003 R2

2008-02-07 Thread Richard Mason

New submission from Richard Mason:

The following test script works OK on all windows platforms apart from 
Windows Server 2003 R2:

import win32pdh
win32pdh.EnumObjects(None, None, 0, 1)

When I run on Windows Server 2003 R2 get the following dump:

E:\fusiondx\libtest.py
Traceback (most recent call last):
  File E:\fusiondx\lib\test.py, line 2, in module
win32pdh.EnumObjects(None, None, 0, 1)
pywintypes.error: (-2147481648, 'EnumObjects for buffer size', 'No 
error message is available')

--
components: Extension Modules
messages: 62152
nosy: rmason
severity: critical
status: open
title: win32pdh.EnumObjects fails on Windows Server 2003 R2
type: crash
versions: Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2038
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com