Re: [Tutor] A required question

2018-11-26 Thread Mats Wichmann
On 11/25/18 8:54 PM, Asokan Pichai wrote:
> On Sat, Nov 24, 2018, 14:33 Avi Gross  
>> David,
>>
>> As I suspected. Yes, I am aware how to do those things. Just wondered if
>> anyone automated the process so a fairly simple interface worked.
>>
> Does the requirements.txt file (associated with pip IIRC) does most of what
> you want?

If so, then also worth looking at the pipfile and pipenv which are
aiming to improve on the experience.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A required question

2018-11-25 Thread Asokan Pichai
On Sat, Nov 24, 2018, 14:33 Avi Gross  David,
>
> As I suspected. Yes, I am aware how to do those things. Just wondered if
> anyone automated the process so a fairly simple interface worked.
>
Does the requirements.txt file (associated with pip IIRC) does most of what
you want?

>
> I am dropping the request.
>
> Avi
>
> -Original Message-
> From: Tutor  On Behalf Of
> David Rock
> Sent: Friday, November 23, 2018 9:28 PM
> To: Tutor Python 
> Subject: Re: [Tutor] A required question
>
>
> > On Nov 23, 2018, at 09:35, Alan Gauld via Tutor 
> wrote:
> >
> > On 23/11/2018 05:34, Avi Gross wrote:
> >> What I was thinking was the ability to do something like this:
> >>
> >> import ReChoir as require
> >>
> >> require.version(condition, before=True, after=False)
> >> require.modules(module list, recursive=True) require.os([“Eunuchs”,
> >> “Windblows”])
> >> require.functionality(“print3”)
> >
> > I can see the logic but suspect discussion of new features is probably
> > the preserve of the main Python list. If you can get traction there
> > somebody might actually go ahead and write one!
>
> discussion of a “require” library probably isn’t necessary.  It’s pretty
> straightforward to include the logic using existing methods.
>
> For the version of python, test against sys.version_info For the modules,
> put your import calls in a try block and handle exceptions For the OS
> version, test against os.name or sys.platform The last one,
> “functionality,” is a bit vague.  Probably another candidate for a try
> block.
>
>
> —
> David Rock
> da...@graniteweb.com
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A required question

2018-11-24 Thread Avi Gross
David,

As I suspected. Yes, I am aware how to do those things. Just wondered if anyone 
automated the process so a fairly simple interface worked. 

I am dropping the request.

Avi

-Original Message-
From: Tutor  On Behalf Of David 
Rock
Sent: Friday, November 23, 2018 9:28 PM
To: Tutor Python 
Subject: Re: [Tutor] A required question


> On Nov 23, 2018, at 09:35, Alan Gauld via Tutor  wrote:
> 
> On 23/11/2018 05:34, Avi Gross wrote:
>> What I was thinking was the ability to do something like this:
>> 
>> import ReChoir as require
>> 
>> require.version(condition, before=True, after=False) 
>> require.modules(module list, recursive=True) require.os([“Eunuchs”, 
>> “Windblows”])
>> require.functionality(“print3”)
> 
> I can see the logic but suspect discussion of new features is probably 
> the preserve of the main Python list. If you can get traction there 
> somebody might actually go ahead and write one!

discussion of a “require” library probably isn’t necessary.  It’s pretty 
straightforward to include the logic using existing methods.

For the version of python, test against sys.version_info For the modules, put 
your import calls in a try block and handle exceptions For the OS version, test 
against os.name or sys.platform The last one, “functionality,” is a bit vague.  
Probably another candidate for a try block.


—
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A required question

2018-11-24 Thread Avi Gross
ne 29, in 
var = imp.find_module(modulosity)
  File 
"C:\Users\avid2016\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 
297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named 'koala'

Amazingly it failed!

Calling it a night as I find errors even after I rewrite it like this;

modulosity = "SimPy"

print(" importing " + modulosity + "By hook or by crook.")

import imp
try:
var = imp.find_module(modulosity)
print ("FOUND: " + modulosity + " at " + str(var))
except:
print("NOT FOUND")
print("Module needs loading: " + modulosity)
import os
os.system("python -m pip install " + modulosity)

exec(f"import {modulosity}")

I am sure something is doable and can be made into a proper function. Yes, I 
cheated by using exec. But it is now after Spanksgiving.

-Original Message-
From: Tutor  On Behalf Of Alan 
Gauld via Tutor
Sent: Friday, November 23, 2018 10:35 AM
To: tutor@python.org
Subject: Re: [Tutor] A required question

On 23/11/2018 05:34, Avi Gross wrote:
> Just to be different, and perhaps return to the purpose of this group,

Actually I think the higher level debate of Python's direction as a teaching 
language is entirely appropriate for this group. It kind of defines the group 
and and its current and future role.

Whereas...

> What I was thinking was the ability to do something like this:
> 
> import ReChoir as require
> 
> require.version(condition, before=True, after=False) 
> require.modules(module list, recursive=True) require.os([“Eunuchs”, 
> “Windblows”])
> require.functionality(“print3”)

I can see the logic but suspect discussion of new features is probably the 
preserve of the main Python list. If you can get traction there somebody might 
actually go ahead and write one!

On the tutor list such matters are usually adequately covered by virtual 
environments etc.

--
Alan G


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A required question

2018-11-23 Thread Alan Gauld via Tutor
On 23/11/2018 05:34, Avi Gross wrote:
> Just to be different, and perhaps return to the purpose of this group,

Actually I think the higher level debate of Python's direction as
a teaching language is entirely appropriate for this group. It kind
of defines the group and and its current and future role.

Whereas...

> What I was thinking was the ability to do something like this:
> 
> import ReChoir as require
> 
> require.version(condition, before=True, after=False)
> require.modules(module list, recursive=True)
> require.os([“Eunuchs”, “Windblows”])
> require.functionality(“print3”)

I can see the logic but suspect discussion of new features is
probably the preserve of the main Python list. If you can get
traction there somebody might actually go ahead and write one!

On the tutor list such matters are usually adequately covered
by virtual environments etc.

-- 
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@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] A required question

2018-11-23 Thread Avi Gross
Just to be different, and perhaps return to the purpose of this group, I have a 
question.

 

Is there some functionality available in Python that you could put in the 
beginning of a program so it aborts with a message if the version of R being 
run is not acceptable?

 

Let me elaborate. There seem to be new features added as you move up. I mean 
2.2, 2.3, … 3.0 and so on.

 

But there also seem to be features deprecated then removed.

 

To make it crazier, some features are back-ported into later releases of 2.X 
while some features are activated only in you import the right things from 
__FUTURE__ .

 

Add to that the fact that various modules may exist or not exist on your 
machine in your search PATH and they may import yet others, and it gets crazy. 
Even weirder is that you can probably download a missing file as the program 
runs and then import it and probably many other scenarios where you own program 
writes a module and then imports it!

 

What I was thinking was the ability to do something like this:

 

import ReChoir as require

 

require.version(condition, before=True, after=False)

require.modules(module list, recursive=True)

require.os([“Eunuchs”, “Windblows”])

require.functionality(“print3”)

 

I hope you get the idea. Any one of the statements above might be made anywhere 
in your program but is best near the top of the main program perhaps after any 
imports from the dunder FUTURE.

 

I am not designing it. I am giving a very silly example and also suggesting a 
possible scenario like this:

 

if ! require( <> ):

print(“Sorry, your system is too primitive to use this snazzy 
software.”)

print(“In a moment, you will be re-directed to a dumber version 
written”)

print(“stone age tools. Please upgrade son.”

print(“running program paleo.py for you with same arguments.”

sleep(5)

exit( os.system(<<<“call to python to run paleo.py with same 
args using argv …”>>>) )

 

So in some cases, you quit with a message saying why you quit. In the example 
at the end, you may call alternate functionality, perhaps a shell-script rather 
than python, that does something for them. In an extreme case, the script would 
download a later version of Python as a sort of bootstrap. 

 

Yes, tons of holes in here and implementation details. For example, some 
features are only needed if the command line or data lead you down some path. 
No need to abort most of the time and not easy or even possible to see if you 
might need it.

 

So is there anything interesting out there already, designed to not so much 
make python portable, but to prevent things from running and then dying in 
middle of something important. 

 

Yes, I know there is an assert command you can use and there are system 
variables you can query to see what version of Python you are running on what 
OS and so on. No doubt there are tools you can use to see if everything 
imported exists (maybe not the right file) somewhere in the path. The latter 
alone is a huge issue as there have been changes in how you import including 
some really odd ones where they broke old functionality. 

 

There may come a day when 2.X is as extinct as polio (stubbornly hanging in 
there as some refuse to vaccinate) but I do not foresee the march of changes 
slowing in 3.x, let alone 4.x^2 and beyond.

 

Such a tool might make it easier for people to use new features with less fear.

 

One more thought. Such a function set might simply try new features inside a 
“try” and catch the error so they can gracefully annoy the user with a snide 
remark and even tell them what is missing. For example a line with a := in it 
should fail everywhere now but might work later. An f”string” is not that old. 
A line using open() in an iterator context would fail somewhere back in 2.x. In 
theory, you can make a list of testable new features and even give them names 
you can ask for such as the “print3” above.

 

Why do I ask? I had a great day today except it followed a horrible day 
yesterday. I did a bunch of work in R but the main point could just as easily 
happen in Python. I wanted various packages to do various things. Some had 
broken for me in the last year or so and been replaced with something that 
refused to work. In English, it was supposed to take a linear model generated 
from data and calculate some predicted info from it and make a nice graph with 
lines showing the impact of another variable at the mean and +/- a standard 
deviation. The problem is that I had the latest version of R installed but some 
of the many packages required were not yet available or their dependencies were 
either not available or of the wrong date. This happens with Python modules 
too. With lots of research, I loaded some things from alternate places and 
backed up to older versions and then forward and eventually had a brainstorm of 
figuring out what to