所有控件都以C结尾, C代表的是Control
BC====Button
CBC====Check Box
EC====Edit Control------
CBC====Combo Box---------
List Box----------
Group Box---------
Radio Button------
import type { CSSProperties } from 'vue'
const styles: { [key: string]: CSSProperties } = {
container: {
display: "none"
}
}
// Relevannsi - Search title only.
// Rebuild index after adding function.
add_filter( 'relevanssi_index_content', '__return_false' );
Tu es un expert en rénovation de biens immobiliers et consommation énergétique des logements.
Rédige un article de blog sur [TOPIC] en français, entre 600 et 1500 mots.
L'article devrait notamment traiter des sujets suivants [TOPICS].
L'article doit comporter un titre dans une balise h2 et un sous-titre dans une balise h3.
L'article doit comporter entre 3 et 7 chapitres.
L'article doit être généré sous forme de document html.
Le document html doit notamment contenir deux balises meta :
- une bal
function getUserInfo() {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject('request exception')
}, 1000)
})
}
// 1) Try-catch
async function loggedIn() {
try {
let userInfo = await getUserInfo()
// Execution interrupt
let pageInfo = await getPageInfo(userInfo?.userId)
} catch(e) {
console.warn(e)
}
}
// 2 direct catch
async function loggedIn() {
let userInfo
from .models import LargeData, SomeData
# * 1 iterator()
data = LargeData.objects.all()
# Iterate over queryset using iterator
# The iterator() method is used to retrieve query results one at a time, rather than loading all results into memory at once
for obj in data.iterator(chunk_size=100):
# process each object
print(obj)
# * 2 explain()
queryset = SomeData.objects.filter(is_active=True, is_published=False)
explanation = queryset.query.explain()
print(explanation)
from functools import wraps
def memoize(func):
cache = {}
@wraps(func)
def wrapper(*args):
print("** 'memoize' decorator :")
if args in cache:
return cache[args]
else:
result = func(*args)
cache[args] = result
print(f"{func.__name__} returned: {result}")
print()
return result
return wrapper
from functools import wraps
def debug(func):
@wraps(func)
def wrapper(*args, **kwargs):
print("** 'debug' decorator :")
print(f"Calling {func.__name__} with args: {args} and kwargs: {kwargs}")
result = func(*args, **kwargs)
print(f"{func.__name__} returned: {result}")
print()
return result
return wrapper
from django.db import models
class BaseModel(models.Model):
created_at = models.DateTimeField(
auto_now_add=True,
verbose_name="created_at",
help_text="Date et heure de création",
)
updated_at = models.DateTimeField(
auto_now=True,
verbose_name="updated_at",
help_text="Date et heure de la dernière modification",
)
is_being_deleted = models.BooleanField(
default=False,
verbose_name="is_being_dele
from dataclasses import dataclass
# dataclass is a shortcut to avoid writing __init__ __repr__ __eq__ and __hash__ methods
@dataclass
class Product:
name: str
price: float
quantity: int = 0
def total_cost(self) -> float:
return self.price * self.quantity
# Usage
p1 = Product(name="Laptop", price=1000.0, quantity=3)
p2 = Product(name="Laptop", price=1000.0, quantity=3)
p3 = Product(name="Smartphone", price=500.0, quantity=2)
print(p1) # Product(name="Laptop", price=1000.0, quan
# It transforms the 1st implicit parameter to be the name or instance of the class not the individual object
class Person:
species = "Homo sapiens"
@classmethod
def get_species(cls):
return cls.species
# Usage
print(Person.get_species()) # Homo sapiens
# staticmethod is used to denote a method inside of a class as static
# ie method belongs to the class, not to the instance of a class
class Math:
@staticmethod
def add(x, y):
return x + y
@staticmethod
def multiply(x, y):
return x * y
# Usage
print(Math.add(5, 7)) # 12
print(Math.multiply(3, 4)) # 12
class Circle:
def __init__(self, radius):
self._radius = radius
@property
def radius(self):
"""Get the radius of the circle"""
print("called me")
return self._radius
@radius.setter
def radius(self, value):
"""Set the radius of the circle. Must be positive."""
if value >=0:
self._radius = value
else:
raise ValueError("Radius must be positive")
@radius.deleter
def radius(self):
print("deleted")
del self._radius
# Usage
c
import atexit
import sqlite3
cxn = sqlite3.connect("db.sqlite3")
def init_db():
cxn.execute("CREATE TABLE IF NOT EXISTS memes (id INTEGER PRIMARY KEY, meme TEXT)")
print("Database initialised!")
@atexit.register
def exit_handler():
cxn.commit()
cxn.close()
print("Closed database!")
if __name__ == "__main__":
init_db()
1 / 0
...
import atexit
@atexit.register
def exit_handler() -> None:
print("We're exiting now!")
def main() -> None:
for i in range(10):
print(2**i)
if __name__ == "__main__":
main()
atexit.unregister(exit_handler)
1 / 0