source | all docs for version 0.9.0 | all versions | oilshell.org
Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
Oil's expression language borrows heavily from Python. In fact, it literally
started with Python's Grammar/Grammar
file.
This doc describes some differences, which may help Python users learn Oil.
If you don't know Python, see A Tour of the Oil Language.
r'c:\Program Files\'
or $'line\n'
.\u{3bc}
instead of \u03bc
and \U000003bc
['pea', 'nut']
, there are
shell-like literals %(pea nut)
.true
, false
, and null
are preferred, but True
,
False
, and None
are accepted for compatibility.42,
are disallowed, in favor of the more explicit
tup(42)
.Other literals like ints and floats are the same as in Python.
%symbol
(used in eggex now, but could also be used as interned strings)\n
and \u{03bc}
, and also #'a'
^(ls | wc -l)
^[1 + a[i] + f(x)]
^{42, verbose = true}
Kinds of of operators:
=== ~== in not in
< > <= =>
+ -
& |
and or
++
$
and @
Equality:
===
for exact quality?~==
for approximate (numbers and strings)
==
?Oil doesn't overload operators as much, and does string <-> int conversion:
a + b
is for addition, while a ++ b
is for concatenation.a < b
does numeric comparison (with conversion). cmp()
could be for
strings.Other:
1:5:2
syntax because 0::2
conflicts with module::name
.
This might have been unnecessary.mydict->key
as an alias for mydict['key']
++
mentioned above~
operator rather than the re
module.~~
glob match operator%
. Use ${x %.3f}
instead.@
for matrix multiply.s[i]
returns an integer code point ("rune").runeAt()
and byteAt()
?in
for array/list membership. Only dict membership.++=
operator on strings doesn't existtrue !== 1
. In Python, they are equal: True == 1
.