Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Back on python for the AMIGA again and discovered this little gem...


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Back on python for the AMIGA again and discovered this little gem...

I am back on Python for the AMIGA again and discovered this little gem that exits the program:-
(If you search GOOGLE as 'os.sys.exit()' python nothing seems to appear.)

Code:
import os
os.sys.exit()

I know of the other four and how they apply but I have no idea whether this creates any zombies or memory holes or whatever.
Code:
import os
import sys
"""
sys.exit()
os._exit()
exit()
quit()
"""

Just thought you might like to know guys as I still code for the lowly AMIGA and its latest version of Python is an unreliable Version 2.4.6 and its earliest is 1.4.0 which I use a lot still...
The code in the top code block works from Version 1.4.0 on the AMIGA and an installed 3.5.2 on my MBP.
These 2 Users Gave Thanks to wisecracker For This Post:
# 2  
These are great posts! Thanks.

I used to love to program on the Amiga, including the years when I was a land surveyor and wrote a lot of land surveying programs on the Amiga (as well as a Tandy TRS 80 as I recall) which I used in my business, and your posts brings back fond, distant memories.
This User Gave Thanks to Neo For This Post:
# 3  
As an addendum to this thread assigning 'sys' to 'os.sys' opens up 'sys' without wasting namespace by importing 'sys' at all IF 'os' is already imported.
Demo code:
Code:
import os
print("")
print(dir(os.sys))
# import sys    # This is not needed if os is imported!

# Instead of taking up namespace by import[ing] sys, assign sys to os.sys in its place.
sys = os.sys

# A few simple 'sys' functions in action.
print("")
print(sys.platform)
print("")
print(sys.version)
print("")
print(sys.builtin_module_names)
print("")
sys.stdout.write("Hello unix.com!")
print("")
print("")
print(sys.modules)
print("")
sys.exit(10)

Results, OSX 10.14.3, default bash terminal calling python3.5...
Code:
Last login: Mon Jul  8 16:30:25 on ttys000
AMIGA:amiga~> cd Desktop/Code/Python
AMIGA:amiga~/Desktop/Code/Python> python3.5 os_sys.py

['__displayhook__', '__doc__', '__excepthook__', '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_debugmallocstats', '_getframe', '_home', '_mercurial', '_xoptions', 'abiflags', 'api_version', 'argv', 'base_exec_prefix', 'base_prefix', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'get_coroutine_wrapper', 'getallocatedblocks', 'getcheckinterval', 'getdefaultencoding', 'getdlopenflags', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval', 'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info', 'intern', 'is_finalizing', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'set_coroutine_wrapper', 'setcheckinterval', 'setdlopenflags', 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr', 'stdin', 'stdout', 'thread_info', 'version', 'version_info', 'warnoptions']

darwin

3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]

('_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 'time', 'xxsubtype', 'zipimport')

Hello unix.com!

{'zipimport': <module 'zipimport' (built-in)>, '_sitebuiltins': <module '_sitebuiltins' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_sitebuiltins.py'>, 'encodings.latin_1': <module 'encodings.latin_1' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings/latin_1.py'>, 'codecs': <module 'codecs' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/codecs.py'>, 'sre_compile': <module 'sre_compile' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sre_compile.py'>, 'os': <module 'os' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py'>, '_warnings': <module '_warnings' (built-in)>, '_signal': <module '_signal' (built-in)>, 'encodings': <module 'encodings' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings/__init__.py'>, '_weakrefset': <module '_weakrefset' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_weakrefset.py'>, 'builtins': <module 'builtins' (built-in)>, '_locale': <module '_locale' (built-in)>, '_imp': <module '_imp' (built-in)>, '_stat': <module '_stat' (built-in)>, 'os.path': <module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/posixpath.py'>, 'sre_parse': <module 'sre_parse' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sre_parse.py'>, 'genericpath': <module 'genericpath' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/genericpath.py'>, 'stat': <module 'stat' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/stat.py'>, 'sys': <module 'sys' (built-in)>, '_frozen_importlib_external': <module '_frozen_importlib_external' (frozen)>, '_codecs': <module '_codecs' (built-in)>, 'sysconfig': <module 'sysconfig' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sysconfig.py'>, '_osx_support': <module '_osx_support' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_osx_support.py'>, '_frozen_importlib': <module '_frozen_importlib' (frozen)>, '_sre': <module '_sre' (built-in)>, 'abc': <module 'abc' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/abc.py'>, 'encodings.aliases': <module 'encodings.aliases' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings/aliases.py'>, '_bootlocale': <module '_bootlocale' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_bootlocale.py'>, '_io': <module 'io' (built-in)>, 're': <module 're' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/re.py'>, 'marshal': <module 'marshal' (built-in)>, '_sysconfigdata': <module '_sysconfigdata' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_sysconfigdata.py'>, 'copyreg': <module 'copyreg' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/copyreg.py'>, '_thread': <module '_thread' (built-in)>, 'encodings.utf_8': <module 'encodings.utf_8' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings/utf_8.py'>, 'posixpath': <module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/posixpath.py'>, 'io': <module 'io' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/io.py'>, 'sre_constants': <module 'sre_constants' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sre_constants.py'>, 'errno': <module 'errno' (built-in)>, '__main__': <module '__main__' from 'os_sys.py'>, 'posix': <module 'posix' (built-in)>, '_weakref': <module '_weakref' (built-in)>, 'site': <module 'site' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site.py'>, '_collections_abc': <module '_collections_abc' from '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/_collections_abc.py'>}

AMIGA:amiga~/Desktop/Code/Python> echo $?
10
AMIGA:amiga~/Desktop/Code/Python> _

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
GCC for tha AMIGA...
wisecracker
Hi guys... For the AMIGA fans out there... Not sure if this is the right forum but someone has done a successful working port of gcc for the classic AMIGA A1200. It contains a very large subset of *NIX commands and now AMIGA fanatics like me can include another platform, within the...... News, Links, Events and Announcements
0
News, Links, Events and Announcements
A journey down memory lane - AMIGA...
wisecracker
Hi guys and gals... Who still plays with the AMIGA in any of its guises? I have a classic A1200(HD) on 24/7 and still build and code for it... Also _clones_ of the same machine using WinUAE and E-UAE... It still has that one major beauty for this 62 year old - moi - it is FUN! ;o)... What is on Your Mind?
2
What is on Your Mind?

Featured Tech Videos