[Tutor] A required question

David Rock david at graniteweb.com
Fri Nov 23 21:27:35 EST 2018


> On Nov 23, 2018, at 09:35, Alan Gauld via Tutor <tutor at python.org> 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
david at graniteweb.com






More information about the Tutor mailing list