...
 
Commits (4)
\begin{module}[id=file-type]
\importmhmodule[path=programming/en/files]{files}
\importmhmodule[repos=MiKoMH/GenCS,path=codes/en/utfcodes]{utfcodes}%
\begin{frame}
\frametitle{File Types}
\begin{itemize}
\item
\begin{definition}[id=text-file.def]
A \defii{text}{file} is a computer file that is structured as a sequence of
\mtrefi[utfcodes?character-encoding]{encoded}
\trefis[unicode-ucs]{character}. Computer files that are not \trefiis{text}{file}
are called \defiis{binary}{file}.
\end{definition}
\item
\begin{assertion}[type=remark]
\Trefiis{text}{file} are usually encoded with $\ASCIIcode$,
\trefi[ASCII-problems]{ISO-Latin}, or -- increasingly -- $\unicode$ encodings like
$\UTFeight$.
\end{assertion}
\end{itemize}
\end{frame}
\begin{note}
\begin{assertion}[type=remark]
\importmhmodule[repos=MiKoMH/TDM,path=digdocs/en/digital-text]{digital-text}
\Trefii{plain}{text} is different from \trefii[markup]{formatted}{text}, which includes
\trefiis[markup]{markup}{code}, and \trefiis{binary}{file} in which some portions must
be interpreted as binary objects (encoded integers, real numbers, images, etc.)
\end{assertion}
\end{note}
\end{module}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
......@@ -33,6 +33,7 @@
\end{definition}
\end{itemize}
\end{frame}
\begin{nomtext}
Many operating systems use files as a primary computational metaphor, also treating
other resources like \trefis{file}. \inlinedef{This leads to an abstraction of files
......
\begin{module}[id=python-funcargs]
\importmhmodule[path=python/en/functions]{python-functions}
\begin{frame}
\frametitle{Argument Passing in $\pythonLanguage$: Default Arguments}
\begin{itemize}
\item
\begin{definition}[id=def.default-argument]
The last $k\leq n$ of $n$ parameters of a \trefi{function} can be
\defiis{default}{argument} of the form
\lstinline[mathescape]|$p_i$=$\pmetavar{val}_i$|: If no argunent $a_i$ is given in
the function call, the \defii{default}{value} $\pmetavar{val}_i$ is taken.
\end{definition}
\item
\begin{example}[for=def.default-argument]
The head of the \lstinline|open| function is
\lstinputmhlisting{python/ex/open.py}
\end{example}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Argument Passing in $\pythonLanguage$: Flexible Arity}
\begin{itemize}
\item
\begin{definition}[id=def.rest-argument]
$\pythonLanguage$ \trefis{function} can take a variable number of parameters:
\lstinline[mathescape]|def $f$ ($p_1$,$\ldots$,$p_k$,*$r$)| allows
\lstinline[mathescape]|$f$($a_1$,$\ldots$,$a_k$,$a_{k+1}$,$\ldots$,$a_n$)| and binds the
parameter $r$ to the list \lstinline[mathescape]|[$a_{k+1}$,$\ldots$,$a_n$]|.
\end{definition}
\item
\begin{example}[for=def.rest-argument]
\lstinputmhlisting{python/ex/rest.py}
\end{example}
\item We can also use the ``star syntax'' in the function call
\item
\begin{example}[title=Passing a list]
\lstinputmhlisting{python/ex/star-arg.py}
\end{example}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Argument Passing in $\pythonLanguage$: Keyword Arguments}
\begin{itemize}
\item
\begin{definition}[id=def.keyword-arguments]
$\pythonLanguage$ \trefis{function} can take \defiis{keyword}{argument}:\\
if $k$ is a sequence of key/value pairs then
\lstinline[mathescape]|def $f$($p_1$,$\ldots$,$p_n$,**$k$)|, binds the keys to
values in the body of $f$.
\end{definition}
\item
\begin{example}[for=def.keyword-arguments]
\lstinputmhlisting{python/ex/kwargs.py}
\end{example}
\item Again, we can use the ``double star syntax'' in the function call
\item
\begin{example}[title=Passing a dictionary]
\lstinputmhlisting{python/ex/dict-arg.py}
\end{example}
\end{itemize}
\end{frame}
\end{module}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
\begin{module}[id=html-python]
\importmhmodule[path=python/en/strings]{python-strings}
\importmhmodule[repos=MiKoMH/GenCS,path=www/en/php]{php}
\importmhmodule[repos=MiKoMH/GenCS,path=www/en/html]{html}
\lstset{language=python}
\begin{frame}[fragile]
\frametitle{What would we do in $\pythonLanguage$}
......@@ -9,7 +9,22 @@
\begin{example}[title=$\html$ Hello World in $\pythonLanguage$]\strut\\
\lstinputmhlisting{python/ex/hello.py}
\end{example}
\item Why is this not as good as $\php$?
\item
\begin{omtext}[title=Problem]
Most \trefii[www-concepts]{web}{page} content is static (page head, text blocks,
etc.)
\end{omtext}
\item
\begin{omtext}[title=Another]
If $\html$ markup dominate, want to use a $\html$ editor (mode)
\begin{itemize}
\item e.g. for $\html$ syntax highlighting/indentation/completion/checking
\end{itemize}
\end{omtext}
\item
\begin{omtext}[title=Idea]
Embed program snippets into $\html$ pages.\lec{only execute these, copy rest}
\end{omtext}
\item If $\html$ markup dominate, want to use a $\html$ editor (mode)
\begin{itemize}
\item e.g. for $\html$ syntax highlighting/indentation/completion/checking
......
def pdict(a1, a2, a3):
print('a1: ',a1,', a2: ',a1,', a3: ',a1)
dict = {"a3": 3, "a2": "two"}
>>> pdict(1, **dict)
>>> a1: 1, a2: two, a3: 3
def kw_args(farg, **kwargs):
print "formal arg:", farg
for key in kwargs:
print "another keyword arg: %s: %s" % (key, kwargs[key])
>>> kw_args(farg=1, myarg2="two", myarg3=3)
def open(file, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, closefd=True, opener=None)
def flexary (a,b,*c)
return len(c)
>>> flexary (1,2,3,4,5)
>>> 3
def test_var_args_call(arg1, arg2, arg3):
...
args = ["two", 3]
test_var_args_call(1, *args)
......@@ -17,6 +17,7 @@
\mhinputref{python/en/forloop}
\mhinputref{python/en/functions-intro}
\mhinputref{python/en/functions}
\mhinputref{python/en/funcargs}
\nmhinputref{python/snip/fileio-intro}
\mhinputref{python/en/input-print}
\nmhinputref{python/snip/fileio-intro}
......
% adapted from MiKoMH/GenCS/source/www/fragments/serverside.tex
\begin{omgroup}{Server Side Scripting}
\mhinputref[MiKoMH/GenCS]{www/en/serverside-scripting}
\mhinputref{python/en/html-in-python}
\nmhinputref[MiKoMH/GenCS]{www/snip/php-intro}
\mhinputref[MiKoMH/GenCS]{www/en/php}
\mhinputref[MiKoMH/GenCS]{www/en/template-engine}
\mhinputref{python/en/html-in-python}
\mhinputref[MiKoMH/GenCS]{www/en/webapps}
\mhinputref[MiKoMH/GenCS]{www/en/webapp-framework}
\mhinputref[MiKoMH/GenCS]{www/en/cookies}
\end{omgroup}
......