News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPImpact Blog:
No need for set/get methods in Python
August 18, 2008 @ 12:06:37

Federico compares two languages in this new post to the PHP::Impact blog today - PHP and Python - in their need for "getters" and "setters".

Python code doesn't typically use the get and set methods so common in PHP. Normally, when writing PHP code, you carefully protect your instance variables by making them private, so callers can only interact with them via getter and setter methods. [...] Python's solution to this problem is more readable, it has a construct called a "property".

He compares two blocks of code that do the same thing - set properties on the object with the PHP side doing a bit more error checking (seemingly) than the Python side. They both apply a title property to a book object.

1 comment voice your opinion now!
python compare getter setter example


blog comments powered by Disqus

Similar Posts

Setfive.com: PHP: Some thoughts on using array_* with closures

Stuart Herbert's Blog: Quick Tip: Get, Set and Query in One Method

Padraic Brady's Blog: Zend Framework Blog Tutorial - Part 7: Authorisation with Zend_Acl & Styling

Symfony Blog: New in symfony 1.2: Doctrine goodies

Etienne Kneuss' Blog: Late Static Bindings Explained


Community Events





Don't see your event here?
Let us know!


application interview api zendserver podcast release version community developer introduction conference tips development code list deployment laravel language framework series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework