Re: nonlocal fails ?

2019-11-14 Thread Richard Damon
On 11/14/19 12:57 PM, R.Wieser wrote: > Michael, > >> nonlocal does not share or use its *caller's* variables. Rather it >> reaches into the scope of the outer function where it was defined. >> That's a very different concept than what you're proposing. > Oh blimy! You're right.Its an at com

Re: nonlocal fails ?

2019-11-14 Thread Richard Damon
On 11/14/19 1:43 PM, R.Wieser wrote: > Richard, > >> Assuming that one language works like another is a danger > Abitrarily redefining words and using misnomers is another ... ("global" > and "nonlocal" respecivily if you wonder) > >> First, Python doesn't really have 'Variables' like a lot of ot

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread MRAB
On 2019-11-15 00:37, Dennis Lee Bieber wrote: On Thu, 14 Nov 2019 21:00:59 +0100, "R.Wieser" declaimed the following: :-) I already wrote that program in C{something} (I'm not sure what my Pi offers by default) a while ago, but "ported" it to python. For the above mentioned "example" reaso

Re: Trouble trying to get started with pygame

2019-11-14 Thread originallmoney
On Tuesday, November 12, 2019 at 7:05:16 PM UTC-5, Terry Reedy wrote: > On 11/12/2019 2:32 PM, originallmo...@gmail.com wrote: > > I'm curious: I've been seeing people having multiple pygame programs open > > at once (Where each one is a component of a main program, obviously). > > Multiple progr

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Michael Torrie
On 11/14/19 2:13 AM, R.Wieser wrote: > Too bad that the Pi has no free hardware that can be abused for stuff like > this (like a serial port in synchronous mode). An arduino working in conjunction with the Pi can fill in the gaps. At one time you could buy an arduino board that was also a Pi hat

Re: nonlocal fails ?

2019-11-14 Thread Michael Torrie
On 11/14/19 2:16 PM, R.Wieser wrote: > I think I did - though implicitily. What do normal people use "by > reference" arguments for ? Yep, that is what I wanted too. Well I've only seen this done in languages where other mechanisms for returning complex types are not present. For example in C

Re: nonlocal fails ?

2019-11-14 Thread Terry Reedy
On 11/14/2019 4:16 PM, R.Wieser wrote: If you mentioned what problem you are trying to solve 1) Have value 2) use value in procedure 1 3) use updated value in procedure 2 4) use again updated value in procedure 1, 2 or maybe 3 For the sake of learning I'm now going over all of the possibili

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Rob Gaddi
On 11/14/19 12:34 PM, R.Wieser wrote: Dennis, The R-Pi has never, to my knowledge, been billed as suitable for industrial/real-time/process-control... I have not read those specs to be honest. But for some reason I assumed that a 1.4 GHz machine should easily be able to generate a 1.6 KHz s

Re: nonlocal fails ?

2019-11-14 Thread Chris Angelico
On Fri, Nov 15, 2019 at 8:21 AM R.Wieser wrote: > > Michael, > > > I note that you didn't answer the question, what are you trying > > to accomplish? > > I think I did - though implicitily. What do normal people use "by > reference" arguments for ? Yep, that is what I wanted too. > That doesn

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread MRAB
On 2019-11-14 20:00, R.Wieser wrote: Dave, Can you expand on what you are trying to accomplish with this? There is a small 433 MHz rf transmitter connected to the pin, and when I send the right pattern a wireless wall-wart will respond and switch a lamp on or off. Its just ment as an exam

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Michael, > I note that you didn't answer the question, what are you trying > to accomplish? I think I did - though implicitily. What do normal people use "by reference" arguments for ? Yep, that is what I wanted too. > It looks to me like you're trying to write a program in a different > la

Re: py2 vs py3: zlib.adler32/crc32

2019-11-14 Thread MRAB
On 2019-11-14 19:22, Karsten Hilbert wrote: Hi all, I am unsure how to solve: I use adler32/crc32 to generate integer values from data for setting up an advisory lock in PostgreSQL. The PG function pg_try_advisory_lock() https://www.postgresql.org/docs/12/functions-admin.html#FUNCTIONS-AD

Re: Reading mail getting [, ...

2019-11-14 Thread MRAB
On 2019-11-14 19:43, Abdur-Rahmaan Janhangeer wrote: Greetings, Using this code to read mail. I'm printing to file only mails sent by some people. For some mails i get the body as the below instead of actual text: [, ] instead of the actual mail body. Here is the code: # # import imaplib imp

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Dave Cinege
Rudy, OK I'm old enough cancer to know what X10 is. :-) I wouldn't think this is too difficult to do as you're only sending. For this application IMO there is too much going on inside python that can interrupt the cycle of modulation. (Intra and Extra python; garbage collection, other process

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > The R-Pi has never, to my knowledge, been billed as suitable > for industrial/real-time/process-control... I have not read those specs to be honest. But for some reason I assumed that a 1.4 GHz machine should easily be able to generate a 1.6 KHz signal, even using Python. I was wr

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > Ugh -- let's try Google Drive... I was able to download them, thanks.All but the 100uSec one seemed to be rather stable. > That is what I'd thought, but if you've looked at that simple program I > used, apparently the "run longer" was taking place between the > > t += > > and the

Re: nonlocal fails ?

2019-11-14 Thread Chris Angelico
On Fri, Nov 15, 2019 at 7:19 AM Michael Torrie wrote: > > On 11/14/19 10:57 AM, R.Wieser wrote: > >> I know of no sane way that a function could work with the scope of > >> any arbitrary caller. > > > > The trick seems to be to emulate a "by reference" call, by using a mutable > > object as the ar

Re: nonlocal fails ?

2019-11-14 Thread Michael Torrie
On 11/14/19 10:57 AM, R.Wieser wrote: > The trick seems to be to emulate a "by reference" call, by using a mutable > object as the argument and stuff the value inside of it (IIRC a tuple with a > single element). I note that you didn't answer the question, what are you trying to accomplish? In o

Re: nonlocal fails ?

2019-11-14 Thread Michael Torrie
On 11/14/19 10:57 AM, R.Wieser wrote: >> I know of no sane way that a function could work with the scope of >> any arbitrary caller. > > The trick seems to be to emulate a "by reference" call, by using a mutable > object as the argument and stuff the value inside of it (IIRC a tuple with a > sin

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dave, > Can you expand on what you are trying to accomplish with this? There is a small 433 MHz rf transmitter connected to the pin, and when I send the right pattern a wireless wall-wart will respond and switch a lamp on or off. Its just ment as an example of a real-world application of P

Reading mail getting [, ...

2019-11-14 Thread Abdur-Rahmaan Janhangeer
Greetings, Using this code to read mail. I'm printing to file only mails sent by some people. For some mails i get the body as the below instead of actual text: [, ] instead of the actual mail body. Here is the code: # # import imaplib import email import time my_senders = ['y...@x.com ', 'y.

py2 vs py3: zlib.adler32/crc32

2019-11-14 Thread Karsten Hilbert
Hi all, I am unsure how to solve: I use adler32/crc32 to generate integer values from data for setting up an advisory lock in PostgreSQL. The PG function pg_try_advisory_lock() https://www.postgresql.org/docs/12/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS takes two PG ints which are defin

Re: nonlocal fails ?

2019-11-14 Thread Terry Reedy
On 11/14/2019 12:53 PM, Richard Damon wrote: On Nov 14, 2019, at 12:20 PM, R.Wieser wrote: MRAB, 'nonlocal' is used where the function is nested in another function The problem is that that was not clear to me from the description - nor is it logical to me why it exludes the main context

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Gene Heskett
On Thursday 14 November 2019 13:05:06 Dennis Lee Bieber wrote: > On Thu, 14 Nov 2019 09:31:34 +0100, "R.Wieser" > > declaimed the following: > >What I tried to indicate is that the Pi has 500,000 cycles to work > > with between two of those time events. I consider that to be quite > > a few. >

Re: nonlocal fails ?

2019-11-14 Thread Chris Angelico
On Fri, Nov 15, 2019 at 5:46 AM R.Wieser wrote: > > Richard, > > > Assuming that one language works like another is a danger > > Abitrarily redefining words and using misnomers is another ... ("global" > and "nonlocal" respecivily if you wonder) Every language that has a concept of "global" stil

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Richard, > Assuming that one language works like another is a danger Abitrarily redefining words and using misnomers is another ... ("global" and "nonlocal" respecivily if you wonder) > First, Python doesn't really have 'Variables' like a lot of other > languages > (they don't hold a bag of b

Re: nonlocal fails ?

2019-11-14 Thread Richard Damon
> On Nov 14, 2019, at 12:56 PM, R.Wieser wrote: > > Jan, > >> So what you want to do is dynamic scope? > > No, not really.I was looking for method to let one procedure share a > variable with its caller - or callers, selectable by me. And as a "by > reference" argument does not seem t

Re: nonlocal fails ?

2019-11-14 Thread Rhodri James
On 14/11/2019 17:11, R.Wieser wrote: Rhodri, MyVar is a global here, so nonlocal explicitly doesn't pick it up. I do not agree with you there (the variable being global). If it where than I would have been able to alter the variable inside the procedure without having to resort to a "global"

Re: A more

2019-11-14 Thread Terry Reedy
On 11/14/2019 10:24 AM, James Lu wrote: Where do I go to find a more complete specification for Python? The Cpython code, the tests, and its actual behavior. I want to learn about common semi-internal language features used by popular libraries, because I am reimplementing Python. The refere

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Michael, > nonlocal does not share or use its *caller's* variables. Rather it > reaches into the scope of the outer function where it was defined. > That's a very different concept than what you're proposing. Oh blimy! You're right.Its an at compile-time thing, not a runtime one. Thanks

Re: nonlocal fails ?

2019-11-14 Thread Richard Damon
> > On Nov 14, 2019, at 12:20 PM, R.Wieser wrote: > > MRAB, > >> 'nonlocal' is used where the function is nested in another function > > The problem is that that was not clear to me from the description - nor is > it logical to me why it exludes the main context from its use. > > Regards, >

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Jan, > So what you want to do is dynamic scope? No, not really.I was looking for method to let one procedure share a variable with its caller - or callers, selectable by me. And as a "by reference" argument does not seem to exist in Python ... And yes, I am a ware that procedures can ret

Re: nonlocal fails ?

2019-11-14 Thread Richard Damon
On Nov 14, 2019, at 12:18 PM, R.Wieser wrote: > > Rhodri, > >> MyVar is a global here, so nonlocal explicitly doesn't pick it up. > > I do not agree with you there (the variable being global). If it where than > I would have been able to alter the variable inside the procedure without > ha

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Rob Gaddi
On 11/13/19 1:26 PM, Dietmar Schwertberger wrote: On 13.11.2019 21:20, R.Wieser wrote: 300us is getting on towards realtime. Not really.  Translated to a frequency (toggeling the pin) it would be just 1.6 KHz.   Thats rather slow for an ARM machine running on 1.4 Ghz (about a million times as f

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
MRAB, > 'nonlocal' is used where the function is nested in another function The problem is that that was not clear to me from the description - nor is it logical to me why it exludes the main context from its use. Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Rhodri, > MyVar is a global here, so nonlocal explicitly doesn't pick it up. I do not agree with you there (the variable being global). If it where than I would have been able to alter the variable inside the procedure without having to resort to a "global" override (an override which is only

Re: nonlocal fails ?

2019-11-14 Thread Michael Torrie
On 11/14/19 7:15 AM, R.Wieser wrote: > Too bad though, it means that procedures that want to share/use its callers > variables using nonlocal can never be called from main. And that a caller > of a procedure using nonlocal cannot have the variable declared as global > (just tested it). nonloc

Re: Logistic Regression Define X and Y for Prediction

2019-11-14 Thread Mike C
Hi Jason, I will try it out... Nothing in the documentation tells a person. Thanks From: Python-list on behalf of Jason Friedman Sent: Wednesday, November 13, 2019 7:19 PM Cc: python-list@python.org Subject: Re: Logistic Regression Define X and Y for Predicti

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Dave Cinege
Can you expand on what you are trying to accomplish with this? It seems a small C program or library you interface python too is a better solution. With that said, as others mentioned you might need a real time OS or micro controller if this needs to be dead on timing. Dave On 2019/11/13 09:0

A more

2019-11-14 Thread James Lu
Where do I go to find a more complete specification for Python? I want to learn about common semi-internal language features used by popular libraries, because I am reimplementing Python. The reference guide says: > While I am trying to be as precise as possible, I chose to use English > rather t

Re: nonlocal fails ?

2019-11-14 Thread Jan Erik Moström
On 14 Nov 2019, at 15:15, R.Wieser wrote: Too bad though, it means that procedures that want to share/use its callers variables using nonlocal can never be called from main. And that a caller of a procedure using nonlocal cannot have the variable declared as global (just tested it). So wha

Re: nonlocal fails ?

2019-11-14 Thread R.Wieser
Jan, > The nonlocal statement causes the listed identifiers to refer to > previously bound variables in the nearest **enclosing scope excluding > globals**. I read that too, but didn't get from it that the main scope is excluded (I assumed the"excluding globals" was ment at as such dec

Re: nonlocal fails ?

2019-11-14 Thread Rhodri James
On 14/11/2019 13:06, R.Wieser wrote: Hello all, I've just tried to use a "nonlocal MyVar" statement in a procedure defenition, but it throws an error saying "Syntax error: no binding for nonlocal 'MyVar' found. According to platform.python_version() I'm running version 3.8.3 Why am I getting t

Re: nonlocal fails ?

2019-11-14 Thread MRAB
On 2019-11-14 13:06, R.Wieser wrote: Hello all, I've just tried to use a "nonlocal MyVar" statement in a procedure defenition, but it throws an error saying "Syntax error: no binding for nonlocal 'MyVar' found. According to platform.python_version() I'm running version 3.8.3 Why am I getting t

Re: nonlocal fails ?

2019-11-14 Thread Jan Erik Moström
On 14 Nov 2019, at 14:06, R.Wieser wrote: I've also tried moving "MyVar = 7" to the first line, but that doesn't change anything. Using "global MyVar" works.. Try def outer(): MyVar = 10 def Proc1(): nonlocal MyVar MyVar = 5 Proc1()

nonlocal fails ?

2019-11-14 Thread R.Wieser
Hello all, I've just tried to use a "nonlocal MyVar" statement in a procedure defenition, but it throws an error saying "Syntax error: no binding for nonlocal 'MyVar' found. According to platform.python_version() I'm running version 3.8.3 Why am I getting that error ? (already googeled ofcours

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > You know... I never finished my thought there... :-) I already got the feeling I missed something there. > ... 1.6kHz appears to just be viable (there may still be a context > switch but it wasn't visible on my o'scope) Thats ... slow.And a limitation I definitily have to remember

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > Let's see if I can remember how to use my BK Precision > 2542 scope... :-) You didn't have to do that. I was already planning to put my TDS 210 (tektronics) scope to work today, if only to see what the effect of drift-compensated sleeps would be (inserting some print commands here a

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dennis, > Avoiding drift still comes down to computing the time (in some unit) > at which the interval is to expire, and then delaying for the difference > between that time and current time. Yep. And although that can be done with Python, I had hoped to be able to shift all that to lower-leve

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread R.Wieser
Dietmar, > It *is* real-time... > Real-time is not about speed, but about guaranteed timing. What I tried to indicate is that the Pi has 500,000 cycles to work with between two of those time events. I consider that to be quite a few. > at least not on a multitasking non-realtime system. Yep