Re: [Python-ideas] String Format Callable Flag (Was: Efficient Debug Logging)

2017-02-19 Thread Pavol Lisy
On 2/19/17, Eric V. Smith wrote: > On 2/18/2017 2:25 AM, Steven D'Aprano wrote: >> I see three problems: >> >> (1) It will be a bug magnet. People will accidently write >> >> logging.debug('%03d %C03d', 1, expensive()) >> >> >> and then not only will their code still be slow, but they'll have

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Sven R. Kunze
I would like to add another view of this feature might be very useful for cleaning up existing code bases: Just have a look at https://pypi.org/project/xfork/ and specifically I would like to point you to the following lines https://github.com/srkunze/fork/blob/afecde0/fork.py#L216 till #419.

Re: [Python-ideas] More classical for-loop

2017-02-19 Thread Steven D'Aprano
On Sun, Feb 19, 2017 at 03:58:56AM +0100, Mikhail V wrote: > Right after that however, pure physics comes in play. > So memorizing a visual pattern happens in some minutes > of active reading, but further reading lasts "till final victory". You think that learning to read is "pure physics". That'

Re: [Python-ideas] Light-weight call-by-name syntax in Python

2017-02-19 Thread Ed Kellett
On Fri, 17 Feb 2017 at 10:23 Stephan Houben wrote: > Proposal: Light-weight call-by-name syntax in Python > > The following syntax > a : b > is to be interpreted as: > a(lambda: b) > > Effectively, this gives a "light-weight macro system" to Python, > since it allows with little syn

Re: [Python-ideas] String Format Callable Flag (Was: Efficient Debug Logging)

2017-02-19 Thread Eric V. Smith
On 2/19/2017 4:23 AM, Pavol Lisy wrote: On 2/19/17, Eric V. Smith wrote: On 2/18/2017 2:25 AM, Steven D'Aprano wrote: I see three problems: (1) It will be a bug magnet. People will accidently write logging.debug('%03d %C03d', 1, expensive()) and then not only will their code still be

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Michel Desmoulin
A great proposal, although now I would have to explain to my students the subtle difference between: res = (print(i * i) for i in range(x)) print('foo') print(res) And res = delayed [print(i * i) for i in range(x)] print('foo') all(res) They seems doing something similar, but they really don't.

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread David Mertz
On Sun, Feb 19, 2017 at 8:24 AM, Michel Desmoulin wrote: > A great proposal, although now I would have to explain to my students > the subtle difference between: > > res = (print(i * i) for i in range(x)) > res = delayed [print(i * i) for i in range(x)] > They seems doing something similar, bu

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Michel Desmoulin
> > One last thing: my vote is not dropping the ":" in front of they > keyword. > > > I think the colon has parser problems, as I showed in some examples. > Plus I don't like how it looks. But I'd much rather have `a = lazy: > stuff` than not have the construct at all, nonetheless. >

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Joseph Hackman
Michel- Thanks for the feedback! On 19 February 2017 at 11:24, Michel Desmoulin wrote: > A great proposal, although now I would have to explain to my students > the subtle difference between: > > res = (print(i * i) for i in range(x)) > print('foo') > print(res) > > And > > res = delayed [prin

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread David Mertz
On Sun, Feb 19, 2017 at 10:13 AM, Joseph Hackman wrote: > > My honest preference would be that the [] is evaluated fresh each time the > function is called. > def stuff(arg=delayed f()): > would result in f() being called every time stuff() is. This seems more > valuable to me than just doing it o

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Joseph Hackman
> > This doesn't make sense. Function definition time is very different than > function execution time. Changing that distinction is a WAY bigger change > than I think we should contemplate. > Moreover, there is a completely obvious way to spell the behavior you want: > def stuff(): > arg = f

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread David Mertz
On Sun, Feb 19, 2017 at 10:47 AM, Joseph Hackman wrote: > Your argument has convinced me, and I now take (what i believe to be) your >> position: >> > > def stuff(arg = lazy f()): > > should result in a function where the default value of arg is not > evaluated until first function call, and then

Re: [Python-ideas] More classical for-loop

2017-02-19 Thread Mikhail V
On 19 February 2017 at 12:29, Steven D'Aprano wrote: > > Please tell us the optics formula used to determine the optical > "goodness" and "badness" of a word. I want to see this physics formula > that tells us how good or bad a word is "optically", and I want to know > the names of at least a doze

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Pavol Lisy
On 2/19/17, David Mertz wrote: > On Sun, Feb 19, 2017 at 10:13 AM, Joseph Hackman > wrote: >> >> My honest preference would be that the [] is evaluated fresh each time >> the >> function is called. >> def stuff(arg=delayed f()): >> would result in f() being called every time stuff() is. This seem

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-19 Thread Pavol Lisy
On 2/19/17, Michel Desmoulin wrote: > Evnetually we also may need to allow this: > > a = lazy stuff > if a is not lazy: > print(a) > > But then lazy can't be used a var name to help with the transition. What about this? if not inspect.islazy(a): print(a) Next idea is probably obvious: