<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://wikiprogramming.alfredgg.dev/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://wikiprogramming.alfredgg.dev/feed.php">
        <title>Programming script:python:new</title>
        <description></description>
        <link>https://wikiprogramming.alfredgg.dev/</link>
        <image rdf:resource="https://wikiprogramming.alfredgg.dev/lib/tpl/dokuwiki/images/favicon.ico" />
       <dc:date>2026-05-13T10:26:01+0000</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:advanced&amp;rev=1589016310&amp;do=diff"/>
                <rdf:li rdf:resource="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:api&amp;rev=1589016310&amp;do=diff"/>
                <rdf:li rdf:resource="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:language&amp;rev=1589016310&amp;do=diff"/>
                <rdf:li rdf:resource="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:snippets&amp;rev=1589016310&amp;do=diff"/>
                <rdf:li rdf:resource="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:xtra&amp;rev=1589016310&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://wikiprogramming.alfredgg.dev/lib/tpl/dokuwiki/images/favicon.ico">
        <title>Programming</title>
        <link>https://wikiprogramming.alfredgg.dev/</link>
        <url>https://wikiprogramming.alfredgg.dev/lib/tpl/dokuwiki/images/favicon.ico</url>
    </image>
    <item rdf:about="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:advanced&amp;rev=1589016310&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-05-09T09:25:10+0000</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Python avanzado</title>
        <link>https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:advanced&amp;rev=1589016310&amp;do=diff</link>
        <description>Python avanzado

Pequeños conceptos

Comprehesion lists

Crean una lista a partir de otras. 

Siguen el formato [variable_devuelta bucle(s) condicion(es)]:


&gt;&gt;&gt; lst = [4, 6, 1, 8, 3, 0, 5, 9, 10, 7, 2]		# Creación de la lista inicial
&gt;&gt;&gt; big = [n for n in lst if n &gt; 5]			# Selección de números mayores que 5
&gt;&gt;&gt; big
[6, 8, 9, 10, 7]
&gt;&gt;&gt; sbig = sorted([n for n in lst if n &gt; 5])		# Y ordenados
&gt;&gt;&gt; sbig
[6, 7, 8, 9, 10]
&gt;&gt;&gt; sbig = sorted(n for n in lst if n &gt; 5)		# Aunque entre paréntesis no es nec…</description>
    </item>
    <item rdf:about="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:api&amp;rev=1589016310&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-05-09T09:25:10+0000</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Python - elementos del lenguaje</title>
        <link>https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:api&amp;rev=1589016310&amp;do=diff</link>
        <description>Python - elementos del lenguaje

Clases, módulos y funciones própias de Python.

Cómo tratar con...

Strings

Acciones básicas


my_str = 'Hola buenos días!'	# Definición de un string
'ola' in my_str			# Saber si un string forma parte de otro string
my_str[-1:]			# Recoger el último caracter
my_str[2]			# Recoger el segundo carácter
my_path = u&quot;c:\windows&quot;		# Omite los carácteres de escape
len(my_str)			# Saber el tamaño del string
my_str + my_str2		# Concatena el string my_str con my_str2…</description>
    </item>
    <item rdf:about="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:language&amp;rev=1589016310&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-05-09T09:25:10+0000</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Python</title>
        <link>https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:language&amp;rev=1589016310&amp;do=diff</link>
        <description>Python

Sintaxis y uso básico del lenguaje.

Básico

Sintaxis

Variables


a = 3			# Crea la variable numérica a con valor 3
b = 'abc'		# Crea la variable string b con valor 'abc'
c = &quot;def&quot;		# Crea la variable string b con valor 'def'
e = True		# Crea una variable booleana e
del a			# Elimina de memoria la variable a 
a, b = 3, 4		# a = 3, b = 4</description>
    </item>
    <item rdf:about="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:snippets&amp;rev=1589016310&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-05-09T09:25:10+0000</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Python - snippets</title>
        <link>https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:snippets&amp;rev=1589016310&amp;do=diff</link>
        <description>Python - snippets

Utilización del lenguaje para un propósito concreto.

Cómo...

Ejecutar un fichero

Un script en python


execfile(script_path)	


Un ejecutable del sistema


path = r'c:\bsplayer'			# ruta del ejecutable

import os
print os.execv((path), [])		# lanza un ejecutable del sistema, el segundo parámetro son los argumentos para este.

def start (program, *args):
   return os.spawnv(os.P_NOWAIT, program, (program,) + args)
start(path)				# lanza un ejecutable del sistema, en Windows …</description>
    </item>
    <item rdf:about="https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:xtra&amp;rev=1589016310&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-05-09T09:25:10+0000</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Python - xtra</title>
        <link>https://wikiprogramming.alfredgg.dev/doku.php?id=script:python:new:xtra&amp;rev=1589016310&amp;do=diff</link>
        <description>Python - xtra

Pequeños consejos, utilidades del lenguaje...

Patrones de diseño

Método factoría


class ProjectType(object):
    build_cmd = &quot;&quot;
    markers = []

    @classmethod
    def make_project(cls, path):
        prj_types = (PythonProject, AutoconfProject, MakefileOnly, ProjectType)
        for p in prj_types:
            markers = p.markers
            if any(path.isfile(path.join(path, x)) for x in markers):
                return p()

class PythonProject(ProjectType):
    build_cmd …</description>
    </item>
</rdf:RDF>
