Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
35f88613
Kaydet (Commit)
35f88613
authored
Ock 06, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add tutorial section about coding style.
üst
e9766c8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
+52
-5
controlflow.rst
Doc/tutorial/controlflow.rst
+50
-3
introduction.rst
Doc/tutorial/introduction.rst
+2
-2
No files found.
Doc/tutorial/controlflow.rst
Dosyayı görüntüle @
35f88613
...
...
@@ -551,10 +551,57 @@ Here is an example of a multi-line docstring::
No, really, it doesn't do anything.
.. _tut-codingstyle:
Intermezzo: Coding Style
========================
.. sectionauthor:: Georg Brandl <georg@python.org>
.. index:: pair: coding; style
Now that you are about to write longer, more complex pieces of Python, it is a
good time to talk about *coding style*. Most languages can be written (or more
concise, *formatted*) in different styles; some are more readable than others.
Making it easy for others to read your code is always a good idea, and adopting
a nice coding style helps tremendously for that.
For Python, :pep:`8` has emerged as the style guide that most projects adher to;
it promotes a very readable and eye-pleasing coding style. Every Python
developer should read it at some point; here are the most important points
extracted for you:
* Use 4-space indentation, and no tabs.
4 spaces are a good compromise between small indentation (allows greater
nesting depth) and large indentation (easier to read). Tabs introduce
confusion, and are best left out.
* Wrap lines so that they don't exceed 79 characters.
This helps users with small displays and makes it possible to have several
code files side-by-side on larger displays.
* Use blank lines to separate functions and classes, and larger blocks of
code inside functions.
* When possible, put comments on a line of their own.
* Use docstrings.
* Use spaces around operators and after commas, but not directly inside
bracketing constructs: ``a = f(1, 2) + g(3, 4)``.
* Name your classes and functions consistently; the convention is to use
``CamelCase`` for classes and ``lower_case_with_underscores`` for functions
and methods. Always use ``self`` as the name for the first method argument.
* Don't use fancy encodings if your code is meant to be used in international
environments. Plain ASCII works best in any case.
.. rubric:: Footnotes
.. [#] Actually, *call by object reference* would be a better description,
since if a
mutable object is passed, the caller will see any changes the callee makes to it
(items inserted into a list).
.. [#] Actually, *call by object reference* would be a better description,
since if a mutable object is passed, the caller will see any changes the
callee makes to it
(items inserted into a list).
Doc/tutorial/introduction.rst
Dosyayı görüntüle @
35f88613
...
...
@@ -578,8 +578,8 @@ series as follows::
... # the sum of two elements defines the next
... a, b = 0, 1
>>> while b < 10:
...
print b
...
a, b = b, a+b
... print b
... a, b = b, a+b
...
1
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment