Re: Assignment versus binding

2016-10-04 Thread Chris Angelico
On Wed, Oct 5, 2016 at 5:19 PM, Rustom Mody  wrote:
> Its ironical:
> - Function in Fortran was meant to emulate math-functions
> - C took the same thing and did a ‘small little syntax elision’ viz
> conflating function and subprogram (procedure in Pascal speak) all under
> the heading of function. In Pascal it was certainly a publicised intent
> to sharply distinguish functions — no side-effects — from procedures — no 
> return value.
> - Finally this abuse of notation (and notions) has become such a norm 
> (normal!)
> that people are surprised to find non-abusive languages!

So how do you handle something that, by its nature, has BOTH side
effects and a return value? For instance, writing to a socket has
three results:

1) Data is sent to the socket (side effect), possibly with consequent
changes to visible state
2) Status return saying how much was written
3) Possible error return in the event of failure.

#3 aligns fairly nicely with exceptions, although that doesn't easily
handle the possibility that some data was written prior to the error
occurring. #2 has to be some sort of return value, unless you simply
declare that writing anything less than the full data is an error, and
fold it into exception handling. And thanks to #1, it can't be a pure
function, because you aren't allowed to optimize it away (writing
"spam" to the socket twice is not the same as writing it once and
returning 4 to both callers).

The real world is not pure.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Chris Angelico
On Wed, Oct 5, 2016 at 5:17 PM, Gregory Ewing
 wrote:
> Chris Angelico wrote:
>>
>> Seriously though... this ties in with the other issues about *purely*
>> functional languages being rather impractical, and the purity
>> generally being sullied some by things like monads (which I still
>> don't understand, despite the explanations in another thread).
>
>
> If you'd like to understand better, I could put together
> an example that illustrates the basic idea behind monads
> using Python. It's really not that hard; it only seems
> hard because it's traditionally presented in a very
> abstract and mathematical way.
>
> In the process, I think I could also answer your earlier
> question about why automatic currying is considered such
> a good idea.

Wasn't my question, but sure, would be happy to hear about that. How
do you handle variadic functions?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5 amd64 and win32service

2016-10-04 Thread eryk sun
On Wed, Oct 5, 2016 at 6:18 AM, Nagy László Zsolt  wrote:
> But again, that is not related to the question. Why does it not work?
> What is missing?

If you mean why running the service doesn't work, it should once you
run the post-install script that copies pywintypes35.dll to the
Windows System32 directory. This DLL is required by PythonService.exe.
It fails to start without it. After running the post-install script,
run `where pywintypes35.dll` to verify that it was copied correctly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Rustom Mody
On Wednesday, October 5, 2016 at 11:34:31 AM UTC+5:30, Gregory Ewing wrote:
> Steve D'Aprano wrote:
> 
> > And (shamelessly using Python syntax) if I have a function:
> > 
> > def spam(x):
> > print(x)
> > print(x+1)
>  >
>  > spam(time.sleep(60) or 1)
> 
> You can't write that in Haskell, because Haskell's
> equivalent of print() is not a function (or at least
> it's not a function that ever returns), and neither
> is sleep().

Its ironical:
- Function in Fortran was meant to emulate math-functions
- C took the same thing and did a ‘small little syntax elision’ viz
conflating function and subprogram (procedure in Pascal speak) all under
the heading of function. In Pascal it was certainly a publicised intent
to sharply distinguish functions — no side-effects — from procedures — no 
return value.
- Finally this abuse of notation (and notions) has become such a norm (normal!)
that people are surprised to find non-abusive languages!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Gregory Ewing

Chris Angelico wrote:

Seriously though... this ties in with the other issues about *purely*
functional languages being rather impractical, and the purity
generally being sullied some by things like monads (which I still
don't understand, despite the explanations in another thread).


If you'd like to understand better, I could put together
an example that illustrates the basic idea behind monads
using Python. It's really not that hard; it only seems
hard because it's traditionally presented in a very
abstract and mathematical way.

In the process, I think I could also answer your earlier
question about why automatic currying is considered such
a good idea.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5 amd64 and win32service

2016-10-04 Thread Nagy László Zsolt

>> def main(self):
>> self.ReportServiceStatus(win32service.SERVICE_RUNNING)
>> while not self.stop_requested.is_set():
>> time.sleep(1)  # So something useful here
> Why don't you use the Windows Event (hWaitStop) with
> WaitForSingleObject instead of an additional threading.Event?

The main question is: why does this work? What should be different?

About why I use a threading Event instead instead of a Windows event -
production code is similar to this:

 def main(self):
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
worker = Worker(self.stop_requested)
worker.join()


The worker class does the real job.  The win32 service code is only a
wrapper around it. The service can also be started from unix (with an rc
script). In the unix style application, there is another wrapper that
sets up signal handlers, writes out a pid file and starts the same
worker object. The worker must work on both platforms, this is why I
must use platform independent object.

But again, that is not related to the question. Why does it not work?
What is missing?

Thanks,

  Laszlo




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Gregory Ewing

Chris Angelico wrote:

So what
happens if you have a monad "print to the console" in place of Steve's
time.sleep example? Will you get one execution of it or two?


Again, you wouldn't be able to write it that way in Haskell.

The things you *would* be able to write would all have the
property that, if there are two print operations being
done, they are either done by two different expressions or
by an expression being evaluated in two different
environments.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Gregory Ewing

Steve D'Aprano wrote:


And (shamelessly using Python syntax) if I have a function:

def spam(x):
print(x)
print(x+1)

>
> spam(time.sleep(60) or 1)

You can't write that in Haskell, because Haskell's
equivalent of print() is not a function (or at least
it's not a function that ever returns), and neither
is sleep().

It's hard to explain without going into a lot of
detail about monads, but if you tried to write that
in Haskell you would find that the type system,
together with the way the I/O "functions" are defined,
makes it impossible to write anything that uses the
return value of an expression that performs an I/O
operation. So "time.sleep(60) or 1" is unwriteable,
because the return value of the sleep() is not
accessible.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Rustom Mody
On Wednesday, October 5, 2016 at 6:22:45 AM UTC+5:30, Steve D'Aprano wrote:
> On Wed, 5 Oct 2016 04:12 am, Rustom Mody wrote:
> 
> > On Tuesday, October 4, 2016 at 10:06:00 PM UTC+5:30, Steve D'Aprano wrote:
> >> On Tue, 4 Oct 2016 09:32 pm, Rustom Mody wrote:
> >> 
> >> > Are not the contents of the scope and the shape of the scope different
> >> > things?
> >> 
> >> 
> >> What does "the shape of the scope" mean?
> >> 
> >> Scopes don't have a shape -- they aren't geometric objects. So I'm afraid
> >> I don't understand what distinction you are trying to make.
> > 
> > Ok I was speaking quasi metaphorically
> > If you have some non-metaphors please tell!
> 
> I think that by "shape" of the scope, you mean "some identifier or
> description which identifies the scope" -- e.g. "globals", "builtins",
> function foo, function bar, etc.

No
I want to talk of a higher level of collectivity than (what you are calling)
*one* scope

Something analogous to:
a = [1,2,3]
b = [[1,2,3]]
c = [1,[2,3]]
d = [1,[2],3]

“a,b,c,d have the same stuff, shaped (or whatever verb you like) differently”

eg How would you explain that with
e = ["p", "q", "r"]

a and e are same
and
a and b are same
with the two ‘sames’ being different?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read linux kernel source with pycparser (Reposting On Python-List Prohibited)

2016-10-04 Thread meInvent bbird
yes, i searched in google between 2011 and 2012

descending for loop is faster than ascending for loop

On Wednesday, October 5, 2016 at 9:48:41 AM UTC+8, Chris Angelico wrote:
> On Wed, Oct 5, 2016 at 12:41 PM, meInvent bbird  wrote:
> > so far i do not know which bug i search for
> >
> > i would like to change style of for loop
> >
> > form ascending to descending style
> >
> > for(int i=0; i<3; ++i)
> >
> > to
> >
> > for(int i=3; i>=0; --i)
> >
> > or
> >
> > most crazy to change if else if else into mealy machine
> 
> Are you aware that those loops are significantly different?
> 
> ChrisA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read linux kernel source with pycparser (Reposting On Python-List Prohibited)

2016-10-04 Thread Chris Angelico
On Wed, Oct 5, 2016 at 12:41 PM, meInvent bbird  wrote:
> so far i do not know which bug i search for
>
> i would like to change style of for loop
>
> form ascending to descending style
>
> for(int i=0; i<3; ++i)
>
> to
>
> for(int i=3; i>=0; --i)
>
> or
>
> most crazy to change if else if else into mealy machine

Are you aware that those loops are significantly different?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read linux kernel source with pycparser (Reposting On Python-List Prohibited)

2016-10-04 Thread meInvent bbird
On Wednesday, October 5, 2016 at 2:34:49 AM UTC+8, Lawrence D’Oliveiro wrote:
> On Tuesday, October 4, 2016 at 10:38:14 PM UTC+13, meInvent bbird wrote:
> > how to customize pycparser to search what we want such as bug 
> 
> What kind of bug do you want to search for?

so far i do not know which bug i search for

i would like to change style of for loop

form ascending to descending style

for(int i=0; i<3; ++i)

to

for(int i=3; i>=0; --i)

or 

most crazy to change if else if else into mealy machine
-- 
https://mail.python.org/mailman/listinfo/python-list


'str' object has no attribute 'intersection' and unhashable set

2016-10-04 Thread meInvent bbird
def consolidate(sets):
# http://rosettacode.org/wiki/Set_consolidation#Python:_Iterative
setlist = [s for s in sets if s]
for i, s1 in enumerate(setlist):
if s1:
for s2 in setlist[i+1:]:
intersection = s1.intersection(s2)
if intersection:
s2.update(s1)
s1.clear()
s1 = s2
return [s for s in setlist if s]

def wrapper(seqs):
consolidated = consolidate(map(set, seqs))
groupmap = {x: i for i,seq in enumerate(consolidated) for x in seq}
output = {}
for seq in seqs:
target = output.setdefault(groupmap[seq[0]], [])
target.append(seq)
return list(output.values())

with open("testing1.txt", "r") as myfile:
content = myfile.readlines()
gr = [['']]
for ii in range(0,500):
try:
gr = [[content[ii]]] + gr
except:
print "error" + str(content[ii])
#groups = wrapper(content)
for i, group in enumerate(wrapper(gr)):
print('g{}:'.format(i), group)
print("\n")

Traceback (most recent call last):
  File "", line 10, in 
  File "", line 2, in wrapper
  File "", line 7, in consolidate
AttributeError: 'str' object has no attribute 'intersection'

>>> content[1]
'1,[(-1, 1, -2), (2, -1/2, 1)]\n'
>>> content[2]
'0,[(1, 0, 0)]\n'
>>> content[3]
'1,[(1, 0, 1)]\n'
>>> content[4]
'1,[]\n'
>>> content[5]
'1,[]\n'


then i try to edit to
gr = [[set(content[ii])]] + gr

it return unhashable type 'set'

just would like to search all repeatable pattern for a group of lines
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
On Wed, 5 Oct 2016 04:12 am, Rustom Mody wrote:

> On Tuesday, October 4, 2016 at 10:06:00 PM UTC+5:30, Steve D'Aprano wrote:
>> On Tue, 4 Oct 2016 09:32 pm, Rustom Mody wrote:
>> 
>> > Are not the contents of the scope and the shape of the scope different
>> > things?
>> 
>> 
>> What does "the shape of the scope" mean?
>> 
>> Scopes don't have a shape -- they aren't geometric objects. So I'm afraid
>> I don't understand what distinction you are trying to make.
> 
> Ok I was speaking quasi metaphorically
> If you have some non-metaphors please tell!

I think that by "shape" of the scope, you mean "some identifier or
description which identifies the scope" -- e.g. "globals", "builtins",
function foo, function bar, etc.


> Take the basic 'content':
> x = 1
> y = 2
> z = 3
> 
> A. Occuring exactly as above at module level
> B. Occuring exactly as above inside a function
> C. Occuring thus
> x = 1
> foo(2,3)
> 
> def foo(y,z):
> ...
> 
> D.
> def foo():
>   x = 1
>   def bar():
>  y, z = 2,3
> ...
> 
> E.
> def foo():
>   x = 1
>   bar(2,3)
>   ...
> 
> def bar(y,z):
>   ...
> 
> 
> In A,B,C,D,E at some point there's x,y,z having values (contents) 1,2,3
> How do you distinguish them?

By which variables (name bindings) exist in which scopes.


A: all three names 'x', 'y' and 'z' exist in the module scope, i.e. are
globals.

B: all three names 'x', 'y' and 'z' exist in some (unknown) local function
scope.

C: 'x' is a global, 'y' and 'z' are locals of foo.

D: 'x' is a local of foo, 'y' and 'z' are locals of bar, where bar is nested
within foo.

E: 'x' is a local of foo, 'y' and 'z' are locals of bar, where foo and bar
exist in the same (global) scope.


Since the functions (unknown), foo, bar and other bar are themselves names,
to distinguish them you need to know which scope they come from. One of the
bars comes from foo's local namespace, the others are globals.


> I call it the shape of the scope (or environment or bindings or namespace
> or ...???)
> 
> You have a better descriptor for the idea?

The name of the scope.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
On Wed, 5 Oct 2016 06:10 am, Marko Rauhamaa wrote:

> Steve D'Aprano :
> 
>> On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote:
>>
>>> Haskell defines let (it's version of multiple mutually recursive
>>> bindings) in terms of the least fix point of a lambda function whose
>>> (pattern) parameter binds the expressions in the definitions.
>>
>> It binds *the expression* itself? Not the value of the expression?
> 
> Don't know about Haskell, but in a truly functional programming language
> it wouldn't make a difference.

Unfortunately, there is no such thing as a "truly functional language",
because:

> A truly functional programming language wouldn't have side effects (in
> this case, it wouldn't sleep).

any real language[1] must perform computation, and computation has side-
effects: memory is used, power is consumed, the CPU warms up, and most
relevant to my example, calculations take time.

If you don't like my example of time.sleep(60) or 1, replace it by a very
long, very difficult, very time-consuming calculation that eventually
returns 1.

The point is, as Rustom explained, Haskell's evaluation strategy is
call-by-need which delays the evaluation of the expression but then caches
the result so it need only be evaluated once.



[1] That is, an interpreter or compiler for a programming language.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read linux kernel source with pycparser

2016-10-04 Thread Michael Torrie
On 10/04/2016 03:36 AM, meInvent bbird wrote:
> i expect to use pycparser to read linux kernel source
> and get a AST tree, 
> 
> but there are so many directory, 
> 
> how to read linux kernel source with pycparser?
> 
> how to customize pycparser to search what we want such as bug or fix 
> to make a linux patch for linux kernel source with python?

C projects with many .c files aren't meant to be compiled into one unit
(AST) usually.  The kernel is designed to be compiled into many
discrete, compiled object files which are then linked together after
compilation.  Each compilation unit would come from its own AST tree.
Furthermore, most C files can't be parsed by a compiler or parser at all
until the preprocessor has run over it first to handle the many
#define's, #if's, etc.  Fortunately you can run the preprocessor by
itself and output the bare C code.  On gcc I think if you pass -E it
will output the processed code.  Or use the cpp binary, which is
normally invoked by the compiler.

Another thing that will make this very difficult (and is related to the
preprocessor stuff) is that the Linux kernel's compilation can take many
different paths depending on how you configure the kernel. Some parts
may be skipped over entirely, other parts depend on which platform you
are configuring it for.

You could probably do this, and get lots of ASTs you can look at, but
you'll have to do some heavy-duty scripting and modification of
Makefiles to get it to happen in any sort of automatic way.  You make be
able to modify the Makefiles to have GCC itself dump the parse trees as
it creates them. I know GCC can do this. This is really the only
practical way I can see.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Marko Rauhamaa
Ben Bacarisse :
> The question came up because (I paraphrase) "even Scheme uses
> assignment to explain mutually recursive definitions". Haskell defines
> them using the fixed point operator. It's not really about Haskell
> programs so much as how the language features are defined.

BTW, here's the relevant definition (http://www.schemers.org/Docum
ents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.2.2>):

   library syntax:  (letrec  )

   [...]

   Semantics: The s are bound to fresh locations holding
   undefined values, the s are evaluated in the resulting
   environment (in some unspecified order), each  is assigned
   to the result of the corresponding , the  is evaluated in
   the resulting environment, and the value(s) of the last expression in
is(are) returned. Each binding of a  has the entire
   letrec expression as its region, making it possible to define
   mutually recursive procedures.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Ben Bacarisse
Steve D'Aprano  writes:

> On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote:
>
>> Haskell defines let (it's version of multiple mutually recursive
>> bindings) in terms of the least fix point of a lambda function whose
>> (pattern) parameter binds the expressions in the definitions.
>
> It binds *the expression* itself? Not the value of the expression?

Yes and no.  The result is as if the value is bound, but (a) Haskell is
lazy so in some sense it is the expression that is bound and (b) this is
a definition of the semantics, not Haskell itself.  The least fixed
point operator has the effect of binding all the names in the expression
to the result of binding all the names in expression to the result of
binding all the names in the expression to the result of...

In effect I'm not entirely sure how to answer your question (but I
repeat that this is how a syntactic feature is defined, not how you
write Haskell).

> So Haskell uses some form of pass by name?

No, just lazy evaluation.

> And (shamelessly using Python syntax) if I have a function:
>
>
> def spam(x):
> print(x)
> print(x+1)
>
>
> and then call it:
>
> spam(time.sleep(60) or 1)
>
>
> it will sleep for 60 seconds, print 1, then sleep for another 60 seconds,
> then print 2. Is that right?

Because Haskell is a Lazy language, the argument is not evaluated at the
point of call -- it's only evaluated when x is needed.  That part is
like call by name and "binding the expression and not the value".  But
because it is also a purely function language, the result of an
evaluation must always be the same, so the expression, once evaluated is
not evaluated again, and in that sense it's not like call by name.

The question came up because (I paraphrase) "even Scheme uses
assignment to explain mutually recursive definitions".  Haskell defines
them using the fixed point operator.  It's not really about Haskell
programs so much as how the language features are defined.

-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Chris Angelico
On Wed, Oct 5, 2016 at 6:10 AM, Marko Rauhamaa  wrote:
> A truly functional programming language wouldn't have side effects (in
> this case, it wouldn't sleep).

That makes sense. When people are sleeping, they're non-functional,
ergo a programming language that can sleep is non-functional :)

Seriously though... this ties in with the other issues about *purely*
functional languages being rather impractical, and the purity
generally being sullied some by things like monads (which I still
don't understand, despite the explanations in another thread). So what
happens if you have a monad "print to the console" in place of Steve's
time.sleep example? Will you get one execution of it or two?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Marko Rauhamaa
Steve D'Aprano :

> On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote:
>
>> Haskell defines let (it's version of multiple mutually recursive
>> bindings) in terms of the least fix point of a lambda function whose
>> (pattern) parameter binds the expressions in the definitions.
>
> It binds *the expression* itself? Not the value of the expression?

Don't know about Haskell, but in a truly functional programming language
it wouldn't make a difference.

> And (shamelessly using Python syntax) if I have a function:
>
> def spam(x):
> print(x)
> print(x+1)
>
> and then call it:
>
> spam(time.sleep(60) or 1)
>
> it will sleep for 60 seconds, print 1, then sleep for another 60 seconds,
> then print 2. Is that right?

A truly functional programming language wouldn't have side effects (in
this case, it wouldn't sleep).


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: rocket simulation game with just using tkinter

2016-10-04 Thread Irmen de Jong
On 4-10-2016 10:20, Christian Gollwitzer wrote:

> Thanks! It works now with the cursor keys as intended. I'm still having 
> trouble, but
> only because my game playing skills are not very good ;)

Have you managed to land the rocket again at all after a takeoff?
You can practice landing a bit by touching down anywhere on the ground, for 
instance
just a little bit to the right of the starting launchpad.
The real challenge is of course to land it on the other launchpad without 
touchdowns in
between.


>> Also I've discovered that there seems to be an issue with some Tkinter 
>> versions; it
>> sometimes doesn't update the screen fast enough. On OSX this problem is not 
>> present but
>> it is on Python 2.7 on Windows for example. I don't know what is causing it 
>> or how to
>> fix it at this time.   The FPS counter in the top right of the window should 
>> say 30,
>> that is when the game is updating at the intended speed.
> 
> Maybe if the system is simply too slow for your intended speed ?

Python 2.7 on my windows box shows the slow update behavior, while Python 3.5 
on the
same windows box runs fine at 30 fps (or even 60 if you tell it to).
I concluded that it is an implementation problem.

> I see that you are
> using after_idle if the delay is less than 1 ms. after_idle performs a 
> different task
> than after. I think, instead you should skip frames, i.e. compute how many 
> frames you
> are behind the clock and advance the physics by that and draw the next frame 
> instead.
> Otherwise the delay might build up.

Yes you're right but the computer is not too slow I believe, see above.

> The drawing itself has also different speed on different system. And, the 
> canvas is not
> intended to redraw everything on each frame. Instead, updating the objects 
> using the
> coords() method is usually faster. (It should also be easier)

I didn't want to tie it too much to the implementation details of Tkinter 
canvases.
Usually I think games have some graphics area that has to be redrawn every 
frame.
That, and Tkinter canvas cannot rotate a polygon so I have to redraw the rocket 
anyway!

Thanks for your interest in this little game :)
Irmen

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Rustom Mody
On Tuesday, October 4, 2016 at 10:15:10 PM UTC+5:30, Steve D'Aprano wrote:
> On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote:
> 
> > Haskell defines let (it's version of multiple mutually recursive
> > bindings) in terms of the least fix point of a lambda function whose
> > (pattern) parameter binds the expressions in the definitions.
> 
> It binds *the expression* itself? Not the value of the expression?


Lazy evaluation — one of the more touted features of Haskell — uses call-by-need
which is like memoized call-by-name:
https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_need
> 
> So Haskell uses some form of pass by name?
> 
> And (shamelessly using Python syntax) if I have a function:
> 
> 
> def spam(x):
> print(x)
> print(x+1)
> 
> 
> and then call it:
> 
> spam(time.sleep(60) or 1)
> 
> 
> it will sleep for 60 seconds, print 1, then sleep for another 60 seconds,
> then print 2. Is that right?


Strong type system would not allow mixing of effects and values like that
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-04 Thread Albert-Jan Roskam

(Sorry for top-posting)

Yep, part of the baby's hardware. Also, the interface is not limited to visual 
and auditory information:
http://www.scientificamerican.com/article/pheromones-sex-lives/

From: Python-list  on 
behalf of Steven D'Aprano 
Sent: Tuesday, October 4, 2016 7:00:48 AM
To: python-list@python.org
Subject: Re: Is that forwards first or backwards first? (Re: unintuitive 
for-loop behavior)

On Tuesday 04 October 2016 14:51, Michael Torrie wrote:

> On 10/03/2016 08:21 PM, Steve D'Aprano wrote:
>> On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote:
>>
>>> There is that old, but false, saying that the only intuitive interface
>>> is the nipple.  Turns out everything, even that, is learned
>>
>> Citation required.
>
> Sure, just ask a nursing woman.
[...]
> Sucking seems to be instinctive but the actual interface is learned
> (albeit very quickly) by experience.

You say tomahto, I say tomarto. It sounds like we're using different language
to describe the same thing.

Babies do have an instinct to suck if you stick a nipple (or a finger) in their
mouth, or even if you merely touch them on the lips or cheek:

http://www.medicinenet.com/script/main/art.asp?articlekey=5392

https://en.wikipedia.org/wiki/Primitive_reflexes#Rooting_reflex

The rooting instinct, together with the sucking instinct, is present in all
healthy babies. I would expect that only the most severe development
abnormalities would prevent instincts as important for survival as these two.

Between the rooting and sucking instincts, I consider "the only intuitive
interface is the nipple" is correct. However, that doesn't necessarily mean
that babies will suckle well: there are all sorts of reasons why babies don't
breast-feed well, e.g.:

http://www.cyh.com/HealthTopics/HealthTopicDetails.aspx?p=114&np=302&id=1960


> Babies don't just see a nipple and know what it's for.

Of course the instinct isn't *visual* -- babies may not open their eyes for
many minutes after birth (one study found that about 3% of babies hadn't opened
their eyes within 20 minutes, the maximum time allotted) which may be long
after their first suckle.

Nevertheless, there are senses other than sight.



--
Steven
git gets easier once you get the basic idea that branches are homeomorphic
endofunctors mapping submanifolds of a Hilbert space.

--
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Rustom Mody
On Tuesday, October 4, 2016 at 10:06:00 PM UTC+5:30, Steve D'Aprano wrote:
> On Tue, 4 Oct 2016 09:32 pm, Rustom Mody wrote:
> 
> > Are not the contents of the scope and the shape of the scope different
> > things?
> 
> 
> What does "the shape of the scope" mean?
> 
> Scopes don't have a shape -- they aren't geometric objects. So I'm afraid I
> don't understand what distinction you are trying to make.

Ok I was speaking quasi metaphorically
If you have some non-metaphors please tell!

Take the basic 'content':
x = 1
y = 2
z = 3

A. Occuring exactly as above at module level
B. Occuring exactly as above inside a function
C. Occuring thus
x = 1
foo(2,3)

def foo(y,z):
...

D. 
def foo():
  x = 1
  def bar():
 y, z = 2,3
...

E.
def foo():
  x = 1
  bar(2,3)
  ...

def bar(y,z):
  ...


In A,B,C,D,E at some point there's x,y,z having values (contents) 1,2,3
How do you distinguish them?

I call it the shape of the scope (or environment or bindings or namespace or
...???)

You have a better descriptor for the idea?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote:

> Haskell defines let (it's version of multiple mutually recursive
> bindings) in terms of the least fix point of a lambda function whose
> (pattern) parameter binds the expressions in the definitions.

It binds *the expression* itself? Not the value of the expression?

So Haskell uses some form of pass by name?

And (shamelessly using Python syntax) if I have a function:


def spam(x):
print(x)
print(x+1)


and then call it:

spam(time.sleep(60) or 1)


it will sleep for 60 seconds, print 1, then sleep for another 60 seconds,
then print 2. Is that right?



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Testing POST in cherrypy

2016-10-04 Thread Israel Brewster
When testing CherryPy using a cherrypy.text.helper.CPWebCase subclass, I can 
test a page request by calling "self.getPage()", and in that call I can specify 
a method (GET/POST etc). When specifying a POST, how do I pass the parameters? 
I know for a POST the parameters are in the body of the request, but in what 
format? Do I just url lib.urlencode() a dictionary and pass that as the body, 
or is there some other method I should use? Thanks!
---
Israel Brewster
Systems Analyst II
Ravn Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7293
---




-- 
https://mail.python.org/mailman/listinfo/python-list


Thank you for the multipart/mixed

2016-10-04 Thread Jussi Piitulainen
Thank you, Python!

I got important and urgent mail in a format that my rather-out-of-date
Gnus (on a server that I don't control) failed to show me, except in its
raw form. A search for tools to parse the raw multipart/mixed MIME
formatted message, now in a file, turned out one promising thing: the
Python standard library email.parser.

And it worked beautifully :) Usefully documented, too, so that I was
able to work out what to do with it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
On Tue, 4 Oct 2016 09:32 pm, Rustom Mody wrote:

> Are not the contents of the scope and the shape of the scope different
> things?


What does "the shape of the scope" mean?

Scopes don't have a shape -- they aren't geometric objects. So I'm afraid I
don't understand what distinction you are trying to make.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5 amd64 and win32service

2016-10-04 Thread eryk sun
On Tue, Oct 4, 2016 at 7:33 AM, Nagy László Zsolt  wrote:
>
>>> Is it possible to write a win32 service with 64 bit python 3.5? The
>>> pywin32 package does exist on 3.5 64bit, but missing some modules:
>> Try pip installing the "pypiwin32" package.
> That worked, thanks.
>
> Do you have an explanation why to official build (
> https://sourceforge.net/projects/pywin32/files/pywin32/ ) is missing
> these module?

Not off hand.

> After installing this package, the "service start" operation throws "The
> Service Did Not Respond To The Start Or Control Request In A Timely
> Fashion". error code 1053

Run the post-install script (in the Scripts folder):
"pywin32_postinstall.py -install". First edit the script to replace
references to "pywin32_system32" with "pypiwin32_system32", which
reflects the changed directory name in the wheel package. Running this
script should copy over pywintypes35.dll and pythoncom35.dll to the
System32 directory. pywintypes35.dll is required by PythonService.exe.

> def main(self):
> self.ReportServiceStatus(win32service.SERVICE_RUNNING)
> while not self.stop_requested.is_set():
> time.sleep(1)  # So something useful here

Why don't you use the Windows Event (hWaitStop) with
WaitForSingleObject instead of an additional threading.Event?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Ben Bacarisse
Marko Rauhamaa  writes:

> dieter :
>> The concept "assignment" comes from an operational semantics based on
>> some form of "RAM" machine. Such a machine has storage cells where you
>> can assign values to which remain there until overridden with a new
>> value.
>>
>> The concept "binding" comes from a denotational semantics based on
>> some form of functions where parameter names are bound to values on
>> function "application" and do not change inside the function.
>
> I wonder if such pure-bred functional programming languages exist.

I'd put Haskell in that that class.

> Lisp,
> Scheme and Python don't belong to them, at least. Object-oriented
> programming is not really possible without assignment. Even Scheme's
> "letrec" appeals to assignment semantics.

Haskell defines let (it's version of multiple mutually recursive
bindings) in terms of the least fix point of a lambda function whose
(pattern) parameter binds the expressions in the definitions.


-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lxml ignore none in getchildren

2016-10-04 Thread Peter Otten
Sayth Renshaw wrote:

> I am following John Shipmans example from
> http://infohost.nmt.edu/~shipman/soft/pylxml/web/Element-getchildren.html
> 
 xml = '''
> ...  '''
 pen = etree.fromstring(xml)
 penContents = pen.getchildren()
 for  content in penContents:
> ... print "%-10s %3s" % (content.tag, content.get("n", "0"))
> ...
> horse2
> cow 17
> cowboy   2
 
> 
> If I make one minor modification to the xml and change an n to an m as in
> my example below the getchildren will return none for none matches, how
> can I ignore nones?
> 
> In [2]: from lxml import etree
> 
> In [3]: xml = '''  n="2"/>'''
> 
> In [4]: pen =etree.fromstring(xml)
> 
> In [5]: pencontents = pen.getchildren()
> 
> In [6]: for content in pencontents:
>...: print(content.get('n'))
> 2
> None
> 2
> 
> Because
> In [17]: for content in pencontents:
>: if content is not None:
>: print(content.get('n'))
> 
> Sayth

The obvious fix would be to check for None in the right place:

>>> for content in pen.getchildren():
... n = content.get("n")
... if n is not None:
... print(content.tag, n)
... 
horse 2
cowboy 2

Another option would be to select only children that have an "n" attribute 
using xpath:

>>> for content in pen.xpath("/corral/*[@n]"):
... print(content.tag, content.get("n"))
... 
horse 2
cowboy 2


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Marko Rauhamaa
Rustom Mody :
> You are scorning something basic: Dont like 'binding'?
> Ok what about stack-frames? Activation-records?
>
> Just had a conversation with a colleague yesterday in which he was
> complaining about how hard students find to learn this stuff because
> of confusions like hardware-stack and language-stack getting mixed up.
>
> If you dont like abstractions you will have too many details
> And likely confused terminology

Well, I *did* introduce a data model for Python where the abstract
concepts are puppies, pegs and leashes. Instead of "binding", you'd hang
a leash on a labeled peg. Of course, you could also ask a puppy to hold
on to one or more leashes.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


lxml ignore none in getchildren

2016-10-04 Thread Sayth Renshaw
I am following John Shipmans example from 
http://infohost.nmt.edu/~shipman/soft/pylxml/web/Element-getchildren.html

>>> xml = '''
...  '''
>>> pen = etree.fromstring(xml)
>>> penContents = pen.getchildren()
>>> for  content in penContents:
... print "%-10s %3s" % (content.tag, content.get("n", "0"))
... 
horse2
cow 17
cowboy   2
>>> 

If I make one minor modification to the xml and change an n to an m as in my 
example below the getchildren will return none for none matches, how can I 
ignore nones?

In [2]: from lxml import etree

In [3]: xml = ''' '''

In [4]: pen =etree.fromstring(xml)

In [5]: pencontents = pen.getchildren()

In [6]: for content in pencontents:
   ...: print(content.get('n'))
2
None
2

Because 
In [17]: for content in pencontents:
   : if content is not None:
   : print(content.get('n'))

Sayth
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Rustom Mody
On Tuesday, October 4, 2016 at 2:05:31 PM UTC+5:30, Marko Rauhamaa wrote:
> dieter :
> > The concept "assignment" comes from an operational semantics based on
> > some form of "RAM" machine. Such a machine has storage cells where you
> > can assign values to which remain there until overridden with a new
> > value.
> >
> > The concept "binding" comes from a denotational semantics based on
> > some form of functions where parameter names are bound to values on
> > function "application" and do not change inside the function.
> 
> I wonder if such pure-bred functional programming languages exist. Lisp,
> Scheme and Python don't belong to them, at least. Object-oriented
> programming is not really possible without assignment. Even Scheme's
> "letrec" appeals to assignment semantics.
> 
> Ultimately, "binding" comes from outside the computer world. You talk
> about "bound variables" and "free variables". The concepts are needed to
> define the semantics of predicate logic and lambda calculus, for
> example. The C Preprocessor (cpp) comes close to the classic
> binding/transformation semantics of lambda calculus.
> 
> > Thus, at an appropriate level of abstraction, you can say that
> > "binding" and "assignment" are mostly equivalent.
> 
> Yes, but you sound more erudite if you talk about binding.

You are scorning something basic: Dont like 'binding'?
Ok what about stack-frames? Activation-records?

Just had a conversation with a colleague yesterday in which he was
complaining about how hard students find to learn this stuff because of
confusions like hardware-stack and language-stack getting mixed up.

If you dont like abstractions you will have too many details
And likely confused terminology
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Rustom Mody
On Tuesday, October 4, 2016 at 12:47:58 PM UTC+5:30, dieter wrote:
> Steve D'Aprano  writes:
> > On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote:
> >> Steve D'Aprano writes:
> >>> Why shouldn't people say that binding and assignment are the same
> >>> thing in Python? What's the difference?
> >> 
> >> Outside Python, (lambda x : f(x)) is said to "bind" x. It's different
> >> from assigning a new value to x. It's similar to how quantifiers in
> >> logic are said to bind their variables, so that variables bound to
> >> different quantifiers are different variables.
> >
> > o_O
> >
> > Me: "How is binding different from assignment?"
> >
> > You: "This is an example of binding: lambda x: f(x). Its different from
> > assigning to x. Clear now?"
> >
> >
> > What's "outside python"?
> 
> The concept "assignment" comes from an operational semantics based
> on some form of "RAM" machine. Such a machine has storage cells where
> you can assign values to which remain there until overridden with
> a new value.
> 
> The concept "binding" comes from a denotational semantics based on
> some form of functions where parameter names are bound to values on
> function "application" and do not change inside the function.
> 

«Binding comes from semantics ie logicians/mathematicians
Assignment comes from RAM-machine ie engineers»

seems like an intelligent distinction…
Except for the “do not change inside the function”

Sure in pure functional languages they do not change because nothing changes.
However in scheme there is a strong difference between define/let that change
the ‘structure’ of the scope and set! that changes its contents.

> 
> When you pass a Python variable as parameter to a function,
> and this function modifies the value of the corresponding
> "formal parameter", this does not change the variable's value.
> This indicates, that the variable does not model directly the
> corresponding storage cell.
> 
> On the other hand, you can assign a new value to a Python variable
> which indicates that Python variables are neither simple bindings.
> 
> 
> Of course, these are only semantic subtlenesses.
> 
> There are storage cells associated with Python variables and assignment
> can change their content (only on function call, it is not the storage
> cell that gets passed on into the function but the current value).
> 
> On the other hand, one can model Python variables as bindings
> where language constructs (assignments) allow to change the binding.
> 
> Thus, at an appropriate level of abstraction, you can say that
> "binding" and "assignment" are mostly equivalent.

Thats a bizarre statement -- Are not the contents of the scope and the shape of 
the scope different things?

No language (that I know) reifies this as completely as theoretically possible.
In particular scheme goes further but shies away from full first class
environments:
http://stackoverflow.com/questions/617325/why-doesnt-scheme-support-first-class-environments

However many scheme implementations provide it in some ad-hoc manner:
[renamed from ‘environment’ to ‘namespace’ presumably due  to clashes with OS
env-variables]
https://docs.racket-lang.org/reference/syntax-model.html#%28part._namespace-model%29


Python goes some way towards this with locals/globals etc... not really 
first-class.

However at the conceptual level there is a fundamental difference between
the shape of the namespace/environment/scope and its contents.
-- 
https://mail.python.org/mailman/listinfo/python-list


how to read linux kernel source with pycparser

2016-10-04 Thread meInvent bbird
i expect to use pycparser to read linux kernel source
and get a AST tree, 

but there are so many directory, 

how to read linux kernel source with pycparser?

how to customize pycparser to search what we want such as bug or fix 
to make a linux patch for linux kernel source with python?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread Marko Rauhamaa
dieter :
> The concept "assignment" comes from an operational semantics based on
> some form of "RAM" machine. Such a machine has storage cells where you
> can assign values to which remain there until overridden with a new
> value.
>
> The concept "binding" comes from a denotational semantics based on
> some form of functions where parameter names are bound to values on
> function "application" and do not change inside the function.

I wonder if such pure-bred functional programming languages exist. Lisp,
Scheme and Python don't belong to them, at least. Object-oriented
programming is not really possible without assignment. Even Scheme's
"letrec" appeals to assignment semantics.

Ultimately, "binding" comes from outside the computer world. You talk
about "bound variables" and "free variables". The concepts are needed to
define the semantics of predicate logic and lambda calculus, for
example. The C Preprocessor (cpp) comes close to the classic
binding/transformation semantics of lambda calculus.

> Thus, at an appropriate level of abstraction, you can say that
> "binding" and "assignment" are mostly equivalent.

Yes, but you sound more erudite if you talk about binding.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: rocket simulation game with just using tkinter

2016-10-04 Thread Christian Gollwitzer

Am 02.10.16 um 14:46 schrieb Irmen de Jong:

On 1-10-2016 22:07, Irmen de Jong wrote:

Oh, I'm sorry about that, my little knowledge of non-US keyboard layouts shows.
Arrow keys could be an option.   For my education what are the 2 keys to the 
right of
the P then on your keyboard?

Rebinding the keys should be easy though just change them in the keypress and 
keyrelease
methods.


I've updated the keybindings and you can now use [ and ] but also the cursor 
keys to
control the rocket's rotation.


Thanks! It works now with the cursor keys as intended. I'm still having 
trouble, but only because my game playing skills are not very good ;)



Also I've discovered that there seems to be an issue with some Tkinter 
versions; it
sometimes doesn't update the screen fast enough. On OSX this problem is not 
present but
it is on Python 2.7 on Windows for example. I don't know what is causing it or 
how to
fix it at this time.   The FPS counter in the top right of the window should 
say 30,
that is when the game is updating at the intended speed.


Maybe if the system is simply too slow for your intended speed ? I see 
that you are using after_idle if the delay is less than 1 ms. after_idle 
performs a different task than after. I think, instead you should skip 
frames, i.e. compute how many frames you are behind the clock and 
advance the physics by that and draw the next frame instead. Otherwise 
the delay might build up.


The drawing itself has also different speed on different system. And, 
the canvas is not intended to redraw everything on each frame. Instead, 
updating the objects using the coords() method is usually faster. (It 
should also be easier)


Christian




Irmen



--
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt5, OpenGL, where to start, minimal example code?

2016-10-04 Thread Phil Thompson
On 4 Oct 2016, at 5:57 am, John Ladasky  wrote:
> 
> On Monday, October 3, 2016 at 1:30:29 AM UTC-7, Phil Thompson wrote:
>> On 3 Oct 2016, at 4:29 am, John Ladasky  wrote:
> 
>>> And as you can see: trying to call versionFunctions() is exactly where my 
>>> program failed.
>> 
>> Try passing a QOpenGLVersionProfile object to versionFunctions() that has a 
>> version set to one supported by PyQt.
> 
> Hi Phil,
> 
> I'm trying to follow your advice.  It's strange, "from PyQt5.QtGui import 
> QOpenGLVersionProfile" works fine, and I can make an object of that type.
> 
> However: http://pyqt.sourceforge.net/Docs/PyQt5/ DOES NOT DOCUMENT 
> QOpenGLVersionProfile.  I did find Qt documentation, at 
> http://doc.qt.io/qt-5/qopenglversionprofile.html.  I will investigate this 
> issue further.  Sometimes it isn't obvious how the C++ constructors are 
> wrapped in Python.

QOpenGLVersonProfile missing from the docs is a bug.

> If I ever understand a GUI like PyQt5 well enough, I'd like to contribute to 
> its documentation.  Sigh.

If you are an OpenGL expert then you could help a lot by answering my questions 
about how individual functions should be bound.

Phil
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5 amd64 and win32service

2016-10-04 Thread Nagy László Zsolt


>> Is it possible to write a win32 service with 64 bit python 3.5? The
>> pywin32 package does exist on 3.5 64bit, but missing some modules:
> Try pip installing the "pypiwin32" package.
That worked, thanks.

Do you have an explanation why to official build (
https://sourceforge.net/projects/pywin32/files/pywin32/ ) is missing
these module? I'm curious.

After installing this package, the "service start" operation throws "The
Service Did Not Respond To The Start Or Control Request In A Timely
Fashion". error code 1053

I have written many other win32 services in python2 before, but never
got this error message. Is this specific to windows 10?

Here is an MWE:

#!/usr/bin/python3
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import threading
import time


class AppServerSvc(win32serviceutil.ServiceFramework):
_svc_name_ = "TestService"
_svc_display_name_ = "Test Service"

def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.stop_requested = threading.Event()
self.stop_requested.clear()
socket.setdefaulttimeout(60)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
  servicemanager.PYS_SERVICE_STARTED,
  (self._svc_name_, ''))
self.main()
self.ReportServiceStatus(win32service.SERVICE_STOPPED)

def main(self):
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
while not self.stop_requested.is_set():
time.sleep(1)  # So something useful here


if __name__ == '__main__':
win32serviceutil.HandleCommandLine(AppServerSvc)







-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment versus binding

2016-10-04 Thread dieter
Steve D'Aprano  writes:
> On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote:
>> Steve D'Aprano writes:
>>> Why shouldn't people say that binding and assignment are the same
>>> thing in Python? What's the difference?
>> 
>> Outside Python, (lambda x : f(x)) is said to "bind" x. It's different
>> from assigning a new value to x. It's similar to how quantifiers in
>> logic are said to bind their variables, so that variables bound to
>> different quantifiers are different variables.
>
> o_O
>
> Me: "How is binding different from assignment?"
>
> You: "This is an example of binding: lambda x: f(x). Its different from
> assigning to x. Clear now?"
>
>
> What's "outside python"?

The concept "assignment" comes from an operational semantics based
on some form of "RAM" machine. Such a machine has storage cells where
you can assign values to which remain there until overridden with
a new value.

The concept "binding" comes from a denotational semantics based on
some form of functions where parameter names are bound to values on
function "application" and do not change inside the function.


When you pass a Python variable as parameter to a function,
and this function modifies the value of the corresponding
"formal parameter", this does not change the variable's value.
This indicates, that the variable does not model directly the
corresponding storage cell.

On the other hand, you can assign a new value to a Python variable
which indicates that Python variables are neither simple bindings.


Of course, these are only semantic subtlenesses.

There are storage cells associated with Python variables and assignment
can change their content (only on function call, it is not the storage
cell that gets passed on into the function but the current value).

On the other hand, one can model Python variables as bindings
where language constructs (assignments) allow to change the binding.

Thus, at an appropriate level of abstraction, you can say that
"binding" and "assignment" are mostly equivalent.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-04 Thread Steven D'Aprano
On Tuesday 04 October 2016 14:51, Michael Torrie wrote:

> On 10/03/2016 08:21 PM, Steve D'Aprano wrote:
>> On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote:
>> 
>>> There is that old, but false, saying that the only intuitive interface
>>> is the nipple.  Turns out everything, even that, is learned
>> 
>> Citation required.
> 
> Sure, just ask a nursing woman.
[...]
> Sucking seems to be instinctive but the actual interface is learned
> (albeit very quickly) by experience.

You say tomahto, I say tomarto. It sounds like we're using different language 
to describe the same thing.

Babies do have an instinct to suck if you stick a nipple (or a finger) in their 
mouth, or even if you merely touch them on the lips or cheek:

http://www.medicinenet.com/script/main/art.asp?articlekey=5392

https://en.wikipedia.org/wiki/Primitive_reflexes#Rooting_reflex

The rooting instinct, together with the sucking instinct, is present in all 
healthy babies. I would expect that only the most severe development 
abnormalities would prevent instincts as important for survival as these two.

Between the rooting and sucking instincts, I consider "the only intuitive 
interface is the nipple" is correct. However, that doesn't necessarily mean 
that babies will suckle well: there are all sorts of reasons why babies don't 
breast-feed well, e.g.:

http://www.cyh.com/HealthTopics/HealthTopicDetails.aspx?p=114&np=302&id=1960


> Babies don't just see a nipple and know what it's for.

Of course the instinct isn't *visual* -- babies may not open their eyes for 
many minutes after birth (one study found that about 3% of babies hadn't opened 
their eyes within 20 minutes, the maximum time allotted) which may be long 
after their first suckle.

Nevertheless, there are senses other than sight.



-- 
Steven
git gets easier once you get the basic idea that branches are homeomorphic 
endofunctors mapping submanifolds of a Hilbert space.

-- 
https://mail.python.org/mailman/listinfo/python-list