Re: Please verify!!

2012-02-24 Thread Ben Finney
Andrew Berg bahamutzero8...@gmail.com writes:

 On 2/23/2012 4:43 PM, Dave Angel wrote:
  First thing I'd do is to disable tab logic in the editor.  When you 
  press the tab key, there's no excuse for an editor to actually put a tab 
  in the file.  It should adjust the column by adding the appropriate 
  number of spaces.
 Unless, of course, you know, you actually /want/ to use tabs (the
 horror!). The decision whether to use tabs or spaces shouldn't be made
 for the novice programmer.

Those two positions yo describe are in conflict.

Are you referring to novice programmers – who, by any reasonable
definition of “novice”, don't have an opinion on the tabs-versus-spaces
indentation debate?

Or are you talking about people who are experienced enough to have an
opinion and expect their editor to allow them the choice?

 I recommend using UTF-8 always unless there's some reason not to.

Likewise, I recommend using spaces for indentation always, unless
there's some reason not to.

The reason is the same: spaces for indentation and UTF-8 for encoding
will both allow them the best chance of ignoring the issue as
irrelevant, by enabling the smoothest collaboration with the vast
majority of other programmers who have to work with them.

And in both those issues, I think it's ludicrous to expect the novice
programmer to care enough about the matter to have an opinion and select
a configuration option. The editor authors should choose the best option
for them as a default, and let most users sail on, happily ignorant of
the flame wars they have avoided.

-- 
 \   “In the long run nothing can withstand reason and experience, |
  `\and the contradiction which religion offers to both is all too |
_o__)palpable.” —Sigmund Freud |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Andrew Berg
On 2/24/2012 2:32 AM, Ben Finney wrote:
 Are you referring to novice programmers – who, by any reasonable
 definition of “novice”, don't have an opinion on the tabs-versus-spaces
 indentation debate?
 
 Or are you talking about people who are experienced enough to have an
 opinion and expect their editor to allow them the choice?
The former. Opinion doesn't necessarily come with experience - habit
will usually override any minor reason to change. My point is that one
should have an opinion on it, not just be told which is better. I should
clarify that I mean that in a general sense as well, since it may have
come across as a bit of an overreaction.

 The reason is the same: spaces for indentation and UTF-8 for encoding
 will both allow them the best chance of ignoring the issue as
 irrelevant, by enabling the smoothest collaboration with the vast
 majority of other programmers who have to work with them.
If by that, you mean that using spaces is better because it's what the
majority of programmers use, and it makes things much smoother when
working with others, then I agree. When working in a team, it's
definitely not something to argue over.

 And in both those issues, I think it's ludicrous to expect the novice
 programmer to care enough about the matter to have an opinion and select
 a configuration option. The editor authors should choose the best option
 for them as a default, and let most users sail on, happily ignorant of
 the flame wars they have avoided.
A valid point. I think one should have an opinion, but I can see why one
would avoid the issue.

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Jugurtha Hadjar

On 23/02/2012 23:13, Manish Sharma wrote:

Hi I am new to python language. On my first day, somebody told me that
if any python script file is opened with any editor except python
editor, the file is corrupted. Some spacing or indentation is changed
and script stops working. I was opening the script file in Windows
using Notepad++ but I didn't save anything and closed it. Still it was
suggested to never open the python file in any other editor.

Can anybody please verify this? Can opening a python script in any
editor other than python editor corrupt the script? Did anybody ever
face such type of issue or its just misunderstanding of the concept.

I hope this group is the best place to ask this. Please reply !

:)
Manish


I don't think so, I have used EDIT, Notepad, Notepad++ and they all work 
fine.




PS: What's the python editor you were advised to stick with, by the way ?

--
~Jugurtha Hadjar,

--
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Duncan Booth
Andrew Berg bahamutzero8...@gmail.com wrote:

 Yes. However, there are many editors for various platforms that handle
 the different line endings just fine. In fact, Notepad is the only
 editor I can think of off the top of my head that has an issue.

The original question was about Notepad++ which is nothing at all like 
Notepad.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Andrew Berg
On 2/24/2012 5:21 AM, Duncan Booth wrote:
 The original question was about Notepad++ which is nothing at all like 
 Notepad.
And I did give the OP an answer about Notepad++ specifically in another
message.

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Steven D'Aprano
On Fri, 24 Feb 2012 03:18:18 -0600, Andrew Berg wrote:

 On 2/24/2012 2:32 AM, Ben Finney wrote:
 Are you referring to novice programmers – who, by any reasonable
 definition of “novice”, don't have an opinion on the tabs-versus-spaces
 indentation debate?
 
 Or are you talking about people who are experienced enough to have an
 opinion and expect their editor to allow them the choice?

 The former. Opinion doesn't necessarily come with experience - habit
 will usually override any minor reason to change. My point is that one
 should have an opinion on it, not just be told which is better. I should
 clarify that I mean that in a general sense as well, since it may have
 come across as a bit of an overreaction.

My opinion is that we shouldn't use either tabs or spaces, but capital 
Zs instead, 'cos I like Zs and we don't use enough of them!

Opinions need to be informed to be better than useless. By definition 
newbies don't have the experience to have informed opinions. You are 
encouraging people who lack the experience to make an informed decision 
to take sides in the tabs vs spaces question on the basis of... what? 
Gut feeling? Astrology? Feng shui? Whether they find it easy to say the 
word space or have a lisp and prefer tab instead?

There are many times that we can't afford to sit on the fence. Lacking 
experience to decide between spaces and tabs, we can't just say I won't 
use either, or I'll use both (unless you do so in separate files). So 
how can we make a decision?

The usual way is to listen to others, who do have the experience to make 
a decision (even if only imperfectly). But you've just told us off for 
passing on our experience/opinions to newbies, so in effect you're saying 
that people shouldn't learn from the experiences of others.

That, I think, is a terrible philosophy. Life is too short to gain an 
opinion for ourselves about everything, and too difficult to sit on the 
fence.

The right way is to encourage newbies to listen to the arguments put 
forth, and *then* make up their own mind, or in the absence of easily 
understood arguments (let's face it, many technical decisions only make 
sense after years of study, experience or careful reasoning) on the basis 
of any consensus amongst experts. Often there may be no absolutely right 
or wrong answers.

Personally, I prefer tabs for theoretical reasons and spaces for 
practical ones. I think that the world would be better off if we all 
standardised on tabs instead of spaces, but since that's not going to 
happen, I can interoperate better with the mass of broken tools out 
there, and with other people, by using spaces.

I wonder whether Windows users tend to be more sympathetic to tabs than 
Unix/Linux users, and if so, I wonder what if anything that means.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Andrew Berg
On 2/24/2012 6:20 AM, Steven D'Aprano wrote:
 Opinions need to be informed to be better than useless. By definition 
 newbies don't have the experience to have informed opinions.
I thought I had implied that I meant informed opinions, but apparently not.

 There are many times that we can't afford to sit on the fence. Lacking 
 experience to decide between spaces and tabs, we can't just say I won't 
 use either, or I'll use both (unless you do so in separate files). So 
 how can we make a decision?
 
 The usual way is to listen to others, who do have the experience to make 
 a decision (even if only imperfectly). But you've just told us off for 
 passing on our experience/opinions to newbies, so in effect you're saying 
 that people shouldn't learn from the experiences of others.
I don't mean that no one should ever give an opinion. Saying you prefer
spaces because you've had to deal with broken editors that don't handle
tabs well is quite different from saying an editor is wrong/broken if it
isn't using space-tabs. Giving an opinion and presenting an argument are
perfectly fine; I don't agree with calling things inherently wrong if
they aren't what you prefer. I had (and have) no problem with Dave
preferring spaces and giving reasons. I have a problem with him implying
that editors should always use space-tabs and never real tabs,
especially in the context of this thread.

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Chris Angelico
On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Personally, I prefer tabs for theoretical reasons and spaces for
 practical ones. I think that the world would be better off if we all
 standardised on tabs instead of spaces, but since that's not going to
 happen, I can interoperate better with the mass of broken tools out
 there, and with other people, by using spaces.


At work, since we have a fairly small core of developers, we
standardized on tabs - mainly because of a couple of devs who
disagreed on how much indentation looked right (I'm of the opinion
that 1 space is insufficient), and having tab characters in the file
allows us to configure our editors differently. I'm definitely in
favour of using tabs where possible, but if you can't close your
environment, spaces are far safer.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Mark Lawrence

On 24/02/2012 20:41, Chris Angelico wrote:

On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info  wrote:

Personally, I prefer tabs for theoretical reasons and spaces for
practical ones. I think that the world would be better off if we all
standardised on tabs instead of spaces, but since that's not going to
happen, I can interoperate better with the mass of broken tools out
there, and with other people, by using spaces.



At work, since we have a fairly small core of developers, we
standardized on tabs - mainly because of a couple of devs who
disagreed on how much indentation looked right (I'm of the opinion
that 1 space is insufficient), and having tab characters in the file
allows us to configure our editors differently. I'm definitely in
favour of using tabs where possible, but if you can't close your
environment, spaces are far safer.

ChrisA


Oo, thou sinner, fancy violating PEP 8 and standardising on tabs.

OTOH if that's your standard and you stick to it fine.

What I can't stand is the I've always done it this way an I ain't movin 
jus cos sum standard says so attitude.


Yes I have seen this in real life and the person responsible should be 
sacked.


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Chris Angelico
On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 Oo, thou sinner, fancy violating PEP 8 and standardising on tabs.

PEP 8 applies only to Python code, our standard is across all our
languages :) But yes, I'm a horrible sinner and I like tabs. They
separate the display (do you want tabs to show as four-space indent,
two-centimeter indent, or fifty-pixel indent?) from the structure
(this line is indented two levels). Spaces merge those.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-24 Thread Dave Angel

On 02/24/2012 08:25 PM, Chris Angelico wrote:

On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrencebreamore...@yahoo.co.uk  wrote:

Oo, thou sinner, fancy violating PEP 8 and standardising on tabs.

PEP 8 applies only to Python code, our standard is across all our
languages :) But yes, I'm a horrible sinner and I like tabs. They
separate the display (do you want tabs to show as four-space indent,
two-centimeter indent, or fifty-pixel indent?) from the structure
(this line is indented two levels). Spaces merge those.

ChrisA


If tabs were ever implemented consistently and reasonably in both an 
editor and a matching language, then I'd consider leaving tabs in the 
file.  But to me, they're just a crude way to compress the file, and the 
space they save is no longer worth the pain they cause  (I came to this 
conclusion 30 years ago, and have re-evaluated it dozens of times as new 
editors and new languages changed the rules.  At that time, I had one of 
my developers write an editor (shipped with our MSDOS system, instead of 
Edlin) that implemented it.)


Some time when i have a lot more time, I'll state one of (many possible) 
the ways that tabs could be made acceptable in a limited environment.  
Almost 40 years ago, I wrote an editor and assembler whose file format 
used a separation character between fields.  I used A0 because our 
screens at the time ignored the high bit, so a file was sort-of readable 
right out of the box.  And the way that the developer jumped between 
fields was the semi-colon key, of course, since that's the position of 
the skip key in the keypunch we were replacing.


However, I don't intend to foist my opinions on others, just to state 
them as opinions.  At the office, we use special comment fields at 
end-of-file to tell Emacs how to deal with a mixture of tabs and 
spaces.  Code written by a dozen people over a dozen years, and nobody 
wanted to enforce a conversion to something common.





--

DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Please verify!!

2012-02-23 Thread Manish Sharma
Hi I am new to python language. On my first day, somebody told me that
if any python script file is opened with any editor except python
editor, the file is corrupted. Some spacing or indentation is changed
and script stops working. I was opening the script file in Windows
using Notepad++ but I didn't save anything and closed it. Still it was
suggested to never open the python file in any other editor.

Can anybody please verify this? Can opening a python script in any
editor other than python editor corrupt the script? Did anybody ever
face such type of issue or its just misunderstanding of the concept.

I hope this group is the best place to ask this. Please reply !

:)
Manish
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Amirouche Boubekki
2012/2/23 Manish Sharma manish2...@gmail.com

 Hi I am new to python language. On my first day, somebody told me that
 if any python script file is opened with any editor except python
 editor, the file is corrupted. Some spacing or indentation is changed
 and script stops working. I was opening the script file in Windows
 using Notepad++ but I didn't save anything and closed it. Still it was
 suggested to never open the python file in any other editor.

 Can anybody please verify this? Can opening a python script in any
 editor other than python editor corrupt the script? Did anybody ever
 face such type of issue or its just misunderstanding of the concept.



There is compatibility issue with line ending in Windows vs other OS that's
all I'm aware of.

Amirouche
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Ben
They are telling you not to switch between editors that use tabs as tabs and 
ones that use spaces as tabs. Python gets all wonky. No big, use one editor or 
have your preferred editor highlight your non-preferred whitespace. 

FWIW, I use spaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Chris Kaynor
On Thu, Feb 23, 2012 at 2:22 PM, Amirouche Boubekki 
amirouche.boube...@gmail.com wrote:



 2012/2/23 Manish Sharma manish2...@gmail.com

 Hi I am new to python language. On my first day, somebody told me that
 if any python script file is opened with any editor except python
 editor, the file is corrupted. Some spacing or indentation is changed
 and script stops working. I was opening the script file in Windows
 using Notepad++ but I didn't save anything and closed it. Still it was
 suggested to never open the python file in any other editor.

 Can anybody please verify this? Can opening a python script in any
 editor other than python editor corrupt the script? Did anybody ever
 face such type of issue or its just misunderstanding of the concept.



 There is compatibility issue with line ending in Windows vs other OS
 that's all I'm aware of.


The only issues I can think of off the top of my head would be line endings
and indentation (tabs vs spaces, number of spaces for one level). The
second would just require care to avoid issues to make sure you match the
style guides for the files you are working on (the Python standard is 4
spaces, I believe). The first could be a silent issue with some editors and
some versions of Python if crossing between Windows, Linux, and Mac,
however most software (including Python) will now convert between the
different forms automatically, and Notepad++ is good about its handling -
it will create new newlines in the format of the file, if such can be
determined.



 Amirouche

 --
 http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Dave Angel

On 02/23/2012 05:13 PM, Manish Sharma wrote:

Hi I am new to python language. On my first day, somebody told me that
if any python script file is opened with any editor except python
editor, the file is corrupted. Some spacing or indentation is changed
and script stops working. I was opening the script file in Windows
using Notepad++ but I didn't save anything and closed it. Still it was
suggested to never open the python file in any other editor.

Can anybody please verify this? Can opening a python script in any
editor other than python editor corrupt the script? Did anybody ever
face such type of issue or its just misunderstanding of the concept.

I hope this group is the best place to ask this. Please reply !

:)
Manish


That is nonsense.  I've used at least a dozen text editors, from Windows 
Notepad to emacs on Linux.  And since I know of no program called 
python editor, I'm sure none of them was that one.


Of course, there are editors that are broken, or can be configured to be 
broken.  I certainly wouldn't try wordpad, even in text mode.  But a 
good editor with a good configuration can be much nicer to use than Notepad.


First thing I'd do is to disable tab logic in the editor.  When you 
press the tab key, there's no excuse for an editor to actually put a tab 
in the file.  It should adjust the column by adding the appropriate 
number of spaces.  The main place you get in trouble is when a file has 
tabs in some lines, and uses spaces for indenting on other lines.  Since 
tabs are not interpreted the same way in various utilities, it's just 
better not to use them at all.


As Amirouche has pointed out, line endings can be inconsistent between 
different operating systems, and not all editors can handle the 
differences.   But the python compiler/interpreter doesn't care about 
which line ending is used.


One other issue could be files that have non-ASCII characters.  Since a 
text file has no standard way to indicate what format it uses (utf8, 
ucs2, or dozens of extended ASCII encodings), another editor might not 
deal with it correctly.  There is a standard way to indicate to Python 
how to interpret non-ascii characters, so if you either  1) always use 
ASCII1 2) always use the same character encoding, or 3) have your editor 
look for the declaration and honor it,  you'd have no trouble.


If these problems do occur, they'll be pretty easy to spot.  And you can 
always revert to an earlier version, by using your revision control 
system.   Enabling one of those is about as important as choosing your 
editor.


--

DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Joshua Miller
Wasn't supposed to be private, just something went funky with gmail
when i sent it out, oddly enough

On Thu, Feb 23, 2012 at 8:32 PM, Dave Angel d...@davea.name wrote:
 On 02/23/2012 07:15 PM, Joshua Miller wrote:

 When he/she said python editor i'm sure they meant IDLE which in
 some cases is the worst ide to use. Some ide's do mess with python
 files you just have to make sure to change their settings to
 accomadate python. Otherwise no it's a better idea to use  something
 other than IDLE. For windows generally people use eclipse with the
 pydev extension, pyscripter, or the several other IDE's that are known
 with a little help not to do what you are describing ;)


 I can't argue with anything you say here.  But you shouldn't have sent it
 privately, as this is a public list.  And please don't top-post

 So I'm forwarding it to the list.

 --

 DaveA



-- 
~ Josh Miller

A young guy learning to program and develop websites all while still in school
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Andrew Berg
On 2/23/2012 4:43 PM, Dave Angel wrote:
 First thing I'd do is to disable tab logic in the editor.  When you 
 press the tab key, there's no excuse for an editor to actually put a tab 
 in the file.  It should adjust the column by adding the appropriate 
 number of spaces.
Unless, of course, you know, you actually /want/ to use tabs (the
horror!). The decision whether to use tabs or spaces shouldn't be made
for the novice programmer. Make an argument, explain the
advantages/disadvantages, whatever, but don't state your opinion like
it's fact. Even worse, you brought it up in the context of editor
issues, making it sound like using tabs is a common source of problems.
Much of it is personal preference (I could give objective reasons in
support of tabs in Python, but I don't intend to start the whole spaces
vs. tabs discussion again).

 The main place you get in trouble is when a file has 
 tabs in some lines, and uses spaces for indenting on other lines.
I wouldn't call it the main problem, but yes, that happens. It's not
terribly difficult to convert all indentation to tabs or spaces (unless
the number of spaces used to indent is inconsistent).

 As Amirouche has pointed out, line endings can be inconsistent between 
 different operating systems, and not all editors can handle the 
 differences.   But the python compiler/interpreter doesn't care about 
 which line ending is used.
Yes. However, there are many editors for various platforms that handle
the different line endings just fine. In fact, Notepad is the only
editor I can think of off the top of my head that has an issue.

 One other issue could be files that have non-ASCII characters.  Since a 
 text file has no standard way to indicate what format it uses (utf8, 
 ucs2, or dozens of extended ASCII encodings), another editor might not 
 deal with it correctly.  There is a standard way to indicate to Python 
 how to interpret non-ascii characters, so if you either  1) always use 
 ASCII1 2) always use the same character encoding, or 3) have your editor 
 look for the declaration and honor it,  you'd have no trouble.
I recommend using UTF-8 always unless there's some reason not to.

 If these problems do occur, they'll be pretty easy to spot.  And you can 
 always revert to an earlier version, by using your revision control 
 system.   Enabling one of those is about as important as choosing your 
 editor.
I don't think you can really go wrong outside of Git, Bazaar, or
Mercurial. Which of those 3 is best is mainly personal preference.
CVS/SVN should be considered legacy and not suitable for new projects.

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Manish Sharma
Hi All,

Thanks a ton for your replies!

Still my question is what if I open the file and dont make any changes to
it and close it again? Can it be possible just by doing these steps add
indentation to lines? I am not changing the file prefrences to open it
always with notepad++. Opening it once only.

On Fri, Feb 24, 2012 at 6:08 AM, Jason Friedman ja...@powerpull.net wrote:

  Hi I am new to python language. On my first day, somebody told me that
  if any python script file is opened with any editor except python
  editor, the file is corrupted. Some spacing or indentation is changed
  and script stops working. I was opening the script file in Windows
  using Notepad++ but I didn't save anything and closed it. Still it was
  suggested to never open the python file in any other editor.

 It is possible that the OP is not aware of that Python is space
 sensitive, unlike most(?) programming languages.

 for i in range(5):
print(Hello.)
print(Goodbye.)

 will not run because the indentation (leading spaces) on the third
 line is incorrect.  It must instead line up with the second line.

 A single tab is equivalent to a single space as far as Python is
 concerned, but your eyes will report a difference and editors that
 substitute one for the other can cause, after saving, code that was
 formerly working to not work (and, I suppose, the reverse).

 Make sure to read the tutorial at http://python.org (which is
 unfortunately down at this moment
 (http://www.downforeveryoneorjustme.com/python.org)).




-- 
-
Thanks  Regards
Manish Kumar
| Mob: +91-9911635906 |
manish2...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Andrew Berg
On 2/24/2012 1:11 AM, Manish Sharma wrote:
 Still my question is what if I open the file and dont make any changes
 to it and close it again? Can it be possible just by doing these steps
 add indentation to lines? I am not changing the file prefrences to open
 it always with notepad++. Opening it once only.
Notepad++ won't change line endings or indentation unless you tell it
to. In any case, it will indicate when a file has been changed (the
little blue disk icon in the file's tab will turn red).

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list