[opensuse] editor that does not eat out TAB characters
I have just learnt, to my dismay, that python syntax is sensitive to indentation, even if python is supposed to be a modern language ... I figured that out when I used Mac textEditor to copy some lines from a python script and paste them into the pdb text window for debugging. Since I will be using SuSE systems to debug such a script, my question is: do you know of an editor, running on SuSE, which does not cut off the precious indentation characters making a mess of a python script ? For instance, Emacs won't work for this particular problem. Some time ago I got an editor running on Windows (on campus I had to use a Windows box) named "UltraEdit" (I am not sure the spelling is right). It was a very flexible editor tta could be configured for performing very basic as well as very sophisticated editing functions. I wonder whether something similar is available on Linux platforms. Thank you so much, Maura -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Monday 15 June 2009 13:28:48, Maura Monville wrote:
I have just learnt, to my dismay, that python syntax is sensitive to indentation, even if python is supposed to be a modern language ... I figured that out when I used Mac textEditor to copy some lines from a python script and paste them into the pdb text window for debugging.
Since I will be using SuSE systems to debug such a script, my question is: do you know of an editor, running on SuSE, which does not cut off the precious indentation characters making a mess of a python script ? For instance, Emacs won't work for this particular problem.
Some time ago I got an editor running on Windows (on campus I had to use a Windows box) named "UltraEdit" (I am not sure the spelling is right). It was a very flexible editor tta could be configured for performing very basic as well as very sophisticated editing functions. I wonder whether something similar is available on Linux platforms.
Thank you so much, Maura
I love kwrite :-) it doesn't do anything you don't tell it to do and leaves everything as you typed/copied it, unless you set it up different. It also has a very good syntax highlighting and other helpers... Daniel -- Daniel Bauer photographer Basel Barcelona professional photography: http://www.daniel-bauer.com erotic art photos: http://www.bauer-nudes.com Madagascar special: http://www.fotograf-basel.ch/madagascar/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Daniel Bauer said the following on 06/15/2009 07:53 AM:
I love kwrite :-) it doesn't do anything you don't tell it to do and leaves everything as you typed/copied it, unless you set it up different. It also has a very good syntax highlighting and other helpers...
Indeed, and so does VIM and a number of other editors. How much complexity do you want to deal with? -- Clear the battlefield and let me see All the profit from our victory. You talk of freedom, starving children poor. Are you deaf when you hear the season's call? Were you there to watch the earth be scorched? Did you stand beside the spectral torch? Know the leaves of sorrow turned their face, Scattered on the ashes of disgrace. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Monday 15 June 2009 08:16:16 am Anton Aylward wrote:
Daniel Bauer said the following on 06/15/2009 07:53 AM:
I love kwrite :-) it doesn't do anything you don't tell it to do and leaves everything as you typed/copied it, unless you set it up different. It also has a very good syntax highlighting and other helpers...
Indeed, and so does VIM and a number of other editors.
How much complexity do you want to deal with?
Although I'm not a master at VIM I have been using it for years along with kwirte for scripting and programming and they both have done their job and done it well -- "We must plan for freedom, and not only for security, if for no other reason than only freedom can make security more secure." Karl Popper
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Maura Monville wrote:
I have just learnt, to my dismay, that python syntax is sensitive to indentation, even if python is supposed to be a modern language ... I figured that out when I used Mac textEditor to copy some lines from a python script and paste them into the pdb text window for debugging.
One of the reasons I never explored Python .... I believe Eclipse has some Python addons which may be useful....(includes a debugger IIRC).... Get Eclipse from the Eclipse site (the SuSE build works but you may run into problems with installing some plugins with it).... Eclipse should run on anything with a Java JRE/SDK installed...
Since I will be using SuSE systems to debug such a script, my question is: do you know of an editor, running on SuSE, which does not cut off the precious indentation characters making a mess of a python script ? For instance, Emacs won't work for this particular problem.
Some time ago I got an editor running on Windows (on campus I had to use a Windows box) named "UltraEdit" (I am not sure the spelling is right). It was a very flexible editor tta could be configured for performing very basic as well as very sophisticated editing functions. I wonder whether something similar is available on Linux platforms.
Thank you so much, Maura
- -- ============================================================================== I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone. Bjarne Stroustrup ============================================================================== -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAko2N70ACgkQasN0sSnLmgLISQCePMhDDw+vY3HSWGvAXccowUHU /C0AnRf/a4fgIl1nxhCC4Q0EaSTHOix7 =etFL -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dave Howorth wrote:
G T Smith wrote:
Eclipse should run on anything with a Java JRE/SDK installed...
Surely if eclipse was any good, it would have been written in C and GTK+
;-P
Actually Eclipses limitations on Linux (such as they are) are due to it being written with the GTK variant on of the Java SDK. It started of life as alternative to SUNS Java IDE, but has kind of wandered of to some other places. As for some functionality it obviously uses Java introspection functionality it pretty much has to be written in Java. Eclipse has a bewildering array of free (and not free) plugins. I currently have the C/C++ and Perl extensions loading plus some odds and sods for other thinks like Subversion and CVS. Its main problem is that if anything it has too many extensions. It is is the effectively the Open Source alternative to M$ Visual Studio with significant technical input from IBM. - -- ============================================================================== I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone. Bjarne Stroustrup ============================================================================== -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAko3bnEACgkQasN0sSnLmgLHxgCeLW1ukkJT4uXQpZR7zr1sFEfv DiEAoKvMBgMd6fMuqHwUW6pR9hGa4hKa =N7ev -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Maura Monville wrote:
I have just learnt, to my dismay, that python syntax is sensitive to indentation, even if python is supposed to be a modern language
I thought the fact that python uses indentation to indicate blocks of code was one of the distinguishing features of Python.
Since I will be using SuSE systems to debug such a script, my question is: do you know of an editor, running on SuSE, which does not cut off the precious indentation characters making a mess of a python script ?
vi? /Per -- Per Jessen, Zürich (20.2°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Maura Monville said the following on 06/15/2009 07:28 AM:
Since I will be using SuSE systems to debug such a script, my question is: do you know of an editor, running on SuSE, which does not cut off the precious indentation characters making a mess of a python script ? For instance, Emacs won't work for this particular problem.
VI - VIM. There is(are) a switch(es) to control whether tabs get expanded an how they get 'expanded' on screen - or not. I'd expect emacs to have one too but I've never been tempted to use that. VI/VIM has serve me well for 27 years. -- He had occasional flashes of silence, that made his conversation perfectly delightful. Sydney Smith, referring to Macaulay -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Maura Monville wrote:
For instance, Emacs won't work for this particular problem.
I don't use emacs or python but ... 'make' files depend on tabs being in exactly the right place and I'd be astounded if emacs can't be used to edit make files! It also seems rather strange that there are apparently two Python modes for emacs if it can't be used to edit python :) http://www.emacswiki.org/emacs/PythonMode So my bet is that emacs can be used to edit python. How much do I win? Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
whatever editor I use .. I have not found a way to see the unprintable characters (Tab).
Maura
----- Messaggio originale -----
Da: Dave Howorth
For instance, Emacs won't work for this particular problem.
I don't use emacs or python but ... 'make' files depend on tabs being in exactly the right place and I'd be astounded if emacs can't be used to edit make files! It also seems rather strange that there are apparently two Python modes for emacs if it can't be used to edit python :) http://www.emacswiki.org/emacs/PythonMode So my bet is that emacs can be used to edit python. How much do I win? Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Mon, 15 Jun 2009, 17:39:47 +0200, Maura Monville wrote:
whatever editor I use .. I have not found a way to see the unprintable characters (Tab). Maura
hmm, that's pretty easy... Just use "vim" and type :set list<CR>; now every Tab character will be shown as ^I ;-) I don't actually like that editing mode, though; if you, however, insist on changing the leading 8 blanks in a line into a tab, you can run "unexpand" on any text file to do exactly that ... Cheers. l8er manfred -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hi! Am Montag 15 Juni 2009 17:54:05 schrieb Manfred Hollstein:
I don't actually like that editing mode, though; if you, however, insist on changing the leading 8 blanks in a line into a tab, you can run "unexpand" on any text file to do exactly that ...
You'll love it once you frequently change between systems with 1024 px or 2560 px wide displays. ;) Regards, Matthias
On Mon, 15 Jun 2009, 17:58:41 +0200, Matthias Bach wrote:
Hi!
Am Montag 15 Juni 2009 17:54:05 schrieb Manfred Hollstein:
I don't actually like that editing mode, though; if you, however, insist on changing the leading 8 blanks in a line into a tab, you can run "unexpand" on any text file to do exactly that ...
You'll love it once you frequently change between systems with 1024 px or 2560 px wide displays. ;)
yeah, but then the terminal description is wrong; normally a tab-stop is every 8 characters. If you look at terminfo(5), the entry for "tab" shows: tab ht ta tab to next 8-space hardware tab stop and further down: Tabs and Initialization If the terminal has hardware tabs, the command to advance to the next tab stop can be given as ht (usually control I). ... Dunno if nowadays GUI programs still adhere to such "historical" standards, though ;-)
Regards, Matthias
Cheers. l8er manfred -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Maura Monville said the following on 06/15/2009 11:39 AM:
whatever editor I use .. I have not found a way to see the unprintable characters (Tab).
Help us here. Why do you need to see the tab as a specific marker rather than as expanded spaces? If I recall, python only needs the indenting, it doesn't care what's shown on the screen for you so long as its consistent, and VI (and I would presume Emacs) will expand tabs on screen to how ever many display spaces your sweet heart desires. So what really is your problem here? Is it that you've grown up in Windows with an editor that shows tabs as an arrow rather than expanding spaces so you can see the indenting being aligned? Or what? If so, VI can be configured to show tabs as "^I", but then you don't see the alignment of the indents. I thought you wanted to work in Python, so why not use VI's Python mode. Perhaps I'm an oddball, but I'd rather see the tabs expanded on screen. Does Python care whether the indenting is via tabs or spaces so long as its consistent? What are you really asking here? People have offered a number of solutions but you seem to be playing a "Yes-but" game. -- "Necessity is the mother of invention" is a silly proverb. "Necessity is the mother of futile dodges" is much nearer the truth. - Alfred North Whitehead -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Anton Aylward wrote:
If I recall, python only needs the indenting, it doesn't care what's shown on the screen for you so long as its consistent
And this is where the trouble starts if you use tabs: Consistency. Because as soon as you (or somebody else) use a different editor on a different machine, chances are that tabs get expanded to the wrong number of spaces (4 or 8 or whatever). This makes your Python code look wrong, because many editors (or the authors) will mix tabs and spaces. So there are two rules from PEP 8 [1] that you should _really_ obey: - Never mix tabs and spaces. - For new projects, spaces-only are strongly recommended over tabs. Everything else is just a major PITA! Also, always start python with the "-tt" option, this will raise an error if tabs and spaces are mixed in a way that is ambiguous. Regards nordi [1] http://www.python.org/dev/peps/pep-0008/ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Personally I do hate Windows. Although, in certain environments the development platform, and even the tools, are imposed ... take irt or leave it.
My current problem stems from my ignorance about python. On top of that I have to use the undocumented python code written by an Ms. student who decided to leave the Computer Science program when he was just a couple of weeks from defending his thesis. A crazy behaviour that nobody expected.
By trial and error I succeeded in getting the python script run to completion without any error. But the oputut it generates is not what was expected. Basically the python script is supposed to extract automatically some data from the miRecords data base which is public and available in form of structurated HTML web pages.
I understand where the python script gets the raw data (miRecords). But I cannot understand where it stores the information it is supposed to extract. It looks like the script is trying to store the info into a local database that might be
MySql or SQLight. Since I cannot see any call or link to either databases, I tried to run the python script step-by-step.
Since python is a scripting language I would expect to be able to accomplish that just copying llines from the script and pasting them onto a python terminal shell. But, regardless of which editor I use, python interpreter prints out plenty of "indentation error " messages.
I tried an interactive graphic debug session by typing #ddd pbd ... which brought up a nice GUI expecting an executable to be uploaded (sigh !).
I did not install pydbg as no rpm file is provided (as far as I know) and its installation procedure from source code is not clear to me. I do not know whether the standard steps (configure, make, make install) can be applyed to a scripting language.
I am appalled at a modern object-oriented language that is built on a suyntax which is sensistive to indentation !
I hope I won't irritate anyone if I post some excerpts of my pdb debugging attempts ... maybe they will be meaningful for
pythons experienced users.
Thank you very much for your patience.
Maura
----- Messaggio originale -----
Da: Anton Aylward
whatever editor I use .. I have not found a way to see the unprintable characters (Tab).
Help us here. Why do you need to see the tab as a specific marker rather than as expanded spaces? If I recall, python only needs the indenting, it doesn't care what's shown on the screen for you so long as its consistent, and VI (and I would presume Emacs) will expand tabs on screen to how ever many display spaces your sweet heart desires. So what really is your problem here? Is it that you've grown up in Windows with an editor that shows tabs as an arrow rather than expanding spaces so you can see the indenting being aligned? Or what? If so, VI can be configured to show tabs as "^I", but then you don't see the alignment of the indents. I thought you wanted to work in Python, so why not use VI's Python mode. Perhaps I'm an oddball, but I'd rather see the tabs expanded on screen. Does Python care whether the indenting is via tabs or spaces so long as its consistent? What are you really asking here? People have offered a number of solutions but you seem to be playing a "Yes-but" game. -- "Necessity is the mother of invention" is a silly proverb. "Necessity is the mother of futile dodges" is much nearer the truth. - Alfred North Whitehead -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
In <854438.63892.qm@web24208.mail.ird.yahoo.com>, Maura Monville wrote:
Personally I do hate Windows. Although, in certain environments the development platform, and even the tools, are imposed ... take irt or leave it.
I always tell them I'll leave it. There is fallout, but there's fallout the other way too.
Since python is a scripting language I would expect to be able to accomplish that just copying llines from the script and pasting them onto a python terminal shell. But, regardless of which editor I use, python interpreter prints out plenty of "indentation error " messages.
Your editor, editor toolkit, clipboard, or terminal toolkit may be munging this[1]. It's often not easy to copy/paste tabs. You might try using a python debugger, if such a thing exists, and have it read the file, but step/next/continue between lines based on your input. -- Boyd Stephen Smith Jr. ,= ,-_-. =. bss@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/ [1] For example, best I can tell, konsole never provides tabs to the selection. I know cat, vim, etc. are printing them to the terminal, but taking that output and pasting it anywhere else results in the tabs being turned into spaces.
On Mon June 15 2009 5:01 pm, Maura Monville wrote:
I hope I won't irritate anyone if I post some excerpts of my pdb debugging attempts ... maybe they will be meaningful for pythons experienced users.
Maura, there is a very helpful python mailing list that deals with exactly your situation. Go to python.com and find it. It will be a big help. -- Bob Rea mailto:gapetard@stsams.org http://www.petard.us http://www.petard.us/blog http://www.petard.us/gallery Where is Bill Stringfellow now that we really need him? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Maura Monville wrote:
I tried to run the python script step-by-step. Have you tried pdb for that? A very nice introduction can be found at [1], plus some links. That is probably better than copy and paste anyway, because you would always have to copy and paste all "import" statements before code snippets can work.
I am appalled at a modern object-oriented language that is built on a suyntax which is sensistive to indentation ! This is not a bug, it is a feature. It forces programmers to use indentation, and to use it consistently. That means all Python programs are indented the same way (=easy to read).
Also, you don't have to explicitly mark blocks with {..} or do...done or whatever as in other languages. This explicit marking and the indentation have redundant info about the program structure: One is for the compiler/interpreter, one for the human. But redundancy can lead to inconsistency, e.g. a programmer writing if (foo == 1) bar(); foobar(); For the human eye, foobar() belongs to the if statement. For the compiler it does not, because there is no {...}. This kind of mistake cannot happen in Python, because syntactically, what you see is what you get. Removing the redundant info also makes it easier to read the code, because there is simply less to read. So using indentation as part of the syntax makes programs easier to read and eliminates an entire class of programming errors. Regards nordi [1] http://www.ferg.org/papers/debugging_in_python.html -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 nordi wrote:
Maura Monville wrote:
I am appalled at a modern object-oriented language that is built on a suyntax which is sensistive to indentation ! This is not a bug, it is a feature. It forces programmers to use indentation, and to use it consistently. That means all Python programs are indented the same way (=easy to read).
Indentation based block definition has some limitations. While many aspects of Python are very good, this particular departure is problematic. I explored Python out of curiosity a while back and this particular feature was enough for me not to consider making use of the language for any future project.
Also, you don't have to explicitly mark blocks with {..} or do...done or whatever as in other languages. This explicit marking and the indentation have redundant info about the program structure: One is for the compiler/interpreter, one for the human. But redundancy can lead to inconsistency, e.g. a programmer writing if (foo == 1) bar(); foobar();
A minor issue. Which for any half way decent IDE would be reformatted as .. either if (foo == 1 ) bar(); foobar(); or if (foo == 1 ) bar(); foobar(); according to formatting preferences by applying the IDE formatter... BTW Some consider it good practice in C/C++ and similar to use the form... if (1 == foo) bar(); to avoid accidents like if (foo = 1) bar(); which is usually correct syntax but may not give intended result. When... if (1 = foo) bar() in most languages will generate a runtime or compile syntax error..
For the human eye, foobar() belongs to the if statement. For the compiler it does not, because there is no {...}. This kind of mistake cannot happen in Python, because syntactically, what you see is what you get. Removing the redundant info also makes it easier to read the code, because there is simply less to read.
Depends whether the syntax actually adds functionally, e.g. in many C/C++ like languages blocks can be used to control variable scope. (Something rather difficult to follow without an explicit beginning and end of block definition). What the block indentation does is make EOL a kind of implicit end of statement and obscures more subtle aspects of code structure. (Closures must be fun in Python... :-) )
So using indentation as part of the syntax makes programs easier to read and eliminates an entire class of programming errors.
Regards nordi
- -- ============================================================================== I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone. Bjarne Stroustrup ============================================================================== -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAko3bkkACgkQasN0sSnLmgIDTgCfVzSjomWOQy6YOx7Zh1IQa5rC hvsAoIglmxvlh0vZINzGEfwXQICu6b6F =HzmW -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
G T Smith wrote:
Indentation based block definition has some limitations. I would like to know about those limitations. You can use blocks for scoping variables even when those blocks are 'only' defined with indentation. Python does not do that, but that does not mean it cannot be done. Anything else?
A minor issue. Which for any half way decent IDE would be reformatted as .. You are assuming that you have an IDE ready when you do the development. This only holds true until you have to work on a customers server over ssh to fix a bug. And it assumes you always write your programs with an IDE. I, at least, do not edit my shell scripts with Eclipse. Neither would I write Python or Perl programs of just 50 lines with a big IDE.
BTW Some consider it good practice in C/C++ and similar to use the form...
if (1 == foo) bar();
to avoid accidents like
if (foo = 1) bar(); Yes, that is certainly good practice. But the second example will get you a syntax error in Python, another kind of mistake you cannot make in that language. Probably a lesson learned from C.
A note to the TO: When you try to get the program to work, make sure you use the same version of Python that was used to program it. Some other distributions ship rather old Python versions (their package management uses Python, so they are much more conservative with new Python versions). If your program was written for one of the old versions it may give you trouble with Python version 2.6 that ships with current openSuse distributions. Regards nordi -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 nordi wrote:
G T Smith wrote:
Indentation based block definition has some limitations. I would like to know about those limitations. You can use blocks for scoping variables even when those blocks are 'only' defined with indentation. Python does not do that, but that does not mean it cannot be done. Anything else?
Mildly puzzled by this assertion, Python does not support this but it can be done!? (how? by a code hack or redefining the language syntax). My view on the block delimitators is they are rather like the capital letter at the beginning of a sentence and a full stop at the end. They are not essential but they help make things more readable.
A minor issue. Which for any half way decent IDE would be reformatted as .. You are assuming that you have an IDE ready when you do the development. This only holds true until you have to work on a customers server over ssh to fix a bug. And it assumes you always write your programs with an IDE. I, at least, do not edit my shell scripts with Eclipse. Neither would I write Python or Perl programs of just 50 lines with a big IDE.
For small scripts I would agree using full IDE is a bit like cracking a nut with sledgehammer, but for more complex applications a full IDE, with non runtime syntax checking, formatting, IDE controlled debugging and CVS /Subversion support is pretty well essential. (BTW I have run Eclipse over ssh and it usually works quite well). Also in situations where you have to work with a language you are unfamiliar with or very rusty on, IDE syntax checking and help systems can be very helpful. BTW I would not never consider debugging code on a production machine if I could possibly avoid it. That path leads to madness....
BTW Some consider it good practice in C/C++ and similar to use the form...
if (1 == foo) bar();
to avoid accidents like
if (foo = 1) bar(); Yes, that is certainly good practice. But the second example will get you a syntax error in Python, another kind of mistake you cannot make in that language. Probably a lesson learned from C.
There are occasions that assignment within a logical test is quite useful for brevity or complex coding. So this is not always an error but this is more an indicator that this is an intended rather than an unintended action. For those unfamiliar with the language it can be difficult to follow, however one tends to assume that those charged with maintenance have some knowledge.
A note to the TO: When you try to get the program to work, make sure you use the same version of Python that was used to program it. Some other distributions ship rather old Python versions (their package management uses Python, so they are much more conservative with new Python versions). If your program was written for one of the old versions it may give you trouble with Python version 2.6 that ships with current openSuse distributions.
Hmmm... Another reason to avoid python IMHO, most versions of a language should have a degree of backwards compatibility.
Regards nordi
- -- ============================================================================== I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone. Bjarne Stroustrup ============================================================================== -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAko6IV4ACgkQasN0sSnLmgKkXQCfYd07gWzEyBuyVrDztGKktP/m Dq0AnRLilYjaaOZmfnWH2wrhTTeo+UXa =aMt+ -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Monday 15 June 2009 04:01:16 pm Maura Monville wrote:
Personally I do hate Windows. Although, in certain environments the development platform, and even the tools, are imposed ... take irt or leave it.
My current problem stems from my ignorance about python. On top of that I have to use the undocumented python code written by an Ms. student who decided to leave the Computer Science program when he was just a couple of weeks from defending his thesis. A crazy behaviour that nobody expected. By trial and error I succeeded in getting the python script run to completion without any error. But the oputut it generates is not what was expected. Basically the python script is supposed to extract automatically some data from the miRecords data base which is public and available in form of structurated HTML web pages. I understand where the python script gets the raw data (miRecords). But I cannot understand where it stores the information it is supposed to extract. It looks like the script is trying to store the info into a local database that might be MySql or SQLight. Since I cannot see any call or link to either databases, I tried to run the python script step-by-step. Since python is a scripting language I would expect to be able to accomplish that just copying llines from the script and pasting them onto a python terminal shell. But, regardless of which editor I use, python interpreter prints out plenty of "indentation error " messages. I tried an interactive graphic debug session by typing #ddd pbd ... which brought up a nice GUI expecting an executable to be uploaded (sigh !). I did not install pydbg as no rpm file is provided (as far as I know) and its installation procedure from source code is not clear to me. I do not know whether the standard steps (configure, make, make install) can be applyed to a scripting language. I am appalled at a modern object-oriented language that is built on a suyntax which is sensistive to indentation !
I hope I won't irritate anyone if I post some excerpts of my pdb debugging attempts ... maybe they will be meaningful for pythons experienced users.
I suggest using IDLE (zypper install python-idle). This program was written in Python using the Tkinter GUI toolkit. It provides an interpreter interface as well as an editor. The editor allows you to write Python scripts easily with auto-indentation and syntax highlighting. It uses a lot of conventions that a lot of Python programmers use when writing their code. It even has help on the syntax of functions at the interpreter. Worth a try. -- Thank you, Anthony -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
I did installed python-idle from Yast which requested SuSE 11.1 DVD ... I hope it is the same as the one that zypper would have installed.
Anyway, no new applet or icon has been added to the Application menu.
I tried to launch it from terminal command line but I do not know where Yast placed it.
mauede@linux-326k:~> which python-idle
which: no python-idle in (/home/bin/Spectra:/home/mauede/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin)
mauede@linux-326k:~> which idle
/usr/bin/idle
So I launched as above:
mauede@linux-326k:~> /usr/bin/idle
IDLE Subprocess: socket error: Connection refused, retrying....
It opened up a window. I assume I have to use such a window to debug the python script.
I have always used debugger with compiled code ... so I feel at a loss.
I need to run the python script passing a parameter and do not know how to do.
Is there an IDLE demo ?
Thank you very much,
Maura
----- Messaggio originale -----
Da: Anthony Simonelli
Personally I do hate Windows. Although, in certain environments the development platform, and even the tools, are imposed ... take irt or leave it.
My current problem stems from my ignorance about python. On top of that I have to use the undocumented python code written by an Ms. student who decided to leave the Computer Science program when he was just a couple of weeks from defending his thesis. A crazy behaviour that nobody expected. By trial and error I succeeded in getting the python script run to completion without any error. But the oputut it generates is not what was expected. Basically the python script is supposed to extract automatically some data from the miRecords data base which is public and available in form of structurated HTML web pages. I understand where the python script gets the raw data (miRecords). But I cannot understand where it stores the information it is supposed to extract. It looks like the script is trying to store the info into a local database that might be MySql or SQLight. Since I cannot see any call or link to either databases, I tried to run the python script step-by-step. Since python is a scripting language I would expect to be able to accomplish that just copying llines from the script and pasting them onto a python terminal shell. But, regardless of which editor I use, python interpreter prints out plenty of "indentation error " messages. I tried an interactive graphic debug session by typing #ddd pbd ... which brought up a nice GUI expecting an executable to be uploaded (sigh !). I did not install pydbg as no rpm file is provided (as far as I know) and its installation procedure from source code is not clear to me. I do not know whether the standard steps (configure, make, make install) can be applyed to a scripting language. I am appalled at a modern object-oriented language that is built on a suyntax which is sensistive to indentation !
I hope I won't irritate anyone if I post some excerpts of my pdb debugging attempts ... maybe they will be meaningful for pythons experienced users.
I suggest using IDLE (zypper install python-idle). This program was written in Python using the Tkinter GUI toolkit. It provides an interpreter interface as well as an editor. The editor allows you to write Python scripts easily with auto-indentation and syntax highlighting. It uses a lot of conventions that a lot of Python programmers use when writing their code. It even has help on the syntax of functions at the interpreter. Worth a try. -- Thank you, Anthony -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 15.06.2009, Maura Monville wrote:
For instance, Emacs won't work for this particular problem.
That's not true, you just have to autoload "python-mode" in your .emacs to get it working. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (14)
-
Adam Jimerson
-
Anthony Simonelli
-
Anton Aylward
-
Bob Rea
-
Boyd Stephen Smith Jr.
-
Daniel Bauer
-
Dave Howorth
-
G T Smith
-
Heinz Diehl
-
Manfred Hollstein
-
Matthias Bach
-
Maura Monville
-
nordi
-
Per Jessen