Italian Chiacchiericci

Star-Dust

Expert
Licensed User
Longtime User
Funzioni/metodi della stringa

MethodDescription
capitalize()Converts the first character to upper case
casefold()Converts string into lower case
center()Returns a centered string
count()Returns the number of times a specified value occurs in a string
encode()Returns an encoded version of the string
endswith()Returns true if the string ends with the specified value
expandtabs()Sets the tab size of the string
find()Searches the string for a specified value and returns the position of where it was found
format()Formats specified values in a string
format_map()Formats specified values in a string
index()Searches the string for a specified value and returns the position of where it was found
isalnum()Returns True if all characters in the string are alphanumeric
isalpha()Returns True if all characters in the string are in the alphabet
isascii()Returns True if all characters in the string are ascii characters
isdecimal()Returns True if all characters in the string are decimals
isdigit()Returns True if all characters in the string are digits
isidentifier()Returns True if the string is an identifier
islower()Returns True if all characters in the string are lower case
isnumeric()Returns True if all characters in the string are numeric
isprintable()Returns True if all characters in the string are printable
isspace()Returns True if all characters in the string are whitespaces
istitle()Returns True if the string follows the rules of a title
isupper()Returns True if all characters in the string are upper case
join()Converts the elements of an iterable into a string
ljust()Returns a left justified version of the string
lower()Converts a string into lower case
lstrip()Returns a left trim version of the string
maketrans()Returns a translation table to be used in translations
partition()Returns a tuple where the string is parted into three parts
replace()Returns a string where a specified value is replaced with a specified value
rfind()Searches the string for a specified value and returns the last position of where it was found
rindex()Searches the string for a specified value and returns the last position of where it was found
rjust()Returns a right justified version of the string
rpartition()Returns a tuple where the string is parted into three parts
rsplit()Splits the string at the specified separator, and returns a list
rstrip()Returns a right trim version of the string
split()Splits the string at the specified separator, and returns a list
splitlines()Splits the string at line breaks and returns a list
startswith()Returns true if the string starts with the specified value
strip()Returns a trimmed version of the string
swapcase()Swaps cases, lower case becomes upper case and vice versa
title()Converts the first character of each word to upper case
translate()Returns a translated string
upper()Converts a string into upper case
zfill()Fills the string with a specified number of 0 values at the beginning


La cosa più interessante per me
s = 'Python'
s[0] # elemento in posizione 0 (il primo) 'P'
s[5] # elemento in posizione 5 (il sesto) 'n'
s[-1] # elemento in posizione -1 (l'ultimo) 'n'
s[-4] # elemento in posizione -4 (il quartultimo) 't'
Substring
s[0:2] # sottostringa con elementi da 0 (incluso) a 2 (escluso) 'Py'
s[:2] # dall'inizio all'elemento con indice 2 (escluso) 'Py'
s[3:5] # dall'elemento con indice 3 (incluso) a 5 (escluso) 'ho'
s[4:] # dall'elemento con indice 4 (incluso) alla fine 'on'
s[-2:] # dall'elemento con indice -2 (incluso) alla fine 'on'
Operazioni
'Py' + 'thon' = 'Python'
'Py' * 2 = 'PyPy'
'Ba' + 'na' * 2 = 'Banana'
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Quello che tu hai trovato interessante a me non piace proprio.

Il motivo è semplice: pur di rendere tutto estremamente sintetico, hanno reso le cose illeggibili, criptiche.

Vuoi mettere un bel SubString rispetto a quella robaccia? Questa la capisce al volo anche chi nemmeno conosca il linguaggio.
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Meglio che non capiscano cosa scrivo, così devono per forza chiamare me per gli aggiornamenti.
Comunque il substring con i valori negativi è il massimo
 

LucaMs

Expert
Licensed User
Longtime User
Meglio che non capiscano cosa scrivo, così devono per forza chiamare me per gli aggiornamenti.
Già, peccato che nemmeno tu ci capirai un tubero fritto, perché non ricorderai cose così astruse, che sicuramente ci saranno anche nel resto del linguaggio.
Inoltre, scovare un bug in un sorgente fatto in quel modo, sarà un'impresa (mentre fare errori sarà molto facile).
 

Star-Dust

Expert
Licensed User
Longtime User
Già, peccato che nemmeno tu ci capirai un tubero fritto, perché non ricorderai cose così astruse, che sicuramente ci saranno anche nel resto del linguaggio.
Inoltre, scovare un bug in un sorgente fatto in quel modo, sarà un'impresa (mentre fare errori sarà molto facile).
Penso sia individuale la cosa, a me sembra semplice e ci riesco bene a leggere perchè rispecchia proprio come lo fare io.
Sicuramente non sarà cosi per tutti, ma per me è abbastanza semplice e logico.
 

LucaMs

Expert
Licensed User
Longtime User
Penso sia individuale la cosa, a me sembra semplice e ci riesco bene a leggere perchè rispecchia proprio come lo fare io.
Sicuramente non sarà cosi per tutti, ma per me è abbastanza semplice e logico.
Direi di no, che non sia soggettivo ma oggettivo.

Oh, mi sono messo "5 minuti" ad analizzare una cosetta e... vedo (dall'orario del tuo post) che ne sono passati 25; come dire: "Mannag - per non scrivere altro - come vola il tempo!.
 

LucaMs

Expert
Licensed User
Longtime User
Direi di no, che non sia soggettivo ma oggettivo.
E' un po' come dire in televisione:

"Il PNRR..."

anziché:

"Il Piano Nazionale di Ripresa e Resilenza..."

ovvero usare degli acronimi, dando per scontato che tutti li conoscano tutti. E' vero che uno potrebbe non sapere nemmeno il significato della frase per esteso, o meglio a che cosa si riferisca, e anche dubitare che esista (!), visto che noi stupidi cittadini non abbiamo diritto di esserne informati dettagliatamente, ma certamente è parecchio più leggibile e "comprensibile".
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Direi di no, che non sia soggettivo ma oggettivo.

Oh, mi sono messo "5 minuti" ad analizzare una cosetta e... vedo (dall'orario del tuo post) che ne sono passati 25; come dire: "Mannag - per non scrivere altro - come vola il tempo!.
E' il tuo punto di vista, ma non puoi considerare oggettivo un punto di vista solo perchè è il tuo modo di vedere. Senza considerare che il Python è uno dei linguaggi di sviluppo più usati e ricercati.

Comunque non voglio prolungare questa conversazione, che mi sembra già completa.
 

LucaMs

Expert
Licensed User
Longtime User
E' il tuo punto di vista, ma non puoi considerare oggettivo un punto di vista solo perchè è il tuo modo di vedere
In alcuni casi si può e questo è uno di quelli.

Io non dubito assolutamente che tu, guardando quel codice, ADESSO lo capisca al volo ma è oggettivo che SubString, visto che tutti parliamo e leggiamo parole, sia molto più semplice ed esplicativo.


Senza considerare che il Python è uno dei linguaggi di sviluppo più usati e ricercati.
Direi che il motivo non sia assolutamente la cripticità di quel tipo di istruzioni; saranno ben altri motivi, questo può solo essere considerato un difetto.

Senza contare che il cibo più mangiato nel mondo è... la merda, visto che è apprezzata da miliardi di esseri viventi: le mosche!
 

amorosik

Expert
Licensed User
Già, peccato che nemmeno tu ci capirai un tubero fritto, perché non ricorderai cose così astruse, che sicuramente ci saranno anche nel resto del linguaggio.
Inoltre, scovare un bug in un sorgente fatto in quel modo, sarà un'impresa (mentre fare errori sarà molto facile).

Voto per il tubero fritto
Pure ammia sembra inutilmente troooppo sintetico
 

LucaMs

Expert
Licensed User
Longtime User
E' il tuo punto di vista, ma non puoi considerare oggettivo un punto di vista solo perchè è il tuo modo di vedere.
E' vero che ognuno ha i propri punti di vista, ma è anche vero che ci siano casi in cui le cose siano oggettive e ben poco soggettive.

Ad esempio (e mi sembra calzante, in questo caso): dare capocciate ad un muro. E' oggettivo che sia doloroso; se poi, in casi particolari, sei anestetizzato o masochista e ti piaccia, sono eccezioni 😄
 

Elric

Well-Known Member
Licensed User
Ho visto Don't look up. Mi è piaciuto davvero molto, nonostante il senso di amarezza.
 

Star-Dust

Expert
Licensed User
Longtime User
Top