SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
Python Quick Reference
                   OPERATOR PRECEDENCE IN EXPRESSIONS
  Operator                     Description                                       A
 `expr,...`                    String conversion                                 NA
 {key:expr,...}                Dictionary creation                               NA
 [expr,...]                    List creation                                     NA
 (expr,...)                    Tuple creation or simple parentheses              NA
 f(expr,...)                   Function call                                     L
 x[index:index]                Slicing                                           L
 x[index]                      Indexing                                          L
 x.attr                        Attribute reference                               L
 x**y                          Exponentiation (x to yth power)                   R
 ~x                            Bitwise NOT                                       NA
 +x, -x                        Unary plus and minus                              NA
 x*y, x/y, x//y, x%y           Multiplication, division, remainder               L
 x+y, x-y                      Addition, subtraction                             L
 x<<y, x>>y                    Left-shift, right-shift                           L
 x&y                           Bitwise AND                                       L
 x^y                           Bitwise XOR                                       L
 x|y                           Bitwise OR                                        L
 x<y, x<=y, x>y, x>=y          Comparisons                                       C
 x<>y, x!=y, x==y              Equality/inequality tests*                        C
 x is y, x is not y            Identity tests                                    C
 x in y, x not in y            Membership tests                                  C
 not x                         Boolean NOT                                       NA
 x and y                       Boolean AND                                       L
 x or y                        Boolean OR                                        L
 lambda arg,...: expr          Anonymous simple function                         NA
* x!=y and x<>y are the same inequality test (!= is the preferred form, <> obsolete)
A – Associativity L – Left R – Right C – Chaining NA – Not associative

                              LIST OBJECT METHODS
 Operator            Description
 L.count(x)        Returns the number of occurrences of x in L
 L.index(x)        Returns the index of the first occurrence of x in L or raises an
                   exception if L has no such item
 L.append(x)       Appends x to the end of L
 L.extend(l)       Appends all the items of list l to the end of L
 L.insert(i,x)     Inserts x at index i in L
 L.remove(x)       Removes the first occurrence of
                   x from L
 L.pop(i=-1)       Returns the value of the item at
                   index i and removes it from L
 L.reverse( )      Reverses, in-place, the items of L
 L.sort(f=cmp)     Sorts, in-place, the items of L,
                   comparing items by f

   Excerpted from Python in a Nutshell




              www.oreilly.com
Python Quick Reference
                           COMMON FILE OPERATIONS
  Operation                      Interpretation
 output = open('/tmp/spam', 'w') Create output file ('w' means write).
 input = open('data', 'r')       Create input file ('r' means read).
 S = input.read( )               Read entire file into a single string.
 S = input.read(N)               Read N bytes (1 or more).
 S = input.readline( )           Read next line (through end-line marker).
 L = input.readlines( )          Read entire file into list of line strings.
 output.write(S)                 Write string S into file.
 output.writelines(L)            Write all line strings in list L into file.
 output.close( )                 Manual close (done for you when file
                                 collected).

              COMMON DICTIONARY LITERALS AND OPERATIONS
  Operation                            Interpretation
 D1 = { }                              Empty dictionary
 D2 = {'spam': 2, 'eggs': 3}           Two-item dictionary
 D2['eggs']                            Indexing by key
 D2.has_key('eggs'), 'eggs' in D2      membership test
 D2.keys( ), D2.values( ), D2.items( ) lists of keys, values, items
 D2.copy( ), D2.update(D1)             shallow copy, dict merging
 D2.get(key, default=None)             quot;indexingquot; w/default value
 len(D1)                               Length (number stored entries)
 D2[key] = 42                          Adding/changing,
 del D2[key]                           deleting
 D4 = dict(zip(keyslist, valslist))    Construction

                   COMMON TUPLE LITERALS AND OPERATIONS
  Operation                   Interpretation
 ()                           An empty tuple
 T1 = (0,)                    A one-item tuple (not an expression)
 T2 = (0, 'Ni', 1.2, 3)       A four-item tuple
 T2 = 0, 'Ni', 1.2, 3         Another four-item tuple (same as prior line)
 T1[i]                        Indexing
 T1[i:j]                      slicing
 len(t1)                      length (number of items)
 T1 + T2                      Concatenation
 T2 * 3                       repetition
 for x in T2                  Iteration
 3 in T2                      member-
                              ship test

             Excerpted from Learning
                  Python, 2nd Edition




           www.oreilly.com
©2004 O’Reilly Media, Inc. O’Reilly logo is a registered trademark of
O’Reilly Media Inc. All other trademarks are property of their respective owners. #40055

Mais conteúdo relacionado

Mais procurados

Thinking in Functions: Functional Programming in Python
Thinking in Functions: Functional Programming in PythonThinking in Functions: Functional Programming in Python
Thinking in Functions: Functional Programming in PythonAnoop Thomas Mathew
 
Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Bryan O'Sullivan
 
Scala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data TypeScala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data TypePhilip Schwarz
 
Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Bryan O'Sullivan
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Philip Schwarz
 
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...Philip Schwarz
 
Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Vadim Dubs
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional ProgrammingHugo Firth
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...Philip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Philip Schwarz
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Bryan O'Sullivan
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Bryan O'Sullivan
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Philip Schwarz
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With ScalaKnoldus Inc.
 
Humble introduction to category theory in haskell
Humble introduction to category theory in haskellHumble introduction to category theory in haskell
Humble introduction to category theory in haskellJongsoo Lee
 

Mais procurados (20)

Thinking in Functions: Functional Programming in Python
Thinking in Functions: Functional Programming in PythonThinking in Functions: Functional Programming in Python
Thinking in Functions: Functional Programming in Python
 
Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6
 
Scala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data TypeScala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data Type
 
Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Real World Haskell: Lecture 3
Real World Haskell: Lecture 3
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
 
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
 
Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
 
Ch03
Ch03Ch03
Ch03
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Real World Haskell: Lecture 5
Real World Haskell: Lecture 5
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With Scala
 
Humble introduction to category theory in haskell
Humble introduction to category theory in haskellHumble introduction to category theory in haskell
Humble introduction to category theory in haskell
 
Python list
Python listPython list
Python list
 

Semelhante a python

Functional programming in f sharp
Functional programming in f sharpFunctional programming in f sharp
Functional programming in f sharpchribben
 
High Wizardry in the Land of Scala
High Wizardry in the Land of ScalaHigh Wizardry in the Land of Scala
High Wizardry in the Land of Scaladjspiewak
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisSilvio Cesare
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Sheik Uduman Ali
 
UNIT 1 - Revision of Basics - II.pptx
UNIT 1 - Revision of Basics - II.pptxUNIT 1 - Revision of Basics - II.pptx
UNIT 1 - Revision of Basics - II.pptxNishanSidhu2
 
Sequence and Traverse - Part 3
Sequence and Traverse - Part 3Sequence and Traverse - Part 3
Sequence and Traverse - Part 3Philip Schwarz
 
R Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfR Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfTimothy McBush Hiele
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structuresMohd Arif
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docSrikrishnaVundavalli
 
Model-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error CheckingModel-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error CheckingEelco Visser
 
Testing for share
Testing for share Testing for share
Testing for share Rajeev Mehta
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming iiPrashant Kalkar
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxlemonchoos
 

Semelhante a python (20)

Functional programming in f sharp
Functional programming in f sharpFunctional programming in f sharp
Functional programming in f sharp
 
02python.ppt
02python.ppt02python.ppt
02python.ppt
 
02python.ppt
02python.ppt02python.ppt
02python.ppt
 
High Wizardry in the Land of Scala
High Wizardry in the Land of ScalaHigh Wizardry in the Land of Scala
High Wizardry in the Land of Scala
 
Introducing scala
Introducing scalaIntroducing scala
Introducing scala
 
Scala Bootcamp 1
Scala Bootcamp 1Scala Bootcamp 1
Scala Bootcamp 1
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
 
UNIT 1 - Revision of Basics - II.pptx
UNIT 1 - Revision of Basics - II.pptxUNIT 1 - Revision of Basics - II.pptx
UNIT 1 - Revision of Basics - II.pptx
 
Sequence and Traverse - Part 3
Sequence and Traverse - Part 3Sequence and Traverse - Part 3
Sequence and Traverse - Part 3
 
R Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfR Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdf
 
scripting in Python
scripting in Pythonscripting in Python
scripting in Python
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.doc
 
Ch5a
Ch5aCh5a
Ch5a
 
Model-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error CheckingModel-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error Checking
 
Testing for share
Testing for share Testing for share
Testing for share
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptx
 

Mais de webuploader

Michael_Hulme_Banff_Social_Networking
Michael_Hulme_Banff_Social_NetworkingMichael_Hulme_Banff_Social_Networking
Michael_Hulme_Banff_Social_Networkingwebuploader
 
cyberSecurity_Milliron
cyberSecurity_MillironcyberSecurity_Milliron
cyberSecurity_Millironwebuploader
 
LiveseyMotleyPresentation
LiveseyMotleyPresentationLiveseyMotleyPresentation
LiveseyMotleyPresentationwebuploader
 
FairShare_Morningstar_022607
FairShare_Morningstar_022607FairShare_Morningstar_022607
FairShare_Morningstar_022607webuploader
 
3_System_Requirements_and_Scaling
3_System_Requirements_and_Scaling3_System_Requirements_and_Scaling
3_System_Requirements_and_Scalingwebuploader
 
ScalabilityAvailability
ScalabilityAvailabilityScalabilityAvailability
ScalabilityAvailabilitywebuploader
 
scale_perf_best_practices
scale_perf_best_practicesscale_perf_best_practices
scale_perf_best_practiceswebuploader
 
7496_Hall 070204 Research Faculty Summit
7496_Hall 070204 Research Faculty Summit7496_Hall 070204 Research Faculty Summit
7496_Hall 070204 Research Faculty Summitwebuploader
 
FreeBSD - LinuxExpo
FreeBSD - LinuxExpoFreeBSD - LinuxExpo
FreeBSD - LinuxExpowebuploader
 

Mais de webuploader (20)

Michael_Hulme_Banff_Social_Networking
Michael_Hulme_Banff_Social_NetworkingMichael_Hulme_Banff_Social_Networking
Michael_Hulme_Banff_Social_Networking
 
socialpref
socialprefsocialpref
socialpref
 
cyberSecurity_Milliron
cyberSecurity_MillironcyberSecurity_Milliron
cyberSecurity_Milliron
 
PJO-3B
PJO-3BPJO-3B
PJO-3B
 
LiveseyMotleyPresentation
LiveseyMotleyPresentationLiveseyMotleyPresentation
LiveseyMotleyPresentation
 
FairShare_Morningstar_022607
FairShare_Morningstar_022607FairShare_Morningstar_022607
FairShare_Morningstar_022607
 
saito_porcupine
saito_porcupinesaito_porcupine
saito_porcupine
 
3_System_Requirements_and_Scaling
3_System_Requirements_and_Scaling3_System_Requirements_and_Scaling
3_System_Requirements_and_Scaling
 
ScalabilityAvailability
ScalabilityAvailabilityScalabilityAvailability
ScalabilityAvailability
 
scale_perf_best_practices
scale_perf_best_practicesscale_perf_best_practices
scale_perf_best_practices
 
7496_Hall 070204 Research Faculty Summit
7496_Hall 070204 Research Faculty Summit7496_Hall 070204 Research Faculty Summit
7496_Hall 070204 Research Faculty Summit
 
Chapter5
Chapter5Chapter5
Chapter5
 
Mak3
Mak3Mak3
Mak3
 
visagie_freebsd
visagie_freebsdvisagie_freebsd
visagie_freebsd
 
freebsd-watitis
freebsd-watitisfreebsd-watitis
freebsd-watitis
 
BPotter-L1-05
BPotter-L1-05BPotter-L1-05
BPotter-L1-05
 
FreeBSD - LinuxExpo
FreeBSD - LinuxExpoFreeBSD - LinuxExpo
FreeBSD - LinuxExpo
 
CLI313
CLI313CLI313
CLI313
 
CFInterop
CFInteropCFInterop
CFInterop
 
WCE031_WH06
WCE031_WH06WCE031_WH06
WCE031_WH06
 

Último

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Último (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

python

  • 1. Python Quick Reference OPERATOR PRECEDENCE IN EXPRESSIONS Operator Description A `expr,...` String conversion NA {key:expr,...} Dictionary creation NA [expr,...] List creation NA (expr,...) Tuple creation or simple parentheses NA f(expr,...) Function call L x[index:index] Slicing L x[index] Indexing L x.attr Attribute reference L x**y Exponentiation (x to yth power) R ~x Bitwise NOT NA +x, -x Unary plus and minus NA x*y, x/y, x//y, x%y Multiplication, division, remainder L x+y, x-y Addition, subtraction L x<<y, x>>y Left-shift, right-shift L x&y Bitwise AND L x^y Bitwise XOR L x|y Bitwise OR L x<y, x<=y, x>y, x>=y Comparisons C x<>y, x!=y, x==y Equality/inequality tests* C x is y, x is not y Identity tests C x in y, x not in y Membership tests C not x Boolean NOT NA x and y Boolean AND L x or y Boolean OR L lambda arg,...: expr Anonymous simple function NA * x!=y and x<>y are the same inequality test (!= is the preferred form, <> obsolete) A – Associativity L – Left R – Right C – Chaining NA – Not associative LIST OBJECT METHODS Operator Description L.count(x) Returns the number of occurrences of x in L L.index(x) Returns the index of the first occurrence of x in L or raises an exception if L has no such item L.append(x) Appends x to the end of L L.extend(l) Appends all the items of list l to the end of L L.insert(i,x) Inserts x at index i in L L.remove(x) Removes the first occurrence of x from L L.pop(i=-1) Returns the value of the item at index i and removes it from L L.reverse( ) Reverses, in-place, the items of L L.sort(f=cmp) Sorts, in-place, the items of L, comparing items by f Excerpted from Python in a Nutshell www.oreilly.com
  • 2. Python Quick Reference COMMON FILE OPERATIONS Operation Interpretation output = open('/tmp/spam', 'w') Create output file ('w' means write). input = open('data', 'r') Create input file ('r' means read). S = input.read( ) Read entire file into a single string. S = input.read(N) Read N bytes (1 or more). S = input.readline( ) Read next line (through end-line marker). L = input.readlines( ) Read entire file into list of line strings. output.write(S) Write string S into file. output.writelines(L) Write all line strings in list L into file. output.close( ) Manual close (done for you when file collected). COMMON DICTIONARY LITERALS AND OPERATIONS Operation Interpretation D1 = { } Empty dictionary D2 = {'spam': 2, 'eggs': 3} Two-item dictionary D2['eggs'] Indexing by key D2.has_key('eggs'), 'eggs' in D2 membership test D2.keys( ), D2.values( ), D2.items( ) lists of keys, values, items D2.copy( ), D2.update(D1) shallow copy, dict merging D2.get(key, default=None) quot;indexingquot; w/default value len(D1) Length (number stored entries) D2[key] = 42 Adding/changing, del D2[key] deleting D4 = dict(zip(keyslist, valslist)) Construction COMMON TUPLE LITERALS AND OPERATIONS Operation Interpretation () An empty tuple T1 = (0,) A one-item tuple (not an expression) T2 = (0, 'Ni', 1.2, 3) A four-item tuple T2 = 0, 'Ni', 1.2, 3 Another four-item tuple (same as prior line) T1[i] Indexing T1[i:j] slicing len(t1) length (number of items) T1 + T2 Concatenation T2 * 3 repetition for x in T2 Iteration 3 in T2 member- ship test Excerpted from Learning Python, 2nd Edition www.oreilly.com ©2004 O’Reilly Media, Inc. O’Reilly logo is a registered trademark of O’Reilly Media Inc. All other trademarks are property of their respective owners. #40055