New submission from Juancarlo Añez :
The problematic `findall(...)[0]` is a common anti-pattern in Python programs.
The reason is lack of symmetry and completeness in the `re` module.
The original proposal in `python-ideas` was to add `re.findfirst(pattern,
string, flags=0, default=_mark
Juancarlo Añez added the comment:
The discussion on python-ideas favored the inclusion of `findfirst()`. At any
rate, not having a generator version of `findall()` is an important omission.
Another user's search of Github public repositories found that
`findall(...)[0]` is prevalent. p
Juancarlo Añez added the comment:
There's no way to assert that `findall(...)[0]` is efficient enough in most
cases. It is easy to see that that it is risky in every case, as runtime may be
exponential, and memory O(len(input)). A mistake in the regular expression may
easily result in a
Juancarlo Añez added the comment:
The bottom problem, as I see it, is that, historically, `re.search()` returns
`None` when there is no match, instead of returning a `Match` object that is
consistent with "no match" (evaluates to `False`, etc.)
The above seems too difficult to re
Juancarlo Añez added the comment:
The analysis done by Terry bypasses the fact that `search(...)` returns `None`
when there is no match, so indexing or calling methods in its result is not
safe code.
`findall()` returns an empty list when there is no match.
`findalliter()` returns an empty
Juancarlo Añez added the comment:
def isplit(text, sep=None, maxsplit=-1):
"""
A lowmemory-footprint version of:
iter(text.split(sep, maxsplit))
Adapted from https://stackoverflow.com/a/9770397
"""
if maxsplit == 0:
yie
Juancarlo Añez added the comment:
My local timezone is (VET,VET) == time.tzname, and test_logging fails because
time.timezone is off by 30 minutes. I couldn't find the cause for the problem
with time.timezone, but logging is not to blame. I'm running the tests on
Ubuntu 12.04 A
Juancarlo Añez added the comment:
@Vinay The test *is* broken in theory, because it uses today's time.timezone to
make calculations over a datetime in the past (1993), even when official time
zones have changes in recent years for Caracas, Moscow, and others:
http://www.timeanddate.com
Juancarlo Añez added the comment:
> And datetime.datetime.now().tzinfo is always None.
I can reproduce that.
--
___
Python tracker
<http://bugs.python.org/issu
Juancarlo Añez added the comment:
I did extensive testing on time.timezone, and it is correct as far as the
current date is concerned. The problem, as mentioned before, is that
test_logging is using time.timezone for dates in the past for which the time
zone may have been different from the
Juancarlo Añez added the comment:
@Vinay No reason. datetime.astimezone(None) is documented in 3.3. You may even
use:
r.created = time.mktime(dt.astimezone().timetuple())
--
___
Python tracker
<http://bugs.python.org/issue14
Changes by Juancarlo Añez :
--
type: compile error -> behavior
___
Python tracker
<http://bugs.python.org/issue14902>
___
___
Python-bugs-list mailing list
Un
New submission from Juancarlo Añez :
>>> import io
>>> d = io.open('.')
Traceback (most recent call last):
File "", line 1, in
IsADirectoryError: [Errno 21] Is a directory: '.'
>>>
>>> import os
>>> d = io.op
Juancarlo Añez added the comment:
io.open() clearly doesn't care about opening directories as long as they are
passed as os.open() file descriptors. Quite unexpected!
--
___
Python tracker
<http://bugs.python.org/is
Juancarlo Añez added the comment:
Note that attempting subsequent operations on the returned object do raise
IsADirectoryError.
>>> import io
>>> import os
>>> d = io.open(os.open('.',0))
>>> d.read()
Traceback (most recent call last):
File &q
New submission from Juancarlo Añez:
Under Ubuntu Linux 11.10 and 12.04, webbroser.open() will output the following
message to the console:
Created new window in existing browser session.
The behavior is both unexpected and troublesome.
--
components: Library (Lib)
messages: 167443
New submission from Juancarlo Añez:
>>> t.pencolor(u'red')
Traceback (most recent call last):
File "", line 1, in
File "", line 1, in pencolor
File "/usr/lib/python2.7/lib-tk/turtle.py", line 2166, in pencolor
color = self._colorstr(
Juancarlo Añez added the comment:
This patch solves the problem by making turtle check for string against
basestring insted of str.
--
keywords: +patch
Added file: http://bugs.python.org/file26758/turtle_unicode.patch
___
Python tracker
<h
Juancarlo Añez added the comment:
The bug showed up in a script that used:
from __future__ import unicode_literals
--
___
Python tracker
<http://bugs.python.org/issue15
New submission from Juancarlo Añez:
$ lsb_release -a
LSB Version:
core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: Ubuntu
Description:Ubuntu 12.04.1 LTS
Release
Juancarlo Añez added the comment:
$ dpkg -l | grep readline
ii libreadline-dev 6.2-8
GNU readline and history libraries, development files
ii libreadline55.2-11
Juancarlo Añez added the comment:
Check if clear_history() is available before calling it.
--
keywords: +patch
Added file:
http://bugs.python.org/file26761/readline_clear_history_available.patch
___
Python tracker
<http://bugs.python.org/issue15
Changes by Juancarlo Añez :
Removed file:
http://bugs.python.org/file26761/readline_clear_history_available.patch
___
Python tracker
<http://bugs.python.org/issue15
Juancarlo Añez added the comment:
Check if clear_history() is available before calling it.
--
Added file:
http://bugs.python.org/file26762/readline_clear_history_available.patch
___
Python tracker
<http://bugs.python.org/issue15
24 matches
Mail list logo