[issue5205] String Formatting with namedtuple

2009-02-10 Thread Lie Ryan

New submission from Lie Ryan :

I've been experimenting with namedtuple, it seems that string formatting
doesn't recognize namedtuple as mapping. 

from collections import namedtuple
Nt = namedtuple('Nt', ['x', 'y'])
nt = Nt(12, 32)
print 'one = %(x)s, two = %(y)s' % nt

# output should be:
one = 12, two = 32

currently, it is possible to use nt._asdict() as a workaround, but I
think it will be easier and more intuitive to be able to use namedtuple
directly with string interpolation.

I tried this with 2.6 and 2.7a (trunk). Haven't seen 3.0 yet.

PS: Although the following works, it is not the topic of the issue:
print 'one = %s, two = %s' % nt

--
components: Library (Lib)
messages: 81555
nosy: lieryan
severity: normal
status: open
title: String Formatting with namedtuple
type: feature request
versions: Python 2.7

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



[issue5205] String Formatting with namedtuple

2009-02-10 Thread Lie Ryan

Changes by Lie Ryan :


--
components: +Interpreter Core
versions: +Python 2.6

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



[issue7166] IDLE (python 3.1.1) syntax coloring for b'bytestring' and u'unicode' string literal

2009-10-18 Thread Lie Ryan

Changes by Lie Ryan :


--
versions: +Python 2.7, Python 3.2 -Python 3.1

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



[issue7166] IDLE (python 3.1.1) syntax coloring for b'bytestring' and u'unicode' string literal

2009-10-18 Thread Lie Ryan

New submission from Lie Ryan :

On python trunk and 3.2 IDLE, the b in b'' is not green colored.
On python 3.1 IDLE, the u in u'' is still colored, despite a SyntaxError.

(sorry, I don't have diff installed on my Windows machine)

Change on python trunk:
/Lib/idlelib/ColorDelegator.py
def make_pat():

sqstring = r"(\b[rRuUbB])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
dqstring = r'(\b[rRuUbB])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
sq3string = r"(\b[rRuUbB])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
dq3string = r'(\b[rRuUbB])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'



And on py3k branch:
/Lib/idlelib/ColorDelegator.py
def make_pat():

sqstring = r"(\b[rRbB])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
dqstring = r'(\b[rRbB])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
sq3string = r"(\b[rRbB])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
dq3string = r'(\b[rRbB])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'


--
components: IDLE
messages: 94222
nosy: lieryan
severity: normal
status: open
title: IDLE (python 3.1.1) syntax coloring for b'bytestring' and u'unicode' 
string literal
type: behavior
versions: Python 3.1

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



[issue7441] Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.

2009-12-05 Thread Lie Ryan

New submission from Lie Ryan :

maybe related to #6501

Vista 32-bit SP1, Python 3.1:
"""
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
D:\>chcp 65001
Active code page: 65001

D:\>python -c 'print("")'
Fatal Python error: Py_Initialize: can't initialize sys standard streams
LookupError: unknown encoding: cp65001

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
D:\>python
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
"""

Expected, either:
1. print nothing (""), or
2. python exception about unknown encoding, or
3. python exception about cannot encode to the encoding

cp65001 is supposed to be an alias for utf-8. Because of the error,
there is AFAICT no way to set the command prompt to accept utf-8 output
even for pipe redirection.

A workaround is to use sys.stdout.buffer.write() to write raw byte
strings, encoding manually. But this takes us back to python 2.

--
components: IO, Interpreter Core, Unicode, Windows
messages: 95987
nosy: lieryan
severity: normal
status: open
title: Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.
type: crash
versions: Python 3.1

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



[issue2312] Update PEP 3135 (super())

2009-03-11 Thread Lie Ryan

Lie Ryan  added the comment:

The possible new PEP 3135, however I'm not that familiar with the
implementation of the new super, thus please review whether it is "right
w.r.t. reality". I'm writing only from whatever I can determine from
observing the behavior of super in python 3.0.1

Probably not related, but while playing with super, I noticed several
things, I'm not sure about whether this is bug or design decision:
- super() in normal function is SystemError, instead of SyntaxError or a
more descriptive error

btw, is "__class__" related to "__this_class__" alt implementation? I
assume yes, so I removed the alt implementation for __this_class__

--
nosy: +lieryan
Added file: http://bugs.python.org/file13303/pep3135

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



[issue2312] Update PEP 3135 (super())

2009-03-11 Thread Lie Ryan

Lie Ryan  added the comment:

Here is the unified diff.

--
keywords: +patch
Added file: http://bugs.python.org/file13305/pep-3135.diff

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



[issue6021] itertools.grouper

2009-05-14 Thread Lie Ryan

New submission from Lie Ryan :

An itertool to Group-by-n 

>>> lst = range(15)
>>> itertools.grouper(lst, 5)
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]

This function is often asked in several c.l.py discussions, such as these: 
http://comments.gmane.org/gmane.comp.python.general/623377
http://comments.gmane.org/gmane.comp.python.general/622763

There are several issues. What should be done if the number of items in
the original list is not exactly divisible?
- raise an error as default
- pad with a value from 3rd argument
- make the last one shorter, maybe using keyword arguments or sentinel
to 3rd argument

or should there be separate functions for each of them?

What about infinite list? Most recipes for the function uses zip which
breaks with infinite list.

--
components: Library (Lib)
messages: 87743
nosy: lieryan
severity: normal
status: open
title: itertools.grouper
type: feature request

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



[issue6021] itertools.grouper

2009-05-14 Thread Lie Ryan

Lie Ryan  added the comment:

All implementations relying on zip or zip_longest breaks with infinite
iterable (e.g. itertools.count()).

And it is not impossible to define a clean, flexible, and familiar API
which will be similar to open()'s mode or unicode error mode. The modes
would be 'error' (default), 'pad', 'truncate', and 'partial' (maybe
should suggest a better name than 'partial')

> There is an issue with having too many itertools.  
> The module taken as a whole becomes more 
> difficult to use as new tools are added.

It should also be weighed that a lot of people are expecting for this
kind of function in itertools. I think there are other functions in
itertools that have more questionable value than groupers, such as starmap.

--

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



[issue6141] missing first argument on subprocess.Popen w/ executable

2009-05-29 Thread Lie Ryan

New submission from Lie Ryan :

Following from http://comments.gmane.org/gmane.comp.python.tutor/55576

>>> import subprocess
>>> subprocess.Popen(['a', 'b', 'c', 'd'], executable='echo')

b c d

instead of the (what I) expected result
a b c d

I suggests two possible change:
1. add another optional argument called displayed_executable (or
something similar) and make the arg argument contains only arguments
2. it is made clear in the documentation that the first argument is used
as executable display name

Since the first alternative is behavioral change, it couldn't possibly
go through already released version; therefore if it is the chosen
solution it would have to go to Python 2.7 and Python 3.2. 

Changing the documentation should be easier, although the problem will
persist for unsuspecting users; and even if the first alternative is
taken, perhaps documentation change should still be done retrospectively
(I don't know the policy on doc change on old python version)

It should be noted that I tested this only with Python 2.5 on Gentoo
(although from the discussion, I presumed this is considered a feature
and would have persisted in later versions). And at the time of this
writing, I have no idea how it behaves in Windows.

--
assignee: georg.brandl
components: Documentation, Library (Lib)
messages: 88504
nosy: georg.brandl, lieryan
severity: normal
status: open
title: missing first argument on subprocess.Popen w/ executable
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2

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



[issue6332] typo on man page warning control

2009-06-23 Thread Lie Ryan

New submission from Lie Ryan :

A minor typo on the man page

> -W argument
> ...
> such as inside a loop); module to print each warning *only only*
> ...

--
assignee: georg.brandl
components: Documentation
files: onlyonly.diff
keywords: patch
messages: 89645
nosy: georg.brandl, lieryan
severity: normal
status: open
title: typo on man page warning control
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file14349/onlyonly.diff

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



[issue6332] typo on man page warning control

2009-06-23 Thread Lie Ryan

Lie Ryan  added the comment:

Bored, I grepped the trunk for a few more stuffs that has similar
consecutive duplicate typos. The dup.diff patch corrects these typos.

Not opening a new issue since all of them are minor.

--
Added file: http://bugs.python.org/file14350/dup.diff

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