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. Python problems...

Python problems...

Scheduled Pinned Locked Moved The Lounge
python
73 Posts 29 Posters 0 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.
  • G glennPattonWork3

    To be perfectly honest I think the retail price of Python has more to do with it popularity than anything else. Remember you get what you pay for. :omg:

    T Offline
    T Offline
    theoldfool
    wrote on last edited by
    #48

    Granted, the "price is right". Python is very handy for one-off kind of stuff. I am using it to debug/tune Chris's CP-AI used with Blue Iris, mostly BI settings. Watch for a change in the BI log, filter it with what I am looking for and send me an SMS. Handy to get a heads up so as to check out the event. Maybe trivial, but handy. Also use it from time to time as a syslog server when looking for people trying to access sites they don't belong on using the corp LAN. Cleanup after ransomware is no fun. Now, this payroll program I an writing with Python is more of a struggle. :) An intellectual is someone who can listen to the William Tell Overture and not think of the Lone Ranger. ¯\_(ツ)_/¯

    >64 Some days the dragon wins. Suck it up.

    1 Reply Last reply
    0
    • P PIEBALDconsult

      I'm not talking about using the spacebar to indent code. I don't think the issue is about what key is pressed, but about what characters are produced and stored. Back when using a VT we had to indent by using the spacebar. But with modern(ish) IDEs we use the TAB key, and have it insert either SPACEs or TABs as configured -- the result looks the same, but it isn't. I don't recall what Turbo Pascal and C/C++ did with TABs. When I use Notepad, I still have to use the spacebar to indent because it uses eight-character-wide TAB-stops, but I don't use that for code.

      W Offline
      W Offline
      Wizard of Sleeves
      wrote on last edited by
      #49

      Tab spaces should be in half-inches or centimeters, depending where you live. Not characters.

      Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.

      P 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Worse: space and tab are not the same: so two lines which look to be identically indented in your chosen editor can be in different code blocks as a tab is one whitespace regardless of the visual effect. X|

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        A Offline
        A Offline
        alang_icon
        wrote on last edited by
        #50

        Why don't Python editors indicate tabs/spaces with some sort of symbol? Perhaps '{' for tab and ' ' for space. To be even more helpful, the editor could indicate the end of a block with '}' ?

        1 Reply Last reply
        0
        • G glennPattonWork3

          Hi All, Being strongly encouraged (read forced) to use Python for a test rig. Okay need to get down with Kids etc. but syntactic white space 'align your tabs' (who came up with that, is it 1988, am I using a BBC micro) oh gord!!!:mad:

          K Offline
          K Offline
          Kate X257
          wrote on last edited by
          #51

          Ok, so, I'm going to give you the single best use-case for bothering with Python. Jupyter Notebooks. It's a webserver-based environment to document, script, and generate results in a single document. You can transform notebooks into slides, so you can teach a class. You can effectively collab with people on notebooks, so you can do research across the globe. You can generate and plot all manner of graphs, so you can use it to prove something. There's markup and HTML support if you need it. Anything else --> don't use Python

          G 1 Reply Last reply
          0
          • P PIEBALDconsult

            OriginalGriff wrote:

            "use tabs" to save file space

            I'm quite certain that isn't the reasoning. I think some TABophiles use TABs to save keystrokes. I, of course, use two SPACEs per TAB and otherwise a whole :elephant:ing load of whitespace, vertical space in particular. I am not interested in "saving space" or "saving keystrokes" I need space so I can read the stuff. The simple IDE I developed for myself defaults to TABs because there is no reasonable number of SPACEs to use as a default instead. But what can save file space is that it right-trims SPACEs from lines when it saves a file -- that eliminates a lot more characters from saved files than using TABs.

            C Offline
            C Offline
            Cpichols
            wrote on last edited by
            #52

            I do not understand why anyone uses spaces tbh. I also set my tab spacing to 2, but most of the legacy code I work on - and even some of the newer stuff added to that legacy code - uses spaces, and are thus untidy along the left margin and often not collapsible. Use tabs, for the love of pretty code, and for that matter, used blank lines between logical blocks. And concise comments.

            P 1 Reply Last reply
            0
            • K Kate X257

              Ok, so, I'm going to give you the single best use-case for bothering with Python. Jupyter Notebooks. It's a webserver-based environment to document, script, and generate results in a single document. You can transform notebooks into slides, so you can teach a class. You can effectively collab with people on notebooks, so you can do research across the globe. You can generate and plot all manner of graphs, so you can use it to prove something. There's markup and HTML support if you need it. Anything else --> don't use Python

              G Offline
              G Offline
              glennPattonWork3
              wrote on last edited by
              #53

              Finished the tutorial I had to do, I can say it gets around some problems (& creates it own) but there never issues I have had I mean 'you can create a web server in two lines', a good 90% of the code I have written is embedded (except a few test rig software front ends), by embedded I mean small memory, limited output and tends to be mounted in a hole under ground or under water. So web is not an issue...

              1 Reply Last reply
              0
              • C Cpichols

                I do not understand why anyone uses spaces tbh. I also set my tab spacing to 2, but most of the legacy code I work on - and even some of the newer stuff added to that legacy code - uses spaces, and are thus untidy along the left margin and often not collapsible. Use tabs, for the love of pretty code, and for that matter, used blank lines between logical blocks. And concise comments.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #54

                I see no reason it wouldn't be collapsible. What IDE can't collapse it? How does your code look if you open it in another IDE/editor? Open it in Notepad for instance.

                C 1 Reply Last reply
                0
                • W Wizard of Sleeves

                  Tab spaces should be in half-inches or centimeters, depending where you live. Not characters.

                  Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #55

                  I agree, but only as an ideal as I know no IDE which can do that.

                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    I see no reason it wouldn't be collapsible. What IDE can't collapse it? How does your code look if you open it in another IDE/editor? Open it in Notepad for instance.

                    C Offline
                    C Offline
                    Cpichols
                    wrote on last edited by
                    #56

                    a slight exaggeration and significant simplification:

                    some code
                    some more code that should be on the same tab as the above, but here's a loop
                    {
                    code that loops or whatever

                    // a comment
                    }

                          // a comment
                          code loop
                     {
                        code
                    

                    }

                    1 Reply Last reply
                    0
                    • P peterkmx

                      OK, "risible" ... thanks, never heard of it :-)

                      A Offline
                      A Offline
                      Alister Morton
                      wrote on last edited by
                      #57

                      You don't remember "Life of Brian" with the centurion who can't stop laughing at the name "Biggus Dickus". "Do you find it wisible?"

                      P 1 Reply Last reply
                      0
                      • M Mircea Neacsu

                        Let’s agree to disagree :) There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font size. Your artistic eye might know better than your logical brain :)

                        Mircea

                        J Offline
                        J Offline
                        jschell
                        wrote on last edited by
                        #58

                        Mircea Neacsu wrote:

                        There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font siz

                        True. However English text is the not the same as programming. I read English very fast and often deliberating skip parts. Certainly I am generally oblivious to periods. But ignoring a period in programming would be a bad idea. In the editor I use the typeface is specifically not proportional. I have tried it and found it to be a very bad idea. In English text the layout of the text seldom has meaning. In programming the layout does convey information such as easily seeing blocks.

                        M 1 Reply Last reply
                        0
                        • P PIEBALDconsult

                          OriginalGriff wrote:

                          "use tabs" to save file space

                          I'm quite certain that isn't the reasoning. I think some TABophiles use TABs to save keystrokes. I, of course, use two SPACEs per TAB and otherwise a whole :elephant:ing load of whitespace, vertical space in particular. I am not interested in "saving space" or "saving keystrokes" I need space so I can read the stuff. The simple IDE I developed for myself defaults to TABs because there is no reasonable number of SPACEs to use as a default instead. But what can save file space is that it right-trims SPACEs from lines when it saves a file -- that eliminates a lot more characters from saved files than using TABs.

                          J Offline
                          J Offline
                          jschell
                          wrote on last edited by
                          #59

                          PIEBALDconsult wrote:

                          I think some TABophiles use TABs to save keystrokes.

                          I use spacing to provide formatting. Tabs in a file, not spaces allows one to skip backwards with fewer keystrokes. Never seen that happen with pseudo spaces (tabbing but with space replacement.) Since I am also very much a touch typist auto indenting tends to be a hinderance since it tends to break my train of thought. While tabbing (space replacement or not) is fewer keystrokes to get to where I actually want to be without it.

                          P 1 Reply Last reply
                          0
                          • J jschell

                            PIEBALDconsult wrote:

                            I think some TABophiles use TABs to save keystrokes.

                            I use spacing to provide formatting. Tabs in a file, not spaces allows one to skip backwards with fewer keystrokes. Never seen that happen with pseudo spaces (tabbing but with space replacement.) Since I am also very much a touch typist auto indenting tends to be a hinderance since it tends to break my train of thought. While tabbing (space replacement or not) is fewer keystrokes to get to where I actually want to be without it.

                            P Offline
                            P Offline
                            PIEBALDconsult
                            wrote on last edited by
                            #60

                            jschell wrote:

                            skip backwards with fewer keystrokes

                            Yes, I can see that, but it isn't that big of a deal for me, in fact I think I frequently use the mouse to do that, which is worse. Also, when using two SPACEs per indent it's less of a burden than with four.

                            jschell wrote:

                            a touch typist

                            I definitely am not, but coding is like writing literature, so it's OK.

                            jschell wrote:

                            auto indenting tends to be a hinderance

                            Unsure what you are referring to. If you mean having a new line auto-indented to the same level as the previous when you hit RETURN, I like that. With my coding format style, I have a lot of indent levels, so that saves me type.

                            jschell wrote:

                            it tends to break my train of thought

                            There are still things Visual Studio does which I don't like and I seem to have no control over them, and I occasionally have to UNDO (Ctrl-Z) an auto-formatting change it made. It's part of why I wrote my own simple IDE which does only what I want it to.

                            1 Reply Last reply
                            0
                            • A Alister Morton

                              You don't remember "Life of Brian" with the centurion who can't stop laughing at the name "Biggus Dickus". "Do you find it wisible?"

                              P Offline
                              P Offline
                              peterkmx
                              wrote on last edited by
                              #61

                              Oh no ... 😊 this is not my cup of tea, I’ve seen one or 2 fragments on YT a few years ago, and I found it ridiculous, beyond strange, not really interesting ... Thus risible fits here also I guess, but why “wisible”? 😊 My intuition says that this is the pronunciation from the movie - is this guess correct?

                              A 1 Reply Last reply
                              0
                              • M MarkTJohnson

                                Considering it was named after the people who gave us the Ministry of Silly Walks, Dead Parrots, and the Argument Sketch, what else would you expect?

                                honey the codewitch wrote:

                                It's risible.

                                Had to look that word up, which caused me to be risible.

                                I’ve given up trying to be calm. However, I am open to feeling slightly less agitated. I’m begging you for the benefit of everyone, don’t be STUPID.

                                P Offline
                                P Offline
                                peterkmx
                                wrote on last edited by
                                #62

                                You are not the only one ... I must admit I looked it up, too :-), feel safer now

                                1 Reply Last reply
                                0
                                • J jschell

                                  Mircea Neacsu wrote:

                                  There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font siz

                                  True. However English text is the not the same as programming. I read English very fast and often deliberating skip parts. Certainly I am generally oblivious to periods. But ignoring a period in programming would be a bad idea. In the editor I use the typeface is specifically not proportional. I have tried it and found it to be a very bad idea. In English text the layout of the text seldom has meaning. In programming the layout does convey information such as easily seeing blocks.

                                  M Offline
                                  M Offline
                                  Mircea Neacsu
                                  wrote on last edited by
                                  #63

                                  I didn’t say the text of a program is the same as the text of a novel. What I do say however is that people writing programs could use a bit from the centuries of experience of typographers. It might be one of my (many) obsessions, but being somewhat dyslexic, I pay a lot of attention to things like font typeface, tab sizes page layout and such. When things go well, my programs are a thing of beauty in content and form. That happens rarely 🤪

                                  Mircea

                                  J 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    Most editors can, but they tend to default to "use tabs" to save file space. And some only do it for modified lines, and ... it's a mess. Just don't use Python is my advice! :laugh:

                                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                    W Offline
                                    W Offline
                                    WPerkins
                                    wrote on last edited by
                                    #64

                                    Just add braces. For the "purists" make them optional. I have set a new project NPP policy: No Python Period. Cannot find a compelling reason to introduce chaos just to be trendy.

                                    1 Reply Last reply
                                    0
                                    • H honey the codewitch

                                      I refer to it as "invisible source code" because that's what significant whitespace is. And it's just as stupid as it sounds. How do you debug that which you cannot see? It's risible.

                                      To err is human. Fortune favors the monsters.

                                      N Offline
                                      N Offline
                                      Nelek
                                      wrote on last edited by
                                      #65

                                      honey the codewitch wrote:

                                      How do you debug that which you cannot see?

                                      Casting a spell to make it visible? Using talcum powder? Asking a blind colleague to do it for you?

                                      M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                                      1 Reply Last reply
                                      0
                                      • OriginalGriffO OriginalGriff

                                        Worse: space and tab are not the same: so two lines which look to be identically indented in your chosen editor can be in different code blocks as a tab is one whitespace regardless of the visual effect. X|

                                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                        A Offline
                                        A Offline
                                        Al Fargnoli
                                        wrote on last edited by
                                        #66

                                        Get a better editor!

                                        1 Reply Last reply
                                        0
                                        • K Kenneth Haugland

                                          It is scripted so it's slower than .NET code. And the UI? :~

                                          A Offline
                                          A Offline
                                          Al Fargnoli
                                          wrote on last edited by
                                          #67

                                          But it gives the correct answers when you have complex variables. Dot-net can't do that.

                                          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