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.
  • T theoldfool

    There's Codon for that: [^]Python-based compiler achieves orders-of-magnitude speedups | MIT News | Massachusetts Institute of Technology[^]

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

    T Offline
    T Offline
    trønderen
    wrote on last edited by
    #27

    You rarely if ever find a Python supporter who will agree that some other compiled language is orders-of-magnitude faster than Python. Yet, when Python is compiled, it is speeded up by orders-of-magnitude. The only logical conclusion is that compiled Python is way faster than any other compiled language. Believe it if you want to.

    1 Reply Last reply
    0
    • T trønderen

      Dan Neely wrote:

      The chuckle[mastadon] s guilty of designing python have no such excuse.

      I was there when C pushed out Pascal (and Algol and Simula and ...). Lots of programmers argued in favor of C because they hated all the typing of BEGIN and END (and in some languages CASE - ESAC, DO - OD and PROCEDURE - ERUDECORP). I met lots of programmers who insisted that replacing keywords with braces speeded up their programming. Besides, they argued: All those keywords clutter up the program code. C, using braces for delimiters, is much cleaner, they insisted. Python is just taking this one step further. Why should you have to type a delimiter, if you indent the code? Why clutter up you code with braces? Besides: Using both delimiters and indentation opens for inconsistencies: You could be using a brace without indenting, and the reader might overlook it, or indenting without a brace, leading the reader to think that the indented code makes up a block. If you use indentation only, you avoid such problems. That is how the arguments go. Most modern programmers never wrote a compiler, not even a parser, an in any case, using indents for identifying blocks is not, and has never been, a resource saver. So that argument is never heard. I hope that I do not appear as if I am supporting these arguments! I am certainly not. I am much in favor of making structures very explicit. I want the compiler to check that redundant elements (like indent and textual markers) correspond, and to check that the label on the block close matches than of the block opening. I am definitely not a Python lover.

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

      It seems to be logical that adding these { } to Python with the same semantics as in C would save Python from a lot of criticism ... Like in Cython, where static typing has been added. AFAIK there is also syntax in Python to indicate variable types, but there is nothing done yet with this weird block structure ... :-). Is this feasible (?), perhaps not ... I am dreaming about Python 4.x with { } :-) it's TIOBE rating would probably skyrocket ...

      FreedMallocF 1 Reply Last reply
      0
      • C Chris Maunder

        Ya get used to it ;) (The thing that will do your head in is the error when you keep trying to do !var) Oh, and good luck with PIP. You've got this! :thumbsup::thumbsup:

        cheers Chris Maunder

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

        Chris Maunder wrote:

        good luck with PIP

        Peripheral Interchange Program? I haven't used that since my PDP-11 days.

        1 Reply Last reply
        0
        • P peterkmx

          It seems to be logical that adding these { } to Python with the same semantics as in C would save Python from a lot of criticism ... Like in Cython, where static typing has been added. AFAIK there is also syntax in Python to indicate variable types, but there is nothing done yet with this weird block structure ... :-). Is this feasible (?), perhaps not ... I am dreaming about Python 4.x with { } :-) it's TIOBE rating would probably skyrocket ...

          FreedMallocF Offline
          FreedMallocF Offline
          FreedMalloc
          wrote on last edited by
          #30

          As trønderen stated above, with braces whitespace becomes more or less immaterial and so it is, for the most part, with Java, C#, C, C++, etc. And that leads to not having to indent when structuring your code. I was always led to believe that one of the reasons Python made whitespace significant was to enforce "proper" code structure and now all those ugly 2-finger-typed brace characters can be eliminated. In a sense, they actually are there, they're just invisible - and therein lies the rub (at least to braceophiles like me).

          P 1 Reply Last reply
          0
          • L Lost User

            Never had a problem yet with pip. ;P I did say "yet", which probably means trouble the next time I use it.

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #31

            You've not had the: Package A needs version < X of Package B Package C needs version > X of package B Package D needs Package A and Package C /bangs head on desk

            cheers Chris Maunder

            1 Reply Last reply
            0
            • Mike HankeyM Mike Hankey

              Agreed but with intelligent Python editors why can't they convert between white space and tabs? 4 spaces = 1 tab

              PartsBin an Electronics Part Organizer - An updated version available! JaxCoder.com Latest Article: Simon Says, A Child's Game

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

              I use two SPACEs per TAB. The simple IDE I wrote can do it, even were I ever to use it for Python. On the other hand, a TAB-stop should be a certain width (e.g. a half inch), regardless of font and display medium, not measured in "character positions". If we could have that, then maybe TABs would make sense.

              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!

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

                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.

                H C J 3 Replies 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:

                  J Offline
                  J Offline
                  jmaida
                  wrote on last edited by
                  #34

                  Using a programming language named after a snake (a constrictor, no less) is maybe a sign. "the devil made me do it" I do not use python for the reasons mentioned (invisible code, tab and space blindness, etc.) I do use other's python code as pseudo code, of sorts, for C.

                  "A little time, a little trouble, your better day" Badfinger

                  G 1 Reply Last reply
                  0
                  • J jmaida

                    Using a programming language named after a snake (a constrictor, no less) is maybe a sign. "the devil made me do it" I do not use python for the reasons mentioned (invisible code, tab and space blindness, etc.) I do use other's python code as pseudo code, of sorts, for C.

                    "A little time, a little trouble, your better day" Badfinger

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

                    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 1 Reply Last reply
                    0
                    • FreedMallocF FreedMalloc

                      As trønderen stated above, with braces whitespace becomes more or less immaterial and so it is, for the most part, with Java, C#, C, C++, etc. And that leads to not having to indent when structuring your code. I was always led to believe that one of the reasons Python made whitespace significant was to enforce "proper" code structure and now all those ugly 2-finger-typed brace characters can be eliminated. In a sense, they actually are there, they're just invisible - and therein lies the rub (at least to braceophiles like me).

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

                      Yes, I agree ... I even do not notice anymore how I type them :-). I got so much used to them that code without them seems odd (and my brain is warning me - this won't work, so I get in persistent confusion when looking at standard Python code). Also, the missing ; in some languages' code bugs me a lot ... It seems that in Go it is implicit, for some strange reason ... (there is always a good reason for something like this :-) of course )

                      1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        :shudder: Not to diss on COBOL, but after thirty+ years I still remember having to help a fellow college student debug a COBOL program which wasn't working. She had used TABs to pad a string to the desired length -- it looked OK on a VT100, but the compiler knew better.

                        H Offline
                        H Offline
                        honey the codewitch
                        wrote on last edited by
                        #37

                        That's my main problem with Python as well. Tabs? Spaces? Who knows? Source code should not be invisible. I will make a grudging exception for line based grammars like Visual BASIC. At least that's manageable.

                        To err is human. Fortune favors the monsters.

                        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.

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #38

                          The reason I use tabs is Shift+Arrow = Highlight - Tab/Shift-Tab = indent/deindent the block of text. I use this so often when I code that I could scarcely be productive without it.

                          To err is human. Fortune favors the monsters.

                          P 1 Reply Last reply
                          0
                          • H honey the codewitch

                            The reason I use tabs is Shift+Arrow = Highlight - Tab/Shift-Tab = indent/deindent the block of text. I use this so often when I code that I could scarcely be productive without it.

                            To err is human. Fortune favors the monsters.

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

                            honey the codewitch wrote:

                            Tab/Shift-Tab = indent/deindent the block of text

                            Yes, using the TAB key, but it actually inserts/removes the necessary number of SPACEs rather than TABs. I don't see that TAB characters makes a difference in doing that.

                            H 1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              honey the codewitch wrote:

                              Tab/Shift-Tab = indent/deindent the block of text

                              Yes, using the TAB key, but it actually inserts/removes the necessary number of SPACEs rather than TABs. I don't see that TAB characters makes a difference in doing that.

                              H Offline
                              H Offline
                              honey the codewitch
                              wrote on last edited by
                              #40

                              Oh, I think my editor uses tabs. So I just use them too. It would be weird anyway for me switching between Tab and spacebar. In the end i always "Format Document" and I've got the process for that tailored more or less to my liking so it's easy and it works for me.

                              To err is human. Fortune favors the monsters.

                              P 1 Reply Last reply
                              0
                              • H honey the codewitch

                                Oh, I think my editor uses tabs. So I just use them too. It would be weird anyway for me switching between Tab and spacebar. In the end i always "Format Document" and I've got the process for that tailored more or less to my liking so it's easy and it works for me.

                                To err is human. Fortune favors the monsters.

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

                                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.

                                H W 2 Replies 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.

                                  H Offline
                                  H Offline
                                  honey the codewitch
                                  wrote on last edited by
                                  #42

                                  Ah, I getcha. Sorry. Yeah, I think my editor inserts 4 spaces when I hit tab.

                                  To err is human. Fortune favors the monsters.

                                  P 1 Reply Last reply
                                  0
                                  • H honey the codewitch

                                    Ah, I getcha. Sorry. Yeah, I think my editor inserts 4 spaces when I hit tab.

                                    To err is human. Fortune favors the monsters.

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

                                    I used to do four, but I've cut down to two. Which is bizarre considering the tiny (8 pt) font I use for code.

                                    M 1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      I used to do four, but I've cut down to two. Which is bizarre considering the tiny (8 pt) font I use for code.

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

                                      No, it’s logical: four spaces would indent too much in relation to font size. Full disclosure: I also use two spaces and a tiny font :-D

                                      Mircea

                                      P 1 Reply Last reply
                                      0
                                      • M Mircea Neacsu

                                        No, it’s logical: four spaces would indent too much in relation to font size. Full disclosure: I also use two spaces and a tiny font :-D

                                        Mircea

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

                                        I have the opposite opinion, I think the indent should remain constant (maybe about a 1/4 or a 1/2 inch) regardless of font size, so a tab-stop would use fewer character-places with a larger font and more with a smaller one. But I know of no IDE which uses absolute tab-stops -- I wouldn't willingly code in a word processor.

                                        M 1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

                                          I have the opposite opinion, I think the indent should remain constant (maybe about a 1/4 or a 1/2 inch) regardless of font size, so a tab-stop would use fewer character-places with a larger font and more with a smaller one. But I know of no IDE which uses absolute tab-stops -- I wouldn't willingly code in a word processor.

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

                                          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

                                          P J 2 Replies 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