(Create print() page) |
(Fix version) |
||
(5 intermediate revisions by one user not shown) | |||
Line 6: | Line 6: | ||
Return Value: None. | Return Value: None. | ||
| | | | ||
− | [[Syntax]]: print(arg1 [, arg2, arg3 ...] [sep | + | [[Syntax]]: print(arg1 [, arg2, arg3 ...] [sep=STRING, end=STRING, file=STRING]) |
− | The print() function is based on the python3 print() function. | + | The print() function is based on the python3 print() function. You can pass as many arguments of whatever type you want and it will print them, separated by sep, with the end string at the end. |
− | You can pass as many arguments of whatever type you want and it will print | + | |
− | them, separated by sep, with the end string at the end. | + | |
− | sep defaults to | + | sep defaults to " ". end defaults to "\n". file defaults to stdout. |
− | If file is provided, it will be opened in append mode same as fprintf | + | If file is provided, it will be opened in append mode same as [[fprintf]]. |
− | Note that the keyword arguments can be given in any order, anywhere in the | + | Note that the keyword arguments can be given in any order, anywhere in the call, even interspersed with regular arguments. |
− | call, even interspersed with regular arguments. | + | |
− | Note that this prints complex objects (structures, text objects, 3D arrays) | + | Note that this prints complex objects (structures, text objects, 3D arrays) similar to the way that [[dump]] does except without a depth limit for arrays ''or'' structs. When combined with sep, that can look off. |
− | + | ||
− | When combined with sep, that can look off. | + | |
− | The best way to use print in those cases is to set sep | + | The best way to use print in those cases is to set sep="" and pass space and newlines as you want, or just print complex structures separately. See the example. |
− | and newlines as you want, or just print complex structures separately. | + | |
− | See the example. | + | |
| | | | ||
− | dv> b | + | dv> b = create(2,3,2) |
2x3x2 array of int32, bsq format [48 bytes] | 2x3x2 array of int32, bsq format [48 bytes] | ||
0 1 | 0 1 | ||
2 3 | 2 3 | ||
4 5 | 4 5 | ||
− | + | ||
6 7 | 6 7 | ||
8 9 | 8 9 | ||
− | 10 | + | 10 11 |
− | + | ||
dv> print(100, b, 300) | dv> print(100, b, 300) | ||
100 0 1 | 100 0 1 | ||
2 3 | 2 3 | ||
4 5 | 4 5 | ||
− | + | ||
6 7 | 6 7 | ||
8 9 | 8 9 | ||
− | 10 | + | 10 11 300 |
− | + | ||
− | dv> print(100, '\n', b, '\n', 300, sep | + | dv> print(100, '\n', b, '\n', 300, sep=''''''') |
100 | 100 | ||
0 1 | 0 1 | ||
2 3 | 2 3 | ||
4 5 | 4 5 | ||
− | + | ||
6 7 | 6 7 | ||
8 9 | 8 9 | ||
− | 10 | + | 10 11 |
300 | 300 | ||
+ | |||
+ | dv> c = { a = 1, b = 2 } | ||
+ | struct, 2 elements | ||
+ | a: 1 | ||
+ | b: 2 | ||
+ | dv> dump(c) | ||
+ | struct, 2 elements... | ||
+ | dv> print(c) | ||
+ | a: 1 | ||
+ | b: 2 | ||
| | | | ||
| | | | ||
Line 61: | Line 64: | ||
*[[printf]] | *[[printf]] | ||
*[[sprintf]] | *[[sprintf]] | ||
+ | *[[fprintf]] | ||
+ | | | ||
| | | | ||
+ | 2.18 | ||
| | | | ||
}} | }} |
Latest revision as of 18:06, 18 November 2016
Contents: Description, Arguments, Usage, Examples, Related Functions Supported Under Version: > 2.18 Current Davinci Version: 2.27 64-bit Safe: Yes
Description Print output to a stream
Arguments and Return Values Arguments: objects to print Return Value: None.
Usage Syntax: print(arg1 [, arg2, arg3 ...] [sep=STRING, end=STRING, file=STRING]) The print() function is based on the python3 print() function. You can pass as many arguments of whatever type you want and it will print them, separated by sep, with the end string at the end. sep defaults to " ". end defaults to "\n". file defaults to stdout. If file is provided, it will be opened in append mode same as fprintf. Note that the keyword arguments can be given in any order, anywhere in the call, even interspersed with regular arguments. Note that this prints complex objects (structures, text objects, 3D arrays) similar to the way that dump does except without a depth limit for arrays or structs. When combined with sep, that can look off. The best way to use print in those cases is to set sep="" and pass space and newlines as you want, or just print complex structures separately. See the example.
Examples dv> b = create(2,3,2) 2x3x2 array of int32, bsq format [48 bytes] 0 1 2 3 4 5 6 7 8 9 10 11 dv> print(100, b, 300) 100 0 1 2 3 4 5 6 7 8 9 10 11 300 dv> print(100, '\n', b, '\n', 300, sep='') 100 0 1 2 3 4 5 6 7 8 9 10 11 300 dv> c = { a = 1, b = 2 } struct, 2 elements a: 1 b: 2 dv> dump(c) struct, 2 elements... dv> print(c) a: 1 b: 2 |
DavinciWiki Mini-Nav Bar Contents
Contact Developers
All other topics
Recent Core Changes Modified On: 11-19-2016 |