#centos django
Explore tagged Tumblr posts
richardmurrayhumblr · 5 months ago
Text
Tumblr media
The 35th edition of the 2024 Richard Murray Newsletter.
topics
The sixty-seventh of the Cento series. A cento is a poem made by an author from the lines of another author's work. In the series I place my cento and a link to the other authors poem.
Womens History Month 2024
Human Spice Potion tutorial
The Spirit Coop
Introduction to The Sermon On The Hand and the Cordatitudes
Le Gateau Marche Avec Musique Et Entremets
Dates- astrology , astronomy , priceisright , regionalism
IF YOU MADE IT THIS FAR : Halle Berry and the evil in a thespians life , Django unchained , KWL marketing with melissa storm , Dodes'ka-den , Psycho Bliss from mystic-skillz , Skeleton Fight - from Ray HArryhausen , Tonfa Girl Game Prototype from Dualmask
URL https://rmnewsletter.over-blog.com/2023/11/09/01/2024-rmnewsletter.html
#rmnewsletter
2 notes · View notes
devops-jobs · 3 years ago
Photo
Tumblr media
HIRING: Senior Site Reliability Engineer / London, England, United Kingdom
0 notes
youviralart · 3 years ago
Link
Tumblr media
2 notes · View notes
faccioliste · 4 years ago
Text
12 Etudes, Op.10: No.2 in A minor – Frédéric Chopin, Andrei Yeh
12 Etudes, Op.10: No.4 in C sharp minor – Frédéric Chopin, Andrei Yeh 
1977 – Ana Tijoux
24 mila baci – Adriano Celentano 
33 “GOD” – Bon Iver
3 Nouvelles Etudes, B.130: 2. Allegretto in A flat major – Frédéric Chopin, Andrei Yeh 
3WW – Alt-J 
3WW – OTG Version, Alt-J
44 gatti 
505 – Arctic Monkeys 
50 Special – Lùnapop
 715 - CR∑∑KS – Bon Iver 
A Cruel Angel’s Thesis – Neon Genesis Evangelion
A Fifth of Beethoven – Walter Murphy
A mano a mano – Rino Gaetano
A me me piace ‘a nutella – Il piccolo Lucio
A new error – Moderat 
A NINGÚN HOMBRE (Cap.11: Poder) – ROSALÍA
Acida – Prozac+
Acqua (Malpensandoti) – Tedua
Addams Family Theme
Addio a Napoli / Ma come fanno i marinai – Dalla, De Gregori
Address Unknown – The Ink Spots
After Hours – The Velvet Underground
Aggiungi un posto a tavola – Johnny Dorelli
Ai ai ai – Los locos 
Ain’t Got No – Nina Simone
Al ballo mascherato – Fabrizio De André
Alexander Platz – Franco Battiato
Alla consolle – Mimmo Amerelli
All Alone – Gorillaz
All Day and All of the Night – The Kinks
All In – Nitro
All I want is you – Barry Louis Polisar
All of me – John Legend
All tomorrow’s parties – The Velvet Underground
Alter Ego – Tame Impala
American Boy – Estelle, Kanye West
American Pie – Don McLean
American Woman – Lenny Kravitz
Amigas Cheetahs – The Ceetah Girls
Amor, amor de mia amores – Natalie Lagourcade
Amore che vieni, amore che vai – Fabrizio De André
Amore disperato – Nada
Anche per te – Lucio Battisti
Andavo a cento all’ora – Gianni Morandi
Anemos - Introduzione – Murubutu
Another brick in the wall – Pink Floyd
Antidoping – Gemitaiz, MadMan, Ensi
APPARTENGO - Il sangue – Marracash, Massimo Pericolo
Applausi per Fibra – Fabri Fibra
Arabella – Arctic Monkeys
Are you gonna be my girl – Jet
Argenti Vive – Caparezza
Arrivederci Tristezza – Brunori Sas
Ask - The Smiths
Autoipnotica – Caparezza
Avrai ragione tu (ritratto) – Caparezza
Azzurro – Adriano Celentano
Ba-ba-baciami piccina – Quartetto Cedra
Babalù – Mannarino
Baby – Justin Bieber
Baby Boy – Beyoncé
…Baby One More Time – Britney Spears
Baby’s on Fire – Die Antwoord
Baciala – La Sirenetta
Baciami ancora – Jovanotti
Back In Black – AC/DC
Back On The Scene – Slaughterhouse
Badabum Cha Cha – Jim Croce
bad guy – Billie Eilish
Bad Mouth – Fugazi
BAGDAD - Cap.7: Liturgia – ROSALÍA
Balla – Umberto Rosario Balsamo
Ballata degli impiccati – Fabrizio De André
Bam bam – Sister Nancy
BamBam – Matador
Banana Brain – Die Antwoord
Bandiera Bianca – Franco Battiato
Bandiera Gialla – Gianni Pettenati
Bandiera Rossa – ✊
Bang bang (My baby shot me down) – Nancy Sinatra
Barbera e Champagne – Giorgio Gaber
Beachwood Park – The Zombies
Bella ciao – ✊
Bella vera – 883
Be my baby – The Ronettes
Ben 10 – Sigla
Benzi box – DANGERDOOM
Berghem béla sità
The best of both worlds – Hannah Montana
Bibbidi bobbidi bu
Bigger Than Prince – Green Velvet
The Black Angel’s Death song – The Velvet Underground, Nico
Blackbird – The Beatles
Blank Space – Taylor Swift
Blowin’ in the wind – Bob Dylan
Blue Monday – New Order
Blue Suede Shoes – Elvis Presley
Blush Beat – Club Domani
Bocca di rosa – Fabrizio De André
BODY PARTS - I denti – Marracash
Boom boom boom boom – Vegaboys
Boom Boom Pow – Black Eyed Peas
Branca Day – Derozer
BRAVI A CADERE - I polmoni – Marracash
Brazil – Django Reinhardt
Breakthru – Queen
Briciole – Calcutta
Brother Sparrow – Agnes Obel
Bull in the heather – Sonic Youth
Buonanotte Fiorellino – Francesco De Gregori
Buona sera (Signorina) – Fred Buscaglione
By Night – Sophie Hutchings
B.Y.O.B. – System Of A Down
By starlight – The Smashing Pumpkins
By This River – Brian Eno
Cacao Meraviglio – Renzo Arbore, Paola Cortellesi, Nino Frassica
California King Bed – Rihanna
Camcamini spazzacamin
Canapa – Punkreas
Cannabis – Ska-P
Cannibal Bling Bling – 10LEC6
Can’t Hold Us – Macklemore
Can’t Stop – Red Hot Chili Peppers
Canzone – Lucio Dalla
Canzone all’entrata – Caparezza
Canzone all’uscita – Caparezza
Canzone a metà – Caparezza
Canzone Del Maggio – Fabrizio De André
Canzone intelligente – Cochi E Renato
Canzone per te – Sergio Endrigo
Carabinieri – Sigla 
Caramba beviamo del whisky 
Carlo Martello Ritorna Dalla Battaglia Di Poitiers – Fabrizio De André
Caso umano – Ministri
Cattolica – Pop X
Centro di gravità permanente – Franco Battiato
C’est la vie (you never can tell) – Pulp no pulp
Che coss’è l’amor – Vinicio Capossela
Che Fico! – Pippo Franco
Che Idea! – Flaminio Maphia
Chi C’è – Fabri Fibra
China Town – Caparezza
Chi Se Ne Frega Della Musica – Caparezza
Chissà Dove Sei – Francesco De Gregori
Chop Suey! – System of a Down
Chum – Earl Sweatshirt
Chunky – Flatbush Zombies
Ci Penso Dopo – Fabri Fibra
Cirano – Francesco Guccini 
Clandestino – Manu Chao
Clint Eastwood – Gorillaz
Coda di Lupo – Fabrizio De André
Come porti i capelli bella bionda – I Girasoli
Comfortably Numb – Pink Floyd
Complicated – Avril Lavigne
Comprami – Viola Valentino
Compro Horror – Caparezza
Comunque Dada – Caparezza
Concerning Hobbits – The Lord of the Rings
Conga! 
Cooler Couleur – Crookers
Cose che non capisco – Caparezza
Country Roads
Crabs in a Bucket – Vince Staples
Crazy in Love – Beyoncé
Crooked Cops – Rejjie Snow
CRUDELIA - I nervi – Marracash
Cuccurucucù – Franco Battiato
Cuore Matto – Little Tony
Cuore Nero – Blind
DA BUTTARE - Il ca**o – Marracash
Da Feeling – Nightmares On Wax 
Dafne sa contare – Murubutu
Dance Monkey – Tones and I
Dancing Queen – ABBA
Dancing With Myself – Billy Idol
Dangerous – Kid Enigma
DE AQUÍ NO SALES (Cap.4: Disputa) – ROSALÍA
Death on Two Legs (Dedicated to...) – Queen
Death USB – Salmo
Dedicato a te – Le Vibrazioni
Del Verde – Calcutta
Desire Be Desire Go – Tame Impala
Detto, Fatto. – Gemitaiz & MadMan
DIANA – M¥SS KETA
Dieci ragazze – Lucio Battisti
Diet Mountain Dew – Lana Del Rey
Die Walkure - Ride of the Valkyries – Royal Philharmonic Orchestra
DI MI NOMBRE (Cap.8: Éxtasis) – ROSALÍA
Disorder – Joy Division
Dispari – Marta Sui Tubi
Disperato Erotico Stomp – Lucio Dalla
Dog in the Mirror – Guerilla Toss
Do I Wanna Know? - Arctic Monkeys
Domani – Ernia 
Domani – Articolo 31
Domani smetto – Articolo 31
Don Chisciotte – Francesco Guccini
Don Raffaè – Fabrizio De André
Don’t Cha – The Pussycat Dolls
Don't Give Up – Mystery Jets
Don’t Let Me Be Misunderstood – The Animals
Don’t Pass Me By – The Beatles
Don’t Sit Down ’Cause I’ve Moved Your Chair – Arctic Monkeys
Don’t Stop Me – BowLand
DON’T WANNA SPIN – GFOTY
Do the astral plane – Flying Lotus
Dove sta zazà – Gabriella Ferri 
Dove vola l’avvoltoio – Pietro Buttarelli
Downer – Nirvana 
Dream – Hiroshi Noshimura
Dream a Little Dream of Me – Ella Fitzgerald & Louis Armstrong
Drogata schifosa – Pop X
Due su due – Articolo 31
Ed ero contentissimo – Tiziano Ferro
E la luna bussò – Loredana Bertè 
E la vita, la vita – Cochi e Renato
Eleanor Rigby – The Beatles
El pueblo unido – ✊
El Tango De Roxanne – José Feliciano
Endors Toi – Tame Impala
Eroe (Storia di Luigi Delle Bicocche) – Caparezza
Estate – Negramaro 
È tardi – Caparezza
E ti vengo a cercare – Franco Battiato
Everybody Needs Somebody to Love – The Blues Brothers
Everytime We Touch – Cascada
Facciamo un pupazzo insieme? – Frozen 
Fai da tela – Caparezza
Fall In Love – Yuno
Family Affair – Mary J. Blige
Fango – Jovanotti 
Farò di te un uomo – Mulan
Fatty Boom Boom – Die Antwoord
Feel Good Inc. – Gorillaz
Feeling Good – Nina Simone
Femme Fatale – The Velvet Underground
Fenomeno – Fabri Fibra
Figli d’arte – Caparezza
Figli Di Pitagora – Eiffel 65
Figli di puttana – Pop X
Fireside – Arctic Monkeys
Five to one – The Doors 
Fleas to beas – 10LEC6
Forever Jung – Caparezza
Franziska – Fabrizio De André
Freak Like Me – DJ Deeon
Frosinone – Calcutta
Funkytown – Lipps Inc.
Funnel of Love – Wanda Jackson 
Fuori dal tunnel – Caparezza
Gaetano – Calcutta
Game of Thrones – Sigla
Gasolina – Daddy Yankee
Gente che spera – Articolo 31 
Ghetto Kraviz – Nina Kraviz
Gianna – Rino Gaetano
Gigugin – Articolo 31
Giotto Beat – Caparezza
GIOVANNA HARDCORE – MYSS KETA
Girlfriend – Avril Lavigne
Girls Just Want to Have Fun – Cyndi Lauper
Giudizi universali – Samuele Bersani
Gli insetti del podere – Caparezza
Gli uccelli – Franco Battiato
G.O.A.T. - Il cuore – Marracash
GO AWAY! – CocoRosie
Goodbye Malinconia – Caparezza
Good Golly Miss Molly – Little Richard
Goodnight Moon – Shivaree
Gotta Go My Own Way – High School Musical Cast
Grande figlio di puttana – Stadio
Grau grau grau - da “io sto con gli ippopotami” – Bud Spencer
Grease – The Four Seasons
Greased Lightnin’ – John Travolta
GRETA THUNBERG - Lo stomaco – Marracash
Hallelujah – Leonard Cohen
Happiness is a Warm Gun – The Beatles
Happy Days – Ghali
Happy Days (Theme from Happy Days) – Pratt & McClain
Happy Hour – Felix da Housecat
Harder, Better, Faster, Stronger – Daft Punk
Harry Potter in 99 Seconds – Jon Cozart
Have You Ever Had... (Skit) – Salmo
Heart and Soul – Joy Division
Heartbreak Hotel – Elvis Presley
Hello, I Love You – The Doors
Hey Bulldog – The Beatles
Hit Me with Your Best Shot – Pat Benatar
Hit the Road Jack – Ray Charles
Hive – Earl Sweatshirt
Ho capito che ti amo – Luigi Tenco
Hoedown Throwdown – Miley Cyrus
Hollaback Girl – Gwen Stefani
home with you – FKA twigs
hope is a dangerous thing for a woman like me to have - but i have it – Lana Del Rey
Hotel Supramonte – Fabrizio De André
House Credibility – Caparezza
Ho visto un re – Enzo Jannacci
How Far – Tei Shi
HUMBLE. – Kendrick Lamar
HUMUHUMUNUKUNUKUAPUA’A – High School Musical Cast
Hypnotize – The Notorious B.I.G.
I Am Woman – Helen Reddy
I Bet You Look Good on the Dancefloor – Arctic Monkeys
(I Can’t Get No) Satisfaction – The Rolling Stones
I Cento Passi – Modena City Ramblers
I colori del vento – Pocahontas 
I consigli di un pirla – Articolo 31
Ieri era zero – Hercules 
I Fink U Freeky – Die Antwoord
I Follow Rivers – Lykke Li
If She Really Is Your Light – Pavlove
I Know It’s Over – The Smiths
Il ballo del qua qua – Romina Power 
Il ballo di San Vito – Vinicio Capossela
Il bar della rabbia – Mannarino
Il Bel Canto – Ministri
Il Bombarolo – Fabrizio De André
Il Cielo In Una Stanza – Gino Paoli
Il Dito Medio Di Galileo – Caparezza
Il Funkytarro – Articolo 31
Il Gatto E La Volpe – Edoardo Bennato
Il gigante e la bambina – Lucio Dalla 
Il gorilla – Fabrizio De André
I’ll Be Your Mirror – The Velvet Underground
I’ll Come Running – Brian Eno
Il Mondo – Jimmy Fontana
Il Pescatore – Fabrizio De André
Il posto più freddo – I Cani
Il Principe Ali – Aladdin
Il regalo più grande – Tiziano Ferro
Il senso dell’odio – Salmo
Il suonatore Jones – Fabrizio De André
Il tempo di morire – Lucio Battisti
Il testamento – Fabrizio De André
Il testamento di Tito – Fabrizio De André
Il testo che avrei voluto scrivere – Caparezza
Il Vitello Dai Piedi Di Balsa – Elio e le Storie Tese
I’m a Believer – Smash Mouth
I marinai tornano tardi – Murubutu
Impara il longobardo con Alessandro Barbero 
I’m so tired – The Beatles
In caduta libera – Folkstone
In Cold Blood​​ – alt-J
Incontro – Francesco Guccini
In Italia – Fabri Fibra
Innuendo – Queen
Insieme a te non ci sto più – Caterina Caselli
In the Aeroplane Over the Sea – Neutral Milk Hotel
Introduzione – Fabrizio De André
In Un Giorno Di Pioggia – Modena City Ramblers
Inverno – Fabrizio De André
Io centro con i missili –  Pop X
Io credo in me – Naruto 
Io ho in mente te – Equipe 84
Io non mi sento italiano – Giorgio Gaber
Io sono fatto di neve – Ministri
Io sono qui – Salmo
Irene – Pinguini Tattici Nucleari
Iris – The Goo Goo Dolls
Isla Magica – Maria Usbeck
Isobarre – Murubutu
I sogni son desideri 
Isola verde – Murubutu
Italove – EMMANUELLE
It Is Not Meant To Be – Tame Impala
It’s not too late – 10LEC6
I’ve got a woman – Ray Charles
(I’ve Had) The Time of My Life – Bill Medley
I vitelloni – Bobo Rondelli
I wanna be your lover – La Bionda 
I wanna be yours – Arctic Monkeys 
I want you back – The Jackson 5 
I will survive – Gloria Gaynor 
Jazz suite no.2: 6 waltz II – Dmitri Shostakovich
Jigsaw Feeling – Siouxsie and the Banshees
Johnny B. Goode – Chuck Berry
Just Dropped In (To See What Condition My Condition Was In) – Kenny Rogers
Just the way you are – Bruno Mars 
Kalasnjkov – Goran Bregović, Slobodan Salijevic
Keep yourself alive – Queen
Kentucky – Il Bepi & The Prismas
Kevin Spacey – Caparezza
Killer Queen – Queen
King’s Supreme – Machete Crew
Kitaro – Caparezza
Kurt Cobain – Brunori Sas
La Ballata Dell’amore Cieco (O Della Vanità) – Fabrizio De André
La Ballata dell’eroe – Fabrizio De André
La Ballata del Miché – Fabrizio De André
La bambola – Patty Pravo
La bella la và al fosso – I Girasoli
La Bomba In Testa – Fabrizio De André
La Caduta di Atlante – Caparezza
La Canzone del Padre – Fabrizio De André
La Canzone di Barbara – Fabrizio De André
La Canzone di Marinella – Fabrizio De André
La cesarina – I Girasoli
La città vecchia – Fabrizio De André
La collina dei pioppi – Murubutu
La cosa – Cochi e Renato
Lacrime – Ghali
La cura – Franco Battiato
La danza delle streghe – Gabry Ponte 
Ladies and Gentlemen We Are Floating in Space – Spiritualized
La donna cannone – Francesco De Gregori
Lady Marmalade – Moulin Rouge
La famiglia dei becchini – Musica Per Bambini 
La fine di Gaia – Caparezza
La Ghigliottina – Caparezza
La grande onda – Piotta
La guerra di Piero – Fabrizio De André
La Isla Bonita – Madonna
La La Land – Green Velvet
Lala Song – Bob Sinclar
La libertà – Giorgio Gaber
La lontananza – Domenico Modugno
La mamma di Rosina – I Girasoli
La Marchetta di Popolino – Caparezza
La mazurka di periferia – Raoul Casadei
La mia parte intollerante – Caparezza
La mia ragazza mena – Articolo 31
L’animale – Franco Battiato
La notte – Arisa
La parata degli elefanti rosa – Quartetto Cetra
L’appuntamento – Calibro 35
La prima rondine venne ier sera – Pop x
La prima volta  – Motta
La prima volta – Salmo
La regola dell’amico – 883
La rivoluzione del sessintutto – Caparezza
L’armata perduta di Re Cambise – Murubutu
Larsen – Caparezza
Las Divinas – Patito Feo
La società dei magnaccioni – Lando Fiorini
La spesa – Marta Sui Tubi
La stagione del tuo amore – Fabrizio De André
La Strada – Modena City Ramblers 
La Tartaruga – Bruno Lauzi
Laughing On The Outside – Bernadette Carroll
La Valse à Mille Temps – Jacques Brel
La vie en rose – Édith Piaf
La vie en rose – Louis Armstrong
L’avvelenata – Francesco Guccini
Layla – Eric Clapton
Le barche – Calcutta
Le coppie – I Cani
Legalize The Premier – Caparezza
L’emozione non ha voce – Adriano Celentano
Le ragazze di porta venezia – Myss Keta
Less Than – Nine Inch Nails
Le tasche piene di sassi – Jovanotti
Let Me Blow Ya Mind – Eve
Let’s Get Crazy – Hannah Montana
Let’s Twist Again – Chubby Checker
Levante – Murubutu
Lexotan – I Cani
L. Fast & D. Young – Salmo
L’Idraulico Aulico – MusicaPerBambini
Life on Mars? – David Bowie
L’immensità – Don Backy
Limonata – Calcutta 
L’infinto – Caparezza
L’inno del corpo sciolto – Roberto Benigni 
L’isola Che Non C’è – Edoardo Bennato
L’italiano medio – Articolo 31
Little Green Bag – George Baker Selection
Little Lover – AC/DC
Livin’ la Vida Loca – Ricky Martin
Lonely Boy – The Black Keys
Lonely Day – System of a Down
Long Tall Sally – Little Richard
Lontano dagli occhi – Sergio Endrigo
Lontano, lontano – Luigi Tenco
Look at Me, I’m Sandra Dee – Stockard Channing
Looking at You – MC5
Loose Lips – Kimya Dawson
Loser – Beck
Los Ojos Del Diablo – El Raton 
Lo stretto indispensabile – Il libro della giungla 
Love Buzz – Shocking Blue
Love Is a Laserquest – Arctic Monkeys
Love Me – Justin Bieber
Love sex american express – Cristian Marchi
Love Stink – LoboLoto
Love Story – Taylor Swift
Lucifer Sam – Pink Floyd
Lucille – Little Richard
L’ultima festa – Cosmo
L’ultima speranza – Hercules
L’uomo che premette – Caparezza
L’uomo tigre 
L’uva fogarina – I Girasoli 
Ma che freddo fa – Nada
Madame Hollywood – Felix da Housecat
MADAME - L’anima – Marracash
Maddalena e Madonna – Brunori Sas
Madonnina dai riccioli d’oro – I Girasoli
Mad Sounds – Arctic Monkeys
Magazine – Dark Polo Gang
Ma il cielo è sempre più blu – Rino Gaetano
MALAMENTE (Cap.1: Augurio) – ROSALÍA
MALDICIÓN (Cap.10: Cordura) – ROSALÍA
Maledetti scarafaggi 
Mambo Italiano – Renato Carosone
Mamma Roma, Addio – Cranio Randagio
Mara e il maestrale – Murubutu
Marco gioca sott’acqua – Murubutu
Marks – Nicolas Jaar
Marry You – Bruno Mars
MARYLEAN – Machete
Marylou – Mannarino
mary magdalene – FKA twigs
Mas Que Nada – Sergio Mendes
Materazzi ha fatto gol – Matrixgol
Matilda – ​​alt-J
Men In Black – Will Smith
Mentre tutto scorre – Negramaro
Merchandise – Fugazi
Me So’ Mbriacato – Mannarino
Messa in moto – Caparezza
Meteorological – Guerilla Toss
Mica Van Gogh – Caparezza
Migliora La Tua Memoria Con Un Click – Caparezza
Milano – Calcutta
MILANO SUSHI & COCA – M¥SS KETA
Milkshake – Kelis
Mi mujer – Nicolas Jaar
Minor Swing – Django Reinhardt & le Hot Club de France
Minuetto – Mia Martini
Mio fratello è figlio unico – Rino Gaetano
Mi parli di te – Motta
Mi sei scoppiato dentro al cuore – Mina
Mi sento una betulla in piena estate insieme a te – Cecco e Cipo
Misirlou – Surf Boys 
Mi sono innamorato di te – Luigi Tenco
Moanin’ – Charles Mingus
Moby Dick – Led Zeppelin
Mon oncle – Frank Barcellini
Moondance – Van Morrison
Morte in diretta – Salmo
Mouth trap! – 10LEC5
Mr. Simpatia – Fabri Fibra
My Generation – The Who
My Rollercoaster – Kimya Dawson
NANA (Cap.9: Concepción) – ROSALÍA
Nandemonaiya – RADWIMPS
Narcoleptic Verses Pt. 1 – Salmo
Negative Youth – Salmo
Nel blu dipinto di blu – Domenico Modugno
Nella Mia Ora Di Libertà – Fabrizio De André
Nella pancia dello squalo – Salmo
Nessuno – Brunori Sas
Nessun rimpianto – 883
Niente da capire – Francesco De Gregori 
Niente di strano – Giorgio Poi 
No. 1 Party Anthem – Arctic Monkeys
No Big Bang – Priests
No Fear – Fabrizio Maurizi 
Noi bambine non abbiamo scelta – Baustelle
Non farti cadere le braccia – Edoardo Bennato
Non me lo posso permettere – Caparezza
Non me lo so spiegare – Tiziano Ferro
Non potrei mai – Fast Animals and Slow Kids
Non siete stato voi – Caparezza 
NON SONO MARRA - La pelle – Marracash
No Stress – Laurent Wolf
No Surprises – Radiohead
No Tengo Dinero – Righeira
Noter de Berghem – I cör alegher 
Notte prima degli esami – Antonello Venditti 
No Woman, No Cry – Bob Marley & The Wailers
Ob-La-Di, Ob-La-Da – The Beatles
Oh, pretty woman – Roy Orbison
Oltre il ponte – Modena City Ramblers
Oltre l’orizzonte – Oceania 
One More Time – Daft Punk 
One O Six – Jupiter 
One way or another – Blondie 
On Melancholy hill – Gorillaz
On the floor  Jennifer Lopez
Oops! I did it again – Britney Spears 
Orgasmo – Calcutta
Oroscopo – Calcutta
OSCENO – Lilly Meraviglia 
Our song – Taylof Swift 
Paint it, Black – The Rolling Stones
Pale Blue Eyes – The Velvet Underground 
Pantalica – Colapesce 
Papa was a Rolling Stones – The Temptations
Paper Bag Acid – Jerome Hill 
Paradise – Phoebe Cates
Paranoia mia – Ernia 
Parole parola – Mina 
Party in the U.S.A – Miley Cyrus 
Peace Lovin Man – John Lee Hooker
Peaches en regalia – Frank Zappa
Penny Lane – The Beatles 
Pepper – Butthole Surfers 
Per amore e basta – Motta
Per dimenticare – Zero Assoluto 
Però mi vuol bene – Quartetto Cetra 
Per tutte le volte che – Valerio Scanu 
Peter Gunn – Henry Mancini
Piazza Grande – Lucio Dalla
Piccola Sbronza – Selton, Dente 
PIENSO EN TU MIRÁ (Cap.3: Celos) – ROSALÍA
Pifferaio magico – Articolo 31
Piledriver Waltz – Arctic Monkeys 
Piove – Domenico Modugno 
Pippi calzelunghe 
Pistorius – Gemitaiz, Madman 
Più bella cosa – Eros Ramazzotti 
Planet Caravan – Black Sabbath
Play – Betta Lemme 
Pleasentville – Nitro 
POCO DI BUONO - Il fegato – Marracash 
Poesia – Don Backy 
Poetessa maledetta – Club Domani, Stephanie Glitter 
Pokemon – Giorgio Vanni 
Pollon, pollon combina guai – Critina D’Avena 
Pop porno – Il Genio
Pornoromanzo – Brunori Sas
Posso farcela – Alex Baroni (Hercules)
Post Concerto – Coma_Cose 
Precipitevolissimevolmente – Dente, Il Genio 
Preghiera delle palle di neve – Musica Per Bambini
PRESO (Cap.6: Clausura) – ROSALÍA
Pretty fly (for a white guy) – The Offspring
Price Tag – Jessie J, B.o.
Prima di dormire – Salmo 
Prisencolinensinainciusol – Adriano Celentano 
Prisoner 709 – Caparezza 
Promised Land – Joe Smooth 
Prospettiva Nevsi – Franco Battiato
Psycho Killer – Talking Heads 
Pump up the jam – Technotronic, Felly 
QUALCOSA IN CUI CREDERE - Lo scheletro – Marracash
Quando quando quando – Tony Renis 
QUELLI CHE NON PENSANO - Il cervello – Marracash
Quello che siamo diventati – Motta 
QUE NO SALGA LA LUNA (Cap.2: Boda) – ROSALÍA
Questa è la mia festa – Maria Antonietta 
Questa è la realtà – Hercules 
Questo piccolo grande amore – Claudio Baglioni
Ragazza magica – Jovanotti 
Ragazze acidelle – Flaminio Maphia 
Ragazzo fortunato – Jovanotti 
Ramaya – Afric Simone
Rancho della luna – Salmo 
Rasputin – Boney M. 
Recitativo – 2 invocazioni 1 atto di accusa – Fabrizio de andré
Reginella campagnola – I Girasoli
Relax Your Body – D.F.X. 
RENIEGO - Cap.5: Lamento – ROSALÍA
Respect – Aretha Franklin 
Restiamo in casa – Colapesce 
Ricchi Dentro - Ghali
The Climb – Miley Cyrus
The Dark Side of the Mood – Nitro
The Flintstones – Sigla 
The Gravedigger’s Song – Mark Lanegan
The Heroic Weather - Conditions of the Universe, Part 1: A Veiled Mist – Alexandre Desplat
The Kids Aren’t Alright – The Offspring
The lazy song – Bruno Mars
The realness – RuPaul
8 notes · View notes
plebcoder · 4 years ago
Text
PLAN 2021
# COMPILERS
- Learn about C compiler
-- Makefile
-- Makefiles
- Compiling from source 
# VIRTUALIZATION 
- Libvirtd (linux vms) 
- Docker (containers)
# AAA Authentication 
- LDAP or alternative
# PROGRAMMING LANGUAGES
- Python (wtb django)
- PHP (Most dinousaur code bases use this fucking language so why not)
# DISTROS
- CENTOS: Should i continue with CENTOS now with the rolling release model rolling out?
- FEDORA
# NETWORKING
- DHCP
- PROXIES
- VPNs
- NFTables (firewall) 
- IPV4 subnettning
- IPV4 vlans 
- IPV6 
- Routing 
- wlan configurations 
# DEVOPS
- configuration management 
- Compilation, see #compilers 
- #networking 
- #virtualization
- git ( https://git.wiki.kernel.org/index.php/Main_Page )
idk most of devops feels like a meme to automate things that are done manually, like compiling from source can basically be done with jenkins or whatever. Ansible is just a ssh wrapper (lmao?). 
# BACKUPS
- database management 
- files
- nfs
- raid (https://raid.wiki.kernel.org/index.php/HowTo)
Programming Languages
- Python 
2 notes · View notes
about-urusy · 5 years ago
Text
Development skills
Lang
Java
Python
JavaScript
PL/SQL
Framework
Spring Boot
Struts
Seaser
Django
Vue.js
Database
Oracle DB
MySQL
OS
Windows(10, Server)
Linux(Redhat, CentOS)
UNIX(Solaris)
macOS
Middleware
Tomcat
Redis
Hazelcast
Other
Git, GitLab
Docker
JIRA, Redmine
34 notes · View notes
adalfa · 2 years ago
Link
0 notes
rollielectro · 2 years ago
Text
Sublime text tutorial
Tumblr media
SUBLIME TEXT TUTORIAL INSTALL
SUBLIME TEXT TUTORIAL CODE
Whether you're new to Sublime and feeling your way around or a Sublime Text expert. We’ll be skipping lightly over the coding parts and focusing on using SublimeGit, so it should be usable for any project using git. We will go through building the Django tutorial application, and managing it in git. Installing : sublime-text-3126-1. Here on my channel you'll find all manner of tips, tricks and tutorials for getting the most out of Sublime Text. This tutorial will take you through the usual stages of using SublimeGit for managing a project. Prerequisites Before you continue with this tutorial, we accept that you have an essential comprehension of use of different Text editors like Visual Studio code, P圜harm for Python and Integrated Development Environment (IDE) like NetBeans. You can do it by running the following command. After the fulfillment of this tutorial, you will have a top to bottom information of Sublime Text editor.
SUBLIME TEXT TUTORIAL INSTALL
Now is the time to install the Sublime Text Editor. One it is downloaded, add the required repo file for sublime text editor to your machine as follows. Let us begin by downloading the rpm of Sublime Editor by using the following command.
Compatible with many language grammars from TextMate.
Extensive customizability via JSON settings files, including project-specific and platform-specific settings.
Simultaneous editing: simultaneously make the same interactive changes to multiple selected areas.
SUBLIME TEXT TUTORIAL CODE
Brackets is an open source code editor which is best suited for Website Designers and Front-end Web Developers. Ich habe verwendet TernJS für Sublime für eine Weile und die Vorschläge, die ich bekomme, sind viel besser als die Standardvorschläge. This article is about Adobe Brackets Tutorial.
" Command palette" uses adaptive matching for quick keyboard invocation of arbitrary commands Wie bereits erwähnt, tern.js ist ein neues und vielversprechendes Projekt mit Plugins für Sublime Text, Vim und Emacs. Sublime text editor menyediakan banyak sekali fitur yang sangat berguna.
Goto Anything," quick navigation to files, symbols, or lines.
Though you might not have a text editor downloaded on your own computer, youve more or less used one. In this tutorial you will be briefed about the installation of Sublime Text Editor on CentOS 7. Text editors are programs developers write their code in. It supports many programming and markup languages and its functionality can be extended with the addition of surportive plugins, which are community-built and maintained under free-software licenses. Sublime Text is a cross-platform source code editor developed based on Python' s Application Programming Interface (API). To install Sublime Text Editor on CentOS 7
Tumblr media
0 notes
computingpostcom · 2 years ago
Text
Welcome to this guide on how to run Netbox IPAM Tool in Docker Containers. But before we dive into the nub of this matter, let’s first get to know what the Netbox IPAM tool is all about. Netbox is a free and open-source tool used to manage and document computer networks via the web. Netbox IPAM is written in Django. It helps ease the task of creating virtual implementations of devices in a data center which initially were being done on paper. The amazing features of Netbox IPAM include the following: Vlan Management VRF Management IPAM – IP Address Management DCIM – Data Center Infrastructure Management Circuit Provider Management Multi-Site (tenancy) Single Converged Database Rack Elevation Report Alert Connection Management – Interfaces/Console/Power Customization Header For Logo’s etc Running Netbox using Docker Containers is simple because, all the tedious task of installing dependencies such as Python, Django e.t.c is avoided. Getting Started. Before we begin on this guide, ensure that your system is up-to-date and the required packages installed. ## On Debian/Ubuntu sudo apt update && sudo apt upgrade sudo apt install curl vim git ## On RHEL/CentOS/RockyLinux 8 sudo yum -y update sudo yum -y install curl vim git ## On Fedora sudo dnf update sudo dnf -y install curl vim git 1. Install Docker and Docker-Compose on Linux This setup relies on Docker and docker-compose meeting the below requirements: Docker version 19.03 and above docker-compose version 1.28.0 and above Install the latest version of Docker CE on Linux with the aid of the guide below. How To Install Docker CE on Linux Systems Verify the installed version of Docker. $ docker -v Docker version 20.10.10, build b485636 Then add your system user to the docker group in order to execute docker commands without using the sudo command. sudo usermod -aG docker $USER newgrp docker Now proceed and install Docker-compose on Linux. Download the latest version of docker-compose as below. curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi - Make the file executable. chmod +x docker-compose-linux-x86_64 Move the file to your PATH. sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose Verify your installation by checking the docker-compose version. $ docker-compose version Docker Compose version v2.1.1 Now start and enable docker. sudo systemctl start docker && sudo systemctl enable docker 2. Provision the Netbox IPAM server All the components needed to build Netbox as a docker container are provided in the Github repository. Here, images are built and released to Docker Hub and Quay.io once a day. Now git clone the Netbox docker file as below. git clone -b release https://github.com/netbox-community/netbox-docker.git Navigate into the Netbox directory. cd netbox-docker Modify the docker-compose.yml from the docker-compose.override.yml.example file as below. tee docker-compose.override.yml 8080/tcp, :::8000->8080/tcp netbox-docker-netbox-1 d652988275e6 netboxcommunity/netbox:v3.0-1.4.1 "/sbin/tini -- /opt/…" 2 minutes ago Up 2 minutes netbox-docker-netbox-housekeeping-1 6ee0e21ecde0 netboxcommunity/netbox:v3.0-1.4.1 "/sbin/tini -- /opt/…" 2 minutes ago Up 2 minutes netbox-docker-netbox-worker-1 3ff7e0c6b174 redis:6-alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp netbox-docker-redis-cache-1 92e49f207764 redis:6-alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp netbox-docker-redis-1 77908ccce0ca postgres:13-alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 5432/tcp netbox-docker-postgres-1
If you have a firewall enabled, allow port 8000 as below. ##For Firewalld sudo firewall-cmd --zone=public --add-port=8000/tcp --permanent sudo firewall-cmd --reload ##For UFW sudo ufw allow 8000/tcp 3. Access the Netbox IPAM tool Web UI Everything is set, we can now proceed and access the Netbox IPAM web UI with the URL http://Hostname:8000 or http://IP_Address:8000. Log in to the page with the default credentials as Username: admin, Password: admin, and API Token: 0123456789abcdef0123456789abcdef01234567 On successful login, you will see this page. Now here, you can navigate using the panel on your left as shown. While on this panel, you can add the devices, connections, circuits, IPAM, clusters, power supply, and many other items to be managed. This gives an implementation that with Netbox IPAM tool, it is so easy to manage a data center by adding the required devices. To add a device let’s say a router, you will add the information below. In case you want to stop all the running containers, run the below command: $ docker-compose stop You can remove the containers as below. $ docker-compose stop && docker-compose rm Sample Output: +] Running 6/0 ⠿ Container netbox-docker-netbox-housekeeping-1 Stopped 0.0s ⠿ Container netbox-docker-netbox-1 Stopped 0.0s ⠿ Container netbox-docker-netbox-worker-1 Stopped 0.0s ⠿ Container netbox-docker-redis-cache-1 Stopped 0.0s ⠿ Container netbox-docker-redis-1 Stopped 0.0s ⠿ Container netbox-docker-postgres-1 Stopped 0.0s ? Going to remove netbox-docker-netbox-1, netbox-docker-netbox-housekeeping-1, netbox-docker-netbox-worker-1, netbox-docker-redis-cache-1, netbox-docker-redis-1, netbox-docker-postgres-1 (y/N) y Conclusion That is it! At this point, we can all agree that running Netbox IPAM Tool in Docker Containers is easier. I hope you succeeded to set up the Netbox IPAM tool Docker container.
0 notes
devops-jobs · 3 years ago
Photo
Tumblr media
HIRING: Director of Engineering, Cloud Infrastructure / Los Angeles, CA
0 notes
mzaghi · 3 years ago
Text
Buscamos Coordinador de Desarrollador Web via #comercializadoragt
Buscamos Coordinador de Desarrollador Web via #comercializadoragt Favor enviar tu CV a [email protected] Tecnologías y lenguajes PHP Javascript HTML CSS Python SQL WordPress Laravel NodeJS ReactJS VueJS (opcional) Django (opcional) CSS Framework (Bootstrap, Bulma, Foundation) Sistemas basados en Linux (Ubuntu, CentOS, Amazon…
View On WordPress
0 notes
dylanhyde131 · 4 years ago
Text
What Are Web Services
To explain what we mean by a web service , let's take all the sites, divide them into groups by purpose, and see the difference between them.
Getting to know the company:
·         business cards,
·         corporate sites.
Such sites solve image problems. They tell about a company or an individual, show news, introduce employees, goods and services , etc. The price for services, a calculator, an online consultant , etc., brings commercial benefits from the site .
Sales:
·         landing pages,
·         online shopping .
The main task of such a site is to tell about a product or service and lead the visitor to the purchase. If an online store solves this problem directly, then a  landing page (aka one-page page) most often only generates leads - arouses the target audience's interest in a product or service and offers to leave your email address or other contact information. Each element of a one-page page works for this task, the placement of which should be logically justified. How to make a landing page is taught by professionals from the Tilda website builder.
Informational:
·         blogs,
·         media.
Such resources cover events and issues of varying degrees of significance and topics. It is expected that information sites will have a rubricator, search, the ability to leave a comment and share an article on social networks, newsletter subscription, mobile layout and flawless SEO optimization , which allows the site to be in the first places in search results for relevant queries.
A blog does not have to be made from scratch - platforms for this purpose, like LiveJournal, Blogger, Blogspot, Tumblr and others, have been enough at all times.
Communication:
·         social network,
·         forums,
·         dating websites.
While such sites successfully serve as both a marketplace and a news source in 2019, they were primarily designed to help you connect with new people and keep them online with old friends and family. Among the main functions - a user profile, the ability to exchange private messages, create topics and leave comments.
Web Services :
·         message boards,
·         catalogs,
·         online consultation ,
·         product search and price comparison,
·         business solutions,
·         shopping marketplaces ,
·         booking systems.
With the help of a web service, a  user receives a service in real time or performs an action: buys a ticket, processes a photo, collects a presentation, or converts one currency into another at the current rate. From this point of view, Web Development resemble programs or mobile applications. While business cards or landing pages simply sell services and talk about the company, Web Development are of practical use.
Service sites and  Internet services  are synonymous with Web Development, so don't get lost if you come across such wording.
Services should be useful, their main task is to make the user solve the problem quickly and with minimal effort. Imagine you need a credit card. To choose and order a suitable one, you can independently study the websites of a dozen banks, then go to the office of one of them, stand in line, talk to the manager, fill out the documents, and return in a week for a ready credit card. 
Good service always looks concise. The less detail distracts the user from the main function, the better. An illustrative example is any Yandex or Google services: on the page with maps you will find only maps, and on the online wallet website  - only a tool for managing finances, without unnecessary links and advertisements for other products.
To make it convenient for the user, when developing such a website, it is very important to pay attention to UX analytics , and the  costs of UX / UI design��can be much higher than when creating a regular landing page or online store .
Why creating service sites is more difficult and more expensive than business cards
Web service development will have to be done from scratch. Ready-made box solutions are practically not suitable for this, especially when it comes to a product, and not a calculator on the company's website.
What Makes It Difficult To Create Such A Site?
·         Higher costs for  UX analytics , UX / UI design and  front-end development . The service will be used by people with specific needs, and the more narrow the task needs to be closed, the sharper the interface should be tailored for its user. Don't underestimate the importance of the user interface .
·         Backend development costs... A landing page or business card does not need a backend , because their content is static and does not imply any interaction. Web Development, on the other hand, need to work with a bunch of data: sort products by price, brand, or other attribute, make a cinema reservation for a specific movie, time and place , etc.
·         Integration with various services. It can be anything: CRM, 1C , SMS mailing , push notifications , payment. This part of the project can be made even more expensive if you develop, for example, your own payment gateway, but why, if there are ready-made solutions.
·         Lack of box solutions and designers. A business card can be made from a template, and an  online store  - based on hundreds of ready-made CMS. But if you need a system for managing petroleum product shipments with unique mechanics tailored to your business processes , then you cannot do without custom development from scratch, which is long and expensive.
What Is The Cost Of Developing A Web Development Services
Every serious product goes through the steps listed below. In parentheses, we indicated the percentage of the total time to create a product that takes a particular stage.
·         Analytics (3%)
Analytics determines who needs this service, how exactly it will solve the user's task, what value it brings to its owner, what is included in the project's technological stack (programming languages, frameworks, plugins, integrations), in what form the client will receive the service and how it is will scale.
·         Design (11%)
At the design stage, the user experience (UX), interface (UI) and the appearance of the service are thought out.
·         Development (55%)
To make the service look good on all devices, front-end developers make responsive HTML / CSS-layout and, in general, set the created design in motion by the power of the code, and  back-end developers establish client-server interaction and  business logic from the server side.
·         Testing (11%)
To prevent the client from getting the product as working anyway, testers run it through manual and automated tests to identify bugs.
·         Management (20%)
The manager ensures the work of the entire team and keeps the client informed of what is happening on the project: shows the results, discusses possible going beyond the deadlines and ways to prevent this , etc.
Product promotion stands apart. It is incorrect to measure it in hours and rubles - marketing constantly requires injections if the product is serious and wants to live a long time, adjusting to changing trends and the needs of its users. Once we talked in our blog about the promotion of a mobile application, which we recommend to read about .
What Is Included In The Web Service Technology Stack
The right set of technologies is the first step towards creating any product, including a  web service . Live Typing uses:
·         Programming languages ​​PHP, Python, Ruby.
·         Laravel, Yii2, Symfony, Django, Ruby On Rails frameworks.
·         Databases MySQL, PostgreSQL, Redis, MongoDB.
·         Operating systems Ubuntu, CentOS.
1 note · View note
kientrucsutiennguyen · 4 years ago
Text
Flask là gì
August 16, 2019February 8, 2020 Phạm Tâm TháiHọc lập trình15 Comments on Hướng dẫn lập trình Flask – Phần 1: Hello World!
Tumblr media
Loạt bài viết này sẽ hướng dẫn lập bạn cách tạo ra một ứng dụng Web đơn giản với Python và Flask framework.
Bạn đang xem: Flask là gì
Để giúp cho bạn dễ theo dõi, sau đây là danh sách các bài viết trong loạt bài hướng dẫn này:
Phần 1: Hello, World (bài viết này)
Bạn có thể truy cập mã nguồn cho phần này tạiGitHub.
Tại sao lại dùng Python mà không phải các ngôn ngữ khác?
Python là một ngôn ngữ đa năng và dễ học. Các chương trình viết bằng Python thường ngắn gọn và dễ hiểu. Nó cũng sở hữu một thư viện với các hàm và lớp xây dựng sẵn để tạo ra hầu hết các ứng dụng một cách nhanh chóng, từ các chương trình quản lý hệ thống cho đến các ứng dụng Web hoặc xa hơn nữa là các ứng dụng về trí tuệ nhân tạo hoặc phân tích dữ liệu. Nhược điểm của Python là chạy chậm hơn một số ngôn ngữ biên dịch (C/C++ hoặc thậm chí là Java hay C#). Tuy nhiên, với các hệ thống phần cứng hiện nay thì điểm yếu này có thể được bỏ qua trong một số điều kiện nhất định. Python là một ngôn ngữ hoàn hảo để xây dựng các ứng dụng nhỏ và vừa cho nhu cầu cá nhân hoặc doanh nghiệp.
Xem thêm: Aggressive Là Gì – Aggressive Trong Tiếng Tiếng Việt
Tại sao lại là Flask? Không phải Django mới là Web framework phổ biến nhất dựa trên Python hay sao?
Theo mức độ phổ biến, các ứng dụng Web trên nền tảng Django nhiều hơn là Flask. Tuy vậy, điều đó không đưa đến kết luận là Django tốt hơn Flask. Nếu muốn xây dựng một ứng dụng với thời gian ngắn nhất, Django dĩ nhiên là một lựa chọn tốt. Nhưng xét về tính linh hoạt, Django lại không bằng Flask. Với Django, các thành phần cơ bản của ứng dụng đã được định nghĩa sẵn, vì vậy khó tùy biến hơn. Ngược lại, Flask cho phép người lập trình lựa chọn và ghép nối các thành phần theo ý mình. Vì vậy, Flask là lựa chọn tốt cho những ai muốn tìm hiểu sâu về các Web framework và muốn có mức độ tùy biến cao.
Xem thêm: Ndk Là Gì – Bộ Phát Triển Android Native (Ndk) Là Gì
Để thực hành theo loạt bài hướng dẫn này, bạn cần chuẩn bị các bước như sau:
Cài đặt Python
Nếu máy của bạn không có sẵn Python, bạn cần cài đặt nó. Tùy theo hệ điều hành bạn đang sử dụng, bạn sẽ dùng những trình cài đặt khác nhau (nếu là Windows, bạn có thể download trực tiếp trình cài đặt từ trang chủ của Python – https://ift.tt/1fWWeAB. Nếu là Mac OS X, bạn cần dùng homebrew, nếu là Linux, bạn phải dùng trình quản lý gói thích hợp tùy theo bản phân phối bạn đang sử dụng – apt trên Ubuntu hoặc Debian, dnf trên Fedora, yum trên RHEL hoặc CentOS …). Tuy nhiên, dù dùng hệ điều hành nào đi nữa, hãy chắc rằng bạn cài đặt Python 3 vì Python 2 sẽ kết thúc vòng đời và không được hỗ trợ kể từ tháng 1 năm 2020.
Để kiểm tra xem Python đã được cài đặt và hoạt động tốt trên máy của bạn hay không, bạn có thể dùng cửa sổ lệnh (Command Prompt hoặc Windows PowerShell trên Window, terminal trên Mac OS X hoặc Linux) và dùng lệnh python3 (nếu lệnh này không hoạt động, bạn có thể thử chỉ dùng python). Nếu Python được cài đặt và hoạt động, sau khi dùng lệnh này, bạn sẽ thấy kết quả như sau:
Chuyên mục: Hỏi Đáp
from Sửa nhà giá rẻ Hà Nội https://ift.tt/36ogDhB Blog của Tiến Nguyễn https://kientrucsunguyentien.blogspot.com/
0 notes
hostvn · 5 years ago
Photo
Tumblr media
Hướng dẫn cài đặt Django trên CentOS 7
0 notes
mbaljeetsingh · 5 years ago
Text
The Ultimate Python Beginner's Handbook
Tumblr media
Python has become one of the fastest-growing programming languages over the past few years.
Not only it is widely used, it is also an awesome language to tackle if you want to get into the world of programming.
This Python Guide for Beginners allows you to learn the core of the language in a matter of hours instead of weeks.
Quick info: You can download a PDF version of this Python Guide for Beginners.
Ready to dive in?
Table of contents
Introduction to Python
Installing Python 3
Running Code
Syntax
Comments
Variables
Types
Typecasting
User Input
Operators
Conditionals
Lists
Tuples
Sets
Dictionaries
while Loops
for Loops
Functions
Scope
List Comprehensions
Lambda Functions
Modules
if name == 'main'
Files
Classes and Objects
Inheritance
Exceptions
Conclusion
Introduction to Python
Python was created in 1990 by Guido Van Rossum in Holland.
One of the objectives of the language was to be accessible to non-programmers.
Python was also designed to be a second language for programmers to learn due to its low learning curve and ease of use.
Python runs on Mac, Linux, Windows, and many other platforms.
Python is:
Interpreted: it can execute at runtime, and changes in a program are instantly perceptible. To be very technical, Python has a compiler. The difference when compared to Java or C++ is how transparent and automatic it is. With Python, we don't have to worry about the compilation step as it's done in real-time. The tradeoff is that interpreted languages are usually slower than compiled ones.
Semantically Dynamic: you don't have to specify types for variables and there is nothing that makes you do it.
Object-Oriented: everything in Python is an object. But you can choose to write code in an object-oriented, procedural, or even functional way.
High level: you don't have to deal with low-level machine details.
Python has been growing a lot recently partly because of its many uses in the following areas:
System scripting: it's a great tool to automate everyday repetitive tasks.
Data Analysis: it is a great language to experiment with and has tons of libraries and tools to handle data, create models, visualize results and even deploy solutions. This is used in areas like Finance, E-commerce, and Research.
Web Development: frameworks like Django and Flask allow the development of web applications, API's, and websites.
Machine Learning: Tensorflow and Pytorch are some of the libraries that allow scientists and the industry to develop and deploy Artificial Intelligence solutions in Image Recognition, Health, Self-driving cars, and many other fields.
You can easily organize your code in modules and reuse them or share them with others.
Finally, we have to keep in mind that Python had breaking changes between versions 2 and 3. And since Python 2 support ended in 2020, this article is solely based on Python 3.
So let's get started.
Installing Python 3
If you use a Mac or Linux you already have Python installed. But Windows doesn't come with Python installed by default.
You also might have Python 2, and we are going to use Python 3. So you should check to see if you have Python 3 first.
Type the following in your terminal.
python3 -V
Notice the uppercase V.
If your result is something similar to 'Python 3.x.y', for instance, Python 3.8.1, then you are ready to go.
If not, follow the next instructions according to your Operating System.
Installing Python 3 on Windows
Go to https://www.python.org/downloads/.
Download the latest version.
After the download, double-click the installer.
On the first screen, check the box indicating to "Add Python 3.x to PATH" and then click on "Install Now".
Wait for the installation process to finish until the next screen with the message "Setup was successful".
Click on "Close".
Installing Python 3 on Mac
Install XCode from the App Store.
Install the command line tools by running the following in your terminal.
xcode-select --install
I recommend using Homebrew. Go to https://brew.sh/ and follow the instructions on the first page to install it.
After installing Homebrew, run the following brew commands to install Python 3.
brew update brew install python3
Homebrew already adds Python 3 to the PATH, so you don't have to do anything else.
Installing Python 3 on Linux
To install using apt, available in Ubuntu and Debian, enter the following:
sudo apt install python3
To install using yum, available in RedHat and CentOS, enter the following:
sudo yum install python3
Running Code
You can run Python code directly in the terminal as commands or you can save the code in a file with the .py extension and run the Python file.
Terminal
Running commands directly in the terminal is recommended when you want to run something simple.
Open the command line and type python3
renan@mypc:~$ python3
You should see something like this in your terminal indicating the version (in my case, Python 3.6.9), the operating system (I'm using Linux), and some basic commands to help you.
The >>> tells us we are in the Python console.
Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
Let's test it by running our first program to perform basic math and add two numbers.
>>> 2 + 2
The output is:
4
To exit the Python console simply type exit().
>>> exit()
Running .py files
If you have a complex program, with many lines of code, the Python console isn't the best option.
The alternative is simply to open a text editor, type the code, and save the file with a .py extension.
Let's do that, create a file called second_program.py with the following content.
print('Second Program')
The print() function prints a message on the screen.
The message goes inside the parentheses with either single quotes or double quotes, both work the same.
To run the program, on your terminal do the following:
renan@mypc:~$ python3 second_program.py
The output is:
Second Program
Syntax
Python is known for its clean syntax.
The language avoids using unnecessary characters to indicate some specificity.
Semicolons
Python doesn't use semicolons to finish lines. A new line is enough to tell the interpreter that a new command is beginning.
The print() method will display something.
In this example, we have two commands that will display the messages inside the single quotes.
print('First command') print('Second command')
Output:
First command Second command
But the following is wrong due to the semicolons in the end:
print('First command'); print('Second command');
Indentation
Many languages use curly-brackets to define scope.
Python's interpreter uses only indentation to define when a scope ends and another one starts.
This means you have to be aware of white spaces at the beginning of each line -- they have meaning and might break your code if misplaced.
This definition of a function works:
def my_function(): print('First command')
This doesn't work because the indentation of the second line is missing and will throw an error:
def my_function(): print('First command')
Case sensitivity and variables
Python is case sensitive. So the variables name and Name are not the same thing and store different values.
name = 'Renan' Name = 'Moura'
As you can see, variables are easily created by just assigning values to them using the = symbol.
This means name stores 'Renan' and Name stores 'Moura'.
Finally, to comment something in your code, use the hash mark #.
The commented part does not influence the program flow.
# this function prints something def my_function(): print('First command')
This was just an overview. The details of each of these will become clearer in the next chapters with examples and broader explanations.
The purpose of comments is to explain what is happening in the code.
Comments are written along with your code but do not influence your program flow.
When you work by yourself, maybe comments don't feel like something you should write. After all, at the moment, you know the whys of every single line of code.
But what if new people come on board your project after a year and the project has 3 modules, each with 10,000 lines of code?
Think about people who don't know a thing about your app and who are suddenly having to maintain it, fix it, or add new features.
Remember, there is no single solution for a given problem. Your way of solving things is yours and yours only. If you ask 10 people to solve the same problem, they will come up with 10 different solutions.
If you want others to fully understand your reasoning, good code design is mandatory, but comments are an integral part of any codebase.
The syntax of comments in Python is rather easy: just use the hash mark # symbol in front of the text you want to be a comment.
#This is a comment and it won't influence my program flow
You can use a comment to explain what some piece of code does.
#calculates the sum of any given two numbers a + b
Maybe you want to comment on something very complex or describe how some process works in your code.
In these cases, you can use multiline comments.
To do that, just use a single hash mark # for each line.
#Everything after the hash mark # is a comment #This is a comment and it won't influence my program flow #Calculates the cost of the project given variables a and b #a is the time in months it will take until the project is finished #b is how much money it will cost per month a + b * 10
Variables
In any program, you need to store and manipulate data to create a flow or some specific logic.
That's what variables are for.
You can have a variable to store a name, another one to store the age of a person, or even use a more complex type to store all of this at once like a dictionary.
Creating, also known as Declaring
Declaring a variable is a basic and straightforward operation in Python
Just pick a name and attribute a value to it using the = symbol.
name='Bob' age=32
You can use the print() function to show the value of a variable.
print(name) print(age)
Bob 32
Notice that in Python there is no special word to declare a variable.
The moment you assign a value, the variable is created in memory.
Python also has dynamic typing, which means you don't have to tell it if your variable is a text or a number, for instance.
The interpreter infers the typing based on the value assigned.
If you need it, you can also re-declare a variable just by changing its value.
#declaring name as a string name='Bob' #re-declaring name as an int name = 32
Keep in my mind, though, that this is not recommended since variables must have meaning and context.
If I have a variable called name I don't expect it to have a number stored in it.
Naming Conventions
Let's continue from the last section when I talked about meaning and context.
Don't use random variable names like x or y.
Say you want to store the time of a party, just call it party_time.
Oh, did you notice the underscore _?
By convention, if you want to use a variable name that is composed of two or more words, you separate them by underscores. This is called Snake Case.
Another option would be using CamelCase as in partyTime. This is very common in other languages, but not the convention in Python as stated before.
Variables are case sensitive, so party_time and Party_time are not the same. Also, keep in mind that the convention tells us to always use lower case.
Remember, use names that you can recall inside your program easily. Bad naming can cost you a lot of time and cause annoying bugs.
In summary, variable names:
Are Case sensitive: time and TIME are not the same
Have to start with an underscore _ or a letter (DO NOT start with a number)
Are allowed to have only numbers, letters and underscores. No special characters like: #, $, &, @, etc.
This, for instance, is not allowed: party#time, 10partytime.
Types
To store data in Python you need to use a variable. And every variable has its type depending on the value of the data stored.
Python has dynamic typing, which means you don't have to explicitly declare the type of your variable -- but if you want to, you can.
Lists, Tuples, Sets, and Dictionaries are all data types and have dedicated sections later on with more details, but we'll look at them briefly here.
This way I can show you the most important aspects and operations of each one in their own section while keeping this section more concise and focused on giving you a broad view of the main data types in Python.
Determining the Type
First of all, let's learn how to determine the data type.
Just use the type() function and pass the variable of your choice as an argument, like the example below.
print(type(my_variable))
Boolean
The boolean type is one of the most basic types of programming.
A boolean type variable can only represent either True or False.
my_bool = True print(type(my_bool)) my_bool = bool(1024) print(type(my_bool))
<class 'bool'> <class 'bool'>
Numbers
There are three types of numeric types: int, float, and complex.
Integer
my_int = 32 print(type(my_int)) my_int = int(32) print(type(my_int))
<class 'int'> <class 'int'>
Float
my_float = 32.85 print(type(my_float)) my_float = float(32.85) print(type(my_float))
<class 'float'> <class 'float'>
Complex
my_complex_number = 32+4j print(type(my_complex_number)) my_complex_number = complex(32+4j) print(type(my_complex_number))
<class 'complex'> <class 'complex'>
String
The text type is one of the most commons types out there and is often called string or, in Python, just str.
my_city = "New York" print(type(my_city)) #Single quotes have exactly #the same use as double quotes my_city = 'New York' print(type(my_city)) #Setting the variable type explicitly my_city = str("New York") print(type(my_city))
<class 'str'> <class 'str'> <class 'str'>
You can use the + operator to concatenate strings.
Concatenation is when you have two or more strings and you want to join them into one.
word1 = 'New ' word2 = 'York' print(word1 + word2)
New York
The string type has many built-in methods that let us manipulate them. I will demonstrate how some of these methods work.
The len() function returns the length of a string.
print(len('New York'))
8
The replace() method replaces a part of the string with another. As an example, let's replace 'New' for 'Old'.
print('New York'.replace('New', 'Old'))
Old York
The upper() method will return all characters as uppercase.
print('New York'.upper())
NEW YORK
The lower() method does the opposite, and returns all characters as lowercase.
print('New York'.lower())
new york
Lists
A list has its items ordered and you can add the same item as many times as you want. An important detail is that lists are mutable.
Mutability means you can change a list after its creation by adding items, removing them, or even just changing their values. These operations will be demonstrated later in the section dedicated to Lists.
my_list = ["bmw", "ferrari", "maclaren"] print(type(my_list)) my_list = list(("bmw", "ferrari", "maclaren")) print(type(my_list))
<class 'list'> <class 'list'>
Tuples
A tuple is just like a list: ordered, and allows repetition of items.
There is just one difference: a tuple is immutable.
Immutability means you can't change a tuple after its creation. If you try to add an item or update one, for instance, the Python intepreter will show you an error. I will show that these errors occur later in the section dedicated to Tuples.
my_tuple = ("bmw", "ferrari", "maclaren") print(type(my_tuple)) my_tuple = tuple(("bmw", "ferrari", "maclaren")) print(type(my_tuple))
<class 'tuple'> <class 'tuple'>
Sets
Sets don't guarantee the order of the items and are not indexed.
A key point when using sets: they don't allow repetition of an item.
my_set = {"bmw", "ferrari", "maclaren"} print(type(my_set)) my_set = set(("bmw", "ferrari", "maclaren")) print(type(my_set))
<class 'set'> <class 'set'>
Dictionaries
A dictionary doesn't guarantee the order of the elements and is mutable.
One important characteristic in dictionaries is that you can set your own access keys for each element.
my_dict = {"country" : "France", "worldcups" : 2} print(type(my_dict)) my_dict = dict(country="France", worldcups=2) print(type(my_dict))
<class 'dict'> <class 'dict'>
Typecasting
Typecasting allows you to convert between different types.
This way you can have an int turned into a str, or a float turned into an int, for instance.
Explicit conversion
To cast a variable to a string just use the str() function.
# this is just a regular explicit intialization my_str = str('32') print(my_str) # int to str my_str = str(32) print(my_str) # float to str my_str = str(32.0) print(my_str)
32 32 32.0
To cast a variable to an integer just use the int() function.
# this is just a regular explicit intialization my_int = int(32) print(my_int) # float to int: rounds down to 3 my_int = int(3.2) print(my_int) # str to int my_int = int('32') print(my_int)
32 3 32
To cast a variable to a float just use the float() function.
# this is an explicit intialization my_float = float(3.2) print(my_float) # int to float my_float = float(32) print(my_float) # str to float my_float = float('32') print(my_float)
3.2 32.0 32.0
What I did above is called an explicit type conversion.
In some cases you don't need to do the conversion explicitly, since Python can do it by itself.
Implicit conversion
The example below shows implicit conversion when adding an int and a float.
Notice that my_sum is float. Python uses float to avoid data loss since the int type can not represent the decimal digits.
my_int = 32 my_float = 3.2 my_sum = my_int + my_float print(my_sum) print(type(my_sum))
35.2 <class 'float'>
On the other hand, in this example, when you add an int and a str, Python will not be able to make the implicit conversion, and the explicit type conversion is necessary.
my_int = 32 my_str = '32' # explicit conversion works my_sum = my_int + int(my_str) print(my_sum) #implicit conversion throws an error my_sum = my_int + my_str
64 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'str'
The same error is thrown when trying to add float and str types without making an explicit conversion.
my_float = 3.2 my_str = '32' # explicit conversion works my_sum = my_float + float(my_str) print(my_sum) #implicit conversion throws an error my_sum = my_float + my_str
35.2 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'float' and 'str'
User Input
If you need to interact with a user when running your program in the command line (for example, to ask for a piece of information), you can use the input() function.
country = input("What is your country? ") #user enters 'Brazil' print(country)
Brazil
The captured value is always string. Just remember that you might need to convert it using typecasting.
age = input("How old are you? ") #user enters '29' print(age) print(type(age)) age = int(age) print(type(age))
The output for each print() is:
29 <class 'str'> <class 'int'>
Notice the age 29 is captured as string and then converted explicitly to int.
Operators
In a programming language, operators are special symbols that you can apply to your variables and values in order to perform operations such as arithmetic/mathematical and comparison.
Python has lots of operators that you can apply to your variables and I will demonstrate the most used ones.
Arithmetic Operators
Arithmetic operators are the most common type of operators and also the most recognizable ones.
They allow you to perform simple mathematical operations.
They are:
+: Addition
-: Subtraction
*: Multiplication
/: Division
**: Exponentiation
//: Floor Division, rounds down the result of a division
%: Modulus, gives you the remainder of a division
Let's see a program that shows how each of them is used.
print('Addition:', 5 + 2) print('Subtraction:', 5 - 2) print('Multiplication:', 5 * 2) print('Division:', 5 / 2) print('Floor Division:', 5 // 2) print('Exponentiation:', 5 ** 2) print('Modulus:', 5 % 2)
Addition: 7 Subtraction: 3 Multiplication: 10 Division: 2.5 Floor Division: 2 Exponentiation: 25 Modulus: 1
Concatenation
Concatenation is when you have two or more strings and you want to join them into one.
This useful when you have information in multiple variables and want to combine them.
For instance, in this next example I combine two variables that contain my first name and my last name respectively to have my full name.
The + operator is also used to concatenate.
first_name = 'Renan ' last_name = 'Moura' print(first_name + last_name)
Renan Moura
Since concatenation is applied to strings, to concatenate strings with other types, you have to do an explicit typecast using str().
I have to typecast the int value 30 to string with str() to concatenate it with the rest of the string.
age = 'I have ' + str(30) + ' years old' print(age)
I have 30 years old
Comparison Operators
Use comparison operators to compare two values.
These operators return either True or False.
They are:
==: Equal
!=: Not equal
>: Greater than
<: Less than
>=: Greater than or equal to
<=: Less than or equal to
Let's see a program that shows how each of them is used.
print('Equal:', 5 == 2) print('Not equal:', 5 != 2) print('Greater than:', 5 > 2) print('Less than:', 5 < 2) print('Greater than or equal to:', 5 >= 2) print('Less than or equal to:', 5 <= 2)
Equal: False Not equal: True Greater than: True Less than: False Greater than or equal to: True Less than or equal to: False
Assignment Operators
As the name implies, these operators are used to assign values to variables.
x = 7 in the first example is a direct assignment storing the number 7 in the variable x.
The assignment operation takes the value on the right and assigns it to the variable on the left.
The other operators are simple shorthands for the Arithmetic Operators.
In the second example x starts with 7 and x += 2 is just another way to write x = x + 2. This means the previous value of x is added by 2 and reassigned to x that is now equal to 9.
x = 7 print(x)
7
+=: addition and assignment
x = 7 x += 2 print(x)
9
-=: subtraction and assignment
x = 7 x -= 2 print(x)
5
*=: multiplication and assignment
x = 7 x *= 2 print(x)
14
/=: division and assignment
x = 7 x /= 2 print(x)
3.5
%=: modulus and assignment
x = 7 x %= 2 print(x)
1
//=: floor division and assignment
x = 7 x //= 2 print(x)
3
**=: exponentiation and assignment
x = 7 x **= 2 print(x)
49
Logical Operators
Logical operators are used to combine statements applying boolean algebra.
They are:
and: True only when both statements are true
or: False only when both x and y are false
not: The not operator simply inverts the input, True becomes False and vice versa.
Let's see a program that shows how each one is used.
x = 5 y = 2 print(x == 5 and y > 3) print(x == 5 or y > 3) print(not (x == 5))
False True False
Membership Operators
These operators provide an easy way to check if a certain object is present in a sequence: string, list, tuple, set, and dictionary.
They are:
in: returns True if the object is present
not in: returns True if the object is not present
Let's see a program that shows how each one is used.
number_list = [1, 2, 4, 5, 6] print( 1 in number_list) print( 5 not in number_list) print( 3 not in number_list)
True False True
Conditionals
Conditionals are one of the cornerstones of any programming language.
They allow you to control the program flow according to specific conditions you can check.
The if statement
The way you implement a conditional is through the if statement.
The general form of an if statement is:
if expression: statement
The expression contains some logic that returns a boolean, and the statement is executed only if the return is True.
A simple example:
bob_age = 32 sarah_age = 29 if bob_age > sarah_age: print('Bob is older than Sarah')
Bob is older than Sarah
We have two variables indicating the ages of Bob and Sarah. The condition in plain English says "if Bob's age is greater than Sarah's age, then print the phrase 'Bob is older than Sarah'".
Since the condition returns True, the phrase will be printed on the console.
The if else and elif statements
In our last example, the program only does something if the condition returns True.
But we also want it to do something if it returns False or even check a second or third condition if the first one wasn't met.
In this example, we swapped Bob's and Sarah's age. The first condition will return False since Sarah is older now, and then the program will print the phrase after the else instead.
bob_age = 29 sarah_age = 32 if bob_age > sarah_age: print('Bob is older than Sarah') else: print('Bob is younger than Sarah')
Bob is younger than Sarah
Now, consider the example below with the elif.
bob_age = 32 sarah_age = 32 if bob_age > sarah_age: print('Bob is older than Sarah') elif bob_age == sarah_age: print('Bob and Sarah have the same age') else: print('Bob is younger than Sarah')
Bob and Sarah have the same age
The purpose of the elif is to provide a new condition to be checked before the else is executed.
Once again we changed their ages and now both are 32 years old.
As such, the condition in the elif is met. Since both have the same age the program will print "Bob and Sarah have the same age".
Notice you can have as many elifs as you want, just put them in sequence.
bob_age = 32 sarah_age = 32 if bob_age > sarah_age: print('Bob is older than Sarah') elif bob_age < sarah_age: print('Bob is younger than Sarah') elif bob_age == sarah_age: print('Bob and Sarah have the same age') else: print('This one is never executed')
Bob and Sarah have the same age
In this example, the else is never executed because all the possibilities are covered in the previous conditions and thus could be removed.
Nested conditionals
You might need to check more than one conditional for something to happen.
In this case, you can nest your if statements.
For instance, the second phrase "Bob is the oldest" is printed only if both ifs pass.
bob_age = 32 sarah_age = 28 mary_age = 25 if bob_age > sarah_age: print('Bob is older than Sarah') if bob_age > mary_age: print('Bob is the oldest')
Bob is the oldest
Or, depending on the logic, make it simpler with Boolean Algebra.
This way, your code is smaller, more readable and easier to maintain.
bob_age = 32 sarah_age = 28 mary_age = 25 if bob_age > sarah_age and bob_age > mary_age: print('Bob is the oldest')
Bob is the oldest
Or even:
bob_age = 32 sarah_age = 28 mary_age = 25 if bob_age > sarah_age > mary_age: print('Bob is the oldest')
Bob is the oldest
Ternary Operators
The ternary operator is a one-line if statement.
It's very handy for simple conditions.
This is how it looks:
<expression> if <condition> else <expression>
Consider the following Python code:
a = 25 b = 50 x = 0 y = 1 result = x if a > b else y print(result)
1
Here we use four variables, a and b are for the condition, while x and y represent the expressions.
a and b are the values we are checking against each other to evaluate some condition. In this case, we are checking if a is greater than b.
If the expression holds true, i.e., a is greater than b, then the value of x will be attributed to result which will be equal to 0.
However, if a is less than b, then we have the value of y assigned to result, and result will hold the value 1.
Since a is less than b, 25 < 50, result will have 1 as final value from y.
The easy way to remember how the condition is evaluated is to read it in plain English.
Our example would read: result will be x if a is greater than b otherwise y.
Lists
As promised in the Types section, this section and the next three about Tuples, Sets, and Dictionaries will have more in depth explanations of each of them since they are very important and broadly used structures in Python to organize and deal with data.
A list has its items ordered and you can add the same item as many times as you want.
An important detail is that lists are mutable.
Mutability means you can change a list after its creation by adding items, removing them, or even just changing their values.
Initialization
Empty List
people = []
List with initial values
people = ['Bob', 'Mary']
Adding in a List
To add an item in the end of a list, use append().
people = ['Bob', 'Mary'] people.append('Sarah') print(people)
['Bob', 'Mary', 'Sarah']
To specify the position for the new item, use the insert() method.
people = ['Bob', 'Mary'] people.insert(0, 'Sarah') print(people)
['Sarah', 'Bob', 'Mary']
Updating in a List
Specify the position of the item to update and set the new value
people = ['Bob', 'Mary'] people[1] = 'Sarah' print(people)
['Bob', 'Sarah']
Deleting in a List
Use the remove() method to delete the item given as an argument.
people = ['Bob', 'Mary'] people.remove('Bob') print(people)
['Mary']
To delete everybody, use the clear() method:
people = ['Bob', 'Mary'] people.clear()
Retrieving in a List
Use the index to reference the item.
Remember that the index starts at 0.
So to access the second item use the index 1.
people = ['Bob', 'Mary'] print(people[1])
Mary
Check if a given item already exists in a List
people = ['Bob', 'Mary'] if 'Bob' in people: print('Bob exists!') else: print('There is no Bob!')
Tuples
A tuple is similar to a list: it's ordered, and allows repetition of items.
There is just one difference: a tuple is immutable.
Immutability, if you remember, means you can't change a tuple after its creation. If you try to add an item or update one, for instance, the Python interpreter will show you an error.
Initialization
Empty Tuple
people = ()
Tuple with initial values
people = ('Bob', 'Mary')
Adding in a Tuple
Tuples are immutable. This means that if you try to add an item, you will see an error.
people = ('Bob', 'Mary') people[2] = 'Sarah'
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'tuple' object does not support item assignment
Updating in a Tuple
Updating an item will also return an error.
But there is a trick: you can convert into a list, change the item, and then convert it back to a tuple.
people = ('Bob', 'Mary') people_list = list(people) people_list[1] = 'Sarah' people = tuple(people_list) print(people)
('Bob', 'Sarah')
Deleting in a Tuple
For the same reason you can't add an item, you also can't delete an item, since they are immutable.
Retrieving in a Tuple
Use the index to reference the item.
people = ('Bob', 'Mary') print(people[1])
Mary
Check if a given item already exists in a Tuple
people = ('Bob', 'Mary') if 'Bob' in people: print('Bob exists!') else: print('There is no Bob!')
Sets
Sets don't guarantee the order of items and are not indexed.
A key point when using sets: they don't allow repetition of an item.
Initialization
Empty Set
people = set()
Set with initial values
people = {'Bob', 'Mary'}
Adding in a Set
Use the add() method to add one item.
people.add('Sarah')
Use the update() method to add multiple items at once.
people.update(['Carol', 'Susan'])
Remember, Sets do not allow repetition, so if you add 'Mary' again, nothing changes.
people = {'Bob', 'Mary'} people.add('Mary') print(people)
{'Bob', 'Mary'}
Updating in a Set
Items in a set are not mutable. You have to either add or delete an item.
Deleting in a Set
To remove Bob from the dictionary:
people = {'Bob', 'Mary'} people.remove('Bob') print(people)
{'Mary'}
To delete everybody:
people.clear()
Check if a given item already exists in a set
people = {'Bob', 'Mary'} if 'Bob' in people: print('Bob exists!') else: print('There is no Bob!')
Dictionaries
The dictionary doesn't guarantee the order of the elements and it is mutable.
One important characteristic of dictionaries is that you can set your customized access keys for each element.
Initialization of a Dictionary
Empty Dictionary
people = {}
Dictionary with initial values
people = {'Bob':30, 'Mary':25}
Adding in a Dictionary
If the key doesn't exist yet, it is appended to the dictionary.
people['Sarah']=32
Updating a Dictionary
If the key already exists, the value is just updated.
#Bob's age is 28 now people['Bob']=28
Notice that the code is pretty much the same.
Deleting in a Dictionary
To remove Bob from the dictionary:
people.pop('Bob')
To delete everybody:
people.clear()
Retrieving in a Dictionary
bob_age = people['Bob'] print(bob_age)
30
Check if a given key already exists in a Dictionary
if 'Bob' in people: print('Bob exists!') else: print('There is no Bob!')
while Loops
Loops are used when you need to repeat a block of code a certain number of times or apply the same logic over each item in a collection.
There are two types of loops: for and while.
You will learn about for loops in the next section.
Basic Syntax
The basic syntax of a while loop is as below.
while condition: statement
The loop will continue until the condition is True.
The square of a number is
The example below takes each value of number and calculates its squared value.
number = 1 while number <= 5: print(number, 'squared is', number**2) number = number + 1
1 squared is 1 2 squared is 4 3 squared is 9 4 squared is 16 5 squared is 25
You can use any variable name, but I chose number because it makes sense in the context. A common generic choice would be simply i.
The loop will go on until number (initialized with 1) is less than or equal to 5.
Notice that after the print() command, the variable number is incremented by 1 to take the next value.
If you don't do the incrementation you will have an infinite loop since number will never reach a value greater than 5. This is a very important detail!
else block
When the condition returns False, the else block will be called.
number = 1 while number <= 5: print(number, 'squared is', number**2) number = number + 1 else: print('No numbers left!')
1 squared is 1 2 squared is 4 3 squared is 9 4 squared is 16 5 squared is 25 No numbers left!
Notice the phrase 'No numbers left!' is printed after the loop ends, that is after the condition number <= 5 evaluates to False.
How to break out of a while loop in Python
Simply use the break keyword, and the loop will stop its execution.
number = 1 while number <= 5: print(number, 'squared is', number**2) number = number + 1 if number == 4: break
1 squared is 1 2 squared is 4 3 squared is 9
The loop runs normally, and when number reaches 4 the if statement evaluates to True and the break command is called. This finishes the loop before the squared value of the numbers 4 and 5 are calculated.
How to skip an item in a while loop
The continue will do that for you.
I had to invert the order of the if statement and the print() to show how it works properly.
number = 0 while number < 5: number = number + 1 if number == 4: continue print(number, 'squared is', number**2)
1 squared is 1 2 squared is 4 3 squared is 9 5 squared is 25
The program always checks if 4 is the current value of number. If it is, the square of 4 won't be calculated and the continue will skip to the next iteration when the value of number is 5.
for Loops
for loops are similar to while loops in the sense that they are used to repeat blocks of code.
The most important difference is that you can easily iterate over sequential types.
Basic Syntax
The basic syntax of a for loop is as below.
for item in collection: statement
Loop over a list
To loop over a list or any other collection, just proceed as shown in the example below.
cars = ['BMW', 'Ferrari', 'McLaren'] for car in cars: print(car)
BMW Ferrari McLaren
The list of cars contains three items. The for loop will iterate over the list and store each item in the car variable, and then execute a statement, in this case print(car), to print each car in the console.
range() function
The range function is widely used in for loops because it gives you a simple way to list numbers.
This code will loop through the numbers 0 to 5 and print each of them.
for number in range(5): print(number)
0 1 2 3 4
In contrast, without the range() function, we would do something like this.
numbers = [0, 1, 2, 3, 4] for number in numbers: print(number)
0 1 2 3 4
You can also define a start and stop using range().
Here we are starting in 5 and a stoping in 10. The number you set to stop is not included.
for number in range(5, 10): print(number)
5 6 7 8 9
Finally, it is also possible to set a step.
Here we starting in 10 and incrementing by 2 until 20, since 20 is the stop, it is not included.
for number in range(10, 20, 2): print(number)
10 12 14 16 18
else block
When the items in the list are over, the else block will be called.
cars = ['BMW', 'Ferrari', 'McLaren'] for car in cars: print(car) else: print('No cars left!')
BMW Ferrari McLaren No cars left!
How to break out of a for loop in Python
Simply use the break keyword, and the loop will stop its execution.
cars = ['BMW', 'Ferrari', 'McLaren'] for car in cars: print(car) if car == 'Ferrari': break
BMW Ferrari
The loop will iterate through the list and print each car.
In this case, after the loop reaches 'Ferrari', the break is called and 'McLaren' won't be printed.
How to skip an item in a for loop
In this section, we'll learn how continue can do this for you.
I had to invert the order of the if statement and the continue to show how it works properly.
Notice that I always check if 'Ferrari' is the current item. If it is, 'Ferrari' won't be printed, and the continue will skip to the next item 'McLaren'.
cars = ['BMW', 'Ferrari', 'McLaren'] for car in cars: if car == 'Ferrari': continue print(car)
BMW McLaren
Loop over a Loop: Nested Loops
Sometimes you have more complex collections, like a list of lists.
To iterate over these lists, you need nested for loops.
In this case, I have three lists: one of BMW models, another on Ferrari models, and finally one with McLaren models.
The first loop iterates over each brand's list, and the second will iterate over the models of each brand.
car_models = [ ['BMW I8', 'BMW X3', 'BMW X1'], ['Ferrari 812', 'Ferrari F8', 'Ferrari GTC4'], ['McLaren 570S', 'McLaren 570GT', 'McLaren 720S'] ] for brand in car_models: for model in brand: print(model)
BMW I8 BMW X3 BMW X1 Ferrari 812 Ferrari F8 Ferrari GTC4 McLaren 570S McLaren 570GT McLaren 720S
Loop over other Data Structures
The same logic that applies for loops over a list can be extended to the other data structures: tuple, set, and dictionary.
I will briefly demonstrate how to make a basic loop over each one of them.
Loop over a Tuple
people = ('Bob', 'Mary') for person in people: print(person)
Bob Mary
Loop over a Set
people = {'Bob', 'Mary'} for person in people: print(person)
Bob Mary
Loop over a Dictionary
To print the keys:
people = {'Bob':30, 'Mary':25} for person in people: print(person)
Bob Mary
To print the values:
people = {'Bob':30, 'Mary':25} for person in people: print(people[person])
30 25
Functions
As the code grows the complexity also grows. And functions help organize the code.
Functions are a handy way to create blocks of code that you can reuse.
Definition and Calling
In Python use the def keyword to define a function.
Give it a name and use parentheses to inform 0 or more arguments.
In the line after the declaration starts, remember to indent the block of code.
Here is an example of a function called print_first_function() that only prints a phrase 'My first function!'.
To call the function just use its name as defined.
def print_first_function(): print('My first function!') print_first_function()
My first function!
return a value
Use the return keyword to return a value from the function.
In this example the function second_function() returns the string 'My second function!'.
Notice that print() is a built-in function and our function is called from inside it.
The string returned by second_function() is passed as an argument to the print() function.
def second_function(): return 'My second function!' print(second_function())
My second function!
return multiple values
Functions can also return multiple values at once.
return_numbers() returns two values simultaneously.
def return_numbers(): return 10, 2 print(return_numbers())
(10, 2)
Arguments
You can define parameters between the parentheses.
When calling a function with parameters you have to pass arguments according to the parameters defined.
The past examples had no parameters, so there was no need for arguments. The parentheses remained empty when the functions were called.
One Argument
To specify one parameter, just define it inside the parentheses.
In this example, the function my_number expects one number as argument defined by the parameter num.
The value of the argument is then accessible inside the function to be used.
def my_number(num): return 'My number is: ' + str(num) print(my_number(10))
My number is: 10
Two or more Arguments
To define more parameters, just use a comma to separate them.
Here we have a function that adds two numbers called add. It expects two arguments defined by first_num and second_num.
The arguments are added by the + operator and the result is then returned by the return.
def add(first_num, second_num): return first_num + second_num print(add(10,2))
12
This example is very similar to the last one. The only difference is that we have 3 parameters instead of 2.
def add(first_num, second_num, third_num): return first_num + second_num + third_num print(add(10,2,3))
15
This logic of defining parameters and passing arguments is the same for any number of parameters.
It is important to point out that the arguments have to be passed in the same order that the parameters are defined.
Default value.
You can set a default value for a parameter if no argument is given using the = operator and a value of choice.
In this function, if no argument is given, the number 30 is assumed as the expected value by default.
def my_number(my_number = 30): return 'My number is: ' + str(my_number) print(my_number(10)) print(my_number())
My number is: 10 My number is: 30
Keyword or Named Arguments
When calling a function, the order of the arguments have to match the order of the parameters.
The alternative is if you use keyword or named arguments.
Set the arguments to their respective parameters directly using the name of the parameters and the = operators.
This example flips the arguments, but the function works as expected because I tell it which value goes to which parameter by name.
def my_numbers(first_number, second_number): return 'The numbers are: ' + str(first_number) + ' and ' + str(second_number) print(my_numbers(second_number=30, first_number=10))
The numbers are: 10 and 30
Any number of arguments: *args
If you don't want to specify the number of parameters, just use the * before the parameter name. Then the function will take as many arguments as necessary.
The parameter name could be anything like *numbers, but there is a convention in Python to use *args for this definition of a variable number of arguments.
def my_numbers(*args): for arg in args: print(number) my_numbers(10,2,3)
10 2 3
Any number of Keyword/Named arguments: **kwargs
Similar to *args, we can use **kwargs to pass as many keyword arguments as we want, as long as we use **.
Again, the name could be anything like **numbers, but **kwargs is a convention.
def my_numbers(**kwargs): for key, value in kwargs.items(): print(key) print(value) my_numbers(first_number=30, second_number=10)
first_number 30 second_number 10
Other types as arguments
The past examples used mainly numbers, but you can pass any type as argument and they will be treated as such inside the function.
This example takes strings as arguments.
def my_sport(sport): print('I like ' + sport) my_sport('football') my_sport('swimming')
I like football I like swimming
This function takes a list as argument.
def my_numbers(numbers): for number in numbers: print(number) my_numbers([30, 10, 64, 92, 105])
30 10 64 92 105
Scope
The place where a variable is created defines its availability to be accessed and manipulated by the rest of the code. This is known as scope.
There are two types of scope: local and global.
Global Scope
A global scope allows you to use the variable anywhere in your program.
If your variable is outside a function, it has global scope by default.
name = 'Bob' def print_name(): print('My name is ' + name) print_name()
My name is Bob
Notice that the function could use the variable name and print My name is Bob.
Local Scope
When you declare a variable inside a function, it only exists inside that function and can't be accessed from the outside.
def print_name(): name = "Bob" print('My name is ' + name) print_name()
My name is Bob
The variable name was declared inside the function, so the output is the same as before.
But this will throw an error:
def print_name(): name = 'Bob' print('My name is ' + name) print(name)
The output of the code above is:
Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'name' is not defined
I tried to print the variable name from outside the function, but the scope of the variable was local and could not be found in a global scope.
Mixing Scopes
If you use the same name for variables inside and outside a function, the function will use the one inside its scope.
So when you call print_name(), the name='Bob' is used to print the phrase.
On the other hand, when calling print() outside the function scope, name="Sarah" is used because of its global scope.
name = "Sarah" def print_name(): name = 'Bob' print('My name is ' + name) print_name() print(name)
The output of the code above is:
My name is Bob Sarah
List Comprehensions
Sometimes we want to perform some very simple operations over the items of a list.
List comprehensions give us a succinct way to work on lists as an alternative to other methods of iteration, such as for loops.
Basic syntax
To use a list comprehension to replace a regular for loop, we can make:
[expression for item in list]
Which is the same as doing:
for item in list: expression
If we want some conditional to apply the expression, we have:
[expression for item in list if conditional ]
Which is the same as doing:
for item in list: if conditional: expression
Example 1: calculating the cube of a number
Regular way
numbers = [1, 2, 3, 4, 5] new_list = [] for n in numbers: new_list.append(n**3) print(new_list)
[1, 8, 27, 64, 125]
Using list comprehensions
numbers = [1, 2, 3, 4, 5] new_list = [] new_list = [n**3 for n in numbers] print(new_list)
[1, 8, 27, 64, 125]
Example 2: calculating the cube of a number only if it is greater than 3
Using the conditional, we can filter only the values we want the expression to be applied to.
Regular way
numbers = [1, 2, 3, 4, 5] new_list = [] for n in numbers: if(n > 3): new_list.append(n**3) print(new_list)
[64, 125]
Using list comprehensions
numbers = [1, 2, 3, 4, 5] new_list = [] new_list = [n**3 for n in numbers if n > 3] print(new_list)
[64, 125]
Example 3: calling functions with list comprehensions
We can also call functions using the list comprehension syntax:
numbers = [1, 2, 3, 4, 5] new_list = [] def cube(number): return number**3 new_list = [cube(n) for n in numbers if n > 3] print(new_list)
[64, 125]
Lambda Functions
A Python lambda function can only have one expression and can't have multiple lines.
It is supposed to make it easier to create some small logic in one line instead of a whole function as is usually done.
Lambda functions are also anonymous, which means there is no need to name them.
Basic Syntax
The basic syntax is very simple: just use the lambda keyword, define the parameters needed, and use ":" to separate the parameters from the expression.
The general forms is:
lambda arguments : expression
One parameter example
Look at this example using only one parameter
cubic = lambda number : number**3 print(cubic(2))
8
Multiple parameter example
If you want, you can also have multiple parameters.
exponential = lambda multiplier, number, exponent : multiplier * number**exponent print(exponential(2, 2, 3))
16
Calling the Lambda Function directly
You don't need to use a variable as we did before. Instead you can make use of parenthesis around the lambda function and another pair of parenthesis around the arguments.
The declaration of the function and the execution will happen in the same line.
(lambda multiplier, number, exponent : multiplier * number**exponent)(2, 2, 3)
16
Examples using lambda functions with other built-in functions
Map
The Map function applies the expression to each item in a list.
Let's calculate the cubic of each number in the list.
numbers = [2, 5, 10] cubics = list(map(lambda number : number**3, numbers)) print(cubics)
[8, 125, 1000]
Filter
The Filter function will filter the list based on the expression.
Let's filter to have only the numbers greater than 5.
numbers = [2, 5, 10] filtered_list = list(filter(lambda number : number > 5, numbers)) print(filtered_list)
[10]
Modules
After some time your code starts to get more complex with lots of functions and variables.
To make it easier to organize the code we use Modules.
A well-designed Module also has the advantage of being reusable, so you write code once and reuse it everywhere.
You can write a module with all the mathematical operations and other people can use it.
And, if you need, you can use someone else's modules to simplify your code, speeding up your project.
In other programming languages, these are also referred to as libraries.
Using a Module
To use a module we use the import keyword.
As the name implies we have to tell our program what module to import.
After that, we can use any function available in that module.
Let's see an example using the math module.
First, let's see how to have access to a constant, Euler's number.
import math math.e
2.718281828459045
In this second example, we are going to use a function that calculates the square root of a number.
It is also possible to use the as keyword to create an alias.
import math as m m.sqrt(121) m.sqrt(729)
11 27
Finally, using the from keyword, we can specify exactly what to import instead of the whole module and use the function directly without the module's name.
This example uses the floor() function that returns the largest integer less than or equal to a given number.
from math import floor floor(9.8923)
9
Creating a Module
Now that we know how to use modules, let's see how to create one.
It is going to be a module with the basic math operations add, subtract, multiply, divide and it is gonna be called basic_operations.
Create the basic_operations.py file with the four functions.
def add(first_num, second_num): return first_num + second_num def subtract(first_num, second_num): return first_num - second_num def multiply(first_num, second_num): return first_num * second_num def divide(first_num, second_num): return first_num / second_num
Then, just import the basic_operations module and use the functions.
import basic_operations basic_operations.add(10,2) basic_operations.subtract(10,2) basic_operations.multiply(10,2) basic_operations.divide(10,2)
12 8 20 5.0
if __name__ == '__main__'
You are in the process of building a module with the basic math operations add, subtract, multiply, and divide called basic_operations saved in the basic_operations.py file.
To guarantee everything is fine, you can run some tests.
def add(first_num, second_num): return first_num + second_num def subtract(first_num, second_num): return first_num - second_num def multiply(first_num, second_num): return first_num * second_num def divide(first_num, second_num): return first_num / second_num print(add(10, 2)) print(subtract(10,2)) print(multiply(10,2)) print(divide(10,2))
After running the code:
renan@pro-home:~$ python3 basic_operations.py
The output is:
12 8 20 5.0
The output for those tests are what we expected.
Our code is right and ready to share.
Let's import the new module run it in the Python console.
Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import basic_operations 12 8 20 5.0 >>>
When the module is imported our tests are displayed on the screen even though we didn't do anything besides importing basic_operations.
To fix that we use if __name__ == '__main__' in the basic_operations.py file like this:
def add(first_num, second_num): return first_num + second_num def subtract(first_num, second_num): return first_num - second_num def multiply(first_num, second_num): return first_num * second_num def divide(first_num, second_num): return first_num / second_num if __name__ == '__main__': print(add(10, 2)) print(subtract(10,2)) print(multiply(10,2)) print(divide(10,2))
Running the code directly on the terminal will continue to display the tests. But when you import it like a module, the tests won't show and you can use the functions the way you intended.
Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import basic_operations >>> basic_operations.multiply(10,2) 20 >>>
Now that you know how to use the if __name__ == '__main__', let's understand how it works.
The condition tells when the interpreter is treating the code as a module or as a program itself being executed directly.
Python has this native variable called __name__.
This variable represents the name of the module which is the name of the .py file.
Create a file my_program.py with the following and execute it.
print(__name__)
The output will be:
__main__
This tells us that when a program is executed directly, the variable __name__ is defined as __main__.
But when it is imported as a module, the value of __name__ is the name of the module.
Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import my_program my_program >>>
This is how the Python interpreter differentiates the behavior of an imported module and a program executed directly on the terminal.
Files
Creating, deleting, reading, and many other functions applied to files are an integral part of many programs.
As such, it is very important to know how to organize and deal with files directly from your code.
Let's see how to handle files in Python.
File create
First things first, create!
We are going to use the open() function.
This function opens a file and returns its corresponding object.
The first argument is the name of the file we are handling, the second refers to the operation we are using.
The code below creates the file "people.txt", the x argument is used when we just want to create the file. If a file with the same name already exists, it will throw an exception.
people_file = open("people.txt", "x")
You can also use the w mode to create a file. Unlike the x mode, it will not throw an exception since this mode indicates the writing mode. We are opening a file to write data into it and, if the file doesn't exist, it is created.
people_file = open("people.txt", "w")
The last one is the a mode which stands for append. As the name implies, you can append more data to the file, while the w mode simply overwrites any existing data.
When appending, if the file doesn't exist, it also creates it.
people_file = open("people.txt", "a")
File write
To write data into a file, you simply open a file with the w mode.
Then, to add data, you use the object return by the open() function. In this case, the object is called people_file. Then you call the write() function passing the data as argument.
people_file = open("people.txt", "w") people_file.write("Bob\n") people_file.write("Mary\n") people_file.write("Sarah\n") people_file.close()
We use \n at the end to break the line, otherwise the content in the file will stay in the same line as "BobMarySarah".
One more detail is to close() the file. This is not only a good practice, but also ensures that your changes were applied to the file.
Remember that when using w mode, the data that already existed in the file will be overwritten by the new data. To add new data without losing what was already there, we have to use the append mode.
File append
The a mode appends new data to the file, keeping the existing one.
In this example, after the first writing with w mode, we are using the a mode to append. The result is that each name will appear twice in the file "people.txt".
#first write people_file = open("people.txt", "w") people_file.write("Bob\n") people_file.write("Mary\n") people_file.write("Sarah\n") people_file.close() #appending more data #keeping the existing data people_file = open("people.txt", "a") people_file.write("Bob\n") people_file.write("Mary\n") people_file.write("Sarah\n") people_file.close()
File read
Reading the file is also very straightforward: just use the r mode like so.
If you read the "people.txt" file created in the last example, you should see 6 names in your output.
people_file = open("people.txt", "r") print(people_file.read())
Bob Mary Sarah Bob Mary Sarah
The read() function reads the whole file at once. If you use the readline() function, you can read the file line by line.
people_file = open("people.txt", "r") print(people_file.readline()) print(people_file.readline()) print(people_file.readline())
Bob Mary Sarah
You can also loop to read the lines like the example below.
people_file = open("people.txt", "r") for person in people_file: print(person)
Bob Mary Sarah Bob Mary Sarah
Delete a File
To delete a file, you also need the os module.
Use the remove() method.
import os os.remove('my_file.txt')
Check if a File Exists
Use the os.path.exists() method to check the existence of a file.
import os if os.path.exists('my_file.txt'): os.remove('my_file.txt') else: print('There is no such file!')
Copy a File
For this one, I like to use the copyfile() method from the shutil module.
from shutil import copyfile copyfile('my_file.txt','another_file.txt')
There are a few options to copy a file, but copyfile() is the fastest one.
Rename and Move a File
If you need to move or rename a file you can use the move() method from the shutil module.
from shutil import move move('my_file.txt','another_file.txt')
Classes and Objects
Classes and Objects are the fundamental concepts of Object-Oriented Programming.
In Python, everything is an object!
A variable (object) is just an instance of its type (class).
That's why when you check the type of a variable you can see the class keyword right next to its type (class).
This code snippet shows that my_city is an object and it is an instance of the class str.
my_city = "New York" print(type(my_city))
<class 'str'>
Differentiate Class x Object
The class gives you a standard way to create objects. A class is like a base project.
Say you are an engineer working for Boeing.
Your new mission is to build the new product for the company, a new model called 747-Space. This aircraft flies higher altitudes than other commercial models.
Boeing needs to build dozens of those to sell to airlines all over the world, and the aircrafts have to be all the same.
To guarantee that the aircrafts (objects) follow the same standards, you need to have a project (class) that can be replicable.
The class is a project, a blueprint for an object.
This way you make the project once, and reuse it many times.
In our code example before, consider that every string has the same behavior and the same attributes. So it only makes sense for strings to have a class str to define them.
Attributes and Methods
Objects have some behavior which is is given by attributes and methods.
In simple terms, in the context of an object, attributes are variables and methods are functions attached to an object.
For example, a string has many built-in methods that we can use.
They work like functions, you just need to separate them from the objects using a ..
In this code snippet, I'm calling the replace() method from the string variable my_city which is an object, and an instance of the class str.
The replace() method replaces a part of the string for another and returns a new string with the change. The original string remains the same.
Let's replace 'New' for 'Old' in 'New York'.
my_city = 'New York' print(my_city.replace('New', 'Old')) print(my_city)
Old York New York
Creating a Class
We have used many objects (instances of classes) like strings, integers, lists, and dictionaries. All of them are instances of predefined classes in Python.
To create our own classes we use the class keyword.
By convention, the name of the class matches the name of the .py file and the module by consequence. It is also a good practice to organize the code.
Create a file vehicle.py with the following class Vehicle.
class Vehicle: def __init__(self, year, model, plate_number, current_speed = 0): self.year = year self.model = model self.plate_number = plate_number self.current_speed = current_speed def move(self): self.current_speed += 1 def accelerate(self, value): self.current_speed += value def stop(self): self.current_speed = 0 def vehicle_details(self): return self.model + ', ' + str(self.year) + ', ' + self.plate_number
Let's break down the class to explain it in parts.
The class keyword is used to specify the name of the class Vehicle.
The __init__ function is a built-in function that all classes have. It is called when an object is created and is often used to initialize the attributes, assigning values to them, similar to what is done to variables.
The first parameter self in the __init__ function is a reference to the object (instance) itself. We call it self by convention and it has to be the first parameter in every instance method, as you can see in the other method definitions def move(self), def accelerate(self, value), def stop(self), and def vehicle_details(self).
Vehicle has 5 attributes (including self): year, model, plate_number, and current_speed.
Inside the __init__, each one of them is initialized with the parameters given when the object is instantiated.
Notice that current_speed is initialized with 0 by default, meaning that if no value is given, current_speed will be equal to 0 when the object is first instantiated.
Finally, we have three methods to manipulate our vehicle regarding its speed: def move(self), def accelerate(self, value), and def stop(self).
And one method to give back information about the vehicle: def vehicle_details(self).
The implementation inside the methods work the same way as in functions. You can also have a return to give you back some value at the end of the method as demonstrated by def vehicle_details(self).
Using the Class
To use the class in your terminal, import the Vehicle class from the vehicle module.
Create an instance called my_car, initializing year with 2009, model with 'F8', plate_number with 'ABC1234', and current_speed with 100.
The self parameter is not taken into consideration when calling methods. The Python interpreter infers its value as being the current object/instance automatically, so we just have to pass the other arguments when instantiating and calling methods.
Now use the methods to move() the car which increases its current_speed by 1, accelerate(10) which increases its current_speed by the value given in the argument, and stop() which sets the current_speed to 0.
Remember to print the value of current_speed at every command to see the changes.
To finish the test, call vehicle_details() to print the information about our vehicle.
>>> from vehicle import Vehicle >>> >>> my_car = Vehicle(2009, 'F8', 'ABC1234', 100) >>> print(my_car.current_speed) 100 >>> my_car.move() >>> print(my_car.current_speed) 101 >>> my_car.accelerate(10) >>> print(my_car.current_speed) 111 >>> my_car.stop() >>> print(my_car.current_speed) 0 >>> print(my_car.vehicle_details()) F8, 2009, ABC1234
If we don't set the initial value for current_speed, it will be zero by default as stated before and demonstrated in the next example.
>>> from vehicle import Vehicle >>> >>> my_car = Vehicle(2009, 'F8', 'ABC1234') >>> print(my_car.current_speed) 0 >>> my_car.move() >>> print(my_car.current_speed) 1 >>> my_car.accelerate(10) >>> print(my_car.current_speed) 11 >>> my_car.stop() >>> print(my_car.current_speed) 0 >>> print(my_car.vehicle_details()) F8, 2009, ABC1234
Inheritance
Let's define a generic Vehicle class and save it inside the vehicle.py file.
class Vehicle: def __init__(self, year, model, plate_number, current_speed): self.year = year self.model = model self.plate_number = plate_number self.current_speed = current_speed def move(self): self.current_speed += 1 def accelerate(self, value): self.current_speed += value def stop(self): self.current_speed = 0 def vehicle_details(self): return self.model + ', ' + str(self.year) + ', ' + self.plate_number
A vehicle has attributes year, model, plate_number, and current_speed.
The definition of vehicle in the Vehicle is very generic and might not be suitable for trucks, for instance, because it should include a cargo attribute.
On the other hand, a cargo attribute does not make much sense for small vehicles like motorcycles.
To solve this we can use inheritance.
When a class (child) inherits another class (parent), all the attributes and methods from the parent class are inherited by the child class.
Parent and Child
In our case, we want a new Truck class to inherit everything from the Vehicle class. Then we want it to add its own specific attribute current_cargo to control the addition and removal of cargo from the truck.
The Truck class is called a child class that inherits from its parent class Vehicle.
A parent class is also called a superclass while a child class is also known as a subclass.
Create the class Truck and save it inside the truck.py file.
from vehicle import Vehicle class Truck(Vehicle): def __init__(self, year, model, plate_number, current_speed, current_cargo): super().__init__(year, model, plate_number, current_speed) self.current_cargo = current_cargo def add_cargo(self, cargo): self.current_cargo += cargo def remove_cargo(self, cargo): self.current_cargo -= cargo
Let's break down the class to explain it in parts.
The class Vehicle inside the parentheses when defining the class Truck indicates that the parent Vehicle is being inherited by its child Truck.
The __init__ method has self as its first parameter, as usual.
The parameters year, model, plate_number, and current_speed are there to match the ones in the Vehicle class.
We added a new parameter current_cargo suited for the Truck class.
In the first line of the __init__ method of the Truck class we have to call the __init__ method of the Vehicle class.
To do that we use super() to make a reference to the supperclass Vehicle, so when super().__init__(year, model, plate_number, current_speed) is called we avoid repetition of our code.
After that, we can assign the value of current_cargo normally.
Finally, we have two methods to deal with the current_cargo: def add_cargo(self, cargo):, and def remove_cargo(self, cargo):.
Remember that Truck inherits attributes and methods from Vehicle, so we also have an implicit access to the methods that manipulate the speed: def move(self), def accelerate(self, value), and def stop(self).
Using the Truck class
To use the class in your terminal, import the Truck class from the truck module.
Create an instance called my_truck, initializing year with 2015, model with 'V8', plate_number with 'XYZ1234', current_speed with 0, and current_cargo with 0.
Use add_cargo(10) to increase current_cargo by 10, remove_cargo(4), to decrease current_cargo by 4.
Remember to print the value of current_cargo at every command to see the changes.
By inheritance, we can use the methods from the Vehicle class to move() the truck which increases its current_speed by 1, accelerate(10) which increases its current_speed by the value given in the argument, and stop() which sets the current_speed to 0.
Remember to print the value of current_speed at every interaction to see the changes.
To finish the test, call vehicle_details() inherited from the Vehicle class to print the information about our truck.
>>> from truck import Truck >>> >>> my_truck = Truck(2015, 'V8', 'XYZ1234', 0, 0) >>> print(my_truck.current_cargo) 0 >>> my_truck.add_cargo(10) >>> print(my_truck.current_cargo) 10 >>> my_truck.remove_cargo(4) >>> print(my_truck.current_cargo) 6 >>> print(my_truck.current_speed) 0 >>> my_truck.accelerate(10) >>> print(my_truck.current_speed) 10 >>> my_truck.stop() >>> print(my_truck.current_speed) 0 >>> print(my_truck.vehicle_details()) V8, 2015, XYZ1234
Exceptions
Errors are a part of every programmer's life, and knowing how to deal with them is a skill on its own.
The way Python deals with errors is called 'Exception Handling'.
If some piece of code runs into an error, the Python interpreter will raise an exception.
Types of Exceptions
Let's try to raise some exceptions on purpose and see the errors they produce.
First, try to add a string and an integer
'I am a string' + 32
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: must be str, not int
Now, try to access an index that doesn't exist in a list.
A common mistake is to forget that sequences are 0-indexed, meaning the first item has index 0, not 1.
In this example, the list car_brands ends at index 2.
car_brands = ['ford', 'ferrari', 'bmw'] print(car_brands[3])
Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range
If we try to print a variable that doesn't exist:
print(my_variable)
Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'my_variable' is not defined
Math doesn't allow division by zero, so trying to do so will raise an error, as expected.
32/0
Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero
This was just a sample of the kinds of exceptions you might see during your daily routine and what can cause each of them.
Exception Handling
Now we know how to cause errors that will crash our code and show us some message saying something is wrong.
To handle these exceptions just make use of the try/except statement.
try: 32/0 except: print('Dividing by zero!')
Dividing by zero!
The example above shows the use of the try statement.
Put the block of code that may cause an exception inside the try scope. If everything runs alright, the except block is not invoked. But if an exception is raised, the block of code inside the except is executed.
This way the program doesn't crash and if you have some code after the exception, it will keep running if you want it to.
Specific Exception Handling
In the last example the except block was generic, meaning it was catching anything.
Good practice it to specify the type of exception we are trying to catch, which helps a lot when debugging the code later.
If you know a block of code can throw an IndexError, specify it in the except:
try: car_brands = ['ford', 'ferrari', 'bmw'] print(car_brands[3]) except IndexError: print('There is no such index!')
There is no such index!
You can use a tuple to specify as many exception types as you want in a single except:
try: print('My code!') except(IndexError, ZeroDivisionError, TypeError): print('My Excepetion!')
else
It is possible to add an else command at the end of the try/except. It runs only if there are no exceptions.
my_variable = 'My variable' try: print(my_variable) except NameError: print('NameError caught!') else: print('No NameError')
My variable No NameError
Raising Exceptions
The raise command allows you to manually raise an exception.
This is particularly useful if you want to catch an exception and do something with it -- like logging the error in some personalized way like redirecting it to a log aggregator, or ending the execution of the code since the error should not allow the progress of the program.
try: raise IndexError('This index is not allowed') except: print('Doing something with the exception!') raise
Doing something with the exception! Traceback (most recent call last): File "<stdin>", line 2, in <module> IndexError: This index is not allowed
finally
The finally block is executed independently of exceptions being raised or not.
They are usually there to allow the program to clean up resources like files, memory, network connections, etc.
try: print(my_variable) except NameError: print('Except block') finally: print('Finally block')
Except block Finally block
Conclusion
That's it!
Congratulations on reaching the end.
I want to thank you for reading this article.
If you want to learn more, checkout my blog renanmf.com.
Remember to download a PDF version of this Python Guide for Beginners.
You can also find me on Twitter: @renanmouraf.
via freeCodeCamp.org https://ift.tt/2wM85mu
0 notes
captaindownloadzoneme · 5 years ago
Text
The Best IDE Software
The work of a developer is complex and time-consuming, but arming yourself with the most sophisticated tools makes the job both quicker and easier. That’s why many developers turn to integrated development environments (IDEs) to manage workflows, access a suite of development tools within a single dashboard, and reduce errors that can have catastrophic consequences if deployed unchecked.
IDEs run the gamut from the simple to the incredibly sophisticated, with some aiming for a clutter-free UI in a lightweight tool to maximize speed for smaller-scale tasks and others offering cross-platform, multi-language support in robust environments capable of handling the most complicated development projects.
Read Best IDEs for Web Development
Tumblr media
1. Microsoft Visual Studio
Microsoft Visual Studio is a premium IDE ranging in price from$699 - $2,900 depending on the edition and licensing. The many editions of this IDE are capable of creating all types of programs ranging from web applications to mobile apps to video games. This series of software includes tons of tools for compatibility testing so that you can see how your apps run on more than 300 devices and browsers. Thanks to its flexibility, Visual Studio is a great tool for both students and professionals.
Features:
A massive library of extensions that is always growing
IntelliSense
Customizable dashboard and dockable windows
Straightforward workflow and file hierarchy
Insights for monitoring performance in real-time
Automation tools
Easy refactoring and code snippet insertion
Split-screen support
Error list that allows debugging while building
Approval checks when deploying apps via ClickOnce, Windows Installer or Publish Wizard
Drawbacks:
 Because the Visual Studio is a heavyweight IDE, it takes considerable resources to open and run, so making simple edits may be time-consuming on some devices. For a simpler task, it may be easier to use a lightweight editor.
2. NetBeans
A free, open-source Integrated Development Environment for software developers. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java language, C/C++, and even dynamic languages such as PHP, JavaScript, Groovy, and Ruby. Apache NetBeans is easy to install and use straight out of the box and runs on many platforms including Windows, Linux, Mac OS X, and Solaris.
Tumblr media
Features:
Intuitive drag-and-drop interface
Dynamic and static libraries
Multi-session GNU debugger integration with code assistance
Allows for remote development
Compatible with Windows, Linux, OS X, and Solaris platforms
Supports Qt Toolkit
Supports Fortran and Assembler files
Supports a number of compilers including CLang/LLVM, Cygwin, GNU, MinGW, and Oracle Solaris Studio
Drawbacks: 
This free IDE consumes a lot of memory, so it may perform sluggishly on some machines.
3. PyCharm
PyCharm Community for PC is a free Python IDE with the complete set of tools for productive development with the Python programming language. In addition, the IDE provides high-class capabilities for professional Web development with the Django framework. Intelligent PC Python IDE with refactorings, debugger, code completion, on-the-fly code analysis, and coding productivity orientation.
Notable Features:
Compatible with Windows, Linux, and Mac OS
Comes with Django IDE
Easy to integrate with Git, Mercurial, and SVN
Customizable interface with VIM emulation
JavaScript, Python and Django debuggers
Supports Google App Engine
Drawbacks: 
Users complain that PyCharm has some bugs, such as the autocomplete feature occasionally not working, which can be a minor inconvenience.
4.IntelliJ IDEA
IntelliJ IDEA is a powerful Java integrated development environment(IDE) for developing computer software for Windows PC. Every aspect of IntelliJ IDEA is specifically designed to maximize developer productivity. Together, powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience.
Features:
Extensive database editor and UML designer
Supports multiple build systems
Test runner UI
Code coverage
Git integration
Supports Google App Engine, Grails, GWT, Hibernate, Java EE, OSGi, Play, Spring, Struts and more
Deployment and debugging tools for most application servers
Intelligent text editors for HTML, CSS, and Java
Integrated version control
AIR Mobile supports Android and iOS devices
Drawbacks: 
This IDE comes with a learning curve, so it may not the best for beginners. There are many shortcuts to remember, and some users complain about the clunky UI
5. RStudio
RStudio is an integrated development environment (IDE) for R. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management. RStudio is available in open source and commercial editions and runs on the desktop (Windows, Mac, and Linux) or in a browser connected to RStudio Server or RStudio Server Pro (Debian/Ubuntu, RedHat/CentOS, and SUSE Linux).
Tumblr media
Features:
Syntax highlighting, code completion, and smart indentation
Execute R code directly from the source editor
Quickly jump to function definitions
Integrated R help and documentation
Easily manage multiple working directories using projects
Workspace browser and data viewer
Interactive debugger to diagnose and fix errors quickly
Extensive package development tools
Authoring with Sweave and R Markdown
Drawbacks:
Most Git operations have to get handled via the command line.
Read: Which are better for developers, IDEs or text editors?
0 notes