
۴۴٬۰۰۰تومان
نوع فایل دانلود: EPUB
پس از خرید، یک فایل EPUB دریافت میکنید.
این فایل با Calibre، Apple Books و سایر کتابخوانهای دیجیتال مناسب است.
این کتاب برنامهای سیستماتیک برای عیبیابی برنامههای شماست. تمرکز کتاب روی زبان پایتون نیست، هرچند که فصل ۳ به مباحث پایه میپردازد. در عوض، تمرکز اصلی من همیشه روی عیبیابی است. اگر در عیبیابی پایتون تازهکار هستید، فکر میکنم این کتاب نقطه شروع خوبی باشد. برنامهنویسان باتجربهتر پایتون ممکن است بخواهند نگاهی به فهرست مطالب بیندازند تا ببینند آیا نکتهی خاصی که توجهشان را جلب کند وجود دارد یا خیر. کدهای نمونه، لیستها، تاپلها، حلقهها یا کلاسها را نشان میدهند، اما در سادهترین شکلی که میتوانستم تصور کنم. فصلهای ۱ و ۲ نحوه راهاندازی محیط عیبیابی پایتون را شرح میدهند و برنامهای برای عیبیابی همزمان با نوشتن کد ارائه میکنند. ۱. روی تکههای کوچک کد کار کنید، تست کنید و سپس به سراغ بخش بعدی بروید. ۲. چندین نسخه پشتیبان از فایلهای خود نگه دارید. ۳. تصویری روشن از آنچه میخواهید برنامهتان انجام دهد داشته باشید. ۴. از نمونه فایلهای داده کوچکی که میدانید دادههای تمیزی دارند برای توسعه کد خود استفاده کنید. وقتی کد خود را تست کردید و مطمئن شدید هیچ خطایی ندارد، از اتصال به دادههای زنده یا فایلهای داده واقعی استفاده کنید. ۵. یادداشتهایی از نقطهای که برنامهنویسی را متوقف کردهاید و گامهای بعدی نگه دارید. ۶. تقسیم کنید و غلبه کنید. کد را به دو نیم تقسیم کنید و هر نیمه را تست کنید تا ببینید خطا در کدام قسمت است. این کار را تکرار کنید تا دقیقاً به محل خطا برسید. ۷. هنگام عیبیابی، سوابقی از آزمایشهای خود نگه دارید تا بدانید چه چیزهایی را امتحان کردهاید. فصل ۴ پیشنهادهای سادهای برای عیبیابی کد با مثالهای مشخصی از کد و نتایج ارائه میدهد. حتی اگر تا به حال اسپایدر یا پایتون را ندیده باشید، امیدوارم در پایان این فصل احساس اعتمادبهنفس کنید تا بیشتر مشکلات پیشروی خود را حل کنید. • با بررسی کلی عیبیابی، با ویرایشگر، کاوشگر متغیر، و حالتهای عیبیابی و تعاملی در کنسول آشنا خواهید شد. ما مواقعی را بررسی میکنیم که شیء خود را در کاوشگر متغیر نمیبینید و کشف میکنیم که چرا گزارش خطای کنسول عبارت NameError را نشان میدهد. • به عمق حالت عیبیابی بروید، از جمله دستورات پایه، نحوه تنظیم نقطه توقف، و مثالهایی از قدم به قدم پیش رفتن در کد. • دستورات چاپ (و سرنخهای بصری برای عمق دستورات حلقه) را اضافه کنید. • ثبت وقایع برای مواقعی که دستورات چاپ از روی صفحه محو میشوند. • از حالت تعاملی با چندین دستور رایج کنسول و دو دستور ویژه استفاده کنید: [object name]?dir(object)help(object)%debug%timeit فصل ۵ به طور خلاصه انواعی از خطاها را که ممکن است با آنها روبرو شوید بررسی میکند، و سپس در فصل ۶ میتوانید دانش عیبیابی خود را به کار بگیرید. ما به نحوهی بازیابی مقادیر اشیاء، اطلاعات نوع داده، طول اشیاء یا ساختار دادهها، آرگومانها و مقادیر بازگشتی نگاهی میاندازیم. از آنجا که نحوه نگارش بر اساس نوع و طول اشیاء متفاوت است، مثالهای متعددی برای رشتهها، اعداد، تاپلها، لیستها و دیکشنریها وجود دارد. همچنین مقدار ویژه None را که مختص پایتون است، بررسی خواهیم کرد. فصل ۷ پر از مثال است. قالب هر مثال یکسان است: توضیحات، نتیجه مورد نظر، نتیجه واقعی، کد نادرست، مراحل عیبیابی، نحوه حل مشکل، کد درست، و ارجاع به مباحث مرتبط قبلی. در نهایت، فصل پیوست و مرجع شامل لینکهایی به مستندات Python.org و وبسایتهای iPython.readthedocs برای اطلاعات بیشتر است.
This book is a systematic plan to debug your programs. The focus is not on the Python language, although Chapter 3 does cover the basics. Instead, my focus is always on debugging. If you’re new to Python debugging, I think this book is a good starting point. Experienced Python programmers might want to review the table of contents, to see if there’s anything special that catches their interest.The sample code demonstrates lists, tuples, loops, or classes, but in the simplest form I could imagine. Chapters 1-2 outline how to set up your Python debugging environment, and establish a debugging plan as you write your code.1.Work on small chunks of code, test, and then move on to the next piece.2.Keep multiple backup versions of your files.3.Have a clear idea of what you want your program to do.4.Use small data file samples that you know have clean data to develop your code. When you’ve tested your code and are confident there are no bugs, use live data connections or real data files. 5.Keep notes of where you stopped programming and the next steps.6.Divide and concur. Divide the code in half and test each half to see which half has the error. Repeat to drill down to the location with the error.7.When debugging, keep a record of experiments, so you know what you’ve already tried.Chapter 4 has simple suggestions for debugging your code, with specific examples of the code and results. Even if you’ve never seen Spyder or Python before, at the end of this chapter, I hope you’ll feel confident debugging most of the issues you’ll encounter.•With the Debugging Overview, you’ll learn about the Editor, Variable Explorer, and Debug Mode and Interactive Mode in the Console. We’ll look at those times when you don’t see your object in Variable Explorer, and explore why the Console traceback says “NameError.”•Delve into Debug Mode, including basic commands, how to set a breakpoint, and examples of stepping through the code.•Add Print Statements (and visual clues for the depth of loop statements).•Logging for those times when print statements roll off the screen.•Use Interactive Mode with several common Console commands and two magic commands. [object name]?dir(object)help(object)%debug%timeitChapter 5 briefly looks at the types of errors you may encounter, and then in Chapter 6, you can try out your debugging knowledge. We’ll look at the syntax for retrieving object values, type information, the length of objects or data structures, arguments, and return values. Because syntax varies based on the type and length of objects, there are numerous examples for strings, numbers, tuples, lists, and dictionaries. We’ll also look at the special “None” value, unique to Python.Chapter 7 is chock full of examples. The format for each example is the same: Description, Intended Outcome, Actual Result, Incorrect Code, Debugging Steps, How to Resolve the Issue, Good Code, and a Reference to earlier related topics.Finally, the Appendix-Reference chapter includes links to the Python.org docs and the iPython.readthedocs websites for more detailed information.