[Tutor] Tutor Digest, Vol 163, Issue 28

Saahndong Ransom saahndongransom at gmail.com
Tue Sep 19 10:45:17 EDT 2017


What are the uses of python?
What are easy way to learn python?

On Sep 19, 2017 15:07, <tutor-request at python.org> wrote:

Send Tutor mailing list submissions to
        tutor at python.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
        tutor-request at python.org

You can reach the person managing the list at
        tutor-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."

Today's Topics:

   1. pip install of subprocess module (Derek Smith)
   2. Re: pip install of subprocess module (Alan Gauld)
   3. Require help for a script (Clara Chua)
   4. Re: Require help for a script (Alan Gauld)
   5. Re: Require help for a script (D.V.N.Sarma ??.??.???.????)


---------- Forwarded message ----------
From: Derek Smith <DerekSmith at racksquared.com>
To: "tutor at python.org" <tutor at python.org>
Cc:
Bcc:
Date: Mon, 18 Sep 2017 17:59:39 +0000
Subject: [Tutor] pip install of subprocess module
Hi All,

Thank for the recent replies.  I want to use the subprocess.run module b/c
per the docs os.system is antiquated and cannot use  more than 1 arg in 3.6.
Why am I doing wrong below?  Also couldn't I just copy and paste the
subprocess code from github and create a file, but then how do I tell
python this is a new module called os.system since this py file requires
os.system and os.spawn*
I am on AIX 7.1, python 3.6.2, pip 9.0.1

Thx agn!

# pip install git+https://github.com/python/cpython/blob/3.6/Lib/
subprocess.py -vvv
Collecting git+https://github.com/python/cpython/blob/3.6/Lib/subprocess.py
  Cloning https://github.com/python/cpython/blob/3.6/Lib/subprocess.py to
/tmp/pip-bw8rryo9-build
  Running command git clone -q https://github.com/python/
cpython/blob/3.6/Lib/subprocess.py /tmp/pip-bw8rryo9-build
remote: Not Found
fatal: repository 'https://github.com/python/cpython/blob/3.6/Lib/
subprocess.py/' not found
Cleaning up...
Command "git clone -q https://github.com/python/cpython/blob/3.6/Lib/
subprocess.py /tmp/pip-bw8rryo9-build" failed with error code 128 in None
Exception information:
Traceback (most recent call last):
  File "/opt/freeware/lib/python3.6/site-packages/pip/basecommand.py", line
215, in main
    status = self.run(options, args)
  File "/opt/freeware/lib/python3.6/site-packages/pip/commands/install.py",
line 335, in run
    wb.build(autobuilding=True)
  File "/opt/freeware/lib/python3.6/site-packages/pip/wheel.py", line 749,
in build
    self.requirement_set.prepare_files(self.finder)
  File "/opt/freeware/lib/python3.6/site-packages/pip/req/req_set.py", line
380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/opt/freeware/lib/python3.6/site-packages/pip/req/req_set.py", line
620, in _prepare_file
    session=self.session, hashes=hashes)
  File "/opt/freeware/lib/python3.6/site-packages/pip/download.py", line
805, in unpack_url
    unpack_vcs_link(link, location)
  File "/opt/freeware/lib/python3.6/site-packages/pip/download.py", line
479, in unpack_vcs_link
    vcs_backend.unpack(location)
  File "/opt/freeware/lib/python3.6/site-packages/pip/vcs/__init__.py",
line 286, in unpack
    self.obtain(location)
  File "/opt/freeware/lib/python3.6/site-packages/pip/vcs/git.py", line
142, in obtain
    self.run_command(['clone', '-q', url, dest])
  File "/opt/freeware/lib/python3.6/site-packages/pip/vcs/__init__.py",
line 325, in run_command
    spinner)
  File "/opt/freeware/lib/python3.6/site-packages/pip/utils/__init__.py",
line 707, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "git clone -q
https://github.com/python/cpython/blob/3.6/Lib/subprocess.py
/tmp/pip-bw8rryo9-build" failed with error code 128 in None



Derek Smith  |  Unix/TSM Administrator  | Racksquared Data Centers
::  dereksmith at racksquared.com  *: www.racksquared.com<http://
www.racksquared.com/> |  www.racksquared.jobs<http://www.racksquared.jobs/>

[cid:image003.png at 01D2E9AA.1B9CF8F0]




---------- Forwarded message ----------
From: Alan Gauld <alan.gauld at yahoo.co.uk>
To: tutor at python.org
Cc:
Bcc:
Date: Mon, 18 Sep 2017 23:24:31 +0100
Subject: Re: [Tutor] pip install of subprocess module
On 18/09/17 18:59, Derek Smith wrote:

> I want to use the subprocess.run module b/c per the> docs os.system is
antiquated

Its not so much antiquated but it is deprecated because
it is severely limited, all you get back is an error code.

> Why am I doing wrong below?

You are trying to install it, but subprocess is part
of the standard library, it should already be installoed.

Just use the >>> prompt and try

>>> import subprocess

If you don't get an error then its already there.

> python this is a new module called os.system

subprocess is its own moduile it is not part of os.

import os
import subprocess

> since this py file requires os.system and os.spawn*

Both of those can be replaced by calls within
subprocess but  they will not be called by
those names. Read the subprocess module documents
carefully they give example code for replacing
these functions.


--
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





---------- Forwarded message ----------
From: Clara Chua <clarabuyss at gmail.com>
To: tutor at python.org
Cc:
Bcc:
Date: Tue, 19 Sep 2017 15:48:40 +0800
Subject: [Tutor] Require help for a script
Hi Python tutor, I require help for a script that asks user for number of
rows, r and number of columns c, and generates a r x c matrix with the
following values:

- The value of each element in the first row is the number of the column
- The value of each element in the first column is the number of the row
- The rest of the elements each has a value equal to the sum of the element
above it and the element to the left.

Example of such matrix if a user inputs r=4 and c=5

1    2     3     4     5
2    4     7    11   16
3    7    14   25   41
4   11    25   50   91

We were told to use the for loops as well as numpy for this.
Thank you in advance!



---------- Forwarded message ----------
From: Alan Gauld <alan.gauld at yahoo.co.uk>
To: tutor at python.org
Cc:
Bcc:
Date: Tue, 19 Sep 2017 09:54:18 +0100
Subject: Re: [Tutor] Require help for a script
On 19/09/17 08:48, Clara Chua wrote:
> Hi Python tutor, I require help for a script that asks user for number of
> rows, r and number of columns c, and generates a r x c matrix with the
> following values:

What help do you need?
Which part of the above do you not know how to do?

Can you ask the user for two numbers and store them
in two variables?

It says generate a matrix, I'm guessing that's
where the numpy stuff comes in although a standard
Python list would be just as effective in this case.
In either case can you define a new two dimensional
data structure using the sizes read previously?

> - The value of each element in the first row is the number of the column

Do you know how to populate the first row?

> - The value of each element in the first column is the number of the row

Do you know how to populate the first column (or first
element of each row)?

> - The rest of the elements each has a value equal to the sum of the
element
> above it and the element to the left.

Do you know how to iterate over each cell in your matrix,
starting with the second row?

For a given cell do you know how to read the value above?
For a given cell do you know how to read the value left?

Do you know how to sum two values and store the result
in the current cell?

> Example of such matrix if a user inputs r=4 and c=5
>
> 1    2     3     4     5
> 2    4     7    11   16
...

Tell us which part of the problem you are stuck with.
Show us the code you have tried and any error
messages (in full). Then we can give you more focused
help.

--
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





---------- Forwarded message ----------
From: "D.V.N.Sarma డి.వి.ఎన్.శర్మ" <dvnsarma at gmail.com>
To: Clara Chua <clarabuyss at gmail.com>
Cc: "tutor at python.org" <tutor at python.org>
Bcc:
Date: Tue, 19 Sep 2017 19:36:56 +0530
Subject: Re: [Tutor] Require help for a script
First fill the first row and first column of the matrix with seperate loops.
Then the rest of the elements of the matrix can be filled with nested loops.
regards,
Sarma.


On Tue, Sep 19, 2017 at 1:18 PM, Clara Chua <clarabuyss at gmail.com> wrote:
> Hi Python tutor, I require help for a script that asks user for number of
> rows, r and number of columns c, and generates a r x c matrix with the
> following values:
>
> - The value of each element in the first row is the number of the column
> - The value of each element in the first column is the number of the row
> - The rest of the elements each has a value equal to the sum of the
element
> above it and the element to the left.
>
> Example of such matrix if a user inputs r=4 and c=5
>
> 1    2     3     4     5
> 2    4     7    11   16
> 3    7    14   25   41
> 4   11    25   50   91
>
> We were told to use the for loops as well as numpy for this.
> Thank you in advance!
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor at python.org
https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list