Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. I have such mixed feelings about python

I have such mixed feelings about python

Scheduled Pinned Locked Moved The Lounge
pythonquestionlounge
34 Posts 15 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • OriginalGriffO OriginalGriff

    honey the codewitch wrote:

    Is 4 spaces read the same way as a tab?

    No. A tab is one whitespace character, four spaces are four - so the compiler looks at identical looking code in your editor and thinks that it's differently indented. There have been quite a few question this year where that has been the problem. And that's one of the reasons I really don't like Python.

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

    K Offline
    K Offline
    kalberts
    wrote on last edited by
    #4

    Another problem with whitespace is which definition of whitespace. Python scopes by a subset of whitespace characters. I guess this subset is defined in a language spec, but there is only one way to be reasonably sure to avoid problems: Whenever anyone says "whitespace", read it as "a space character".

    honey the codewitchH 1 Reply Last reply
    0
    • R Rage

      So, refusing to use a hammer to take care of a nail just because the handle is pink coloured instead of wooden coloured ? ;P

      Do not escape reality : improve reality !

      honey the codewitchH Offline
      honey the codewitchH Offline
      honey the codewitch
      wrote on last edited by
      #5

      More because the handle is invisible, if we're extending the analogy to whitespace :)

      Real programmers use butterflies

      R 1 Reply Last reply
      0
      • R Rage

        So, refusing to use a hammer to take care of a nail just because the handle is pink coloured instead of wooden coloured ? ;P

        Do not escape reality : improve reality !

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #6

        When there are better looking hammers, yes. ;)

        Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

        honey the codewitchH 1 Reply Last reply
        0
        • honey the codewitchH honey the codewitch

          More because the handle is invisible, if we're extending the analogy to whitespace :)

          Real programmers use butterflies

          R Offline
          R Offline
          Rage
          wrote on last edited by
          #7

          AND that the accuracy of the hammer differs depending on the size of the handle. Which is kind of a terrible analogy, since it is indeed that way in reality :sigh:

          Do not escape reality : improve reality !

          1 Reply Last reply
          0
          • Z ZurdoDev

            When there are better looking hammers, yes. ;)

            Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

            honey the codewitchH Offline
            honey the codewitchH Offline
            honey the codewitch
            wrote on last edited by
            #8

            this :)

            Real programmers use butterflies

            1 Reply Last reply
            0
            • honey the codewitchH honey the codewitch

              I'm not a python dev. I have written exactly zero bits of software in it. That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python. I'm guessing that's probably why it's so popular with the AI crowd. The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences. **I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.

              Real programmers use butterflies

              Sander RosselS Offline
              Sander RosselS Offline
              Sander Rossel
              wrote on last edited by
              #9

              I once spent an hour finding a bug in a Haskell program. It was a homework assignment so it needed to run, but I kept getting "variable not defined" or some such. Turned out one line in a give or take 50 lines application was indented with a tab instead of spaces :sigh:

              Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

              honey the codewitchH 1 Reply Last reply
              0
              • honey the codewitchH honey the codewitch

                I'm not a python dev. I have written exactly zero bits of software in it. That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python. I'm guessing that's probably why it's so popular with the AI crowd. The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences. **I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.

                Real programmers use butterflies

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #10

                honey the codewitch wrote:

                Is 4 spaces read the same way as a tab?

                If you use a Python aware editor you probably don't need to care. I use IDLE (the Python IDE), and Visual Studio Code. Both of them handle the indentation perfectly so it is not much of an issue. Until you want to reformat the file in a different editor.

                honey the codewitchH 1 Reply Last reply
                0
                • K kalberts

                  Another problem with whitespace is which definition of whitespace. Python scopes by a subset of whitespace characters. I guess this subset is defined in a language spec, but there is only one way to be reasonably sure to avoid problems: Whenever anyone says "whitespace", read it as "a space character".

                  honey the codewitchH Offline
                  honey the codewitchH Offline
                  honey the codewitch
                  wrote on last edited by
                  #11

                  I agree though I'll say I've written enough parsers and grammars that I guess I expect it to be a language specific subset of whitespace (the JSON standard grammar has a similar issue) but that's me. It's rare that I've found languages that accept literally any whitespace you can throw at it. I think C# is an exception in that it can handle it (but I'd have to look to be certain)

                  Real programmers use butterflies

                  1 Reply Last reply
                  0
                  • Sander RosselS Sander Rossel

                    I once spent an hour finding a bug in a Haskell program. It was a homework assignment so it needed to run, but I kept getting "variable not defined" or some such. Turned out one line in a give or take 50 lines application was indented with a tab instead of spaces :sigh:

                    Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                    honey the codewitchH Offline
                    honey the codewitchH Offline
                    honey the codewitch
                    wrote on last edited by
                    #12

                    significant whitespace has no place in language grammars. It's poor design. People will argue about that maybe, but the proof is in the results. Like you said, it took you an hour to find that invisible bug.

                    Real programmers use butterflies

                    J Sander RosselS 2 Replies Last reply
                    0
                    • L Lost User

                      honey the codewitch wrote:

                      Is 4 spaces read the same way as a tab?

                      If you use a Python aware editor you probably don't need to care. I use IDLE (the Python IDE), and Visual Studio Code. Both of them handle the indentation perfectly so it is not much of an issue. Until you want to reformat the file in a different editor.

                      honey the codewitchH Offline
                      honey the codewitchH Offline
                      honey the codewitch
                      wrote on last edited by
                      #13

                      Having to use a language aware editor so that it doesn't actually destroy your code is a huge red flag in terms of language design, IMO. Significant whitespace has no place in language grammars. It's poor design. The proof is in the confusion and other problems it generates, like literally invisible syntax/"compilation" errors in source code.

                      Real programmers use butterflies

                      L 1 Reply Last reply
                      0
                      • honey the codewitchH honey the codewitch

                        I'm not a python dev. I have written exactly zero bits of software in it. That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python. I'm guessing that's probably why it's so popular with the AI crowd. The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences. **I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.

                        Real programmers use butterflies

                        M Offline
                        M Offline
                        Marc Clifton
                        wrote on last edited by
                        #14

                        honey the codewitch wrote:

                        The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences.

                        I agree, though I did get used to the significant whitespace in F#, and other FP languages use that as well, which of course leads to the problem Sander described. As to scripting, I comfort myself in that any of the heavy lifting is done behind the scenes in C, so the way I think about it is, all Python really is is a more sophisticated language (as compared to say, a .bat file) for gluing together calls to compiled code. Like any scripting language, I find that it requires its own unique discipline to write decent code - many disciplines are the same, like DRY, but each language has its own unique set of "best practice" disciplines, and Python is no exception.

                        Latest Articles:
                        Abusing Extension Methods, Null Continuation, and Null Coalescence Operators

                        honey the codewitchH 1 Reply Last reply
                        0
                        • honey the codewitchH honey the codewitch

                          significant whitespace has no place in language grammars. It's poor design. People will argue about that maybe, but the proof is in the results. Like you said, it took you an hour to find that invisible bug.

                          Real programmers use butterflies

                          J Offline
                          J Offline
                          John R Shaw
                          wrote on last edited by
                          #15

                          :thumbsup: It is hard enough to finds the ones you can actually see.

                          INTP "Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra "I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone

                          1 Reply Last reply
                          0
                          • M Marc Clifton

                            honey the codewitch wrote:

                            The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences.

                            I agree, though I did get used to the significant whitespace in F#, and other FP languages use that as well, which of course leads to the problem Sander described. As to scripting, I comfort myself in that any of the heavy lifting is done behind the scenes in C, so the way I think about it is, all Python really is is a more sophisticated language (as compared to say, a .bat file) for gluing together calls to compiled code. Like any scripting language, I find that it requires its own unique discipline to write decent code - many disciplines are the same, like DRY, but each language has its own unique set of "best practice" disciplines, and Python is no exception.

                            Latest Articles:
                            Abusing Extension Methods, Null Continuation, and Null Coalescence Operators

                            honey the codewitchH Offline
                            honey the codewitchH Offline
                            honey the codewitch
                            wrote on last edited by
                            #16

                            all true. my main issues with scripting are these: 1. Usually because of duck typing and lack of full compilation and such errors can be harder to track down. 2. In terms of performance it is so often hard to know exactly what is going to cause the performance issues, or worse, sometimes there isn't a reasonable way around it. That's fine, when scripting is used here and there in moderation, but it's a different story when you're powering an entire application with it.

                            Real programmers use butterflies

                            R M 2 Replies Last reply
                            0
                            • honey the codewitchH honey the codewitch

                              I'm not a python dev. I have written exactly zero bits of software in it. That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python. I'm guessing that's probably why it's so popular with the AI crowd. The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences. **I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.

                              Real programmers use butterflies

                              J Offline
                              J Offline
                              Jorgen Andersson
                              wrote on last edited by
                              #17

                              honey the codewitch wrote:

                              I'm guessing that's probably why it's so popular with the AI crowd.

                              I had a workmate showing me all these cool things you could do with Python and AI, and especially Machine Learning. It could all be broken down into different ways of calling a library, written in C.

                              Wrong is evil and must be defeated. - Jeff Ello

                              honey the codewitchH K 2 Replies Last reply
                              0
                              • J Jorgen Andersson

                                honey the codewitch wrote:

                                I'm guessing that's probably why it's so popular with the AI crowd.

                                I had a workmate showing me all these cool things you could do with Python and AI, and especially Machine Learning. It could all be broken down into different ways of calling a library, written in C.

                                Wrong is evil and must be defeated. - Jeff Ello

                                honey the codewitchH Offline
                                honey the codewitchH Offline
                                honey the codewitch
                                wrote on last edited by
                                #18

                                I've browsed github python repositories and found much more than that therein. I think your workmate maybe didn't give you the best example. Unfortunately I don't have a better one handy, as my level of involvement in all of this is as a passing interest.

                                Real programmers use butterflies

                                J 1 Reply Last reply
                                0
                                • honey the codewitchH honey the codewitch

                                  I've browsed github python repositories and found much more than that therein. I think your workmate maybe didn't give you the best example. Unfortunately I don't have a better one handy, as my level of involvement in all of this is as a passing interest.

                                  Real programmers use butterflies

                                  J Offline
                                  J Offline
                                  Jorgen Andersson
                                  wrote on last edited by
                                  #19

                                  honey the codewitch wrote:

                                  I think your workmate maybe didn't give you the best example

                                  They were to me. :-\

                                  Wrong is evil and must be defeated. - Jeff Ello

                                  1 Reply Last reply
                                  0
                                  • honey the codewitchH honey the codewitch

                                    significant whitespace has no place in language grammars. It's poor design. People will argue about that maybe, but the proof is in the results. Like you said, it took you an hour to find that invisible bug.

                                    Real programmers use butterflies

                                    Sander RosselS Offline
                                    Sander RosselS Offline
                                    Sander Rossel
                                    wrote on last edited by
                                    #20

                                    With a right editor you can make them visible. Something like ...my code vs. -> my code. But that creates a lot of noise on your screen and doesn't contribute to readability. Even better, an editor that always converts tabs to spaces, which I think VS does too (or at least it's a setting). Everyone on the team should always use the same amount of spaces for all projects though. Not having that is annoying in C#, but probably disastrous in Python (or Haskell). All in all, I don't think it has to be a problem. I've been doing some YAML lately and I couldn't even get it to break because my (web) editor just wouldn't allow it. If the code is properly formatted and the spaces are invisible I think it looks pretty and concise though.

                                    Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                                    1 Reply Last reply
                                    0
                                    • honey the codewitchH honey the codewitch

                                      I'm not a python dev. I have written exactly zero bits of software in it. That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python. I'm guessing that's probably why it's so popular with the AI crowd. The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences. **I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.

                                      Real programmers use butterflies

                                      A Offline
                                      A Offline
                                      Amarnath S
                                      wrote on last edited by
                                      #21

                                      Notepad++ enables us to clearly differentiate spaces from tabs.

                                      B 1 Reply Last reply
                                      0
                                      • R Rage

                                        So, refusing to use a hammer to take care of a nail just because the handle is pink coloured instead of wooden coloured ? ;P

                                        Do not escape reality : improve reality !

                                        theoldfoolT Offline
                                        theoldfoolT Offline
                                        theoldfool
                                        wrote on last edited by
                                        #22

                                        I usually need a bigger hammer. :) I think we all tend to look at something newish as a replacement for our current "hammer".. I find python to be very handy to work out what someone really wants. A friend has a bunch of (older) IoT controllers in an office building. The interface is via a built in web server in each controller. He wants to collect the data remotely. Turns out that these things will contact a syslog server if you configure it. Wrote the initial server in python to figure out what data he wanted to parse out and how to format it. Then rewrote it in C++ (runs on a W7 system). Reason to rewrite? Since the controllers are independent, and clashes are probable, performance was high priority... Windows is not an RTOS. Do they miss an occasional event? Probably, how would we know? Lou -- Give a man a fish; you have fed him for today. Teach a man to use the Internet and he won't bother you for weeks, or even months unless you give him your email address. ¯\_(ツ)_/¯

                                        If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.

                                        1 Reply Last reply
                                        0
                                        • honey the codewitchH honey the codewitch

                                          I'm not a python dev. I have written exactly zero bits of software in it. That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python. I'm guessing that's probably why it's so popular with the AI crowd. The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences. **I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.

                                          Real programmers use butterflies

                                          B Offline
                                          B Offline
                                          BillWoodruff
                                          wrote on last edited by
                                          #23

                                          What gob-smacks me about Python is its popularity. What did it offer that made it attractive ? An easy way for digital nomads to put up websites ?

                                          «One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali

                                          K 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups