[RELEASED] Python 3.3.0 release candidate 1

2012-08-25 Thread Georg Brandl

On behalf of the Python development team, I'm delighted to announce the
first release candidate of Python 3.3.0.

This is a preview release, and its use is not recommended in
production settings.

Python 3.3 includes a range of improvements of the 3.x series, as well
as easier porting between 2.x and 3.x.  Major new features and changes
in the 3.3 release series are:

* PEP 380, syntax for delegating to a subgenerator (yield from)
* PEP 393, flexible string representation (doing away with the
   distinction between wide and narrow Unicode builds)
* A C implementation of the decimal module, with up to 80x speedup
   for decimal-heavy applications
* The import system (__import__) now based on importlib by default
* The new lzma module with LZMA/XZ support
* PEP 397, a Python launcher for Windows
* PEP 405, virtual environment support in core
* PEP 420, namespace package support
* PEP 3151, reworking the OS and IO exception hierarchy
* PEP 3155, qualified name for classes and functions
* PEP 409, suppressing exception context
* PEP 414, explicit Unicode literals to help with porting
* PEP 418, extended platform-independent clocks in the time module
* PEP 412, a new key-sharing dictionary implementation that
   significantly saves memory for object-oriented code
* PEP 362, the function-signature object
* The new faulthandler module that helps diagnosing crashes
* The new unittest.mock module
* The new ipaddress module
* The sys.implementation attribute
* A policy framework for the email package, with a provisional (see
   PEP 411) policy that adds much improved unicode support for email
   header parsing
* A collections.ChainMap class for linking mappings to a single unit
* Wrappers for many more POSIX functions in the os and signal
   modules, as well as other useful functions such as sendfile()
* Hash randomization, introduced in earlier bugfix releases, is now
   switched on by default

In total, almost 500 API items are new or improved in Python 3.3.
For a more extensive list of changes in 3.3.0, see

 http://docs.python.org/3.3/whatsnew/3.3.html

To download Python 3.3.0 visit:

 http://www.python.org/download/releases/3.3.0/

Please consider trying Python 3.3.0 with your code and reporting any bugs
you may notice to:

 http://bugs.python.org/


Enjoy!

--
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.3's contributors)
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 1:04 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 You're confusing two different levels of explanation here. On the one
 hand, you're talking about C semantics, where you are explicitly
 responsible for managing unnamed data via indirection (pointers).
 Typically, the *pointers* get given names, the data does not.

 On the other hand, you talk about Python, where you have no access at all
 to the pointers and memory addresses. You manage the data you actually
 care about by giving them names, and then leave it up to the Python
 virtual machine to transparently manage whatever indirection is needed to
 make it work.
 ...
 * in C, I care about identifiers (names) in order to explicitly manage
 addresses and pointers as a means to reach the data I actually care about;

 * in Python, I care about identifiers in order to reach the data I
 actually care about.

Yet the two are almost the same. Python objects don't have names, they
just have their own data. (Leaving aside functions, which have their
names as data for the benefit of tracebacks and such.) A C pointer has
a name; a Python identifier has (or is, if you like) a name. They're
very different in how you use them only because C doesn't naturally
work with everything on the heap and pointers everywhere. In fact,
when I was interfacing Python and C, there were a few places where I
actually handed objects to Python and kept manipulating them, simply
because the Python data model suited what I was trying to do; but what
I was doing was using PyObject *some_object as though it were a Python
variable. I even did up a trivial C++ class that encapsulated the
INCREF/DECREF work, so my LocalPyObject really could be treated as a
local variable, Python-style.

Where's the difference?

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread wxjmfauth
Le samedi 25 août 2012 02:24:35 UTC+2, Antoine Pitrou a écrit :
 Ramchandra Apte maniandram01 at gmail.com writes:
 
  
 
  The zen of python is simply a guideline
 
 
 
 What's more, the Zen guides the language's design, not its implementation.
 
 People who think CPython is a complicated implementation can take a look at 
 PyPy 
 
 :-)

Unicode design: a flat table of code points, where all code
points are equals.
As soon as one attempts to escape from this rule, one has to
pay for it.
The creator of this machinery (flexible string representation)
can not even benefit from it in his native language (I think
I'm correctly informed).

Hint: Google - Das grosse Eszett

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Ben Finney
wxjmfa...@gmail.com writes:

 Unicode design: a flat table of code points, where all code
 points are equals.

Yes, Unicode's design entails a flat table of hundreds of thousands of
code points, expansible in future.

This is in direct conflict with the design of all significant computers
we need to write software for: data stored and transported as 8-bit
bytes, which can only ever hold 256 different values, no expansion.

 As soon as one attempts to escape from this rule, one has to
 pay for it.

Yes, in either direction; the conflict means that trade-offs need to be
made.

See this presentation by Ned Batchelder, “Pragmatic Unicode”
URL:http://nedbatchelder.com/text/unipain.html, which lays out the
fundamental conflict of representing human text in computer data; and
several practical approaches to deal with it.

-- 
 \  “I busted a mirror and got seven years bad luck, but my lawyer |
  `\thinks he can get me five.” —Steven Wright |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Publish unittest results from test discovery

2012-08-25 Thread Mark Lawrence

On 25/08/2012 02:03, Steven D'Aprano wrote:

On Fri, 24 Aug 2012 17:25:05 -0700, Lucretiel wrote:

[...]

Is there a way to get unittest disover to work with xmlrunner


Steady on there! It's only been about an hour and a half since you last
asked this exact same question, almost word-for-word identical. The more
specialised the question, the longer it may take for somebody who knows
the answer to reply. For something like this, I would wait at least a
couple of days before replying to your original post. (Don't just re-post
the question in a new thread, keep the response in a single thread.)

I have no idea about xmlrunner and unittest discovery, sorry.




I entirely agree with Steven's comments.  I'd put a question like this 
on a specialised list.  How about gmane.comp.python.testing.general ? 
Sorry I've no idea what it's called elsewhere.


--
Cheers.

Mark Lawrence.

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


Re: Objects in Python

2012-08-25 Thread Mark Lawrence

On 25/08/2012 07:34, Chris Angelico wrote:

On Sat, Aug 25, 2012 at 1:04 PM, Steven D'Aprano


I'm just wondering out aloud if the number of times this type of thread 
has been debated here will fit into a Python long or float?


--
Cheers.

Mark Lawrence.

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Mark Lawrence

On 25/08/2012 08:27, wxjmfa...@gmail.com wrote:

Le samedi 25 août 2012 02:24:35 UTC+2, Antoine Pitrou a écrit :

Ramchandra Apte maniandram01 at gmail.com writes:






The zen of python is simply a guideline




What's more, the Zen guides the language's design, not its implementation.

People who think CPython is a complicated implementation can take a look at PyPy

:-)


Unicode design: a flat table of code points, where all code
points are equals.
As soon as one attempts to escape from this rule, one has to
pay for it.
The creator of this machinery (flexible string representation)
can not even benefit from it in his native language (I think
I'm correctly informed).

Hint: Google - Das grosse Eszett

jmf



It's Saturday morning, I'm stone cold sober, had a good sleep and I'm 
still baffled as to the point if any.  Could someone please enlightem me?


--
Cheers.

Mark Lawrence.

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


Segfault when setting an instance property on 2.7.3

2012-08-25 Thread Vincent Pelletier
Hi.

(please keep me in CC for replies, I'm not subscribed)

I wrote a ctypes-(wait, read on)-based binding[1] for libusb1, in which I'm 
triggering a segfault from an application[2] I wrote.

I've been through several segfault caused by ctypes mis-usage, this one seems 
different enough. I think there is something else (maybe ultimately caused by 
some ctypes effect, but I don't see the relation yet).

The Python line causing the segfault:
https://github.com/vpelletier/python-libusb1/blob/master/usb1.py#L192

C stack at segfault (with -dbg package installed):
http://pastebin.com/rVUPsSrU

#0
(gdb) print *op
$1 = {ob_refcnt = -4247522206314328575, ob_type = 0xcf0dc50ec50dc50e}
(gdb) up
#1
(gdb) print *obj
$2 = {ob_refcnt = 6, ob_type = 0x9c5f70}
(gdb) print obj
$3 = USBTransfer at remote 0xb3a950

The program using python-libusb1 which triggers the segfault:
https://github.com/vpelletier/ITI1480A-linux/blob/master/iti1480a/capture.py
The event loop is at the bottom: allocate USB transfers, submit them, loop on 
libusb1 event handling until there is no more submitted transfer, libusb uses 
callback which resubmits transfer, ...

ctypes possible segfault causes checklist:
- callback is cast into a ctype CFUNCTYPE type instance
  See:
https://github.com/vpelletier/python-libusb1/blob/master/libusb1.py#L587
https://github.com/vpelletier/python-libusb1/blob/master/usb1.py#L133
- a strong ref to it is kept on USBTransfer instance so it is not GC'ed
  See:
https://github.com/vpelletier/python-libusb1/blob/master/usb1.py#L808
- application is single-threaded (libusb1 doesn't create any C thread either)
  so even if there were missing GIL acquisitions, it shouldn't be a problem
  Also, a strong ref to USBTransfer is kept on USBDeviceHandle instance. When
  an USBDeviceHandle is GC'ed, it cancels any pending transfer, waits for
  completion (=libusb1 callback is executed) and then allow them to be GC'ed.
- we are not accessing unallocated memory in this traceback (although it could
  be that memory got overwritten somehow)

I couldn't trigger the bug while under valgrind (which reported some 
Conditional jump or move depends on uninitialized value(s)  Use of 
uninitialized value of size 8 in PyObject_Free, but reading the code I guess 
they are harmless and unrelated).

Any idea of ways to debug this problem further ?

Regards,
-- 
Vincent Pelletier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Frank Millman

On 25/08/2012 10:58, Mark Lawrence wrote:

On 25/08/2012 08:27, wxjmfa...@gmail.com wrote:


Unicode design: a flat table of code points, where all code
points are equals.
As soon as one attempts to escape from this rule, one has to
pay for it.
The creator of this machinery (flexible string representation)
can not even benefit from it in his native language (I think
I'm correctly informed).

Hint: Google - Das grosse Eszett

jmf



It's Saturday morning, I'm stone cold sober, had a good sleep and I'm
still baffled as to the point if any.  Could someone please enlightem me?



Here's what I think he is saying. I am posting this to test the water. I 
am also confused, and if I have got it wrong hopefully someone will 
correct me.


In python 3.3, unicode strings are now stored as follows -
  if all characters can be represented by 1 byte, the entire string is 
composed of 1-byte characters
  else if all characters can be represented by 1 or 2 bytea, the entire 
string is composed of 2-byte characters

  else the entire string is composed of 4-byte characters

There is an overhead in making this choice, to detect the lowest number 
of bytes required.


jmfauth believes that this only benefits 'english-speaking' users, as 
the rest of the world will tend to have strings where at least one 
character requires 2 or 4 bytes. So they incur the overhead, without 
getting any benefit.


Therefore, I think he is saying that he would have preferred that python 
standardise on 4-byte characters, on the grounds that the saving in 
memory does not justify the performance overhead.


Frank Millman


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


Re: python 6 compilation failure on RHEL

2012-08-25 Thread Anssi Saari
Cameron Simpson c...@zip.com.au writes:

 My personal habit to to build with (adjust to match):

   --prefix=/usr/local/python-2.6.4

 and put some symlinks in /usr/local/bin afterwards (python2.6, etc).

There's actually a program for that, it's called stow.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 6:55 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 I'm just wondering out aloud if the number of times this type of thread has
 been debated here will fit into a Python long or float?

Well, when I have to store currency information, I like to store it as
an integer, using the native currency's small unit (eg the cent in
dollar+cent currencies). In this instance, instead of trying to count
the threads (which would be fractional), just count the number of
posts. It then is an integer, and I've yet to find any integer that
can't be represented as a Python long (or, in 3.x, int).

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


Re: Objects in Python

2012-08-25 Thread Mark Lawrence

On 25/08/2012 11:23, Chris Angelico wrote:

On Sat, Aug 25, 2012 at 6:55 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:

I'm just wondering out aloud if the number of times this type of thread has
been debated here will fit into a Python long or float?


Well, when I have to store currency information, I like to store it as
an integer, using the native currency's small unit (eg the cent in
dollar+cent currencies). In this instance, instead of trying to count
the threads (which would be fractional), just count the number of
posts. It then is an integer, and I've yet to find any integer that
can't be represented as a Python long (or, in 3.x, int).

ChrisA



That could have been fun in the good old days of pounds, shillings and 
pence.  Why they had to complicate things by going decimal I shall never 
know.  Bring back simplistic imperial measures for everything, that's 
what I say.


Using long just shows I've still got a Python 2 hat on.  Still when 
those fine people who develop Matplotlib deliver 1.2 with its Py3k 
compliance, aided or hindered by me testing on Windows, Python 3.3 here 
I come.


I suppose an alternative to long (or int) or float would have been the 
Decimal class from the decimal module?  Opinions on this anybody?


--
Cheers.

Mark Lawrence.

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 7:46 PM, Frank Millman fr...@chagford.com wrote:
 Therefore, I think he is saying that he would have preferred that python
 standardise on 4-byte characters, on the grounds that the saving in memory
 does not justify the performance overhead.

If that's indeed the argument, then at least it's something to argue.
What gets difficult is when people complain about the expansion from a
2-byte narrow build to the current 1/2/4-byte representation, which
will indeed use more memory if there are a small number of 0x
codepoints. But there's a correctness difference there.

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Mark Lawrence

On 25/08/2012 10:46, Frank Millman wrote:

On 25/08/2012 10:58, Mark Lawrence wrote:

On 25/08/2012 08:27, wxjmfa...@gmail.com wrote:


Unicode design: a flat table of code points, where all code
points are equals.
As soon as one attempts to escape from this rule, one has to
pay for it.
The creator of this machinery (flexible string representation)
can not even benefit from it in his native language (I think
I'm correctly informed).

Hint: Google - Das grosse Eszett

jmf



It's Saturday morning, I'm stone cold sober, had a good sleep and I'm
still baffled as to the point if any.  Could someone please enlightem me?



Here's what I think he is saying. I am posting this to test the water. I
am also confused, and if I have got it wrong hopefully someone will
correct me.

In python 3.3, unicode strings are now stored as follows -
   if all characters can be represented by 1 byte, the entire string is
composed of 1-byte characters
   else if all characters can be represented by 1 or 2 bytea, the entire
string is composed of 2-byte characters
   else the entire string is composed of 4-byte characters

There is an overhead in making this choice, to detect the lowest number
of bytes required.

jmfauth believes that this only benefits 'english-speaking' users, as
the rest of the world will tend to have strings where at least one
character requires 2 or 4 bytes. So they incur the overhead, without
getting any benefit.

Therefore, I think he is saying that he would have preferred that python
standardise on 4-byte characters, on the grounds that the saving in
memory does not justify the performance overhead.

Frank Millman




I thought Terry Reedy had shot down any claims about performance 
overhead, and that the memory savings in many cases must be substantial 
and therefore worthwhile.  Or have I misread something?  Or what?


--
Cheers.

Mark Lawrence.

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 9:05 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 I thought Terry Reedy had shot down any claims about performance overhead,
 and that the memory savings in many cases must be substantial and therefore
 worthwhile.  Or have I misread something?  Or what?

My reading of the thread(s) is/are that there are two reasons for the
debate to continue to rage:

1) Comparisons with a narrow build in which most characters take two
bytes but there are one or two characters that get encoded with
surrogates. The new system will allocate four bytes per character for
the whole string.

2) Arguments on the basis of huge strings that represent _all the
data_ that your program's working with, forgetting that there are
numerous strings all through everything that are ASCII-only.

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Terry Reedy

On 8/25/2012 7:05 AM, Mark Lawrence wrote:


I thought Terry Reedy had shot down any claims about performance
overhead, and that the memory savings in many cases must be substantial
and therefore worthwhile.  Or have I misread something?


No, you have correctly read what I and others have said. Jim appears to 
not be interested in dialog. Lets leave it at that.



--
Terry Jan Reedy

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


Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Terry Reedy

On 8/24/2012 6:33 PM, Alex wrote:

I'm new to Python and have been using IDLE 3.2.3 to experiment with
code as I learn. Despite being configured to use a 4 space indentation


That applies to the editor and works in the editor for me and others. A 
tab becomes 4 space characters, and a backspace in the appropriate place 
deletes 4 space characters.



width, sometimes IDLE's smart indentation insists upon using width-8
tabs.


Only for the simulated interpreter. There is a tracker issue about 
changing that but no consensus.



--
Terry Jan Reedy

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


Re: Installation of yappi (timing module)

2012-08-25 Thread Virgil Stokes

On 24-Aug-2012 12:28, Virgil Stokes wrote:
I have been doing some experiments with different modules for the timing of 
functions and code segments. One module I would like to test is yappi (thread 
aware timer) which is listed at PyPI. However, I have been unable to install 
it on Windows Vista and Windows 7 (Python 2.7 on both). I have tried both 
easy_install and pip (as suggested at http://code.google.com/p/yappi/). Here 
is what happens with easy_install


C:\Users\Virgileasy_install yappi
Searching for yappi
Reading http://pypi.python.org/simple/yappi/
Reading http://yappi.googlecode.com/
Best match: yappi 0.62
Downloading http://yappi.googlecode.com//files/yappi-0.62.tar.gz
Processing yappi-0.62.tar.gz
Writing 
c:\users\virgil\appdata\local\temp\easy_install-tzt5gl\yappi-0.62\setup.cfg
Running yappi-0.62\setup.py -q bdist_egg --dist-dir 
c:\users\virgil\appdata\local\temp\easy_install-tzt5gl\yappi-0.62\egg-dist-tmp-t3qodo

In file included from D:\python27\include\Python.h:8,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\pyconfig.h:68: io.h: No such file or directory
D:\python27\include\pyconfig.h:296: stdio.h: No such file or directory
In file included from config.h:4,
 from _yappi.c:10:
D:\python27\include\Python.h:19: limits.h: No such file or directory
D:\python27\include\Python.h:22: #error Something's broken. UCHAR_MAX should 
be defined in limits.h.
D:\python27\include\Python.h:26: #error Python's source code assumes C's 
unsigned char is an 8-bit type.

D:\python27\include\Python.h:33: stdio.h: No such file or directory
D:\python27\include\Python.h:35: #error Python.h requires that stdio.h define 
NULL.

D:\python27\include\Python.h:38: string.h: No such file or directory
D:\python27\include\Python.h:40: errno.h: No such file or directory
D:\python27\include\Python.h:42: stdlib.h: No such file or directory
D:\python27\include\Python.h:49: stddef.h: No such file or directory
D:\python27\include\Python.h:56: assert.h: No such file or directory
In file included from D:\python27\include\Python.h:58,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\pyport.h:306: stdlib.h: No such file or directory
D:\python27\include\pyport.h:312: math.h: No such file or directory
D:\python27\include\pyport.h:325: time.h: No such file or directory
D:\python27\include\pyport.h:377: sys\stat.h: No such file or directory
In file included from D:\python27\include\Python.h:85,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\unicodeobject.h:4: stdarg.h: No such file or directory
D:\python27\include\unicodeobject.h:57: ctype.h: No such file or directory
D:\python27\include\unicodeobject.h:120: wchar.h: No such file or directory
In file included from D:\python27\include\Python.h:94,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\stringobject.h:10: stdarg.h: No such file or directory
In file included from D:\python27\include\Python.h:98,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\bytearrayobject.h:9: stdarg.h: No such file or directory
In file included from D:\python27\include\Python.h:121,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\pyerrors.h:319: stdarg.h: No such file or directory
In file included from D:\python27\include\Python.h:126,
 from config.h:4,
 from _yappi.c:10:
D:\python27\include\modsupport.h:10: stdarg.h: No such file or directory
In file included from _yappi.c:10:
config.h:15: stdint.h: No such file or directory
In file included from _yappi.c:23:
timing.h:8: windows.h: No such file or directory
error: Setup script exited with error: command 'gcc' failed with exit status 1

And pip fails with similar problems (same pyconfig errors where C++ header 
files are not found). In both cases yappi-0.62.tar.gz was downloaded.Note: 1) 
I also tried to install from the source which also failed with similar 
problems, 2) I have both cygwin and MinGW gcc compilers on my systems and they 
do contain in their include folder these missing header files.


Any suggestions on how yappi can be installed would be appreciated.

--V :-)




Problem solved!
The ordering of the gcc compilers in my PATH statement caused this failure. I 
have ordered these compilers such that the first one contains the required 
header files and the installation of yappi is now successful.

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


Re: lpod-python

2012-08-25 Thread jerome . dumonteil
Le dimanche 12 août 2012 21:45:49 UTC+2, Agon Hajdari a écrit :
 On Fri, 10 Aug 2012 19:37:16 +0200, Francesco wrote:
 
 
 
  I'm trying to use the lpod-python module to programmatically read data
 
  from Open Document files. My problem is: i can't download the module
 
  from its authors' site,
 
  http://download.lpod-project.org/lpod-python/lpod-python-0.9.3.tar.gz.
 
  It seems the download site is unavailable, while the main site is
 
  working.
 
  I also tried to install the module with pip (I read on the site that
 
  it's now available), but again, no luck.
 
  Do somebody know what's happening to download.lpod-project.org ? It
 
  doesn't even ping...
 
  
 
  Please let me know, thank you very much.
 
  Francesco
 
 
 
 It seems that they are hosting their project at gitorious.org via git. 
 
 Try this: 
 
 git clone git://gitorious.org/lpod-project/lpod-python.git (u need the 
 
 git client of course)
 
 
 
 Agon

Hi, 
The lpod-python code is now at https://github.com/lpod/lpod-python 

git clone git://github.com/lpod/lpod-python.git

We are currently improving source code. There are also new development recipes 
to help (see the readme on git hub).


regards,
jd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Alex
Terry Reedy wrote:

 On 8/24/2012 6:33 PM, Alex wrote:
  Despite being configured to use a 4 space
  indentation
...
  sometimes IDLE's smart indentation insists upon using
  width-8 tabs.
 
 [The 4-space indentation setting] applies to the editor and works in 
 the editor for me and others.
 
 [The width-8 tabs are inserted] Only for the simulated interpreter.
 There is a tracker issue about changing that but no consensus.

Yes, it works in the editor. I was referring to the simulated
interpreter. I guess I didn't make that clear.

In my search for a solution, I did see some of the traffic regarding
the tracker issue, but the posts were all several years old and I was
hoping maybe there was a fix by now. I guess not. Maybe in Python 4, eh?

Thanks.

Alex

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


Re: Filter versus comprehension (was Re: something about split()???)

2012-08-25 Thread David Robinow
On Fri, Aug 24, 2012 at 3:03 PM, Walter Hurry walterhu...@lavabit.com wrote:
 On Fri, 24 Aug 2012 14:29:00 -0400, Dennis Lee Bieber wrote:

 It appears to be a change Google made in the last month or two... My
 hypothesis is that they are replacing hard EOL found in inbound NNTP
 with an HTML p, and then on outgoing replacing the p with a pair of
 NNTP line endings. In contrast, text composed on Google is coming in as
 long single lines (since quoting said text in a response produces on a
  at the start of the paragraph.

 Google Groups sucks. These are computer literate people here. Why don't
 they just use a proper newsreader?
I haven't used a newsreader in over a decade. I'm quite happy with a
mailing list. Am I missing something?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Mark Lawrence

On 25/08/2012 13:50, Alex wrote:

Terry Reedy wrote:


On 8/24/2012 6:33 PM, Alex wrote:

Despite being configured to use a 4 space
indentation

...

sometimes IDLE's smart indentation insists upon using
width-8 tabs.


[The 4-space indentation setting] applies to the editor and works in
the editor for me and others.

[The width-8 tabs are inserted] Only for the simulated interpreter.
There is a tracker issue about changing that but no consensus.


Yes, it works in the editor. I was referring to the simulated
interpreter. I guess I didn't make that clear.

In my search for a solution, I did see some of the traffic regarding
the tracker issue, but the posts were all several years old and I was
hoping maybe there was a fix by now. I guess not. Maybe in Python 4, eh?

Thanks.

Alex



For the record issue 7676, yes?

--
Cheers.

Mark Lawrence.

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


Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Alex
Mark Lawrence wrote:

 On 25/08/2012 13:50, Alex wrote:
  Terry Reedy wrote:
  
   On 8/24/2012 6:33 PM, Alex wrote:
Despite being configured to use a 4 space
indentation
  ...
sometimes IDLE's smart indentation insists upon using
width-8 tabs.
   
   [The 4-space indentation setting] applies to the editor and works
   in the editor for me and others.
   
   [The width-8 tabs are inserted] Only for the simulated
   interpreter.  There is a tracker issue about changing that but no
   consensus.
  
  Yes, it works in the editor. I was referring to the simulated
  interpreter. I guess I didn't make that clear.
  
  In my search for a solution, I did see some of the traffic regarding
  the tracker issue, but the posts were all several years old and I
  was hoping maybe there was a fix by now. I guess not. Maybe in
  Python 4, eh?
  
  Thanks.
  
  Alex
  
 
 For the record issue 7676, yes?

Yes, that appears to be the issue I was talking about and is, in fact,
one of the threads I had looked at before posting here. Of course, I
didn't pay enough attention to the dates. I see the most recent posting
on the issue appears to have been made in January of this year, so I
should have realized it's an ongoing issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Filter versus comprehension (was Re: something about split()???)

2012-08-25 Thread Tim Golden

On 25/08/2012 13:57, David Robinow wrote:

On Fri, Aug 24, 2012 at 3:03 PM, Walter Hurry walterhu...@lavabit.com wrote:

On Fri, 24 Aug 2012 14:29:00 -0400, Dennis Lee Bieber wrote:


It appears to be a change Google made in the last month or two... My
hypothesis is that they are replacing hard EOL found in inbound NNTP
with an HTML p, and then on outgoing replacing the p with a pair of
NNTP line endings. In contrast, text composed on Google is coming in as
long single lines (since quoting said text in a response produces on a
 at the start of the paragraph.


Google Groups sucks. These are computer literate people here. Why don't
they just use a proper newsreader?

I haven't used a newsreader in over a decade. I'm quite happy with a
mailing list. Am I missing something?


Not really. I'm the same; it just means you can skip over the occasional 
ggroups-newsreader discussion threads which pop up

about 3 times a year on average.

:)

TJG

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread wxjmfauth
Le samedi 25 août 2012 11:46:34 UTC+2, Frank Millman a écrit :
 On 25/08/2012 10:58, Mark Lawrence wrote:
 
  On 25/08/2012 08:27, wxjmfa...@gmail.com wrote:
 
 
 
  Unicode design: a flat table of code points, where all code
 
  points are equals.
 
  As soon as one attempts to escape from this rule, one has to
 
  pay for it.
 
  The creator of this machinery (flexible string representation)
 
  can not even benefit from it in his native language (I think
 
  I'm correctly informed).
 
 
 
  Hint: Google - Das grosse Eszett
 
 
 
  jmf
 
 
 
 
 
  It's Saturday morning, I'm stone cold sober, had a good sleep and I'm
 
  still baffled as to the point if any.  Could someone please enlightem me?
 
 
 
 
 
 Here's what I think he is saying. I am posting this to test the water. I 
 
 am also confused, and if I have got it wrong hopefully someone will 
 
 correct me.
 
 
 
 In python 3.3, unicode strings are now stored as follows -
 
if all characters can be represented by 1 byte, the entire string is 
 
 composed of 1-byte characters
 
else if all characters can be represented by 1 or 2 bytea, the entire 
 
 string is composed of 2-byte characters
 
else the entire string is composed of 4-byte characters
 
 
 
 There is an overhead in making this choice, to detect the lowest number 
 
 of bytes required.
 
 
 
 jmfauth believes that this only benefits 'english-speaking' users, as 
 
 the rest of the world will tend to have strings where at least one 
 
 character requires 2 or 4 bytes. So they incur the overhead, without 
 
 getting any benefit.
 
 
 
 Therefore, I think he is saying that he would have preferred that python 
 
 standardise on 4-byte characters, on the grounds that the saving in 
 
 memory does not justify the performance overhead.
 
 
 
 Frank Millman

Very well explained. Thanks.

More precisely, affected are not only the 'english-speaking'
users, but all the users who are using not latin-1 characters.
(See the title of this topic, ... typography).

Being at the same time, latin-1 and unicode compliant is
a plain absurdity in the mathematical sense.

---

For those you do not know, the go language has introduced
the rune type. As far as I know, nobody is complaining, I
have not even seen a discussion related to this subject.


100% Unicode compliant from the day 0. Congratulations.

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


Re: Publish unittest results from test discovery

2012-08-25 Thread Peter Otten
Lucretiel wrote:

 So I've started using unittest, and I love it. I use testdiscovery (python
 -m unittest discover) so that I can distribute my tests and don't have to
 manage them all manually. I wanted to start publishing my test results to
 xml, though. I found xmlrunner by googling around, but it requires me to
 add an if __name__ == '__main__' block to my code, which isn't executed by
 unittest discover. Is there a way to get unittest disover to work with
 xmlrunner, or to some other way to solve this without restructuring all my
 test code?

I don't see where you could specify a test runner on the commandline, but 
you can reuse the discovery code in your own scripts. For the following 
example I basically copied unittest.__main__.py:

$ cat discover.py 
#!/usr/bin/env python
import xmlrunner

__unittest = True

from unittest.main import main, TestProgram, USAGE_AS_MAIN
TestProgram.USAGE = USAGE_AS_MAIN

main(module=None, testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
$ cat test_alpha.py 
import unittest

class T(unittest.TestCase):
def test_alpha(self):
pass
def test_beta(self):
self.assertEquals([a, b, c], [a, B, c])
$ ./discover.py discover

Running tests...
--
.F
==
FAIL [0.001s]: test_beta (test_alpha.T)
--
Traceback (most recent call last):
  File /somewhere/over/the/rainbow/discover/test_alpha.py, line 7, in 
test_beta
self.assertEquals([a, b, c], [a, B, c])
AssertionError: Lists differ: ['a', 'b', 'c'] != ['a', 'B', 'c']

First differing element 1:
b
B

- ['a', 'b', 'c']
?^

+ ['a', 'B', 'c']
?^


--
Ran 2 tests in 0.002s

FAILED (failures=1)

Generating XML reports...
$ ls
discover.py  test_alpha.py  test_alpha.pyc  test-reports
$ ls test-reports/
TEST-test_alpha.T.xml
$ 


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


Probability Algorithm

2012-08-25 Thread 月忧茗
Hi,  All,

I have a  problem of probability algorithm


The goal is obtain a list which contains three items.   as the *FinalList*

There has Four source lists. *
ALIST, BLIST, CLIST, DLIST

There are all  Unknown length. They contains unique elements*
( In fact,  there are all empty at the program beginning,  when running,
there growing  )

Choose items form this source lists. pick up random items to generate the
FinalList
Ensure  The Following Requirements

In the FinalList,
probability of ALIST's item appeared  is  43%
probability of BLIST's item appeared  is  37%
probability of CLIST's item appeared  is  19%
probability of DLIST's item appeared  is  1%




I have written some code, but this just for  the four lists are have a lots
of elements.



from random import choice

final_list = []
slot = []

a_picked_times = 0

while a_picked_times  43:
item = choice(ALIST)
ALIST.remove(item)

if item in already_picked_list:
continue

slot.append(item)
a_picked_times += 1


b_picked_times = 0

while_b_picked_times  37:
...

SOME CODE SIMILAR

# now slot is a list which contains 100 elements,
# in slot, there are 43 elements of ALIST'items, 37 of B, 19 of C, 1 of D

for i in range(3):
final_list.append( choice(slot) )



So, this can ensure the probability requirements.  *BUT only under the
condition: this Four lists have a lots of elements.
*
list.remove( item )  that will not remove all elements in list,  so  we
will correct pick up items with the needs times.

But,  when A, B, C, D empty OR  not enough elements,  How could ensure the
probability requirements?



A, B, C, D list are all get from redis sorted list.   Or some solution with
redis ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Probability Algorithm

2012-08-25 Thread Dave Angel
On 08/25/2012 12:03 PM, 月忧茗 wrote:
 Hi,  All,

 I have a  problem of probability algorithm


 The goal is obtain a list which contains three items.   as the *FinalList*

 There has Four source lists. *
 ALIST, BLIST, CLIST, DLIST

 There are all  Unknown length. They contains unique elements*
 ( In fact,  there are all empty at the program beginning,  when running,
 there growing  )

 Choose items form this source lists. pick up random items to generate the
 FinalList
 Ensure  The Following Requirements

 In the FinalList,
 probability of ALIST's item appeared  is  43%
 probability of BLIST's item appeared  is  37%
 probability of CLIST's item appeared  is  19%
 probability of DLIST's item appeared  is  1%



Would you like to tell us the actual assignment?  This looks like it's
paraphrased.  if you have 3 items, each coming from one of four lists,
the four probabilities have to add up to much more than 100%.

Perhaps what you meant was that each of the three items had those
probabilities of coming from the respective lists.  Then it'd add up to
100%.

Your code is far more complex than needed, and as you observed, doesn't
work if each list doesn't have sufficient members.

I'd simply pick a random number from 0 to 99, see if it's less than 43
and if so, use ALIST.  Else if it's less than 80, use BLIST.  else if
it's less than 99, use CLIST.  Else DLIST.

Then do that 2 more times and you're done.

Don't forget to factor the problem into functions, so you can easily
repeat similar code.

If a list is picked, and it's empty, throw an exception.  Or wait till
the missing item arrives.  And you have to decide  whether to remove the
selected items from the respective lists.  That wasn't specified in the
problem statement.



-- 

DaveA

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


Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Terry Reedy

On 8/25/2012 10:17 AM, Alex wrote:


Yes, that appears to be the issue I was talking about and is, in fact,
one of the threads I had looked at before posting here. Of course, I
didn't pay enough attention to the dates. I see the most recent posting
on the issue appears to have been made in January of this year, so I
should have realized it's an ongoing issue.


There have also been a few posts this year on the idle-sig mail list.

There are only a few people working on IDLE and we have concentrated 
this calendar year on fixing crashers, not semi-aesthetic issues.


--
Terry Jan Reedy

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


issue with struct.unpack

2012-08-25 Thread 9bizy
I am trying to unpack values from sensor data I am retrieving through a serial 
cable, but I get errors while using struct.unpack, how can I use struct.unpack 
to unload the data in a readable format?

I checked the python documentation for struct and I can seen to find any 
argument for this.

I have data = struct.unpack('char',data) but I still get errors
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: issue with struct.unpack

2012-08-25 Thread Mark Lawrence

On 25/08/2012 19:34, 9bizy wrote:

I am trying to unpack values from sensor data I am retrieving through a serial 
cable, but I get errors while using struct.unpack, how can I use struct.unpack 
to unload the data in a readable format?

I checked the python documentation for struct and I can seen to find any 
argument for this.

I have data = struct.unpack('char',data) but I still get errors



We have two options here.  Either

a) People reading your original request go on a mind reading course or 
similar in an attempt to find out what the errors are, though I'm 
confused as to how you get errors from one line of code.


Or

b) Provide the smallest sample of code that allows the problem to be 
reproduced together with the complete traceback so we can see exactly 
what happened.


--
Cheers.

Mark Lawrence.

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


Re: issue with struct.unpack

2012-08-25 Thread MRAB

On 25/08/2012 19:34, 9bizy wrote:

I am trying to unpack values from sensor data I am retrieving through
a serial cable, but I get errors while using struct.unpack, how can I
use struct.unpack to unload the data in a readable format?

I checked the python documentation for struct and I can seen to find
any argument for this.

I have data = struct.unpack('char',data) but I still get errors


The format strings are described here for Python 3:

http://docs.python.org/3.2/library/struct.html

and here for Python 2:

http://docs.python.org/2.7/library/struct.html
--
http://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.3.0 release candidate 1

2012-08-25 Thread Georg Brandl

On behalf of the Python development team, I'm delighted to announce the
first release candidate of Python 3.3.0.

This is a preview release, and its use is not recommended in
production settings.

Python 3.3 includes a range of improvements of the 3.x series, as well
as easier porting between 2.x and 3.x.  Major new features and changes
in the 3.3 release series are:

* PEP 380, syntax for delegating to a subgenerator (yield from)
* PEP 393, flexible string representation (doing away with the
   distinction between wide and narrow Unicode builds)
* A C implementation of the decimal module, with up to 80x speedup
   for decimal-heavy applications
* The import system (__import__) now based on importlib by default
* The new lzma module with LZMA/XZ support
* PEP 397, a Python launcher for Windows
* PEP 405, virtual environment support in core
* PEP 420, namespace package support
* PEP 3151, reworking the OS and IO exception hierarchy
* PEP 3155, qualified name for classes and functions
* PEP 409, suppressing exception context
* PEP 414, explicit Unicode literals to help with porting
* PEP 418, extended platform-independent clocks in the time module
* PEP 412, a new key-sharing dictionary implementation that
   significantly saves memory for object-oriented code
* PEP 362, the function-signature object
* The new faulthandler module that helps diagnosing crashes
* The new unittest.mock module
* The new ipaddress module
* The sys.implementation attribute
* A policy framework for the email package, with a provisional (see
   PEP 411) policy that adds much improved unicode support for email
   header parsing
* A collections.ChainMap class for linking mappings to a single unit
* Wrappers for many more POSIX functions in the os and signal
   modules, as well as other useful functions such as sendfile()
* Hash randomization, introduced in earlier bugfix releases, is now
   switched on by default

In total, almost 500 API items are new or improved in Python 3.3.
For a more extensive list of changes in 3.3.0, see

 http://docs.python.org/3.3/whatsnew/3.3.html

To download Python 3.3.0 visit:

 http://www.python.org/download/releases/3.3.0/

Please consider trying Python 3.3.0 with your code and reporting any bugs
you may notice to:

 http://bugs.python.org/


Enjoy!

--
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.3's contributors)
--
http://mail.python.org/mailman/listinfo/python-list


modeling complex data with sqlalchemy

2012-08-25 Thread Littlefield, Tyler

Hello all:
I had a quick question.
In my game, I have an is-a setup, where all objects contain data like an 
id for sqlalchemy, a name, a description and a list of contents.
In order to add functionality to an object, you add components. So for 
example, a player would have the Player and Living component associated 
with the basic object. It's sort of a way to give myself a way to add 
functionality without having a lot of multiple inheritance.
This creates a problem for me though, since it looks like each component 
would have it's own table. How would you go about modeling the 1:n 
relationship between entity and each component?
Also, I'm going to have a location property on the object, which is 
basically it's location (a reference to another Entity), or None if it 
has no parent. How would you set that up in SA so that location gets 
translated to an ID and then translated back to the required object?
Might there be another easier way to model all this data? It looks like 
this database could get rather large, extremely quickly.


--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

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


Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Ian Kelly
On Sat, Aug 25, 2012 at 9:47 AM,  wxjmfa...@gmail.com wrote:
 For those you do not know, the go language has introduced
 the rune type. As far as I know, nobody is complaining, I
 have not even seen a discussion related to this subject.

Python has that also.  We call it int.

More seriously, strings in Go are not sequences of runes.  They're
actually arrays of UTF-8 bytes.  That means that they're quite
efficient for ASCII strings, at the expense of other characters, like
Chinese (wait, this sounds familiar for some reason).  It also means
that you have to bend over backwards if you want to work with actual
runes instead of bytes.  Want to know how many characters are in your
string?  Don't call len() on it -- that will only tell you how many
bytes are in it.  Don't try to index or slice it either -- that will
(accidentally) work for ASCII strings, but for other strings your
indexes will be wrong.  If you're unlucky you might even split up the
string in the middle of a character, and now your string has invalid
characters in it.  The right way to do it looks something like this:

len([]rune(白鵬翔))  // get the length of the string in characters
string([]rune(白鵬翔)[0:2])  // get the substring containing the first
two characters

It reminds me of working in Python 2.X, except that instead of an
actual unicode type you just have arrays of ints.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sun, Aug 26, 2012 at 5:56 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 On Sat, 25 Aug 2012 09:55:27 +0100, Mark Lawrence
 breamore...@yahoo.co.uk declaimed the following in
 gmane.comp.python.general:


 I'm just wondering out aloud if the number of times this type of thread
 has been debated here will fit into a Python long or float?

 Well, since I don't think one can have a fractional debate (maybe if
 someone starts a thread and NOBODY ever follows up on it), then float's
 don't gain us anything there.

 Presuming a double-precision float, we would have 14-15 significant
 digits for the mantissa -- so anything greater than
 (9)99,999,999,999,999 will have lost accuracy. In contrast Python longs
 have effectively unlimited significant digits.

I wonder if some people are applying an alternative form of duck
typing - if it quacks like a should Python have variables debate, it
gets silenced with that universal grey tape...

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


Re: ONLINE SERVER TO STORE AND RUN PYTHON SCRIPTS

2012-08-25 Thread coldfire
On Friday, 17 August 2012 18:16:08 UTC+5:30, coldfire  wrote:
 I would like to know that where can a python script be stored on-line from 
 were it keep running and can be called any time when required using internet.
 
 I have used mechanize module which creates a webbroswer instance to open a 
 website and extract data and email me.
 
 I have tried Python anywhere but they dont support opening of anonymous 
 websites.
 
 What s the current what to DO this?
 
 Can someone point me in the write direction.
 
 My script have no interaction with User It just Got on-line searches for 
 something and emails me.
 
 
 
 Thanks

I got most of it. I will really appreciate is someone out the address of any of 
the following for use with python 
1Webhost
2Shell Account
3VPS
I am really new to all this Got web server and shell account but unable to 
figure out how to use it or deploy the Code,
My problem is that I m using lot of third party Library which are mostly not 
supported or I don't know How to make it RUN over Internet 


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


Computing win/loss records in Python

2012-08-25 Thread Christopher McComas
Greetings,

I have code that I run via Django that grabs the results from various sports 
from formatted text files. The script iterates over every line in the formatted 
text files, finds the team in the Postgres database updates their w/l record 
depending on the outcome on that line, saves the team's row in the db, and then 
moves on to the next line in the file. 

I'm trying to get away from Django for this project, I want to run the files, 
get the W/L results and output a formatted text file with the teams and their 
W/L records. What's confusing me I guess how to store the data/results as the 
wins and losses tally up. We're talking hundreds of teams, thousands of games, 
but a quick example would be:

Marshall
Ohio State
Kentucky
Indiana

Marshall,24,Ohio State,48,
Kentucky,14,Indiana,10,
Marshall,10,Indiana,7,
Ohio State,28,Kentucky,10

That's just a quick example, I can handle seperating the data in the lines, 
figuring it all out, I just am unsure of how to keep a running total of a 
team's record. I would do for line in file: then on the first line I see that 
Marshall lost so they would have 1, Ohio State won so they'd have 1 win. It'd 
go to the next line Kentucky 1 win, Indiana 1 loss, then on the 3rd line, 
Marshall got a win so they'd have 1 win, but it would have to remember that 
loss from line 1...

Does this make sense?

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


Re: Computing win/loss records in Python

2012-08-25 Thread Rodrick Brown
On Aug 25, 2012, at 10:22 PM, Christopher McComas
mccomas.ch...@gmail.com wrote:

 Greetings,

 I have code that I run via Django that grabs the results from various sports 
 from formatted text files. The script iterates over every line in the 
 formatted text files, finds the team in the Postgres database updates their 
 w/l record depending on the outcome on that line, saves the team's row in the 
 db, and then moves on to the next line in the file.

 I'm trying to get away from Django for this project, I want to run the files, 
 get the W/L results and output a formatted text file with the teams and their 
 W/L records. What's confusing me I guess how to store the data/results as the 
 wins and losses tally up. We're talking hundreds of teams, thousands of 
 games, but a quick example would be:

 Marshall
 Ohio State
 Kentucky
 Indiana

 Marshall,24,Ohio State,48,
 Kentucky,14,Indiana,10,
 Marshall,10,Indiana,7,
 Ohio State,28,Kentucky,10

 That's just a quick example, I can handle seperating the data in the lines, 
 figuring it all out, I just am unsure of how to keep a running total of a 
 team's record. I would do for line in file: then on the first line I see 
 that Marshall lost so they would have 1, Ohio State won so they'd have 1 win. 
 It'd go to the next line Kentucky 1 win, Indiana 1 loss, then on the 3rd 
 line, Marshall got a win so they'd have 1 win, but it would have to remember 
 that loss from line 1...

 Does this make sense?

Yes, use a RDBMS, SQLite may be the best fit for your use case its
quick and has low overhead.



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


Re: Computing win/loss records in Python

2012-08-25 Thread Steven W. Orr

On 8/25/2012 10:20 PM, Christopher McComas wrote:

Greetings,

I have code that I run via Django that grabs the results from various sports 
from formatted text files. The script iterates over every line in the formatted 
text files, finds the team in the Postgres database updates their w/l record 
depending on the outcome on that line, saves the team's row in the db, and then 
moves on to the next line in the file.

I'm trying to get away from Django for this project, I want to run the files, 
get the W/L results and output a formatted text file with the teams and their 
W/L records. What's confusing me I guess how to store the data/results as the 
wins and losses tally up. We're talking hundreds of teams, thousands of games, 
but a quick example would be:

Marshall
Ohio State
Kentucky
Indiana

Marshall,24,Ohio State,48,
Kentucky,14,Indiana,10,
Marshall,10,Indiana,7,
Ohio State,28,Kentucky,10

That's just a quick example, I can handle seperating the data in the lines, figuring it 
all out, I just am unsure of how to keep a running total of a team's record. I would do 
for line in file: then on the first line I see that Marshall lost so they 
would have 1, Ohio State won so they'd have 1 win. It'd go to the next line Kentucky 1 
win, Indiana 1 loss, then on the 3rd line, Marshall got a win so they'd have 1 win, but 
it would have to remember that loss from line 1...

Does this make sense?

Thanks,


win_count = defaultdict(int)
loss_count = defaultdict(int)

items = line.split(',')
if items[1]  items[3]:
windex = 0
lossdex = 2
else:
windex = 2
lossdex = 0
win_count[windex] += 1
loss_count[lossdex] += 1

Zat help?


--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Computing win/loss records in Python

2012-08-25 Thread Steven D'Aprano
On Sat, 25 Aug 2012 22:42:59 -0400, Steven W. Orr wrote:

 win_count = defaultdict(int)
 loss_count = defaultdict(int)

When I try that, I get NameError: name 'defaultdict' is not defined.

I think it is rather unfair on beginners to show them code that almost, 
but not quite, works, and expect them to somehow work out what this 
mysterious defaultdict is.

The answer is probably to do this first:

from collections import defaultdict


 items = line.split(',')
 if items[1]  items[3]:
  windex = 0
  lossdex = 2

That's not going to work, because you are doing string comparisons 
instead of numeric comparisons. Consider:

Kentucky,6,Indiana,59

'6'  '59' and you will wrongly count that as a win to Kentucky.


 else:
  windex = 2
  lossdex = 0
 win_count[windex] += 1
 loss_count[lossdex] += 1

And that certainly won't work, because all you are doing is counting how 
many times the first team beats the second, instead of counting how many 
times each team wins.


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


Re: Computing win/loss records in Python

2012-08-25 Thread Steven D'Aprano
On Sat, 25 Aug 2012 22:20:05 -0400, Christopher McComas wrote:

 Marshall,24,Ohio State,48,
 Kentucky,14,Indiana,10,
 Marshall,10,Indiana,7,
 Ohio State,28,Kentucky,10
 
 That's just a quick example, I can handle seperating the data in the
 lines, figuring it all out, I just am unsure of how to keep a running
 total of a team's record. I would do for line in file: then on the
 first line I see that Marshall lost so they would have 1, Ohio State won
 so they'd have 1 win. It'd go to the next line Kentucky 1 win, Indiana 1
 loss, then on the 3rd line, Marshall got a win so they'd have 1 win, but
 it would have to remember that loss from line 1...

There are many ways to do this. Here's one: we keep three sets of data, 
wins, losses and ties.

wins = {}
losses = {}
ties = {}
for line in open(datafile.txt):
line = line.strip()  # get rid of leading and trailing whitespace
line = line.rstrip(',')  # and any trailing comma
teamA, scoreA, teamB, scoreB = line.split(',')  # split on commas
teamA = teamA.strip().title()  # normalise the case
teamB = teamB.strip().title()
scoreA = int(scoreA)
scoreB = int(scoreB)
if scoreA == scoreB:
# Handle a draw.
ties[teamA] = ties.get(teamA, 0) + 1
ties[teamB] = ties.get(teamB, 0) + 1
else:
if scoreA  scoreB:
winner = teamA
loser = teamB
else:
winner = teamB
loser = teamA
wins[winner] = wins.get(winner, 0) + 1
losses[loser] = losses.get(loser, 0) + 1


Once you've done that, you can check the win/loss score of any team:

name = 'Marshall'
w = wins.get(name, 0)
l = losses.get(name, 0)
d = ties.get(name, 0)
total = w+l+d
print(
  Team %s played %d games, won %d, lost %d and tied %d.
  % (name, total, w, l, d)
  )


If you want to store these results permanently, you need to write them 
out to file. You can roll your own, but a simpler way might be to use one 
of the pickle, json, csv or plistlib modules to do it.


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


Re: Probability Algorithm

2012-08-25 Thread 月忧茗
Sorry,   missing some conditions

*already_picked_list*   is get from db.

  Why keep a counter? Rather than an iterated loop

so ,  if use a iterated loop:

for i in range(43):
item = choice( ALIST )
ALIST.remove( item )

if item in already_picked_list:
continue

slot.append( item )


For example, if  we picked item from ALIST 43 times, but all picked items
are in already_picked_list
What's the slot?   It's a empty list,  not contains item from ALIST.

*This is wrong*



 Do you really want to remove an item from the source list?

*Yes*,   i*tems in slot must be unique*

( This is also a condition, which  I have missing... )

 and if you don't want duplicates from within a source list, you should
remove them when building the source list
*
As I mentioned , The source list are all unique elements*



Your last code.
if B ,C ,D are all empty,  result's elements are all from A,  A's
probability is 100% ?

I Know ,  this problem should treated as two situation:

If the four list has not enough elements,   There are no way to ensure the
probability requirements.
If they has enough elements,  Your solution is a good way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Probability Algorithm

2012-08-25 Thread Steven D'Aprano
On 08/25/2012 12:03 PM, 月忧茗 wrote:

 In the FinalList,
 probability of ALIST's item appeared  is  43% probability of BLIST's
 item appeared  is  37% probability of CLIST's item appeared  is  19%
 probability of DLIST's item appeared  is  1%

First, select one of the four lists with those appropriate probabilities. 
Then once you selected a list, select one of its items randomly.

import random

def select_list():
x = random.randint(1, 100)
if x = 43:
return ALIST
elif x = 80:  # 43 + 37
return BLIST
elif x = 99:  # + 19
return CLIST
else:
return DLIST

the_list = select_list()
the_item = random.choice(the_list)



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


Re: Computing win/loss records in Python

2012-08-25 Thread Ben Finney
Christopher McComas mccomas.ch...@gmail.com writes:

 I have code that I run via Django that grabs the results from various
 sports from formatted text files. The script iterates over every line
 in the formatted text files, finds the team in the Postgres database
 updates their w/l record depending on the outcome on that line, saves
 the team's row in the db, and then moves on to the next line in the
 file.

It seems that you already have a PostgreSQL database storing this data.

 I'm trying to get away from Django for this project

That existing database can be accessed without Django. You could talk
directly using the ‘psycopg2’ library, but you don't have to go that
far.

I would recommend you use SQLAlchemy as a good and flexible way to
access existing databases (or make new ones) in a Pythonic manner
URL:http://www.sqlalchemy.org/. If you are using a free-software
operating system, you will likely already have packages available to
install SQLAlchemy from your operating system's package repositories.

-- 
 \ “True greatness is measured by how much freedom you give to |
  `\  others, not by how much you can coerce others to do what you |
_o__)   want.” —Larry Wall |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Probability Algorithm

2012-08-25 Thread 月忧茗
Thanks for helps


This code almost meets my needs .
But not accurate probability when not enough source elements.

So I give up the not enough elements situation.
For source list is growing fast,  the bast situation just appear in the
program starting



2012/8/26 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info

 On 08/25/2012 12:03 PM, 月忧茗 wrote:

  In the FinalList,
  probability of ALIST's item appeared  is  43% probability of BLIST's
  item appeared  is  37% probability of CLIST's item appeared  is  19%
  probability of DLIST's item appeared  is  1%

 First, select one of the four lists with those appropriate probabilities.
 Then once you selected a list, select one of its items randomly.

 import random

 def select_list():
 x = random.randint(1, 100)
 if x = 43:
 return ALIST
 elif x = 80:  # 43 + 37
 return BLIST
 elif x = 99:  # + 19
 return CLIST
 else:
 return DLIST

 the_list = select_list()
 the_item = random.choice(the_list)



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

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


Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll

On 08/24/2012 10:04 PM, Steven D'Aprano wrote:

The fact that the end result is the same is hardly surprising -- Python's
VM is built on top of C pointer indirection, so of course you can start
with pointers and end up with Python semantics. But the practice of
coding are very different:

* in C, I care about identifiers (names) in order to explicitly manage
addresses and pointers as a means to reach the data I actually care about;

* in Python, I care about identifiers in order to reach the data I
actually care about.

So I find this comment very interesting. It makes me wonder if the root 
cause of our (pretty minor) disagreement is in some sense related to our 
mental models of *C* variables. I'm actually not much of a C programmer 
specifically, but I do a lot of C++ stuff. Of those two descriptions, 
I'd actually say that the Python description sounds more like how I 
think about variables in C++ most of the time.


Obviously there are differences between value and reference semantics 
between the two languages, but thinking about some variable being 
located at some address in memory is something that I actually do pretty 
rarely; I basically think of variables as naming data, and addresses 
mostly come into play when thinking about points-to and aliasing 
information at a more abstract level, much the same as I do in Python.


Evan

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


Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll

On 08/24/2012 05:00 AM, Steven D'Aprano wrote:

No. The compiler remembers the address of 'a' by keeping notes about it
somewhere in memory during the compilation process. When you run the
compiled program, there is no longer any reference to the name 'a'.

...

The mapping of name:address is part of the *compilation* process -- the
compiler knows that variable 'x' corresponds to location 12345678, but
the compiled code has no concept of anything called 'x'. It only knows
about locations. The source code 'x = 42' is compiled into something like
'store 42 into location 12345678'. (Locations may be absolute or
relative.)

In languages with name bindings, the compiler doesn't need to track
name:address pairs. The compiled application knows about names, but not
about addresses. The source code 'x = 42' is compiled into something like
'store 42 into the namespace using key x'.
What you describe is sorta correct, but it's also not... you're 
describing implementations rather than the language. And while the 
language semantics certainly impose restrictions on the implementation, 
I think in this case the situation is closer than you acknowledge:



From the Python side, I suspect that for most functions, you'd be able 
to create a Python implementation that behaves more like C, and 
allocates locals in a more traditional fashion. I don't know much about 
it, but I'd guess that PyPy already does something along this line; 
someone also mentioned that Cython (admittedly not a full-blown Python 
implementation, but close for the purpose of this question) tries to do 
the same thing.



On the C side, imagine a function with locals x, y, and z which never 
takes the address of any of them. (You said later that Just because the 
public interface of the language doesn't give you any way to view the 
fixed locations of variables, doesn't mean that variables cease to have 
fixed locations.)


First, C variables may not even have a memory address. They can 
disappear completely during compilation, or live in a register for their 
entire life.


Second, it's possible that those variables *don't* occupy a fixed 
location. If you never explicitly take an address of a variable (x), 
then I can't think of any way that the address can be observed without 
invoking undefined behavior -- and this means the C compiler is free to 
transform it to anything that is equivalent under the C semantics. In 
particular, it can split uses of a variable into multiple ones if there 
are disjoint live ranges. For instance, in:

x = 5
print x
x = 10
print x
there are two live ranges of x, one consisting of lines 1 and 2, and one 
consisting of lines 3 and 4. These live ranges could have been different 
variables; I could just of easily have written

x = 5
print x
y = 10
print y
and these pieces of code are observationally equivalent, so the compiler 
is allowed to generate the same code for both. In particular, it could 
either compile the second example to share the same memory address for x 
and y (meaning that a memory address isn't uniquely named by a single 
variable) or it could compile the first to put the two live ranges of x 
into different memory addresses (meaning that a variable doesn't 
uniquely name a memory address). In fact, I'd *expect* an optimizing 
compiler to share memory for x and y, and I'd also expect to be able to 
concoct an example where different live ranges of one variable wind up 
at different addresses. (The latter I'm less sure of though, and I also 
expect it'd be a little hard, as you'd have to come up with an example 
where even at the high optimization levels you'd need to see that, both 
live ranges would wind up in memory.)


Third, and more wackily, you could technically create a C implementation 
that works like Python, where it stores variables (whose addresses 
aren't taken) in a dict keyed by name, and generates code that on a 
variable access looks up the value by accessing that dict using the name 
of the variable.


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


[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread STINNER Victor

STINNER Victor added the comment:

Even if I would prefer to see a fully working new implementation of the
buffer interface, I agree with Georg: it's too late for such huge change in
Python 3.3. Can' we wait Python 3.4 to change the equality operator?

It also took me three major releases to fix all Unicode issues (and it's
probably not finished :-)).
Le 24 août 2012 23:05, Georg Brandl rep...@bugs.python.org a écrit :


 Georg Brandl added the comment:

 I'm not very keen to hold up the release for long times again, especially
 for a patch of this size and lots of potential breakage.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue15573
 ___


--

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

The effect of the change is pretty minimal though: Previously
not equal was returned for unknown formats, now the struct
module figures it out.

memoryobject.c has 100% coverage except for a couple of lines
that are either impossible to reach or very hard to reach.

The new code is among the most heavily exercised lines, since
in test_buffer.py the verify() function always asserts equality.


You can look at the attached memoryobject.c.gcov: *All* failure paths
are taken since Python API functions are wrapped in macros that
set PyExc_FailAPIError and return failure at predefined points
the test suite.

--
Added file: http://bugs.python.org/file26992/memoryobject.c.gcov

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

With Stefan's major improvements to the test suite for 3.3, the risk is low and 
I *really* don't want to spend the life of the 3.3 series excusing the current 
comparison behaviour.

By contrast, explaining the shift in definition as moving from raw memory 
comparisons to by value comparisons is relatively easy.

--

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Georg Brandl

Georg Brandl added the comment:

Well, I'm not against you committing it as long as you commit it *right now*.  
I'm about to cut the tag.

--

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

 You can look at the attached memoryobject.c.gcov: *All* failure paths
 are taken since Python API functions are wrapped in macros that
 set PyExc_FailAPIError and return failure at predefined points
 the test suite.

That should read: With a patch that wraps Python API functions ...

Obviously the macros aren't in by default.

--

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

Great, give me 20 minutes or so.

--

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

I'm currently on IRC and double checking the patch locally.

--

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Stefan, was there something specific you wanted to do before committing? 
Otherwise I can commit it as soon as this full test run finishes.

--

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



[issue7475] codecs missing: base64 bz2 hex zlib hex_codec ...

2012-08-25 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
priority: release blocker - high

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset afa3dedfee18 by Nick Coghlan in branch 'default':
Close #15573: use value-based memoryview comparisons (patch by Stefan Krah)
http://hg.python.org/cpython/rev/afa3dedfee18

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue15573] Support unknown formats in memoryview comparisons

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

Except for Misc/NEWS the patch can be committed unchanged. Please
go ahead!

[The remaining doc changes are tracked elsewhere.]

--

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



[issue15781] test_threaded_import fails on Windows

2012-08-25 Thread Stefan Krah

New submission from Stefan Krah:

test_parallel_module_init() fails on Windows-64:

http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/553/steps/test/logs/stdio

==
FAIL: test_parallel_module_init (test.test_threaded_import.ThreadedImportTests)
--
Traceback (most recent call last):
  File 
C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_threaded_import.py,
 line 125, in test_parallel_module_init
self.check_parallel_module_init()
  File 
C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_threaded_import.py,
 line 120, in check_parallel_module_init
self.assertFalse(errors)
AssertionError: [AttributeError('module' object has no attribute 
'randrange',)] is not false

--

--
components: Tests
messages: 169116
nosy: brett.cannon, haypo, jkloth, pitrou, skrah
priority: normal
severity: normal
status: open
title: test_threaded_import fails on Windows
type: behavior
versions: Python 3.3, Python 3.4

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



[issue13370] test_ctypes fails when building python with clang

2012-08-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Duh... 

3.3 without patch fails when I leave out '--with-pydebug'. I'm now running  the 
testsuite for 2.7 and 3.2 with patch and will commit once those are ready, 
which should be within an hour from now.

--

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



[issue15756] subprocess.poll() does not handle errno.ECHILD No child processes

2012-08-25 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
nosy: +tshepang

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



[issue15781] test_threaded_import fails on Windows

2012-08-25 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
nosy: +ncoghlan

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

The buildbot in question uses -j4, and I can reproduce this on Linux
with:

./python -m test -uall -F -j4 -v test_threaded_import


==
FAIL: test_parallel_meta_path (test.test_threaded_import.ThreadedImportTests)
--
Traceback (most recent call last):
  File /home/stefan/hg/cpython/Lib/test/test_threaded_import.py, line 131, in 
test_parallel_meta_path
self.check_parallel_module_init()
  File /home/stefan/hg/cpython/Lib/test/test_threaded_import.py, line 120, in 
check_parallel_module_init
self.assertFalse(errors)
AssertionError: [AttributeError('module' object has no attribute 
'randrange',), AttributeError('module' object has no attribute 
'randrange',)] is not false

--
Ran 6 tests in 4.221s

--
title: test_threaded_import fails on Windows - test_threaded_import fails with 
-j4

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



[issue13518] configparser can’t read file objects from urlopen

2012-08-25 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
resolution:  - invalid
status: open - closed

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



[issue15765] test_getcwd_long_pathnames (in test_posix) kills NetBSD

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

I completely forgot about that issue. The patch looks good to me.

--

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



[issue13370] test_ctypes fails when building python with clang

2012-08-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 58a87c02692c by Ronald Oussoren in branch '2.7':
Fix issue 13370: Ensure that ctypes works on Mac OS X when Python is compiled 
using the clang compiler
http://hg.python.org/cpython/rev/58a87c02692c

New changeset a425f2697273 by Ronald Oussoren in branch '3.2':
Fix issue 13370: Ensure that ctypes works on Mac OS X when Python is compiled 
using the clang compiler
http://hg.python.org/cpython/rev/a425f2697273

New changeset bed8dd30309d by Ronald Oussoren in branch 'default':
Fix issue 13370: Ensure that ctypes works on Mac OS X when Python is
http://hg.python.org/cpython/rev/bed8dd30309d

--
nosy: +python-dev

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



[issue13370] test_ctypes fails when building python with clang

2012-08-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The issue should be gone in the upcoming 3.3rc1 release and  the next stable 
releases of 3.2 and 2.7.

--
resolution:  - fixed
status: open - pending

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

With
$ ./python -m test -uall -F -j16 -v test_threaded_import
I couldn't reproduce after 1000 test passes.

--

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



[issue15782] Compile error for a number of Mac modules with recent Xcode

2012-08-25 Thread Ronald Oussoren

New submission from Ronald Oussoren:

Recent versions of Xcode on OSX 10.7 and 10.8 fail to compile 3 of the 
extension modules in Mac/Modules: the modules for fm, qd and qdoffs.

That's because those extensions wrap APIs that are long deprecated and are no 
longer present.

The attached patch fixes the miscompilation by making most of the body of the 
extension empty when compiling with the 10.7 (or later) SDK.

This changes the API of these extension modules, but that cannot be helped 
because the platform APIs that are wrapped by these extensions are no longer 
present.

(Patch is not relevant for python 3.x because these extensions have been 
removed in python 3.0)

--
assignee: ronaldoussoren
components: Build, Macintosh
files: miscompile-mac-modules.txt
keywords: needs review
messages: 169123
nosy: ned.deily, ronaldoussoren
priority: normal
severity: normal
stage: patch review
status: open
title: Compile error for a number of Mac modules with recent Xcode
type: compile error
versions: Python 2.7
Added file: http://bugs.python.org/file26993/miscompile-mac-modules.txt

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

No joy here either - currently at 704 successful runs and counting with 
Stefan's command line.

$ uname -a
Linux lancre 3.5.1-1.fc17.x86_64 #1 SMP Thu Aug 9 17:50:43 UTC 2012 x86_64 
x86_64 x86_64 GNU/Linux

$ cat /proc/cpuinfo | grep model name
model name  : Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
model name  : Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
model name  : Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz
model name  : Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz

--

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



[issue12834] memoryview.to_bytes() and PyBuffer_ToContiguous() incorrect for non-contiguous arrays

2012-08-25 Thread Martin v . Löwis

Martin v. Löwis added the comment:

The last bugfix release of 3.2 will happen shortly after the release of 3.3, 
so in a not-too-far future (compared to the age of this issue, which just had 
its first birthday yesterday).

So if this issue should really block 3.2 (which I still think it should not), 
I'd urge possible contributors to start working on it now - especially if this 
is going to be a large patch. If such patch introduces new bugs, it won't be 
possible to ever fix them (unless they are security-critical). Also note that 
this is almost the only release blocker for the 3.2 release, next to a 
easy-to-implement request to update the expat code.

--

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



[issue12834] memoryview.to_bytes() and PyBuffer_ToContiguous() incorrect for non-contiguous arrays

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Despite my earlier comments, I'm now inclined to agree with Martin here - 
upgrading to 3.3 fixes so many other problems with memoryview, that's a more 
compelling solution.

And, of course, using NumPy instead always remains an option for more robust 
buffer API support in older versions.

--
priority: release blocker - high

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



[issue12834] memoryview.to_bytes() and PyBuffer_ToContiguous() incorrect for non-contiguous arrays

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

(Not saying this shouldn't be fixed, just saying it's not a disaster if it 
isn't)

--

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



[issue12834] memoryview.to_bytes() and PyBuffer_ToContiguous() incorrect for non-contiguous arrays

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

I agree that for 3.2 this isn't so important given that non-contiguous
arrays have multiple issues there.

Christian, does a fix for 3.2 benefit FreeImage? Don't you run into
other problems with memoryview?


If it helps, I can try to write a patch for 3.2.

--

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

I can only reproduce this on a Core i7. Native OS is Debian Wheezy,
also reproduced earlier on a FreeBSD VM hosted on that machine
(see msg167989). The machine has 4 physical cores, perhaps we
can blame hyper-threading. ;)


$ cat /proc/cpuinfo | grep model name
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz
model name  : Intel(R) Core(TM) i7 CPU 930  @ 2.80GHz



I can't reproduce it on a Core 2 Duo running Ubuntu natively.

--

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



[issue15776] Allow pyvenv to work in existing directory

2012-08-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b200acb6bed4 by Andrew Svetlov in branch 'default':
Delete Misc/NEWS record for reverted #15776.
http://hg.python.org/cpython/rev/b200acb6bed4

--

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



[issue15776] Allow pyvenv to work in existing directory

2012-08-25 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
priority: release blocker - critical
stage:  - needs patch

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



[issue15724] Add versionchanged to memoryview docs

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

This was less work than expected. I suppose docs can always go in
even after rc1 is out, so I'll wait for that.

--
keywords: +patch
Added file: http://bugs.python.org/file26994/issue15724.diff

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Up to 2279 runs without a failure here - yay for elusive hardware specific 
threading bugs :P

I'll leave it running overnight and see what happens.

--

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

I can also reproduce it on the Core 2 machine with a ridiculuously
low switch interval:


 diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -198,6 +198,8 @@
 except ImportError:
 multiprocessing = None
 
+sys.setswitchinterval(0.0001)
+
 
 # Some times __path__ and __file__ are not absolute (e.g. while running from
 # Lib/) and, if we change the CWD to run the tests in a temporary dir, some

--

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



[issue15781] test_threaded_import fails with -j4

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

Oh, and as usual, my machines have all CPUs at 100% load.

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Nick Coghlan

New submission from Nick Coghlan:

decimal.localcontext() works correctly with both the pure Python decimal module 
and the C accelerator.

decimal.localcontext(None) only works with the pure Python version. The C 
accelerator throws an exception instead of treating it as equivalent to 
omitting the argument.

--
keywords: 3.3regression
messages: 169135
nosy: ncoghlan, skrah
priority: normal
severity: normal
stage: test needed
status: open
title: decimal.localcontext(None) fails when using the C accelerator module
type: behavior
versions: Python 3.3

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Georg, a regression in the decimal API relative to 3.2 got picked up by #15136. 
Are you OK with cherrypicking a fix for this into rc2?

--
nosy: +georg.brandl

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



[issue15136] Decimal accepting Fraction

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

There is indeed a regression in decimal.localcontext with the C accelerator: 
omitting the argument entirely still works, but passing None explicitly now 
fails. I created #15783 for that.

On the topic of this thread, I'm also -1 on conversion methods, but +1 on 
string formatting support.

There's an obvious benefit in providing the latter in order to get a better 
feel for the value of a rational number by displaying a Decimal 
approximation, but questionable benefit in providing the former.

Explicit conversion is sufficiently rare that I'm OK with the idea of either 
going via a string (as used to be necessary for binary floats) or by explicitly 
casting the numerator to Decimal, then dividing by the denominator (no need to 
cast them both).

--
nosy: +ncoghlan

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

The feature is undocumented though. Is it a regression?

There are other places as well. The topic was raised in msg153447 and
msg153506, with no further comments. So I concluded that None argument
support wasn't important.

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Nick Coghlan

Nick Coghlan added the comment:

While it's undocumented in the main docs [1], help(decimal.localcontext) in 3.2 
starts with:

localcontext(ctx=None)
Return a context manager for a copy of the supplied context

We essentially have two votes in favour of it should work (the pure Python 
impl and the docstring), and two in favour of meh (the prose docs and the 
lack of a test case)

I think we should fix it, but I don't mind if Georg wants it to wait until 3.3.1

[1] http://docs.python.org/py3k/library/decimal#decimal.localcontext

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Ezio Melotti

Ezio Melotti added the comment:

Can't this be fixed in the CONTEXT_CHECK_VA macro?
With the attached patch decimal.localcontext(None) works and there aren't any 
failures, however I don't think there are tests that pass None explicitly, so 
this approach might not work.

--
keywords: +patch
nosy: +ezio.melotti
Added file: http://bugs.python.org/file26995/issue15783.diff

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



[issue10650] decimal.py: quantize(): excess digits with watchexp=0

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

Here's a patch deprecating watchexp.

--

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



[issue10650] decimal.py: quantize(): excess digits with watchexp=0

2012-08-25 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
keywords: +patch
Added file: http://bugs.python.org/file26996/issue10650.diff

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

OK, but for example:

Help on function __truediv__ in module decimal:

__truediv__(self, other, context=None)
Return self / other.

Here I think it's undisputed that a C version should not cram a context
argument into a number method. There are many functions in decimal where
some arguments are just implementation details, or worse, leftovers
(see #10650).

So I simply don't know if localcontext(None) was intended or (once)
an implementation detail.

localcontext(None) by itself looks kind of awkward to me. The only valid
use case I can see is indeed the one from #15136.

I don't particularly mind either way for localcontext(), but in more
speed sensitive areas I would care.

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

 Can't this be fixed in the CONTEXT_CHECK_VA macro?

No, the macro should only allow contexts. E.g. in the case of localcontext(None)
context_copy(local, NULL) would be called on local=Py_None, which is undefined.

What would perhaps be needed for a nice C-API is a function like

   PyArg_ParseTupleSkipNone()

that treats None arguments in the same way as optional args that are
not given.

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Stefan Krah

Stefan Krah added the comment:

This is the complete list of context=None divergences. It would
be possible to change that, since most of the functions are
generated by macro wrappers.


# This is the only place where 'ctx' is used
localcontext(ctx=None)

canonical(self, context=None)
compare(self, other, context=None)
compare_signal(self, other, context=None)
exp(self, context=None)
fma(self, other, third, context=None)
is_normal(self, context=None)
is_subnormal(self, context=None)
ln(self, context=None)
log10(self, context=None)
logb(self, context=None)
logical_and(self, other, context=None)
logical_invert(self, context=None)
logical_or(self, other, context=None)
logical_xor(self, other, context=None)
max(self, other, context=None)
max_mag(self, other, context=None)
min(self, other, context=None)
min_mag(self, other, context=None)
next_minus(self, context=None)
next_plus(self, context=None)
normalize(self, context=None)
number_class(self, context=None)
quantize(self, exp, rounding=None, context=None, watchexp=True)
remainder_near(self, other, context=None)
rotate(self, other, context=None)
scaleb(self, other, context=None)
shift(self, other, context=None)
sqrt(self, context=None)
to_eng_string(self, context=None)
to_integral(self, rounding=None, context=None)
to_integral_value(self, rounding=None, context=None)
to_integral_exact(self, rounding=None, context=None)

context.power(self, a, b, modulo=None)

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Mark Dickinson

Mark Dickinson added the comment:

This doesn't strike me as something it's essential to resolve before 3.3.1.

And I agree that decimal.localcontext(None) looks peculiar.  I noticed this 
yesterday when looking at #15136 and dismissed it as an artifact of the 
implementation---I didn't think to check what the docs said.  I think it's a 
bit unfortunate that the docs specify ctx=None.  I doubt that too much 
thought went into that;  without knowing the history, I suspect that at the 
time it was just a way to indicate that the context was an optional argument.

IOW, my vote would be not to require that None is accepted, and to treat this 
as an minor error in the documentation.

--

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



[issue15783] decimal.localcontext(None) fails when using the C accelerator module

2012-08-25 Thread Mark Dickinson

Mark Dickinson added the comment:

Adding Raymond to the nosy, since he may know more about what was intended.

--
nosy: +rhettinger

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



[issue14649] doctest.DocTestSuite error misleading when module has no docstrings

2012-08-25 Thread Chris Jerdonek

Chris Jerdonek added the comment:

 Personally I prefer to have the test case create the file(s) used in the test 
 dynamically, writing them to the temporary working directory.

I prefer that too, but when I approached this issue, I found that test_doctest 
doesn't use unittest.  It uses only doctest tests to test itself, and it uses 
checked-in files to test things like DocTestSuite and DocFileSuite.  For 
example, test_DocFileSuite has this:

 suite = doctest.DocFileSuite('test_doctest.txt',
...  'test_doctest2.txt',
...  'test_doctest4.txt')

(Hence the eight supporting files I mentioned in my previous comment, of which 
these are three.)

Should I break the current way of doing things for this module and introduce 
unittest and the first dynamically created files?

 We have in the past put notes in the doc that say this may change in the 
 future, though that is usually about desired enhancements.

That's interesting.  It's like a Will change in version ... counterpart to 
Changed in version   Come to think of it, that could be a useful practice 
in general because it would let people future-proof their code more easily and 
give them incentives to upgrade.

To simplify things for the purposes of this issue, we can discuss adding such 
wording to earlier versions only if and when we actually change the future 
behavior.  I can create a separate issue to discuss changing future behavior 
once this issue is complete.

--

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



[issue15136] Decimal accepting Fraction

2012-08-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

After reading the comments, I am ambivalent about a conversion function, and 
given the lack of consensus or even a clear majority, -1. (Which implies a 
change in issue title.)

I am +1 on using the new .format() machinery to have fractions format 
themselves. (Unless Python already does so for other purposes, it should do so 
without importing decimal.) The uploaded function passes the included test 
cases. I guess the rounding should be whatever we do for floats. I fudged that 
in the example.

--
Added file: http://bugs.python.org/file26997/fracdec.py

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-08-25 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Attaching two patches.

Patch 1 changes the common message template in mailbox tests to end in a 
newline. If this wasn't done, more or less all common mailbox tests would have 
to be special cased for mbox.

Patch 2 adds a single blank line after each message in mbox. A single blank 
line is added if the added message doesn't end in a newline or ends in a single 
newline. When read back, a single newline is added to the end o the message if 
it wasn't there (and this is the reason why patch 1 is needed).

--
keywords: +patch
Added file: 
http://bugs.python.org/file26998/issue15222_v1_0001_end_test_msg_template_in_newline.patch

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-08-25 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
keywords: +needs review
stage:  - patch review
Added file: 
http://bugs.python.org/file26999/issue15222_v1_0002_insert_blank_after_each_message_in_mbox.patch

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



  1   2   >