Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 2.4 Decorators @info:cursos:pue:python-pcpp1:m1
- dose of theory. So, let's create a function – ''simple_hello()'' is one of the simplest functions we 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(fun
- 2.1 PEP 20 – The Zen of Python @info:cursos:pue:python-pcpp1:m2
- e. In Python, it’s preferred to use not only the simplest way to express a programming idea, but also... python-pcpp1:m2:pasted:20231105-125726.png }} == Simple is better than complex Simplicity is the key to success. A **simpler solution** is usually preferred over a complex one, and g
- 1.2 How to use sockets in Python @info:cursos:pue:python-pcpp1:m4
- rite **a program which reads the address of a WWW site** (e.g., pythoninstitute.org) using the standar... oot document** (the main HTML document of the WWW site) of the specified site; * the program **outputs the document** to the screen; * the program **u... t will contain the requested root document of the site) - **close the socket** (end the connection)
- 3.1 PEP 8 – Introduction @info:cursos:pue:python-pcpp1:m2
- n our case, it means we must not forget about one simple but important observation:** our code will be... n Python, you should remember to follow these two simple rules: * Use **four spaces per indentation... evel_function(): return None </code> * **a single blank line** to surround method definitions i... d and should only be used for test purposes or in situations where your comments or docstrings use a n
- 2.4 Shaping the main window and conversing with the user @info:cursos:pue:python-pcpp1:m3
- r you choose. If you want your main window to be sized in a non-default way, you have to use a low-le... o use it. Look – clicking the window changes its size, and the window gets bigger and smaller periodi... port tkinter as tk def click(*args): global size, grows if grows: size += 50 if size >= 500: grows = False else:
- 1.3 JSON – our new friend @info:cursos:pue:python-pcpp1:m4
- opment is in fact based on TLA. What is TLA? It's simple – it's a Three-Letter Acronym. Close your eye... fferent types, including other objects) or even a single value in a way that can survive network trans... m conversions. JSON solves the problem using two simple tricks: * it uses **UTF-8 coded text** – t... able) and comprehensible by humans; * it uses a simple and not very expanded **format** (we can call
- 2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP @info:cursos:pue:python-pcpp1:m1
- ython-pcpp1:pasted:20231013-035718.png }} A very simple example of two-level inheritance is presented... cle** classes. == Inheritance and polymorphism — Single inheritance vs. multiple inheritance There ar... nheritance should be used with more prudence than single inheritance because: * a single inheritance class is always simpler, safer, and easier to unde
- 4.1 PEP 257 – Docstring Conventions @info:cursos:pue:python-pcpp1:m2
- be turned into documentation; their purpose is to simplify the code, provide precise information, and ... important? Essentially, we must not forget this simple rule by Guido van Rossum: "**Code is more oft... hat comments in Python are created using the hash sign (#). They should be rather brief (no more than ... ne comment, in which case you should use the hash sign at the beginning of each line of comment. Gene
- 1.6 Making life easier with the requests module @info:cursos:pue:python-pcpp1:m4
- ren't able to avoid them) and we also need a tool simpler than the ''socket'' module to talk with the ... ckage manager) you should see a short help screen similar to the one presented here: {{ :info:cursos:p... response. As you can see, the code is extremely **simple and compact** – we don't need to cope with a ... works as expected, you will see a very short and simple result:<code>200</code> As the HTTP protocol
- 2.8 Composition vs Inheritance - two ways to the same destination @info:cursos:pue:python-pcpp1:m1
- ance is to reuse the code. If two classes perform similar tasks, we can create a common base class for... f constructing adaptable objects. You can achieve similar goals by using a concept named composition. ... e code to see how composition works. Look at the simple code presented in the editor pane. <code pyt... et_pressure()'', ''pump()''; attribute available: size * engine; methods available: ''start()'', '
- 4.2 Serialization of Python objects using the pickle module @info:cursos:pue:python-pcpp1:m1
- utput of your data processing for later use? The simplest way to persist outcomes is to generate a fl... text file and to write your outcomes. It’s a very simple thing to do way which is not suitable for per... rint(data2) </code> The presented code is quite simple: * we’re importing a pickle module; * th... ct, returns the initial object. An example of in situ serialization and deserialization is presented
- 1.2 Let TkInter speak! @info:cursos:pue:python-pcpp1:m3
- ow it works. We’ll do it step-by-step. Ready The simplest (and at the same time the less controllable... an enthusiast of living life on the edge, you can simplify your import (but not the rest of your work)... ndow's method, named **mainloop()**. The name is significant because – as you can see – there is noth... cupied by the upper-left corner; * the widget's size is defaultly determined by the constructor in o
- Python Professional Course Series: GUI Programming @info:cursos:pue:python-pcpp1:m3
- to different screen areas and acted in a way very similar to a mouse. But believe us – you don't want... swer was given by pressing a set of allowed keys. Simple? Simple. From our present-day developer's perspective, too simple. From a user's point of view, difficult and i
- 1.7 Four magic letters: CRUD @info:cursos:pue:python-pcpp1:m4
- base (or the service) may vary, e.g., it may be a simple relational database residing in a single file, or on the contrary, a huge, distributed cloud of c... HTTP method. Now we’re ready to carry out some simple but instructive experiments with JSON. We’ll ... ean value; * the initial file contains data for six cars – don't be surprised if the server modifies
- 1.1 SQLite @info:cursos:pue:python-pcpp1:m5
- years. Do you know how that’s possible? Data is simply information about users, the contents of thei... : The sqlite3 module has been available in Python since version 2.5. == sqlite3 – creating a database As we already said, the SQLite database is a single file, which is saved on your computer. Each f... ce a standard that would standardize its syntax. Since the first production deployments, the followin