On Sun, Feb 12, 2017, at 21:55, Steven D'Aprano wrote:
> But honestly, no. This is not going to happen. .Net VB and C# have
> something like this, as does Lua, and people still write classes the
> ordinary way 99.99% of the time.
The VB/C# thing you are referring to is, I assume, extension
On 15 February 2017 at 00:41, Nick Timkovich
wrote:
> Make some shim object that you can index into to get that functionality,
> could even call it Z (for the set of all integers). Short, and requires no
> new syntax.
>
> class IndexableRange:
> def __getitem__(self,
Make some shim object that you can index into to get that functionality,
could even call it Z (for the set of all integers). Short, and requires no
new syntax.
class IndexableRange:
def __getitem__(self, item):
if isinstance(item, slice):
start = item.start if item.start
On 14 February 2017 at 22:41, MRAB wrote:
> On 2017-02-14 21:09, Zachary Ware wrote:
>
>> On Tue, Feb 14, 2017 at 3:06 PM, Mikhail V wrote:
>>
>>> I have a small syntax idea.
>>> In short, contraction of
>>>
>>> for x in range(a,b,c) :
>>>
>>>
> On 14 Feb 2017, at 17:03, Cory Benfield wrote:
>
>
>> On 14 Feb 2017, at 15:51, Barry Scott wrote:
>> And have the evaluation of the argument skipped unless its dbg_log is
>> enabled.
>>
>> I cannot see how to do this with python as it stands.
>>
> On 14 Feb 2017, at 17:39, Kyle Lahnakoski wrote:
>
>
> Can you wrap the expensive functions in lambdas? And have your logger
> evaluate it, only if required?
>
>> debugLog( ‘info is %r’ % (lambda: expensiveFunction(),) )
Interesting idea. I will bench mark and see
There are several mechanisms in the logging module to handle this use-case.
First, note that logging functions can take multiple arguments (
https://docs.python.org/3/library/logging.html?highlight=logging#logging.Logger.debug
):
>>> import logging
>>> msg = "hello, %s! %s to %s you!"
>>> args =
for i in range(...) is *sometimes* indicative of code smell, especially
when then doing x[i], though it has its uses. I've never had a need to
shorten a for...range line though.
Other than it being "cute", do you have an example where it's definitively
better?
On Tue, Feb 14, 2017 at 4:03 PM,
On Tue, Feb 14, 2017 at 4:41 PM, MRAB wrote:
> On 2017-02-14 21:09, Zachary Ware wrote:
>
>> On Tue, Feb 14, 2017 at 3:06 PM, Mikhail V wrote:
>>
>>> I have a small syntax idea.
>>> In short, contraction of
>>>
>>> for x in range(a,b,c) :
>>>
On Feb 14, 2017, at 12:48 PM, Steven D'Aprano wrote:
>On Fri, Feb 10, 2017 at 09:05:49PM -0500, Terry Reedy wrote:
>> Saving about 10 keystrokes is close to trivial.
>
>The same argument can be made for @decorator syntax.
>
>And, if I understand correctly, the same argument *was* made against
I would be surprised if this hasn't been suggested many times before. It's
similar to Matlab's syntax:
for x = start:step:finish
end
Any such change would represent a large departure from normal python syntax
for dubious gain. In general, you can put any expression after the `in`
keyword so
On Tue, Feb 14, 2017 at 3:06 PM, Mikhail V wrote:
> I have a small syntax idea.
> In short, contraction of
>
> for x in range(a,b,c) :
>
> to
>
> for x in a,b,c :
>
> I really think there is something cute in it.
> So like a shortcut for range() which works only in for-in
I have a small syntax idea.
In short, contraction of
for x in range(a,b,c) :
to
for x in a,b,c :
I really think there is something cute in it.
So like a shortcut for range() which works only in for-in statement.
So from syntactical POV, do you find it nice syntax?
Visually it seems to me less
On 2017-02-14 15:51, Barry Scott wrote:
A common pattern I use is to have logging calls for debug and information with
my applications.
The logging calls can be separately enabled and disabled.
For example:
debug_log_enabled = False
def debugLog( msg ):
If debug_log_enabled:
Seems slightly simpler to just make debugLog accept a callable as an
alternative to a string.
debugLog(lambda:( ‘info is %s’ % expensiveFunction()) )
Op 14 feb. 2017 18:42 schreef "Kyle Lahnakoski" :
Can you wrap the expensive functions in lambdas? And have your
Can you wrap the expensive functions in lambdas? And have your logger
evaluate it, only if required?
> debugLog( ‘info is %r’ % (lambda: expensiveFunction(),) )
On 2017-02-14 10:51, Barry Scott wrote:
> A common pattern I use is to have logging calls for debug and information
> with my
> On 14 Feb 2017, at 15:51, Barry Scott wrote:
> And have the evaluation of the argument skipped unless its dbg_log is enabled.
>
> I cannot see how to do this with python as it stands.
>
> Something would have to be added to allow python to short circuit the
>
17 matches
Mail list logo