[issue46574] itertools.count should work with non-number types

2022-01-29 Thread Mital Ashok


New submission from Mital Ashok :

There's no reason that `count('', 'a')` for `'', 'a', 'aa', ...` or `count((), 
(1,))` for `(), (1,), (1, 1), ...` shouldn't work.

count(a, b) should be equivalent to accumulate(chain((a,), repeat(b)))

The docs don't strongly suggest that it won't work (it says *start* is a 
number, but the "roughly equivalent to" generator would work for str/tuple/etc)

--
components: Library (Lib)
messages: 412095
nosy: Mital Ashok
priority: normal
severity: normal
status: open
title: itertools.count should work with non-number types
type: enhancement
versions: Python 3.11

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



[issue30955] \\N in f-string causes next { to be literal if not escaped

2017-07-17 Thread Mital Ashok

New submission from Mital Ashok:

Take this format python code:

import unicodedata
c = chr(0x012345)

To print that character as a string literal, you would expect to do:

print(f"'\\N{{{unicodedata.name(c)}}}'")

Which should print a literal quote (`'`), a backwards slash (`\\` -> `\`), an 
`N`, and the two `{{` should escape and print `{`, followed by the f-expression 
`unicodedata.name(c)`, then the `}}` would print one `}`, and then another 
literal quote (`'`).

However, this raises a `SyntaxError: f-string: single '}' is not allowed`. The 
way to do this without a syntax error is like so:

print(f"'\\N{{unicodedata.name(c)}}}'")

Which prints the expected:

'\N{CUNEIFORM SIGN URU TIMES KI}'

The shortest way to reproduce this is:

f'\\N{'

Which works, and:

f'\\N{{'

which raises an error, even though the first one should raise an error 
(`SyntaxError: f-string: expecting '}'`).

--
messages: 298563
nosy: Mital Ashok
priority: normal
severity: normal
status: open
title: \\N in f-string causes next { to be literal if not escaped
versions: Python 3.6, Python 3.7

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



[issue24327] yield unpacking

2015-05-29 Thread Mital Ashok

New submission from Mital Ashok:

(This is more of a feature request than a bug, but 
https://www.python.org/dev/peps/pep-0042/ said to post it here)

My request is to have syntax like this:

yield *iterable

to lazily return the iterable's items, not much unlike:

# ...
for i in iterable:
yield i
# ...

This is because I constantly find myself yielding all the values in, say, a 
list, then modifying it and yielding it in a loop.

--
messages: 244397
nosy: Mital Ashok
priority: normal
severity: normal
status: open
title: yield unpacking
type: enhancement
versions: Python 3.6

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