Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-16 Thread Elazar
You might also be interested in pep-563 . although it is not intended for design by contract, it can help (syntactically). Elazar On Wed, Aug 15, 2018 at 11:07 PM Marko Ristin-Kaufmann < marko.ris...@gmail.com> wrote: > Hi, > > I would be very

[Python-ideas] Hi!

2018-08-16 Thread Marko Ristin-Kaufmann
Hi, Please let me briefly introduce myself. I'm Marko and live in Zurich, Switzerland. I learned Python and Django during an intership in 2007 and followed its development ever since. I did research in computer vision (at ETH Zurich) and now I work at Parquery AG (Zurich, Switzerland) where we

[Python-ideas] Pre-conditions and post-conditions

2018-08-16 Thread Marko Ristin-Kaufmann
Hi, I would be very interested to bring design-by-contract into python 3. I find design-by-contract particularly interesting and indispensable for larger projects and automatic generation of unit tests. I looked at some of the packages found on pypi and also we rolled our own solution

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Steven D'Aprano
On Wed, Aug 15, 2018 at 09:58:28PM -0400, David Mertz wrote: > When did you last read the Dijkstra paper. It's short and he explains very > well why exactly all the constructs you mention are unlike Goto. Of course I've read it, and no he does not. He only mentions if...else and looping. He

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Brice Parent
If I understand well the need (I'm unsure I've had it myself), it would be easier to be able to import the function in the active context, like this: def foo(a):     return a + c def bar(a, c):     return foo(a) def bazz(a, c):     import __file__.foo     return foo(a) c = 5 call = bar(1,

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-16 Thread Jonathan Fine
Hi Marko Thank you for introducing yourself, and clearly stating your question. That helps us all. You asked: > Could somebody update me on the state of the discussion on this matter? I think bring the existing PEP up to date would be a good starting point. Its content hasn't been changed since

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-16 Thread Paul Moore
On Thu, 16 Aug 2018 at 10:41, Jonathan Fine wrote: > > Hi Marko > > Thank you for introducing yourself, and clearly stating your question. > That helps us all. You asked: > > > Could somebody update me on the state of the discussion on this matter? > > I think bring the existing PEP up to date

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Rhodri James
On 15/08/18 19:55, Jonathan Fine wrote: Rhodri says my version, exaggerated for effect, reads like Sometimes a value is required. But (pay careful attention to this, it's important and there will be a quiz later) we're not able to provide one. Yes, Rhodri, you've understood what I'm doing. I

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Jonathan Fine
Hi Neil Thank you for your post, regarding https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy. You've suggested changing "built-in name None" to "keyword None". I think that's a good change. And similar changes might be welcome elsewhere in the docs, perhaps also for

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Jonathan Fine
Hi Rhodri Thank you for your message. You wrote: > I disagree. That original text looks like it has been very carefully > written to be (almost) true. What you are proposing to replace it with is > less true and confusing to boot. The decision is neither your's nor mine. It is for the Python

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Paul Moore
On Thu, 16 Aug 2018 at 15:28, Jonathan Fine wrote: > I'd like to take this to bugs.python.org, if only to provide another > route to discovering this (very useful) conversation. That's perfectly OK, and entirely your choice. However, if you do so, I'd hope that you present the dissenting views

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Neil Girdhar
Is None a builtin? In [1]: from keyword import kwlist In [3]: 'Ellipsis' in kwlist Out[3]: False In [4]: 'None' in kwlist Out[4]: True Maybe we should change This type has a single value. There is a single object with this value. This object is accessed through the built-in name None. It is

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Jonathan Fine
Hi Paul Thank you for your comments. I think different people experience things in different ways, based on who they are. What their background, training, experience are. One person's precision is another's pedantry. An aside. Babbage and Tennyson: https://www.uh.edu/engines/epi879.htm You

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Rhodri James
On 16/08/18 14:04, Jonathan Fine wrote: And I think there's more. The page says None This type has a single value. There is a single object with this value. [...] I think it better to write NoneType This type has a single value, `None`. The keyword `None` always gives the value `None`. I

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Paul Moore
On Thu, 16 Aug 2018 at 14:26, Rhodri James wrote: > > On 16/08/18 14:04, Jonathan Fine wrote: > > And I think there's more. The page says > >> None > >> This type has a single value. There is a single object with this value. > >> [...] > > I think it better to write > >> NoneType > >> This type

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Rhodri James
On 16/08/18 14:41, Jonathan Fine wrote: Hi Rhodri Thank you for your message. You wrote: I disagree. That original text looks like it has been very carefully written to be (almost) true. What you are proposing to replace it with is less true and confusing to boot. The decision is neither

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 1:28 AM, Steven D'Aprano wrote: > there > are times where I have really wanted to access the caller's environment, > not the environment where my function was defined. > what am I missing? can't you get that by passing locals() in to a function? A bit clunky, sure, but

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Jonathan Fine
Hi Chris Steve and you wrote: >> there >> are times where I have really wanted to access the caller's environment, >> not the environment where my function was defined. > what am I missing? can't you get that by passing locals() in to a function? I think this will fail when values are changed.

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-16 Thread Marko Ristin-Kaufmann
Hi Jonathan and Paul, Thank you very much for your suggestions! I will try to contact the author of the PEP. Let me clarify a bit a potential misunderstanding. Please mind that contracts are not tied to individual variables, but to expressions. Think of it as defining a lambda which takes as

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Jonathan Fine
Hi Paul We wrote >> I'd like to take this to bugs.python.org, if only to provide another >> route to discovering this (very useful) conversation. > > That's perfectly OK, and entirely your choice. However, if you do so, > I'd hope that you present the dissenting views from this list when you >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Jacob Solinsky
On Thu, 16 Aug 2018, 12:44 Jacob Solinsky, wrote: > I wanted the called, jumped to function to change state in the caller. > From what I tried to do, passing locals() cannot accomplish this. I have > made it happen in other languages though. > In the R language, one can do this > > foo =

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Stephen J. Turnbull
tl;dr A pedantic note on dynamic binding. Steven D'Aprano writes: > The most common language today that uses dynamic scoping is probably > Emacs Lisp. AFAIK all Common-Lisp-ish languages implement dynamic scoping: anything defvar'd is dynamically-scoped. > Although dynamic scoping is very

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Jonathan Fine
Hi Jacob I really like your previous post. I find it really helps me understand what you want. You wrote > I wanted the called, jumped to function to change state in the caller. > From what I tried to do, passing locals() cannot accomplish this. I have > made it happen in other languages though.

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Stephen J. Turnbull
Jacob Solinsky writes: > What I had hoped to do was use a preamble code block to collect all of the > most common queries called by the mutate function in the local namespace, > for example > > C = 'bpgkdtszSZjCmnywh' > M = 'mn' > > > class Morpheme: > #stuff > > def

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Steven D'Aprano
On Thu, Aug 16, 2018 at 10:31:28AM +0200, Brice Parent wrote: > If I understand well the need (I'm unsure I've had it myself), it would > be easier to be able to import the function in the active context, like > this: > > def foo(a): >     return a + c > > def bar(a, c): >     return foo(a) >

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
one more thought: given that: > > The contents of this dictionary should not be modified; changes may not >> affect the values of local and free variables used by the interpreter. >> > > and: > """ > locals() > > Update and return a dictionary representing the current local symbol table. > I

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Angelico
On Fri, Aug 17, 2018 at 5:32 AM, Chris Barker via Python-ideas wrote: > hmm -- made me think that generators are doing something different here -- > and indeed they are. If you use regular functions: > > In [30]: def local_modifying(loc): > ...: """ > ...: adds a "fred" key to the

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Steven D'Aprano
On Thu, Aug 16, 2018 at 09:34:57AM -0700, Chris Barker wrote: > On Thu, Aug 16, 2018 at 1:28 AM, Steven D'Aprano > wrote: > > > there > > are times where I have really wanted to access the caller's environment, > > not the environment where my function was defined. > > > > what am I missing?

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 10:33 AM, Jonathan Fine wrote: > >> there > >> are times where I have really wanted to access the caller's environment, > >> not the environment where my function was defined. > > > what am I missing? can't you get that by passing locals() in to a > function? > > I think