id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
500 | probably get an error messagebut it' worth checking to see if the version you want is already installed using homebrew to install python if you only have python installedor if you have an older version of python you can install the latest version of python using package called homebrew installing homebrew homebrew depe... |
501 | python and you can use the python command to configure your text editor so it runs python programs with python instead of python python on windows python isn' usually included by default on windowsbut it' worth checking to see if it exists on the system open terminal window by rightclicking on your desktop while holdin... |
502 | it' annoying to type the full path each time you want to start python terminalso we'll add the path to the system so you can just use the command python if you already checked the add python to path box when installingyou can skip this step open your system' control panelchoose system and securityand then choose system... |
503 | you won' get an error if you use one of the following readily available built-in functions as variable namebut you'll override the behavior of that functionabs(all(any(basestring(bin(bool(bytearray(callable(chr(classmethod(cmp(compile(complex(delattr(dict(dir(note appendix divmod(input(enumerate(int(eval(isinstance(exe... |
504 | edi programmers spend lot of time writingreadingand editing codeand using text editor that makes this work as efficient as possible is essential an efficient editor should highlight the structure of your code so you can catch common bugs as you're working it should also include automatic indentingmarkers to show approp... |
505 | you spend more time programming we'll use hello_world py as an example program to run in each editor geany geany is simple text editor that lets you run almost all of your programs directly from the editor it also displays your output in terminal windowwhich helps you get comfortable using terminals installing geany on... |
506 | compile and execute with command next to each each of these commands starts with python (in lowercase)but geany doesn' know where your system stored the python command you need to add the path you use when starting terminal session (you can skip these steps if you set the path variable as described in appendix in the c... |
507 | most editors allow you to set up visual cueusually vertical lineto show where your lines should end set this feature by selecting edit preferences editor displayand make sure that long line marker is enabled then make sure the value of column is set to indenting and unindenting code blocks to indent block of codehighli... |
508 | download an installer for windows from run the installerand you should see sublime text in your start menu running python programs in sublime text if you're using the version of python that came with your systemyou'll probably be able to run your programs without adjusting any settings to run programsgo to tools build ... |
509 | now we'll set up sublime text to be as efficient as possible by customizing the features mentioned at the beginning of this appendix converting tabs to spaces go to view indentation and make sure there' check mark next to indent using spaces if there isn'tcheck it setting the line length indicator go to view rulerand t... |
510 | the instructions thereyou'll also need to install few graphical packages that idle depends on installing idle on windows idle should have been installed automatically when you installed python you should find it in your start menu customizing idle settings because it' the default python editormost of the settings in id... |
511 | get ting help everyone gets stuck at some point when they're learning to programand one of the most important skills to learn as programmer is how to get unstuck efficiently this appendix outlines several ways to help you get unstuck when programming gets confusing first steps when you're stuckyour first step should be... |
512 | explicit statements like " ' trying to install the latest version of python on my windows machineare detailed enough for others in the python community to help you statements like " ' trying to install pythondon' provide enough information for others to offer much help your answer to the second question should provide ... |
513 | chances are that someone else has had the same problem you're having and has written about it online good searching skills and specific inquiries will help you find existing resources to solve the issue you're facing for exampleif you're struggling to install python on windows searching python windows might direct you ... |
514 | if you're using specific librarysuch as pygamematplotlibdjangoand so onlinks to the official documentation for that project will often appear in searches--for exampleplanning to work with any of these librariesit' good idea to become familiar with the official documentation /learnpython reddit is made up of number of s... |
515 | to join the main python channelenter /join #python in the input box you'll see confirmation that you joined the channel and some general information about the channel the channel ##learnpython (with two hashtagsis usually quite active as well this channel is associated with see messages about posts on /learnpython too ... |
516 | gi version control software allows you to take snapshots of project whenever it' in working state when you make changes to project--for examplewhen you implement new feature--you have the option of reverting back to previous working state if the project' current state isn' functioning well using version control softwar... |
517 | solo developers git implements version control by tracking the changes made to every file in projectif you make mistakeyou can just return to previously saved state installing git git runs on all operating systemsbut there are different approaches to installing it on each system the following sections provide specific ... |
518 | let' make project to work with create folder somewhere on your system called git_practice inside the foldermake simple python programhello_world py print("hello git world!"we'll use this program to explore git' basic functionality ignoring files files with the extension pyc are automatically generated from py filesso w... |
519 | before doing anything elselet' look at the status of the projectgit_practicegit status on branch master initial commit untracked files(use "git add to include in what will be committedgitignore hello_world py nothing added to commit but untracked files present (use "git addto trackgit_practicein gita branch is version ... |
520 | committed the label new file means these files were newly added to the repository making commit let' make the first commitu git_practicegit commit - "started project [master (root-commitc started project files changed insertion(+create mode gitignore create mode hello_world py git_practicegit status on branch master no... |
521 | informationthe reference id of the commit and the message recorded for the commit the second commit to see the real power of version controlwe need to make change to the project and commit that change here we'll just add another line to hello_world pyhello_world py print("hello git world!"print("hello everyone "if we c... |
522 | now let' see how to abandon change and revert back to the previous working state firstadd new line to hello_world pyhello_world py print("hello git world!"print("hello everyone "print("oh noi broke the project!"save and run this file we check the status and see that git notices this changegit_practicegit status on bran... |
523 | changes and manually undo them git does all of that for you note you might have to click in your editor' window to refresh the file and see the previous version checking out previous commits you can check out any commit in your lognot just the most recentby including the first six characters of the reference id instead... |
524 | recent commits and go back to previous stateyou can reset the project to previous commit working from the master branchenter the followingu git_practicegit status on branch master nothing to commitworking directory clean git_practicegit log --pretty=oneline cb cff bd ab ed extended greeting be dbc ff be fd started proj... |
525 | on branch master initial commit untracked files(use "git add to include in what will be committedgitignore hello_world py nothing added to commit but untracked files present (use "git addto trackz git_practicegit add git_practicegit commit - "starting over [master (root-commit starting over files changed insertions(+cr... |
526 | symbols (addition) (asteriskoperator bmp (bitmapimage files (concatenation operator) - (division) =(equality operator) (greater than) >(greater than or equal to) (hash mark)for comments !(inequality operator) (less than) <(less than or equal to) (modulo operator) - (multiplication) \ (newline) (not) +operator py file e... |
527 | play button adding - button class deactivating drawing hiding the mouse cursor resetting the game starting the game reviewing scoring displaying the level - displaying the number of ships - displaying the score increasing point values making scoring system - rounding and formatting the score scoreboard class scoring al... |
528 | all classes from module - entire module module into module - multiple classes - single class - inheritance - attributes and methods - __init__(method - instances as attributes - overriding methods in python super(function methods calling __init()__ modeling real-world objects - multiple instancescreating styling guidel... |
529 | data associating with user connecting to users restricting access to - databases creating foreign keys many-to-one relationships migrating - queries querysets forms - cross-site request forgery displaying get and post requests modelform processing validation widgets hashes (for passwords) http error installed_appsmodif... |
530 | working with contents writing to by appending empty files multiple lines flags floats - foods py - for loops - functions arguments - arbitrary - avoiding errors with - keyword - lists as - optional - order of positional arguments - built-in calling - multiple times - defining dictionariesreturning - import statements l... |
531 | making an account procfile projects deleting pushing to securing python runtimespecifying settings pymodifying for superusercreating toolbeltinstalling user-friendly urls wsgi pymodifying for hex formatfor colors highs_lows py - hn_submissions py - homebrew idle - commenting out code customizing settings installing on ... |
532 | secret_key setting using gunicorn locally html headersdefining logging out - login page - migrating the database - styling bootstrap collapsible navigation jumbotron navigation bar - selectors registration page - users app default login view displaying messages to logged-in users logging in user usercreationform len(fu... |
533 | classes modelform modules - aliases for functions aliases for importing all importing specific importing an entire module modulo operator (%) - motorcycles py - mountain_poll py mpl_squares py - multiplication (*) my_car py my_cars py - my_electric_car py name errors - name_function py - name py - names py na_populatio... |
534 | print statements long in python privileges procfile project gutenberg promptsfor user input - py file extension pygal charts histograms - linksadding styling - tooltipsadding color themes installing plotting dictionaries rolling dice worldmap - grouping countries - plotting numerical data - styling - pygame see also al... |
535 | debugging tips - documentation - irc (internet relay chat) - channels culture making an account reddit stack overflow return values rollercoaster py rolling dice analyzing results different sizes two dice rubber duck debugging rw_visual py - scatter_squares py - secret_key setting setup(method sitkaalaskaweather data -... |
536 | preface xxxiii part getting started python & session why do people use pythonsoftware quality developer productivity is python "scripting language"okbut what' the downsidewho uses python todaywhat can do with pythonsystems programming guis internet scripting component integration database programming rapid prototyping ... |
537 | summary test your knowledgequiz test your knowledgeanswers how python runs programs introducing the python interpreter program execution the programmer' view python' view execution model variations python implementation alternatives execution optimization tools frozen binaries future possibilitiessummary test your know... |
538 | import and reload basics the grander module storyattributes usage notesimport and reload using exec to run module files the idle user interface idle startup details idle basic usage idle usability features advanced idle tools usage notesidle other ides other launch options embedding calls frozen binary executables text... |
539 | nesting comprehensions dictionaries mapping operations nesting revisited missing keysif tests sorting keysfor loops iteration and optimization tuples why tuplesfiles binary bytes files unicode text files other file-like tools other core types how to break your code' flexibility user-defined classes and everything else ... |
540 | summary test your knowledgequiz test your knowledgeanswers the dynamic typing interlude the case of the missing declaration statements variablesobjectsand references types live with objectsnot variables objects are garbage-collected shared references shared references and in-place changes shared references and equality... |
541 | string formatting method calls formatting method basics adding keysattributesand offsets advanced formatting method syntax advanced formatting method examples comparison to the formatting expression why the format methodgeneral type categories types share operation sets by categories mutable types can be changed in pla... |
542 | text and binary filesthe short story storing python objects in filesconversions storing native python objectspickle storing python objects in json format storing packed binary datastruct file context managers other file tools core types review and summary object flexibility references versus copies comparisonsequalitya... |
543 | test your knowledgequiz test your knowledgeanswers assignmentsexpressionsand prints assignment statements assignment statement forms sequence assignments extended sequence unpacking in python multiple-target assignments augmented assignments variable name rules expression statements expression statements and in-place c... |
544 | pass continue break loop else for loops general format examples loop coding techniques counter loopsrange sequence scanswhile and range versus for sequence shufflersrange and len nonexhaustive traversalsrange versus slices changing listsrange versus comprehensions parallel traversalszip and map generating both offsets ... |
545 | the dir function docstrings__doc__ pydocthe help function pydochtml reports beyond docstringssphinx the standard manual set web resources published books common coding gotchas summary test your knowledgequiz test your knowledgeanswers test your knowledgepart iii exercises part iv functions and generators function basic... |
546 | program designminimize cross-file changes other ways to access globals scopes and nested functions nested scope details nested scope examples factory functionsclosures retaining enclosing scope state with defaults the nonlocal statement in nonlocal basics nonlocal in action why nonlocalstate retention options state wit... |
547 | function design concepts recursive functions summation with recursion coding alternatives loop statements versus recursion handling arbitrary structures function objectsattributes and annotations indirect function calls"first classobjects function introspection function attributes function annotations in anonymous func... |
548 | extended comprehension syntax for sets and dictionaries summary test your knowledgequiz test your knowledgeanswers the benchmarking interlude timing iteration alternatives timing modulehomegrown timing script timing results timing module alternatives other suggestions timing iterations and pythons with timeit basic tim... |
549 | configuring the search path search path variations the sys path list module file selection summary test your knowledgequiz test your knowledgeanswers module coding basics module creation module filenames other kinds of modules module usage the import statement the from statement the from statement imports happen only o... |
550 | relative import basics why relative importsthe scope of relative imports module lookup rules summary relative imports in action pitfalls of package-relative importsmixed use python namespace packages namespace package semantics impacts on regular packagesoptional __init__ py namespace packages in action namespace packa... |
551 | summary test your knowledgequiz test your knowledgeanswers test your knowledgepart exercises part vi classes and oop oopthe big picture why use classesoop from , feet attribute inheritance search classes and instances method calls coding class trees operator overloading oop is about code reuse summary test your knowled... |
552 | step adding behavior methods coding methods step operator overloading providing print displays step customizing behavior by subclassing coding subclasses augmenting methodsthe bad way augmenting methodsthe good way polymorphism in action inheritcustomizeand extend oopthe big idea step customizing constructorstoo oop is... |
553 | namespacesthe conclusion simple namesglobal unless assigned attribute namesobject namespaces the "zenof namespacesassignments classify names nested classesthe legb scopes rule revisited namespace dictionariesreview namespace linksa tree climber documentation strings revisited classes versus modules summary test your kn... |
554 | boolean methods in python object destruction__del__ destructor usage notes summary test your knowledgequiz test your knowledgeanswers designing with classes python and oop polymorphism means interfacesnot call signatures oop and inheritance"is-arelationships oop and composition"has-arelationships stream processors revi... |
555 | slotsattribute declarations propertiesattribute accessors __getattribute__ and descriptorsattribute tools other class changes and extensions static and class methods why the special methodsstatic methods in and static method alternatives using static and class methods counting instances with static methods counting ins... |
556 | default exception handler catching exceptions raising exceptions user-defined exceptions termination actions summary test your knowledgequiz test your knowledgeanswers exception coding details the try/except/else statement how try statements work try statement clauses the try else clause exampledefault behavior example... |
557 | built-in exception classes built-in exception categories default printing and state custom print displays custom data and behavior providing exception details providing exception methods summary test your knowledgequiz test your knowledgeanswers designing with exceptions nesting exception handlers examplecontrol-flow n... |
558 | how python stores strings in memory python' string types text and binary files coding basic strings python string literals python string literals string type conversions coding unicode strings coding ascii text coding non-ascii text encoding and decoding non-ascii text other encoding schemes byte string literalsencoded... |
559 | why manage attributesinserting code to run on attribute access properties the basics first example computed attributes coding properties with decorators descriptors the basics first example computed attributes using state information in descriptors how properties and descriptors relate __getattr__ and __getattribute__ ... |
560 | decorator state retention options class blunders idecorating methods timing calls adding decorator arguments coding class decorators singleton classes tracing object interfaces class blunders iiretaining multiple instances decorators versus manager functions why decorators(revisitedmanaging functions and classes direct... |
561 | metaclass dispatch in both and coding metaclasses basic metaclass customizing construction and initialization other metaclass coding techniques inheritance and instance metaclass versus superclass inheritancethe full story metaclass methods metaclass methods versus class methods operator overloading in metaclass method... |
562 | python environment variables how to set configuration options python command-line arguments python windows launcher command lines for more help the python windows launcher the unix legacy the windows legacy introducing the new windows launcher windows launcher tutorial step using version directives in files step using ... |
563 | part vmodules and packages part viclasses and oop part viiexceptions and tools index xxxii table of contents |
564 | if you're standing in bookstore looking for the short story on this booktry thispython is powerful multiparadigm computer programming languageoptimized for programmer productivitycode readabilityand software quality this book provides comprehensive and in-depth introduction to the python language itself its goal is to ... |
565 | programming pythonamong othersmoves on to show what you can do with python after you've learned it this division of labor is deliberate while application goals can vary per readerthe need for useful language fundamentals coverage does not applications-focused books such as programming python pick up where this book lea... |
566 | all language changes introduced in each line since the prior edition was publishedand has been polished throughout to update and sharpen its presentation specificallypython coverage here has been updated to include features such as dictionary and set comprehensions that were formerly for onlybut have been back-ported f... |
567 | because it bears heavily on this book' contenti need to say few more words about the python / story up front when the fourth edition of this book was written in python had just become available in two flavorsversion was the first in the line of an emerging and incompatible mutation of the language known generically as ... |
568 | python that offers stunning performance improvements--represent futureif not an outright faction all opinions asidealmost five years after its release has yet to supersede xor even match its user base as one metric is still downloaded more often than for windows at python org todaydespite the fact that this measure wou... |
569 | print statement so you can make sense of earlier codeand will often use portable printing techniques that run on both lines 'll also freely introduce new featuressuch as the nonlocal statement in and the string format method available as of and and will point out when such extensions are not present in older pythons by... |
570 | migration and tips on writing code for both python lines and audiences regardless of which version or versions you choose to focus on firstyour skills will transfer directly to wherever your python work leads you about the xsthroughout this book" xand " xare used to refer collectively to all releases in these two lines... |
571 | and software in generalare both challenging and rewarding enough to merit the effort implied by comprehensive books such as this here are few pointers on using this book for readers on both sides of the experience spectrumto experienced programmers you have an initial advantage and can move quickly through some earlier... |
572 | this large probably merits brief roadmap up front by designeach part covers major functional area of the languageand each part is composed of focusing on specific topic or aspect of the part' area in additioneach ends with quizzes and their answersand each part ends with larger exerciseswhose solutions show up in appen... |
573 | this part begins our look at python' higher-level program structure tools functions turn out to be simple way to package code for reuse and avoid code redundancy in this partwe will explore python' scoping rulesargument-passing techniquesthe sometimes-notorious lambdaand more we'll also revisit iterators from functiona... |
574 | recent editions and give links to their coverage hereand provide solutions to the end-of-part exercises solutions to end-of-quizzes appear in the themselves see the table of contents for finer-grained look at this book' components what this book is not given its relatively large audience over the yearssome have inevita... |
575 | introduced here--including timeitshelvepicklestructjsonpdbosurllibrexmlrandompydoc and idle--they are not officially in this book' primary scope if you're looking for more coverage on such topics and are already proficient with pythoni recommend the follow-up book programming pythonamong others that book assumes this o... |
576 | and descriptors python is still best learned as progression from simple to advancedand linear reading here still makes the most sense stillsome topics may require nonlinear jumps and random lookups to minimize thesethis book will point out forward dependencies when they occurand will ease their impacts as much as possi... |
577 | the examples in this book were run on windows and ultrabook, though python' portability makes this mostly moot pointespecially in this fundamentals-focused book you'll notice few windows-isms--including command-line promptsa handful of screenshotsinstall pointersand an appendix on the new windows launcher in --but this... |
578 | authorpublisherand isbn for example"learning pythonfifth editionby mark lutz copyright mark lutz- - if you feel your use of code examples falls outside fair use or the permission given abovefeel free to contact us at permissions@oreilly com font conventions this book' mechanics will make more sense once you start readi... |
579 | this site will maintain this edition' official list of book errataand chronicle specific patches applied to the text in reprints it' also the official site for the book' examples as described earlier author' sitethis site will be used to post more general updates related to this text or python itself-- hedge against fu... |
580 | phenomenal growth in popularity here' the damage so far 've now written python books ( of thisand of two others)which have together sold some , units by my data 've also been teaching python for over decade and halfhave taught some python training sessions in the europecanadaand mexicoand have met roughly , students al... |
581 | deployed in some fashion by almost every organization writing software technical disagreements asidethat' been an exciting endeavor to be part of also want to thank my original editor at 'reillythe late frank willison this book was largely frank' idea he had profound impact on both my career and the success of python w... |
582 | getting started |
583 | python & session if you've bought this bookyou may already know what python is and why it' an important tool to learn if you don'tyou probably won' be sold on python until you've learned the language by reading the rest of this book and have done project or two but before we jump into detailsthis first of this book wil... |
584 | less to debugand less to maintain after the fact python programs also run immediatelywithout the lengthy compile and link steps required by some other toolsfurther boosting programmer speed program portability most python programs run unchanged on all major computer platforms porting python code between linux and windo... |
585 | this makes the language easier to learnunderstandand remember in practicepython programmers do not need to constantly refer to manuals when reading or writing codeit' consistently designed system that many find yields surprisingly uniform code by philosophypython adopts somewhat minimalist approach this means that alth... |
586 | statement that captures the richness and scope of today' python stillthe term "scriptingseems to have stuck to python like glueperhaps as contrast with larger programming effort required by some other tools for examplepeople often use the word "scriptinstead of "programto describe python code file in keeping with this ... |
587 | term "scriptingis probably best used to describe the rapid and flexible mode of development that python supportsrather than particular application domain okbut what' the downsideafter using it for yearswriting about it for and teaching it for 've found that the only significant universal downside to python is thatas cu... |
588 | mentioned that execution speed is the only major downside to python that' indeed the case for most python usersand especially for newcomers most people find python to be easy to learn and fun to useespecially when compared with its contemporaries like javac#and +in the interest of full disclosurethoughi should also not... |
589 | at this writingthe best estimate anyone can seem to make of the size of the python user base is that there are roughly million python users around the world today (plus or minus fewthis estimate is based on various statisticslike download ratesweb statisticsand developer surveys because python is open sourcea more exac... |
590 | python the one laptop per child (olpcproject built its user interface and activity model in python netflix and yelp have both documented the role of python in their software infrastructures intelciscohewlett-packardseagatequalcommand ibm use python for hardware testing jpmorgan chaseubsgetcoand citadel apply python to ... |
591 | mentioned here in any depth--if you are interested in any of these topicssee the python website or other resources for more details systems programming python' built-in interfaces to operating-system services make it ideal for writing portablemaintainable system-administration tools and utilities (sometimes called shel... |
592 | over xml-rpcsoapand telnetand more python' libraries make these tasks remarkably simple in additiona large collection of third-party tools are available on the web for doing internet programming in python for instancethe htmlgen system generates html files from python class-based descriptionsthe mod_python package runs... |
593 | of underlying database systems for instancebecause the vendor interfaces implement the portable apia script written to work with the free mysql system will work largely unchanged on other systems (such as oracle)all you generally have to do is replace the underlying vendor interface the in-process sqlite embedded sql d... |
594 | provide additional libraries of scientific programming tools and use numpy as core component the pypy implementation of python (discussed in has also gained traction in the numeric domainin part because heavily algorithmic code of the sort that' common in this domain can run dramatically faster in pypy--often to quicke... |
595 | code you can even play solitaire with the pysolfc program and of courseyou can always code custom python scripts in less buzzword-laden domains to perform day-to-day system administrationprocess your emailmanage your document and media librariesand so on you'll find links to the support in many fields at the pypi websi... |
596 | process controls (python for instancecame with broken console input function on windowsmoreoveropen source projects exchange commercial interests for the personal preferences of current set of developerswhich may or may not be the same as yours-you are not held hostage by companybut you are at the mercy of those with s... |
597 | these can serve as both complement and alternative to its oop tools it' free python is completely free to use and distribute as with other open source softwaresuch as tclperllinuxand apacheyou can fetch the entire python system' source code for free on the internet there are no restrictions on copying itembedding it in... |
598 | cell phones running symbian osand windows mobile gaming consoles and ipods tablets and smartphones running google' android and apple' ios and more like the language interpreter itselfthe standard library modules that ship with python are implemented to be as portable across platform boundaries as possible furtherpython... |
599 | functional programming toolsdescribed earlierprovide additional ways to meet many of the same goals built-in object types python provides commonly used data structures such as listsdictionariesand strings as intrinsic parts of the languageas you'll seethey're both flexible and easy to use for instancebuilt-in objects c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.