Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39463 > unrolled thread

Python Newbie

Started byPiterrr <piterrr.dolinski@gmail.com>
First post2013-02-21 13:26 -0800
Last post2013-02-25 19:37 -0800
Articles 20 on this page of 161 — 34 participants

Back to article view | Back to comp.lang.python


Contents

  Python Newbie Piterrr <piterrr.dolinski@gmail.com> - 2013-02-21 13:26 -0800
    Re: Python Newbie Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-21 14:54 -0700
    Re: Python Newbie MRAB <python@mrabarnett.plus.com> - 2013-02-21 21:58 +0000
    Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-22 08:59 +1100
    Re: Python Newbie Peter Pearson <ppearson@nowhere.invalid> - 2013-02-21 22:03 +0000
    Re: Python Newbie Dave Angel <davea@davea.name> - 2013-02-21 17:22 -0500
    Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-21 14:40 -0800
      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-22 10:21 +1100
        Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-21 15:34 -0800
          Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-21 23:48 +0000
          Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-22 11:32 +1100
          Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 11:58 -0700
        Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-21 15:34 -0800
      Re: Python Newbie Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-21 23:27 +0000
      Re: Python Newbie Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-21 16:55 -0700
      Re: Python Newbie rusi <rustompmody@gmail.com> - 2013-02-21 22:57 -0800
      Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-22 10:26 +0000
        Re: Python Newbie Steve Simmons <square.steve@gmail.com> - 2013-02-22 12:05 +0100
        Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-22 22:23 +1100
      Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 16:04 -0700
      Re: Python Newbie Vito De Tullio <vito.detullio@gmail.com> - 2013-02-24 09:23 +0100
      Re: Python Newbie "J.R." <groups_jr-1@yahoo.com.br> - 2013-02-24 23:02 -0300
        Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 21:03 -0500
          Re: Python Newbie "J.R." <groups_jr-1@yahoo.com.br> - 2013-02-24 23:35 -0300
          Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 13:31 +1100
    Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-21 19:35 -0500
    Re: Python Newbie Mitya Sirenef <msirenef@lightbird.net> - 2013-02-21 23:50 -0500
      Re: Python Newbie Rui Maciel <rui.maciel@gmail.com> - 2013-02-22 11:58 +0000
        Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-22 23:12 +1100
          Re: Python Newbie Rui Maciel <rui.maciel@gmail.com> - 2013-02-22 13:50 +0000
            Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-23 01:05 +1100
              Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-23 00:03 +0000
                Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-23 11:21 +1100
            Re: Python Newbie Duncan Booth <duncan.booth@invalid.invalid> - 2013-02-22 14:26 +0000
              Re: Python Newbie Steve Simmons <square.steve@gmail.com> - 2013-02-22 15:45 +0100
                Re: Python Newbie Duncan Booth <duncan.booth@invalid.invalid> - 2013-02-22 15:02 +0000
              Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-23 02:06 +1100
                Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-22 13:37 -0800
                  Re: Python Newbie Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-22 22:08 +0000
                  Re: Python Newbie Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-22 15:45 -0700
                    Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-22 15:38 -0800
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-23 11:17 +1100
                      Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-23 13:29 -0500
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-24 08:38 +1100
                      Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 15:52 -0700
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-24 10:18 +1100
                        Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-23 15:46 -0800
                          Re: Python Newbie Larry Hudson <orgnut@yahoo.com> - 2013-02-23 20:20 -0800
                            Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-24 14:34 +0000
                              Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 07:46 -0800
                                Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 02:52 +1100
                                  Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 11:22 -0500
                                Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-24 17:44 +0000
                                  Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 11:29 -0800
                                    Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-24 21:35 +0000
                                      Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 14:43 -0800
                                        Re: Python Newbie Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-24 18:05 -0500
                                        Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-24 23:13 +0000
                                      Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 14:43 -0800
                                        Re: Python Newbie Larry Hudson <orgnut@yahoo.com> - 2013-02-26 00:32 -0800
                                          Re: Python Newbie rurpy@yahoo.com - 2013-02-26 10:23 -0800
                                            Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-26 10:59 -0800
                                              Re: Python Newbie rurpy@yahoo.com - 2013-02-26 13:30 -0800
                                      Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-24 18:31 -0700
                                    Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 09:08 +1100
                                    Re: Python Newbie Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-24 23:18 +0000
                                    Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-24 22:51 +0000
                                      Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 15:38 -0800
                                        Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 10:45 +1100
                                        Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 15:53 -0800
                                          Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 16:08 -0800
                                            Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-25 00:28 +0000
                                            Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-25 00:38 +0000
                                            Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 16:33 -0800
                                            Re: Python Newbie Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-25 00:45 +0000
                                            Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 19:50 -0500
                                            Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-25 01:04 +0000
                                              Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 12:27 +1100
                                              Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-24 18:42 -0700
                                            Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 12:24 +1100
                                            Re: Python Newbie Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-25 01:44 +0000
                                            Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 12:53 +1100
                                            Re: Python Newbie MRAB <python@mrabarnett.plus.com> - 2013-02-25 02:23 +0000
                                            Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 18:59 -0800
                                          Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 16:08 -0800
                                          Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 19:42 -0500
                                      Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 15:38 -0800
                                    Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-24 23:21 +0000
                                Re: Python Newbie Dave Angel <davea@davea.name> - 2013-02-24 17:47 -0500
                                Re: Python Newbie Serhiy Storchaka <storchaka@gmail.com> - 2013-02-25 14:40 +0200
                              Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 07:46 -0800
                          Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 22:23 -0700
                      Re: Python Newbie MRAB <python@mrabarnett.plus.com> - 2013-02-24 00:11 +0000
                      Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-24 12:37 -0500
                      Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-24 10:56 -0700
                        Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 13:07 -0500
                      Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-24 21:01 -0500
                    Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-22 15:38 -0800
                  Re: Python Newbie Terry Reedy <tjreedy@udel.edu> - 2013-02-22 20:04 -0500
                    Re: Python Newbie rurpy@yahoo.com - 2013-02-22 18:48 -0800
                  Re: Python Newbie Mitya Sirenef <msirenef@lightbird.net> - 2013-02-22 20:47 -0500
                    Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-23 02:02 +0000
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-23 13:18 +1100
                        Re: Python Newbie Grant Edwards <invalid@invalid.invalid> - 2013-02-24 18:19 +0000
                          Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 07:25 +1100
                      Re: Python Newbie Mitya Sirenef <msirenef@lightbird.net> - 2013-02-22 21:40 -0500
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-23 13:48 +1100
                      Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-23 02:59 +0000
                      Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-23 13:34 -0500
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-24 08:40 +1100
                      Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-24 12:41 -0500
                  Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-23 04:13 +0000
                    Re: Python Newbie Serhiy Storchaka <storchaka@gmail.com> - 2013-02-23 11:48 +0200
                  Re: Python Newbie Rui Maciel <rui.maciel@gmail.com> - 2013-02-23 12:30 +0000
                  Re: Python Newbie Steve Simmons <square.steve@gmail.com> - 2013-02-23 16:43 +0100
                    Re: Python Newbie jmfauth <wxjmfauth@gmail.com> - 2013-02-23 10:44 -0800
                      Re: Python Newbie Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-23 12:13 -0700
                      Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-23 11:08 -0800
                        Re: Python Newbie jmfauth <wxjmfauth@gmail.com> - 2013-02-23 12:53 -0800
                          Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-24 08:48 +1100
                          Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-24 00:02 +0000
                      Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 12:16 -0700
                      Re: Python Newbie Matej Cepl <mcepl@redhat.com> - 2013-02-24 00:06 +0100
                  Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-24 02:51 +1100
                    Re: Python Newbie Matej Cepl <mcepl@redhat.com> - 2013-02-24 00:04 +0100
                  Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-23 08:32 -0800
                  Re: Python Newbie Steve Simmons <square.steve@gmail.com> - 2013-02-23 18:39 +0100
                  Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 12:19 -0700
                  Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-24 17:11 +0000
                    Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 11:40 -0800
                      Re: Python Newbie Mitya Sirenef <msirenef@lightbird.net> - 2013-02-24 15:06 -0500
                      Re: Python Newbie "Michael Ross" <gmx@ross.cx> - 2013-02-24 21:33 +0100
                      Re: Python Newbie MRAB <python@mrabarnett.plus.com> - 2013-02-24 20:34 +0000
                      Re: Python Newbie Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-24 20:41 +0000
                      Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 12:34 -0800
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 07:42 +1100
                        Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 15:48 -0500
                          Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-24 21:58 +0000
                          Re: Python Newbie Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-24 21:08 -0500
                          Re: Python Newbie Joshua Landau <joshua.landau.ws@gmail.com> - 2013-02-25 02:59 +0000
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 07:47 +1100
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 07:58 +1100
                        Re: Python Newbie Roy Smith <roy@panix.com> - 2013-02-24 16:08 -0500
                          Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 08:44 +1100
                          Re: Python Newbie Mitya Sirenef <msirenef@lightbird.net> - 2013-02-24 17:40 -0500
                            Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-25 01:11 +0000
                          Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-25 00:42 +0000
                          Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-24 18:34 -0700
                      Re: Python Newbie Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 14:33 -0800
                      Re: Python Newbie Albert Hopkins <marduk@letterboxes.org> - 2013-02-24 18:32 -0500
                      Re: Python Newbie Chris Angelico <rosuav@gmail.com> - 2013-02-25 10:44 +1100
                      Re: Python Newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-25 01:06 +0000
                    Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-24 11:40 -0800
                Re: Python Newbie piterrr.dolinski@gmail.com - 2013-02-22 13:37 -0800
        Re: Python Newbie Mitya Sirenef <msirenef@lightbird.net> - 2013-02-22 20:05 -0500
    Re: Python Newbie Gene Heskett <gheskett@wdtv.com> - 2013-02-23 12:32 -0500
    Re: Python Newbie Steve Simmons <square.steve@gmail.com> - 2013-02-23 19:10 +0100
    Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 11:40 -0700
    Re: Python Newbie Michael Torrie <torriem@gmail.com> - 2013-02-23 12:15 -0700
    Re: Python Newbie Gene Heskett <gheskett@wdtv.com> - 2013-02-23 17:49 -0500
    Re: Python Newbie Nick Mellor <thebalancepro@gmail.com> - 2013-02-25 19:37 -0800

Page 1 of 9  [1] 2 3 4 5 6 7 8 9  Next page →


#39463 — Python Newbie

FromPiterrr <piterrr.dolinski@gmail.com>
Date2013-02-21 13:26 -0800
SubjectPython Newbie
Message-ID<cad0eacc-6040-4a00-bd05-7fabfd2fa70e@googlegroups.com>
Hi folks.
I am a long time C sharp dev, just learning Python now due to job requirements. My initial impression is that Python has got to be the most ambiguous and vague language I have seen to date. I have major issues with the fact that white space matters. How do you deal with this? For example, you open a source file in different editors and the indentation levels change even though i only have spaces, no tabs (compare Windows Notepad and Notepad++). Which editor do you trust? In addition, code is difficult to read because you cannot lay it out in easily discernable blocks. For example, I always tend to indent a full 'if' statement block so that it is easier to see where the if block starts and ends. Can't do that in Python. What is even more frustrating is that Python is inconsistent with its syntax. For example, when I write "if (myVariable != 0):" then this is OK but "for (i in intAry):" results in syntax error. Apparently Python has problems with my use of parentheses. How retarded. I think I will rather find another job than eat my nerves with Python.
Any comments on this before I quit my job?

[toc] | [next] | [standalone]


#39466

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-02-21 14:54 -0700
Message-ID<mailman.2202.1361483688.2939.python-list@python.org>
In reply to#39463
On Thu, Feb 21, 2013 at 2:26 PM, Piterrr <piterrr.dolinski@gmail.com> wrote:
> I am a long time C sharp dev, just learning Python now due to job requirements. My initial impression is that Python has got to be the most ambiguous and vague language I have seen to date. I have major issues with the fact that white space matters. How do you deal with this? For example, you open a source file in different editors and the indentation levels change even though i only have spaces, no tabs (compare Windows Notepad and Notepad++). Which editor do you trust?

I have never had this problem (although I don't use either of those
editors either).  Are you sure you don't have any tabs in there?

> In addition, code is difficult to read because you cannot lay it out in easily discernable blocks. For example, I always tend to indent a full 'if' statement block so that it is easier to see where the if block starts and ends. Can't do that in Python.

I don't understand what it is that you want to do but can't.  Can you
give an example?  The whole point of making indentation matter in
Python is to *force* the programmer to lay out their blocks in a
consistent and easily discernible manner.

> What is even more frustrating is that Python is inconsistent with its syntax. For example, when I write "if (myVariable != 0):" then this is OK but "for (i in intAry):" results in syntax error. Apparently Python has problems with my use of parentheses.

The former works because the if statement only takes one expression,
and the parentheses are interpreted as part of that expression, not
part of the syntax for the if.  The for statement requires both a
variable name and an expression, distinguished by syntax, which again
includes no parentheses.  You could surround just the expression part
in parentheses if you like -- "for i in (intAry):" -- but it looks
pretty weird if you ask me.

I don't know why you should expect to be able to add parentheses to
arbitrary syntax and have it just work.  It strikes me as being like
trying to declare a variable as "int (x=3);" in C# (which I haven't
tested, but I doubt that is valid syntax).

[toc] | [prev] | [next] | [standalone]


#39467

FromMRAB <python@mrabarnett.plus.com>
Date2013-02-21 21:58 +0000
Message-ID<mailman.2203.1361483903.2939.python-list@python.org>
In reply to#39463
On 2013-02-21 21:26, Piterrr wrote:
> Hi folks. I am a long time C sharp dev, just learning Python now due
> to job requirements. My initial impression is that Python has got to
> be the most ambiguous and vague language I have seen to date. I have
> major issues with the fact that white space matters. How do you deal
> with this? For example, you open a source file in different editors
> and the indentation levels change even though i only have spaces, no
> tabs (compare Windows Notepad and Notepad++). Which editor do you
> trust? In addition, code is difficult to read because you cannot lay
> it out in easily discernable blocks. For example, I always tend to
> indent a full 'if' statement block so that it is easier to see where
> the if block starts and ends. Can't do that in Python. What is even
> more frustrating is that Python is inconsistent with its syntax. For
> example, when I write "if (myVariable != 0):" then this is OK but
> "for (i in intAry):" results in syntax error. Apparently Python has
> problems with my use of parentheses. How retarded. I think I will
> rather find another job than eat my nerves with Python. Any comments
> on this before I quit my job?
>
Python isn't C#. It has a different syntax.

Pascal isn't C# either.

Pascal would accept:

     if (myVariable <> 0) then
         ...

and reject:

     for (i := 0 to 9) do
         ...

As for the indentation, it shouldn't change if you're using only spaces
(not unless you're using a proportional font!).

[toc] | [prev] | [next] | [standalone]


#39468

FromChris Angelico <rosuav@gmail.com>
Date2013-02-22 08:59 +1100
Message-ID<mailman.2204.1361483974.2939.python-list@python.org>
In reply to#39463
On Fri, Feb 22, 2013 at 8:26 AM, Piterrr <piterrr.dolinski@gmail.com> wrote:
> Hi folks.
> I am a long time C sharp dev, just learning Python now due to job requirements. My initial impression is that Python has got to be the most ambiguous and vague language I have seen to date. I have major issues with the fact that white space matters. How do you deal with this? For example, you open a source file in different editors and the indentation levels change even though i only have spaces, no tabs (compare Windows Notepad and Notepad++). Which editor do you trust? In addition, code is difficult to read because you cannot lay it out in easily discernable blocks. For example, I always tend to indent a full 'if' statement block so that it is easier to see where the if block starts and ends. Can't do that in Python. What is even more frustrating is that Python is inconsistent with its syntax. For example, when I write "if (myVariable != 0):" then this is OK but "for (i in intAry):" results in syntax error. Apparently Python has problems with my use of parentheses. How retarded. I
>  think I will rather find another job than eat my nerves with Python.
> Any comments on this before I quit my job?

The first comment I would make is this: Every language you learn MUST
teach you something new about programming, otherwise you haven't
really learned a new language (just a new dialect of an old one).
Embrace Python's differences, get to know how things work, then make
your decision as to what you like and what you don't :)

When there's a question of trust involving Windows Notepad, by default
trust the other option. Notepad *sucks* for pretty much everything.
Notepad++ is far more reliable. So is NoteTab, so is SciTE, so is
pretty much anything else on the market (though the Open Watcom editor
is designed exclusively for C, and may not be suitable for Python - it
has a habit of converting tabs to spaces, so you may run into
problems).

The issue of parentheses is one of syntax. Anything that's an
expression can have an extra set of parens around it; anything that's
not, can't. The same will happen in most languages; I daresay C# won't
let you put parentheses around the semicolon at the end of a
statement, for instance. In a for loop, the 'in' keyword separates two
expressions, so you can't have parens around it.

I'm not sure what you mean by "indenting a full 'if' statement block".
Do you mean this:

code
code
    if (some condition) {
    code
    code
    }
code
code

? Because that's a distinctly weird way to lay out code, and would be
against the style guides of many organizations (definitely against any
style guide that I write). Python forces you to use one of the more
common styles:

code
code
if (some condition) {
    code
    code
}
code
code

Since the braces are omitted in Python, the same Python code can
equally well represent the C standards of OTBS (as shown above),
Allman (with the opening brace on the next line, which is my
preference when writing C)... actually, every style in
http://en.wikipedia.org/wiki/Indent_style#Styles follows the pattern
of having 'if' not indented and the body indented, which is what
Python enforces. So this might be a change for you, but if you quit
your job, chances are you'll find an identical change as you conform
to some other workplace's style guide :)

Of course, Python does allow and encourage the use of blank lines to
help lay out your code. So if you're having trouble with the
readability of statements, try judiciously adding blanks before and/or
after, and see if that helps.

And if all that doesn't make you happy with Python, then do look for a
better job. Not every language is for everyone, and you'll produce
better code as a contented C# programmer than as a miffed Python
programmer :) But do consider learning multiple languages. Eric
Raymond states in one of his essays [1] that you would do well to
learn five basic languages: Python, C/C++, Java, Perl, and LISP.
They're distinctly different from each other, and will teach different
things about how to *code*, which is a skill separate from how to
*code C* or how to *code Perl*.

[1] http://www.catb.org/esr/faqs/hacker-howto.html

ChrisA

[toc] | [prev] | [next] | [standalone]


#39470

FromPeter Pearson <ppearson@nowhere.invalid>
Date2013-02-21 22:03 +0000
Message-ID<aonjttFqplbU2@mid.individual.net>
In reply to#39463
On Thu, 21 Feb 2013 13:26:41 -0800 (PST), Piterrr wrote:

> I am a long time C sharp dev, just learning Python now due
> to job requirements. My initial impression is that Python
> has got to be the most ambiguous and vague language I have
> seen to date. I have major issues with the fact that white
> space matters. How do you deal with this?
[snip]
> Any comments on this before I quit my job?

Nope.  Quit immediately.

-- 
To email me, substitute nowhere->spamcop, invalid->net.

[toc] | [prev] | [next] | [standalone]


#39475

FromDave Angel <davea@davea.name>
Date2013-02-21 17:22 -0500
Message-ID<mailman.2207.1361485360.2939.python-list@python.org>
In reply to#39463
On 02/21/2013 04:26 PM, Piterrr wrote:
> Hi folks.
> I am a long time C sharp dev, just learning Python now due to job requirements. My initial impression is that Python has got to be the most ambiguous and vague language I have seen to date. I have major issues with the fact that white space matters. How do you deal with this? For example, you open a source file in different editors and the indentation levels change even though i only have spaces, no tabs (compare Windows Notepad and Notepad++). Which editor do you trust?


I'll take a chance and assume you're not just trolling.

Spend a while with it, you'll learn to like it.  It's about the 35th 
language I've used on the job, and is certainly my favorite.  And the 
fact that indentation has to match the meaning is a key advantage over 
languages that encourage you to write code that reads differently to the 
human than to the compiler.  Many times I've spotted code written by 
others that either had an extra semicolon, or had a dangling else that 
was lined up with a different if than the compiler would use.  There are 
plenty of defensive techniques in the C-family, like requiring braces 
for every clause even if a single statement.  But I find the lack of 
braces to make it easier to see a whole function in one view.

I did spend some time working in C#, but it didn't have a name yet. 
They called it C++ IJW, and I had to practically sign in blood to get a 
copy.  A number of the introspection features of dot-net were a result 
of my requests.  I had software in Microsoft's booth at the announcement 
of dot-net.  I haven't touched dot-net since.

I decided over 30 years ago (in a spec I wrote for one of my developers) 
that tabs in source code were a huge mistake, because of the varied way 
that different editors, printers, etc. handled them.  Consequently, I 
only use editors that have a way to always expand tabs to spaces.  I 
consider the tab key just a way to position myself on the screen, and 
would use a different method if I ever wanted a 09h code point in the file.

Contrary to your experience, I've never seen different text editors 
interpret the columns differently in the absence of tabs.  Are you by 
any chance using a proportional font????  Text files must be used with 
fixed-width fonts.  In any case, avoid Notepad.  It can't even handle 
text files with Unix line-endings.  I use emacs, but I also use Komodo, 
gedit, and in the past have used Kedit, Codewright, and many others.


 > In addition, code is difficult to read because you cannot lay it out
 > in easily discernable blocks. For example, I always tend to indent a
 > full 'if' statement block so that it is easier to see where the
 > if block starts and ends. Can't do that in Python.

The line immediately preceding an indented section is the dependent 
clause, be it if, or else, or def, or class, or ...  The section is 
complete when indentation returns to the earlier level.  Simple, 
consistent, easy to spot.  Unless you use two-column indentation, or 
have 6 levels of indentation in a single function.

 > What is even more frustrating is that Python is inconsistent with
 > its syntax. For example, when I write "if (myVariable != 0):"
 > then this is OK but "for (i in intAry):" results in syntax error.
 > Apparently Python has problems with my use of parentheses.
 > How retarded.

The if statement takes a single expression, so you can use redundant 
parentheses to your heart's content.  The for statement is defined as:

for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]

where in is a keyword, not part of some expression.  So of course the 
parenthesis you tried is illegal.

To see the rest of the grammar, see
    http://docs.python.org/2/reference/grammar.html
or http://docs.python.org/3.3/reference/grammar.html

 > I think I will rather find another job than eat my nerves with Python.
 > Any comments on this before I quit my job?
 >

Finding a new job can be a good thing, if your old company forces you to 
use the same language, and to do the same work over and over again.  My 
career has been full of variety, and I've turned down jobs that were 
offered merely because I already knew the tools.

However, if you give Python a chance, I think it'll grow on you.

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#39479

Frompiterrr.dolinski@gmail.com
Date2013-02-21 14:40 -0800
Message-ID<5c262e95-b3a8-4f2a-b752-84b30bf4f81e@googlegroups.com>
In reply to#39463
Thanks to all for quick relies.

Chris, you are (almost) spot on with the if blocks indentation. This is what I do, and it has served me well for 15 years.

code
code

   if (some condition)
   {
      code
      code
   }

code
code

This is what I call code clarity. With Python, I am having to do this

code
code

##############################

if (some condition):
  code
  code

##############################

code
code

It does the job, but is not ideal.

I am nervous about using variables "out of the blue", without having to declare them. For example, when I write "i = 0" it is perfectly OK to Python without 'i' being declared earlier. How do I know that I haven't used this variable earlier and I am unintentionally overwriting the value? I find I constantly have to use the search facility in the editor, which is not fun.

You see, Javascript, for one, behaves the same way as Python (no variable declaration) but JS has curly braces and you know the variable you have just used is limited in scope to the code within the { }. With Python, you have to search the whole file.

Thanks to Chris, Ian and Dave for explaining the () issue around if and for statement. I don't agree with this, but I understand your points. The reason why I like parentheses is because they help with code clarity. I am obsessed with this. :-) After all, there is a reason why so many languages have required them for several decades.


What about Python's ambiguity?
For example, in C you would write

if (myVar != 0)
  do something

in Python, this is legal

if (not myVar):
  do something

What does this mean? Is it a test for myVar being equal to zero or a test for null, or else?

I want to learn a new language but Python's quirks are a bit of a shock to me at this point. I have been Pythoning only for about a week.

In the mean time, thanks to most of you for encouraging me to give Python a chance. I will do my best to like it, w/o prejudice.

Peter

[toc] | [prev] | [next] | [standalone]


#39487

FromChris Angelico <rosuav@gmail.com>
Date2013-02-22 10:21 +1100
Message-ID<mailman.2213.1361488895.2939.python-list@python.org>
In reply to#39479
On Fri, Feb 22, 2013 at 9:40 AM,  <piterrr.dolinski@gmail.com> wrote:
> Thanks to all for quick relies.
>
> Chris, you are (almost) spot on with the if blocks indentation. This is what I do, and it has served me well for 15 years.
>
> code
> code
>
>    if (some condition)
>    {
>       code
>       code
>    }
>

I understand you have the freedom to do that in most languages, but
that's simply a restriction of Python: you have to use a more
conventional indentation system. Personally, I don't see the 'if' as
being special here, and the body of it (which IS special, as it may or
may not be executed) is already standing out.

> I am nervous about using variables "out of the blue", without having to declare them. For example, when I write "i = 0" it is perfectly OK to Python without 'i' being declared earlier. How do I know that I haven't used this variable earlier and I am unintentionally overwriting the value? I find I constantly have to use the search facility in the editor, which is not fun.
>
> You see, Javascript, for one, behaves the same way as Python (no variable declaration) but JS has curly braces and you know the variable you have just used is limited in scope to the code within the { }. With Python, you have to search the whole file.

That's a fair point. The elision of variable declarations is a design
decision that Python is unlikely to reverse, and it happens to be one
I disagree with. But it's there, so when I code Python, I accept it :)
There are other languages similar to Python that have strict variable
declarations, and with them the awesomeness that is infinitely nested
scopes; Python just has global (module) scope and function scope, plus
'nonlocal' which can solve some problems (but I've yet to find it do
so without damaging code clarity).

> What about Python's ambiguity?
> For example, in C you would write
>
> if (myVar != 0)
>   do something
>
> in Python, this is legal
>
> if (not myVar):
>   do something
>
> What does this mean? Is it a test for myVar being equal to zero or a test for null, or else?

Python has a state called "truthiness". Generally speaking, something
with content is true, and something without content is false. The None
singleton, empty lists, empty tuples, the integer 0, and a regular
expression result that didn't match, all evaluate as False in a
boolean context; most other things evaluate as True. If you
specifically care if it's not zero, you ask if it's not zero; if you
want to know if it's falsy, you check "not X". The facilities are
there to do whatever you want.

ChrisA

[toc] | [prev] | [next] | [standalone]


#39491

Frompiterrr.dolinski@gmail.com
Date2013-02-21 15:34 -0800
Message-ID<52a5d2ab-5cf8-483f-b0b0-15260e4bda2a@googlegroups.com>
In reply to#39487
Hi Chris,

Thanks for this. Regarding ambiguity, you will never find me write ambiguous code. I don't sabotage my own work. But the reality is that in addition to writing my own code, I have to maintain existing. I find it incredibly confusing then I see a statement along the lines of "if not something" - have to study the code in detail to see what it is testing.

I could show more examples of what I find confusing in existing code, but I don't intent to troll. I'm just trying to understand the language as it is. I will see how it goes.

Pete

[toc] | [prev] | [next] | [standalone]


#39496

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-02-21 23:48 +0000
Message-ID<mailman.2218.1361490514.2939.python-list@python.org>
In reply to#39491
On 21/02/2013 23:34, piterrr.dolinski@gmail.com wrote:
> Hi Chris,
>
> Thanks for this. Regarding ambiguity, you will never find me write ambiguous code. I don't sabotage my own work. But the reality is that in addition to writing my own code, I have to maintain existing. I find it incredibly confusing then I see a statement along the lines of "if not something" - have to study the code in detail to see what it is testing.
>
> I could show more examples of what I find confusing in existing code, but I don't intent to troll. I'm just trying to understand the language as it is. I will see how it goes.
>
> Pete
>

Perhaps look at code in the standard library to get a feel for things? 
This should help you overcome OCD, i.e. Obsessive C Disorder :)

-- 
Cheers.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#39505

FromChris Angelico <rosuav@gmail.com>
Date2013-02-22 11:32 +1100
Message-ID<mailman.2226.1361493151.2939.python-list@python.org>
In reply to#39491
On Fri, Feb 22, 2013 at 10:34 AM,  <piterrr.dolinski@gmail.com> wrote:
> Thanks for this. Regarding ambiguity, you will never find me write ambiguous code. I don't sabotage my own work. But the reality is that in addition to writing my own code, I have to maintain existing. I find it incredibly confusing then I see a statement along the lines of "if not something" - have to study the code in detail to see what it is testing.

It's testing something - specifically, whether or not the object wants
to "feel true" or "feel false". It's up to the object to define what
that means.

Most of the time, it's exactly what you want. When it isn't, you can
put an exact comparison.

ChrisA

[toc] | [prev] | [next] | [standalone]


#39700

FromMichael Torrie <torriem@gmail.com>
Date2013-02-23 11:58 -0700
Message-ID<mailman.2368.1361645928.2939.python-list@python.org>
In reply to#39491
On 02/21/2013 04:34 PM, piterrr.dolinski@gmail.com wrote:
> Thanks for this. Regarding ambiguity, you will never find me write 
> ambiguous code. I don't sabotage my own work. But the reality is
> that in addition to writing my own code, I have to maintain existing.
> I find it incredibly confusing then I see a statement along the
> lines of "if not something" - have to study the code in detail to see
> what it is testing.

As others have said, I don't see why this should be confusing.  It's a
common idiom that happens in C# or C all the time:

if (!some_state)
{
	//blah
}

There is absolutely no ambiguity here.  Every C# and C programmer knows
exactly what this means.  As others have said, it's the equivalent of
saying,  ((bool)(expression) != True). Just in a cleaner way and in a
way that echos how most programmers actually think.  And in python,
dropping the unnecessary comparisons actually gives you a speed up too.

In python there is some ambiguity as to what constitutes a boolean truth
or falsehood value for some types.  For example, an empty list ([]) is
false, as is an empty dictionary ({}), and a number is 0.  And in some
cases (default arguments, for example), using a "is None" comparison is
required. For example:

def some_function( a = None):
    # None is used above as the default because lists are
    # mutable, and if a list were placed up there it would
    # affect all subsequent calls to some_function()

    if a is None:
        a = [ 'default', 'values', 'here']

    for x in a:
        print x

some_func()
some_func(1,2,3)

> I could show more examples of what I find confusing in existing
> code, but I don't intent to troll. I'm just trying to understand the 
> language as it is. I will see how it goes.

As long as you are trying to write C# code in Python, you'll be very
frustrated.  Takes some time to learn about what it means to write
"pythonic" code.  You'll be well-served and you will start to enjoy the
language more.  Ditch the excess parenthesis.  They don't make things
clearer necessary and they really confuse what is a statement with what
is an expression (a pet peeve of mine with C).

Finally take some time to learn about how Python works from a language
theory point of view.  One interesting thing you'll learn is that python
actually has no variables.  This is a powerful concept, but can get you
in trouble sometimes when you're not aware of this fact.

[toc] | [prev] | [next] | [standalone]


#39495

Frompiterrr.dolinski@gmail.com
Date2013-02-21 15:34 -0800
Message-ID<mailman.2217.1361490436.2939.python-list@python.org>
In reply to#39487
Hi Chris,

Thanks for this. Regarding ambiguity, you will never find me write ambiguous code. I don't sabotage my own work. But the reality is that in addition to writing my own code, I have to maintain existing. I find it incredibly confusing then I see a statement along the lines of "if not something" - have to study the code in detail to see what it is testing.

I could show more examples of what I find confusing in existing code, but I don't intent to troll. I'm just trying to understand the language as it is. I will see how it goes.

Pete

[toc] | [prev] | [next] | [standalone]


#39489

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2013-02-21 23:27 +0000
Message-ID<mailman.2214.1361489278.2939.python-list@python.org>
In reply to#39479
On 21 February 2013 22:40,  <piterrr.dolinski@gmail.com> wrote:
> Thanks to all for quick relies.
>
> Chris, you are (almost) spot on with the if blocks indentation. This is what I do, and it has served me well for 15 years.
>
> code
> code
>
>    if (some condition)
>    {
>       code
>       code
>    }
>
> code
> code

So you already indent blocks in an "if" construct? This is good
practise in some languages and is enforced in Python. Once I got used
to it I found that the compulsory whitespace made it easier to read
conditional code blocks.

>
> This is what I call code clarity. With Python, I am having to do this
>
> code
> code
>
> ##############################
>
> if (some condition):
>   code
>   code
>
> ##############################
>
> code
> code
>
> It does the job, but is not ideal.

Do you mean that you literally insert a line of '#' characters before
and after in "if" block? There's no need to do that. Just allow
yourself to acclimatise to the significant whitespace and you'll find
that it's easy to see where the block begins and ends.

>
> I am nervous about using variables "out of the blue", without having to declare them. For example, when I write "i = 0" it is perfectly OK to Python without 'i' being declared earlier. How do I know that I haven't used this variable earlier and I am unintentionally overwriting the value? I find I constantly have to use the search facility in the editor, which is not fun.
>
> You see, Javascript, for one, behaves the same way as Python (no variable declaration) but JS has curly braces and you know the variable you have just used is limited in scope to the code within the { }. With Python, you have to search the whole file.

No, you only have to search the whole function which for me is rarely
more than 20 lines. The statement "i=0" when inside a function will
not overwrite anything outside the function (unless you use the
global/nonlocal statements). I rarely use global variables or module
level variables and if I do then I usually have a special place in a
module/script for defining them. I also tend to name them in ALLCAPS
just like C-preprocessor macros that need to be carefully maintained
in a separate "namespace".

>
> Thanks to Chris, Ian and Dave for explaining the () issue around if and for statement. I don't agree with this, but I understand your points. The reason why I like parentheses is because they help with code clarity. I am obsessed with this. :-) After all, there is a reason why so many languages have required them for several decades.

You'll get used to using the colon in the same way.

>
> What about Python's ambiguity?
> For example, in C you would write
>
> if (myVar != 0)
>   do something
>
> in Python, this is legal
>
> if (not myVar):
>   do something
>
> What does this mean? Is it a test for myVar being equal to zero or a test for null, or else?

All of those things. It executes "do something" if myVar is
1) zero (whether int/float/complex etc.)
2) False
3) None
4) an empty collection (list/set/tuple etc.)
5) an empty string
6) and more...

If the context doesn't make it clear what you are testing for then use
a more specific test (myVar!=0 works just as well).

> I want to learn a new language but Python's quirks are a bit of a shock to me at this point. I have been Pythoning only for about a week.
>
> In the mean time, thanks to most of you for encouraging me to give Python a chance. I will do my best to like it, w/o prejudice.

Many of the things that have confused/concerned you are things that I
actually like about Python. Given time you may do as well.


Oscar

[toc] | [prev] | [next] | [standalone]


#39497

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-02-21 16:55 -0700
Message-ID<mailman.2219.1361491414.2939.python-list@python.org>
In reply to#39479
On Thu, Feb 21, 2013 at 3:40 PM,  <piterrr.dolinski@gmail.com> wrote:
> I am nervous about using variables "out of the blue", without having to declare them. For example, when I write "i = 0" it is perfectly OK to Python without 'i' being declared earlier. How do I know that I haven't used this variable earlier and I am unintentionally overwriting the value? I find I constantly have to use the search facility in the editor, which is not fun.

If you need to search for variable names to see if you're overwriting
something, then your functions are too large and should probably be
refactored, or you're abusing globals, or possibly you just haven't
fully understood Python's scoping rules.

> You see, Javascript, for one, behaves the same way as Python (no variable declaration) but JS has curly braces and you know the variable you have just used is limited in scope to the code within the { }. With Python, you have to search the whole file.

Er, this doesn't sound right at all.  Javascript does have variable
declarations, using the "var" keyword.  Within a function, a declared
variable has local scope, but an undeclared variable has global scope.
 Despite having curly braces, Javascript does not have block scopes
like C# does.  More details can be found here:

http://stackoverflow.com/questions/500431/javascript-variable-scope

In Python, on the other hand, an undeclared variable in a function is
local by default (unless it is never assigned to).  To me, this makes
Python win out over Javascript because you're never going to
accidentally create a global variable just by failing to declare the
variable in the function where you use it.

[toc] | [prev] | [next] | [standalone]


#39526

Fromrusi <rustompmody@gmail.com>
Date2013-02-21 22:57 -0800
Message-ID<edf09a42-4bd3-4eea-9abc-d1c59507336c@m9g2000pby.googlegroups.com>
In reply to#39479
On Feb 22, 3:40 am, piterrr.dolin...@gmail.com wrote:
> Thanks to all for quick relies.
>
> Chris, you are (almost) spot on with the if blocks indentation. This is what I do, and it has served me well for 15 years.
>
> code
> code
>
>    if (some condition)
>    {
>       code
>       code
>    }
>
> code
> code
>
> This is what I call code clarity. With Python, I am having to do this
>
> code
> code
>
> ##############################
>
> if (some condition):
>   code
>   code
>
> ##############################
>
> code
> code
>
> It does the job, but is not ideal.
>
> I am nervous about using variables "out of the blue", without having to declare them. For example, when I write "i = 0" it is perfectly OK to Python without 'i' being declared earlier. How do I know that I haven't used this variable earlier and I am unintentionally overwriting the value? I find I constantly have to use the search facility in the editor, which is not fun.
>
> You see, Javascript, for one, behaves the same way as Python (no variable declaration) but JS has curly braces and you know the variable you have just used is limited in scope to the code within the { }. With Python, you have to search the whole file.
>
> Thanks to Chris, Ian and Dave for explaining the () issue around if and for statement. I don't agree with this, but I understand your points. The reason why I like parentheses is because they help with code clarity. I am obsessed with this. :-) After all, there is a reason why so many languages have required them for several decades.
>
> What about Python's ambiguity?
> For example, in C you would write
>
> if (myVar != 0)
>   do something
>
> in Python, this is legal
>
> if (not myVar):
>   do something

I have seen any amount of C code where:
if (x != 0) { ...

is shortened to

if (x) { ...

Python is similar (and many of us dont like this feature).
Just know it as a feature and get on with it.  Python has less
features/gotchas/bugs than most other languages.

As for indentation: This is more a philosophy than a technology
question.  Its called DRY (Dont Repeat Yourself)  In most languages
(other than python and haskell) you use {} or some such for the
compiler and indentation for the human reader.  Saying something
exactly once is not just a space/time saver. Its also a error saver.

> In the mean time, thanks to most of you for encouraging me to give Python a chance. I will do
> my best to like it, w/o prejudice.

The mathematician Paul Halmos was once told by a bewildered student:
"I just dont understand mathematics!"
Halmos replied: My boy you dont understand mathematics. You just get
used to it.

[toc] | [prev] | [next] | [standalone]


#39536

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-02-22 10:26 +0000
Message-ID<512747bd$0$29988$c3e8da3$5496439d@news.astraweb.com>
In reply to#39479
On Thu, 21 Feb 2013 14:40:37 -0800, piterrr.dolinski wrote:

> With Python, I am having to do this
> 
> code
> code
> 
> ##############################
> 
> if (some condition):
>   code
>   code
> 
> ##############################


I prefer this:


# WARNING WARNING WARNING IF STATEMENT AHEAD BEWARE BEWARE BEWARE
if something():
    do(stuff)
# WHEW IF STATEMENT FINISHED!!! WE SURVIVED, THANK THE GODS!!!


That way I can be sure that people reading it will know it is an "if" and 
not a "for" or "while", just in case the actual code wasn't clear enough.



> I am nervous about using variables "out of the blue", without having to
> declare them.

I feel your pain. I'm nervous about declaring variables "out of the 
blue", without having to declare that I'm about to declare them. I live 
in hope that some day I will find a language that lets me write:

FORWARD VARS:
    int x;
    double y;
    str s;

VARS:
    int x;
    float y;
    str s;


and have the compiler catch my error in declaring y as a float instead of 
a double. Then I will be one step closer to my dream of not having to 
understand the code I write.


> For example, when I write "i = 0" it is perfectly OK to
> Python without 'i' being declared earlier. How do I know that I haven't
> used this variable earlier and I am unintentionally overwriting the
> value? I find I constantly have to use the search facility in the
> editor, which is not fun.

Some people suggest that functions should be small enough to read over in 
a glance, or at least a couple of glances. They even say that variable 
names should be meaningful, so you can tell whether a variable has been 
used from context. I say, fi to that! Programming should be a challenge! 
It should be exciting! Which is why I never use functions, and always use 
the same single-letter variable with a cryptographic hash to distinguish 
them.

i048b8497cf86dab9dade2ce6beddf13a = []
i048b6497cd85d9b9da2a3ce6bdedf167 = 42


*wink*


I'm not going to apologise for taking the piss, although I do hope you 
will take it in the spirit it is intended: constructive criticism rather 
than abuse. The reality is, these "problems" you are running into are not 
problems in practice, and the "solutions" you are used to, like braces, 
are visually noisy and not terribly effective. You would probably think 
differently of { } if they were spelled "BEGIN" and "END" like in Pascal.

Braces have one, and only one, advantage: if you pass code through a 
noisy environment that deletes whitespace at will, you can recover the 
structure of the code from the braces. Python does not have that 
advantage, and sometimes it is a pain, e.g. when people email code using 
a broken mail client that deletes spaces.

But then, if you passed C code through something that deleted the braces, 
you'd be royally screwed too. The solution to that is to stop having 
tools that think that whitespace isn't significant. Of course it is 
significant, it is significant to the human reader, who is about a 
hundred billion trillion times more important than the compiler.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#39545

FromSteve Simmons <square.steve@gmail.com>
Date2013-02-22 12:05 +0100
Message-ID<mailman.2252.1361531454.2939.python-list@python.org>
In reply to#39536
Dear Mr D'Aprano,

I thank you for your post but I must complain in the strongest possible 
terms that it was not enclosed in the correct delimeters.  It should 
have been enclosed in a  <humour>... </humour> pair (or 
<humor>...</humor> if you are American).

I was drinking coffee at the time I started reading your post and, 
entirely due to your negligent lack of proper delimiters, much of my 
coffee is now irretrievably resident in my keyboard. My lawyers will be 
in touch...


On 22/02/2013 11:26, Steven D'Aprano wrote:
> On Thu, 21 Feb 2013 14:40:37 -0800, piterrr.dolinski wrote:
>
>> With Python, I am having to do this
>>
>> code
>> code
>>
>> ##############################
>>
>> if (some condition):
>>    code
>>    code
>>
>> ##############################
>
> I prefer this:
>
>
> # WARNING WARNING WARNING IF STATEMENT AHEAD BEWARE BEWARE BEWARE
> if something():
>      do(stuff)
> # WHEW IF STATEMENT FINISHED!!! WE SURVIVED, THANK THE GODS!!!
>
>
> That way I can be sure that people reading it will know it is an "if" and
> not a "for" or "while", just in case the actual code wasn't clear enough.
>
>
>
>> I am nervous about using variables "out of the blue", without having to
>> declare them.
> I feel your pain. I'm nervous about declaring variables "out of the
> blue", without having to declare that I'm about to declare them. I live
> in hope that some day I will find a language that lets me write:
>
> FORWARD VARS:
>      int x;
>      double y;
>      str s;
>
> VARS:
>      int x;
>      float y;
>      str s;
>
>
> and have the compiler catch my error in declaring y as a float instead of
> a double. Then I will be one step closer to my dream of not having to
> understand the code I write.
>
>
>> For example, when I write "i = 0" it is perfectly OK to
>> Python without 'i' being declared earlier. How do I know that I haven't
>> used this variable earlier and I am unintentionally overwriting the
>> value? I find I constantly have to use the search facility in the
>> editor, which is not fun.
> Some people suggest that functions should be small enough to read over in
> a glance, or at least a couple of glances. They even say that variable
> names should be meaningful, so you can tell whether a variable has been
> used from context. I say, fi to that! Programming should be a challenge!
> It should be exciting! Which is why I never use functions, and always use
> the same single-letter variable with a cryptographic hash to distinguish
> them.
>
> i048b8497cf86dab9dade2ce6beddf13a = []
> i048b6497cd85d9b9da2a3ce6bdedf167 = 42
>
>
> *wink*
>
>
> I'm not going to apologise for taking the piss, although I do hope you
> will take it in the spirit it is intended: constructive criticism rather
> than abuse. The reality is, these "problems" you are running into are not
> problems in practice, and the "solutions" you are used to, like braces,
> are visually noisy and not terribly effective. You would probably think
> differently of { } if they were spelled "BEGIN" and "END" like in Pascal.
>
> Braces have one, and only one, advantage: if you pass code through a
> noisy environment that deletes whitespace at will, you can recover the
> structure of the code from the braces. Python does not have that
> advantage, and sometimes it is a pain, e.g. when people email code using
> a broken mail client that deletes spaces.
>
> But then, if you passed C code through something that deleted the braces,
> you'd be royally screwed too. The solution to that is to stop having
> tools that think that whitespace isn't significant. Of course it is
> significant, it is significant to the human reader, who is about a
> hundred billion trillion times more important than the compiler.
>
>
>

[toc] | [prev] | [next] | [standalone]


#39547

FromChris Angelico <rosuav@gmail.com>
Date2013-02-22 22:23 +1100
Message-ID<mailman.2254.1361532194.2939.python-list@python.org>
In reply to#39536
On Fri, Feb 22, 2013 at 10:05 PM, Steve Simmons <square.steve@gmail.com> wrote:
> I thank you for your post but I must complain in the strongest possible
> terms that it was not enclosed in the correct delimeters.  It should have
> been enclosed in a  <humour>... </humour> pair (or <humor>...</humor> if you
> are American).

Steve, you clearly do not understand the vital importance of these
tags, which is for the reader, not the writer! Steven should have
enclosed his text in *both* markers, in order that readers familiar
with only one of the two systems would nevertheless be spared the
indignity of having to learn the other.

<signature>
<name>
<.sig>
ChrisA
</signature>
</.sig>
</name>

... there, have fun unnesting that...

[toc] | [prev] | [next] | [standalone]


#39720

FromMichael Torrie <torriem@gmail.com>
Date2013-02-23 16:04 -0700
Message-ID<mailman.2385.1361660691.2939.python-list@python.org>
In reply to#39479
On 02/21/2013 03:40 PM, piterrr.dolinski@gmail.com wrote:
> Chris, you are (almost) spot on with the if blocks indentation. This
> is what I do, and it has served me well for 15 years.

Most companies, development teams have unified coding style standards
that all programmers must adhere to in the company.  They do vary across
different companies of course. Some may require K&R syntax for braces,
others might settle on GNU-like rules.  One nice thing about requiring
braces in C-like languages is that it's trivial to run a utility on the
source code to reformat it to the required specification.

The point, though, is that even though you prefer to do if blocks that
way, if you were to change jobs and join the development team in another
company they may require you to format them differently.  So we have to
adapt our styles to the needs of the team, the project, and the language.

I have never had a problem fighting indentation for blocks, and it
always seemed natural (just like how I program on paper or the back of
napkins).  I am equally at home with C braces too.  Seems about the same
to me, except I can simply leave off the braces on python.

[toc] | [prev] | [next] | [standalone]


Page 1 of 9  [1] 2 3 4 5 6 7 8 9  Next page →

Back to top | Article view | comp.lang.python


csiph-web