Announcement

Collapse
No announcement yet.

Python 3.4 Steps Closer With New Features

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Personally I don't like Python that much, but you can't say it's different than any of these so called "real" OOP languages with respect to private methods. You can call private methods in PHP, Java and C# via reflection. Works like a charm

    Comment


    • #17
      Originally posted by uid313 View Post
      Prefixing method names with underscore isn't OOP and doesn't make it private.
      It is just you pretending that it is private.
      You presumably use Linux. Making things private should make your blood boil. Python has an "We're all adults here" philosophy just like Linux (and probably why so many of its users develop on Linux). It's not "pretending" that it is private. That is a convention in Python that indicates private. If a user chooses to ignore documentation or needs to get at the variable anyway, they've been warned and are responsible for what happens next. That's the Linux way, the Python way, and arguably the one true free way.

      Python doesn't force things on people. Someone once said that some languages put up barbed wire and land mines to prevent developers from doing certain bad things. Python employs rainbows and sunshine on the good path instead so users are never tempted to go down the bad paths.

      Comment


      • #18
        Hehe, I like this idea:

        The real solution is to create super-private attributes prefixed with three underscores, and have __getattribute__() terminate the program and format the user's hard drive if they try to access them directly. That'll show 'em.

        Comment


        • #19
          Python=Hipster Language

          Comment


          • #20
            Originally posted by monraaf View Post
            Python=Hipster Language
            If that graph defines "popular" as "what I like to use most" then I think it is probably true. If it is popular as in "most used" I would doubt that the sampling was done in a very good way.
            That said, I use Python for everything if possible. I very seldom have to look for another tool.

            Comment


            • #21
              For me OOP is how you think about the code. You can use this thoughts with most language, either if the language designer think you should or not. With some language its easy and with some language its harder. Most people think its easy to think in a OOP way with python.

              Comment


              • #22
                As a c++ guy I have to agree with the python view. For me the whole c++ qualifier, encapsulation business is nothing more than language enforced coding/documentation convention (and performance/optimisation help to some degree).

                It would work just fine without, maybe except for the const qualifier, a must for any language that allows mutable objects imho.

                Comment


                • #23
                  Originally posted by alcalde View Post
                  Python doesn't force things on people. Someone once said that some languages put up barbed wire and land mines to prevent developers from doing certain bad things. Python employs rainbows and sunshine on the good path instead so users are never tempted to go down the bad paths.
                  I disagree, Python is the very example of languages that force things on people. Let's start with its absolutely horrible forced indentation.

                  Comment


                  • #24
                    Originally posted by curaga View Post
                    I disagree, Python is the very example of languages that force things on people. Let's start with its absolutely horrible forced indentation.
                    Which is different than forced braces or forced end statements how, exactly?

                    Comment


                    • #25
                      Originally posted by TheBlackCat View Post
                      Which is different than forced braces or forced end statements how, exactly?
                      I can format my braces however I want. I can't use what indentation I like with python. It's quite a different degree of forcing.

                      Comment


                      • #26
                        Originally posted by curaga View Post
                        I can format my braces however I want.
                        And there's your problem right there

                        Yes, the indentation-controls-scope feature of Python is a bit scary when you start. And it is horrible when you have very long blocks of code.
                        But the neat thing is that since that is horrible, you will actively try to make your blocks of code shorter which usually means prettier and more understandable.

                        EDIT:
                        Also, the problem with scope and long blocks of code is primarily when they are both long and have deep nestings. So avoid long deep nestings

                        Comment


                        • #27
                          Originally posted by curaga View Post
                          I disagree, Python is the very example of languages that force things on people. Let's start with its absolutely horrible forced indentation.
                          I love the forced indention in Python.
                          It encourages clean code, code sharing, code re-use and consistent code style.
                          It's just too bad the amount of indention is optional, PEP 8 document specifies that 4 spaces should be used, but some people use 2, 3 and 8 spaces.

                          Comment


                          • #28
                            Originally posted by uid313 View Post
                            I love the forced indention in Python.
                            It encourages clean code, code sharing, code re-use and consistent code style.
                            Agreed
                            It's just too bad the amount of indention is optional, PEP 8 document specifies that 4 spaces should be used, but some people use 2, 3 and 8 spaces.
                            Or just plain tabs

                            Comment


                            • #29
                              Originally posted by curaga View Post
                              I can format my braces however I want. I can't use what indentation I like with python. It's quite a different degree of forcing.
                              You can't escape syntax; in other languages you can't escape using braces. In Python indentation is syntax, so you can't escape it eiter.
                              By the way in 10 years of programming I have never seen a brace-language project that had code indented in a way that wasn't not 100% standard - aside from the cases where it was recognized bad code and eventually fixed.

                              Comment


                              • #30
                                Originally posted by pankkake View Post
                                By the way in 10 years of programming I have never seen a brace-language project that had code indented in a way that wasn't not 100% standard.
                                Because it's so easy with brace-languages! You write your code in sloppy and formless way and just run an indention program on save I love the brace-languages!

                                Comment

                                Working...
                                X