Ana sayfa Genel Nesne Yönelimli Programlama – Özel Metodlar

Nesne Yönelimli Programlama – Özel Metodlar

1180
61
PAYLAŞ

Nesne Yönelimli Programlama – Özel Metodlar

Nesne yönelimli programlamada son olarak sınıfların özel metodlarını nasıl kendimiz yazarız öğrenmeye çalışalım. Özel metodlar, daha önceden de bahsettiğimiz gibi bizim özel olarak çağırmadığımız ancak her classa ait metodlardır. Bunların çoğu biz tanımlamasak bile Python tarafından varsayılan olarak tanımlanır. Ancak bu metodların bazılarını da özel olarak bizim tanımlamamız gerekmektedir. Daha önceden gördüğümüz init metodu bu metodlara bir örnektir. Bu konuda bu metodlarını nasıl tanımlayacağımızı öğrenmeye çalışacağız. Şimdi örneklerimize geçelim.



Şimdi buradaki metodları kendimiz nasıl tanımlayacağız öğrenmeye çalışalım.

init metodu

init metodunu kendimiz tanımlarsak artık kendi init fonksiyonumuz çalışacaktır.

str metodu

Normalde print(kitap1) ifadesi ekrana şöyle bir yazı yazdırıyor.

Ancak eğer str metodunu kendimiz tanımlarsak artık ekrana kitap1 in içeriğini daha anlaşılır yazabileceğiz.

len metodu

len metodu normalde özel olarak biz tanımlamazsak tanımlanan bir metod değil. Onun için bu metodu kendimiz tanımlamamız gereklidir.

del metodu

del metodu Pythonda bir objeyi del anahtar kelimesiyle sildiğimiz zaman çalıştırılan metoddur. Bu metodu kendimiz tanımlayarak ekstra özellikler ekleyebiliriz.

Siz de bunlar gibi çoğu özel metodu ihtiyacınız olduğu zaman kendiniz yazabilirsiniz. Özel metodlar için güzel bir ingilizce kaynak için şuradan faydalanabilirsiniz.

http://www.diveintopython3.net/special-method-names.html

61 YORUMLAR

  1. Do you have a spam problem on this site; I also am a blogger, and I was wondering your situation; we have developed some nice practices and we are looking to trade methods with other folks, why not shoot me an e-mail if interested.

  2. of course like your web-site however you have to test the
    spelling on several of your posts. Many of them are rife with spelling issues and I to find it very bothersome
    to tell the reality nevertheless I’ll certainly come back again.

  3. What i don’t understood is in reality how you are not actually
    much more neatly-favored than you may be now. You’re very intelligent.
    You know thus considerably in relation to this
    topic, made me individually imagine it from so many various angles.
    Its like men and women are not interested unless it is one thing to accomplish with Woman gaga!
    Your individual stuffs outstanding. At all times deal with it up!

  4. Hi there! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thank you for sharing!

  5. What i do not realize is if truth be told how you’re now not really a lot more well-favored than you may be now. You’re very intelligent. You already know therefore significantly in the case of this subject, produced me in my view consider it from a lot of various angles. Its like women and men aren’t involved except it¦s one thing to do with Woman gaga! Your personal stuffs excellent. All the time maintain it up!

  6. Magnificent beat ! I would like to apprentice whilst you amend your site, how can i subscribe for a weblog website? The account helped me a applicable deal. I have been tiny bit familiar of this your broadcast provided bright clear idea

  7. Have you ever considered about including a little bit more than just
    your articles? I mean, what you say is important and all.
    Nevertheless imagine if you added some great images or
    video clips to give your posts more, “pop”! Your content is excellent but with images and video clips, this
    blog could definitely be one of the very best
    in its niche. Great blog!

  8. It’s a pity you don’t have a donate button! I’d most certainly donate to this fantastic blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account. I look forward to fresh updates and will share this blog with my Facebook group. Chat soon!

  9. What’s Happening i’m new to this, I stumbled upon this I’ve found It absolutely helpful and it has helped me out loads. I hope to contribute & assist other users like its aided me. Great job.

  10. I do not know if it’s just me or if everyone else experiencing issues
    with your website. It appears like some of the written text within your posts are running off the screen. Can someone else please comment and let me know if
    this is happening to them as well? This may be a problem
    with my internet browser because I’ve had this happen previously.
    Thanks

  11. Wow! This can be one particular of the most helpful blogs We have ever arrive across on this subject. Actually Wonderful. I’m also a specialist in this topic so I can understand your effort.

  12. What’s Taking place i’m new to this, I stumbled upon this I’ve discovered It absolutely helpful and it has aided me out loads. I’m hoping to contribute & aid different users like its aided me. Good job.

  13. What i do not understood is actually how you are not really much more well-liked than you might be right now. You are very intelligent. You realize therefore considerably relating to this subject, produced me personally consider it from numerous varied angles. Its like women and men aren’t fascinated unless it’s one thing to accomplish with Lady gaga! Your own stuffs outstanding. Always maintain it up!

  14. Hiya very nice site!! Guy .. Excellent .. Wonderful .. I’ll bookmark your web site and
    take the feeds additionally? I am glad to find a lot of
    helpful info here in the put up, we want work out extra
    strategies on this regard, thanks for sharing. . .

    . . .

  15. Thank you for another informative blog. Where else could I get that type of information written in such an ideal way? I’ve a project that I am just now working on, and I have been on the look out for such information.

  16. I’m not sure exactly why but this web site is loading incredibly
    slow for me. Is anyone else having this issue or is it a problem on my end?
    I’ll check back later on and see if the problem still exists.

  17. What i do not understood is in truth how you’re no longer really a lot more well-favored than you may be right now. You’re very intelligent. You recognize therefore considerably relating to this topic, produced me individually consider it from numerous varied angles. Its like women and men are not fascinated except it’s something to do with Girl gaga! Your individual stuffs excellent. Always care for it up!

  18. magnificent put up, very informative. I’m wondering why the opposite experts of this sector don’t understand this. You should continue your writing. I’m sure, you have a huge readers’ base already!

  19. The very crux of your writing while appearing agreeable in the beginning, did not really sit very well with me personally after some time. Somewhere within the paragraphs you actually managed to make me a believer but just for a while. I still have got a problem with your leaps in logic and one would do well to fill in those gaps. When you actually can accomplish that, I would definitely end up being amazed.

  20. Undeniably believe that which you said. Your favorite reason appeared to be on the net the easiest factor to keep in mind of. I say to you, I definitely get annoyed whilst folks consider issues that they plainly do not know about. You controlled to hit the nail upon the top and also defined out the whole thing without having side effect , people could take a signal. Will probably be again to get more. Thank you

  21. Hello there, just became aware of your blog through Google, and found that it is really informative. I am going to watch out for brussels. I will appreciate if you continue this in future. A lot of people will be benefited from your writing. Cheers!

  22. You could definitely see your enthusiasm within the work you write. The sector hopes for even more passionate writers like you who aren’t afraid to say how they believe. All the time follow your heart.

  23. you’re in point of fact a good webmaster. The website loading velocity is incredible. It seems that you’re doing any unique trick. Also, The contents are masterpiece. you’ve performed a fantastic task in this matter!

  24. I’ve been absent for some time, but now I remember why I used to love this website. Thanks , I¦ll try and check back more frequently. How frequently you update your site?

  25. You really make it seem really easy together with your presentation however I in finding this matter to be actually something that I think I would never understand. It kind of feels too complicated and extremely large for me. I’m taking a look ahead for your next publish, I will try to get the dangle of it!

BİR CEVAP BIRAK

Lütfen yorumunuzu giriniz
Buraya isminizi giriniz