""" Hi i intended to list the built-in function using this function. It seems however to give me the results corresponding with a dictionary. Why is that ? """"

def showbuiltins():

	""" saves the list of built in functions to a file you chose """

	blist = dir(__builtins__)
	print blist
	import asl
	drawer, file = asl.FileRequest('Select a file where to save the list of built-ins', 'ram:BI_list', '', '')
	file = drawer + file 
	print file
	bfile = open(file,"w")
	for item in blist:
    		bfile.write(item + "\n")
	bfile.close()

Not too many of us use the Amiga Standard Library (ASL). It is nice to know that Python is an integral part of Amiga Computer OS.

@vegaseat


I guess not too many indeed. Python is officially part of the AOS 4 (since 4.0 or 4.1) i am not sure.)
Since new PPC hardaware was available i bought a SAM a good year ago. I am totally new to Python and am quite disoriented. All help gladly taken

Right off the bat, I see a common mistake. Don't use 'file' as a variable name.

BTW, with the advent of Python3 file is no longer a function name.

The regular Python distribution does not contain a module asl. This is specific to the Amiga OS.

My question is what do you mean with a dictionary?
In Python there is a container called dictionary that works with key:value pairs.
It would look something like this ...

word2number_dict = {
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9,
"ten": 10}

@vegaseat
This is also what i mean with a dictionary. If you define some dictionary 'dict'
and do a dir(dict) you get exactly the same list as i get in the code at the print blist line:
['__class__', '__cmp__', '__contains__', '_ ...
It is not the list of the python builtin function list that you get when typing th lines 4 and 5 from the interactive shell. So the question is why? And if i understand that i hope you could suggest some alternative function returning this list.
In fact the saving to a file is not important heren, sorry to have posted that.

In regular Python 2.7 for Windows XP, this is working OK for me:

open('builtins.txt','w').write('\n'.join(dir(__builtins__)))
print open('builtins.txt').read()

@tonijv

Thanks for your proposal. It sure is more compact
The problem is not however to generate the list of builtin functions from the python interactive shell, but
(a) have it delivered by a function
(b) have it delivered by a python script launched by a non python application gui or docking system or even from the normal system shell(some button launching the script as "python pybuiltins.py")
This second question is solved: if i delete the function definition in the code above and use it as a script (or inject your solution) that works.
I still don't know how to solve (a) (where of course the builtins might as well be given as a python list).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.