Python/tr: Difference between revisions

From FreeCAD Documentation
(Created page with "== Tanım ==")
(Updating to match new version of source page)
 
(26 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<div class="mw-translate-fuzzy">
{{VeryImportantMessage | (Kasım 2018) FreeCAD başlangıçta Python 2 ile çalışmak üzere tasarlandı. Birçok özellik Python 3 ile çalışıyor, ancak bazıları çalışmıyor. FreeCAD'i Python 3 te tam olarak destekleme işi , devam etmekte olan bir iştir.}}
{{VeryImportantMessage | (Kasım 2018) FreeCAD başlangıçta Python 2 ile çalışmak üzere tasarlandı. Birçok özellik Python 3 ile çalışıyor, ancak bazıları çalışmıyor. FreeCAD'i Python 3 te tam olarak destekleme işi , devam etmekte olan bir iştir.}}
</div>


== Tanım ==
== Tanım ==


{{TOCright}}
[https://www.python.org Python] is a general purpose, high level programming language that is very commonly used in large applications to automate some tasks by creating scripts or [[macros]].


[https://www.python.org Python] genel amaçlı, büyük uygulamalarda komut dosyası veya [[macros/tr|makro]] oluşturarak bazı görevleri otomatikleştirmek için yaygın olarak kullanılan yüksek seviye bir programlama dilidir.
In FreeCAD, Python code can be used to create various elements programmatically, without needing to click on the graphical user interface. Additionally, many tools and workbenches of FreeCAD are programmed in Python.


FreeCAD'de, Python kodu, grafiksel kullanıcı arayüzüne tıklamak zorunda kalmadan programatik olarak çeşitli elemanlar oluşturmak için kullanılabilir. Ek olarak, FreeCAD'in birçok aracı ve tezgahı Python'da programlanmıştır.
See [[Introduction to Python]] to learn about the Python programming language, and then [[Python scripting tutorial]] and [[FreeCAD Scripting Basics]] to start scripting in FreeCAD.


Python programlama dili hakkında bilgi edinmek için [[Introduction to Python/tr|Python'a Giriş]] 'e, ardından da FreeCAD'de komut dosyasını başlatmak için [[Python scripting tutorial/tr|Python betik kılavuzu]] ve [[FreeCAD Scripting Basics/tr|FreeCAD betik kılavuzu]]' ne bakın.
When writing Python code, it's advisable to follow [https://www.python.org/dev/peps/pep-0008/ PEP8: Style Guide for Python Code].


== Conventions ==
== Readability ==
In this documentation, some conventions for Python examples should be followed.


<div class="mw-translate-fuzzy">
This is a typical function signature
Python kodunu yazarken [https://www.python.org/dev/peps/pep-0008/PEP8: Python Kodu için Stil Kılavuzu] 'nu takip etmeniz önerilir.
</div>

These documents present explanations in a more user-friendly way:
* [https://realpython.com/python-pep8/ How to Write Beautiful Python Code With PEP 8]
* [https://realpython.com/documenting-python-code/ Documenting Python Code: A Complete Guide].

== Kurallar ==
Bu belgede, Python örnekleri için bazı kurallara uyulmalıdır.

Bu tipik bir fonksiyon imzasıdır.


{{Code|code=
{{Code|code=
Wire = makeWire(pointslist, closed=False, placement=None, face=None, support=None)
Wire = make_wire(pointslist, closed=False, placement=None, face=None, support=None)
}}
}}


* Anahtar / değer çiftlerine sahip bağımsız değişkenler, imzada belirtilen varsayılan değerlerle isteğe bağlıdır. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir:
* Arguments with key-value pairs are optional, with the default value indicated in the signature. This means that the following calls are equivalent:


{{Code|code=
{{Code|code=
Wire = makeWire(pointslist, False, None, None, None)
Wire = make_wire(pointslist, False, None, None, None)
Wire = makeWire(pointslist, False, None, None)
Wire = make_wire(pointslist, False, None, None)
Wire = makeWire(pointslist, False, None)
Wire = make_wire(pointslist, False, None)
Wire = makeWire(pointslist, False)
Wire = make_wire(pointslist, False)
Wire = makeWire(pointslist)
Wire = make_wire(pointslist)
}}
}}


: Bu örnekte, ilk argüman varsayılan bir değere sahip değildir, bu yüzden her zaman dahil edilmelidir.
: In this example the first argument doesn't have a default value so it should always be included.


* Argümanlar açık anahtarla verildiğinde, isteğe bağlı argümanlar herhangi bir sırayla verilebilir. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir:
* When the arguments are given with the explicit key, the optional arguments can be given in any order. This means that the following calls are equivalent:
{{Code|code=
{{Code|code=
Wire = makeWire(pointslist, closed=False, placement=None, face=None)
Wire = make_wire(pointslist, closed=False, placement=None, face=None)
Wire = makeWire(pointslist, closed=False, face=None, placement=None)
Wire = make_wire(pointslist, closed=False, face=None, placement=None)
Wire = makeWire(pointslist, placement=None, closed=False, face=None)
Wire = make_wire(pointslist, placement=None, closed=False, face=None)
Wire = makeWire(pointslist, support=None, closed=False, placement=None, face=None)
Wire = make_wire(pointslist, support=None, closed=False, placement=None, face=None)
}}
}}


* Python kuralları, kodun okunabilirliğini vurgulamaktadır; Özellikle parantezler hemen fonksiyon ismini takip etmeli ve boşluk virgül takip etmelidir.
* Python's guidelines stress readability of code; in particular, parentheses should immediately follow the function name, and a space should follow a comma.


{{Code|code=
{{Code|code=
Line 47: Line 59:
p2 = Vector(1, 1, 0)
p2 = Vector(1, 1, 0)
p3 = Vector(2, 0, 0)
p3 = Vector(2, 0, 0)
Wire = makeWire([p1, p2, p3], closed=True)
Wire = make_wire([p1, p2, p3], closed=True)
}}
}}


* Kodun birkaç satır üzerinden kesilmesi gerekiyorsa, bu parantez veya parantez içindeki virgül ile yapılmalıdır; ikinci satır öncekiyle aynı hizada olmalıdır.
* If code needs to be broken over several lines, this should be done at a comma inside brackets or parentheses; the second line should be aligned with the previous one.


{{Code|code=
{{Code|code=
Line 56: Line 68:
2, 4, 5]
2, 4, 5]


Wire = makeWire(pointslist,
Wire = make_wire(pointslist,
False, None,
False, None,
None, None)
None, None)
}}
}}


* İşlevler, başka bir çizim işlevinin temeli olarak kullanılabilecek bir nesneyi döndürebilir.
* Functions may return an object that can be used as the base of another drawing function.
{{Code|code=
{{Code|code=
Wire = makeWire(pointslist, closed=True, face=True)
Wire = make_wire(pointslist, closed=True, face=True)
Window = makeWindow(Wire, name="Big window")
Window = make_window(Wire, name="Big window")
}}
}}


== Imports ==
== İçe Aktarma ==


Python fonksiyonları, modül adı verilen dosyalarda saklanır. Bu modülde herhangi bir işlevi kullanmadan önce, modül {{incode | import}} talimatı ile belgeye dahil edilmelidir.
Python functions are stored in files called modules. Before using any function in that module, the module must be included in the document with the {{incode|import}} instruction.


<div class="mw-translate-fuzzy">
This creates prefixed functions, that is, {{incode|module.function()}}. This system prevents name clashes with functions that are named the same but that come from different modules.
For example, the two functions {{incode|Arch.makeWindow()}} and {{incode|myModule.makeWindow()}} may coexist without problem.
Bu, önceden eklenmiş işlevler yaratır, yani, {{incode|module.function ()}}. Bu sistem, aynı adlı ancak farklı modüllerden gelen işlevlerle ad çakışmalarını önler. Örneğin, {{incode | Arch.makeWindow ()}} ve {{incode | myModule.makeWindow ()}} iki işlevi sorunsuz bir şekilde bir arada bulunabilir.
</div>


Tam örnekler, gerekli içe aktarmaları ve önceden belirlenmiş fonksiyonları içermelidir.
Full examples should include the necessary imports and the prefixed functions.


{{Code|code=
{{Code|code=
import FreeCAD, Draft
import FreeCAD as App
import Draft


p1 = FreeCAD.Vector(0, 0, 0)
p1 = App.Vector(0, 0, 0)
p2 = FreeCAD.Vector(1, 1, 0)
p2 = App.Vector(1, 1, 0)
p3 = FreeCAD.Vector(2, 0, 0)
p3 = App.Vector(2, 0, 0)
Wire = Draft.makeWire([p1, p2, p3], closed=True)
Wire = Draft.make_wire([p1, p2, p3], closed=True)
}}
}}


{{Code|code=
{{Code|code=
import FreeCAD, Draft, Arch
import FreeCAD as App
import Draft
import Arch


p1 = FreeCAD.Vector(0, 0, 0)
p1 = App.Vector(0, 0, 0)
p2 = FreeCAD.Vector(1, 0, 0)
p2 = App.Vector(1, 0, 0)
p3 = FreeCAD.Vector(1, 1, 0)
p3 = App.Vector(1, 1, 0)
p4 = FreeCAD.Vector(0, 2, 0)
p4 = App.Vector(0, 2, 0)
pointslist = [p1, p2, p3, p4]
pointslist = [p1, p2, p3, p4]


Wire = Draft.makeWire(pointslist, closed=True, face=True)
Wire = Draft.make_wire(pointslist, closed=True, face=True)
Structure = Arch.makeStructure(Wire, name="Big pillar")
Structure = Arch.make_structure(Wire, name="Big pillar")
}}
}}


{{Powerdocnavi{{#translation:}}}}
[[Category:API Documentation]]
[[Category:Developer Documentation]]
[[Category:Developer Documentation{{#translation:}}]]
[[Category:Poweruser Documentation]]
[[Category:API{{#translation:}}]]
[[Category:User Documentation]]
[[Category:Python Code{{#translation:}}]]
[[Category:Glossary{{#translation:}}]]

Latest revision as of 09:22, 17 October 2021

(Kasım 2018) FreeCAD başlangıçta Python 2 ile çalışmak üzere tasarlandı. Birçok özellik Python 3 ile çalışıyor, ancak bazıları çalışmıyor. FreeCAD'i Python 3 te tam olarak destekleme işi , devam etmekte olan bir iştir.

Tanım

Python genel amaçlı, büyük uygulamalarda komut dosyası veya makro oluşturarak bazı görevleri otomatikleştirmek için yaygın olarak kullanılan yüksek seviye bir programlama dilidir.

FreeCAD'de, Python kodu, grafiksel kullanıcı arayüzüne tıklamak zorunda kalmadan programatik olarak çeşitli elemanlar oluşturmak için kullanılabilir. Ek olarak, FreeCAD'in birçok aracı ve tezgahı Python'da programlanmıştır.

Python programlama dili hakkında bilgi edinmek için Python'a Giriş 'e, ardından da FreeCAD'de komut dosyasını başlatmak için Python betik kılavuzu ve FreeCAD betik kılavuzu' ne bakın.

Readability

Python kodunu yazarken Python Kodu için Stil Kılavuzu 'nu takip etmeniz önerilir.

These documents present explanations in a more user-friendly way:

Kurallar

Bu belgede, Python örnekleri için bazı kurallara uyulmalıdır.

Bu tipik bir fonksiyon imzasıdır.

Wire = make_wire(pointslist, closed=False, placement=None, face=None, support=None)
  • Anahtar / değer çiftlerine sahip bağımsız değişkenler, imzada belirtilen varsayılan değerlerle isteğe bağlıdır. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir:
Wire = make_wire(pointslist, False, None, None, None)
Wire = make_wire(pointslist, False, None, None)
Wire = make_wire(pointslist, False, None)
Wire = make_wire(pointslist, False)
Wire = make_wire(pointslist)
Bu örnekte, ilk argüman varsayılan bir değere sahip değildir, bu yüzden her zaman dahil edilmelidir.
  • Argümanlar açık anahtarla verildiğinde, isteğe bağlı argümanlar herhangi bir sırayla verilebilir. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir:
Wire = make_wire(pointslist, closed=False, placement=None, face=None)
Wire = make_wire(pointslist, closed=False, face=None, placement=None)
Wire = make_wire(pointslist, placement=None, closed=False, face=None)
Wire = make_wire(pointslist, support=None, closed=False, placement=None, face=None)
  • Python kuralları, kodun okunabilirliğini vurgulamaktadır; Özellikle parantezler hemen fonksiyon ismini takip etmeli ve boşluk virgül takip etmelidir.
p1 = Vector(0, 0, 0)
p2 = Vector(1, 1, 0)
p3 = Vector(2, 0, 0)
Wire = make_wire([p1, p2, p3], closed=True)
  • Kodun birkaç satır üzerinden kesilmesi gerekiyorsa, bu parantez veya parantez içindeki virgül ile yapılmalıdır; ikinci satır öncekiyle aynı hizada olmalıdır.
a_list = [1, 2, 3,
          2, 4, 5]

Wire = make_wire(pointslist,
                False, None,
                None, None)
  • İşlevler, başka bir çizim işlevinin temeli olarak kullanılabilecek bir nesneyi döndürebilir.
Wire = make_wire(pointslist, closed=True, face=True)
Window = make_window(Wire, name="Big window")

İçe Aktarma

Python fonksiyonları, modül adı verilen dosyalarda saklanır. Bu modülde herhangi bir işlevi kullanmadan önce, modül import talimatı ile belgeye dahil edilmelidir.

Bu, önceden eklenmiş işlevler yaratır, yani, module.function (). Bu sistem, aynı adlı ancak farklı modüllerden gelen işlevlerle ad çakışmalarını önler. Örneğin, Arch.makeWindow () ve myModule.makeWindow () iki işlevi sorunsuz bir şekilde bir arada bulunabilir.

Tam örnekler, gerekli içe aktarmaları ve önceden belirlenmiş fonksiyonları içermelidir.

import FreeCAD as App
import Draft

p1 = App.Vector(0, 0, 0)
p2 = App.Vector(1, 1, 0)
p3 = App.Vector(2, 0, 0)
Wire = Draft.make_wire([p1, p2, p3], closed=True)
import FreeCAD as App
import Draft
import Arch

p1 = App.Vector(0, 0, 0)
p2 = App.Vector(1, 0, 0)
p3 = App.Vector(1, 1, 0)
p4 = App.Vector(0, 2, 0)
pointslist = [p1, p2, p3, p4]

Wire = Draft.make_wire(pointslist, closed=True, face=True)
Structure = Arch.make_structure(Wire, name="Big pillar")