Download Effective Python: 59 Specific Ways to Write Better Python by Brett Slatkin PDF

By Brett Slatkin

ISBN-10: 0134034287

ISBN-13: 9780134034287

“Each merchandise in Slatkin’s Effective Python teaches a self-contained lesson with its personal resource code. This makes the ebook random-access: goods are effortless to browse and examine in no matter what order the reader wishes. i'll be recommending Effective Python to scholars as an admirably compact resource of mainstream recommendation on a really vast diversity of issues for the intermediate Python programmer.”
Brandon Rhodes, software program engineer at Dropbox and chair of PyCon 2016-2017

It’s effortless to begin coding with Python, that's why the language is so renowned. although, Python’s precise strengths, charms, and expressiveness might be challenging to know, and there are hidden pitfalls which may simply journey you up.

Effective Python can assist you grasp a really “Pythonic” method of programming, harnessing Python’s complete energy to put in writing tremendously strong and well-performing code. utilizing the concise, scenario-driven kind pioneered in Scott Meyers’ best-selling Effective C++, Brett Slatkin brings jointly fifty nine Python most sensible practices, suggestions, and shortcuts, and explains them with life like code examples.

Drawing on years of expertise construction Python infrastructure at Google, Slatkin uncovers little-known quirks and idioms that powerfully effect code habit and function. You’ll research how one can accomplish key projects, so that you can write code that’s more straightforward to appreciate, preserve, and improve.

Key gains include

  • Actionable directions for all significant components of Python 3.x and 2.x improvement, with distinctive factors and examples
  • Best practices for writing services that make clear goal, advertise reuse, and steer clear of bugs
  • Coverage of the way to competently convey behaviors with periods and objects
  • Guidance on find out how to stay away from pitfalls with metaclasses and dynamic attributes
  • More effective techniques to concurrency and parallelism
  • Better innovations and idioms for utilizing Python’s integrated modules
  • Tools and most sensible practices for collaborative development
  • Solutions for debugging, checking out, and optimization to be able to enhance caliber and performance

Show description

Read Online or Download Effective Python: 59 Specific Ways to Write Better Python PDF

Best python books

Learning Python: Powerful Object-Oriented Programming (4th Edition)

Google and YouTube use Python simply because it's hugely adaptable, effortless to take care of, and enables swift improvement. so that you can write fine quality, effective code that's simply built-in with different languages and instruments, this hands-on ebook may help you be efficient with Python fast -- even if you're new to programming or simply new to Python.

Real Python: An Introduction to Python Through Practical Examples

An book to educate programming via hands-on, attention-grabbing examples which are worthy and fun!

Python is a smart programming language. It's loose, strong, more straightforward to learn than such a lot languages, and has extensions to be had to do nearly something you may think automatically.

But how do you certainly use it? There are a whole lot assets in the market for studying Python, yet none of them are very useful or fascinating - as an alternative, they move over each one proposal one after the other, by no means tying whatever jointly, yet spending lots of time misplaced in technical language, discussing the twenty alternative ways to complete each one simple job. ..

I are looking to write an booklet that eventually provides a concise creation to every little thing you could truly are looking to do with Python.

We'll commence with a short yet thorough evaluation of the entire fundamentals, so that you don't even desire any past adventure with programming. however the majority of the ebook may be spent build up instance code to unravel fascinating real-world problems.

Python is astounding for automating repetitive initiatives that may another way take you hours - for example, fast collecting facts from the net, or renaming hundreds and hundreds of documents. many of the subject matters that I'm making plans to cover:

Collecting info from webpages (web scraping)
Interacting with PDF records - studying information, developing PDFs, enhancing pages, including passwords. ..
Interacting with Excel records (less performance in OS X)
Calling different open air courses from inside of Python
Files - read/write/modify, unzip, rename, circulation, etc.
Basic online game development
Interacting with SQL databases (internal and ODBC connections)
GUI (Graphical consumer Interface) layout - developing basic point-and-click courses that anybody can use
Any different themes that you just, my backers, are so much in!
Update: through well known call for, I'll be including net software development

All comparable path fabrics downloadable at: http://www. psychotix. com/share/Real_Python. zip

Python Algorithms: Mastering Basic Algorithms in the Python Language

Python Algorithms explains the Python method of set of rules research and layout.

Written through Magnus Lie Hetland, writer of starting Python, this publication is sharply keen on classical algorithms, however it additionally supplies a superb figuring out of primary algorithmic problem-solving ideas.

The publication offers with the most vital and tough components of programming and machine technological know-how, yet in a hugely pedagogic and readable manner.

The publication covers either algorithmic thought and programming perform, demonstrating how concept is mirrored in genuine Python programs.

Well-known algorithms and information buildings which are equipped into the Python language are defined, and the person is proven the way to enforce and review others himself.

Testing Python: Applying Unit Testing, TDD, BDD and Acceptance Testing

Primary checking out methodologies utilized to the preferred Python language

Testing Python; utilising Unit checking out, TDD, BDD and attractiveness trying out is the main complete publication on hand on checking out for one of many most sensible software program programming languages on the earth. Python is a average selection for brand new and skilled builders, and this hands-on source is a miles wanted advisor to enterprise-level trying out improvement methodologies. The ebook will convey you why Unit checking out and TDD can result in purifier, extra versatile programs.

Unit checking out and Test-Driven improvement (TDD) are more and more must-have abilities for software program builders, it doesn't matter what language they paintings in. In firm settings, it's serious for builders to make sure they constantly have operating code, and that's what makes checking out methodologies so beautiful. This booklet will educate you the main prevalent trying out suggestions and should introduce to you to nonetheless others, protecting functionality checking out, non-stop trying out, and more.

Learn Unit trying out and TDD—important improvement methodologies that lie on the middle of Agile development
Enhance your skill to paintings with Python to boost robust, versatile functions with fresh code
Draw at the services of writer David Sale, a number one united kingdom developer and tech commentator
Get sooner than the gang by way of gaining knowledge of the underappreciated international of Python testing
Knowledge of software program checking out in Python may set you except Python builders utilizing superseded methodologies. Python is a common healthy for TDD and trying out Python is a must-read textual content for someone who desires to strengthen services in Python programming.

Additional resources for Effective Python: 59 Specific Ways to Write Better Python

Example text

We know this because in interactive interpreter mode an expression is printed out to the screen. >>> x = y = z = 3 >>> x = z >>> x==z 1 As you can see, x = z and x = y = z = 3 aren't printed to the screen, which means that they don't return a value and so are not expressions. In Python, the use of the comparison operator (==), not the assignment operator, is what makes a statement an expression. This is because the == returns a value, usually 1 or 0, whereas = doesn't. In Java, C, and C++, an assignment is an expression, which is why confusing the assignment and comparison operators is a common programmer error (mostly in C and C++; Java has its own way of dealing with this problem).

The result is shown in the second example. Remember, an empty list indicates false. >>> def checkSeq(seq): ... if (seq): ... print "has item" ... else : ... print "empty" ... >>> non_empty_list = [1,2,3] >>> empty_list = [] >>> checkSeq(empty_list) empty >>> checkSeq(non_empty_list) has item Typically, if statements contain expressions that use comparison and logical operators. To illustrate, let's say that a woman is looking for her perfect man tall, dark, and handsome; the strong, quiet type between the ages of 27 and 35.

Note that the tuple argument containing a single item can be denoted with the % operator as item, or (item). Table 3-6. ' %cASCII character >>> "%c" % (97) 'a' >>> "%c" % 97 'a' >>> "%c" % (97) 'a' Table 3-7 shows how flags can be used with the format directives to add leading zeroes or spaces to a formatted number. They should be inserted immediately after the %. 56 57 Table 3-7. Format Directive Flags Flag Description Interactive Session#Forces octal to have a 0 prefix; forces hex to have a 0x prefix >>> "%#x" % 0xff '0xff' >>> "%#o" % 0377 '0ff' +Forces a positive number to have a sign >>> "%+d" % 100 '+100' -Left justification (default is right) >>> "%-5d, %-5d" % (10,10) '10 , 10 ' " "Precedes a positive number with a blank space >>> "% d,% d" % (-10, 10) '-100,10' 00 padding instead of spaces >>> "%05d" % (100,) '00100' Advanced Topic: Using the %d, %i, %f, and %e Directives for Formatting Numbers The % directives format numeric types: %i works with Integer; %f and %e work with Float with and without scientific notation, respectively.

Download PDF sample

Rated 4.97 of 5 – based on 26 votes