From fal at libero.it  Sun Apr  3 11:03:03 2022
From: fal at libero.it (Francesco A. Loffredo)
Date: Sun, 3 Apr 2022 17:03:03 +0200
Subject: [Tutor] problem solving with lists
In-Reply-To: <001301d83a0c$746c1ad0$5d445070$@bluewin.ch>
References: <000001d83129$f99e9750$ecdbc5f0$@bluewin.ch>
 <t01ter$3um$1@ciao.gmane.io> <000401d831f7$3f9c7150$bed553f0$@bluewin.ch>
 <t04q15$mgi$1@ciao.gmane.io> <001301d83a0c$746c1ad0$5d445070$@bluewin.ch>
Message-ID: <ff617f09-bcf1-1e06-5c9c-176eed3cce63@libero.it>

My two cents:

I tried to solve the problem Marcus proposed, and I think the following 
little functions can help.


###################################################

from itertools import combinations

def pairs(seq):
 ??? """
 ??? returns all groups of two elements that can be found in seq
 ??? """
 ??? seen = set()
 ??? for elem in combinations(seq, 2):
 ??????? seen.add(elem)
 ??????? seen.add(tuple(reversed(elem)))
 ??? return seen

def combi(seq, n, seen=None):
 ??? """
 ??? returns all n-tuples taken from the sequence seq, such that no tuple
 ??? contains a pair of elements already present in another tuple
 ??? (Marcus Luetolf problem)
 ??? """
 ??? if seen is None:
 ??????? seen = set()
 ??? res = list()
 ??? for elem in combinations(seq, n):
 ??????????? couples = pairs(elem)
 ??????????? if any([x in seen for x in couples]):
 ??????????????? continue
 ??????????? else:
 ??????????????? seen = seen.union(couples)
 ??????????????? res.append(elem)
 ??? return res, seen

if __name__ == "__main__":
 ??? already = set()
 ??? text = "abcdefghijklmnop"
 ??? final = list()

 ??? final, already = combi(text, 4)

 ??? print(final)

######################################################


Let me know if I correctly understood the problem.

Hope this helps

Francesco


From luigimanpeach12 at gmail.com  Sun Apr  3 12:20:32 2022
From: luigimanpeach12 at gmail.com (Eleejay 1O1)
Date: Sun, 3 Apr 2022 11:20:32 -0500
Subject: [Tutor] Requesting help
Message-ID: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>

Hello,

I'm currently enrolled in the Python Programming course with Google. And
I'm trying to understand returning values and returning values using
functions. I do understand the role of functions, however, the use of
return using functions throws me off. Can you help me with this?

Thank you in advance
Elijah

From wlfraed at ix.netcom.com  Sun Apr  3 14:38:45 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Sun, 03 Apr 2022 14:38:45 -0400
Subject: [Tutor] Requesting help
References: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
Message-ID: <6qpj4hhiu8ivmm3kvmgksa0adsp21ltokr@4ax.com>

On Sun, 3 Apr 2022 11:20:32 -0500, Eleejay 1O1 <luigimanpeach12 at gmail.com>
declaimed the following:

>
>I'm currently enrolled in the Python Programming course with Google. And
>I'm trying to understand returning values and returning values using
>functions. I do understand the role of functions, however, the use of
>return using functions throws me off. Can you help me with this?
>

	Since I don't know of any means of "returning values" that does not use
a function, your situation is unclear to me. I'm also not going to register
for some Google "course" just for a one-time question.

	Pretty much by definition, a function accepts one or more arguments,
does some computation using those arguments, and returns the result of the
computation as the function value. (Some languages differentiate functions
returning values from procedures which do not -- those languages often,
however, allow side-effects in that arguments to the procedure can be
changed within it, and the changes become visible in the caller; Python
does not -- if one does not explicitly return a value, the language returns
the None object, and if one does not "capture" the return it falls into a
bit-bucket)

def afunc(a, b):
	avalue = math.sin(a) / b
	return avalue

value = afunc(2.78, 3.14)



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From PythonList at DancesWithMice.info  Sun Apr  3 17:29:02 2022
From: PythonList at DancesWithMice.info (dn)
Date: Mon, 4 Apr 2022 09:29:02 +1200
Subject: [Tutor] Requesting help
In-Reply-To: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
References: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
Message-ID: <feec88a9-f213-2d52-2931-3bc0d57e8d5a@DancesWithMice.info>

On 04/04/2022 04.20, Eleejay 1O1 wrote:
> Hello,
> 
> I'm currently enrolled in the Python Programming course with Google. And
> I'm trying to understand returning values and returning values using
> functions. I do understand the role of functions, however, the use of
> return using functions throws me off. Can you help me with this?


Can this question be made more specific?

"I do understand the role of functions": what do you understand? Perhaps
your understanding is different from Python's!

Particularly when: "the use of return using functions throws me off" -
given that many?most functions exist purely to return a value(s)!


When people of @Dennis and my vintage first started-out in computing, a
popular mantra was "Input, Process, Output".

It may be helpful to regard a function as a "process" - it achieves
something. Please inspect some (good) example code and note that a
function's name involves a verb (back when I was at school: a 'doing'
word), eg

    calculate_wages()
    format_full_name_and_title()
    arrange_draws_for_league()

So, it has an objective, which generalises to 'take some "input", do
something to "process" it, and produce some "output".

For bonus-points: if your function's name includes the word "and", it
should probably be split into two...


How does a function take input-data? Answer: arguments and parameters
(and more besides). The post doesn't mention this 'side'. So, will
ignore for-now.


How does a function deliver its output? This known as "return-ing" its
result(s). How do you understand a function to communicate its completed
task?


How do you understand the input-process-output pattern of functions?
-- 
-- 
Regards,
=dn

From wlfraed at ix.netcom.com  Sun Apr  3 19:14:40 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Sun, 03 Apr 2022 19:14:40 -0400
Subject: [Tutor] Requesting help
References: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
 <feec88a9-f213-2d52-2931-3bc0d57e8d5a@DancesWithMice.info>
Message-ID: <7fak4hlno5vl7ecncsd7duag33oh1njs03@4ax.com>

On Mon, 4 Apr 2022 09:29:02 +1200, dn <PythonList at DancesWithMice.info>
declaimed the following:

>
>When people of @Dennis and my vintage first started-out in computing, a
>popular mantra was "Input, Process, Output".
>
	<heh> ... and so many of my school assignments tended lo literally look
like:

	call loaddata
	call compute
	call saveresults

(FORTRAN, using error-prone named common blocks to pass large amounts of
data around)


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From PythonList at DancesWithMice.info  Sun Apr  3 19:23:41 2022
From: PythonList at DancesWithMice.info (dn)
Date: Mon, 4 Apr 2022 11:23:41 +1200
Subject: [Tutor] Requesting help
In-Reply-To: <7fak4hlno5vl7ecncsd7duag33oh1njs03@4ax.com>
References: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
 <feec88a9-f213-2d52-2931-3bc0d57e8d5a@DancesWithMice.info>
 <7fak4hlno5vl7ecncsd7duag33oh1njs03@4ax.com>
Message-ID: <a6899c74-3690-b630-dbb3-25dfe89e47ae@DancesWithMice.info>

On 04/04/2022 11.14, Dennis Lee Bieber wrote:
> On Mon, 4 Apr 2022 09:29:02 +1200, dn <PythonList at DancesWithMice.info>
> declaimed the following:
> 
>>
>> When people of @Dennis and my vintage first started-out in computing, a
>> popular mantra was "Input, Process, Output".
>>
> 	<heh> ... and so many of my school assignments tended lo literally look
> like:
> 
> 	call loaddata
> 	call compute
> 	call saveresults
> 
> (FORTRAN, using error-prone named common blocks to pass large amounts of
> data around)


Looks so familiar!

However, if the OP is relying upon globals (or even mutables!) within
his/her functions, that'll lead to a whole raft of (other) problems!


Do you know - as I age (and age), when I look back, I find that even
nostalgia ain't as good as it used to be...

-- 
Regards,
=dn

From alan.gauld at yahoo.co.uk  Sun Apr  3 19:37:16 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Mon, 4 Apr 2022 00:37:16 +0100
Subject: [Tutor] Requesting help
In-Reply-To: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
References: <CAGn9nNXG1A4fnuvi6F8kDpETv_zC78fEZ3JkCVXPmRBVfdQPmQ@mail.gmail.com>
Message-ID: <t2db3d$2lg$1@ciao.gmane.io>

On 03/04/2022 17:20, Eleejay 1O1 wrote:

> I'm trying to understand returning values and returning values using
> functions. 

They are the same. You can only return values from functions.

> I do understand the role of functions

Functions have many roles but the two most important are
1) To improve readability(and thus maintenace) of your code
2) to make common algorithms reusable thius saving typing and
duplication of code(and therefore of errors)

> return using functions throws me off. Can you help me with this?

return terminates a function. If a value is added then that value is
returned to the caller of the function. Otherwise None is returned to
the caller.

The other role of 'return' is to return control to the calling code. A
function can be thought of a small independane program that runs inside
another one. While the function is executing the outer calling code
stops and waits for the function to complete. The return statement
signals that control returns to the external code.

This dual role of 'return'' can confuse beginners but really the two
things are the same thing. The function terminates and hands back
control and its terminal value to the caller.

def aFunction(some, parameters, here):
    code_that_uses_the_parameters_here()
    return aValue  # to the caller

#call the function
myValue = aFunction(1,2,3)  # some=1,parameters=2,here=3
print(myValue)  # prints whatever value myFunction returned.

We use builtin functions and their return values all the time

total = sum([1,2,3,4])
print(total)  # total = 10

sum() is a builtin unction that takes a sequence of values,
adds them together and returns the result.

myname = input("Enter your name")
size = len(myname)
print(myname,"is ", size, "chars long")

input() is a builtin function that takes a prompt string
    parameter, reads a string from the keyboard and returns
    that string to the caller
len() is a builtin function that takes an object and works
    out its length (for some definition of length) and returns
    it to the caller.
print() is a builtin function that takes a variable number
    of parameters and converts them to strings before
    sending them to the stdout stream. It doesn't return
    a value to the caller so its result is the default, None.

Your user defined functions are just like the builtin
functions. There is no real differnce to Python.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From marcus.luetolf at bluewin.ch  Mon Apr  4 14:53:51 2022
From: marcus.luetolf at bluewin.ch (marcus.luetolf at bluewin.ch)
Date: Mon, 4 Apr 2022 20:53:51 +0200
Subject: [Tutor] problem solving with lists
In-Reply-To: <ff617f09-bcf1-1e06-5c9c-176eed3cce63@libero.it>
References: <000001d83129$f99e9750$ecdbc5f0$@bluewin.ch>
 <t01ter$3um$1@ciao.gmane.io> <000401d831f7$3f9c7150$bed553f0$@bluewin.ch>
 <t04q15$mgi$1@ciao.gmane.io> <001301d83a0c$746c1ad0$5d445070$@bluewin.ch>
 <ff617f09-bcf1-1e06-5c9c-176eed3cce63@libero.it>
Message-ID: <002601d84855$53903790$fab0a6b0$@bluewin.ch>

Hello Experts,
Francesco Loffredo's solution looks very clean.
It returns 15 sublists/teams in final, but 20 are required, for each item in text has to combine with
every other item in 4 sublists/teams  5 times.
Regards, Marcus. 

-----Urspr?ngliche Nachricht-----
Von: Francesco A. Loffredo <fal at libero.it> 
Gesendet: Sonntag, 3. April 2022 17:03
An: tutor at python.org; marcus.luetolf at bluewin.ch
Betreff: Re: [Tutor] problem solving with lists

My two cents:

I tried to solve the problem Marcus proposed, and I think the following little functions can help.


###################################################

from itertools import combinations

def pairs(seq):
     """
     returns all groups of two elements that can be found in seq
     """
     seen = set()
     for elem in combinations(seq, 2):
         seen.add(elem)
         seen.add(tuple(reversed(elem)))
     return seen

def combi(seq, n, seen=None):
     """
     returns all n-tuples taken from the sequence seq, such that no tuple
     contains a pair of elements already present in another tuple
     (Marcus Luetolf problem)
     """
     if seen is None:
         seen = set()
     res = list()
     for elem in combinations(seq, n):
             couples = pairs(elem)
             if any([x in seen for x in couples]):
                 continue
             else:
                 seen = seen.union(couples)
                 res.append(elem)
     return res, seen

if __name__ == "__main__":
     already = set()
     text = "abcdefghijklmnop"
     final = list()

     final, already = combi(text, 4)

     print(final)

######################################################


Let me know if I correctly understood the problem.

Hope this helps

Francesco



From wlfraed at ix.netcom.com  Mon Apr  4 16:47:40 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Mon, 04 Apr 2022 16:47:40 -0400
Subject: [Tutor] problem solving with lists
References: <000001d83129$f99e9750$ecdbc5f0$@bluewin.ch>
 <t01ter$3um$1@ciao.gmane.io> <000401d831f7$3f9c7150$bed553f0$@bluewin.ch>
 <t04q15$mgi$1@ciao.gmane.io> <001301d83a0c$746c1ad0$5d445070$@bluewin.ch>
 <ff617f09-bcf1-1e06-5c9c-176eed3cce63@libero.it>
 <002601d84855$53903790$fab0a6b0$@bluewin.ch>
Message-ID: <tilm4hddqn3ufmmggla4f88d6k8qldiuqu@4ax.com>

On Mon, 4 Apr 2022 20:53:51 +0200, <marcus.luetolf at bluewin.ch> declaimed
the following:

>Hello Experts,
>Francesco Loffredo's solution looks very clean.
>It returns 15 sublists/teams in final, but 20 are required, for each item in text has to combine with
>every other item in 4 sublists/teams  5 times.

	Which is the correct result IF one does not restart the combinations
for each week. Restarting the combinations allows subsequent weeks to
select "teams" that were excluded in previous weeks.

	I've never modified the ooREXX code to restart, and to treat "current
week" differently from "previous weeks"...

C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>letters_set.rex 16 4
Accepted items: 15
abcd aefg ahij aklm
anop behk bfil bgjm
ceim cfhn cgko cjlp
dejn dfkp dghl

C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>

	That (my ooREXX) code is only looking for common pairs over the entire
period, and does not account for "player can not repeat within current
week". I suspect the same is true for the referenced code.

	The Python version with both 

        Constraint: all players are assigned to groups each week;
                    ie, no player may appear in multiple groups in the week
        Constraint: no pairs of players may repeat from week to week
                    (a solution may mean some players are never paired)

C:\Users\Wulfraed\Documents\_Hg-Repositories\Python Progs\SGP>main.py 4 4 5
Week # 0:       abcd    efgh    ijkl    mnop
Week # 1:       aeim    bfjn    cgko    dhlp
Week # 2:       afkp    belo    chin    dgjm
Week # 3:       agln    bhkm    cejp    dfio
Week # 4:       ahjo    bgip    cflm    dekn

C:\Users\Wulfraed\Documents\_Hg-Repositories\Python Progs\SGP>

	The main computation (no input parsing/output formatting)
-=-=-
from itertools import combinations

LETTERS = string.ascii_letters + string.digits


def main(num_groups, group_size, num_weeks):
    schedule =[ [ set() for _ in range(num_groups)] for _ in
range(num_weeks)]
    for wn, week in enumerate(schedule):
        #initialize generator of groupings at start of each week, so items
        #skipped in previous week are again candidates
        group_gen = combinations(LETTERS[:group_size * num_groups],
group_size)
        for gn, group in enumerate(week):
            while True:
                accept = True
                candidate = set(next(group_gen))
                #first filter for no duplicate players in this week
                for agroup in week[:gn]:
                    if not candidate.isdisjoint(agroup):    #if candidate &
agroup:
                        accept = False
                        break
                #filter for no duplicate pairs in previous weeks
                if accept:
                    for aweek in schedule[:wn]:
                        for agroup in aweek:
                            if len(candidate & agroup) > 1:
                                #repeated pair
                                accept = False
                                break
                        if not accept: break
                if accept:
                    #candidate has not been rejected, add it to current
week
                    week[gn] = candidate
                    break
    return schedule
-=-=-


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From mmirkhan at uci.edu  Mon Apr  4 18:02:45 2022
From: mmirkhan at uci.edu (Megan Ani Mirkhanian)
Date: Mon, 4 Apr 2022 15:02:45 -0700
Subject: [Tutor] (no subject)
Message-ID: <CAAEXh_MitP0+3RFczZVMuGMsuPdaprhExO6JmHimgA0CvAywvw@mail.gmail.com>

Hi,

I am writing a code to make my stepper motor back and forward.
I wrote the code and then at the bottom I created a for loop which commands
the stepper motor to go backwards and then forwards. I am trying to find a
way to make the two for loops variables so that when I want to make the
stepper motor go backwards I click on for instance x and enter and when I
want the stepper motor to go forward I click on for instance y and enter.
Is there a way to do this?

# Stepper1.py

import RPi.GPIO as GPIO
import time

IN_1 = 16  # adapt to your wiring IN1 is grey which is 16
IN_2 = 18 # IN2 is red which is 18
IN_3 = 7 # IN3 is yellow which is 7
IN_4 = 11 # IN4 is white which is 11
delay = 0.002 # time to settle

def setup():
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(IN_1, GPIO.OUT)
    GPIO.setup(IN_2, GPIO.OUT)
    GPIO.setup(IN_3, GPIO.OUT)
    GPIO.setup(IN_4, GPIO.OUT)

def forwardStep():
    setStepper(1, 0, 1, 0)
    setStepper(0, 1, 1, 0)
    setStepper(0, 1, 0, 1)
    setStepper(1, 0, 0, 1)
    setStepper(1, 0, 1, 0)
    setStepper(0, 1, 1, 0)
    setStepper(0, 1, 0, 1)
    setStepper(1, 0, 0, 1)


def backwardStep():
    setStepper(1, 0, 0, 1)
    setStepper(0, 1, 0, 1)
    setStepper(0, 1, 1, 0)
    setStepper(1, 0, 1, 0)
    setStepper(1, 0, 0, 1)
    setStepper(0, 1, 0, 1)
    setStepper(0, 1, 1, 0)
    setStepper(1, 0, 1, 0)

def setStepper(in1, in2, in3, in4):
    GPIO.output(IN_1, in1)
    GPIO.output(IN_2, in2)
    GPIO.output(IN_3, in3)
    GPIO.output(IN_4, in4)
    time.sleep(delay)

setup()

for i in range(256):
     backwardStep()

for i in range(256):
     forwardStep()

From PythonList at DancesWithMice.info  Mon Apr  4 22:41:06 2022
From: PythonList at DancesWithMice.info (dn)
Date: Tue, 5 Apr 2022 14:41:06 +1200
Subject: [Tutor] Input
In-Reply-To: <CAAEXh_MitP0+3RFczZVMuGMsuPdaprhExO6JmHimgA0CvAywvw@mail.gmail.com>
References: <CAAEXh_MitP0+3RFczZVMuGMsuPdaprhExO6JmHimgA0CvAywvw@mail.gmail.com>
Message-ID: <d35d9ba4-9490-7b8e-8f93-bcadf88d1073@DancesWithMice.info>

On 05/04/2022 10.02, Megan Ani Mirkhanian wrote:
> Hi,
> 
> I am writing a code to make my stepper motor back and forward.
> I wrote the code and then at the bottom I created a for loop which commands
> the stepper motor to go backwards and then forwards. I am trying to find a
> way to make the two for loops variables so that when I want to make the
> stepper motor go backwards I click on for instance x and enter and when I
> want the stepper motor to go forward I click on for instance y and enter.
> Is there a way to do this?
...


The easiest Python method is probably input():

    direction = input("Which direction, x or y? ")

followed by an if-construct to call either forward_step() or
backward_step().

Some ideas: https://pynative.com/python-input-function-get-user-input/

You may prefer pygame or something similar (https://www.pygame.org/news)
which facilitate both mouse and keyboard interrogation - and in a
fashion which may be familiar to robot-control.

More complicated is the Curses library:
https://docs.python.org/3/howto/curses.html which is terminal-oriented.

The above page also mentions libraries which enable "cursor-addressable
text output and full support for mouse and keyboard input." - in case
the "click on" means that you want mouse-control.

Finally, there are GUIs such as tkinter and Qt...
-- 
Regards,
=dn

From kaushalshriyan at gmail.com  Mon Apr  4 22:59:01 2022
From: kaushalshriyan at gmail.com (Kaushal Shriyan)
Date: Tue, 5 Apr 2022 08:29:01 +0530
Subject: [Tutor] The resource 'projects/gcloud-java-examples' was not found
Message-ID: <CAD7Ssm-uLWA+jf1JLLN8Lcv4fSpgjzmObB2yQ9uv5ro_wN2TZg@mail.gmail.com>

Hi,

I am using the GCP cloud platform and referring to
https://github.com/alfonsof/google-cloud-python-examples. Currently, I am
encountering the issue.

CentOS Stream release 8
# python3
Python 3.9.7 (default, Sep 21 2021, 00:13:39)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
# python3 --version
Python 3.9.7
#

#python3 computeengineinstances.py

MENU
0 = Quit
1 = List all VM instances
2 = Create VM instance
3 = List VM instance
4 = Start instance
5 = Stop instance
6 = Reset instance
7 = Delete instance

Enter an option? 1
Listing VM instances ...
Traceback (most recent call last):
  File
"/root/google-cloud-python-examples/gcloudcomputeengine/computeengineinstances.py",
line 56, in <module>
    main()
  File
"/root/google-cloud-python-examples/gcloudcomputeengine/computeengineinstances.py",
line 33, in main
    computeenginehelper.list_instances()
  File
"/root/google-cloud-python-examples/gcloudcomputeengine/computeenginehelper.py",
line 27, in list_instances
    response = compute.instances().list(project=PROJECT_NAME,
zone=ZONE_NAME).execute()
  File
"/usr/local/lib/python3.9/site-packages/googleapiclient/_helpers.py", line
131, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/googleapiclient/http.py",
line 937, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting
https://compute.googleapis.com/compute/v1/projects/gcloud-java-examples/zones/us-east1-b/instances?alt=json
returned "The resource 'projects/gcloud-java-examples' was not found".
Details: "[{'message': "The resource 'projects/gcloud-java-examples' was
not found", 'domain': 'global', 'reason': 'notFound'}]">

When i run gcloud command it works.

#gcloud compute instances list
NAME                                                 ZONE
 MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
docker-drupal-krishnamohan                           europe-west2-a
 e2-medium                   10.0.0.30    34.142.12.199   RUNNING
gke-dac-drupal-gke-clust-default-pool-92350ba9-390b  europe-west2-a
 n2-standard-2               10.0.0.27    35.189.124.212  RUNNING
gke-dac-drupal-gke-clust-default-pool-b42e3504-sss9  europe-west2-b
 n2-standard-2               10.0.0.25    35.197.228.58   RUNNING
apache-cassandra-servicetest-jineesh                 europe-west2-c
 e2-medium                   10.0.0.18                    TERMINATED
apache-servicetest-jineesh                           europe-west2-c
 e2-medium                   10.0.0.13    35.197.224.90   TERMINATED
apigee-1node-test-instance                           europe-west2-c
 n2-standard-2               10.0.0.20                    TERMINATED
apigee-servicetest-jineesh                           europe-west2-c
 e2-standard-2               10.0.0.22                    TERMINATED
gke-dac-drupal-gke-clust-default-pool-ee4376e8-lx9g  europe-west2-c
 n2-standard-2               10.0.0.26    35.246.48.65    RUNNING
hsbctest-instance-1                                  europe-west2-c
 e2-medium                   10.0.0.9     35.234.154.248  TERMINATED
jenkins-sreejith                                     europe-west2-c
 e2-medium                   10.0.0.23                    TERMINATED
nginx-servicetest-jineesh                            europe-west2-c
 e2-medium                   10.0.0.10                    TERMINATED
pgql-servicetest-jineesh                             europe-west2-c
 e2-medium                   10.0.0.19                    TERMINATED

Any clue regarding the below issue?

googleapiclient.errors.HttpError: <HttpError 404 when requesting
https://compute.googleapis.com/compute/v1/projects/gcloud-java-examples/zones/us-east1-b/instances?alt=json
returned "The resource 'projects/gcloud-java-examples' was not found".
Details: "[{'message': "The resource 'projects/gcloud-java-examples' was
not found", 'domain': 'global', 'reason': 'notFound'}]">

What is the purpose of computeenginehelper.py file as per the below details?

[root at gcloudcomputeengine]# ll
total 20
-rw-r--r-- 1 root root 2582 Mar 10 00:13 README.md
drwxr-xr-x 2 root root   48 Mar 10 00:14 __pycache__
-rw-r--r-- 1 root root 5740 Mar 10 00:13 computeenginehelper.py
-rw-r--r-- 1 root root 1641 Mar 10 00:13 computeengineinstances.py
[root at gcloudcomputeengine]#

Please guide and suggest. Thanks in advance.

Best Regards,

Kaushal

From alan.gauld at yahoo.co.uk  Tue Apr  5 05:18:37 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Tue, 5 Apr 2022 10:18:37 +0100
Subject: [Tutor] (no subject)
In-Reply-To: <CAAEXh_MitP0+3RFczZVMuGMsuPdaprhExO6JmHimgA0CvAywvw@mail.gmail.com>
References: <CAAEXh_MitP0+3RFczZVMuGMsuPdaprhExO6JmHimgA0CvAywvw@mail.gmail.com>
Message-ID: <t2h1hd$10pe$1@ciao.gmane.io>

On 04/04/2022 23:02, Megan Ani Mirkhanian wrote:

> the stepper motor to go backwards and then forwards. I am trying to find a
> way to make the two for loops variables so that when I want to make the
> stepper motor go backwards I click on for instance x and enter and when I
> want the stepper motor to go forward I click on for instance y and enter.

I'm not clear about what you want to know.

Is it how to build a UI that responds to clicks?
If so what kind of UI do you need? A CLI (aka terminal)
or a GUI or a web page? All are possible but all are
quite different.

Or is it how to switch between forward and backwards motion based on
whether x or y is set?

In fact I'd suggest a single variable called 'direction' and set it
to 'forward' or 'backward'. Alternatively use a boolean variable
called forward and set that to True or false.

Then you can write

if forward:
   for _ in range(256); forwardStep()
else:
   for _ in range(256): backwardStep()

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From alan.gauld at yahoo.co.uk  Tue Apr  5 05:24:16 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Tue, 5 Apr 2022 10:24:16 +0100
Subject: [Tutor] The resource 'projects/gcloud-java-examples' was not
 found
In-Reply-To: <CAD7Ssm-uLWA+jf1JLLN8Lcv4fSpgjzmObB2yQ9uv5ro_wN2TZg@mail.gmail.com>
References: <CAD7Ssm-uLWA+jf1JLLN8Lcv4fSpgjzmObB2yQ9uv5ro_wN2TZg@mail.gmail.com>
Message-ID: <t2h1s0$llt$1@ciao.gmane.io>

On 05/04/2022 03:59, Kaushal Shriyan wrote:

> https://github.com/alfonsof/google-cloud-python-examples. Currently, I am
> encountering the issue.
> 
> line 937, in execute
>     raise HttpError(resp, content, uri=self.uri)
> googleapiclient.errors.HttpError: <HttpError 404 when requesting
> https://compute.googleapis.com/compute/v1/projects/gcloud-java-examples/zones/us-east1-b/instances?alt=json
> returned "The resource 'projects/gcloud-java-examples' was not found".
> Details: "[{'message': "The resource 'projects/gcloud-java-examples' was
> not found", 'domain': 'global', 'reason': 'notFound'}]">

Usually these kinds of errors are down to either path names being wrong
or permissions not being set.

> When i run gcloud command it works.
> 
> #gcloud compute instances list

I have no idea how that works, but it may not be working the same way
your app works. So it may not prove anything. Can you retrieve the
"missing" resource using an http request? Perhaps using the urllib module?

> What is the purpose of computeenginehelper.py file as per the below details?
> 
> [root at gcloudcomputeengine]# ll
> total 20
> -rw-r--r-- 1 root root 2582 Mar 10 00:13 README.md
> drwxr-xr-x 2 root root   48 Mar 10 00:14 __pycache__
> -rw-r--r-- 1 root root 5740 Mar 10 00:13 computeenginehelper.py
> -rw-r--r-- 1 root root 1641 Mar 10 00:13 computeengineinstances.py

I assume it contains helper functions used by the other file.
But you can open it and read the code to see what it does.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From wlfraed at ix.netcom.com  Tue Apr  5 11:18:12 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Tue, 05 Apr 2022 11:18:12 -0400
Subject: [Tutor] (no subject)
References: <CAAEXh_MitP0+3RFczZVMuGMsuPdaprhExO6JmHimgA0CvAywvw@mail.gmail.com>
Message-ID: <20mo4hh7ikcvkrhlhiv6sp5dti7hd8fp60@4ax.com>

On Mon, 4 Apr 2022 15:02:45 -0700, Megan Ani Mirkhanian <mmirkhan at uci.edu>
declaimed the following:

>way to make the two for loops variables so that when I want to make the
>stepper motor go backwards I click on for instance x and enter and when I
>want the stepper motor to go forward I click on for instance y and enter.
>Is there a way to do this?
>

	This is rather cloudy... WHAT are "instance x" and "instance y"? Also,
are you using some sort of H-bridge circuit card, or trying to do direct
wire control? 

>def forwardStep():
>    setStepper(1, 0, 1, 0)
>    setStepper(0, 1, 1, 0)
>    setStepper(0, 1, 0, 1)
>    setStepper(1, 0, 0, 1)
>    setStepper(1, 0, 1, 0)
>    setStepper(0, 1, 1, 0)
>    setStepper(0, 1, 0, 1)
>    setStepper(1, 0, 0, 1)
>

	EEEEK!

	If I understand that, you are performing TWO cycles on each call (the
last four duplicate the first four).

	The first thing I'd do is strip out the magic numbers...

FORWARD = [ (1, 0, 1, 0), (0, 1, 1, 0), (0, 1, 0, 1), (1, 0, 0, 1) ]
REVERSE = [ ... ]

... and loop through that (this does just ONE cycle, add extra phases as
needed)...

def stepMotor(sequence):
	for phase in sequence:
		setStepper(*phase)

	You'd then just have some conditional that selects which of FORWARD or
REVERSE gets passed to the stepMotor() invocation.

>def setStepper(in1, in2, in3, in4):
>    GPIO.output(IN_1, in1)
>    GPIO.output(IN_2, in2)
>    GPIO.output(IN_3, in3)
>    GPIO.output(IN_4, in4)
>    time.sleep(delay)

	
	HOWEVER!

	Have you looked at https://github.com/gavinlyonsrepo/RpiMotorLib
(high-level, once set-up there are things like .run() methods) and/or
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-10-stepper-motors/software
(which is a lower-level, basically similar to what you are attempting)


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From marcus.luetolf at bluewin.ch  Wed Apr  6 14:43:14 2022
From: marcus.luetolf at bluewin.ch (marcus.luetolf at bluewin.ch)
Date: Wed, 6 Apr 2022 20:43:14 +0200
Subject: [Tutor] problem solving with lists, coding problems
Message-ID: <000801d849e6$2c7b6660$85723320$@bluewin.ch>

Hello Experts again,
after a break  I've resumed my task and broken up my problem into several
steps  folowing your advises below but I'm running now into coding problems:

In my first step to draw players for the 4 tflights/sublists for day_1
(instead of week_1) I was to create a player_history  beginning with the
first player ('a')
oft he first flight/sublist ( (player_history_a).
 Using set comprehension as mentioned in your text below a dictionary was
returned:
> player_history_a:  {'a': {'a'}, 'b': {'b'}, 'c': {'c'}, 'd': {'d'}}

I expected:  player_history_a:  {'a': { 'b', 'c', 'd'}}, so I got something
wrong.

My code (not having it converted to a function yet): 

>all_players = list('abcdefghijklmnop')  # this variable as a string throws
errors
>c_all_players = all_players[:]

>flight_1_day_1 = []
>flight_2_day_1 = []
>flight_3_day_1 = []
>flight_4_day_1 = []

>for player in c_all_players[0:4]:
>    flight_1_day_1.append(player)
>    player_history_a = {player:{player} for player in flight_1_day_1}
>print('player_history_a: ',player_history_a)         
>del c_all_players[0:4]
    
>for player in c_all_players[0:4]:
>    flight_2_day_1.append(player)
>del c_all_players[0:4]

>for player in c_all_players[0:4]:
>    flight_3_day_1.append(player)
>del c_all_players[0:4]

>for player in c_all_players[0:4]:
>    flight_4_day_1.append(player)
         
>print('flight_1_day_1: ', flight_1_day_1)
>print('flight_2_day_1: ', flight_2_day_1)
>print('flight_3_day_1: ', flight_3_day_1)
>print('flight_4_day_1: ', flight_4_day_1)
 
So,please  where is my error ?

Regards, Marcus.


-----Urspr?ngliche Nachricht-----
Von: Tutor <tutor-bounces+marcus.luetolf=bluewin.ch at python.org> Im Auftrag
von dn
Gesendet: Montag, 21. M?rz 2022 11:14
An: tutor at python.org
Betreff: Re: [Tutor] problem solving with lists

On 21/03/2022 21.51, marcus.luetolf at bluewin.ch wrote:
> ...yes, the weekly Draws below  are exactly what I have in mind !!!
> And I realised earlier that "I asked the wrong questions". But with 
> your Cooments about the solution I think I can find a solution myself.
> It was never my intention to let tutor do my "homework", I had learned
nothing.
> Thanks, Marcus.

Excellent news!

Keep going! (here)

Follow earlier suggestions of defining meaningful terminology by first
writing (specifying) the problem, as completely as you can. All those
detailed clauses, as we say in English: "the if-s, the but-s, and the
maybe-s" are the details which cause trips and stumbles.

A lot of programmers rush to start coding. The above is well-worth spending
the time - and if the spec[ification] has come from someone else (as it
would in a commercial environment), this is where we find, as early as
possible, that the client hasn't given us the full-story!

As you say, the key to it all is to ask the 'right' questions and document
the requirements and 'rules'.

Once the problem is clearly understood, we can start looking for solutions.
Often there is more than one, and certainly more than one way to approach
building a solution.

These are the major steps of "program[me] design". Again, it is worth
checking and re-checking, because errors caught early in the development
process are cheaper (time and/or $) to fix, than those not realised until
later. Thus, the completed work described earlier was a second, and longer,
version of the first - so a complete re-write became necessary because I did
not understand what was needed!

Now you understand why there was evidence of frustration in the way people
were replying to you!


Next try to break-up the chosen solution into stages or phases. In this
case, I think of a League (or competition) which will take
(number_of_weeks) five weeks before all 'unique' combinations of players can
be played. Each week requires its own "draw", which will consist of
(number_of_groupings) four groups of players. Each group of players will
consist of (players_per_grouping) four players - who have never played with
each-other before (in this league/competition).

You can see that the overall solution consists of sub-solutions to
sub-problems. It's a bit like those inter-locking Russian dolls, or
(?Swiss) chocolates with a center and multiple layers/flavors inside a hard
chocolate coating. We also refer to it as like an onion. This approach to
problem-solving is called "stepwise decomposition" (or "- refinement). It is
the process of dividing a large problem into smaller problems, and those
into smaller... until the small problem is one that is easy to solve.

The beauty of this is that if you have a correct and sensible design (easily
said, not so easily done!), it should be possible to write and test (or
'prove') each 'unit' or sub-solution of the code, by itself - which is a
good deal easier than trying to test the whole 'onion' and not being sure
where some failure or error is caused within the mass of code! What happens
when you have to cut-up a (real) onion?

I tend to code each 'layer' as a function. Indeed after choosing the name of
the function (and writing the def ... line), I'll add a docstring which is
basically that section of the 'design' (from earlier). I'll repeat this
until the whole problem has been covered.
Only then, do I sit down to start writing code for the smallest of the
sub-solutions (or, the inner-most layer of the onion/chocolate).


Now, to help you on your way, here are a few other data-structures which I
used:

weekly_draws = list()

- to hold the [five] weeks' draws
- perhaps only necessary if you're going to do something with this data (I
was only printing it out)

player_history = { player:{ player } for player in players }

- to hold the set of players who this player has previously played
- rather than complicating loop-controls (or maybe adding lots of one-time
if-conditions) within the code, it seemed easier to initialise each player's
set with him-/her-self - after all, under the 'rules' you cannot play
someone you've already played, nor can you play yourself.
(two 'rules' for the price of one!)
- this 'one-liner' code-construction is called a "set-comprehension" and I
very rarely see/use one - whereas their close-relatives,
"list-comprehensions", are very common.


If you'd like to post your sub-solutions (text-design, plus Python-code),
we'll be happy to help you along...
--
Regards,
=dn
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


From wlfraed at ix.netcom.com  Wed Apr  6 17:10:33 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Wed, 06 Apr 2022 17:10:33 -0400
Subject: [Tutor] problem solving with lists, coding problems
References: <000801d849e6$2c7b6660$85723320$@bluewin.ch>
Message-ID: <b7vr4h12j2l2o9bc3l72o2jvl6qaq73vc7@4ax.com>

On Wed, 6 Apr 2022 20:43:14 +0200, <marcus.luetolf at bluewin.ch> declaimed
the following:

>
>>all_players = list('abcdefghijklmnop')  # this variable as a string throws
>errors

	What error? Where?

>>c_all_players = all_players[:]
>


>>> all_players = "abcdefghijklmnop"
>>> c_all_players = all_players[:]
>>> 

No error here... Though I again have to question your reliance on defining
one iterable, only to make a complete copy of the very same iterable.

>>flight_1_day_1 = []
>>flight_2_day_1 = []
>>flight_3_day_1 = []
>>flight_4_day_1 = []
>

	Similarly your use of hard-coded groups here rather than some structure
on which you can perform a loop.

>>for player in c_all_players[0:4]:
>>    flight_1_day_1.append(player)
>>    player_history_a = {player:{player} for player in flight_1_day_1}

	Take a pencil and paper, and run that loop by hand. For one thing, you
have the list comprehension INSIDE the for loop -- and both the list-comp
and the for loop are using the same NAME for their control variables!

	Consider (I changed the control name in the list-comp to make it
explicit)

>>> flight_1_day_1 = []
>>> for player in all_players[0:4]:
... 	flight_1_day_1.append(player)
... 	print(flight_1_day_1)
... 	player_history_a ={plr : {plr} for plr in flight_1_day_1}
... 	print(player_history_a)
... 
['a']
{'a': {'a'}}
['a', 'b']
{'a': {'a'}, 'b': {'b'}}
['a', 'b', 'c']
{'a': {'a'}, 'b': {'b'}, 'c': {'c'}}
['a', 'b', 'c', 'd']
{'a': {'a'}, 'b': {'b'}, 'c': {'c'}, 'd': {'d'}}
>>> 

	All the above is equivalent to...

>>> f1d1 = list(all_players[0:4])
>>> print(f1d1)
['a', 'b', 'c', 'd']
>>> pha = { plr : {plr} for plr in f1d1}
>>> print(pha)
{'a': {'a'}, 'b': {'b'}, 'c': {'c'}, 'd': {'d'}}
>>> 

>>print('player_history_a: ',player_history_a)         
>>del c_all_players[0:4]
>
	The only place I can see that would throw an error is the use of that
"del" statement, as strings are immutable. The effect is equivalent to...

	c_all_players = c_all_players[4:]

	But then, I'd drop even that... You have hard-coded so much already
that does not support looping that you might just as easily hard-code the
substring ranges...

	for player in all_players[0:4]:
...

    
>>for player in c_all_players[0:4]:

	for player in all_players[4:8]:

...repeat with 8:12 and 12:16


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From woodsgav000 at students.centergrove.k12.in.us  Fri Apr  8 14:02:01 2022
From: woodsgav000 at students.centergrove.k12.in.us (Gavin Woods)
Date: Fri, 8 Apr 2022 14:02:01 -0400
Subject: [Tutor] Center Grove Student Mentoring Question
Message-ID: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>

Dear Python Tutor,



My name is Gavin, and I am a 7th grade student at Center Grove Middle
School Central in Greenwood, IN. In my LA class, we are working on a
project called "Genius Hour." For this project, we are asked to choose a
topic that we are passionate about. One component of this project is
seeking a mentor who can help answer questions about the topic we chose.
That is why I'm reaching out to you. My topic for my Genius Hour Project is
how to code. I was hoping you could answer some questions that I have
regarding my project.

1. Are there any specific websites/videos that I can use to help me learn
python?

2. What are some useful tips for beginners?

3. If there was one thing you knew before coding, what would it be?

Thank you so much for taking the time to read my email. I hope you will be
able to help me. If possible, would you please respond to this email by
Friday, April 23rd? I look forward to hearing from you. If you have any
questions regarding my project, you can contact me or my LA teachers at the
following email addresses:

Sincerely,

[FIRST NAME]

For questions, please email my teachers: (Mrs. Sarah Pironello)
pironellos at centergrove.k12.in.us or (Ms. Olivia Hornsby)
hornsbyg at centergrove.k12.in.us

From alan.gauld at yahoo.co.uk  Fri Apr  8 15:42:15 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Fri, 8 Apr 2022 20:42:15 +0100
Subject: [Tutor] Center Grove Student Mentoring Question
In-Reply-To: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
References: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
Message-ID: <t2q36o$iuc$1@ciao.gmane.io>

On 08/04/2022 19:02, Gavin Woods wrote:

> seeking a mentor who can help answer questions about the topic we chose.

As a group we can fulfil that brief, we just don't do one-on-one
mentoring. But we will answer any questions relating to the Python
language, its standard library of modules and general
coding principles (aka software engneering).

We will also critique code samples (up to, say, 100 lines or so).
We won't do your homework for you but we will suggest approaches
you might take and things to avoid.

We like to see real code and full error messages (and sample data
when appropriate). But don't include screen shots or other
images - the serbver strips them off for security.

> 1. Are there any specific websites/videos that I can use to help me learn
> python?

Literally dozens, including mine :-)

But if you visit the python.org site there are start pages for
programmers and non-programmers, each with links to multiple
tutorials.

> 2. What are some useful tips for beginners?

Write code, the more the better. Don;t just cut n paste - get used to
typing the constructs.

Don't just do the minimum suggested by the tutorial (even mine :-)
Experiment with different values, add extra features. See if the code
does what you expect and if not work out why - or ask here if you can't
figure it out..

Use print() profusely to see what is happening in your code..

Remember that computers are fundamentally stupid! They won't guess
what you mean, they will interpret exactly what you type and nothing
more. It might seem obvious to you but it won't be to python.

> 3. If there was one thing you knew before coding, what would it be?

All of the above!
Plus coding is way harder than I expected and also it's a lot
of fun in a masochistic kind of a way.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From PythonList at DancesWithMice.info  Fri Apr  8 17:06:19 2022
From: PythonList at DancesWithMice.info (dn)
Date: Sat, 9 Apr 2022 09:06:19 +1200
Subject: [Tutor] Center Grove Student Mentoring Question
In-Reply-To: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
References: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
Message-ID: <159a9e50-63b3-0bd3-d927-e43938cbc6fa@DancesWithMice.info>

Welcome to our happy band!


On 09/04/2022 06.02, Gavin Woods wrote:
...

> project called "Genius Hour." For this project, we are asked to choose a

Good to hear! I'm a great believer in the constructivist approach (ask
your teacher if you don't know how that philosophy under-pins "Genius
Hour") and wish more of 'school' worked this way.

Fundamentally all good programmers are driven by what is referred-to as
a "need for achievement". We like to get things done. We don't let
(sometimes repeated) problems/faults/"bugs" get in the way. Intrinsic
motivation (another term you may need to ask about) is the only way one
can cope with a machine that stubbornly (only) does things its own way...


> seeking a mentor who can help answer questions about the topic we chose.
> That is why I'm reaching out to you. My topic for my Genius Hour Project is
> how to code. I was hoping you could answer some questions that I have
> regarding my project.

If you/your teachers/'the rules' specifically require "a mentor" (as in
one person - whereas we are a group), you should 'look-around' because
there's bound to be someone-local who'll assist.

There is an active "IndyPy" PUG (Python Users' Group) - I don't recall
if that is "Indy" as in "Indiana" or in "Indianapolis", but you'll work
it out. They will be holding a meeting next week, and although the topic
looks rather advanced (certainly not for a raw beginner), you may like
to go-along and see if you can make a few 'contacts' - face-to-face
shows willing and makes for a good first-impression! Please review
https://indypy.org/ and see if you can find contact and meeting details
to-suit...


> 1. Are there any specific websites/videos that I can use to help me learn
> python?


@Alan has already provided a link to his course. If you work through
that, and find a question, we'll be delighted to help you learn.

An alternative might be a MOOC (Massively Open Online Course - whereas
my first lecture was delivered to ~300 university students, these days
we count in hundreds of thousands of trainees!). 'Mine' are not Python,
but there are plenty available on both the Coursera and edX platforms.
The advantage of these is that alongside the lessons, they run
Discussion Boards. These are constrained to members of the one course,
and split across sessions; enabling (staff and) trainees at the same
level to discuss the same topic (and for you to read other/previous
people's questions, and responses - also, as you gain confidence, to
contribute to others' learning!). Further disclosure: I was asked to
audit (some of?) the U.Mich Python courses on Coursera, and found them
useful.

Another approach might be to use a (text) book. This will also provide
you with the structure and direction of a learning-plan (which is what
"course" also means!). However, a book will not meet the "socialisation"
context which you enjoy when working alongside class-mates - unless
there are others in your cohort with similar aims.


> 2. What are some useful tips for beginners?

A spirit of enquiry. A drive towards continuous learning. A preparedness
to be told "you are wrong" without mercy - we've already tried to
challenge you with 'the bad news'.


> 3. If there was one thing you knew before coding, what would it be?

How grey I'd become four~five decades later...


...> questions regarding my project, you can contact me or my LA
teachers at the
> following email addresses:

Communication is at the heart of programming - communicating with the
machine, but also communicating with one's colleagues. (in truth many of
us better at the former, than the latter) I'll emphasise that to saying
'communicating clearly and unambiguously'.

Ask yourself (and your favorite search engine) if "LA" communicates to
people who are not teachers or school-students? "Los Angeles",
"Louisiana", "Loud Artists", "Layabout", ...???

-- 
Regards,
=dn

From wlfraed at ix.netcom.com  Fri Apr  8 19:41:06 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Fri, 08 Apr 2022 19:41:06 -0400
Subject: [Tutor] Center Grove Student Mentoring Question
References: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
Message-ID: <uig15hpk985cofgaijoqnhp38r47fdqqtk@4ax.com>

On Fri, 8 Apr 2022 14:02:01 -0400, Gavin Woods
<woodsgav000 at students.centergrove.k12.in.us> declaimed the following:

>That is why I'm reaching out to you. My topic for my Genius Hour Project is
>how to code. I was hoping you could answer some questions that I have
>regarding my project.
>

	Don't take this too negatively, but "how to code" is somewhat limiting
-- at least in the industry I went through. "coders" were the bottom rung
(computer operator might have been lower -- they were responsible for
changing ribbons on printers, loading printer paper, swapping mag-tape
reels, and feeding card decks to the mainframe; and maybe running specific
programs at scheduled times in accordance with a "run book"). "coders" were
responsible for taking requirements and algorithms provided by higher level
people (program and system analysts) and turning them into runable code.

	For example -- an electronic checkbook register (have you even
encountered paper checks? <G>).

Input is a time-ordered sequence of checks (withdrawals) and deposits to
the checking account, along with the previous saved check register.
Output is an updated (saved) check register containing the new
transactions, along with a report of the final account balance (or a
listing of the transactions with a running total), and any warnings of
overdrafts (balance less than 0.00).

	Requirements may include clauses for validation of inputs (check
numbers are in ascending sequence or voided, etc.)

	Presuming you mean to come up with an application from scratch, and not
rely upon someone handing you all the high-level work leaving you to
translate into a specific language, you may want to look into tutorials on
"software engineering" -- save OOAD/OOP (object oriented analysis and
design/object oriented programming) for later (though you will run into OOP
at some point if using Python, as much of the standard library is OOP
based.

	At those higher levels, software engineering is language neutral (it
may be difficult, but one can do OOAD with a non-OOP language at the end).

	Starting points: The documentation that comes with most Python installs
should have the language reference manual, the language tutorial, and the
library reference manual. You'll be using the library reference a lot,
though you don't have to memorize all the packages -- the most used will be
the chapters on the standard data types in Python, maybe os and os.path. A
lot of the packages are specific to various Internet protocols which you
may not need.

	Read the tutorial, get familiar with the language reference, and browse
the library reference.

>1. Are there any specific websites/videos that I can use to help me learn
>python?
>
	I don't have any experience with online videos for learning
programming. I tend to prefer printed textbooks, or PDF files, that allow
me to flip back and forth.



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From martin at linux-ip.net  Fri Apr  8 22:13:24 2022
From: martin at linux-ip.net (Martin A. Brown)
Date: Fri, 8 Apr 2022 19:13:24 -0700
Subject: [Tutor] Center Grove Student Mentoring Question
In-Reply-To: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
References: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
Message-ID: <11d8fe50-2bab-6bf-6371-71ff779cdf@wonderfrog.net>


> My name is Gavin, and I am a 7th grade student at Center Grove 
> Middle School Central in Greenwood, IN.

Welcome!  You have definitely reached a decent cross-section of 
Python practitioners by emailing this list.  And, thank you for 
introducing yourself and framing your question.

> In my LA class, we are working on a project called "Genius Hour." 

I'm also not sure what "LA class" might be.  Language Arts?

> For this project, we are asked to choose a topic that we are 
> passionate about. One component of this project is seeking a 
> mentor who can help answer questions about the topic we chose. 
> That is why I'm reaching out to you. My topic for my Genius Hour 
> Project is how to code. I was hoping you could answer some 
> questions that I have regarding my project.

> 1. Are there any specific websites/videos that I can use to help 
>    me learn python?

Tons.  The wealth of options boggles the mind.

  * https://docs.python.org/3/tutorial/
  * https://www.w3schools.com/python/
  * 
Concomitant with the rise of the Internet came email distribution 
lists (like this), newsgroups (now less common), discussion forum 
technology, and distributed software development, and an 
increasing interest in open source software.

Why do I mention that now?  Python grew amid these sociocultural 
features and is a lovely example of cooperative, non-hierarchical 
development of software languages.

One of the many results is tons of material, both available for sale 
(books, courses) and also freely available (examples above, 
including Alan Gauld's posting).

What you have found here, Gavin, is a bunch of people who really 
enjoy Python and look forward to the opportunity to share it with 
others who wish to learn.  The list is geared toward specific "how 
do I solve this problem" or "how do I understand this Python 
concept" as well more general questions like yours.

Lastly, your question is "are there any specific websites/videos 
that I can use to help me learn python".... yes, we could probably 
each send you dozens, or scores of possibilities!

I will also point out that you might find a similar response if you 
were to send a similar question to a group of people who were 
interested in other programming languages such as Java, C, Rust, 
Ruby, Javascript, Go and many others.  Of course, since we are all 
denizens of the Python list, we are geared to tell you about the 
joys and wonders of Python!

> 2. What are some useful tips for beginners?

Practice, practice, practice.  Read, read, read.

One of my general top suggestion for anybody trying to write 
anything in any (new-to-them) programming language is to already 
have a project, task, challenge in mind.  Here are some examples, 
but this can and should be something that interests you.

  * Fetch and display some content from a website.
  * Re-encode all sound / songs from one format to another.
  * Write a chat bot.
  * Write a temperature controller for an oven/smoker.

(I knew one person whose choice was to write an IRC server to learn 
a new language, and another who would write a fractal generator.)

Once you know what you want to write.... don't start there directly, 
but figure out what things you need to do in the new language and 
write a bunch of "toys".  This is the practice that allows you to 
you pick up the skills by writing "toy" programs or exercises that 
allow you to practice your mental facility with the required 
features of the language (data structures, how to read or write 
files, how to print text, draw graphics, send or receive data from a 
network, perform computations on things).

Feel free to throw away the toys when you are done or keep them if 
you wish (I keep mine in a folder called ~/python/learning/).  If 
one toy, concept or language feature is hard, step away from it for 
a day or so and practice on some other toys or language features.

Some common "toys" that I have written in several languages I have 
learned:

  * Open a file, read it into memory print it to screen.  "cat"
  * Open a file, read it line by line, print matching lines "grep"
  * Compute the circumference of a circle from its radius.
  * Fetch content from a website and print out one specific thing.
  * Get the computer to create a "bag" of 1000 marbles of different 
    random colors and then count the number of each color.

Then go find and read other examples of your successful toys.  Find 
examples where other people solved similar problems.  Note!  This is 
hard work, reading somebody else's programs, but it is also a 
valuable skill, just like reading somebody else's letter, article or
book.  By reading, you may see how somebody else did that thing that 
you were having trouble with.

Then, practice re-writing the toys to get better, clearer, shorter, 
faster.  This is like all practice:  running, throwing darts, 
juggling, riding horses -- practicing these things is like working 
on your form in javelin toss or swimming.  The more you can write 
the toys effortlessly, the more you find that you can assemble 
things that are no longer toys.

If you were learning French, you might learn two different ways to 
express the same idea.

This is very useful for a beginner because every human language and 
programming language captures and express ideas differently.  And, 
sometimes you might say:  "Shall we go to dinner?" and other times 
you might say "Yo, let's get some grub!"  And, it takes awareness 
and practice to know when to say each of those things.

If you know the circumstances and people very well, it could be 
appropriate to say the latter.  If you don't know the circumstances 
and people, you might choose the former option, which is a bit more 
formal.

Programming languages often do something similar.  If you know your 
data, say, in this case a dictionary that might (or might not) have 
a record of distances for each javelin thrower at a track meet:

  # -- grab "distances" from "data" (dictionary)... if not present
  #    use a list with 0 meters ...
  #
  max_meters = max(data.get('distances', [0]))

  # -- here, we know "distances" key exists in "data"
  #
  max_meters = max(data['distances'])

The point is that usually there are several acceptable ways to solve 
a problem, even in very simple toy problems, so you can practice 
using the different techniques.  This is similar to learning to 
suggest a prandial outing.

(No, I'm not suggesting you take Python to a candlelit dinner, 
although who knows what it might tell you about floats, strings, 
iterators and the occasional Exception?)

> 3. If there was one thing you knew before coding, what would it be?

I'm assuming this is "if there one thing you wish you knew before 
coding" ....

A most difficult question to answer, so I will leave this for 
others.

 * I frequently find colleagues teaching me the relevance of a new 
   way to look at a question or a problem.  So don't forget that the 
   learning mode with computers never stops.... so you can 
   absolutely discover what you don't yet know and take the time to 
   learn it then.

 * Such a big topic that I'm not sure how to answer, but I will say 
   that I re-learn frequently that patience when learning new 
   languages and touching new computer systems is warranted.

> Thank you so much for taking the time to read my email. I hope you 
> will be able to help me. If possible, would you please respond to 
> this email by Friday, April 23rd? I look forward to hearing from 
> you. If you have any questions regarding my project, you can 
> contact me or my LA teachers at the following email addresses:

I hope my answers and those from others on the mailing list help you 
in your project.

Good luck, Gavin, and thank you for your courteous request to the 
mailing list.

-Martin

-- 
Martin A. Brown
http://linux-ip.net/

From juliushamilton100 at gmail.com  Sat Apr  9 06:19:51 2022
From: juliushamilton100 at gmail.com (Julius Hamilton)
Date: Sat, 9 Apr 2022 12:19:51 +0200
Subject: [Tutor] Pyenv; path; packages
Message-ID: <CAEsMKX2hMZL8_szYPUSOr6tjna_Bp+WG=aAaMKtmNixLjaRhSw@mail.gmail.com>

Hey,

I installed pyenv with homebrew on Mac but it did not automatically put the
path to the installed version (3.7.13) in my path. The command ?python? is
not recognized. I can invoke it by invoking the full path to the
installation.

Why isn?t it in my path by default? Did I mess a step of the installation
or something? Should I just add it myself or what is the standard practice
here?

I have packages installed via my system pip3 (for Python 3.8.9) and it
seems the Python I installed via pyenv can?t find them.

Am I supposed to reinstall all packages for Python 3.7.13? Is it really the
case that the packages for Python 3.8.9 won?t work with Python 3.7.13?

I?m just trying to use the same set up I have but with an older version of
Python. Someone said I don?t need a virtual environment for this, just an
older installation of Python. I saw I could download a binary for Python
3.7 as well.

Is the simplest to just download that binary, make an alias for the path to
it and I?m good to go?

Thanks very much,
Julius

From mats at wichmann.us  Sat Apr  9 09:34:15 2022
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 9 Apr 2022 07:34:15 -0600
Subject: [Tutor] Pyenv; path; packages
In-Reply-To: <CAEsMKX2hMZL8_szYPUSOr6tjna_Bp+WG=aAaMKtmNixLjaRhSw@mail.gmail.com>
References: <CAEsMKX2hMZL8_szYPUSOr6tjna_Bp+WG=aAaMKtmNixLjaRhSw@mail.gmail.com>
Message-ID: <ac054193-d499-16bc-2953-6c8a71999af4@wichmann.us>

On 4/9/22 04:19, Julius Hamilton wrote:
> Hey,
> 
> I installed pyenv with homebrew on Mac but it did not automatically put the
> path to the installed version (3.7.13) in my path. The command ?python? is
> not recognized. I can invoke it by invoking the full path to the
> installation.
> 
> Why isn?t it in my path by default? Did I mess a step of the installation
> or something? Should I just add it myself or what is the standard practice
> here?

pyenv requires some support in your shell, there should have been
instructions how to add this to the startup file. The pyenv data
directory needs to be in your search path.

> 
> I have packages installed via my system pip3 (for Python 3.8.9) and it
> seems the Python I installed via pyenv can?t find them.
> 
> Am I supposed to reinstall all packages for Python 3.7.13? Is it really the
> case that the packages for Python 3.8.9 won?t work with Python 3.7.13?

Yes.  While there are packages that are version-agnostic (usually, these
are the ones that are pure Python and don't have any compiled bits),
they still need to be in a path that the Python interpreter you'll be
using is going to look in.  Each version of Python will have a matching
pip that installs to the right paths for that Python, so by far the
easiest way to make multiple versions work is to let the appropriate pip
do its thing.

It's worth learning to use virtualenvs, they're quite easy, and if you
install the plugin for pyenv they will integrate well.  Here's a made-up
sample:

python3.9 -m pip freeze > mypkgs.txt   # make a list of what you installed
pyenv versions   # which Pythons does pyenv know about?
# let's say it found the 3.7.13 you mentioned
pyenv virtualenv 3.7.13 my37project
pyenv activate my37project
python --version   # to check this is really getting the right one
pip install -r mypkgs.txt   # install the same packages you had for 3.9
pyenv deactivate  # drop back to regular mode

anytime you've activated the virtualenv you'll by getting this alternate
environment, which you can mess with as you want without worries of
affecting your regular version.


From juliushamilton100 at gmail.com  Sat Apr  9 12:44:48 2022
From: juliushamilton100 at gmail.com (Julius Hamilton)
Date: Sat, 9 Apr 2022 18:44:48 +0200
Subject: [Tutor] Mac install previous version of Python
Message-ID: <CAEsMKX161xyrDbVoL9P6fDr9PbsLKymtnHA4cxituf00o3stPg@mail.gmail.com>

Hey,

I?m trying to get a binary for an older version of Python - 3.7 - for Mac.

I tried to get it from the Python downloads page but it returned a .pkg
file. I don?t know how to run the installer from the command line.

Do I have to use the GUI?

Thanks very much,
Julius

From mats at wichmann.us  Sat Apr  9 13:24:28 2022
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 9 Apr 2022 11:24:28 -0600
Subject: [Tutor] Mac install previous version of Python
In-Reply-To: <CAEsMKX161xyrDbVoL9P6fDr9PbsLKymtnHA4cxituf00o3stPg@mail.gmail.com>
References: <CAEsMKX161xyrDbVoL9P6fDr9PbsLKymtnHA4cxituf00o3stPg@mail.gmail.com>
Message-ID: <3770beb2-bf16-7794-e3c1-72dfa905f18c@wichmann.us>

On 4/9/22 10:44, Julius Hamilton wrote:
> Hey,
> 
> I?m trying to get a binary for an older version of Python - 3.7 - for Mac.
> 
> I tried to get it from the Python downloads page but it returned a .pkg
> file. I don?t know how to run the installer from the command line.
> 
> Do I have to use the GUI?
> 
> Thanks very much,
> Julius

% man installer




From bryan.m.obrien at gmail.com  Sat Apr  9 13:02:22 2022
From: bryan.m.obrien at gmail.com (Bryan O'Brien)
Date: Sat, 9 Apr 2022 12:02:22 -0500
Subject: [Tutor] Mac install previous version of Python
In-Reply-To: <CAEsMKX161xyrDbVoL9P6fDr9PbsLKymtnHA4cxituf00o3stPg@mail.gmail.com>
References: <CAEsMKX161xyrDbVoL9P6fDr9PbsLKymtnHA4cxituf00o3stPg@mail.gmail.com>
Message-ID: <B7C74309-578D-4926-B18E-0C53145AF8BA@gmail.com>

You don't technically need to use the GUI.   However, since you asked, it would be _easier_ if you open Finder and double-click on the downloaded pkg file.   

> On Apr 9, 2022, at 11:46, Julius Hamilton <juliushamilton100 at gmail.com> wrote:
> 
> ?Hey,
> 
> I?m trying to get a binary for an older version of Python - 3.7 - for Mac.
> 
> I tried to get it from the Python downloads page but it returned a .pkg
> file. I don?t know how to run the installer from the command line.
> 
> Do I have to use the GUI?
> 
> Thanks very much,
> Julius
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

From fufomadu894 at gmail.com  Sat Apr  9 12:42:32 2022
From: fufomadu894 at gmail.com (Chidinma Ufomadu)
Date: Sat, 9 Apr 2022 12:42:32 -0400
Subject: [Tutor] Hi
Message-ID: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>

I need help with a project. I can't seem to be able to make the green led
come on when the servo is rotating, the red led just stay on. from machine
import Pin, PWM, ADC
import utime
Pot = ADC(0)# Pot at channel 0 for servo
servo = PWM(Pin(0)) # GPIO pins
servo.freq(50)
switch = (3, Pin.IN, Pin.PULL_UP) # PMW wave input

L1 = Pin(1, Pin.OUT) #GPIO2 set as pin for RED LED
L2 = Pin(2, Pin.OUT) #GPIO3 set as pin for Green LED

ch1 = PWM(Pin(2)) # set ch1 for L1 to PWM using GP2
ch1.freq(1000)
ch2 = PWM(Pin(3)) # set ch2 for L2 to PWM using GP3
ch2.freq(1000)
while True:                 # Do forever
    duty = Pot.read_u16()   # Copy pot Raw value to duty
    value = int(1350 + (Pot.read_u16() / 9.57))
    # adds the ruired offset to raw value of pot.
    servo.duty_u16(value) # final value needed a bit of weaking
    print(value)
    utime.sleep(0.5)
    L1.value(1)
    L2.value(0)
    utime.sleep(0.5)

That's the code I have written. I don't know what the problem is, please
help. Thank you.

From alan.gauld at yahoo.co.uk  Sat Apr  9 14:17:56 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Sat, 9 Apr 2022 19:17:56 +0100
Subject: [Tutor] Pi GPIO question was: Hi
In-Reply-To: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>
References: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>
Message-ID: <t2sikl$al1$1@ciao.gmane.io>

On 09/04/2022 17:42, Chidinma Ufomadu wrote:
> I need help with a project. I can't seem to be able to make the green led
> come on when the servo is rotating, the red led just stay on. from machine

This isn't really a Pi forum so we have limited experience here.
ut I'll make some general comments based on no knowledge whatsoever
of what you are actuall doing!


> Pot = ADC(0)# Pot at channel 0 for servo
> servo = PWM(Pin(0)) # GPIO pins
> servo.freq(50)
> switch = (3, Pin.IN, Pin.PULL_UP) # PMW wave input
> 
> L1 = Pin(1, Pin.OUT) #GPIO2 set as pin for RED LED
> L2 = Pin(2, Pin.OUT) #GPIO3 set as pin for Green LED

Might be better to call them Red and Green rather than L1 L2.
Saves you remembering which is which.

> ch1 = PWM(Pin(2)) # set ch1 for L1 to PWM using GP2
> ch1.freq(1000)

redCh maybe?

> ch2 = PWM(Pin(3)) # set ch2 for L2 to PWM using GP3
> ch2.freq(1000)

greenCh maybe?

> while True:                 # Do forever
>     duty = Pot.read_u16()   # Copy pot Raw value to duty
>     value = int(1350 + (Pot.read_u16() / 9.57))
>     # adds the ruired offset to raw value of pot.
>     servo.duty_u16(value) # final value needed a bit of weaking
>     print(value)

Apart from printing value you never use it for anything.
Is that correct?

>     utime.sleep(0.5)
>     L1.value(1)
>     L2.value(0)

You always set the same hard coded values. Should these
maybe be related to the value calculated above?

>     utime.sleep(0.5)

I don't know if that helps!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From wlfraed at ix.netcom.com  Sat Apr  9 16:14:51 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Sat, 09 Apr 2022 16:14:51 -0400
Subject: [Tutor] Pi GPIO question was: Hi
References: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>
Message-ID: <mkn35hhjchtk0j0kpq62no2l8hakbpg007@4ax.com>

{purloining Mr. Gauld's renamed subject line to avoid too many split
threads}

On Sat, 9 Apr 2022 12:42:32 -0400, Chidinma Ufomadu <fufomadu894 at gmail.com>
declaimed the following:

>I need help with a project. I can't seem to be able to make the green led
>come on when the servo is rotating, the red led just stay on. 

	There isn't really any Python specific problem here... What device are
you using? Beaglebone Black, Raspberry-Pi (or one of the work-alikes --
Orange Pi, etc.), AdaFruit Metro running CircuitPython (the Metro are
Arduino compatible microcontrollers [no OS] with a CircuitPython
interpreter as the firmware, running scripts from flash). Note that
Adafruit provides a "blinka" library (which will run on Beagle and R-Pi) to
allow for a unified CircuitPython environment under those Linux boards.

	Usenet comp.sys.raspberry-pi might be a better group for questions
involving GPIO and R-Pi's... Or AdaFruit's tutorials for CircuitPython.

from machine
>import Pin, PWM, ADC

	What library is "machine" part of? A quick Google implies it is part of
MicroPython, which is not native to most (if not all) Linux-based
microcomputer boards.

>import utime
>Pot = ADC(0)# Pot at channel 0 for servo

	Again -- what device? Raspberry-Pi boards don't have native ADC
(Beaglebone does have ADC); pretty much any microcontroller board (Arduino,
Metro, TIVA C) have native ADCs. One needs an external chip to obtain ADC
on an R-Pi. I'd have to study documentation some to determine if R-Pi has
hardware PWM -- I believe it is mostly software-based (tight loops counting
on/off durations).

>servo = PWM(Pin(0)) # GPIO pins
>servo.freq(50)

	Are you actually controlling a servo?

>switch = (3, Pin.IN, Pin.PULL_UP) # PMW wave input
>

	I'm not sure what you intend with this... If the /input/ really is a
PWM square wave it may be toggling too fast to really detect the on/off
intervals. It is more common for PWM inputs to be filtered via something
like a resistor/capacitor network to generate an average voltage, and then
use an ADC to read the voltage.

>L1 = Pin(1, Pin.OUT) #GPIO2 set as pin for RED LED
>L2 = Pin(2, Pin.OUT) #GPIO3 set as pin for Green LED

	As Mr. Gauld mentions, those names "stink"... redLED/greenLED at least
are names that don't require one to look back in the code to determine what
is being controlled.

>
>ch1 = PWM(Pin(2)) # set ch1 for L1 to PWM using GP2
>ch1.freq(1000)
>ch2 = PWM(Pin(3)) # set ch2 for L2 to PWM using GP3
>ch2.freq(1000)

	Here you seem to be replacing the prior "L1"/"L2" usage with connection
to the PWM output -- and again replacing "chX" with "channel_XXX" (where
XXX is RED or GREEN) would make the code easier to read. Or are they... You
set the LEDs on pins 1 and 2, but you are setting PWM on pins 2 and 3 --
but earlier you set pin 3 to be an input!

>while True:                 # Do forever
>    duty = Pot.read_u16()   # Copy pot Raw value to duty
>    value = int(1350 + (Pot.read_u16() / 9.57))
>    # adds the ruired offset to raw value of pot.
>    servo.duty_u16(value) # final value needed a bit of weaking

	So you are reading some (unknown) ADC device and using that to change
the duty-cycle of some unknown servo.

>    print(value)
>    utime.sleep(0.5)
>    L1.value(1)
>    L2.value(0)

	What do you expect to see here? Those statements hard-code your RED LED
to ON, and the GREEN to OFF. I don't know how those conflict with your PWM
settings (which I'd presume defaulted to 50% duty cycle, and would have the
LEDs at half-brightness).

	Confusingly, you have the ADC running a channel 0 (does that map to a
GPIO pin 0?), and you have the servo on a pin 0... Same pin? Knowing the
board being used, so one can look up the documentation of I/O pins is
greatly needed.


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From nathan-tech at hotmail.com  Sat Apr  9 18:56:55 2022
From: nathan-tech at hotmail.com (Nathan Smith)
Date: Sat, 9 Apr 2022 23:56:55 +0100
Subject: [Tutor] could someone break this down
Message-ID: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>

Hi there,


I've been working with a module recently called TWL-06 python scrabble 
dictionary, found here:

https://github.com/fogleman/TWL06


in this module, the creator packaged a dictionary of words into a DAWG, 
Directed Acyclic Word Graph, which was then packaged into a binary 
lookup table.


the table is base64 encoded and compressed with zlib, which is fine I 
got that.

Once unpackaged from that though (done by the module) it still does not 
look like words to me (presumably because it is in a DAWG). I don't 
entirely understand how to create these though and fear it's because I 
don't understand the termonology perhaps?


I found this DAWG creator, https://github.com/AndrasKovacs/dawg-gen


but don't want to use tit without knowing 1, what I'm talking about and 
2, if it will even work.


Any help anyone can provide is appreciated.

Nathan

-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net



From PythonList at DancesWithMice.info  Sat Apr  9 19:17:59 2022
From: PythonList at DancesWithMice.info (dn)
Date: Sun, 10 Apr 2022 11:17:59 +1200
Subject: [Tutor] could someone break this down
In-Reply-To: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
Message-ID: <fa15ee51-0881-a5ee-a9c7-9d73283229d8@DancesWithMice.info>

On 10/04/2022 10.56, Nathan Smith wrote:
> I've been working with a module recently called TWL-06 python scrabble
> dictionary, found here:
> https://github.com/fogleman/TWL06


Took a look at TWL. From the examples given, it looks straightforward to
me - but that doesn't help you one iota!


> in this module, the creator packaged a dictionary of words into a DAWG,
> Directed Acyclic Word Graph, which was then packaged into a binary
> lookup table ...
> Once unpackaged from that though (done by the module) it still does not
> look like words to me (presumably because it is in a DAWG). I don't

It is *not* meant to look like words! (this is actually described in the
ReadMe) It is a series of letters linked together in a fashion that will
'construct' ('legal') words.

Thus, in the example, wrt 'legal words', the letter "b" may only be
followed by the letters a, d, e, ... So, there are NO words beginning bc...


> entirely understand how to create these though and fear it's because I
> don't understand the termonology perhaps? ...
> but don't want to use tit without knowing 1, what I'm talking about and
> 2, if it will even work.
> Any help anyone can provide is appreciated.

No "perhaps" <grin>.

Try removing the word "Word" and researching "Directed Acyclic
Graph[s]". Wikipedia's description is rather mathematical in nature
(https://en.wikipedia.org/wiki/Directed_acyclic_graph). Hazelcast's
description (towards the top of my search/hits) might be easier to
follow (https://hazelcast.com/glossary/directed-acyclic-graph/) NB
remember, acyclic graphing is a technique that can be applied in areas
other than letters and words!

Then, turn your search-engine to the full term. It's quite topical given
the current/recent fad for Wordle!

Fire-up your REPL (Python in terminal) and duplicate/work-through the
examples the TWL-folk have given.

By which time, you will have absorbed some of the terminology, and
hopefully be able to decide if TWL will 'work' in your application...

-- 
Regards,
=dn

From mats at wichmann.us  Sat Apr  9 19:18:28 2022
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 9 Apr 2022 17:18:28 -0600
Subject: [Tutor] could someone break this down
In-Reply-To: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
Message-ID: <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>

On 4/9/22 16:56, Nathan Smith wrote:
> Hi there,
...
> but don't want to use tit without knowing 1, what I'm talking about and
> 2, if it will even work.
> 
> 
> Any help anyone can provide is appreciated.

It would help if you let us know what you're trying to accomplish,
rather than leaving us to guess...



From bouncingcats at gmail.com  Sat Apr  9 19:59:55 2022
From: bouncingcats at gmail.com (David)
Date: Sun, 10 Apr 2022 09:59:55 +1000
Subject: [Tutor] Hi
In-Reply-To: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>
References: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>
Message-ID: <CAMPXz=pYtduuR9gN485iwSVxE7Dn4gAKKMJ_MYuBXjb8G9HA9A@mail.gmail.com>

On Sun, 10 Apr 2022 at 03:56, Chidinma Ufomadu <fufomadu894 at gmail.com> wrote:

> I need help with a project. I can't seem to be able to make the green led
> come on when the servo is rotating, the red led just stay on.

Hi,

>     L1.value(1)

The above statement in your code lights the red LED, The nonzero
argument 1 tells the hardware to turn the LED on.

>     L2.value(0)

The above statement in your code turns off the the green LED. The zero
argument 0 tells the hardware to turn the LED off.

> That's the code I have written.
> I don't know what the problem is, please help.

There is no statement anywhere in your code that turns on the green
LED. So, it never gets turned on.

While your question is welcome here, I suggest this mailing list isn't
the best place to ask questions about Python running on
microcontrollers, because most people here are not using Python in
that way.

This mailing list is about helping people to use Python as a universal
language, without concerning itself with the specifics of the
hardware that it is running on.

For that reason, you will get better help by finding a forum which is
targetted to your specific hardware and version of Python.

If you are using circuit python, ask here:
  https://forums.adafruit.com/viewforum.php?f=60

If you are using micropython, ask here:
  https://forum.micropython.org/

Before you ask questions anywhere, searching and reading answers to
previous questions asked in the same place is an excellent way to
learn without having to wait for replies.

Also, it is important for you to understand that the behaviour of Python
running on microcontrollers varies depending on the hardware.

That is not because of Python. It is because in general each different
microcontroller provides different feature capabilities, and Python is
just being used here as an an interface to those capabilities. So it won't
behave the same on every hardware. That's why there are many "ports" (ie
variations) of Python for different hardware.

So just asking about "Python" won't get you the answers you need until you
give more details about the hardware you are using.

I can't even run your code here to test it, because it does not run on
my hardware, and you do not tell us what hardware you are using.

So, when asking for help you will get better answers if you always
state what hardware you are running on, and what version of Python you
are using. If you don't provide that information, it makes it hard for
people to help you. The documentation is different for each different
hardware platform, when there is no operating system running on that
platform to provide a universal interface for Python to use.

I wish you good luck with your project.

From nathan-tech at hotmail.com  Sat Apr  9 19:43:03 2022
From: nathan-tech at hotmail.com (Nathan Smith)
Date: Sun, 10 Apr 2022 00:43:03 +0100
Subject: [Tutor] could someone break this down
In-Reply-To: <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>
Message-ID: <DB7PR07MB509323F62FB17387AF745978E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>

Hi


Typical me, sorry about that Mats.


thanks DN for the links!


So I'm trying to understand DAWGS so that I can repackage the data 
included with the TWL module (which you're right DN is really nice and 
simple) because it uses American words when I want British words. I have 
the wordlist, just not the DAWG format :)


Nathan

On 10/04/2022 00:18, Mats Wichmann wrote:
> On 4/9/22 16:56, Nathan Smith wrote:
>> Hi there,
> ...
>> but don't want to use tit without knowing 1, what I'm talking about and
>> 2, if it will even work.
>>
>>
>> Any help anyone can provide is appreciated.
> It would help if you let us know what you're trying to accomplish,
> rather than leaving us to guess...
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&amp;data=04%7C01%7C%7C81ee475e1bb84839d70008da1a7f80b4%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637851432158013539%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=RCFucwMcGccLooFWYTwh9nrgrwsB2N3p68QGMFySIx8%3D&amp;reserved=0
-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net



From bouncingcats at gmail.com  Sun Apr 10 00:49:47 2022
From: bouncingcats at gmail.com (David)
Date: Sun, 10 Apr 2022 14:49:47 +1000
Subject: [Tutor] Pi GPIO question was: Hi
In-Reply-To: <mkn35hhjchtk0j0kpq62no2l8hakbpg007@4ax.com>
References: <CAB5fAjPYKForknuPSESRN-9YsWq_pCWWSf=1YgNzzS-8gOEz5A@mail.gmail.com>
 <mkn35hhjchtk0j0kpq62no2l8hakbpg007@4ax.com>
Message-ID: <CAMPXz=qhxJbX0soXwFPrxQSO+FzpGHFotUizsirrBYbVx5_D1g@mail.gmail.com>

Hello fellow posters,

Just a heads-up for future awareness, I suggest that the assumption
that the kickoff question is something related to Rasperry Pi is
likely to be incorrect.

So I think that changing the subject to include "Pi", and talking about
"Pi" in replies, is not helpful.

Because the posted code is clearly Micropython [1][2][3], or a derivative.

So it is far more likely that this code is running on a bare
microcontroller, rather than any platform that uses any operating
system.

The only "Pi" branded family product that matches that is the Raspberry Pi Pico.
  https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html

Which is not what most people are talking about when they talk about
Raspberry Pi, most people are referring to a single board computer
that's running some flavour of Linux. That's what made Raspberry Pi
famous.

Using Micropython does not require Linux or any other OS.

Yes, theoretically someone could build the Linux port of Micropython
and run it under Linux on a typical Raspberry Pi, but that would be rare
because it's a hugely suboptimal use of the hardware, compared to
the vastly more common situation of using Micropython directly on a
much simpler microcontroller board.

To see my point, take a look at this page:
  https://circuitpython.org/downloads
which shows almost 300 boards claimed suitable to run
Circuit Python, a Micropython derivative.

Any Micropython questions will almost certainly be about some
kind of hardware like these.

[1] https://github.com/micropython/micropython
[2] https://docs.micropython.org/en/latest/
[3] https://forum.micropython.org/

From PythonList at DancesWithMice.info  Sun Apr 10 01:27:42 2022
From: PythonList at DancesWithMice.info (dn)
Date: Sun, 10 Apr 2022 17:27:42 +1200
Subject: [Tutor] could someone break this down
In-Reply-To: <DB7PR07MB509323F62FB17387AF745978E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>
 <DB7PR07MB509323F62FB17387AF745978E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
Message-ID: <33e9a993-a988-d832-8795-acb18f26e721@DancesWithMice.info>

On 10/04/2022 11.43, Nathan Smith wrote:
> Hi
> 
> 
> Typical me, sorry about that Mats.
> 
> 
> thanks DN for the links!
> 
> 
> So I'm trying to understand DAWGS so that I can repackage the data
> included with the TWL module (which you're right DN is really nice and
> simple) because it uses American words when I want British words. I have
> the wordlist, just not the DAWG format :)

It might be worth contacting the people behind TWL, to see if they
already have, or will be open to you providing, a British dictionary.

Similarly, perhaps it will be worth performing a scan of GitHub, in case
someone has already forked the project for British application.

-- 
Regards,
=dn

From nathan-tech at hotmail.com  Sun Apr 10 19:15:58 2022
From: nathan-tech at hotmail.com (Nathan Smith)
Date: Mon, 11 Apr 2022 00:15:58 +0100
Subject: [Tutor] could someone break this down
In-Reply-To: <33e9a993-a988-d832-8795-acb18f26e721@DancesWithMice.info>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>
 <DB7PR07MB509323F62FB17387AF745978E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <33e9a993-a988-d832-8795-acb18f26e721@DancesWithMice.info>
Message-ID: <DB7PR07MB509393C3A7C0E3ED29C4A621E4EB9@DB7PR07MB5093.eurprd07.prod.outlook.com>

Hi DN,


Yeah I reached out via email on the Github page but no response.

Considering the module was last updated in 2013 I'm not sure if that 
email is even valid :)


Digging to see if anyone else has figures this though.


Thanks to the resources provided I think I now have a rough 
understanding of DAWG's but breaking down how the one in the module was 
written to file and such is still challenge.


Still onwards and upwards.

On 10/04/2022 06:27, dn wrote:
> On 10/04/2022 11.43, Nathan Smith wrote:
>> Hi
>>
>>
>> Typical me, sorry about that Mats.
>>
>>
>> thanks DN for the links!
>>
>>
>> So I'm trying to understand DAWGS so that I can repackage the data
>> included with the TWL module (which you're right DN is really nice and
>> simple) because it uses American words when I want British words. I have
>> the wordlist, just not the DAWG format :)
> It might be worth contacting the people behind TWL, to see if they
> already have, or will be open to you providing, a British dictionary.
>
> Similarly, perhaps it will be worth performing a scan of GitHub, in case
> someone has already forked the project for British application.
>
-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net



From PythonList at DancesWithMice.info  Sun Apr 10 19:50:01 2022
From: PythonList at DancesWithMice.info (dn)
Date: Mon, 11 Apr 2022 11:50:01 +1200
Subject: [Tutor] could someone break this down
In-Reply-To: <DB7PR07MB509393C3A7C0E3ED29C4A621E4EB9@DB7PR07MB5093.eurprd07.prod.outlook.com>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>
 <DB7PR07MB509323F62FB17387AF745978E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <33e9a993-a988-d832-8795-acb18f26e721@DancesWithMice.info>
 <DB7PR07MB509393C3A7C0E3ED29C4A621E4EB9@DB7PR07MB5093.eurprd07.prod.outlook.com>
Message-ID: <0ce3cf6a-2a5f-6fdc-3aa4-46657d5f3397@DancesWithMice.info>

On 11/04/2022 11.15, Nathan Smith wrote:
> Yeah I reached out via email on the Github page but no response.
> Considering the module was last updated in 2013 I'm not sure if that
> email is even valid :)
> Digging to see if anyone else has figures this though.

Sad, but likely. GitHub is sometimes a great source of source (hah!) but
is all too often a place to put 'stuff that I don't want to be bothered
with any more'...


I doubt that reverse-engineering the code will help, because it only
traverses the DAWG data - it doesn't show how to build the DAWG from a
(British) dictionary in the first place!

ie head meet brick-wall!


> Thanks to the resources provided I think I now have a rough
> understanding of DAWG's but breaking down how the one in the module was
> written to file and such is still challenge.

I was thinking that the concept of building a Finite State Machine to
traverse a DAWG - and to build the DAWG in the first place, would make
quite a good programming (design and coding) assignment...


If GitHub is no help, try 'the cheese shop' aka PyPi (https://pypi.org).
Searching for DAWG realised some familiar 'hit's.

It also mentions tries as an alternative data-structure.

Noted "lexpy" which has been updated more recently (but then, once it's
working, what updates are necessary?). It offers the choice of DAWG or
trie, and seems to feature both the 'building' of the lexicon, and its
(later) interrogation.


Let us know how you get on...
-- 
Regards,
=dn

From cs at cskk.id.au  Sun Apr 10 21:00:03 2022
From: cs at cskk.id.au (Cameron Simpson)
Date: Mon, 11 Apr 2022 11:00:03 +1000
Subject: [Tutor] Center Grove Student Mentoring Question
In-Reply-To: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
References: <CAJPKaeXX_5jcGm8J464AFywKaaQSzQGYSz-0Vm4GmnQTTXptRg@mail.gmail.com>
Message-ID: <YlN9k40l0/a7fFvM@cskk.homeip.net>

On 08Apr2022 14:02, Gavin Woods <woodsgav000 at students.centergrove.k12.in.us> wrote:
>3. If there was one thing you knew before coding, what would it be?

Since you have several verbose responses, I'll just address this. For 
me, the fun of coding comes from making myself a tool to do something 
and seeing it work.

The most important things about coding are to know:
- computers and programming languages are very literal - a computer will 
  do exactly what you ask and so precision is important, including 
  spelling
- there is no magic - if you cannot solve the problem mechanically ("by 
  hand") you can't instruct a computer to do it; that said, you can 
  learn yourself how to solve some probems by trying things with the 
  computer and seeing how they work and fail
- there is no magic - you need to provide enough information to solve 
  the problem
- computers do not get bored - once you've written a programme to solve 
  the problem, a computer can do as many solutions as you like - that's 
  a big reason to write small programmes - to have the computer do the 
  boring bits

And as mentioned by others: use the print() function when you have 
problems: seeing the actual values in the programme tells you a lot, 
particularly when you expected different values.

Cheers,
Cameron Simpson <cs at cskk.id.au>

From nadeem_559 at yahoo.com  Sun Apr 10 21:11:54 2022
From: nadeem_559 at yahoo.com (nadeem nan)
Date: Mon, 11 Apr 2022 01:11:54 +0000 (UTC)
Subject: [Tutor] Help/suggestion requested
References: <865830075.605238.1649639514827.ref@mail.yahoo.com>
Message-ID: <865830075.605238.1649639514827@mail.yahoo.com>

Hello experts !
My name is Nadeem and I am a novice learning Python through an online course. As part of the end of first module, we have been assigned a small project to take a form of text or paragraph of any size with punctuations included. The goal of the project is?
1. to write a script which will take the given text and add each word from it to a dictionary along with its frequency (no. of times repeated).?
2. Punctuations are to be removed before adding the words to the dictionary.
3. remove common words like 'the, they, are, not, be ,me, it, is, in' etc. from the dictionary.
My problem:
I am not being able to remove the common words from the dictionary. I have defined 2 dicts, word_dictionary which will store the words and its frequency as key:value pair and other final_dictionary which will store the words and its frequency without common words. To do this I have defined a list 'less_desired_words' containing the common words and used nested loops to compare the common words and if there is no match, to add the word to the final_dictionary. However this is not working (I may be not using it properly or doing something wrong).
Can you please advise, how I would be able to compare and add the words I wish to keep in the final_dictionary. The full code is as below.?
#Initialise text as stringtext = '''"I told you already," the curator stammered, kneeling defenseless on the floor of the gallery. "Ihave no idea what you are talking about!""You are lying." The man stared at him, perfectly immobile except for the glint in his ghostly eyes."You and your brethren possess something that is not yours."The curator felt a surge of adrenaline. How could he possibly know this?"Tonight the rightful guardians will be restored. Tell me where it is hidden, and you will live." Theman leveled his gun at the curator's head. "Is it a secret you will die for?"Sauni?re could not breathe.'''
#create a dictionary to store the words and their frequencies as key : value pair.word_dictionary = {}#create a dictinary to store the words without common words.final_dictionary = {}#split and store the sample text in a listtext_list = text.split()print(text_list)#define unwanted characters as stringunwanted_characters = '''.,/?@:;{}[]_ '"-+=!?$%^&*()~<>?`'''
#define less desired or common words as a listless_desired_words = ['the', 'a', 'they', 'are', 'i', 'me', 'you', 'we', 'there', 'their', 'can', 'our', 'is', 'not', 'for', 'in', 'on', 'no', 'have', 'he', 'she', 'and', 'your', 'him', 'her']
#iterate through text_list and remove the punctuations and convert to lower case words ? ? ? ?for word in text_list:? ? for character in unwanted_characters:? ? ? ? word = word.replace(character, "")? ? ? ? word = word.lower()
#count the words in the list and add to dictionary with their frequecy as key:value pair ? ? ? ? ? ?? ? if word in word_dictionary:? ? ? ? frequency = word_dictionary[word]? ? ? ? word_dictionary[word] = frequency + 1? ? ? ? ? ? else:? ? ? ? word_dictionary[word] = 1
print(word_dictionary)
#remove the less desired or common words and add the remaining words to the final dictionary.? ? ? ?for word, frequent in word_dictionary.items():? ? for notword in less_desired_words:? ? ? ? if word != notword:? ? ? ? ? ? final_dictionary[word] = frequent? ? 

#print(word_dictionary)print(final_dictionary)

Thanking you in advance,
Nadeem??
??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

From alan.gauld at yahoo.co.uk  Mon Apr 11 04:30:20 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Mon, 11 Apr 2022 09:30:20 +0100
Subject: [Tutor] Help/suggestion requested
In-Reply-To: <865830075.605238.1649639514827@mail.yahoo.com>
References: <865830075.605238.1649639514827.ref@mail.yahoo.com>
 <865830075.605238.1649639514827@mail.yahoo.com>
Message-ID: <t30ous$663$1@ciao.gmane.io>

On 11/04/2022 02:11, nadeem nan via Tutor wrote:
> Hello experts !
> My name is Nadeem and I am a novice learning Python through an online course. As part of the end of first module, we have been assigned a small project to take a form of text or paragraph of any size with punctuations included. The goal of the project is?
> 1. to write a script which will take the given text and add each word from it to a dictionary along with its frequency (no. of times repeated).?
> 2. Punctuations are to be removed before adding the words to the dictionary.
> 3. remove common words like 'the, they, are, not, be ,me, it, is, in' etc. from the dictionary.

On the last point I'd suggest it would be easier to never add them to
the dictionary in the first place. Just check before inserting...

Unfortunately you need to post code in plain text format,
otherwise the layout gets mangled and unreadable, as you see below...

> #Initialise text as stringtext = '''"I told you already," the curator stammered, kneeling defenseless on the floor of the gallery. "Ihave no idea what you are talking about!""You are lying." The man stared at him, perfectly immobile except for the glint in his ghostly eyes."You and your brethren possess something that is not yours."The curator felt a surge of adrenaline. How could he possibly know this?"Tonight the rightful guardians will be restored. Tell me where it is hidden, and you will live." Theman leveled his gun at the curator's head. "Is it a secret you will die for?"Sauni?re could not breathe.'''
> #create a dictionary to store the words and their frequencies as key : value pair.word_dictionary = {}#create a dictinary to store the words without common words.final_dictionary = {}#split and store the sample text in a listtext_list = text.split()print(text_list)#define unwanted characters as stringunwanted_characters = '''.,/?@:;{}[]_ '"-+=!?$%^&*()~<>?`'''
> #define less desired or common words as a listless_desired_words = ['the', 'a', 'they', 'are', 'i', 'me', 'you', 'we', 'there', 'their', 'can', 'our', 'is', 'not', 'for', 'in', 'on', 'no', 'have', 'he', 'she', 'and', 'your', 'him', 'her']
> #iterate through text_list and remove the punctuations and convert to lower case words ? ? ? ?for word in text_list:? ? for character in unwanted_characters:? ? ? ? word = word.replace(character, "")? ? ? ? word = word.lower()
> #count the words in the list and add to dictionary with their frequecy as key:value pair ? ? ? ? ? ?? ? if word in word_dictionary:? ? ? ? frequency = word_dictionary[word]? ? ? ? word_dictionary[word] = frequency + 1? ? ? ? ? ? else:? ? ? ? word_dictionary[word] = 1

There are some bits on that which look like they could
be optimised but...

This looks like the relevant bit. I'll guess at formatting:

> print(word_dictionary)
> #remove the less desired or common words and add the remaining words to the final dictionary.

? ? ? ?for word, frequent in word_dictionary.items():       ? ? for
notword in less_desired_words:?
         ? ? ? if word != notword:
      ? ? ? ? ? ? final_dictionary[word] = frequent? ?

Rather than looping over less_desired_words
you could use an 'in' test:

if word not in less_desired_words:
     final_dictionary....

Secondly you are adding to the final dict everytime the word is not
notword. Thats wasteful, so you probably want a 'break' statement in
there. Alternatively use the else clause of the second for loop
to add the word.

Another approach would just be to del() the word from the original
dictionary if it is in less_desired...

However, it does look like it should work.
What are you getting?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From breamoreboy at gmail.com  Mon Apr 11 09:48:35 2022
From: breamoreboy at gmail.com (Mark Lawrence)
Date: Mon, 11 Apr 2022 14:48:35 +0100
Subject: [Tutor] could someone break this down
In-Reply-To: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
Message-ID: <22cc6f1d-b955-fa2d-815c-f580d4af4b04@gmail.com>

On 09/04/2022 23:56, Nathan Smith wrote:
> Hi there,
> 
> I've been working with a module recently called TWL-06 python scrabble 
> dictionary, found here:
> 
> https://github.com/fogleman/TWL06
> 
> in this module, the creator packaged a dictionary of words into a DAWG, 
> Directed Acyclic Word Graph, which was then packaged into a binary 
> lookup table.
> 
> the table is base64 encoded and compressed with zlib, which is fine I 
> got that.
> 
> Once unpackaged from that though (done by the module) it still does not 
> look like words to me (presumably because it is in a DAWG). I don't 
> entirely understand how to create these though and fear it's because I 
> don't understand the termonology perhaps?
> 
> I found this DAWG creator, https://github.com/AndrasKovacs/dawg-gen
> 
> but don't want to use tit without knowing 1, what I'm talking about and 
> 2, if it will even work.
> 
> Any help anyone can provide is appreciated.
> 
> Nathan
> 

This little beast appears to be very stable 
https://dawg.readthedocs.io/en/latest/ and is available on pypi. Nothing 
ventured nothing gained :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence


From learn2program at gmail.com  Tue Apr 12 03:19:18 2022
From: learn2program at gmail.com (Alan Gauld)
Date: Tue, 12 Apr 2022 08:19:18 +0100
Subject: [Tutor] Fwd:  Help/suggestion requested
In-Reply-To: <426074953.4732.1649732658832@mail.yahoo.com>
References: <426074953.4732.1649732658832@mail.yahoo.com>
Message-ID: <7c124c14-ecb5-c803-3001-edd09eb73f55@yahoo.co.uk>

Forwarding to list

Please always use "Reply List" or "Repy All" when responding to the
tutor list,
otherwise you just reply to the individual.

-------- Forwarded Message --------

Hi Alan,

Thanks a lot for taking the time out to read my email. I really
appreciate your suggestion and help. Please excuse me for the messy
email earlier. However after following your advice and rewriting my
code, I have managed to get the desired result. Initially in the bottom
part of the code where I was trying to filter out the less desired words
by removing from the original list, I was getting an error as 'list out
of bound'.?

Please see the amended code below and if there is room for improvement,
please do let me know.

***************************************************************************

#Initialise text as string
text = '''"I told you already," the curator stammered, kneeling
defenseless on the floor of the gallery. "I
have no idea what you are talking about!"
"You are lying." The man stared at him, perfectly immobile except for
the glint in his ghostly eyes.
"You and your brethren possess something that is not yours."
The curator felt a surge of adrenaline. How could he possibly know this?
"Tonight the rightful guardians will be restored. Tell me where it is
hidden, and you will live." The
man leveled his gun at the curator's head. "Is it a secret you will die
for?"
Sauni?re could not breathe.'''

#create a dictionary to store the words and their frequencies as key :
value pair.
word_dictionary = {}

#split and store the sample text in a list
text_list = text.split()
print(text_list)

#new list to store words without the common words
new_list = []

#define unwanted characters as string
special_characters = '''.,/?@:;{[]_ }'"-+=!?$%^&*()~<>?`'''

#define less desired or common words as a list
less_desired_words = ['the', 'a', 'they', 'are', 'i', 'me', 'you', 'we',
'there', 'their', 'can', 'our', 'is', 'not',?
'be','for', 'in', 'on', 'no', 'have', 'he', 'she', 'and', 'your', 'him',
'her', 'at', 'of', 'that','his', 'what', 'it','where', 'will']

#iterate through text_list and remove the punctuations and convert to
lower case words and add to new list? ? ? ?
for word in text_list:
? ? for character in special_characters:
? ? ? ? word = word.lower()
? ? ? ? word = word.replace(character, "")
? ? new_list.append(word)

print(new_list)? ??
??
#iterate through new list and remove the common words
for word in new_list:
? ? for common_word in less_desired_words:
? ? ? ? if common_word in new_list:
? ? ? ? ? ? new_list.remove(common_word)? ? ? ?

print(new_list)

#count the words in the list and add to dictionary with their frequecy
as key:value pair? ? ? ? ? ??
for word in new_list:
? ? if word in word_dictionary:
? ? ? ? frequency = word_dictionary[word]
? ? ? ? word_dictionary[word] = frequency + 1
? ? ? ??
? ? else:
? ? ? ? word_dictionary[word] = 1

print(word_dictionary)

**************************************************************************

Your's faithfully,

Nadeem Nan

?
?
?

?
?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??


On Monday, 11 April 2022, 09:31:53 BST, Alan Gauld via Tutor
<tutor at python.org> wrote:


On 11/04/2022 02:11, nadeem nan via Tutor wrote:
> Hello experts !
> My name is Nadeem and I am a novice learning Python through an online
course. As part of the end of first module, we have been assigned a
small project to take a form of text or paragraph of any size with
punctuations included. The goal of the project is?
> 1. to write a script which will take the given text and add each word
from it to a dictionary along with its frequency (no. of times repeated).?
> 2. Punctuations are to be removed before adding the words to the
dictionary.
> 3. remove common words like 'the, they, are, not, be ,me, it, is, in'
etc. from the dictionary.

On the last point I'd suggest it would be easier to never add them to
the dictionary in the first place. Just check before inserting...

Unfortunately you need to post code in plain text format,
otherwise the layout gets mangled and unreadable, as you see below...

> #Initialise text as stringtext = '''"I told you already," the curator
stammered, kneeling defenseless on the floor of the gallery. "Ihave no
idea what you are talking about!""You are lying." The man stared at him,
perfectly immobile except for the glint in his ghostly eyes."You and
your brethren possess something that is not yours."The curator felt a
surge of adrenaline. How could he possibly know this?"Tonight the
rightful guardians will be restored. Tell me where it is hidden, and you
will live." Theman leveled his gun at the curator's head. "Is it a
secret you will die for?"Sauni?re could not breathe.'''
> #create a dictionary to store the words and their frequencies as key :
value pair.word_dictionary = {}#create a dictinary to store the words
without common words.final_dictionary = {}#split and store the sample
text in a listtext_list = text.split()print(text_list)#define unwanted
characters as stringunwanted_characters = '''.,/?@:;{}[]_
'"-+=!?$%^&*()~<>?`'''
> #define less desired or common words as a listless_desired_words =
['the', 'a', 'they', 'are', 'i', 'me', 'you', 'we', 'there', 'their',
'can', 'our', 'is', 'not', 'for', 'in', 'on', 'no', 'have', 'he', 'she',
'and', 'your', 'him', 'her']
> #iterate through text_list and remove the punctuations and convert to
lower case words ? ? ? ?for word in text_list:? ? for character in
unwanted_characters:? ? ? ? word = word.replace(character, "")? ? ? ?
word = word.lower()
> #count the words in the list and add to dictionary with their frequecy
as key:value pair ? ? ? ? ? ?? ? if word in word_dictionary:? ? ? ?
frequency = word_dictionary[word]? ? ? ? word_dictionary[word] =
frequency + 1? ? ? ? ? ? else:? ? ? ? word_dictionary[word] = 1

There are some bits on that which look like they could
be optimised but...

This looks like the relevant bit. I'll guess at formatting:

> print(word_dictionary)
> #remove the less desired or common words and add the remaining words
to the final dictionary.

? ? ? ?for word, frequent in word_dictionary.items():? ? ? ? ? for
notword in less_desired_words:?
? ? ? ? ? ? ? if word != notword:
? ? ? ? ? ? ? ? ? final_dictionary[word] = frequent? ?

Rather than looping over less_desired_words
you could use an 'in' test:

if word not in less_desired_words:
? ? final_dictionary....

Secondly you are adding to the final dict everytime the word is not
notword. Thats wasteful, so you probably want a 'break' statement in
there. Alternatively use the else clause of the second for loop
to add the word.

Another approach would just be to del() the word from the original
dictionary if it is in less_desired...

However, it does look like it should work.
What are you getting?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



_______________________________________________
Tutor maillist? -? Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

From alan.gauld at yahoo.co.uk  Tue Apr 12 03:48:16 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Tue, 12 Apr 2022 08:48:16 +0100
Subject: [Tutor] Fwd: Help/suggestion requested
In-Reply-To: <7c124c14-ecb5-c803-3001-edd09eb73f55@yahoo.co.uk>
References: <426074953.4732.1649732658832@mail.yahoo.com>
 <7c124c14-ecb5-c803-3001-edd09eb73f55@yahoo.co.uk>
Message-ID: <t33as1$125l$1@ciao.gmane.io>

On 12/04/2022 08:19, Alan Gauld wrote:

> code, I have managed to get the desired result. 

Well done!

> Please see the amended code below and if there is room for improvement,

There is always room for improvement! :-)

> #create a dictionary to store the words and their frequencies as key :
> value pair.
> word_dictionary = {}
> 
> #split and store the sample text in a list
> text_list = text.split()
> print(text_list)
> 
> #new list to store words without the common words
> new_list = []
> 
> #define unwanted characters as string
> special_characters = '''.,/?@:;{[]_ }'"-+=!?$%^&*()~<>?`'''
> 
> #define less desired or common words as a list
> less_desired_words = ['the', 'a', 'they', 'are', 'i', 'me', 'you', 'we',
> 'there', 'their', 'can', 'our', 'is', 'not',?
> 'be','for', 'in', 'on', 'no', 'have', 'he', 'she', 'and', 'your', 'him',
> 'her', 'at', 'of', 'that','his', 'what', 'it','where', 'will']
> 
> #iterate through text_list and remove the punctuations and convert to
> lower case words and add to new list? ? ? ?
> for word in text_list:
> ? ? for character in special_characters:
> ? ? ? ? word = word.lower()   # move this outside the loop so it only gets done once
> ? ? ? ? word = word.replace(character, "")

      if word not in less_common_words:

> ? ?       new_list.append(word)

Instead of adding to the list add to a dictionary with the count.
Use dict.get() which looks like:

############
words = {}

...

words[word] = words.get(word,0) + 1
############

get(words,0) returns zero if words is not in the dict.

> 
> print(new_list)? ??
> ??

The loop below is no longer necessary...

> #iterate through new list and remove the common words
> for word in new_list:
> ? ? for common_word in less_desired_words:
> ? ? ? ? if common_word in new_list:
> ? ? ? ? ? ? new_list.remove(common_word)? ? ? ?
> 
> print(new_list)
> 

Counting the words is no longer necessary

> #count the words in the list and add to dictionary with their frequecy
> as key:value pair? ? ? ? ? ??
> for word in new_list:
> ? ? if word in word_dictionary:
> ? ? ? ? frequency = word_dictionary[word]
> ? ? ? ? word_dictionary[word] = frequency + 1
> ? ? ? ??
> ? ? else:
> ? ? ? ? word_dictionary[word] = 1
> 
> print(word_dictionary)-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From nadeem_559 at yahoo.com  Wed Apr 13 10:08:35 2022
From: nadeem_559 at yahoo.com (nadeem nan)
Date: Wed, 13 Apr 2022 14:08:35 +0000 (UTC)
Subject: [Tutor] Fwd: Help/suggestion requested
In-Reply-To: <t33as1$125l$1@ciao.gmane.io>
References: <426074953.4732.1649732658832@mail.yahoo.com>
 <7c124c14-ecb5-c803-3001-edd09eb73f55@yahoo.co.uk>
 <t33as1$125l$1@ciao.gmane.io>
Message-ID: <100056996.932000.1649858915983@mail.yahoo.com>

Hi Alan,
Thanks once again for bailing me out. Your ideas and suggestions are really helpful and I have already few things from your during the exchange of emails. I really appreciate you taking the time out for me. Very much obliged.
Sincerely,
Nadeem Nan
???
??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? 

    On Tuesday, 12 April 2022, 08:49:50 BST, Alan Gauld via Tutor <tutor at python.org> wrote:  
 
 On 12/04/2022 08:19, Alan Gauld wrote:

> code, I have managed to get the desired result. 

Well done!

> Please see the amended code below and if there is room for improvement,

There is always room for improvement! :-)

> #create a dictionary to store the words and their frequencies as key :
> value pair.
> word_dictionary = {}
> 
> #split and store the sample text in a list
> text_list = text.split()
> print(text_list)
> 
> #new list to store words without the common words
> new_list = []
> 
> #define unwanted characters as string
> special_characters = '''.,/?@:;{[]_ }'"-+=!?$%^&*()~<>?`'''
> 
> #define less desired or common words as a list
> less_desired_words = ['the', 'a', 'they', 'are', 'i', 'me', 'you', 'we',
> 'there', 'their', 'can', 'our', 'is', 'not',?
> 'be','for', 'in', 'on', 'no', 'have', 'he', 'she', 'and', 'your', 'him',
> 'her', 'at', 'of', 'that','his', 'what', 'it','where', 'will']
> 
> #iterate through text_list and remove the punctuations and convert to
> lower case words and add to new list? ? ? ?
> for word in text_list:
> ? ? for character in special_characters:
> ? ? ? ? word = word.lower()? # move this outside the loop so it only gets done once
> ? ? ? ? word = word.replace(character, "")

? ? ? if word not in less_common_words:

> ? ?? ? ? new_list.append(word)

Instead of adding to the list add to a dictionary with the count.
Use dict.get() which looks like:

############
words = {}

...

words[word] = words.get(word,0) + 1
############

get(words,0) returns zero if words is not in the dict.

> 
> print(new_list)? ??
> ??

The loop below is no longer necessary...

> #iterate through new list and remove the common words
> for word in new_list:
> ? ? for common_word in less_desired_words:
> ? ? ? ? if common_word in new_list:
> ? ? ? ? ? ? new_list.remove(common_word)? ? ? ?
> 
> print(new_list)
> 

Counting the words is no longer necessary

> #count the words in the list and add to dictionary with their frequecy
> as key:value pair? ? ? ? ? ??
> for word in new_list:
> ? ? if word in word_dictionary:
> ? ? ? ? frequency = word_dictionary[word]
> ? ? ? ? word_dictionary[word] = frequency + 1
> ? ? ? ??
> ? ? else:
> ? ? ? ? word_dictionary[word] = 1
> 
> print(word_dictionary)-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist? -? Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
  

From alan.gauld at yahoo.co.uk  Wed Apr 13 20:46:16 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Thu, 14 Apr 2022 01:46:16 +0100
Subject: [Tutor] Python app on a Mac
Message-ID: <t37qsp$146b$1@ciao.gmane.io>

I've just migrated to a Mac mini running Monterey.

I have a Python GUI(Tkinter) app that I wrote on Linux and
have managed to get working on MacOS except....

When I start the program I get a Terminal wondow as well
as the GUI. On Windows I'd run it with pythonw and in Linux
I just created a desktop launcher to avoid that. But there
is no pythonw on MacOS nor a simple way I can find to
launch apps from the desktop.

Does anyoe know how to launch a Python program from the
desktop without a Terminal window(or at least with an
iconified one!) Does it require Applescript or somesuch?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From bouncingcats at gmail.com  Fri Apr 15 05:04:33 2022
From: bouncingcats at gmail.com (David)
Date: Fri, 15 Apr 2022 19:04:33 +1000
Subject: [Tutor] Python app on a Mac
In-Reply-To: <t37qsp$146b$1@ciao.gmane.io>
References: <t37qsp$146b$1@ciao.gmane.io>
Message-ID: <CAMPXz=o_QxFcC2V2ogw7YRyMhFJwXdg2Uen3C3FTPAE1kRcB5w@mail.gmail.com>

On Thu, 14 Apr 2022 at 10:48, Alan Gauld via Tutor <tutor at python.org> wrote:
>
> I've just migrated to a Mac mini running Monterey.
>
> I have a Python GUI(Tkinter) app that I wrote on Linux and
> have managed to get working on MacOS except....
>
> When I start the program I get a Terminal wondow as well
> as the GUI. On Windows I'd run it with pythonw and in Linux
> I just created a desktop launcher to avoid that. But there
> is no pythonw on MacOS nor a simple way I can find to
> launch apps from the desktop.
>
> Does anyoe know how to launch a Python program from the
> desktop without a Terminal window(or at least with an
> iconified one!) Does it require Applescript or somesuch?

Hi Alan,

I think that python-list at python.org is a better fit for this question than
python-tutor, and that you're more likely to get replies there too.

I'm sure you know this, but I'm just replying to an unanswered
question in the same manner as a would if I didn't recognise
the name of the questioner.

From dsavage1796 at yahoo.com  Sun Apr 17 21:09:26 2022
From: dsavage1796 at yahoo.com (david savage)
Date: Mon, 18 Apr 2022 01:09:26 +0000 (UTC)
Subject: [Tutor] Python jobs with no work experience
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
Message-ID: <618179275.660604.1650244166759@mail.yahoo.com>

Hi...thank you for this ability to ask questions.  I have dabbled with Python (Windows), but have never had the opportunity to use Python in a job.  I have been a PL/B programmer for the past 28 years, and recently got laid off from my job.  Because of the scarcity of open positions in this programming field, I'd like to get an entry-level position with a company that utilizes Python.  Someplace where I can actually increase my understanding of Python & therefore put it to good use...in an actual productive environment, but I'm not aware of any company that is willing to take on a programmer who doesn't have actual work experience using Python.  

So, anyway, that is my dilemna.  Can someone give me any suggestions on how to get my "foot in the door".....so to speak ?   My PL/B programming career started soon after I got hired on as an operator, running PL/B programs all day.   I think learning PL/B was a requirement of the job, & so I thought "this is going to be a great career for me", so I learned it.   I do enjoy PL/B, but if I knew then what I know now, I would probably have ran in the opposite direction.   

I have already checked out the web site of the maker of PL/B, as the job postings on there are not taken down, even when the jobs are filled.

So thanks for whatever advice you have..  If I knew what, in Python, specifically to focus on learning, then I will not feel like I'm spinning my wheels.  I'm even willing to start at the bottom.

David

From leamhall at gmail.com  Mon Apr 18 06:38:23 2022
From: leamhall at gmail.com (Leam Hall)
Date: Mon, 18 Apr 2022 05:38:23 -0500
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <618179275.660604.1650244166759@mail.yahoo.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
Message-ID: <d772783f-ae9e-be6b-ff55-5a0fe3cb2061@gmail.com>

David,

I came to programming from an electronics technician background, and I don't really have a lot of computer science in my course credits. What I do have, and what you seem to share, is a passion for learning. If that is true, then you're in the right place.

Your PL/B background gives you at least two advantages. You already know how to program, and if I understand PL/B then you've already learned how to translate business needs into code. Python is easy to learn, widely in use, and you can spend the rest of your career doing something in it. The real challenge will be to find what you want to do; what aspect of life are you passionate about? What concepts do you go home and tinker with? Find that, and you'll probably find several Python projects who could use your help. That will give you the experience sensible employers want.

EdX and Coursera have lots of great beginning Python courses. If you already have some Python skills, and you really want to make a long term career move, I'd suggest:

	https://www.edx.org/course/building-modern-python-applications-on-aws

Many workloads are moving to serverless, and the sooner we ramp up to that the better our careers will be. If you're strong in maths, then data science and machine learning are also Python strengths and there are courses for those as well.

Bottom line; Python is a good language to base your career on. Just figure out what you want your career to be.

Leam



On 4/17/22 20:09, david savage via Tutor wrote:
> Hi...thank you for this ability to ask questions.  I have dabbled with Python (Windows), but have never had the opportunity to use Python in a job.  I have been a PL/B programmer for the past 28 years, and recently got laid off from my job.  Because of the scarcity of open positions in this programming field, I'd like to get an entry-level position with a company that utilizes Python.  Someplace where I can actually increase my understanding of Python & therefore put it to good use...in an actual productive environment, but I'm not aware of any company that is willing to take on a programmer who doesn't have actual work experience using Python.
> 
> So, anyway, that is my dilemna.  Can someone give me any suggestions on how to get my "foot in the door".....so to speak ?   My PL/B programming career started soon after I got hired on as an operator, running PL/B programs all day.   I think learning PL/B was a requirement of the job, & so I thought "this is going to be a great career for me", so I learned it.   I do enjoy PL/B, but if I knew then what I know now, I would probably have ran in the opposite direction.
> 
> I have already checked out the web site of the maker of PL/B, as the job postings on there are not taken down, even when the jobs are filled.
> 
> So thanks for whatever advice you have..  If I knew what, in Python, specifically to focus on learning, then I will not feel like I'm spinning my wheels.  I'm even willing to start at the bottom.
> 
> David

-- 
Site Automation Engineer   (reuel.net/resume)
Scribe: The Domici War     (domiciwar.net)
General Ne'er-do-well      (github.com/LeamHall)

From eleonora.panini7jkd at gmail.com  Mon Apr 18 05:50:54 2022
From: eleonora.panini7jkd at gmail.com (Eleonora Panini)
Date: Mon, 18 Apr 2022 11:50:54 +0200
Subject: [Tutor] Python question
Message-ID: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>

<https://stackoverflow.com/posts/71904558/timeline>

I need help to do the following steps in Phyton:

-my starting array is: array = np.random.rand(1024x11700)

-I have to obtain an array 1024x23400 with the following characteristics:
25 columns(1024x25) of data and 25 columns (1024x25) of zeros

 So I thought to do a loop every 25 columns(1024x25), insert an array of
zeros (1024x25) alternatevely every 25 columns, so I obtain an array
1024x23400..

but I don't know how to do it in Phyton.. Can you help me? Thank you

-- 
*Eleonora Panini*
*3480581404*

From PythonList at DancesWithMice.info  Mon Apr 18 16:02:58 2022
From: PythonList at DancesWithMice.info (dn)
Date: Tue, 19 Apr 2022 08:02:58 +1200
Subject: [Tutor] Python question
In-Reply-To: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
References: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
Message-ID: <4478d08e-a8d5-6d31-b213-7b48ad617ff4@DancesWithMice.info>

Greetings,

On 18/04/2022 21.50, Eleonora Panini wrote:
> <https://stackoverflow.com/posts/71904558/timeline>
> 
> I need help to do the following steps in Phyton:
> 
> -my starting array is: array = np.random.rand(1024x11700)
> 
> -I have to obtain an array 1024x23400 with the following characteristics:
> 25 columns(1024x25) of data and 25 columns (1024x25) of zeros
> 
>  So I thought to do a loop every 25 columns(1024x25), insert an array of
> zeros (1024x25) alternatevely every 25 columns, so I obtain an array
> 1024x23400..
> 
> but I don't know how to do it in Phyton.. Can you help me? Thank you


This sounds very much like a homework assignment. Is it?

Please show us the pertinent code you have written so-far, and any
exception report. That way we can help you to improve...

How do you construct the first 25-columns (in Python)?
How do you construct the zero-ed columns?
How do you put the first pair of 25-column 'sets of data' together?
How would you repeat this for the requisite number of times/columns?

BTW this looks more like numpy than Python...
-- 
Regards,
=dn

From dsavage1796 at yahoo.com  Mon Apr 18 07:30:12 2022
From: dsavage1796 at yahoo.com (david savage)
Date: Mon, 18 Apr 2022 11:30:12 +0000 (UTC)
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <d772783f-ae9e-be6b-ff55-5a0fe3cb2061@gmail.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <d772783f-ae9e-be6b-ff55-5a0fe3cb2061@gmail.com>
Message-ID: <2060444063.737872.1650281412720@mail.yahoo.com>

Thank you for this advice !? ?
David

Sent from Yahoo Mail on Android 
 
  On Mon, Apr 18, 2022 at 5:40 AM, Leam Hall<leamhall at gmail.com> wrote:   David,

I came to programming from an electronics technician background, and I don't really have a lot of computer science in my course credits. What I do have, and what you seem to share, is a passion for learning. If that is true, then you're in the right place.

Your PL/B background gives you at least two advantages. You already know how to program, and if I understand PL/B then you've already learned how to translate business needs into code. Python is easy to learn, widely in use, and you can spend the rest of your career doing something in it. The real challenge will be to find what you want to do; what aspect of life are you passionate about? What concepts do you go home and tinker with? Find that, and you'll probably find several Python projects who could use your help. That will give you the experience sensible employers want.

EdX and Coursera have lots of great beginning Python courses. If you already have some Python skills, and you really want to make a long term career move, I'd suggest:

??? https://www.edx.org/course/building-modern-python-applications-on-aws

Many workloads are moving to serverless, and the sooner we ramp up to that the better our careers will be. If you're strong in maths, then data science and machine learning are also Python strengths and there are courses for those as well.

Bottom line; Python is a good language to base your career on. Just figure out what you want your career to be.

Leam



On 4/17/22 20:09, david savage via Tutor wrote:
> Hi...thank you for this ability to ask questions.? I have dabbled with Python (Windows), but have never had the opportunity to use Python in a job.? I have been a PL/B programmer for the past 28 years, and recently got laid off from my job.? Because of the scarcity of open positions in this programming field, I'd like to get an entry-level position with a company that utilizes Python.? Someplace where I can actually increase my understanding of Python & therefore put it to good use...in an actual productive environment, but I'm not aware of any company that is willing to take on a programmer who doesn't have actual work experience using Python.
> 
> So, anyway, that is my dilemna.? Can someone give me any suggestions on how to get my "foot in the door".....so to speak ?? My PL/B programming career started soon after I got hired on as an operator, running PL/B programs all day.? I think learning PL/B was a requirement of the job, & so I thought "this is going to be a great career for me", so I learned it.? I do enjoy PL/B, but if I knew then what I know now, I would probably have ran in the opposite direction.
> 
> I have already checked out the web site of the maker of PL/B, as the job postings on there are not taken down, even when the jobs are filled.
> 
> So thanks for whatever advice you have..? If I knew what, in Python, specifically to focus on learning, then I will not feel like I'm spinning my wheels.? I'm even willing to start at the bottom.
> 
> David

-- 
Site Automation Engineer? (reuel.net/resume)
Scribe: The Domici War? ? (domiciwar.net)
General Ne'er-do-well? ? ? (github.com/LeamHall)
_______________________________________________
Tutor maillist? -? Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
  

From oscar.j.benjamin at gmail.com  Mon Apr 18 21:16:17 2022
From: oscar.j.benjamin at gmail.com (Oscar Benjamin)
Date: Tue, 19 Apr 2022 02:16:17 +0100
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <618179275.660604.1650244166759@mail.yahoo.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
Message-ID: <CAHVvXxS2brTnCJqsNVT8kDU5Pq8XWt5vbhXtyQZgNa1s4-kHPA@mail.gmail.com>

On Mon, 18 Apr 2022 at 10:12, david savage via Tutor <tutor at python.org> wrote:
>
> Hi...thank you for this ability to ask questions.  I have dabbled with Python (Windows), but have never had the opportunity to use Python in a job.  I have been a PL/B programmer for the past 28 years, and recently got laid off from my job.  Because of the scarcity of open positions in this programming field, I'd like to get an entry-level position with a company that utilizes Python.  Someplace where I can actually increase my understanding of Python & therefore put it to good use...in an actual productive environment, but I'm not aware of any company that is willing to take on a programmer who doesn't have actual work experience using Python.

Many companies will employ someone based on their experience in
contributing to open source software. That's a way that you can build
skills in something like Python as well as being helped to develop
your skills and the results are publicly visible for any potential
employer.

--
Oscar

From cs at cskk.id.au  Mon Apr 18 18:45:11 2022
From: cs at cskk.id.au (Cameron Simpson)
Date: Tue, 19 Apr 2022 08:45:11 +1000
Subject: [Tutor] Python question
In-Reply-To: <4478d08e-a8d5-6d31-b213-7b48ad617ff4@DancesWithMice.info>
References: <4478d08e-a8d5-6d31-b213-7b48ad617ff4@DancesWithMice.info>
Message-ID: <Yl3p99h9+t81ICj4@cskk.homeip.net>

On 19Apr2022 08:02, DL Neil <PythonList at DancesWithMice.info> wrote:
>BTW this looks more like numpy than Python...

numpy is a popular Python library. I've no objection to dealing with it 
in the "tutor" list for questions we can help with. (I'm not a numpy 
expert, though I'm starting to dabble in it.)

Cheers,
Cameron Simpson <cs at cskk.id.au>

From wlfraed at ix.netcom.com  Tue Apr 19 00:25:39 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Tue, 19 Apr 2022 00:25:39 -0400
Subject: [Tutor] Python question
References: <4478d08e-a8d5-6d31-b213-7b48ad617ff4@DancesWithMice.info>
 <Yl3p99h9+t81ICj4@cskk.homeip.net>
Message-ID: <r1cs5hpb3pach3v0mm4mnke0b94s7og6qk@4ax.com>

On Tue, 19 Apr 2022 08:45:11 +1000, Cameron Simpson <cs at cskk.id.au>
declaimed the following:

>On 19Apr2022 08:02, DL Neil <PythonList at DancesWithMice.info> wrote:
>>BTW this looks more like numpy than Python...
>
>numpy is a popular Python library. I've no objection to dealing with it 
>in the "tutor" list for questions we can help with. (I'm not a numpy 
>expert, though I'm starting to dabble in it.)
>

	I'd tend to concur this is a numpy question (other than the OP's "but I
don't know how to do it in Phyton [sic]" there is nothing in the assignment
that requires pure Python rather than numpy built-ins).

	This sounds very much like an exercise in slicing, numpy.split,
numpy.concatenate, numpy.insert, or numpy.stack. Maybe numpy.zeros, also.
The OP should probably be examining the numpy documentation:
https://numpy.org/doc/stable/reference/routines.html



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/


From mats at wichmann.us  Tue Apr 19 10:50:37 2022
From: mats at wichmann.us (Mats Wichmann)
Date: Tue, 19 Apr 2022 08:50:37 -0600
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <618179275.660604.1650244166759@mail.yahoo.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
Message-ID: <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>


On 4/17/22 19:09, david savage via Tutor wrote:
> Hi...thank you for this ability to ask questions.  I have dabbled with Python (Windows), but have never had the opportunity to use Python in a job.  I have been a PL/B programmer for the past 28 years, and recently got laid off from my job.  Because of the scarcity of open positions in this programming field, I'd like to get an entry-level position with a company that utilizes Python.  Someplace where I can actually increase my understanding of Python & therefore put it to good use...in an actual productive environment, but I'm not aware of any company that is willing to take on a programmer who doesn't have actual work experience using Python.  
> 
> So, anyway, that is my dilemna.  Can someone give me any suggestions on how to get my "foot in the door".....so to speak ?   My PL/B programming career started soon after I got hired on as an operator, running PL/B programs all day.   I think learning PL/B was a requirement of the job, & so I thought "this is going to be a great career for me", so I learned it.   I do enjoy PL/B, but if I knew then what I know now, I would probably have ran in the opposite direction.   
> 
> I have already checked out the web site of the maker of PL/B, as the job postings on there are not taken down, even when the jobs are filled.
> 
> So thanks for whatever advice you have..  If I knew what, in Python, specifically to focus on learning, then I will not feel like I'm spinning my wheels.  I'm even willing to start at the bottom.

It would be remiss not to warn you it's not going to be easy.  Today's
tech job market seems to filter ruthlessly on basically "having done
that exact job before".  Even seasoned developers have trouble with this
(umm, like me: I repeatedly get told I have a really impressive
background, but it doesn't tick the right boxes up front so I don't
become an actual candidate). The joke we old-timers tell is that these
days, even entry-level jobs require 8+ years of experience in the
relevant technologies.  And it apparently wasn't a joke that an open
source developer named Sebastian Ramirez was told he didn't have enough
years working with FastAPI to fit a job description - and he's the guy
that *wrote* FastAPI!!!

The point of all this is that in addition to good advice on which
aspects of the Python ecosystem to spend time learning, and to
contribute to open source projects to gain some real-life experience
(which really is great advice - IF you have the time to invest. If the
job search is pressing, you may not, it can take quite a while to
develop sufficient credibility from working on such a project)...
there's more to it than the technological part. You're going to need to
find someone to "take a chance" and that's not going to happen if you
can't find a way to talk to some people doing hiring, and that means
developing strategies for getting around the Gatekeepers, whose job it
is to present only the "best" candidates and not waste a hiring
manager's time with less promising looking ones.

From mats at wichmann.us  Tue Apr 19 11:14:11 2022
From: mats at wichmann.us (Mats Wichmann)
Date: Tue, 19 Apr 2022 09:14:11 -0600
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
Message-ID: <caa7c78b-fe84-d3a1-dfcb-beab17e55f92@wichmann.us>

On 4/19/22 08:50, Mats Wichmann wrote:

> And it apparently wasn't a joke that an open
> source developer named Sebastian Ramirez was told he didn't have enough
> years working with FastAPI to fit a job description - and he's the guy
> that *wrote* FastAPI!!!

Citation for completeness:

https://twitter.com/tiangolo/status/1281946592459853830?ref_src=twsrc%5Etfw



From dsavage1796 at yahoo.com  Tue Apr 19 11:16:14 2022
From: dsavage1796 at yahoo.com (david savage)
Date: Tue, 19 Apr 2022 15:16:14 +0000 (UTC)
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
Message-ID: <500435578.1218281.1650381374111@mail.yahoo.com>

 Thank you Mats.....You make some good points there.

David
     On Tuesday, April 19, 2022, 10:11:17 AM CDT, Mats Wichmann <mats at wichmann.us> wrote:  
 
 
On 4/17/22 19:09, david savage via Tutor wrote:
> Hi...thank you for this ability to ask questions.? I have dabbled with Python (Windows), but have never had the opportunity to use Python in a job.? I have been a PL/B programmer for the past 28 years, and recently got laid off from my job.? Because of the scarcity of open positions in this programming field, I'd like to get an entry-level position with a company that utilizes Python.? Someplace where I can actually increase my understanding of Python & therefore put it to good use...in an actual productive environment, but I'm not aware of any company that is willing to take on a programmer who doesn't have actual work experience using Python.? 
> 
> So, anyway, that is my dilemna.? Can someone give me any suggestions on how to get my "foot in the door".....so to speak ?? My PL/B programming career started soon after I got hired on as an operator, running PL/B programs all day.? I think learning PL/B was a requirement of the job, & so I thought "this is going to be a great career for me", so I learned it.? I do enjoy PL/B, but if I knew then what I know now, I would probably have ran in the opposite direction.? 
> 
> I have already checked out the web site of the maker of PL/B, as the job postings on there are not taken down, even when the jobs are filled.
> 
> So thanks for whatever advice you have..? If I knew what, in Python, specifically to focus on learning, then I will not feel like I'm spinning my wheels.? I'm even willing to start at the bottom.

It would be remiss not to warn you it's not going to be easy.? Today's
tech job market seems to filter ruthlessly on basically "having done
that exact job before".? Even seasoned developers have trouble with this
(umm, like me: I repeatedly get told I have a really impressive
background, but it doesn't tick the right boxes up front so I don't
become an actual candidate). The joke we old-timers tell is that these
days, even entry-level jobs require 8+ years of experience in the
relevant technologies.? And it apparently wasn't a joke that an open
source developer named Sebastian Ramirez was told he didn't have enough
years working with FastAPI to fit a job description - and he's the guy
that *wrote* FastAPI!!!

The point of all this is that in addition to good advice on which
aspects of the Python ecosystem to spend time learning, and to
contribute to open source projects to gain some real-life experience
(which really is great advice - IF you have the time to invest. If the
job search is pressing, you may not, it can take quite a while to
develop sufficient credibility from working on such a project)...
there's more to it than the technological part. You're going to need to
find someone to "take a chance" and that's not going to happen if you
can't find a way to talk to some people doing hiring, and that means
developing strategies for getting around the Gatekeepers, whose job it
is to present only the "best" candidates and not waste a hiring
manager's time with less promising looking ones.
_______________________________________________
Tutor maillist? -? Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
  

From leamhall at gmail.com  Tue Apr 19 14:50:10 2022
From: leamhall at gmail.com (Leam Hall)
Date: Tue, 19 Apr 2022 13:50:10 -0500
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <500435578.1218281.1650381374111@mail.yahoo.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
 <500435578.1218281.1650381374111@mail.yahoo.com>
Message-ID: <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>

David,

There was a point where we didn't have a lot of money. For a while I worked as a security guard, but that didn't really pay the bills. My wife went into the military to support us, and I found out about Linux.

I could barely afford a 386 computer; a friend loaned me a single speed Mitsumi CDROM and my wife let me get "Slackware Unleashed" which had a Linux CD in it. The computer and I hung out in the closet. When my wife got an assignment to Italy, there were no jobs on base but I found an Italian ISP that had just fired their only Unix guy. They gave me free dial-up access and a little bit of cash to cover the phone bill, I worked a few hours a week as a Linux guy. When something stumped me at work, I'd take the problem home, pour through "Essential System Administration" and the man pages, and then come back the next day with a solution. The internet wasn't quite a thing back then.

When we came back to the US, a place needed a few hours of SCO Unix work. I did that, and continued to learn, until a newspaper hired me as a Solaris admin. I kept learning and finding more challenging jobs, and later on I decided that being a programmer would help me fix the issues the operations people had. I worked my career and have been a full time programmer for few years. It took me six years to go from playing with DR-DOS to earning a full time living as a Linux/Unix admin, but I pay our bills and sent my wife through college with zero debt.

Mats is right, some places work hard to say "no" to well qualified candidates. But it just takes one "yes" to get started.

Leam

-- 
Site Automation Engineer   (reuel.net/resume)
Scribe: The Domici War     (domiciwar.net)
General Ne'er-do-well      (github.com/LeamHall)

From alan.gauld at yahoo.co.uk  Tue Apr 19 18:24:24 2022
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Tue, 19 Apr 2022 23:24:24 +0100
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
 <500435578.1218281.1650381374111@mail.yahoo.com>
 <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
Message-ID: <t3ncqo$2l9$1@ciao.gmane.io>

On 19/04/2022 19:50, Leam Hall wrote:

> I could barely afford a 386 computer; a friend loaned me a single speed Mitsumi CDROM

My first experience of Linux(and Windows as it happens) was on a 386SX
25MHz with 5MB RAM in 1993.

> "Slackware Unleashed" which had a Linux CD in it.

I just threw out my copy of that last year.

> playing with DR-DOS 

And I used DR DOS for years before moving to Windows, it
was much better than MS DOS. I still have the 30+
floppy disks for DR DOS 6 and the big fat manual.
Pity I no longer have a 3.5 inch floppy drive!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



From dsavage1796 at yahoo.com  Tue Apr 19 15:35:23 2022
From: dsavage1796 at yahoo.com (david savage)
Date: Tue, 19 Apr 2022 19:35:23 +0000 (UTC)
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
 <500435578.1218281.1650381374111@mail.yahoo.com>
 <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
Message-ID: <1624257222.1343606.1650396923774@mail.yahoo.com>

Well....that's inspiring....thank you for sharing Leam !
David

Sent from Yahoo Mail on Android 
 
  On Tue, Apr 19, 2022 at 1:51 PM, Leam Hall<leamhall at gmail.com> wrote:   David,

There was a point where we didn't have a lot of money. For a while I worked as a security guard, but that didn't really pay the bills. My wife went into the military to support us, and I found out about Linux.

I could barely afford a 386 computer; a friend loaned me a single speed Mitsumi CDROM and my wife let me get "Slackware Unleashed" which had a Linux CD in it. The computer and I hung out in the closet. When my wife got an assignment to Italy, there were no jobs on base but I found an Italian ISP that had just fired their only Unix guy. They gave me free dial-up access and a little bit of cash to cover the phone bill, I worked a few hours a week as a Linux guy. When something stumped me at work, I'd take the problem home, pour through "Essential System Administration" and the man pages, and then come back the next day with a solution. The internet wasn't quite a thing back then.

When we came back to the US, a place needed a few hours of SCO Unix work. I did that, and continued to learn, until a newspaper hired me as a Solaris admin. I kept learning and finding more challenging jobs, and later on I decided that being a programmer would help me fix the issues the operations people had. I worked my career and have been a full time programmer for few years. It took me six years to go from playing with DR-DOS to earning a full time living as a Linux/Unix admin, but I pay our bills and sent my wife through college with zero debt.

Mats is right, some places work hard to say "no" to well qualified candidates. But it just takes one "yes" to get started.

Leam

-- 
Site Automation Engineer? (reuel.net/resume)
Scribe: The Domici War? ? (domiciwar.net)
General Ne'er-do-well? ? ? (github.com/LeamHall)
_______________________________________________
Tutor maillist? -? Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
  

From mats at wichmann.us  Tue Apr 19 19:32:59 2022
From: mats at wichmann.us (Mats Wichmann)
Date: Tue, 19 Apr 2022 17:32:59 -0600
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
 <500435578.1218281.1650381374111@mail.yahoo.com>
 <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
Message-ID: <2363502a-cb36-27f0-a5a7-cce92b65b0db@wichmann.us>

On 4/19/22 12:50, Leam Hall wrote:
> David,
> 
> There was a point where we didn't have a lot of money. For a while I
> worked as a security guard, but that didn't really pay the bills. My
> wife went into the military to support us, and I found out about Linux.
> 
> I could barely afford a 386 computer; a friend loaned me a single speed
> Mitsumi CDROM and my wife let me get "Slackware Unleashed" which had a
> Linux CD in it. The computer and I hung out in the closet. When my wife
> got an assignment to Italy, there were no jobs on base but I found an
> Italian ISP that had just fired their only Unix guy. They gave me free
> dial-up access and a little bit of cash to cover the phone bill, I
> worked a few hours a week as a Linux guy. When something stumped me at
> work, I'd take the problem home, pour through "Essential System
> Administration" and the man pages, and then come back the next day with
> a solution. The internet wasn't quite a thing back then.
> 
> When we came back to the US, a place needed a few hours of SCO Unix
> work. I did that, and continued to learn, until a newspaper hired me as
> a Solaris admin. I kept learning and finding more challenging jobs, and
> later on I decided that being a programmer would help me fix the issues
> the operations people had. I worked my career and have been a full time
> programmer for few years. It took me six years to go from playing with
> DR-DOS to earning a full time living as a Linux/Unix admin, but I pay
> our bills and sent my wife through college with zero debt.
> 
> Mats is right, some places work hard to say "no" to well qualified
> candidates. But it just takes one "yes" to get started.

I agree with the other comments, this is a great story.

and yes, it only takes one to say yes (sure wish I could find that one,
sigh).  There's a very sharp guy I worked with for several years - we
were both "contributed" to a consortium project by our (different)
employers.  His company basically went away, and he got a job with the
organization that hosted/operated the consortium and remained assigned
to the project.  Then later he lost that job in a downsizing, but after
some months he found a job with, of all things, a jewelry store in the
new city his family had recently moved to, they needed a Linux
syadmin/app developer/all-around-everything-tech.  Doesn't seem like the
place for a senior tech guy, but he was very happy with that job (I
don't know if he's moved on though I used the past tense there).  So not
only does it only take one, but the one can be in a quite unexpected place.


From cs at cskk.id.au  Tue Apr 19 19:53:48 2022
From: cs at cskk.id.au (Cameron Simpson)
Date: Wed, 20 Apr 2022 09:53:48 +1000
Subject: [Tutor] Python question
In-Reply-To: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
References: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
Message-ID: <Yl9LjHQdviYd/zWf@cskk.homeip.net>

On 18Apr2022 11:50, Eleonora Panini <eleonora.panini7jkd at gmail.com> wrote:
><https://stackoverflow.com/posts/71904558/timeline>
>I need help to do the following steps in Phyton:
>
>-my starting array is: array = np.random.rand(1024x11700)
>
>-I have to obtain an array 1024x23400 with the following characteristics:
>25 columns(1024x25) of data and 25 columns (1024x25) of zeros
>
> So I thought to do a loop every 25 columns(1024x25), insert an array of
>zeros (1024x25) alternatevely every 25 columns, so I obtain an array
>1024x23400..
>
>but I don't know how to do it in Phyton.. Can you help me? Thank you

See Dennis' followup with suggested numpy functions which will help.

My own naive approach would be to make a new array by alternatively 
concatentating your 25 rows of data, then 25 rows of zeroes (Dennis 
mentioned a .zeroes function), repeat until you have done the whole 
original array.

I suggest you use a for-loop, using a range() to obtain the offsets you 
need: https://docs.python.org/3/library/stdtypes.html#range
so the initial loop would look like this:

    for offset in range(0, 11700, 25):

which counts "offset" from 0 to 11700 (excluding the 11700) in steps of 
25. That would let you grab the 25 rows of data at each offset and make 
an additional 25 rows of zeroes for building the second array.

Cheers,
Cameron Simpson <cs at cskk.id.au>

From leamhall at gmail.com  Tue Apr 19 20:03:18 2022
From: leamhall at gmail.com (Leam Hall)
Date: Tue, 19 Apr 2022 19:03:18 -0500
Subject: [Tutor] Python jobs with no work experience
In-Reply-To: <2363502a-cb36-27f0-a5a7-cce92b65b0db@wichmann.us>
References: <618179275.660604.1650244166759.ref@mail.yahoo.com>
 <618179275.660604.1650244166759@mail.yahoo.com>
 <a4d9938d-5c5a-992a-cb23-794cfc9d479a@wichmann.us>
 <500435578.1218281.1650381374111@mail.yahoo.com>
 <d9e0deba-7557-c4f9-ad5f-6cbd7b520533@gmail.com>
 <2363502a-cb36-27f0-a5a7-cce92b65b0db@wichmann.us>
Message-ID: <fbca6e4f-e8d1-f05a-933b-22c77e3928dc@gmail.com>

On 4/19/22 18:32, Mats Wichmann wrote:
  
> and yes, it only takes one to say yes (sure wish I could find that one,
> sigh). 

You'll get there! Remember, someone hired me and I'm not actually that bright.   ;)

Leam

-- 
Site Automation Engineer   (reuel.net/resume)
Scribe: The Domici War     (domiciwar.net)
General Ne'er-do-well      (github.com/LeamHall)

From __peter__ at web.de  Wed Apr 20 05:55:06 2022
From: __peter__ at web.de (Peter Otten)
Date: Wed, 20 Apr 2022 11:55:06 +0200
Subject: [Tutor] Python question
In-Reply-To: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
References: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
Message-ID: <04991159-25a5-8752-01f4-f4044ed5b634@web.de>

On 18/04/2022 11:50, Eleonora Panini wrote:
> <https://stackoverflow.com/posts/71904558/timeline>
>
> I need help to do the following steps in Phyton:
>
> -my starting array is: array = np.random.rand(1024x11700)
>
> -I have to obtain an array 1024x23400 with the following characteristics:
> 25 columns(1024x25) of data and 25 columns (1024x25) of zeros
>
>   So I thought to do a loop every 25 columns(1024x25), insert an array of
> zeros (1024x25) alternatevely every 25 columns, so I obtain an array
> 1024x23400..
>
> but I don't know how to do it in Phyton.. Can you help me? Thank you

Hello Eleonora,

in case you are still not working ;) on the problem here's some
spoon-feeding. My approach differs from what you sketched out above in
that I create a result matrix (i. e. your 1024x23400 beast) containing
only zeros and then copy parts of the original data (the 1024x25 chunks)
into that result matrix.

Notes:

- For aesthetic reasons I swapped rows and columns
- Numpy experts might do this differently

import numpy


def blowup(a, chunksize):
     assert len(a.shape) == 2
     if a.shape[0] % chunksize:
         raise ValueError(
             f"Number of matrix rows ({a.shape[0]}) "
             f"must be a multiple of chunk size ({chunksize})."
         )

     # create a matrix of zeros with twice as many rows as 'a'
     b = numpy.zeros((2 * a.shape[0], a.shape[1]))

     # lazily split 'a' into sub-matrices with chunksize rows
     chunks = (
         a[start:  start + chunksize]
         for start in range(0, a.shape[0], chunksize)
     )

     # iterate over the sub-matrices and replace zeros in 'b' with those
     # sub-matrices.
     delta = 2 * chunksize
     start = 0
     for chunk in chunks:
         b[start:start+chunksize] = chunk
         start += delta

     return b


# sample 6x3 matrix
a = numpy.arange(6 * 3, dtype=float).reshape((6, 3)) + 1
print(a)

# create 12x3 matrix with every two data rows followed by two rows of
# zeroes
b = blowup(a, 2)
print(b)

# 12x3 matrix with every three data rows followed by three rows of
# zeroes
print(blowup(a, 3))

# 3x3 matrix cannot be broken into chunks of two without rest
# --> ValueError
print(blowup(a[:3], 2))

From nathan-tech at hotmail.com  Wed Apr 20 10:18:03 2022
From: nathan-tech at hotmail.com (Nathan Smith)
Date: Wed, 20 Apr 2022 15:18:03 +0100
Subject: [Tutor] could someone break this down
In-Reply-To: <0ce3cf6a-2a5f-6fdc-3aa4-46657d5f3397@DancesWithMice.info>
References: <DB7PR07MB5093C48ADEB86ECD2BD4DE38E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <b472b8c6-75a7-7405-664b-4c3647b35644@wichmann.us>
 <DB7PR07MB509323F62FB17387AF745978E4E89@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <33e9a993-a988-d832-8795-acb18f26e721@DancesWithMice.info>
 <DB7PR07MB509393C3A7C0E3ED29C4A621E4EB9@DB7PR07MB5093.eurprd07.prod.outlook.com>
 <0ce3cf6a-2a5f-6fdc-3aa4-46657d5f3397@DancesWithMice.info>
Message-ID: <DB7PR07MB509347FE642D35C6EC5F6B0BE4F59@DB7PR07MB5093.eurprd07.prod.outlook.com>

Just as a closing on this one I ended up going with DN's mentioned 
approach in a way.


After another fruitless day of attempts I decided to hell with it and 
built my own DAWG out of fresh data sources, then rewrote parts of the 
TWL module to fit it. At the end it took me three attempts, but came out 
pretty well, all things considered. Admittedly though, my data sources 
are much bigger and I've rewritten it for more speed than small. Sadly, 
it no longer fits 500KB! :)


It works, though and that's what matters.

Amusing I did have a novice mistake which hopefully the list will laugh at.

I compiled the British and American word lists, and did a check to see 
if every word in the American one appeared in the British, expecting 
words like "color" and "favor" to not appear.

Actually, all the American words were in the British one! "I've wasted 
my time." I thought, "they're identical!" After about an hour of feeling 
sorry for myself, I then thought to run len(american) and len(british). 
Low and behold, american was 178,000ish, British was 270,000ish. Oh.

OOPS! :)

turns out the british wordlist for Scrabble includes the one used by 
TWL, then adds words.


Ah well, problem solved now.

thanks everyone for your help as ever.

Nathan

On 11/04/2022 00:50, dn wrote:
> On 11/04/2022 11.15, Nathan Smith wrote:
>> Yeah I reached out via email on the Github page but no response.
>> Considering the module was last updated in 2013 I'm not sure if that
>> email is even valid :)
>> Digging to see if anyone else has figures this though.
> Sad, but likely. GitHub is sometimes a great source of source (hah!) but
> is all too often a place to put 'stuff that I don't want to be bothered
> with any more'...
>
>
> I doubt that reverse-engineering the code will help, because it only
> traverses the DAWG data - it doesn't show how to build the DAWG from a
> (British) dictionary in the first place!
>
> ie head meet brick-wall!
>
>
>> Thanks to the resources provided I think I now have a rough
>> understanding of DAWG's but breaking down how the one in the module was
>> written to file and such is still challenge.
> I was thinking that the concept of building a Finite State Machine to
> traverse a DAWG - and to build the DAWG in the first place, would make
> quite a good programming (design and coding) assignment...
>
>
> If GitHub is no help, try 'the cheese shop' aka PyPi (https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpypi.org%2F&amp;data=04%7C01%7C%7C2a955077c73846bc591408da1b4e0223%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637852319105031206%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=GVpzhbq13PcGEs%2FRN9efXj8%2FtIs7X8XcG5HBZdHQzcg%3D&amp;reserved=0).
> Searching for DAWG realised some familiar 'hit's.
>
> It also mentions tries as an alternative data-structure.
>
> Noted "lexpy" which has been updated more recently (but then, once it's
> working, what updates are necessary?). It offers the choice of DAWG or
> trie, and seems to feature both the 'building' of the lexicon, and its
> (later) interrogation.
>
>
> Let us know how you get on...
-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net



From eleonora.panini7jkd at gmail.com  Wed Apr 20 14:39:15 2022
From: eleonora.panini7jkd at gmail.com (Eleonora Panini)
Date: Wed, 20 Apr 2022 20:39:15 +0200
Subject: [Tutor] Python question
In-Reply-To: <Yl9LjHQdviYd/zWf@cskk.homeip.net>
References: <CAGKHBxKa6TxptWce1svjauJ4pBbZJu4guygGYEO-QA0QCv7BSA@mail.gmail.com>
 <Yl9LjHQdviYd/zWf@cskk.homeip.net>
Message-ID: <CAGKHBxL4tLTs9S7GFdMEC6hG1S7tanZ8-i6wUip0BhCZuFXdUA@mail.gmail.com>

Thank you for your suggestions..I have an other question:
Why my output plot is empty? The code is:

fig, ax = plt.subplots()
ax.set_title(f"Orbit={OrbitNumber}" + f"-Date={DATE[0]}" +
"-Burst mode high resolution -from FFT A131W wave form" )
x_lims = list(map( lambda x:x, d_time.Time))
x_lims = mdates.date2num(x_lims)
ext=[np.nanmin(x_lims),np.nanmax(x_lims),0,1024]
im = ax.imshow(70+20*np.log10(np.rot90(inter,2)),interpolation='None',cmap=
'jet',aspect='auto', extent=ext)
ax.set_xlabel('DateTime')
ax.set_ylabel('f [kHz]')
plt.ylim(0,1024)
x1=d_time.iloc[12]['Time']
x2=d_time.iloc[189]['Time']
y=np.arange(0,1025)
plt.fill_betweenx(y,x1,x2,facecolor="white")
x1=d_time.iloc[657]['Time']
x2=d_time.iloc[1076]['Time']
y=np.arange(0,1025)
plt.fill_betweenx(y,x1,x2,facecolor="white")
x1=d_time.iloc[0]['Time']
x2=d_time.iloc[10]['Time']
y=np.arange(0,1025)
plt.fill_betweenx(y,x1,x2,facecolor="white")
fig.colorbar(im, ax=ax, pad=0.05)
ax.xaxis.set_ticks_position("bottom")
ax.xaxis.set_label_position("bottom")
ax.xaxis_date()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
ax.xaxis.set_major_locator(mdates.MinuteLocator(interval=1))
d_time.plot( x='Time', y='Freq', ax=ax, alpha=0)
#plt.savefig("/content/drive/MyDrive/Colab
Notebooks/Plot/inter.png",bbox_inches = 'tight')
plt.rcParams["figure.figsize"] = (20,3)
plt.show()

These are the 2 columns of my dataframe 'd_time':
d_time = pd.DataFrame()
d_time['Time']=pd.date_range(start="2018-8-7 07:08:55.902",end=
"2018-8-7 07:46:01.813" ,freq="0.04S").values
d_time.Time = pd.to_datetime(d_time.Time)
d_time['Freq'] = np.arange(0,55648).tolist()

the array 'inter' is 1024x23400
The part of my code with iloc is to select the white zone of my plot


On Wed, 20 Apr 2022 at 01:55, Cameron Simpson <cs at cskk.id.au> wrote:

> On 18Apr2022 11:50, Eleonora Panini <eleonora.panini7jkd at gmail.com> wrote:
> ><https://stackoverflow.com/posts/71904558/timeline>
> >I need help to do the following steps in Phyton:
> >
> >-my starting array is: array = np.random.rand(1024x11700)
> >
> >-I have to obtain an array 1024x23400 with the following characteristics:
> >25 columns(1024x25) of data and 25 columns (1024x25) of zeros
> >
> > So I thought to do a loop every 25 columns(1024x25), insert an array of
> >zeros (1024x25) alternatevely every 25 columns, so I obtain an array
> >1024x23400..
> >
> >but I don't know how to do it in Phyton.. Can you help me? Thank you
>
> See Dennis' followup with suggested numpy functions which will help.
>
> My own naive approach would be to make a new array by alternatively
> concatentating your 25 rows of data, then 25 rows of zeroes (Dennis
> mentioned a .zeroes function), repeat until you have done the whole
> original array.
>
> I suggest you use a for-loop, using a range() to obtain the offsets you
> need: https://docs.python.org/3/library/stdtypes.html#range
> so the initial loop would look like this:
>
>     for offset in range(0, 11700, 25):
>
> which counts "offset" from 0 to 11700 (excluding the 11700) in steps of
> 25. That would let you grab the 25 rows of data at each offset and make
> an additional 25 rows of zeroes for building the second array.
>
> Cheers,
> Cameron Simpson <cs at cskk.id.au>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
*Eleonora Panini*
*3480581404*

From phillor9 at gmail.com  Tue Apr 26 06:37:26 2022
From: phillor9 at gmail.com (Phil)
Date: Tue, 26 Apr 2022 20:37:26 +1000
Subject: [Tutor] testing the bits of a binary number
Message-ID: <a58aeb9c-1a53-8d2e-c7be-fafc377d62af@gmail.com>

I've been experimenting with a simpler way of testing the bits of a 
number without success.

Say I have a number represented as 0b00001001 and I want to test which 
bits are set. I solved this originally as I would in assembly language 
by anding a bit mask and the number. The number and the bit mask are 
shifter left followed by another anding operation until the most 
significant bit is reached.

This does work but it seems unnecessarily complex when using a high 
level language. An Internet search shows that similar questions have 
been asked and answerers given but I haven't been able to adapt those 
answerers to my problem. Can this problem be solved in a Pythonic way?

-- 
Regards,
Phil


From alan.gauld at yahoo.co.uk  Tue Apr 26 07:14:36 2022
From: alan.gauld at yahoo.co.uk (alan.gauld at yahoo.co.uk)
Date: Tue, 26 Apr 2022 12:14:36 +0100
Subject: [Tutor] testing the bits of a binary number
In-Reply-To: <a58aeb9c-1a53-8d2e-c7be-fafc377d62af@gmail.com>
References: <790184dd-654b-4d41-bf44-e9dc6cb0042a.ref@email.android.com>
Message-ID: <790184dd-654b-4d41-bf44-e9dc6cb0042a@email.android.com>

   Bit operations will be fastest but you could convert to a binary string
   and do a character search if you think that is more elegant. Personally I
   tend to omit the shifting and just create N masks and compare the original
   data to each mask, but that only makes sense for small bit sizes, say 16
   max. I name the masks after the purpose of the bit(s) tested so it looks
   like
   If data & motor_on:
   ? ? ...
   HTH
   Alan G?
   Ps posting from phone, apologies for the top post...?
   On 26 Apr 2022 11:37, Phil <phillor9 at gmail.com> wrote:

     I've been experimenting with a simpler way of testing the bits of a
     number without success.

     Say I have a number represented as 0b00001001 and I want to test which
     bits are set. I solved this originally as I would in assembly language
     by anding a bit mask and the number. The number and the bit mask are
     shifter left followed by another anding operation until the most
     significant bit is reached.

     This does work but it seems unnecessarily complex when using a high
     level language. An Internet search shows that similar questions have
     been asked and answerers given but I haven't been able to adapt those
     answerers to my problem. Can this problem be solved in a Pythonic way?

     --
     Regards,
     Phil

     _______________________________________________
     Tutor maillist? -? Tutor at python.org
     To unsubscribe or change subscription options:
     https://mail.python.org/mailman/listinfo/tutor

From phillor9 at gmail.com  Tue Apr 26 07:20:18 2022
From: phillor9 at gmail.com (Phil)
Date: Tue, 26 Apr 2022 21:20:18 +1000
Subject: [Tutor] testing the bits of a binary number
In-Reply-To: <790184dd-654b-4d41-bf44-e9dc6cb0042a@email.android.com>
References: <790184dd-654b-4d41-bf44-e9dc6cb0042a.ref@email.android.com>
 <790184dd-654b-4d41-bf44-e9dc6cb0042a@email.android.com>
Message-ID: <f2f2f9f8-b359-c3a7-c516-8688ae711682@gmail.com>


On 26/4/22 21:14, alan.gauld at yahoo.co.uk wrote:
> Bit operations will be fastest but you could convert to a binary 
> string and do a character search if you think that is more elegant.

Thank you Alan for your reply and it looks like bit shifting is the only 
real way to solve the problem.

-- 

Regards,
Phil


From cs at cskk.id.au  Tue Apr 26 21:00:01 2022
From: cs at cskk.id.au (Cameron Simpson)
Date: Wed, 27 Apr 2022 11:00:01 +1000
Subject: [Tutor] testing the bits of a binary number
In-Reply-To: <f2f2f9f8-b359-c3a7-c516-8688ae711682@gmail.com>
References: <f2f2f9f8-b359-c3a7-c516-8688ae711682@gmail.com>
Message-ID: <YmiVkTODECVvzwWw@cskk.homeip.net>

On 26Apr2022 21:20, Phil <phillor9 at gmail.com> wrote:
>
>On 26/4/22 21:14, alan.gauld at yahoo.co.uk wrote:
>>Bit operations will be fastest but you could convert to a binary 
>>string and do a character search if you think that is more elegant.
>
>Thank you Alan for your reply and it looks like bit shifting is the 
>only real way to solve the problem.

To an extent it depends on what question you are really trying to 
answer.

My own experience is that I'm usually concerned only with the 
combination of bits involved. Made up example:

    if flags & F_MODE1:
        # mode 1, we expect no other bits
        flags &= ~F_MODE1
        if flags:
            raise ValueError("MODE1 set, unexpected other bits: %s" % bin(flags))
        ... do the mode 1 stuff ...
    elif flags & F_MODE2:
        flags &= ~F_MODE1
        submode = False
        if flags & F_MODE2_SUBMODE:
            flags &= ~F_MODE1
            submode = True
        if flags:
            raise ValueError("MODE2 set, submode=%s, unexpected other bits: s" (submode, bin(flags)))
        ... do the mode 2 stuff ...
    else:
        ... whatever ...

So in the above example I'm interested in specific bits, and want to 
know if any bits are unparsed.

What's your use case? Or is this a learning exercise around bit 
manipulation, which is also just fine?

Also, you can at least print the binary form with the bin() function.

Finally, enums provide a nice Pythonic way of representing bitmaps:
https://docs.python.org/3/library/enum.html#module-enum

That might help you with testing and representation.

Cheers,
Cameron Simpson <cs at cskk.id.au>

From phillor9 at gmail.com  Wed Apr 27 01:47:12 2022
From: phillor9 at gmail.com (Phil)
Date: Wed, 27 Apr 2022 15:47:12 +1000
Subject: [Tutor] testing the bits of a binary number
In-Reply-To: <YmiVkTODECVvzwWw@cskk.homeip.net>
References: <f2f2f9f8-b359-c3a7-c516-8688ae711682@gmail.com>
 <YmiVkTODECVvzwWw@cskk.homeip.net>
Message-ID: <223e5140-f357-b3d6-c00d-60a1fab17ef9@gmail.com>


On 27/4/22 11:00, Cameron Simpson wrote:
>
> My own experience is that I'm usually concerned only with the
> combination of bits involved. Made up example:

Thank you Cameron for your reply and example code.


> What's your use case?

After experimenting with the new match-case statements I decided to 
refine a past project which turns on LEDS based on which bit is set. I 
came across a project yesterday that really had nothing to do with my 
project, or match-case statements, but it gave me an idea that made me 
think that there might be a more elegant way of solving the problem 
rather that shifting a bit mask to determine which bits are set. I've 
since refined the project in a minor way by eliminating a couple of 
lines of repeating code and coming up with a more meaningful name for a 
function.

-- 

Regards,
Phil


From nataprokopchuk at ukr.net  Wed Apr 27 11:35:41 2022
From: nataprokopchuk at ukr.net (Nataliya Prokopchuk)
Date: Wed, 27 Apr 2022 18:35:41 +0300
Subject: [Tutor] Voice reading in power point
Message-ID: <1651073740.870763000.kjtazijw@frv55.fwdcdn.com>

Hi,Could you please help me with a correct code for voice reading of power point presentation, all continuing slides, to have a like recording result at the end?

ThNk you in advance!

Kind regards, 
Nataliya Prokopchuk

From nathan-tech at hotmail.com  Wed Apr 27 16:22:56 2022
From: nathan-tech at hotmail.com (Nathan Smith)
Date: Wed, 27 Apr 2022 21:22:56 +0100
Subject: [Tutor] Voice reading in power point
In-Reply-To: <1651073740.870763000.kjtazijw@frv55.fwdcdn.com>
References: <1651073740.870763000.kjtazijw@frv55.fwdcdn.com>
Message-ID: <DB7PR07MB5093EBE82AF50A2CDD8310F4E4FA9@DB7PR07MB5093.eurprd07.prod.outlook.com>

Hello,


You'll probably want to combine two or three modules to do this.

My recommendations would be:

Python PPTX:

https://python-pptx.readthedocs.io/#:~:text=python%2Dpptx%20is%20a%20Python,link%20in%20a%20web%20application.


And a text to speech module:

https://www.geeksforgeeks.org/convert-text-speech-python/#


Hope that helps

Nathan

On 27/04/2022 16:35, Nataliya Prokopchuk wrote:
> Hi,Could you please help me with a correct code for voice reading of power point presentation, all continuing slides, to have a like recording result at the end?
>
> ThNk you in advance!
>
> Kind regards,
> Nataliya Prokopchuk
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&amp;data=05%7C01%7C%7C8c22e574a0b64d7f53ff08da28797441%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637866799353541106%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=doywt3tcqpLCrP2t0%2FKgMjPtlkcOxIc5xF218TeR5G8%3D&amp;reserved=0
-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net



From iamsatyabrata428 at gmail.com  Thu Apr 28 14:48:17 2022
From: iamsatyabrata428 at gmail.com (SATYABRATA DATTA)
Date: Fri, 29 Apr 2022 00:18:17 +0530
Subject: [Tutor] How to solve the overflow error in double_scalars
In-Reply-To: <CA+0cB4y7-6s3tLo2yhg4uGWBiosP=nHYL8qvwQ5M2sJeeEiu_Q@mail.gmail.com>
References: <CA+0cB4y7-6s3tLo2yhg4uGWBiosP=nHYL8qvwQ5M2sJeeEiu_Q@mail.gmail.com>
Message-ID: <CACNWyveZwjYk=d=8oXQ6TWdAtnzjPG+SfPO0ax=u4fqc+OAOag@mail.gmail.com>

Inside a python package Encountering overflow due to a part of code

this is my code part

    def V1(self, bosons, fermions, X):
        X = np.asanyarray(X, dtype=np.float64)
        phi1 = X[...,0]

        y1 = (17/3)*(4*(self.y6**4) - 3*(self.g**4))*(phi1**4)

        y1 -= (4*(self.y6**4) -
3*(self.g**4))*(2*np.log(np.abs((phi1)/(self.renormScaleSq**0.5))+
1e-100))*(phi1**4)
        return (y1/(64*np.pi*np.pi))

The error message is

Warning (from warnings module):
  File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cosmoTransitions\gen_poten.py",
line 258
    y1 -= (4*(self.y6**4) -
3*(self.g**4))*(2*np.log(np.abs((phi1)/(self.renormScaleSq**0.5))+
1e-100))*(phi1**4)RuntimeWarning: overflow encountered in
double_scalars
Warning (from warnings module):
  File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\cosmoTransitions\gen_poten.py",
line 258
    y1 -= (4*(self.y6**4) -
3*(self.g**4))*(2*np.log(np.abs((phi1)/(self.renormScaleSq**0.5))+
1e-100))*(phi1**4)RuntimeWarning: overflow encountered in multiply


and getting a completely wrong output,I think it is occuring due to the log
function but don't know how to resolve it

From wlfraed at ix.netcom.com  Thu Apr 28 20:29:50 2022
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Thu, 28 Apr 2022 20:29:50 -0400
Subject: [Tutor] How to solve the overflow error in double_scalars
References: <CA+0cB4y7-6s3tLo2yhg4uGWBiosP=nHYL8qvwQ5M2sJeeEiu_Q@mail.gmail.com>
 <CACNWyveZwjYk=d=8oXQ6TWdAtnzjPG+SfPO0ax=u4fqc+OAOag@mail.gmail.com>
Message-ID: <i6bm6hdvu0sj8p8omod5oc429pgjmem5eh@4ax.com>

On Fri, 29 Apr 2022 00:18:17 +0530, SATYABRATA DATTA
<iamsatyabrata428 at gmail.com> declaimed the following:

>Inside a python package Encountering overflow due to a part of code
>
>this is my code part
>
>    def V1(self, bosons, fermions, X):
>        X = np.asanyarray(X, dtype=np.float64)
>        phi1 = X[...,0]
>
>        y1 = (17/3)*(4*(self.y6**4) - 3*(self.g**4))*(phi1**4)
>
>        y1 -= (4*(self.y6**4) -
>3*(self.g**4))*(2*np.log(np.abs((phi1)/(self.renormScaleSq**0.5))+
>1e-100))*(phi1**4)
>        return (y1/(64*np.pi*np.pi))
>

	<SNIP>

>and getting a completely wrong output,I think it is occuring due to the log
>function but don't know how to resolve it

	Not a direct help, but I'd suggest breaking those long expressions into
a sequence of short steps with temporary variables. That would let you
isolate which term(s) are causing the problem(s).

	You may also simplify some of the code by pulling out common
sub-expressions: you are computing

	4 * (self.y6**4)
and
	3 * (self.g**4)

on both lines... (and since numpy appears to be involved given the np.
references, y6 and g could be numpy arrays, making those computations
costly to repeat). Say: y6quadby4, gquadby3 <G>

	17 / 3				(SEVENTEENTHIRDS)
and
	64*np.pi*np.pi		(PISQUAREBY64)

are invariants, and could be pre-computed at the module level and bound to
"constant" names rather than computing them each time this function is
invoked.


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/