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 (itera
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/fil
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 enti
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:
&g
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 declar
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 ""
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 usag
Dave Reid wrote:
>
> New submission from Dave Reid :
>
> 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, whic
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
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
<h
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 'impo
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") + '&qu
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
Change by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<https://bugs.python.org/issue36191>
___
___
Python-bugs-list
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() alway
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 exam
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 (m
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
___
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
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
<http://bugs.python.org
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
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
___
Pytho
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
<http://bugs.python.org/i
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
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:
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.
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", "copy
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue5950>
___
___
Python-bugs-list mailing list
Peter Otten added the comment:
This could be a duplicate of issue14591.
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue17020>
___
___
Pytho
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'\xe
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 wil
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
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.
--
comp
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
<http://bugs.python.or
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
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue22240>
___
___
Python-bugs-list mailing list
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", "credi
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
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
>>&g
Peter Otten added the comment:
I have condensed your code into a self-contained demo.
Unfortunately that seems to work on 2.7 (I don't have 2.5).
--
nosy: +peter.otten
Added file: http://bugs.python.org/file34035/demo.py
___
Python tracker
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 P
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
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 ;)
--
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue20714>
___
___
Python-bugs-list mailing list
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 se
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.
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'
Traceba
Peter Otten added the comment:
I did sign today (and received the confirmation email).
--
___
Python tracker
<http://bugs.python.org/issue20791>
___
___
Python-bug
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
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 attach
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
<http://bugs.python.org/is
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
Changes by Peter Otten <__pete...@web.de>:
--
keywords: +patch
Added file: http://bugs.python.org/file34263/copyreg.patch
___
Python tracker
<http://bugs.python.org/i
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
___
Pytho
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.
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue29287>
___
___
Python-bugs-list mailing list
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue29290>
___
___
Python-bugs-list mailing list
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue16623>
___
___
Python-bugs-list mailing list
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 i
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
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.
>>&g
Peter Otten added the comment:
Have you considered writing your own little sniffer? Getting it right for your
actual data is usually easier to achieve than a general solution.
The following simplistic sniffer should work with your samples:
def make_dialect(delimiter):
class Dialect
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
<http://bugs.python.org/is
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 A
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
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue23551>
___
___
Python-bugs-list mailing list
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue23495>
___
___
Python-bugs-list mailing list
Changes by Peter Otten <__pete...@web.de>:
--
nosy: +peter.otten
___
Python tracker
<http://bugs.python.org/issue23639>
___
___
Python-bugs-list mailing list
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
69 matches
Mail list logo