code

Cerca

Heus ací els resultats de la cerca.

3.1 PEP 8 – Introduction @info:cursos:pue:python-pcpp1:m2
154 Resultats, Darrera modificació:
8 is a document that provides coding conventions (code style guide) for Python code. PEP 8 is considered one of the most important PEPs and a must-read for e... sional Python programmer, as it helps to make the code more consistent, more readable, and more efficien... about one simple but important observation:** our code will be read much more often than it will be writ
4.1 PEP 257 – Docstring Conventions @info:cursos:pue:python-pcpp1:m2
101 Resultats, Darrera modificació:
regulations!) associated with documenting Python code using docstrings. In short, it tries to answer th... tion about the functionality of a larger piece of code in a **prescriptive** way. They help programmers... urpose, operation, and capabilities of particular code blocks or sections. == Docstring vs. comments Bef... ggest): comments are used for **commenting** your code, while docstrings are used for **documenting** yo
1.7 Four magic letters: CRUD @info:cursos:pue:python-pcpp1:m4
84 Resultats, Darrera modificació:
your cars.json is located and launch the server: <code bash>json-server --watch cars.json</code> **Note (very important)** – the fact that the ''json-server'... ll transmit JSON messages between the client (our code) and the server (''json-server''). The way the se... which is completely useless to us. Look at the code in the editor. It's very basic so far, but will g
1.1 SQLite @info:cursos:pue:python-pcpp1:m5
84 Resultats, Darrera modificació:
lite3 module, you must import it in your script: <code python>import sqlite3</code> NOTE: The sqlite3 module has been available in Python since version 2.5. ... ect'' method provided by the ''sqlite3'' module: <code python>import sqlite3 conn = sqlite3.connect('hello.db')</code> The ''connect'' method returns the database rep
2.4 Decorators @info:cursos:pue:python-pcpp1:m1
74 Resultats, Darrera modificació:
message logging; * thread synchronization; * code refactorization; * caching. == Function decora... could think of. We'll decorate it in a moment. <code python> def simple_hello(): print("Hello from simple function!") </code> <code python> def simple_decorator(function): print('We are about to call "{}"'.format(function._
2.1 PEP 20 – The Zen of Python @info:cursos:pue:python-pcpp1:m2
72 Resultats, Darrera modificació:
e editor window, type in ''import this'', run the code, and voilà! Can you see what happens? What you s... e encouraged to accept them and implement in your code. These, of course, should be looked upon holisti... 7.png }} == Explicit is better than implicit The code you write should be **explicit and readable**. W... onality. If not, think about leaving a comment in code to explain what’s going on so that other programm
3.1 Advanced techniques of creating and serving exceptions @info:cursos:pue:python-pcpp1:m1
70 Resultats, Darrera modificació:
raised) when it has no idea what do to with your code. What happens next? * the raised exception ex... t an exception error message like the following: <code ; output> IndexError: list index out of range </code> Sooner or later, every Pythonista will write a code that raises an exception, and that is why it is s
1.4 Talking to JSON in Python @info:cursos:pue:python-pcpp1:m4
67 Resultats, Darrera modificació:
and we're sure that you knew it before we asked: <code python> import json </code> The first JSON module's power is the ability to automatically **convert Py... utputs a number – we don't expect anything more: <code python> import json electron = 1.602176620898E10−19 print(json.dumps(electron)) </code> The code outputs: <code ; output> 16021766189.98
2.1 File processing - XML files @info:cursos:pue:python-pcpp1:m5
66 Resultats, Darrera modificació:
n XML tag must have a corresponding closing tag. <code xml><?xml version="1.0"?> <data> <book title=... r> <year>1603</year> </book> </data></code> == XML parsing (part 1) Processing XML files in ... ocument, pass it to the parse method as follows: <code python>import xml.etree.ElementTree as ET tree = ET.parse('books.xml') root = tree.getroot() </code> The ''getroot'' method returns the root element
4.1 Shallow and deep copy operations @info:cursos:pue:python-pcpp1:m1
64 Resultats, Darrera modificació:
. It’s hard to imagine writing a piece of Python code that performs any kind of data processing without... pying them. When you spot the following clause: <code python> a_list = [ 1, 'New York', 100] </code> {{ :info:cursos:pue:python-pcpp1:pasted:20231026-143815... treat it as an absolute memory address. Run the code presented in the right pane to see how the string
1.6 Making life easier with the requests module @info:cursos:pue:python-pcpp1:m4
56 Resultats, Darrera modificació:
ipt run-time environment that executes JavaScript code outside of a browser//. Don't be afraid – we’re g... in, but we aren't going to force you to write any code in it. It’ll act as a **black box** for us, and w... overed, so when you issue the following command: <code bash>npm</code> (which is short for node.js package manager) you should see a short help screen simila
5.1 Metaprogramming @info:cursos:pue:python-pcpp1:m1
53 Resultats, Darrera modificació:
and implemented in the early 1960s. For Python, code modifications can occure while the code is being executed, and you might have already experienced it wh... ws programmers to minimize the number of lines of code to express a solution, in turn reducing developme... preparation; those tools could be applied to your code to make it follow specific programming patterns,
4.2 Serialization of Python objects using the pickle module @info:cursos:pue:python-pcpp1:m1
51 Resultats, Darrera modificació:
string, an integer, and a list. When you run the code presented in the right pane, a new file should be created. Remember to run the code locally. <code python> import pickle a_dict = dict() a_dict['EUR'] = {'code':'Euro', 'symbol': '€'} a_dict['GBP'] = {'code':'
2.4 Shaping the main window and conversing with the user @info:cursos:pue:python-pcpp1:m3
45 Resultats, Darrera modificació:
would use a method named ''title()''. Our sample code shows a window which changes its title each time ... it ten times, after which the title remains 0. <code python> import tkinter as tk def click(*args): ... ow.bind("<Button-1>", click) window.mainloop() </code> Changing the main window’s icon is more trouble... agree it’s not very elegant. Take a look at the code we've provided in the editor. <code python> impo
1.2 How to use sockets in Python @info:cursos:pue:python-pcpp1:m4
43 Resultats, Darrera modificació:
ll you? This is what we'll put at the top of our code: <code python> import socket </code> === Obtaining user input We also need **the name of the HTTP server** we... The user knows it better. Let's ask him or her: <code python> import socket server_addr = input("What
2.5 Working with the Canvas @info:cursos:pue:python-pcpp1:m3
42 Resultats, Darrera modificació:
1.6 Events and how to handle them @info:cursos:pue:python-pcpp1:m3
41 Resultats, Darrera modificació:
1.2 Let TkInter speak! @info:cursos:pue:python-pcpp1:m3
37 Resultats, Darrera modificació:
2.3 A small lexicon of widgets - Part 3 @info:cursos:pue:python-pcpp1:m3
34 Resultats, Darrera modificació:
1.3 JSON – our new friend @info:cursos:pue:python-pcpp1:m4
33 Resultats, Darrera modificació:
3.1 The CSV module in Python @info:cursos:pue:python-pcpp1:m5
32 Resultats, Darrera modificació:
4.1 Logging in Python @info:cursos:pue:python-pcpp1:m5
31 Resultats, Darrera modificació:
2.5 Different faces of Python methods @info:cursos:pue:python-pcpp1:m1
30 Resultats, Darrera modificació:
2.3 Extended function argument syntax @info:cursos:pue:python-pcpp1:m1
28 Resultats, Darrera modificació:
2.6 Abstract classes @info:cursos:pue:python-pcpp1:m1
26 Resultats, Darrera modificació:
1.7 Visiting widgets’ properties @info:cursos:pue:python-pcpp1:m3
26 Resultats, Darrera modificació:
5.1 The configparser module @info:cursos:pue:python-pcpp1:m5
26 Resultats, Darrera modificació:
2.1 Python core syntax @info:cursos:pue:python-pcpp1:m1
24 Resultats, Darrera modificació:
2.7 Encapsulation @info:cursos:pue:python-pcpp1:m1
20 Resultats, Darrera modificació:
1.5 A simple GUI application @info:cursos:pue:python-pcpp1:m3
18 Resultats, Darrera modificació:
1.8 Interacting with widget methods @info:cursos:pue:python-pcpp1:m3
16 Resultats, Darrera modificació:
1.9 Looking at variables @info:cursos:pue:python-pcpp1:m3
16 Resultats, Darrera modificació:
2.2 A small lexicon of widgets - Part 2 @info:cursos:pue:python-pcpp1:m3
16 Resultats, Darrera modificació:
2.1 A small lexicon of widgets - Part 1 @info:cursos:pue:python-pcpp1:m3
15 Resultats, Darrera modificació:
1.4 Coloring your widgets @info:cursos:pue:python-pcpp1:m3
9 Resultats, Darrera modificació:
1.1 What is PEP? @info:cursos:pue:python-pcpp1:m2
1 Resultats, Darrera modificació: