[issue41259] Find adverbs is not correct on the documentation

2020-07-09 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

While I don't want to start a philosical discussion -- is that really better? 
Finding adverbs with a regex doesn't work in the general case -- think 
butterfly, panoply, well -- and the example is meant to illustrate the usage of 
re.findall() rather than regex syntax.

"finding adverbs" is just shorter and easier to understand than "finding 
sequences of word characters that end with "ly".

--
nosy: +peter.otten

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



[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

This is not a bug (and if it were you would have to report to numpy, not 
cpython).

Consider:

>>> import numpy
>>> a = numpy.zeros((2,2,2))
>>> a[0,2]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: index 2 is out of bounds for axis 1 with size 2

This is probably the message you expect. However, if you write
>>> a[0][2]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: index 2 is out of bounds for axis 0 with size 2

you split the operation into two steps, and the second axis of a is effectively 
the first axis of a[0].

--
nosy: +peter.otten -steven.daprano

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



[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

That's a bug in your code. You create another ArgumentParser in the toplevel 
code of preprocess.py. When this module is imported directly or indirectly your 
script will us this parser to parse the command line first. Minimal example:

$ cat preprocess.py
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--foo")
print(parser.parse_args())
$ cat test.py
import argparse
import preprocess

parser = argparse.ArgumentParser()
parser.add_argument("--bar")
print(parser.parse_args())
$ python3 test.py --bar 42
usage: test.py [-h] [--foo FOO]
test.py: error: unrecognized arguments: --bar 42
$ 

Fix: Protect toplevel code in preprocess.py with

if __name__ == "__main__":
parser = ...
...

--
nosy: +peter.otten

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



[issue36193] Redirected stderr not reset properly when using logging

2019-03-06 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

[Andrius]
> So it is not possible to consistently manage stderr when it involves > 
> logging library without explicitly "manage" it?

That's what I think, at least from within a script. To me redirect_xxx() always 
looked like a workaround to have old code write to a destination that was 
unforeseen in the initial design. I prefer

dump_stuff(dest)

to

with redirect_stdout(dest):
   dump_stuff()

That said -- do you have a suggestion how the logging library could be adapted 
to work smoothly with redirect_xxx()?

(A compelling use case would also be nice, but note that I'm not the one who 
makes the decisions.)

--

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



[issue36191] pubkeys.txt contains bogus keys

2019-03-05 Thread Peter Otten


Change by Peter Otten <__pete...@web.de>:


--
nosy: +peter.otten

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



[issue36193] Redirected stderr not reset properly when using logging

2019-03-05 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

I see various options to address this.

(1) Change basicConfig() to use __stderr__ instead of stderr to avoid 
redirections from within the script.

(2) Change your script to call basicConfig() explicitly, before the temporary 
redirection takes place. 

In both cases logging output will always go to the "real" stderr.

(3) Write a special handler that fetches sys.stderr lazily. Here's a sketch:

class StderrHandler(logging.StreamHandler):
def __init__(self):
super().__init__()

def get_stream(self):
return sys.stderr

def set_stream(self, _value):
pass

stream = property(get_stream, set_stream)

logging.basicConfig(handlers=[StderrHandler()])

As written this is likely to fail with multiple threads...

My personal favourite is option (2).

--
nosy: +peter.otten

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



[issue35787] shlex.split inserts extra item on backslash space space

2019-01-20 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

To me the current shlex behaviour makes sense, and the shell (tested with bash) 
behaves the same way:

$ python3 -c 'import sys; print(sys.argv)' a   b
['-c', 'a', 'b']
$ python3 -c 'import sys; print(sys.argv)' a \  b
['-c', 'a', ' ', 'b']

--
nosy: +peter.otten

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



[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-18 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

You probably saw this is in Python 2.7 where it is the expected behaviour.
All versions of Python 3 should produce the NameError.

--
nosy: +peter.otten
versions: +Python 3.6 -Python 2.7

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



[issue30952] [Windows] include Math extension in SQlite

2017-11-06 Thread Peter Otten

Peter Otten <__pete...@web.de> added the comment:

A possible workaround is to use create_function():

>>> import sqlite3, math
>>> db = sqlite3.connect(":memory:")
>>> db.execute("select sin(?);", (math.pi,)).fetchone()
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.OperationalError: no such function: sin
>>> db.create_function("sin", 1, math.sin)
>>> db.execute("select sin(?);", (math.pi,)).fetchone()
(1.2246467991473532e-16,)

--
nosy: +peter.otten

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



[issue31266] attribute error

2017-08-23 Thread Peter Otten

Peter Otten added the comment:

You have probably written your own re.py file which shadows the one in the 
standard library. Once you remove or rename your re.py the error should go away.

--
nosy: +peter.otten

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



[issue31214] os.walk has a bug on Windows

2017-08-15 Thread Peter Otten

Peter Otten added the comment:

Read the documentation of os.walk() again. It already walks the complete 
directory tree starting with src. 

When you invoke it again by calling your copy_dir() method recursively you will 
of course see once more the files and directories in the respective 
subdirectory.

--
nosy: +peter.otten

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-11 Thread Peter Otten

Peter Otten added the comment:

While I don't think that the csv module should second-guess broken input you 
might consider "fixing" your data on the fly:

def close_quote(line):
if line.count('"') % 2:
line = line.rstrip("\n") + '"\n'
return line

with open("data.csv") as f:
for row in csv.reader(map(close_quote, f)):
print(row)

That should give the desired output.

--
nosy: +peter.otten

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



[issue16623] argparse help formatter does not honor non-breaking space

2017-01-17 Thread Peter Otten

Changes by Peter Otten <__pete...@web.de>:


--
nosy: +peter.otten

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



[issue29290] argparse breaks long lines on NO-BREAK SPACE

2017-01-17 Thread Peter Otten

Changes by Peter Otten <__pete...@web.de>:


--
nosy: +peter.otten

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



[issue29287] IDLE needs syntax highlighting for f-strings

2017-01-17 Thread Peter Otten

Changes by Peter Otten <__pete...@web.de>:


--
nosy: +peter.otten

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



[issue28969] fnmatch is not threadsafe

2016-12-15 Thread Peter Otten

Peter Otten added the comment:

Here's another way to reproduce the error. The problem seems to be in the C 
implementation of _lru_cache_wrapper() / bounded_lru_cache_wrapper().

$ cat test.py
import functools
import threading
import time

@functools.lru_cache(maxsize=2)
def f(v):
time.sleep(.01)

threads = [threading.Thread(target=f, args=(v,)) for v in [1,2,2,3,2]]
for t in threads:
t.start()

$ ./python test.py
Exception in thread Thread-5:
Traceback (most recent call last):
  File "/somewhere/Lib/threading.py", line 916, in _bootstrap_inner
self.run()
  File "/somewhere/Lib/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
KeyError: (2,)

$ ./python
Python 3.7.0a0 (default:654ec6ed3225+, Dec 15 2016, 11:24:30) 
[GCC 4.8.4] on linux

--
nosy: +peter.otten, rhettinger, serhiy.storchaka

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Peter Otten

Peter Otten added the comment:

Your code relies on the assumption that when the lambda is invoked the global t 
is still bound to the Thread instance you are starting. It seems that this is 
not always the case, and I don't see why it should be guaranteed either.
I don't know whether it's a good idea to store per-thread data in the Thread 
instance (have a look at threading.local()), but

def start_thread():
t = Thread(target=lambda: f(t))
t.obj = [0]
t.start()

for _ in range(n_threads):
start_thread()

will at least avoid the global.

--
nosy: +peter.otten

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



[issue26126] Possible subtle bug when normalizing and str.translate()ing

2016-01-15 Thread Peter Otten

Peter Otten added the comment:

There seems to be a connection to hash randomization. I consistently get

$ PYTHONHASHSEED=1 python3.6 ./normbug.py 
BUG ('The aenid oevre', '!=', 'The AEnid oevre')
$ PYTHONHASHSEED=0 python3.6 ./normbug.py 
OK ('The AEnid oevre', '==', 'The AEnid oevre')

--
nosy: +peter.otten

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



[issue26126] Possible subtle bug when normalizing and str.translate()ing

2016-01-15 Thread Peter Otten

Peter Otten added the comment:

Not a bug. In your XFORMS dict you have

>>> ord("Æ") == 0xC6
True

Whether the value of "Æ" or 0xC6 is used by str.maketrans() depends on the 
order of the dict entries which in turn is determined by the keys' hash. Remove 
one and you should see consistent results.

--

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



[issue25999] Add support of native number in bin()

2016-01-03 Thread Peter Otten

Peter Otten added the comment:

How would you disambiguate -1 and (for example) 2**64-1 on a 64-bit machine? 
Python's int is not limited to a specific number of bits.

--
nosy: +peter.otten

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



[issue24787] csv.Sniffer guesses M instead of \t or , as the delimiter

2015-08-04 Thread Peter Otten

Peter Otten added the comment:

The sniffer actually changes its mind in the fourth line:

Python 3.4.0 (default, Jun 19 2015, 14:20:21) 
[GCC 4.8.2] on linux
Type help, copyright, credits or license for more information.
 import csv
 csv.Sniffer().sniff(\
... Invoice File,Credit Memo,Amount Claimed,Description,Invoice,Message,
... Sscanner ac15072911220.pdf,CM_15203,28714.32,MX Jan Feb,948198,,
... Sscanner ac15072911221.pdf,CM 16148,15600,MX Unkwon,948199,,
... ).delimiter
','
 csv.Sniffer().sniff(\
... Invoice File,Credit Memo,Amount Claimed,Description,Invoice,Message,
... Sscanner ac15072911220.pdf,CM_15203,28714.32,MX Jan Feb,948198,,
... Sscanner ac15072911221.pdf,CM 16148,15600,MX Unkwon,948199,,
... Sscanner ac15072911230.pdf,CM 16148,33488,MX Cavalier,948200,Photos don't 
match the invoice
... ).delimiter
'M'

That line has only 5 commas while all others have 6. Unfortunately all lines 
contain exactly two M...

--
nosy: +peter.otten

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



[issue16669] Docstrings for namedtuple

2015-04-27 Thread Peter Otten

Peter Otten added the comment:

Here's a variant that builds on your code, but makes for a nicer API. 
Single-line docstrings can be passed along with the attribute name, and with 
namedtuple.with_docstrings(... all info required to build the class ...) from a 
user perspective the factory looks like a class method:

from functools import partial
from collections import namedtuple


def _with_docstrings(cls, typename, field_names_with_doc,
 *, verbose=False, rename=False, doc=None):
field_names = []
field_docs = []
if isinstance(field_names_with_doc, str):
field_names_with_doc = [
line for line in field_names_with_doc.splitlines() if line.strip()]
for item in field_names_with_doc:
if isinstance(item, str):
item = item.split(None, 1)
if len(item) == 1:
[fieldname] = item
fielddoc = None
else:
fieldname, fielddoc = item
field_names.append(fieldname)
field_docs.append(fielddoc)

nt = cls(typename, field_names, verbose=verbose, rename=rename)

for fieldname, fielddoc in zip(field_names, field_docs):
if fielddoc is not None:
new_property = property(getattr(nt, fieldname), doc=fielddoc)
setattr(nt, fieldname, new_property)

if doc is not None:
nt.__doc__ = doc
return nt

namedtuple.with_docstrings = partial(_with_docstrings, namedtuple)

if __name__ == __main__:
Point = namedtuple.with_docstrings(Point, x abscissa\ny ordinate)
Address = namedtuple.with_docstrings(
Address,

name Surname
first_name First name

city
email Email address
)
Whatever = namedtuple.with_docstrings(
Whatever,
[(foo, doc for\n foo),
 (bar, doc for bar),
 baz],
doc=The Whatever class.

Example for a namedtuple with multiline docstrings for its attributes.)

--
nosy: +peter.otten

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



[issue23639] Not documented special names

2015-03-11 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
nosy: +peter.otten

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



[issue23495] The writer.writerows method should be documented as accepting any iterable (not only a list)

2015-03-07 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
nosy: +peter.otten

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



[issue23551] IDLE to provide menu options for using PIP

2015-03-07 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
nosy: +peter.otten

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



[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Peter Otten

Peter Otten added the comment:

This is not a bug; the signature of re.sub() is

sub(pattern, repl, string, count=0, flags=0)

and the fourth argument thus the 'count' delimiting the number of substitutions 
that you accidentally specify as

 import re
 re.S
16

I recommend that you use a keyword arg to fix your code:

 re.sub('x', 'a', x*20, flags=re.S)
''

--
nosy: +peter.otten

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



[issue22240] argparse support for python -m module in help

2014-08-21 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
nosy: +peter.otten

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



[issue5950] Make zipimport work with zipfile containing comments

2014-05-28 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
nosy: +peter.otten

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



[issue21553] Behaviour of modules depends on how they where imported

2014-05-22 Thread Peter Otten

Peter Otten added the comment:

Here's a simpler demo for what I believe you are experiencing:

$ mkdir package
$ cd package/
$ touch __ini__.py module.py
$ export PYTHONPATH=..
$ python3
Python 3.3.2+ (default, Feb 28 2014, 00:52:16) 
[GCC 4.8.1] on linux
Type help, copyright, credits or license for more information.
 import module, package.module
 module is package.module
False

Even though module and package.module correspond to the same file
Python does not recognize that you intend the former to be part of a package. 
Your run0.py script goes through its sys.path entries and unfortunately the 
first entry points into a package so that all modules in that package become 
also visible as toplevel modules.

A good way to avoid this trap is to use relative imports

 from . import module
Traceback (most recent call last):
  File stdin, line 1, in module
SystemError: Parent module '' not loaded, cannot perform relative import

--
nosy: +peter.otten

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



[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread Peter Otten

Peter Otten added the comment:

As every beginner will learn about (and probably overuse) range() pretty soon I 
think it's OK to use that form. 

The math-inspired notation [0, 255] may be misinterpreted as a list. You also 
lose the consistency of preferring half-open intervals everywhere.

The third alternative I see,

0 = x  256

has the problem that it requires a name (the 'x') that may not correspond to a 
variable in the source code. You'd also need to clarify that x must be an int 
to make the message bulletproof.

I think this should be left as is.

--
nosy: +peter.otten

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



[issue20823] Clarify copyreg.pickle() documentation

2014-03-02 Thread Peter Otten

New submission from Peter Otten:

The documentation for 

copyreg.pickle(type, function, constructor=None)

has the sentence

TypeError will be raised if *object* is a class or *constructor* is not 
callable.

It's not clear to me what object refers to. I believe it refers to the first 
arg (called ob_type in 2.x) and classic classes which were handled with

def pickle(ob_type, pickle_function, constructor_ob=None):
if type(ob_type) is _ClassType:
raise TypeError(copy_reg is not intended for use with classes)

in 2.x If I'm right the above sentence should become.

A TypeError will be raised if *constructor* is not callable.

in 3.x. If I'm wrong please think of way to express the intended meaning more 
clearly.

Another minor change: class C need not inherit from object explicitly in  3.x.

--
assignee: docs@python
components: Documentation
messages: 212541
nosy: docs@python, peter.otten
priority: normal
severity: normal
status: open
title: Clarify copyreg.pickle() documentation
versions: Python 3.3

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



[issue20823] Clarify copyreg.pickle() documentation

2014-03-02 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
keywords: +patch
Added file: http://bugs.python.org/file34263/copyreg.patch

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



[issue20805] Error in 3.3 Tutorial

2014-02-28 Thread Peter Otten

Peter Otten added the comment:

No, that's not an error. Given a class MyClass and an instance x of that class

 class MyClass:
... def f(self): return 42
... 
 x = MyClass()

you usually invoke a method like so:
 x.f()
42

But it is also possible to break that in two steps
(1) get the bound method and store it in a variable for later use:

 xf = x.f

(2) call the bound method as often as you like:
 xf()
42


bound method means that the method remembers the instance it is associated 
with (x in the above example).

Gene, while you are still learning the language please ask on the python-tutor 
mailing list first before resorting to the bug tracker.

--
nosy: +peter.otten

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



[issue20804] Sentinels identity lost when pickled (unittest.mock)

2014-02-28 Thread Peter Otten

Peter Otten added the comment:

From looking at the sentinel code it appears a sentinel's identity is 
controlled by its name alone, i. e.

sentinel.foo is sentinel.foo

If that's the desired behaviour it is well possible to make that indentity 
survive pickling. I have attached a demo script using the simplest approach -- 
registering the class with copyreg.
If you like the general idea I'm willing to look up the alternative (a 
__getstate__() or __reduce__() method), too ;)

--
nosy: +peter.otten
Added file: http://bugs.python.org/file34256/pickle_sentinels.py

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



[issue20804] Sentinels identity lost when pickled (unittest.mock)

2014-02-28 Thread Peter Otten

Peter Otten added the comment:

I have no experience with unittest.mock, so I'm in no position to contradict... 
Vlastimil, could you give your use case?

--

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



[issue20791] copy.copy(bytes) is slow

2014-02-27 Thread Peter Otten

Peter Otten added the comment:

Assuming that the current behaviour is by accident here's a patch that adds the 
bytes type to the _copy_dispatch registry.

--
keywords: +patch
nosy: +peter.otten
Added file: http://bugs.python.org/file34244/copy_bytes.patch

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



[issue20794] ImportError: Bad magic number in .pyc file

2014-02-27 Thread Peter Otten

Peter Otten added the comment:

This is expected. You cannot run/import 2.6 .pyc files in python 2.7 because 
the file format has changed.

$ echo 'print hello'  tmp.py 
$ python2.6 -c 'import tmp'
hello
$ rm tmp.py
$ python2.7 -c 'import tmp'
Traceback (most recent call last):
  File string, line 1, in module
ImportError: Bad magic number in tmp.pyc

Naval, if you do have the source .py make sure that you delete all 
occurrences of .pyc in directories preceding the directory containing 
.py in sys.path. Sometimes this error is the result of moving a .py file 
into another directory and forgetting to delete the leftover .pyc.

--
nosy: +peter.otten

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



[issue20791] copy.copy(bytes) is slow

2014-02-27 Thread Peter Otten

Peter Otten added the comment:

I did sign today (and received the confirmation email).

--

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



[issue20714] Allow for ]] in CDATA in minidom

2014-02-24 Thread Peter Otten

Peter Otten added the comment:

Perhaps a look at the competition is still in order: Java silently breaks such 
an invalid CDATA in two, as suggested.

http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.htm says

No lexical check is done on the content of a CDATA section and it is therefore 
possible to have the character sequence ]] in the content, which is illegal 
in a CDATA section per section 2.7 of [XML 1.0]. The presence of this character 
sequence must generate a fatal error during serialization or the cdata section 
must be splitted before the serialization (see also the parameter 
split-cdata-sections in the DOMConfiguration interface).


The change Artur suggested would be covered by this.

--

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



[issue20742] 2to3 zip fixer doesn't fix for loops.

2014-02-23 Thread Peter Otten

Peter Otten added the comment:

Hm, I would expect that in 99 times out of 100 the extra list(...) would be 
removed in a manual step following the automated conversion.

I'd really like to see the non-contrived example with a justified use of this 
evil side effect ;)

--
nosy: +peter.otten

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



[issue20714] Allow for ]] in CDATA in minidom

2014-02-23 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
nosy: +peter.otten

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



[issue20729] mailbox.Mailbox does odd hasattr() check

2014-02-22 Thread Peter Otten

Peter Otten added the comment:

Do you expect many use cases that rely on items(), keys(), and values() being 
lists? 
Maybe it would be acceptable to make these lazy in 3.5, but keep the iterXXX() 
variants as aliases indefinitely.

--
nosy: +peter.otten

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



[issue20587] sqlite3 converter not being called

2014-02-11 Thread Peter Otten

Peter Otten added the comment:

Are you sure that the converter is called in Python 2.5?
I've looked into the source (Modules/_sqlite/cursor.c), and if I understand the 
code correctly it uses the sqlite3_column_decltype() function from the sqlite3 
API to determine the column type.

So Python would be at the mercy of the sqlite3 implementation.

--
Added file: http://bugs.python.org/file34052/demo3.py

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



[issue20004] csv.DictReader classic class has a property with setter

2013-12-17 Thread Peter Otten

New submission from Peter Otten:

I ran into this when trying to trigger rereading the column names with

$ cat tmp.csv
alpha,beta
1,2
gamma,delta,epsilon
3,4,5
$ python
Python 2.7.2+ (default, Jul 20 2012, 22:15:08) 
[GCC 4.6.1] on linux2
Type help, copyright, credits or license for more information.
 import csv
 with open(tmp.csv) as f:
... reader = csv.DictReader(f)
... for i in range(2):
... print next(reader)
... reader.fieldnames = None
... 
{'alpha': '1', 'beta': '2'}
Traceback (most recent call last):
  File stdin, line 4, in module
  File /usr/lib/python2.7/csv.py, line 112, in next
d = dict(zip(self.fieldnames, row))
TypeError: zip argument #1 must support iteration

reader = csv.DictReader(...)
...
reader.fieldnames = None

I think the easiest fix would be to have it inherit from object:

 class DictReader(csv.DictReader, object): pass
... 
 with open(tmp.csv) as f:
... reader = DictReader(f)
... for i in range(2):
... print next(reader)
... reader.fieldnames = None
... 
{'alpha': '1', 'beta': '2'}
{'3': 'gamma', '5': 'epsilon', '4': 'delta'}

--
messages: 206418
nosy: peter.otten
priority: normal
severity: normal
status: open
title: csv.DictReader classic class has a property with setter
versions: Python 2.7

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



[issue20004] csv.DictReader classic class has a property with setter

2013-12-17 Thread Peter Otten

Peter Otten added the comment:

Setting the fieldnames attribute of an existing DictReader is not documented. 
Eric, there is no need for an enhancement (other than for the documentation) as 
this already works in Python 3 where newstyle classes are the default. The 
heart of the bug is really the classic class with a property.

I have no idea what a fix could look like that is less intrusive than promoting 
DictReader to a newstyle class. 

Maybe it would be sufficient to add a comment to the code pointing to my bug 
report? I've already shown one workaround (object as a mixin); another would be 
to set the private _fieldnames rather than fieldnames so that the getter will 
continue to work as designed.

Looking at the current DictReader code and determining why and how it fails 
will be quite hard for a non-expert ;)

--

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



[issue20004] csv.DictReader classic class has a property with setter

2013-12-17 Thread Peter Otten

Peter Otten added the comment:

The proposed patch looks fine to me.

And for the record, I don't think setting fieldnames should be promoted in the 
3.x documentation. Along the lines of Eric's suggestion I should have written 
something like

 import csv
 with open(tmp.csv) as f:
... for i in range(2):
... print next(csv.DictReader(f))
... 
{'alpha': '1', 'beta': '2'}
{'epsilon': '5', 'gamma': '3', 'delta': '4'}

which would have spared you the hustle ;)

Thank you for your effort!

--

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



[issue19808] IDLE applies syntax highlighting to user input in its shell

2013-11-30 Thread Peter Otten

Peter Otten added the comment:

I think the prompt can easily be treated differently because it is written to 
stderr. 
I don't see a difference for user input between input() and raw_input() on 
Linux with Python 2.7.2+ -- syntax-highlighting is applied to both.

--

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



[issue19808] IDLE applys syntax highlighting to user input in its shell

2013-11-27 Thread Peter Otten

New submission from Peter Otten:

For example when you type

 input(What shall I do? )
Run for your life!

in its shell window IDLE shows the 'for' as if it were a keyword. The same 
happens if you run a script that requires user interaction.

--
components: IDLE
messages: 204566
nosy: peter.otten
priority: normal
severity: normal
status: open
title: IDLE applys syntax highlighting to user input in its shell

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



[issue19808] IDLE applies syntax highlighting to user input in its shell

2013-11-27 Thread Peter Otten

Changes by Peter Otten __pete...@web.de:


--
title: IDLE applys syntax highlighting to user input in its shell - IDLE 
applies syntax highlighting to user input in its shell

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



[issue19657] List comprehension conditional evaluation order seems backwards

2013-11-19 Thread Peter Otten

Peter Otten added the comment:

I believe you are misinterpreting what you are seeing. Empty lines read from a 
file do not produce an empty string, you get \n instead which is true in a 
boolean context.

Try

[line.split()[0] for line in lines if line.strip() and not line.startswith(#)]

or add an extra check for all-whitespace line

[... if line and not line.isspace() and not line.startswith(#)]

--
nosy: +peter.otten

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



[issue19528] logger.config.fileConfig cant cope with files starting with an 'r' on windows

2013-11-08 Thread Peter Otten

Peter Otten added the comment:

Simon, in your code you build the config file with 

'''...
args=('{0}', 'a', 131072, 10)
...
'''.format(filename)

The logging module uses eval() to process the args tuple, and a filename 
containing a bashlash will not roundtrip that way. Have a look at the .conf 
file, it contains something like

args=('whatever\testlog\really_cool_logging.log', 'a', 131072, 10)

when it should be

args=('whatever\\testlog\\really_cool_logging.log', 'a', 131072, 10)

To fix this you should drop the quote chars and use the string representation 
of the filename:

'''...
args=({0!r}, 'a', 131072, 10)
...
'''.format(filename)

In short: I think Eric was right with initial assumption.

--
nosy: +peter.otten

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



[issue19210] Unicode Objects in Tuples

2013-10-09 Thread Peter Otten

Peter Otten added the comment:

Be aware that for a 1-tuple the trailing comma is mandatory:

 print (uäöü) # this is a string despite the suggestive parens
äöü
 print (uäöü,) # this is a tuple
(u'\xe4\xf6\xfc',)

--
nosy: +peter.otten

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



[issue18892] sqlite3, valued records not persisted, default ones are

2013-08-31 Thread Peter Otten

Peter Otten added the comment:

David means you should replace the line

conn.commit

in your script which does not invoke the method with

conn.commit()

Side note: as long as you are a newbie it is a good idea to ask on the python 
mailing list first before adding a report to the bug tracker.

--
nosy: +peter.otten

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



[issue18788] Proof of concept: implicit call syntax

2013-08-20 Thread Peter Otten

Peter Otten added the comment:

 a bare expression is not call

Wouldn't that silently swallow a lot of bare

print

statements?

--
nosy: +peter.otten

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



[issue18219] csv.DictWriter is slow when writing files with large number of columns

2013-08-15 Thread Peter Otten

Peter Otten added the comment:

Note that set operations on dict views work with lists, too. So the only change 
necessary is to replace

wrong_fields = [k for k in rowdict if k not in self.fieldnames]

with

wrong_fields = rowdict.keys() - self.filenames

(A backport to 2.7 would need to replace keys() with viewkeys())

--
nosy: +peter.otten

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



[issue17020] random.random() generating values = 1.0

2013-01-23 Thread Peter Otten

Peter Otten added the comment:

This could be a duplicate of issue14591.

--
nosy: +peter.otten

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



[issue15545] sqlite3.Connection.iterdump() does not work with row_factory = sqlite3.Row

2012-08-06 Thread Peter Otten

Peter Otten added the comment:

Here's a minimal fix that modifies the sql in sqlite3.dump._iterdump() to sort 
the tables by name. It is then no longer necessary to sort the resultset in 
Python for the unit tests to pass.

--
keywords: +patch
nosy: +peter.otten
Added file: http://bugs.python.org/file26710/iterdump.diff

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



[issue15074] Strange behaviour of python cmd module. (Ignores slash)

2012-06-15 Thread Peter Otten

Peter Otten __pete...@web.de added the comment:

Not a python bug. You are ommitting an important detail of the stackoverflow 
example in your code:

# we want to treat '/' as part of a word, so override the delimiters
readline.set_completer_delims(' \t\n;')

Please turn to the Python mailing list if you need more help.

--
nosy: +peter.otten

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



[issue14638] pydoc error on instance of a custom class

2012-04-21 Thread Peter Otten

Peter Otten __pete...@web.de added the comment:

Patch upload, second attempt.

--
keywords: +patch
nosy: +peter.otten
Added file: http://bugs.python.org/file25298/render_doc.patch

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



[issue14612] Crash after modifying f_lineno

2012-04-18 Thread Peter Otten

Peter Otten __pete...@web.de added the comment:

frame_setlineno() doesn't keep track of with blocks. Here's a patch.

--
keywords: +patch
nosy: +potten
Added file: http://bugs.python.org/file25258/frame_setlineno.patch

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



Re: [issue14591] Value returned by random.random() out of valid range

2012-04-16 Thread Peter Otten
Dave Reid wrote:

 
 New submission from Dave Reid seabass...@gmail.com:
 
 A particular combination of seed and jumpahead calls seems to force the MT
 generator into a state where it produces a random variate that is outside
 the range 0-1. Problem looks like it might be in
 _randommodule.c:genrand_int32, which produces a value  0x for the
 given state, but I don't understand the generator well enough to debug any
 further.
 
 The attached test case produces 1.58809998297 as the 2nd variate in Python
 2.7 and 1.35540900431 as the 23rd variate in Python 2.7.3. The problem
 occurs on both Linux (CentOS 6) and Mac OSX (10.6.8), both 64-bit.

A simple way to reproduce the problem:

 import random
 r = random.Random()
 a, b, c = r.getstate()
 r.setstate((a, (0x,)*len(b), c))
 r.jumpahead(1)
 r.random()
1.8015423506628903


It looks like in random_jumpahead

mt[i] += i+1;

needs to be masked

mt[i] = (mt[i] + i + 1)  0xUL;

(random_setstate already does that)

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



[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Peter Otten

New submission from Peter Otten __pete...@web.de:

I've been looking at code on the tutor mailing list for some time, and

for line in file.readlines(): ...

is a common idiom there. I suppose this is because the readlines() method is 
easily discoverable while the proper way (iterate over the file object 
directly) is not.

A note added to the readlines() documentation might help:


You don't need the readlines() method to loop over the lines of a file.
for line in file: process(line)
consumes less memory and is often faster.


--
assignee: docs@python
components: Documentation
messages: 148679
nosy: docs@python, potten
priority: normal
severity: normal
status: open
title: Clarify that readlines() is not needed to iterate over a file
type: feature request

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



[issue12888] html.parser.HTMLParser.unescape works only with the first 128 entities

2011-09-03 Thread Peter Otten

Peter Otten __pete...@web.de added the comment:

The unescape() method uses re.sub(regex, sub, re.ASCII), but the third argument 
is count, not flags. Fix is easy: use

re.sub(regex, sub, flags=re.ASCII).

--
keywords: +patch
nosy: +potten
Added file: http://bugs.python.org/file23092/unescape_bug.patch

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



[issue7764] Doc for itertools recipe consume is complicated and less efficient

2010-01-23 Thread Peter Otten

Peter Otten __pete...@web.de added the comment:

As noted on comp.lang.python the implementation can be simplified to

def consume(items, n):
next(islice(items, n, n), None)

When I suggested the above I wasn't aware that 

consume(items, None)

should exhaust the entire iterator. Unfortunately I've not found an elegant way 
to add that functionality.

--
nosy: +potten

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



[issue5832] os.path.walk fails to descend into a directory whose name ends with a space

2009-04-24 Thread Peter Otten

Peter Otten __pete...@web.de added the comment:

Is BBDO Atlanta  a symbolic link?. These are skipped by 
os.path.walk(). (The behaviour of os.walk() can be specified with the 
followsymlinks argument.)

--
nosy: +potten

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



[issue2527] Pass a namespace to timeit

2008-04-02 Thread Peter Otten

Peter Otten [EMAIL PROTECTED] added the comment:

Alexander, I'm fine with a more specific argument name. ns was what 
the Timer already used internally.

Antoine, from __main__ import name1, ..., nameN works fine on the 
command line, but inside a function you'd have to declare the names 
you want to pass to the Timer as globals which I find a bit clumsy. 
Apart from giving a syntax warning a star-import affects the generated 
bytecode and produces the (slower) LOAD_NAME instead of LOAD_FAST.

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



[issue2527] Pass a namespace to timeit

2008-04-01 Thread Peter Otten

New submission from Peter Otten [EMAIL PROTECTED]:

I'd like to suggest a different approach than the one taken in rev. 
54348 to improve timeit's scripting interface: allow passing it a 
namespace. Reasons:

- It has smaller overhead for functions that take an argument:
 def f(a): pass
...
# trunk
 min(ht.Timer(lambda f=f: f(42)).repeat())
0.54068493843078613
# my patch
 min(mt.Timer(f(42), ns=dict(f=f)).repeat())
0.29009604454040527

- it is more flexible. Example:
# working code, requires matplotlib
from timeit import Timer
from time import sleep

def linear(i):
sleep(.05*i)
def quadratic(i):
sleep(.01*i**2)

x = range(10)
y = []
for a in x:
y.append([min(Timer(f(a), ns=dict(f=f, a=a)).repeat(1, 1))
  for f in linear, quadratic])

from pylab import plot, show
plot(x, y)
show()

The above code works unaltered inside a function, unlike the hacks 
using from __main__ import 

- the implementation is simpler and should be easy to maintain.

The provided patch is against 2.5.1. If it has a chance of being 
accepted I'm willing to jump through the necessary hoops: 
documentation, tests, etc.

--
components: Library (Lib)
files: diff_against_2_5_1.txt
messages: 64805
nosy: potten
severity: normal
status: open
title: Pass a namespace to timeit
type: feature request
versions: Python 2.6
Added file: http://bugs.python.org/file9916/diff_against_2_5_1.txt

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