This is a read-only mirror of pymolwiki.org

Difference between revisions of "Extend"

From PyMOL Wiki
Jump to navigation Jump to search
m
 
m
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
===DESCRIPTION===
 
===DESCRIPTION===
"extend" is an API-only function which binds a new external
+
[[Extend]] is an API-only function which binds a new external function as a command into the PyMOL scripting language.  In other words, when you write a function and want PyMOL to recognize the new command, you '''extend''' the command into PyMOL. Once extended, the function name is recognized like other function names (example below).  Typically, '''extend''' is the last line of a PyMOL script.
function as a command into the PyMOL scripting language.
 
  
 
===PYMOL API===
 
===PYMOL API===
cmd.extend(string name,function function)
+
<source lang="python">
 +
cmd.extend(string name,function function)
 +
</source>
  
 
===PYTHON EXAMPLE===
 
===PYTHON EXAMPLE===
def foo(moo=2): print moo
+
<source lang="python">
cmd.extend('foo',foo)
+
def foo(moo=2): print moo
 +
cmd.extend('foo',foo)
 +
</source>
  
 
The following would now work within PyMOL:
 
The following would now work within PyMOL:
PyMOL>foo
+
<source lang="python">
2
+
PyMOL>foo
PyMOL>foo 3
+
2
3
+
PyMOL>foo 3
PyMOL>foo moo=5
+
3
5
+
PyMOL>foo moo=5
PyMOL>foo ?
+
5
 +
PyMOL>foo ?
  
 
Usage: foo [ moo ]
 
Usage: foo [ moo ]
 +
</source>
  
 
===NOTES===
 
===NOTES===
For security reasons, new PyMOL commands created using "extend" are
+
For security reasons, new PyMOL commands created using "extend" are not saved or restored in sessions.
not saved or restored in sessions.
 
  
 
===SEE ALSO===
 
===SEE ALSO===
[[Cmd alias|alias]], [[Cmd api|api]]
+
*[[Alias]]
 +
*[[Api]]
 +
*[[Category:Scripting]]
  
[[Category:Commands|extend]]
+
[[Category:Commands|Extend]]

Revision as of 13:47, 20 June 2009

DESCRIPTION

Extend is an API-only function which binds a new external function as a command into the PyMOL scripting language. In other words, when you write a function and want PyMOL to recognize the new command, you extend the command into PyMOL. Once extended, the function name is recognized like other function names (example below). Typically, extend is the last line of a PyMOL script.

PYMOL API

cmd.extend(string name,function function)

PYTHON EXAMPLE

def foo(moo=2): print moo
cmd.extend('foo',foo)

The following would now work within PyMOL:

PyMOL>foo
2
PyMOL>foo 3
3
PyMOL>foo moo=5
5
PyMOL>foo ?

Usage: foo [ moo ]

NOTES

For security reasons, new PyMOL commands created using "extend" are not saved or restored in sessions.

SEE ALSO