Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Python -- Scripting language with generators and coroutines

Python for Perl programmers

News Scripting Languages

Best Python books for system administrators

Recommended Links Python for Perl programmers Debugging in Python Python Braces Debate
 Python installation Installing Python 3 from RPMs Installing Python Packages Compiling Python from source Jython Python coroutines Generators as semi-coroutines
Perl to Python functions map Control Flow Statements Execution of commands and capturing output of shell scripts and pipelines Imitation of Perl double quoted strings in Python Programming environment Python IDEs Pycharm IDE
Command-Line Syntax and Options pub — The Python Debugger Quotes Python history  Tutorials Python Cheatsheet Etc
 
A new competitor seemed to emerge out of the woodwork every month or so. The first thing I would do, after checking to see if they had a live online demo, was look at their job listings. After a couple years of this I could tell which companies to worry about and which not to. The more of an IT flavor the job descriptions had, the less dangerous the company was.
  • The safest kind were the ones that wanted Oracle experience. You never had to worry about those.
  • You were also safe if they said they wanted C++ or Java developers.
  • If they wanted Perl or Python programmers, that would be a bit frightening-- that's starting to sound like a company where the technical side, at least, is run by real hackers.
  • If I had ever seen a job posting looking for Lisp hackers, I would have been really worried.

-- Paul Graham 

When I see a top-down description of a system or language that has infinite libraries described by layers and layers, all I just see is a morass. I can’t get a feel for it. I can’t understand how the pieces fit; I can’t understand something presented to me that’s very complex. Maybe I do what I do because if I built anything more complicated, I couldn’t understand it. I really must break it down into little pieces.

Ken Thompson

 


Introduction

This is the forth page of an ongoing series of pages covering major scripting language topics for the Unix/Linux system administrators  (others cover Unix shells, Perl, and  TCL) based of Professor Bezroukov lectures.  

Python now is becoming the language Unix/Linux sysadmin must know at least on superficial level, as for many users, especially researchers, it is the primary language iether for development, or for writing supporting scripts. Python has been hailed as a really easy to learn language. It's not completely true, in fact it is as complex language as Perl (and in some areas more complex), with its own  large set of warts.  The fact that simple variables are assigned directly but complex variables like list need copy operation (otherwise alias in a form of pointer is created) is the source of many subtle errors.  Try to put .csv file into a two dimensional list on Python and you will instantly understand what I am taking about.  This example shows that Python is a complex unforgiving language.  In no way a novice can do that.

But it is an easier language to start with and it can be used as a small subset equivalent to Basic. Add to this OO hoopla. That's why got a strong foothold at universities  displacing Java (repeating path of Pascal in this regard, but on  a new level). The rest is history.

In this sense, Python essentially repeated the success of Pascal on a new  level using universities as a backdoor to wider adoption.  This is called Peter Naur effect which exists since PL/1 was created as the first "universal" programming language. It postulates that any programming language suitable for teaching beginners and adopted in this role in large number of universities has strong upward trajectory and the ability to raise to the top ten.  This effect is not absolute (C, C++, Perl are exceptions), but in general it holds very well. Classic examples of this effect include the success of Basic, Pascal, Java, PHP, and Python.

What is really interesting is that as times fly it become more and more difficult for a programming language to raise to the top: it took Python almost 30 years (1989-2019) to reach the current level of popularity (in 2010 it became No. 2 language in GitHub and it looks like it is more popular then Java).

But at the same time Python squeezed by Go language (which became No.3  and No.4 in GitHub in several categories, despite being much newer language; just 10 years old) both for system and for applications development. That difference in speed between Go and Python is easily 10-20 times (Go versus Python 3 fastest programs ) and can be as much as 100 in some cases you might actually encounter, and that's before you factor in the fact that Go can actually multiprocess efficiently. That's a serious disadvantage from computer science perspective. 

In statistical and  some classes of bioinformatics  applications Python is squeezed by R and Julia. And R is somewhat higher level language, then Python with a much better organized repository of modules/libraries.   Julia is much faster then Python and and being much newer language (2007) avoided some Python warts. So long term viability of Python, like in case of Pascal, is not given. Much depends how long it will remain the first language to which students are introduced to programming at universities.  And among teachers of programming, a lot of people are slightly annoyed by the fragmentation caused by Python2 vs Python3 and are ready to try Julia (which is very similar to Python)  I would say that with Python there is a core that could make a much better programming language for intro programming courses.  Also Julia recently joined C, C++, and Fortran as high-level languages in which petaFLOPS computations have been achieved.  Wikipedia

In system administration tasks Perl still holds it own as it is better suited for most system administrators then Python, unless there is strong institutional pressure for Python.

Among the "Big 5" scripting languages (Perl, Ruby, Python, JavaScript, and PHP), I'd say that 2 undeniably were designed for and still largely popular on the web: PHP and JavaScript. Three other are general purpose languages that are used both for system programming and  for application development. The early days of Python2 companies adopted Python as a  language which was easier to learn and less error prone than C/C++ and less verbose and cumbersome than Java (while being much slower). This was quite a big  niche which first included writing server side applications and eventually spread onto the web (Django in 2005 made the big splash). But the current problem is that  most Python programmers are struggling with high memory usage, the single processor limit, and difficulty in achieving high single-processor performance. For a considerable class of applications it is just too slow.  Also programming complex applications in Python is not a walk in the park. the language is too complex and has way to many warts.  One funny fact is that one of the most popular Python IDE -- PyCharm -- is written in Java :-)

As most sysadmins know Perl, Python should be easy to learn at basic level: the key concepts are similar and Python is the language greatly influenced by Perl, incorporating some European and, more specifically, Nicklaus Wirth ideas ( and idiosyncrasies ;-) about programming languages (in a way it can be viewed as belong to the line of European programming languages of Algol 60, Algol 68,  Pascal, Modula and Modula2 fame). Python's core syntax and certain aspects of its philosophy were directly derived from ABC (by Leo Geurts, Lambert Meertens, and Steven Pemberton ): a language for teaching programming which was based on really revolutionary language -- SETL by Jacob Schwartz.

As Guido van Rossum stated "I figured I could design and implement a language 'almost, but not quite, entirely unlike' ABC, improving upon ABC's deficiencies..." He also was influenced by early Perl success:  Version 1.0 was released of Perl was released to alt.sources in Dec 18, 1987, while the first version of Python ( 0.9.0) was released to alt.sources in February 20, 1991, three years after Perl release.

Here is a small example of ABC program from (The ABC Programming Language a short introduction) which collect the set of all words in a document. You instantly see the analogy: 

   HOW TO RETURN words document:
      PUT {} IN collection
      FOR line IN document:
         FOR word IN split line:
            IF word not.in collection:
               INSERT word IN collection
      RETURN collection

As we can see, Python inherited such most of its idiosyncratic and somewhat annoying  features from ABC. For example, such as determination of nesting by indentation (kind of "back to Fortran IV" move  ;-) , rather bold and strange decision to use colon as the separator between the condition and then part in the if/elif/while  statements, absence of variables declarations and lazy typing (which I think was a mistake; while "lazy" typing was large, may be critical advantage over Perl which use "everything goes" mantra, static typing is even better).

It has also several other questionable syntactic and semantic features: simple variables are treated like in most programming languages, while complex structures such as list needs an explicit copy operation to copy. Assignment just creates a pointer alias to the original data structure.  In Python 3 strings are not ASCII strings but Unicode strings which dramatically increases space taken by large   text areas. That make is less acceptable for using for processing genomic files and other large ASCII files, where the amount of tet you can keep in memory is important. 

While it is advocated as the perfect language for beginners, Python does contains quite a few annoyances and strange ad hoc rules, especially in its OO and lambda features, but the core language subset corresponding to Basic is mostly OK.  Still critics mention faults surprisingly similar to those mentioned by Perl critics (The History of Python A Brief Timeline of Python)

Uzah January 26, 2009 at 8:31 PM

  1. How long did it take you to realize the "range" function is using huge amounts of memory when used in a for loop ? Did you not envision people needing more than a few iterations ? If there should only be one way to do something, why have both range and xrange ?
  2. When are you going to add File.open ?
  3. How many more special reserved words are you going to use for "built-in" functions, and are there going to be any "free" names left for people to use in their programs without fear of conflict ?
  4. How many more ugly underscore methods are you going to hack into the "language" ?
  5. Why is everything about this "language" so hacky and provide a million different ways to do the same thing (get/getattr/hasattr/has_key/in/etc) ?
  6. Is the motivation behind the "property" function/decorator/object? to win the most stupid syntax ever ?

Python definitely avoided several traps in which Larry Wall fell. Among them is first of all the idea of forced conversion based on the type of operation (inherited by Perl from shell). Another problem in Perl is C-style curvy brackets as delimiters for blocks. This syntax has a chronic problem of unclosed (run away) bracket. Another important problem that Python managed to avoid is obligatory semicolon at the end of the line  (the fault inherited by Perl from C, which in turn inherited it from PL/1).

Python also does not use sigils, which make the program in Python superficially look "more normal" but you need to remember list of reserved words. In reality sigils are one of lesser Perl problem and people usually adapt rather well to them ($ is for example a dereferencing operator in Perl. so you can use $$line notation, which is pretty slick  ;-).  Forced conversion based on type of operation, abuse of both round and curvy brackets, mandatory semicolon at the end of  statements and attempts to match Python in OO (the last refuge of Perl complexity junkies) are much more serious problems.

But Python fell into C++ trap -- too much of functionality of the language is offloaded to the standard library. One especially pitiful decision is regular expression engine. Errors in regex are difficult to debug (and in general Python syntax errors are difficult to correct for novices).

Also Python came for a different operating system (Amoeba) and the level of integration with Unix is lesser in Python than in Perl which from the beginning was designed as a super ser of shell, AWK and SED and has strong connections to Unix  API.  I/O statements are badly designed until 3.8 when f string for print function were introduced.

While beginner can learn the basic of the language rather quickly (and that's why it was adopted by Universities as the first language ) in reality Python is a complex language which is pretty difficult to master. Semantics is difficult from Perl enough to it painful and annoying to learn for accomplished Perl programmers, as Perl skills and idioms are interfering with Pythons.  You feel like a accomplished ball room dancer put on the ice ring. You need to re-learn a lot of things. And fall a lot of times.  Moreover, all this hype  about Python being easier to read and understand is what is it: programming language hype. It reflect one thing: inability to distinguish "programming in the small" from "programming in the large". I think Philic J Guo put it well (Philip Guo - Hey, your Python code is unreadable! ):

I argue that code written in Python is not necessarily any more easily readable and comprehensible than code written in other contemporary languages, even though one of Python's major selling points is its concise, clear, and consistent syntax. While Python code might be easier to comprehend 'in-the-small', it is not usually any easier to comprehend 'in-the-large'.

Also (dragonwriter on Oct 7, 2015)

Perl: unary + is "convert to number", binary + is "convert operands to numbers and add". This is clear and consistent. String concatenation uses a different operator completely.

Python: binary + is string concatenation if the left operand is a string, and numeric addition if the left operator is a number. It fails at runtime if the right operator is inconsistent with the operation specified by the combination of the operator and the left operand.

That's the key: Python code is usually more difficult to comprehend in the large then, for example,  code from Perl because it is more verbose -- the same task requires  more lines of code then in Perl: in comparison with Perl, Perl has  somewhat higher language level in its core application area -- text processing, requiring less lines of code (and syntactic tokens) to express the same algorithms.  If OO is abused in Python scripts (which IMHO happens with alarming regularity) the difference frequently is over 50%.  In some Python programs that abused OO and modularization simultaneously (tremendous  amount of very small subroutines, which create OO spaghetti) that I, as an experiment,  rewrote in Perl the difference was 4 times (from 600 line  to 150 line)

The number of errors and the difficulty of comprehending the program is directly proportional to the number of lines of code (or more correctly syntax tokens), no matter what language you use.  So Perl obsession with compact coding at the end has some value and justification, although it is often abused.

The number  of errors and the difficulty of comprehending the program is directly proportional to the number of lines of code, no matter what language you use.  So Perl obsession with expressiveness, "Huffman coding" of some language constructs (with frequently used constructs having special notation) and compact coding has value in this respect.

The key problem with  Python programs is that they often suffer from abuse of OO (sometimes to a horrible level), leading to OO-spaghetti and programs several times more complex than they should be.

Python programs can be decomposed into modules, statements, expressions, and objects, as follows:

  1. Programs are composed of modules.
  2. Modules contain statements.
  3. Statements contain expressions.
  4. Expressions create and process objects.

First versions of Python did not introduced any radically new ideas and were by-and-large  just a more cleaner rehash of ideas of Perl with the addition of idea of modules from Modula 3. Interesting enough Python was released in 1991, the same year as Linux. Wikipedia has a short article about Python history:  History of Python - Wikipedia, the free encyclopedia

But starting with version 2.2 it added support of semi-coroutines in a platform independent way (via generators, the concept inspired by Icon) and became class of its own.  I think that this makes Python in certain areas a better scripting language then other members of the "most popular troika" (Perl, PHP and JavaScript). And currently it is definitely more popular language then  Ruby.  Availability of semi-coroutines favorably distinguish Python from Perl.

Quality of documentation

Python’s documentation is incomplete.  You need to rely on books,  Internet search and forums to learn vital information about usage language statement and constructs.  Tremendous amount of book about Python was published since 2000 and half-dozen general and a dozen of specialized books are of high quality.  You need to beware of books that are just rehash of documentation. There are plenty such "make money fast" books.

The first language effect

Python popularity to a large extent stems from its fact that it is used as the first language for introduction to programming at universities. This entail some future risks as universities might abandon Python for something new (like the abandoned Java in favor of Python in the past)

I would like to stress again that  one of the main reasons that Python is so popular is so called "first language effect" (aka "Peter Naur effect" as Peter Naur was the first to mention the profound importance of being accessing to beginners, effect which first demonstrated itself with Basic) -- language that university taught to students as the first programming language (and often the only programming language) has tremendous advantage over alternatives.

Python was adopted as the first language for teaching programming at many universities, and that produces steady stream of language users and some enthusiasts.  And after the language found its niche in intro university courses  the proverb "nothing succeed like success" is fully applicable.

Infatuation with Java in US universities declined substantially from the later of late 90th, because Java does not represent a step forward in development of programming language (both Perl and Python do represent such a step). As skeptics often call it is Cobol for XXI century with the garbage collection on top of it.  

As for programming language there is nothing interesting in Java  in comparison with C and C++ -- it is one step forward and two step back.

And Python is definitely preferable to Java as an introductory programming language: Python interpreter has interactive mode, suitable for small examples and as a language it is more forgiving for novices then Java. It also has decent debugger, although not of the quality of Perl debugger. At least, Python cause much less frustration for novices then iether Java or Perl. For Perl novices have great difficulty mastering usage of sigils $ @ and %, suffer from mandatory semicolon at the end of statements, the difference between comparison strings and number ( '==' vs eq )  and abuse of brackets. That killed Perl chances as an introductory language.

I would like to stress that  "no obligatory semicolon at the end of the statements" helps greatly and  Python is probably the first modern language which implemented this approach. The same is true for no C-style curvy bracket delimited blocks (the source of a lot of grief for beginners as missing  curvy bracket is difficult to locate).  All in all Python  value as introductory language can't be  underestimated.

Also it has more or less regular lexical structure and simpler syntax then both Java and Perl which both belong  to C-style language, while Python does not -- it is a class of its own.

As I mentioned before,  due to its very complex lexical structure and syntax Perl is as horrible as a beginner language; But at the same time for Unix sysadmins the semantic of Perl is closer to "Unix spirit" and this better understandable if you came from Bash and C (typical two languages that sysadmin know; or used to know in the past). For example in Perl $line is a dereferencing of the pointer \$line and represents the value at this location, while in Python line is both pointer to the location and the value.  

Corporate support

While the first 20 years of Python were difficult and it probably survived only due to the DAPRA grant (see revised  DAPRA proposal at https://www.python.org/doc/essays/cp4e/) , later computers became much faster and Python get some adoption, which attracted corporate sponsors.

Python was also lucky that for some time it enjoyed full support of Google (which employed for a long time Python creator,  Guido van Rossum). But then Google produced GO language, which is in many ways a direct competitor to Python. Google developers site still features some classes based on Python https://developers.google.com/edu/python/  based on Python 2.4.  In addition, Microsoft also supported it indirectly (via Iron Python and support In Visual Studio and other tools like Expressions Web). 

That created some money flow for development and put Python in much better position then Perl, which after it lost O'Reilly sponsorship (despite the fact that O'Reilly as a publisher earned millions on Perl books) does not have powerful corporate sponsor and its development at least since Perl 5.10 is lingering in obscurity.

Even in 2017 Python still enjoyed some level of support of Google, and that are no similar sponsor for iether Ruby or R, or Perl.  Out of modern languages only  JavaScript survived a semi-abandoned status (after collapse of Netscape).

Myth about Python orthogonally

Python is simplistically complex.

While in articles that compare Perl and Python you can often read the statement that while Perl provides many way to accomplish particular task, Python provide one  "correct" way. While it is true in several areas (and several design decisions in Python are superior to Perl) this is patently untrue in several important  areas.

For example, if you analyze loops constructs in Python you will definitely come to the conclusion that Python is pretty baroque language: there are way too many ways to traverse array in Python ;-)  You have loops, you have comprehensions (which, in essence, is an "implicit loop"), you have map, filter and zip functions,  and you have generators. And what you do not  have is tried and true C-style for loop with indexes (looks like Guido has some allergy to indexes, and it shows  ;-) .

Python is very idiosyncratic language that doe not use C/C++/Java line of languages legacy. It also has nothing to do with Bash and other Unix shells and as such it is less suitable for sysadmins. the distance is way too great to make sence to use it along with bash. Perl is a better dela here. I'm not saying Python is bad for all those applications. But IMHO it is far from being a user-friendly language that is the main advocacy for it. It is very capricious language in my book and it is very very ideosyncratic. In other words it  has its own way of doing a lot of stuff. That's what I don't get to like in the end.

People who program in C/C++, Java, Javascript and Perl can switch between the any pair of them reasonably easy, but Python always seems to work completely differently. Unless you plan to be a "Python developer"  that's a big disadvantage, because chances are you're going to use several languages throughout your career. By no means I'm trying to attack Python designers. then managed to put their language in top 10 and that's a tremendous achievement, kind of Nobel Price for any language designer. But I would like to stress that  Python is very "pythonic" and for sysadmins this is a huge drawback.

Also, while you can argue about the value of so many way to traverse an array or list (or any "iterable" data structure) in Python, if this is the meaning  of the word "orthogonal" I have a bridge to sell to you.  The same is true if you want to execute a shell program and capture its output and return code.  The design of implement regular expression engine as a library is a blunder, and it will show later as such unless corrected.

So while language itself is highly idiosyncratic, the libraries to it are very baroque. If you analyze the design of system libraries on Python, you will come to conclusion  that their design is not only baroque,  but  also unstable. For example, many widely used constructs in Python 2.7 will not  work in Python 3.7 and need to be rewritten.

Also Guido was never specialist in Unix and it shows. For example, Python is notable weak is the interception of output from pipes and Unix utilities (the area that is absolutely vital for system administrators). Not only it is subpar ( or, at least, provided on lower level then in Perl, where it is a language construct,)  it is also still "work in progress". Methods suitable for 2.7 do not work in 3.7 and need to be "translated". 

Truth be told, having lower level interface provide you will more capabilities. The question is whether you need them or not.

Python suffers from a mild case of NIH syndrome

 

As the language for Unix system administrators the major problem I have with  Python is  falls in "NIH" syndrome trap.  In language area NIH syndrome pretty much means the inability (or lack of desire) to acknowledge  the existence of other languages and the fact that the users probably will be programming is several languages.  This is variant of braking Occam's Razor.  Occam's (or Ockham's) razor is a principle attributed to the 14th century logician and Franciscan friar William of Ockham.  The principle states that "Entities should not be multiplied unnecessarily." And this principle fully applied to syntax constructs.

For example, by replacing classic C for loop with for loop based on   range function Python designers provided the same functionality with  a new construct (with a drawback that in Python 2.x the implementation of the range function it was generating the whole set of integers, consuming memory for no obvious reason):

You may have heard of a function known as xrange(). This is a function that is present in Python 2.x, however it was renamed to range() in Python 3.x, and the original range() function was deprecated in Python 3.x. So what's the difference? Well, in Python 2.x range() produced a list, and xrange() returned an iterator - a sequence object.

Partially it is unavoidable as  spend much of his early years outside Unix ecosystem, being involved with  the design of idiosyncratic OS (Amoeba) and idiosyncratic language (ABC).  This is kind of replay of Pascal warts: Pascal was well know for those arbitrary restrictions (for loop with only increment of 1 was a well known example for which Wirth was justifiably criticized.

For example, instead of providing clean, innovative interface to exiting classic Unix utilities (may be using their compilation is a special mode) Python  essentially tries to re-implement all Unix utilities with its own. This is the path already tried by other languages and it lead to reinventing the well on a large scale.  This also diverts very limited  resources on maintaining those libraries and some are of them inevitably are lingering in obscurity.  We already saw this effect in action with Perl so Python stepped on the same rake. 

Also, while platform independence is not a bad idea per se (actually Unix utilities were ported to all meaningful platform, and thus is typically done long before Python is ported) ,  it is a very bad decision for language used by Unix system administrators, who know most classic Unix utilities really well.

While it is undeniable that in some areas Python broke new ground in language design (generators and coroutines are one such example; only Modula out of mainstream languages used to have coroutine support in the past), in a larger context such decisions as omitting C-style for loop, change of conditional assignment syntax from

x=(y>z)?y:z   

to

x=y if (y>z) else z

This raises question "Why do you need to reinvent the wheel?". 

The same probably is true about classic Algol-68 construct like if then elif else fi (which strangely enough survived only in  Unix shell). Using colon instead of then is not that different from using "{" (opening of the block of statements (famous feature which started with C and then became pretty widespread despite obvious deficiencies). This Monty Python style decision, inherited by Python from ABC does not represent improvement:  it blocks possibilities to implement labels and Goto statements.

BTW the "else" clause of Python loop statement smells with incompetence (or inability to comprehend the famous Knuth paper -- as Knuth pointed out in 1972  in case multiple exits from the loop what you need is the case statement not just else statement activated on exit from triggering the condition at the header of the loop (actually why it is callused "else" ;-).  It is useless unless you are within  subroutine and can use return to break the execution flow, imitating case statement this way. 

Python omitted double quoted string interpolation used in Perl (which in turn inherited it from Unix  shell)  and never found a viable alternative solutions. Of course double quoted strings as implemented in Perl are problematic form many points of view (you need to parse them to extract variables information, which is not easy)

But may be I am too judgmental here. An interesting feature of this notation is that it allows shortened version: x=y if (y>z), while typically, (as implemented in Perl and C)  x=(y>z)?y  is a syntax error. After all, Larry Wall was suffering from his own acute attack of NIH syndrome: he  renamed brake and continue into next and last and replaced perfectly legitimate  keyword elif with elsif, simply becuase he do no like that it in  reverse it is spelled as file ;-)

Another demonstration of NIH syndrome is capturing  pipes and Unix utilities output -- the standard notation for which used in Unix  shells (and Perl) are backquotes.

python - Running shell command and capturing the output - Stack Overflow

The answer to this question depends on the version of Python you're using. The simplest approach is to use the subprocess.check_output function:
>>> subprocess.check_output(['ls', '-l'])
b'total 0\n-rw-r--r--  1 memyself  staff  0 Mar 14 11:04 files\n'

check_output runs a single program that takes only arguments as input.1 It returns the result exactly as printed to stdout. If you need to write input to stdin, skip ahead to the run or Popen sections. If you want to execute complex shell commands, see the note on shell=True at the end of this answer.

The check_output function works on almost all versions of Python still in wide use (2.7+).2 But for more recent versions, it is no longer the recommended approach.

Modern versions of Python (3.5 or higher): run

If you're using Python 3.5 or higher, and do not need backwards compatibility, the new run function is recommended. It provides a very general, high-level API for the subprocess module. To capture the output of a program, pass the subprocess.PIPE flag to the stdout keyword argument. Then access the stdout attribute of the returned CompletedProcess object:

>>> import subprocess
>>> result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE)
>>> result.stdout
b'total 0\n-rw-r--r--  1 memyself  staff  0 Mar 14 11:04 files\n'

The return value is a bytes object, so if you want a proper string, you'll need to decode it. Assuming the called process returns a UTF-8-encoded string:

>>> result.stdout.decode('utf-8')
'total 0\n-rw-r--r--  1 memyself  staff  0 Mar 14 11:04 files\n'

This can all be compressed to a one-liner:

>>> subprocess.run(['ls', '-l'], stdout=subprocess.PIPE).stdout.decode('utf-8')
'total 0\n-rw-r--r--  1 memyself  staff  0 Mar 14 11:04 files\n'

If you want to pass input to the process's stdin, pass a bytes object to the input keyword argument:

>>> cmd = ['awk', 'length($0) > 5']
>>> input = 'foo\nfoofoo\n'.encode('utf-8')
>>> result = subprocess.run(cmd, stdout=subprocess.PIPE, input=input)
>>> result.stdout.decode('utf-8')
'foofoo\n'

You can capture errors by passing stderr=subprocess.PIPE (capture to result.stderr) or stderr=subprocess.STDOUT (capture to result.stdout along with regular output). When security is not a concern, you can also run more complex shell commands by passing shell=True as described in the notes below.

This adds just a bit of complexity, compared to the old way of doing things. But I think it's worth the payoff: now you can do almost anything you need to do with the run function alone.

Older versions of Python (2.7-3.4): check_output

If you are using an older version of Python, or need modest backwards compatibility, you can probably use the check_output function as briefly described above. It has been available since Python 2.7.

subprocess.check_output(*popenargs, **kwargs)  

It takes the same arguments as Popen (see below), and returns a string containing the program's output. The beginning of this answer has a more detailed usage example. In Python 3.5 and greater, check_output is equivalent to executing run with check=True and stdout=PIPE, and returning just the stdout attribute.

You can pass stderr=subprocess.STDOUT to ensure that error messages are included in the returned output -- but in some versions of Python passing stderr=subprocess.PIPE to check_output can cause deadlocks. When security is not a concern, you can also run more complex shell commands by passing shell=True as described in the notes below.

If you need to pipe from stderr or pass input to the process, check_output won't be up to the task. See the Popen examples below in that case.

Complex applications & legacy versions of Python (2.6 and below): Popen

If you need deep backwards compatibility, or if you need more sophisticated functionality than check_output provides, you'll have to work directly with Popen objects, which encapsulate the low-level API for sub processes.

The Popen constructor accepts either a single command without arguments, or a list containing a command as its first item, followed by any number of arguments, each as a separate item in the list. shlex.split can help parse strings into appropriately formatted lists. Popen objects also accept a host of different arguments for process IO management and low-level configuration.

To send input and capture output, communicate is almost always the preferred method. As in:

output = subprocess.Popen(["mycmd", "myarg"], 
                          stdout=subprocess.PIPE).communicate()[0]

Or

>>> import subprocess
>>> p = subprocess.Popen(['ls', '-a'], stdout=subprocess.PIPE, 
...                                    stderr=subprocess.PIPE)
>>> out, err = p.communicate()
>>> print out
.
..
foo

If you set stdin=PIPE, communicate also allows you to pass data to the process via stdin:

>>> cmd = ['awk', 'length($0) > 5']
>>> p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
...                           stderr=subprocess.PIPE,
...                           stdin=subprocess.PIPE)
>>> out, err = p.communicate('foo\nfoofoo\n')
>>> print out
foofoo

Note Aaron Hall's answer, which indicates that on some systems, you may need to set stdout, stderr, and stdin all to PIPE (or DEVNULL) to get communicate to work at all.

In some rare cases, you may need complex, real-time output capturing. Vartec's answer suggests a way forward, but methods other than communicate are prone to deadlocks if not used carefully.

As with all the above functions, when security is not a concern, you can run more complex shell commands by passing shell=True.

Notes

1. Running shell commands: the shell=True argument

Normally, each call to run, check_output, or the Popen constructor executes a single program. That means no fancy bash-style pipes. If you want to run complex shell commands, you can pass shell=True, which all three functions support.

However, doing so raises security concerns. If you're doing anything more than light scripting, you might be better off calling each process separately, and passing the output from each as an input to the next, via

run(cmd, [stdout=etc...], input=other_output)

Or

Popen(cmd, [stdout=etc...]).communicate(other_output)

The temptation to directly connect pipes is strong; resist it. Otherwise, you'll likely see deadlocks or have to do hacky things like this.

2. Unicode considerations

check_output returns a string in Python 2, but a bytes object in Python 3. It's worth taking a moment to learn about unicode if you haven't already.

Indentation as a proxy for nesting -- a bold, interesting, but questionable design decision

ABC designers from which Python borrowed this feature decided to imitate FORTRAN 4 to use an indentation to a part of syntax -- this time to denote nesting. Which is not that different from  the way Fortran 4 used it to distinguish between labels and statements ;-). All-in-all this desition proved to bea success as Python popularity can attest, but it creates some unanticipated side effect as soon as we leave the area of for teaching programming language for beginners and enter professional programming field.

First of all you can't simply cut and pasted fragment from the Web page into an editor and execut successfully, if there is any indention/code grouping at all. Such operation often  does not preserve correct spacing. Look at the fragment below that was pasted from the web:

if foo:
x = y+foo
if x > 4:
foo =3

Was the original block formatted like?

if foo:
    x = y+foo
if x > 4:
    foo =3

OR?

if foo:
    x = y+foo
    if x > 4:
       foo =3

What happens if the editor 'helpfully' fixes things to one of those 2 choices? and it picks the wrong formatting. If we deal with a big enough block of code, and are in a hurry this error will not be caught.

If your source has mixture of tabs and leading spaces you can get into another trouble. Different editors have different default setting for tabs and this way your nesting can became incorrect without you knowing it. Python interpreter has an option to warn you about this situation but you need to use it to get the warnings. Mixing tabs and space are invitation to disaster. Which simply means that tabs should never be  use while writing Python code.

Using nesting as syntax element creates problems with diffs. 

With regular languages editor usually implement a command using which you can find matching  parenthetic. Usually this is Ctrl-} command. Using Python with regular editor deprives you of this possibility. You are looked at specialize Python editors and IDE. If you program in multiple language this might be  not an acceptable choice.

Another side effect that if you want to write statement on level of nesting equal to zero you can't  put any leading spaces before. Python forces you to  start at column one. Which for me is pretty annoying. Of course there is a way around this limitation (you can always put statements into a subroutine, and that's how Python programs are usually structured with main being  yet another subroutine) , but  still this is a drawback.

By relegating block brackets to the lexical level of blank space and comments Python failed to make a necessary adjustment and include pretty printer into interpreter (with the possibility of creating pretty printed program from pseudo-comments like #fi #while, etc ). Such a pretty printer actually is  needed to understand larger Python programs: format of comments can be Algol-68 style (or Bash style if you wish for people who never heard of Algol-68; that's the only feature that Borne shell inherited from algol-68 and Bourne was a member of Algol-68 development team before writing this program ;-). For example:

if a > b :
   delta=b-a
#fi

and the current number of spaces in the tab like  pragma tab = 4. The interesting possibility is that in pretty printed program those comments can be removed and after a reading pretty printed program into the editor reinstated automatically. Such feature can be implemented in any scriptable editor.

My impression is that few people understand that C  solution for blocks ({ } blocks) was pretty weak in comparison with its prototype language (PL/1): it does not permit nice labeled closer of blocks like

A1:do 
   ... 
end A1; 

in PL/1. IMHO introduction of a pretty printer as a standard feature of both a compiler and a GUI environment is long overdue. thare are multiple such programs, The simplest is pindent included with Python source distribution. See Python pretty printers

but there is silver lining in each dark cloud: by adding indentation as the proxy for nesting Python actually encourages a programmer to use a decent editor (which mean not nano/notepad family ;-), but we knew that already, right? 

Theoretically this design decision also  narrows down the possible range of coding styles and  automatically leads to more compact (as for the number of lexical tokens) programs (deletion of curly brackets usually help to lessen the number of lines in C or Perl program by 20% or more).  But in practice Python programs tend to be  more verbose then Perl due to abuse of modularization and OO.

Some design decisions that do deserve praise

Multiline statements in Python are iether detected by unbalanced brackets or can be explicitly marked with a backslash. Which is much better solution then mandatory semicolon at the and of the statements in Perl. You can omit is before '}', but  in all other cases the interpreter will complain

So while Perl carry on this design blunder form PL/1 and C (which is fact is a PL/1 derivative) Python managed to find a better, more optimal for programmers, solution.  Which especially benefits novices, but still is useful for seasoned Perl programmers. I do not know how many hours of my time were wasted on finding and correcting "missing semicolon at the of statement" errors.  It does not matter how many years of experience you have with the language. You still periodically commit such errors, but of coleus you know were to look so they are quietly corrected. Still it is big nuisance,  I would say a war in PL/1 language design.

The ability to close multiple blocks by just changing indentation is another big  plus (actually PL/1 was capable of doing that in late 60th (talk about progress in language design), but neither C, nor Perl can), but  only for short programs, which are visible on  the screen.

Prohibition of assignment statements within conditional expressions is another good design  decision. This in C, C++, Perl and similar languages lead to problem of mixing '=' and '==' with corresponding consequences. This is a well known problem -- a wart in C language design.

Using array index notion for assessing sting is another Python strength. It is a much better solution that using substr function (PL/1, C, Perl). Although with programmable keyboard this is less of  a problem. Still it is a big nuisance.

Python entered the period when the key developer stepped down

  “What moves men of genius, or rather what inspires their work, is not new ideas, but their obsession with the idea that what has already been said is still not enough.”

~ Eugene Delacroix

Art is never finished, only abandoned” ~ Leonardo Da Vinci 

Guido van Rossum ( who at the time of this writing is over 60 ) essentially ended his programmer career.  He devoted to Python 30 years of his life and decided that enough is enough. And 30 years is probably very close to maximum period initial open source software developers support their creation. Usually the initial excitement and desire to make a scratch evaporates after 10 years or so.  Often health problems make is impossible to continue (Larry Wall).

Period after the key developer stepped down is usually the period of chaos for most programming languages and we will see if Python can avoid negative effects of such  a period.  In open source development  too many things are linked to the existence of the  "final arbiter and guru" ( aka Benevolent Dictator) and the conceptual integrity of the language after the key developer stepped down usually suffers.

Guido van Rossum work of Python definitely make him one of the heroes of open source movement along with such giants as Thomson, Knuth, Bill Joe, Theo de Raadt, Richard Stallman, Linus Torvalds, Larry Wall.

But he stepped down without accomplishing the major task -- transition from Python 2.x to Python 3.x.

Python ecosystem

Language itself has little value without full language ecosystem, which includes debugger, IDE, books, Web site, forums, test suits, etc. A good debugger is probably as valuable as the language itself, or, at least, represents 50% of the value of the language.  Python does have a debugger, which became quite decent after, say, version 2.5. Which means rather late. But it is better late then never.

Currently Python has the most developed ecosystem among all scripting languages with a dozen of high quality IDE available (Perl has almost none, although Komodo Edit can be used as a proxy) . Probably pycharm being  the most popular (and it has a free version for individual developers)

Starting from version 2.7 debugger supports almost the same set of operation as famous Perl debugger. In other words at last it manage to bridge the gap with Perl debugger.  Better late then never ;-).  From version 3.4 the debugger can be invoked from within the script, the feature the Perl has for ages.

While from 1990 to 2000 and avalanche of Perl books was published (although surprisingly few of them were of decent quality and they were mostly non-O'Reilly books ;-) , now new Perl books are a very rare event. Python here definitely dominates. There are probably more books published about Python then any other scripting language. In 2017 books about Python are still baked like there is no tomorrow, but like was the case with Perl before most of them are of poor or average quality.  Especially written  by OO zealots. This amount of "junk books" is an interesting  feature of the language. Many Python books should be avoided at all costs as they do not explain the language but obscure it.  You are warned.

One sign of the popularity of a scripting language is availability of editors which use it as macro language. Here Python outshine Perl by several orders of magnitude. Very few editors and IDE were written in Perl. Most are abandonware.

see PythonEditors - Python Wiki

Komodo Editor is a decent quality middleweight free editor  that supports writing add-ons in Python.  See Macro API Reference

Overcomplexity: both Python and Perl are above the level on ordinary human comprehension
and need to be operated as subsets

Despite some claim that Python adhere to simplicity this is simply is not true. Python is bigger language then Perl and as such more complex becuase it it more into esoteric OO areas. It has probably twice more built-in functions.   

In addition to that it pushed a lot of complexity into the standard library, the trick previously successfully used by C, but with the same disastrous results (C treatment of strings as byte arrays, not as a separate data type like in PL/1 was in retrospect a blunder; it is explainable by the fact that it was designed as a system programming language, but still a blunder ).

Python did something similar with regular expression module. In Perl it is a part of the language, in Python it is a part of standard library.  Python has slightly superior set of regular sting manipulating functions, so you can use regular expression less often (for example lstrip(), rstrip() are very useful; endswith() and startswith() are more questionable but still interesting additions) but still 

All-in-all this is a large, complex non-orthogonal language, not that different  in this respect from Perl. Just  a set of warts is different. And while Perl 5 changed very little for the last ten years due to the lack of development funds, Python  adds and adds complexity.  That's why in some areas like bioinformatics and statistics R gained ground at the expense of Python. R is more C-style (it preserves curvy brackets for blocks), higher level language the Python with better organized and documented libraries of packages and Perl style repository CRAN.

The level of interaction of some important scripting languages constructs in the language (regular expression, I/O) in Python is worse then in Perl although Python 3.7 and higher improved in this area , at last introducing something that resemble in convenience to Perl double quoted strings ;-)

And look at discussion about how to execute pipelines and external command in Python. At this point  any illusion that this is orthogonal language should disappear. In this area it is more baroque then Perl. 

Pushing part of complexity into the set of core modules solves nothing, because the computational environment in which Python operates (Unix or Windows) still has the same level of complexity and that level of complexity should be reflected in the language one way or another.

It is important to understand the "real Python" is a large and  complex language and a decent textbook such as  Learning Python, 5th Edition by Mark Lutz (2013) is  over thousand pages. Modest intro like Introducing Python Modern Computing in Simple Packages by Bill Lubanovic is 484 pages. Slightly more expanded intro  Python Essential Reference (4th Edition)  by David Beazley is over 700 pagers. O'Reilly cookbook is 706 pages. And so on and so forth. Humans can't learn such a large language and need to operate with  a subset.

So despite claims to the opposite Python belong to the same family of "complex" languages like Perl -- languages no single human can fully master in his lifetime.  Of course,  like with natural language comprehension, the level of knowledge of the language greatly vary with some individual being able to absorb higher level of complexity, but that does not changes the situation "in general".

The key reflection of this overcomplexity is the level of which Python presented in most popular books: there is no single book that like in C creates solid understanding of how language constructs are mapped into actually computer implementation. In this sense Python will never be able to match C. 

The means that contrary to hype both Perl and Python belong to the class of language with an attitude of "whatever gets the job done" although Python pretends (just pretends) to follow KISS principle: on the surface Python designers seems preferring simplicity and consistency in design to flexibility and multiple way of performing the same operation that Perl advocates (and something goes too far with this concept ;-)   

Version 2.x vs. 3.x problem

There is no single Python language. There are two dialects which are often called 3.x and 2.x.  Version 2.7 is now dominant and this is what can be called "classic Python."

Adoption of version 3.x is still low -- the dominant  versions in use are Python 2.6 and Python 2.7. There is so little enthusiasm about migration to Python 3.0 that developers were forced to threaten to stop releases of 2.x series in Jan 2020, at which point it will exist like Perl 4.0 -- without patches. Also the size of Python 2 codebase is such that  such transition is difficult undertaking in any case.  In other words they now try to force migration to 3.0.  

Bernie_Goetz

Can you elaborate on your point about Python 2 vs 3? I learned on 2.7 years ago and never learned 3.

CrestFallenLunarian

Just the differences between them, and how different modules require different versions. It's almost like two different programming languages, not one being a newer release of the other, because of how much python 3 cut out that makes older stuff not work.

The biggest difference between contemporary Python 3 and legacy Python 2 is the handling of strings:

String differences between Python 3 and Python 2

The biggest difference between contemporary Python 3 and legacy Python 2 is the handling of strings. In versions of Python up to and including Python 2 the str type was a so-called byte string, where each character was encoded as a single byte. In this sense, Python 2 str was similar to the Python 3 bytes, however, the interface presented by str and bytes is in fact different in significant ways.

In particular their constructors are completely different and indexing into a bytes object returns an integer rather than a single code point string. To confuse matters further, there is also a bytes type in Python 2.6 and Python 2.7, but this is just a synonym for str and as such has an identical interface.

If you're writing text handling code intended to be portable across Python 2 and Python 3 – which is perfectly possible – tread carefully!

There are some other differences. For example print  is a statement in Python 2 but is function print() in Python 3 like in Julia.  Also

As of late 2019 Python 2.7 remains the dominant version of Python for scientific and engineering computing (although the standard version that comes with RHEL 6.x is still python 2.6; RHEL 7 uses 2.7 and only RHEL 8 ships 3.x by  default ). 

Most modern Unix application, especially Web applications can generate UTF-8 strings -- a popular encoding for Web pages.  It  uses one byte for the first 256 characters, and up to 4 bytes for other characters .  Some claim that UTF-8 is now the dominant encoding on the World Wide Web (used in over 94% of websites as of November 2019).  From this point of view there should be a special UTF-16 type in the  language which on output should automatically be converted into UTF-8 strings.

For example Microsoft Windows uses UTF-16 in which each character is represented by two bytes (and end of line also represented by two bytes). There is also UTF-32 encoding in which all characters are represented by 4 bytes. It is used by Julia. This is the only fixed length UTF encoding. All other are variable length encodings, although if you limit yourself to the  64K characters UTF-16 is also fixed length encoding.  It looks like UTF-32 is a bridge too far.  It essentially increase the size of stored in the program strings 4 times, unless interpreter uses some internal compression method.

UTF creates some problems for languages with lazy typing can't distinguish between ASCII and UTF-8  strings in the literal, you need to attach  prefix u to the string literal to force UTF-16  representatation. 

Python 3 has slightly better support for coroutines. Here is quote form Fluent Python (chapter 16):

The infrastructure for coroutines appeared in PEP 342 — Coroutines via Enhanced Generators, implemented in Python 2.5 (2006): since then, the yield keyword can be used in an expression, and the .send(value) method was added to the generator API. Using .send(…), the caller of the generator can post data that then becomes the value of the yield expression inside the generator function. This allows a generator to be used as a coroutine: a procedure that collaborates with the caller, yielding and receiving values from the caller.

In addition to .send(…), PEP 342 also added .throw(…) and .close() methods that respectively allow the caller to throw an exception to be handled inside the generator, and to terminate it. These features are covered in the next section and in “Coroutine Termination and Exception Handling”.

The latest evolutionary step for coroutines came with PEP 380 - Syntax for Delegating to a Subgenerator, implemented in Python 3.3 (2012). PEP 380 made two syntax changes to generator functions, to make them more useful as coroutines:

These latest changes will be addressed in “Returning a Value from a Coroutine” and “Using yield from”.

Let’s follow the established tradition of Fluent Python and start with some very basic facts and examples, then move into increasingly mind-bending features.

Note on the difference between Python assignments and Perl assignments

The following explanation destroys the idea that  Python as s simple language. In Perl all variable types defined in the language (scalars,  lists, arrays and hashes are copied "by value", That means that a new copy is create as the result of assignment.

Python behaves like Perl for numeric values, strings and lists, but differently for hashes (called dictionaries in Python)

Novices are usually are not told about this nuance and happily write programs which usually behave as expected, but in reality they just do not understand the level of complexity of the language with hidden references. See assignment in python - Stack Overflow for more information:

... ... ...

I like to picture variables in python as the name written on 'labels' that are attached to boxes but can change its placement by assignment, whereas in other languages, assignment changes the box's contents (and the assignment operator can be overloaded).

Beginners can write quite complex applications without being aware of that, but then they are burned (python - Copied variable changes the original):

André Freitas, Nov 14, 2011 at 13:56

I have a simple problem in Python that is very very strange.
def estExt(matriz,erro):
    # (1) Determinar o vector X das soluções
    print ("Matrix after:");
    print(matriz);

    aux=matriz;
    x=solucoes(aux); # IF aux is a copy of matrix, why the matrix is changed??

    print ("Matrix before: ");
    print(matriz)

...

As you see below, the matrix matriz is changed in spite of the fact that aux is the one being changed by the function solucoes() .

Matrix before:
[[7, 8, 9, 24], [8, 9, 10, 27], [9, 10, 8, 27]]

Matrix after:
[[7, 8, 9, 24], [0.0, -0.14285714285714235, -0.2857142857142847, -0.42857142857142705], [0.0, 0.0, -3.0, -3.0000000000000018]]

André Freitas ,Nov 14, 2011 at 17:16

The line
aux=matriz;

Does not make a copy of matriz , it merely creates a new reference to matriz named aux . You probably want

aux=matriz[:]

Which will make a copy, assuming matriz is a simple data structure. If it is more complex, you should probably use copy.deepcopy

aux = copy.deepcopy(matriz)

As an aside, you don't need semi-colons after each statement, python doesn't use them as EOL markers.

André Freitas ,Nov 15, 2011 at 8:49

Use copy module
aux = copy.deepcopy(matriz) # there is copy.copy too for shallow copying

Minor one: semicolons are not needed.

aux is not a copy of matrix , it's just a different name that refers to the same object.

Modules and OO

The key Python feature is the ability to use modules. In this sense it is a derivative of Modula, which was a really revolutionary language by Nicklaus Wirth. Actually the only older mainstream language that implemented coroutines. Modules is a great language feature in its own right. In Python OO features are bolted on top of this and somewhat spoil the broth.

While Python provides OO features, like C++ can be used without them.  They were added to language, not present from the very beginning. And like in many other languages with OO features they became fashionable and promoted the language. Also OO features are badly abused in Python scripts -- I saw many cases when Linux/Unix maintenance script were written using OO features. Which makes them less maintainable and  the code twice or more verbose and obscure. 

While pointers to memory structures (aka objects) is how OO is implemented, unlike Perl Python it does not provide pointers as a separate data type.  You can use pointers via object oriented framework, but generally this is a perversion.  I think that the pointers is such a valuable programming construct that they should be  presented as a separate data type. All complex structures in Python are actually typed pointers, but  this is too little too late.

Python is shipped with all version of Linux not other Unix flavors

Currently Python is shipped as a standard component only with Linux and FreeBSD. Nether Solaris, not AIX or HP-UX include Python by default (but they do include Perl).

Of course, popularity of those flavors of Unix is in decline, but they hold their  niche in certain areas like large databases processing.

Quantity and quality of library of available modules

By the number and quality of available modules Python is now competitive and in some areas exceeds Perl with its famous CPAN. Like Perl, Python also has large library of standard modules shipped with the interpreter. And actually they are much better documented. Perl modules recently were partially spoiled by the switch to object oriented style of programming advocated by  some Perl advocates, so previous advantage in simplicity that Perl used to hold, now disappeared. It is now often painful to read modules in Perl standard library.

Among useful for sysadmins standard modules in Python we can mention the following

The fact that regular expression are not a part of the language like in Perl is a setback as they proved to be very useful in text processing and that  diminish expressive power of the language for many text processing tasks.

But Python also faces competition from more modern languages such as Ruby and, paradoxically, from R. Although still less popular Ruby competes with Python on features, especially for among programmers who value coroutines paradigm of software development (and it is really a paradigm, not just a language feature). Python provides generators that are close enough, but still...

Paradoxically Python managed to get a foot into numeric computing

Python also get a foot into numeric computing via SciPy/NumPy.  Which is a pretty amazing development. It is now widely used in molecular modeling area, which was previously dominated by compiled language (with Fortran being the major).

Python displaced Perl in bioinformatics

In genomic applications it also managed to displace Perl  because new  generation of bioinformatics engineers are trained at universities using Biopython (although quality of regular expression integration into the language is much lower in Python). Paradoxically and unexplainable to me now R is pushing Python out in this domain.

While Perl was dominant in early days of bioinformatics, this dominance did not last. Now it is almost completely displaced by Python  tin this area. BioPython displaced BioPerl, and new books  are covering almost exclusively BioPython. That's somewhat strange as Perl has more efficient implementation of strings (in Python strings are immutable objects, in Perl they are mutable, and if operation shortens the string or produced the string of the same language, no new memory allocation is needed)

Perl also has regular expression better integrated into the language.

Difficulties of adapting to the language for Perl programmers

Although Python as a  scripting language used Perl as prototype and its features are generally similar to Perl, Perl programmers experience difficulties adapting to the language.  They're not overly similar in implementation details, nor even remotely similar in syntax. Their extension mechanisms also took different directions. 

Processing every line in a file

Perl:

while (<>) {
    print $_;
}

Perl version allows getting input from STDIN, or from arbitrary number of arguments (which are processes one by one). this actually allow inlisit concatenation of arbitrary number of file supplied as the parameters.

Python (not exact equivalent but covers the most common case when filename was supplied explicitly via an argument)

for line in file('filename.txt'):
    print line

Some function are iether redefined or are missing in Python. for example substr is missing as Python allow treating string as a n array of characters (like C) and array notation extended to sliced is applicable). Index function exists in Python is multiple incarnations. One is in keyword in loops and the other is index method for sting class. Which is more confusing than in Perl ;-) Python actually allow to limit index to a specific substring, while Perl allows only to specify the starting position of search.

mystring = 'abcdefghijklmnoprstu'
print mystring.index('b',1,5)
Python has less transparent method of getting output of Unix standard utility or filter into the script:
import subprocess
df = subprocess.Popen(["df", "filename"], stdout=subprocess.PIPE)
output = df.communicate()[0]
device, size, used, available, percent, mountpoint = output.split("\n")[1].split()

While Perl has q, qq string constants and HERE string, Python has some nice features too although it does not match the Perl power:

Adjacent literal strings are concatenated by the Python compiler into a single string:

>>> "first" "second"
'firstsecond'

That can be very useful in splitting long string to get a nicely formatting code. Perl interpret operator . between string constants at compile time, so it has similar feature without introducing additional notation (which makes Python more non-orthogonal language as operator does the same thing and can be optimized at compile time)

First, let's look at multiline strings. Multiline strings are delimited by three quote characters rather than one. Here's an example using three double-quotes:

>>> """This is
... a multiline
... string"""
'This is\na multiline\nstring'

Final notes

We all understand that in real life better language seldom win (look at Java).  Luck plays tremendous role in  determining languages popularity. Best commercially supported language that satisfy current fashion has better chances. Python managed  to ride the wave of enthusiasm toward OO programming, which (by-and-large) unfair relegated Perl to the second class languages.  And it is not a bad scripting language so in a way success of Python is our success too.

It is also a very sad event, when the language you learned and used for a decade of more fades and you need to learn yet another one, just to keep up with programming fashion.

But there is a silver lining in any dark cloud. Using better supported language allow you chose a better IDE and other tools and as such you will be partially complicated for loss of time caused by the necessary to relearn and switch tot he new language.  Also to a certain extent learning Python makes you better appreciate Perl ;-)

For sysadmins that's especially difficult question to answer adhere much depends on your individual situation. It you write programs mostly to yourself and do not need to support Python programmers you probably are better off staying with Perl. If you need to support Python programmer with all this pip troubles, you better start learning Python and make it your primary language.

Python now also has several different implementation of the interpreter, which are a clear sign of both popularity and maturity of the language:  Along with CPython interpreter (which is standard) there is quite popular Jython  which uses JVM and thus integrates well with Java, and Iron Python which is Microsoft implementation (Python -- programming language)

The mainstream Python implementation, also known as CPython, is written in C compliant to the C89 standard, and is distributed with a large standard library written in a mixture of C and Python. CPython ships for a large number of supported platforms, including Microsoft Windows and most modern Unix-like systems. CPython was intended from almost its very conception to be cross-platform; its use and development on esoteric platforms such as Amoeba alongside more conventional ones like Unix or Macintosh has greatly helped in this regard.

Stackless Python is a significant fork of CPython that implements microthreads. It can be expected to run on approximately the same platforms that CPython runs on.

There are two other major implementations: Jython for the Java platform, and IronPython for the .NET platform. PyPy is an experimental self-hosting implementation of Python, in Python, that can output a variety of types of bytecode, object code and intermediate languages.

Several programs exist to package Python programs into standalone executables, including py2exe, PyInstaller, cx_Freeze and py2app.

Many Python programs can run on different Python implementations, on such disparate operating systems and execution environments, without change. In the case of the implementations running on top of the Java virtual machine or the Common Language Runtime, the platform-independence of these systems is harnessed by their respective Python implementation.

Many third-party libraries for Python (and even some first-party ones) are only available on Windows, Linux, BSD, and Mac OS X.

There is also a dialect called Stackless Python which adds support for coroutines, communication channels and task serialization.  As of 2019 this distribution is still maintained.

Python also has better interface with C programs than Perl, and more easily allow to write extension modules in C.

Nikolai Bezroukov


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[May 28, 2021] Microsoft Funds a Team with Guido van Rossum to Double the Speed of Python

May 26, 2021 | developers.slashdot.org

(zdnet.com) 153

Posted by EditorDavid on Monday May 17, 2021 @12:14AM from the faster-functions dept. ZDNet reports:

Guido van Rossum, who created popular programming language Python 30 years ago, has outlined his ambitions to make it twice as fast "" addressing a key weakness of Python compared to faster languages like C++.

Speed in Core Python (CPython) is one of the reasons why other implementations have emerged, such as Pyston .... In a contribution to the U.S. PyCon Language Summit this week , van Rossum posted a document on Microsoft-owned GitHub , first spotted by The Register , detailing some of his ambitions to make Python a faster language, promising to double its speed in Python 3.11 "" one of three Python branches that will emerge next year in a pre-alpha release ... van Rossum was "given freedom to pick a project" at Microsoft and adds that he "chose to go back to my roots".

"This is Microsoft's way of giving back to Python," writes van Rossum... According to van Rossum, Microsoft has funded a small Python team to "take charge of performance improvements" in the interpreted language...

He says that the main beneficiaries of upcoming changes to Python will be those running "CPU-intensive pure Python code" and users of websites with built-in Python.
The Register notes that the faster CPython project "has a GitHub repository which includes a fork of CPython as well as an issue tracker for ideas and tools for analysing performance."

"According to Van Rossum, there will be 'no long-lived forks/branches, no surprise 6,000 line pull requests,' and everything will be open source."

[Jun 11, 2019] American Exceptionalism and American Innocence A People's History of Fake News_From the Revolutionary War to the War on Terror

Jun 11, 2019 | www.amazon.com

Did the U.S. really "save the world" in World War II? Should black athletes stop protesting and show more gratitude for what America has done for them? Are wars fought to spread freedom and democracy? Or is this all fake news?

American Exceptionalism and American Innocence examines the stories we're told that lead us to think that the U.S. is a force for good in the world, regardless of slavery, the genocide of indigenous people, and the more than a century's worth of imperialist war that the U.S. has wrought on the planet.

Sirvent and Haiphong detail just what Captain America's shield tells us about the pretensions of U.S. foreign policy, how Angelina Jolie and Bill Gates engage in humanitarian imperialism, and why the Broadway musical Hamilton is a monument to white supremacy.

====

Like a thunderbolt that penetrates the dark fog of ideological confusion, American Exceptionalism and American Innocence: A People's History of Fake News -- From the Revolutionary War to the War on Terror , illuminates the hidden spaces of the official story of the territory that came to be known as the United States of America.

Meticulously researched, American Exceptionalism and American Innocence utilizes a de-colonial lens that debunks the distorted, mythological liberal framework that rationalized the U.S. settler-colonial project. The de-colonized frame allows them to critically root their analysis in the psychosocial history, culture, political economy, and evolving institutions of the United States of America without falling prey to the unrecognized and unacknowledged liberalism and national chauvinism that seeps through so much of what is advanced as radical analysis today.

That is what makes this work so "exceptional" and so valuable at this moment of institutional and ideological crisis in the U.S. This crisis is indeed more severe and potentially more transformative than at any other moment in this nation's history.

With unflinching clarity, Sirvent and Haiphong go right to the heart of the current social, political, economic, and ideological crisis. They strip away the obscurantist nonsense pushed by liberal and state propagandists that the Trump phenomenon represents a fundamental departure from traditional "American values" by demonstrating that "Trumpism" is no departure at all, but only the unfiltered contemporary and particular expression of the core values that the nation was "founded" on.

What Sirvent and Haiphong expose in their work is that American exceptionalism and its corollary American innocence are the interconnected frames that not only explain why the crude white nationalism of a Donald Trump is consistent with the violence and white supremacy of the American experience, but also why that violence has been largely supported by large sections of the U.S. population repeatedly.

As the exceptional nation, the indispensable nation, the term President Obama liked to evoke to give humanitarian cover to the multiple interventions,

destabilization campaigns, and unilateral global policing operations on behalf of U.S. and international capital, it is expected and largely accepted by the citizens of the U.S. that their nation-state has a right and, actually, a moral duty to do whatever it deems appropriate to uphold the international order. It can do that because this cause is noble and righteous. Lest we forget the words of Theodore Roosevelt, considered a great architect of American progressiveness, "If given the choice between righteousness and peace, I choose righteousness."

In a succinct and penetrating observation, Sirvent and Haiphong point out:

American exceptionalism has always presumed national innocence despite imposing centuries of war and plunder. The American nation-state has been at war for over ninety percent of its existence. These wars have all been justified as necessary ventures meant to defend or expand America's so-called founding values and beliefs. A consequence of centuries of endless war has been the historical tendency of the U.S. to erase from consciousness the realities that surround American domestic and international policy, not to mention the system of imperialism that governs both.

But the acceptance of state violence in the form of economic sanctions and direct and indirect military interventions is not the only consequence of the cultural conditioning process informed by the arrogance of white privilege, white rights, and the protection of white Western civilization. The racist xenophobia, impunity for killer-cops, mass incarceration, ICE raids and checkpoints, left-right ideological convergence to erase "blackness," are all part of the racial management process that still enjoys majoritarian support in the U.S.

American Exceptionalism and American Innocence 's focus on the insidious and corrosive impact of white supremacy throughout the book is a necessary and valuable corrective to the growing tendency toward marginalizing the issue of race, even among left forces under the guise of being opposed to so-called identity politics.

Centering the role of white supremacist ideologies and its connection to American exceptionalism and innocence, Sirvent and Haiphong argue that "communities and activists will be better positioned to dismantle them." American exceptionalism and notions of U.S. innocence not only provide

ideological rationalizations for colonialism, capitalism, empire, and white supremacy, but also a normalized theoretical framework for how the world is and should be structured that inevitably makes criminals out of the people opposing U.S. dominance, within the nation and abroad.

Paul Krugman, a leading liberal within the context of the U.S. articulates this normalized framework that is shared across the ideological spectrum from liberal to conservative and even among some left forces. I have previously referred to this view of the world as representative of the psychopathology of white supremacy:

"We emerged from World War II with a level of both economic and military dominance not seen since the heyday of ancient Rome. But our role in the world was always about more than money and guns. It was also about ideals: America stood for something larger than itself -- for freedom, human rights and the rule of law as universal principles . . . By the end of World War II, we and our British allies had in effect conquered a large part of the world. We could have become permanent occupiers, and/or installed subservient puppet governments, the way the Soviet Union did in Eastern Europe. And yes, we did do that in some developing countries; our history with, say, Iran is not at all pretty. But what we mainly did instead was help defeated enemies get back on their feet, establishing democratic regimes that shared our core values and became allies in protecting those values. The Pax Americana was a sort of empire; certainly America was for a long time very much first among equals. But it was by historical standards a remarkably benign empire, held together by soft power and respect rather than force." 1

American Exceptionalism and American Innocence refutes this pathological view of the U.S. and demonstrates that this view is a luxury that the colonized peoples of the world cannot afford.

The bullet and the bomb -- the American military occupation and the police occupation -- are the bonds that link the condition of Black Americans to oppressed nations around the world. This is the urgency in which the authors approached their task. The physical and ideological war being waged against the victims of the colonial/capitalist white supremacist patriarchy is resulting in real suffering. Authentic solidarity with the oppressed requires a

rejection of obfuscation. The state intends to secure itself and the ruling elite by legal or illegal means, by manipulating or completely jettisoning human freedom and democratic rights. Sirvent and Haiphong know that time is running out. They demonstrate the intricate collaboration between the state and the corporate and financial elite to create the conditions in which ideological and political opposition would be rendered criminal as the state grapples with the legitimacy crisis it finds itself in. They know that Trump's "make America great again" is the Republican version of Obama's heralding of U.S. exceptionalism, and that both are laying the ideological foundation for a cross-class white neofascist solution to the crisis of neoliberal capitalism.

The U.S. is well on its way toward a new form of totalitarianism that is more widespread than the forms of neofascist rule that was the norm in the Southern states of the U.S. from 1878 to 1965. Chris Hedges refers to it as "corporate totalitarianism." And unlike the sheer social terror experienced by the African American population as a result of the corporatist alignment of the new Democratic party and national and regional capital in the South, this "new" form of totalitarianism is more benign but perhaps even more insidious because the control rests on the ability to control thought. And here lies the challenge. Marxist thinker Fredrick Jamison shares a very simple lesson, "The lesson is this, and it is a lesson about system: one cannot change anything without changing everything." This simple theory of system change argues that when you change one part of a system you by necessity must change all parts of the system, because all parts are interrelated.

The failure of the Western left in general and the U.S. left in particular to understand the inextricable, structural connection between empire, colonization, capitalism, and white supremacy -- and that all elements of that oppressive structure must be confronted, dismantled, and defeated -- continues to give lifeblood to a system that is ready to sweep into the dustbins of history. This is why American Exceptionalism and American Innocence is nothing more than an abject subversion. It destabilizes the hegemonic assumptions and imposed conceptual frameworks of bourgeois liberalism and points the reader toward the inevitable conclusion that U.S. society in its present form poses an existential threat to global humanity.

Challenging the reader to rethink the history of the U.S. and to imagine a future, decolonial nation in whatever form it might take, Sirvent and Haiphong include a quote from Indigenous rights supporter Andrea Smith

that captures both the subversive and optimistic character of their book. Smith is quoted saying:

Rather than a pursuit of life, liberty, and happiness that depends on the deaths of others . . . we can imagine new forms of governance based on the principles of mutuality, interdependence, and equality. When we do not presume that the United States should or will continue to exist, we can begin to imagine more than a kinder, gentler settler state founded on genocide and slavery.

American Exceptionalism and American Innocence gives us a weapon to reimagine a transformed U.S. nation, but it also surfaces the ideological minefields that we must avoid if we are to realize a new possibility and a new people.

<img src="https://images-na.ssl-images-amazon.com/images/S/amazon-avatars-global/default._CR0,0,1024,1024_SX48_.png"> John , May 26, 2019

Great Reading, But Some Omissions

I thought the book was great. However, key events were not discussed. One of the first deployed American expeditionary forces to bless the world was the establishment of treaty ports in China. These new American foreign beachheads in the Middle Kingdom came about as a result of Western ambitions to take them over as new colonial owners and led to one of the most ruinous periods in world history. Europe and the U.S. saturated the country with opium, leaving many Chinese stoned. This resulted in the destabilization of China, invasion of the brutal Japanese and the rise of Mao. Result- millions upon millions of people died because of American exceptionalism. It has taken China the last thirty years to recover from the disasters. Naturally, Trump & Co are not aware of this history or are unconcerned. However, the Chinese have not forgotten and routinely warn Team Trump they will not be bullied by foreigners again. Washington elites are ignorant at everyone's peril who want peace. Footnote - American exceptionalists Roosevelt, Kerry, Forbes, etc., got their wealth the old fashion way - by becoming drug kingpins to China.

The other big omission was World War I and especially its aftermath. Lauded by the French and saving European imperialism, returning African-American soldiers found themselves being singled out for extra harsh Jim Crow treatment -- they were too uppity & refused to follow old social norms. Several Black vets were tortured and hung while in uniform because they were bringing back a new message from European trenches - equal treatment. They were also exemplary in defending other Black citizens from White mob ambushes.

Had the authors covered the WWI aftermath, they would have also had to critique in greater detail the media. What they would have had to expose the media was never a friend to African-Americans, which holds to this day. The media was and is consistent with aligning with white elite interests. When Blacks rose up against bad treatment, the media always presented the white point of view. In fact, every white institution was engaged in this biased practice.

The Espionage Act also put a chill on labor organizing post WWI. Indeed, elites were quick to call any Black unrest as seditious and labelled some leaders such as W.E.B Dubois, Bolshevik inspired and should have been brought up on charges. This was the beginning of the linking of Black activism to the Kremlin, long before McCarthyism, COINTELPRO and Black Identity Extremist government labels.

[Jun 05, 2019] End of Discussion How the Left s Outrage Industry Shuts Down Debate, Manipulates Voters, and Makes America Less Free (and Fun)

Notable quotes:
"... This book covers our current inability to allow all voices to be heard. Key words like "racism " and "?-phobia" (add your preference) can and do end conversations before they begin ..."
"... Hate speech is now any speech about an idea that you disagree with. As we go down the road of drowning out some speech eventually no speech will be allowed. Finger pointers should think about the future, the future when they will be silenced. It's never wrong to listen to different point of view. That's called learning. ..."
"... A very clear and balanced portrait of the current political landscape where a "minority of one" can be supposedly damaged as a result of being exposed to "offensive" ideas. ..."
"... A well documented journey of the transformation from a time when people had vehement arguments into Orwell-Land where the damage one supposedly "suffers" simply from having to "hear" offensive words, allows this shrieking minority to not only silence those voices, but to destroy the lives of the people who have the gall to utter them. ..."
Aug 01, 2017 | www.amazon.com

Q Garcia , August 9, 2017

1984 is Here - Everybody's Brother is Watching

This book covers our current inability to allow all voices to be heard. Key words like "racism " and "?-phobia" (add your preference) can and do end conversations before they begin .

Hate speech is now any speech about an idea that you disagree with. As we go down the road of drowning out some speech eventually no speech will be allowed. Finger pointers should think about the future, the future when they will be silenced. It's never wrong to listen to different point of view. That's called learning.

.0 out of 5 stars A Professor's Review of the Outrage Circus (and the first non-Vine review :-)
Brumble Buffin , August 18, 2015
Tolerance gone astray

I became interested in this book after watching Megyn Kelly's interview with Benson (Google it), where he gave his thoughts on the SCOTUS decision to legalize same-sex marriage in all 50 states. He made a heartfelt and reasoned plea for tolerance and grace on BOTH sides. He hit it out of the park with this and set himself apart from some of his gay peers who are determined that tolerance is NOT a two-way street.

We are seeing a vindictive campaign of lawsuits and intimidation against Christian business people who choose not to provide flowers and cakes for same-sex weddings. The First Amendment says that Congress shall make no law prohibiting the free exercise of religion. Thumbing your nose at this core American freedom should alarm us all. Personally, I'm for traditional marriage and I think the better solution would be to give civil unions the same legal rights and obligations as marriage, but that's another discussion.

So what about the book? It exceeded my expectations. Ham and Benson are smart and articulate. Their ideas are clearly presented, supported by hard evidence and they are fair and balanced. The book is a pleasure to read - - unless you are a die-hard Lefty. In that case, it may anger you, but anger can be the first step to enlightenment.

Steve Bicker , August 1, 2015
A Well Documented Death of Debate

A very clear and balanced portrait of the current political landscape where a "minority of one" can be supposedly damaged as a result of being exposed to "offensive" ideas.

A well documented journey of the transformation from a time when people had vehement arguments into Orwell-Land where the damage one supposedly "suffers" simply from having to "hear" offensive words, allows this shrieking minority to not only silence those voices, but to destroy the lives of the people who have the gall to utter them.

The Left lays claim to being the "party of tolerance", unless you happen to "think outside THEIR box", which, to the Left is INtolerable and must not only be silenced, but exterminated... A great book!

[May 13, 2019] Big Israel How Israel's Lobby Moves America by Grant F. Smith

Jewish lobby does not represent the views of the US Jewish population. They represent a small number of rich donors (concentration is just staggering) and of course Israeli government. Those organization are non-representative authoritarian bodies with a lot of functionaries serving for life or extremly long tenures.
Notable quotes:
"... One stunning example of this influence occurred recently. At one time during the nominating process for the Republican candidate for President in the current election, every single aspirant to the nomination made a pilgrimage to Las Vegas to kiss the money ring of Sheldon Adelson, whose only declared interests are Israel and online gambling. This is the same super-patriot Sheldon Adelson who wanted Mitt Romney to pardon Jonathan Pollard, should Romney become President with Adelson's financial backing. ..."
Feb 05, 2016 | www.amazon.com

The latest in the powerful series of titles written by Grant Smith. Highly recommended factual, documented and accessible data that should
be required reading for high school students as well as their parents.!

James Robinson , July 26, 2016

Would have been a tedious read for someone well acquainted with Israeli machinations

Superb compilation of organizations that receive tax exempt status in the US that work exclusively on behave of a foreign nation, Israel,often to the pronounced determent of the US interests and policies. Would have been a tedious read for someone well acquainted with Israeli machinations, but for someone new to the subject the anger that the revelations produce makes the reading of this book a disquietening breeze. Read more

Ronald Johnson , April 11, 2016
non-systematic conjecture about Zionism's amazing insider access to

Book Review of Big Israel, by Grant F. Smith

This is an important book, the latest from Grant F. Smith in the line of his previous investigations into what was referred to as, the "Zionist Occupied Government", an earlier, intuitive, non-systematic conjecture about Zionism's amazing insider access to, and influence of, U.S. foreign policy. It is interesting that Wikipedia describes the "ZOG" exclusively as an anti-semitic conspiracy theory attributed to a list of unsavory persons and racist organizations.

On the one hand, the American Israel Public Affairs Committee puts on a very public celebration every spring, the "policy conference", that is a pep rally of mandatory attendance by national Administration and Congressional people to celebrate Zionism. That event is public. But on the other hand, as Grant Smith analyzes, the "Israel Affinity Organizations" of the United States are a different archipelago.

As to what extent these organizations are legitimate lobbies, versus being mis-identified agents of a foreign power, I won't attempt to summarize, or, "give away" the content of the book; it is for people to read for themselves, to be informed, and to think for themselves.

Grant Smith presents numbers, names, and dates, to be reviewed and challenged by anyone who wants to. There is precedent for that. The USS Liberty attack by Israel was defended as a tragic mistake by author A. Jay Cristol, in his book, "The Liberty Incident". The Wiesenthal Center commissioned the author, Harold Brackman, to write, "Ministry of Lies, the Truth Behind the 'Secret Relationship Between Blacks and Jews' ". That referenced book was by the Nation of Islam. With facts in hand, the Electorate is empowered to make informed decisions about the US national interest, relative to Zionism.

Another good book is by Alison Weir on essentially the same subject, "Against Our Better Judgement, the Hidden History of How the U.S. Was Used to Create Israel". The Amazon servers, for that book review are loaded with discussions, which can be seen under that title. The Amazon book reviews are a valuable national resource that can be a place to survey public opinion, even with the factor that positives have less motivation than negatives to inspire writing an essay.

D L Neal , May 28, 2018
at least at this time- Wonderful, informative and important book

It is obvious why there is no middle ground in the reviews here, at least at this time- Wonderful, informative and important book. Read more One person found this helpful

Luther , May 15, 2016
"America. . . you can move very easily. . .." Netanyahu

No matter what your values -- Christian, Enlightenment, social justice, international law, natural law, the Kantian imperative, crimes against humanity, Judaism's own values (Israel "a light unto the nations" Isaiah 49:6) -- what Israel has done and is doing to the Palestinians is morally wrong.
Sure. People have done bad things to other people forever, but this evil is orchestrated by a large Zionist organization from all over the world. And the US is being made complicit in this immoral undertaking in the numerous ways Grant Smith explores in his book.

Exposing America's unfortunate entanglement is why he wrote this excellent book: 300 pages and 483 footnotes of support for the claims he makes.
The American democratic process is being corrupted at every level in the interests of Israel, and Smith gives chapter and verse on how this is being done.

One stunning example of this influence occurred recently. At one time during the nominating process for the Republican candidate for President in the current election, every single aspirant to the nomination made a pilgrimage to Las Vegas to kiss the money ring of Sheldon Adelson, whose only declared interests are Israel and online gambling. This is the same super-patriot Sheldon Adelson who wanted Mitt Romney to pardon Jonathan Pollard, should Romney become President with Adelson's financial backing.

In addition, Haim Saban of the Brookings Institution plays a similar role in the Democratic party. He has said: "I'm a one-issue guy, and my issue is Israel." He has promised to contribute as much money as needed to elect Hillary Clinton, someone who believes that Israel has a right to exist as a "Jewish state," with Jerusalem (an international city for millenia) as its capital (something no country in the world approves of, not even the USA).

  1. Is this the American democratic process in action?
  2. Is this what the Constitution intends?
  3. Is this our America?

Grant discusses in supported detail the areas of dual citizenship and dual loyalties (American citizens in the Israeli Defense Force); espionage (industrial and military); yearly billions to Israel with no benefit to the US; media control (no debating the facts of history; no Palestinians allowed to articulate and disseminate their narrative); tax exemption for money which goes to Jewish interests as well as the illegal settlements in Israel; perversion of education (forced Holocaust information but no discussion; anti-assimilation); foreign policy (the war with Iraq for the benefit of Israel; the demonization of Iran; no condemnation of Israel's nuclear capability in spite of the Non-Proliferation Treaty; use of the veto in the UN in Israel's interests; Middle East "regime change" wars); Israeli and Jewish influence in Congress (money, intense lobbying by AIPAC and free trips to Israel), and financial contributions only to candidates who are unequivocally pro-Israel, in some cases very large sums of money.

The point is that all of this is being done in spite of the wishes and best interests of the American people and even of Israel. It's not as though the American people voted to do bad things to the Palestinians: kill them, starve them, imprison them, steal from them, and control them. Quite the opposite: as Grant Smith explains, unbiased polls indicate that most Americans show no such support for Israel's mistreatment of the Palestinians and believe that if both sides would abide by international law, the Geneva Conventions, and the UN resolutions relating to Palestine, peace could be achieved between Jews and Arabs in Palestine.

But Zionism has a different agenda, an agenda that will use any means legal and illegal to promote its interests by getting the United States to back it up.
And that agenda is the problem because it is built on non-negotiable beliefs.

What can you say to someone who believes that the Bible mandates the establishment of a Jewish homeland in Palestine to the exclusion of the indigenous inhabitants?

Or, as Rabbi Ovaida Yosef said in 2010, that "The Goyim [non-Jews] are born only in order to serve us. Besides this, they have no place on earth -- only to serve the people Israel."

Not surprisingly, the never-ending "peace process" goes on and on, with no peace in sight.

The US, in spite of itself, continues to support this cruel charade against its own interests and at the expense of neighbors, friends, allies and innocent parties in Palestine and elsewhere in the world.

Grant Smith's excellent book is an attempt to raise America's awareness to the point that something might be done.

[May 13, 2019] America The Farewell Tour by Chris Hedges

Sep 05, 2018 | www.amazon.com
Chapter 1 - DECAY                                                1
Chapter 2 - HEROIN______________________________________________59
Chapter 3 - WORK________________________________________________83
Chapter 4 - SADISM_____________________________________________112
Chapter 5 - HATE_______________________________________________150
Chapter 6 - GAMВIING___________________________________________203
Chapter 7 - KKh KDOM___________________________________________230
Acknowledgments________________________________________________311
Notes----------------------------------------------------------315
Bibliography___________________________________________________351
Index----------------------------------------------------------359

I walked down a long service road into the remains of an abandoned lace factory. The road was pocked with holes Pilled with fetid water. There were saplings and weeds poking up from the cracks in the asphalt. Wooden crates, rusty machinery, broken glass, hulks of old Piling cabinets, and trash covered the grounds. The derelict complex, 288,000 square feet, consisted of two huge brick buildings connected by overhead, enclosed walkways.

The towering walls of the two buildings, with the service road running between them, were covered with ivy. The window panes were empty or had frames jagged with shards of glass. The thick wooden doors to the old loading docks stood agape. I entered the crumbling complex through a set of double wooden doors into a cavernous hall.

The wreckage of industrial America lay before me, home to flocks of pigeons that, startled by my footsteps over the pieces of glass and rotting floorboards, swiftly left their perches in the rafters and air ducts high above my head. They swooped, bleating and clucking, over the abandoned looms.

The Scranton Lace Company was America. It employed more than 1,200 workers on its imported looms, some of the largest ever built.

Gary Moreau, Author TOP 500 REVIEWER, September 5, 2018

Washington is fiddling but it is the capitalist collective that is setting the fires

Throughout history, all great civilizations have ultimately decayed. And America will not be an exception, according to former journalist and war correspondent, Chris Hedges. And while Hedges doesn't offer a date, he maintains we are in the final throes of implosion -- and it won't be pretty.

The book is thoroughly researched and the author knows his history. And despite some of the reviews it is not so much a political treatise as it is an exploration of the American underbelly -- drugs, suicide, sadism, hate, gambling, etc. And it's pretty dark; although he supports the picture he paints with ample statistics and first person accounts.

There is politics, but the politics provides the context for the decay. And it's not as one-dimensional as other reviewers seemed to perceive. Yes, he is no fan of Trump or the Republican leadership. But he is no fan of the Democratic shift to identity politics, or antifa, either.

One reviewer thought he was undermining Christianity but I didn't get that. He does not support "prosperity gospel" theology, but I didn't see any attempt to undermine fundamental religious doctrine. He is, after all, a graduate of Harvard Divinity School and an ordained Presbyterian minister.

He puts the bulk of the blame for the current state of decay, in fact, where few other writers do -- squarely on the back of capitalist America and the super-companies who now dominate nearly every industry. The social and political division we are now witnessing, in other words, has been orchestrated by the capital class; the class of investors, banks, and hedge fund managers who don't create value so much as they transfer it to themselves from others with less power. And I think he's spot on right.

We have seen a complete merger of corporate and political America. Politicians on both sides of the aisle serve at the pleasure of the capitalist elite because they need their money to stay in power. Corporations enjoy all the rights of citizenship save voting, but who needs to actually cast a ballot when you can buy the election.

And what the corpocracy, as I call it, is doing with all that power is continuing to reshuffle the deck of economic opportunity to insure that wealth and income continue to polarize. It's a process they undertake in the name of tax cuts for the middle class (which aren't), deregulation (which hurts society as a whole), and the outright transfer of wealth and property (including millions of acres of taxpayer-owned land) from taxpayers to shareholders (the 1%).

I know because I was part of it. As a former CEO and member of four corporate boards I had a front row seat from the 1970s on. The simplest analogy is that the gamblers rose up and took control of the casinos and the government had their backs in a kind of quid pro quo, all having to do with money.

They made it stick because they turned corporate management into the ultimate capitalists. The people who used to manage companies and employees are now laser focused on managing the companies' stock price and enhancing their own wealth. Corporate executives, in a word, became capitalists, not businessmen and women, giving the foxes unfettered control of the hen house.

They got to that position through a combination of greed -- both corporate management's and that of shareholder activists -- but were enabled and empowered by Washington. Beginning in the 1970s the Justice Department antitrust division, the Labor Department, the EPA, and other institutions assigned the responsibility to avoid the concentration of power that Adam Smith warned us about, and to protect labor and the environment, were all gutted and stripped of power.

They blamed it on globalism, but that was the result, not the cause. Gone are the days of any corporate sense of responsibility to the employees, the collective good, or the communities in which they operate and whose many services they enjoy. It is the corporate and financial elite, and they are now one and the same, who have defined the "me" world in which we now live.

And the process continues: "The ruling corporate kleptocrats are political arsonists. They are carting cans of gasoline into government agencies, the courts, the White House, and Congress to burn down any structure or program that promotes the common good." And he's right. And Trump is carrying those cans.

Ironically, Trump's base, who have been most marginalized by the corpocracy, are the ones who put him there to continue the gutting. But Hedges has an explanation for that. "In short, when you are marginalized and rejected by society, life often has little meaning. There arises a yearning among the disempowered to become as omnipotent as the gods. The impossibility of omnipotence leads to its dark alternative -- destroying like the gods." (Reference to Ernest Becker's The Denial of Death.)

The economic history and understanding of economic theory here is rich and detailed. Capitalism, as Marx and others pointed out, creates great wealth in the beginning but is doomed to failure due to its inability to continue to find sources of growth and to manage inequities in wealth creation. And you don't have to be a socialist to see that this is true. Capitalism must be managed. And our government is currently making no attempt to do so. It is, in fact, dynamiting the institutions responsible for doing so.

All told, this is a very good book. If you don't like reading about underbellies (I found the chapter devoted to sadism personally unsettling, being the father of two daughters.) you will find some of it pretty dark. Having said that, however, the writing is very good and Hedges never wallows in the darkness. He's clearly not selling the underbelly; he's trying to give it definition.

I did think that some of the chapters might have been broken down into different sub-chapters and there is a lack of continuity in some places. All told, however, I do recommend the book. There is no denying the fundamental thesis.

The problem is, however, we're all blaming it on the proverbial 'other guy.' Perhaps this book will help us to understand the real culprit -- the capitalist collective. "The merging of the self with the capitalist collective has robbed us of our agency, creativity, capacity for self-reflection, and moral autonomy." True, indeed.


S. Ferguson , September 1, 2018

"Justice is a manifestation of Love..."

The inimitable Hedges is not only a saint with a penetrating intelligence, but also a man of superior eloquence with the power to pull you into his descriptions of the collapse of western civilization. Hedges says that the new American Capitalism no longer produces products -- rather America produces escapist fantasies. I found this paragraph [page 233] particularly relevant. The act of being dedicated to the 'greater good' has in itself become dangerous.

Chris Hedges: "We do not become autonomous and free human beings by building pathetic, tiny monuments to ourselves. It is through self-sacrifice and humility that we affirm the sanctity of others and the sanctity of ourselves. Those who fight against cultural malice have discovered that life is measured by infinitesimal and often unacknowledged acts of solidarity and kindness. These acts of kindness spin outward to connect our atomized and alienated souls to others. The good draws to it the good. This belief -- held although we may never see empirical proof -- is profoundly transformative. But know this: when these acts are carried out on behalf of the oppressed and the demonized, when compassion defines the core of our lives, when we understand that justice is a manifestation of love, we are marginalized and condemned by our sociopathic elites."

Amazon Customer , September 7, 2018
Great (Recycled) Hedges Rants

If you've never read Hedges - get it now. If you've read him before - there's nothing new here.

Chris Hedges is a writer who has a knack for seeing the big picture and connecting the dots. A chronic pessimist in the best sense, a bitter prophet warning us of the last days of the decaying empire, his page-turning prose carving through the morass of today's mania and derangement. For that, he's in the company somewhere between Cornel West and Morris Berman (the later, whose book Why America Failed, is better than this. If you're familiar with Hedges, but not Morris Berman, go find Berman instead).

I give this three stars only because there isn't much new here if you're familiar with his material. I felt this book to be an update of Empire of Illusion, punched up by old articles from his weekly column at Truthdig. Aside from the introductory chapter, he revisits themes of sadism, the decline of literacy, of labor, of democratic institutions, and so on, which are too familiar. The pages and pages detailing the BDSM craze I felt were excessive in their prurient voyeurism which journalistic approaches can fall into. Not saying he's wrong at all, but this tone could put off some readers, erring on excessive preacherly seminarian virtue signaling as he points out the sins of the world and shouts - "Look! Look at what we've done!"

swisher , August 21, 2018
I'd give a million stars if possible

Heartbreaking to read but so true. In our "truth is not truth" era Mr. Hedges once again writes the sad and shocking obituary for American Democracy and sounds the prophetic alarm to those revelers while Rome burns. All empires come and go but I never thought I'd be a witness to one. Something sick and traitorous has infected the soul of America and I fear it's going to be some demented combination of the worst elements in 1984 and Brave Bew World. The most important work currently published but will anyone listen? Will anything change?

ChrisD , September 5, 2018
Well worth reading - an important perspective

The author is honest and intelligent. When you take a detailed look at reality it can seem harsh.

Don't shoot the messenger who has brought bad news. We need to know the truth. Read, listen, learn. Engage in positive actions to improve the situation.
Chris has given us a wake-up call.

[May 11, 2019] A Texan Looks At Lyndon: A Study In Illegitimate Power

May 31, 2003 | www.amazon.com

Kurt Harding

A Devastating Diatribe, May 31, 2003

It would be an understatement to say that author Haley does not like Lyndon Baines Johnson. And despite the fact that his book is an unrelenting tirade against all things Lyndon, it provides a useful service in reminding the reader of how Johnson trampled and double-crossed friend and foe alike in his single-minded lust for power.

I am fairly conservative politically, but I am open-minded enough to recognize and oppose corruption whether practiced by liberals or conservatives. In my lifetime, Johnson, Nixon, and Clinton have been shining examples of the worst impulses in American presidential politics in which greed and lust for either power or money ended up overshadowing any of their real achievements.

Haley shows that Johnson was a man of few real principles, neither liberal nor conservative, but rather a man who usually always wanted to know which way the wind was blowing before taking a stand on any important issue. Johnson was a man who used all his powers of persuasion and veiled threats to get what he wanted and woe unto anyone who stood in his way.

He was a man who knew and used the old adage "It's not what you know, but who you know" to Machiavellian extremes.

But he was also a man of sometimes great political courage who would rarely give an inch once he took a stand. He hated those who opposed him, nursed resentments, and wreaked revenge on those who crossed him in the least as most of his enemies and many of his friends learned to their sorrow. From the earliest days, he was involved with corrupt Texas politicians from the local to the state level and swam in the seas of corporate corruption with the likes of the infamous swindler Billy Sol Estes and others of his stripe.

Admittedly, the conservatism of the author is the conservatism of a bygone age and the reader will recognize that the book is meant to be a partisan attack on Johnson. Some of the attacks on Johnson are made solely for political reasons as Johnson was clever enough to outmaneuver Haley's ideological brothers and sisters. But Johnson surrounded himself with enough scummy characters and got involved in so many underhanded political AND business deals that he deserves the rough treatment given him in Haley's devastating diatribe.

No matter your political leanings, your eyes will be opened when you read A Texan Looks At Lyndon. The book is well-written and often riveting in its allegations and revelations, but it loses one star for occasional hysteria. If US or Texas politics interests you, then I highly recommend this.

Randall Ivey

You have been warned, July 31, 2000

Haley wrote this book (and published it himself) in 1964 basically as a campaign tract for Barry Goldwater. In the intervening years it has become a classic of its kind, a philippic, to use M.E. Bradford's term, tracing the illegitimate rise to power of Lyndon Baines Johnson.

If you're politically naive, this book will grown hair on your chest. It's an unblinking, fearless portrait of Johnson's wheeling dealing and underhanded methods to achieve the power, prestige, and money he craved all his life.

Haley names all the names and lays out facts and figures for the reader to make up his mind. And the reader winds up shaking his head in utter astonishment. The best part of the book is that detailing Johnson's eventual election to the U.S. Senate in a contest with former Gov. Coke Stevenson.

The election was clearly Stevenson's, but through the machinations of George Parr, the notorious Duke of Duval County, the results were turned around in LBJ's favor. Investigators later found that among those voting in the primary were people who didn't live in the county anymore and people who weren't alive at all. But the results stood.

(An interesting and amusing aside: when Haley ran for Texas governor in 1956, he approached Parr and said, "I'm Evetts Haley. I'm running for governor, and if I win, it will be my privilege to put you in jail."

Parr's reply: "I believe you will." Parr, the Artful Dodger of Texas politics for years, eventually killed himself.)

At times the book grows tiresome, especially in the Bobby Baker and Billie Sol Estes scandals, where Haley turns a virtual torrent of names and numbers on the reader as to be sometimes confusing.

[Apr 23, 2019] The Secret Team The CIA and Its Allies in Control of the United States and the World by L. Fletcher Prouty

Notable quotes:
"... The CIA is the center of a vast mechanism that specializes in Covert Operations ... or as Allen Dulles used to call it, "Peacetime Operations." ..."
"... the CIA is the willing tool of a higher level Secret Team, or High Cabal, that usually includes representatives of the CIA and other instrumentalities of the government, certain cells of the business and professional world and, almost always, foreign participation. It is this Secret Team, its allies, and its method of operation that are the principal subjects of this book. ..."
"... vast intergovernmental undercover infrastructure and its direct relationship with great private industries, mutual funds and investment houses, universities, and the news media, including foreign and domestic publishing houses. The Secret Team has very close affiliations with elements of power in more than three-score foreign countries and is able when it chooses to topple governments, to create governments, and to influence governments almost anywhere in the world. ..."
"... the power of the Team is enhanced by the "cult of the gun" and by its sometimes brutal and always arbitrary anti-Communist flag waving, even when real Communism had nothing to do with the matter at hand. ..."
"... To be a member, you don't question, you don't ask; it's "Get on the Team" or else. One of its most powerful weapons in the most political and powerful capitals of the world is that of exclusion. To be denied the "need to know" status, like being a member of the Team, even though one may have all the necessary clearances, is to be totally blackballed and eliminated from further participation. Politically, if you are cut from the Team and from its insider's knowledge, you are dead. In many ways and by many criteria the Secret Team is the inner sanctum of a new religious order. ..."
"... At the heart of the Team, of course, arc a handful of top executives of the CIA and of the National Security Council (NSC), most notably the chief White House adviser to the President on foreign policy affairs. ..."
"... It is often quite difficult to tell exactly who many of these men really are, because some may wear a uniform and the rank of general and really be with the CIA and others may be as inconspicuous as the executive assistant to some Cabinet officer's chief deputy. ..."
"... even more damaging to the coherent conduct of foreign and military affairs, it is a bewildering collection of semi-permanent or temporarily assembled action committees and networks that respond pretty much ad hoc to specific troubles and to flash-intelligence data inputs from various parts of the world, sometimes in ways that duplicate the activities of regular American missions, sometimes in ways that undermine those activities, and very often in ways that interfere with and muddle them. ..."
"... This report is a prime example of how the Secret Team, which has gained so much control over the vital foreign and political activities of this government, functions. ..."
"... Although even in his time he had seen the beginning of the move of the CIA into covert activities, there can be little doubt that the "diversion" to which he made reference was not one that he would have attributed to himself or to any other President. Rather, the fact that the CIA had gone into clandestine operations and had been "injected into peacetime cloak-and-dagger operations," and "has been so much removed from its intended role" was more properly attributable to the growing and secret pressures of some other power source. As he said, the CIA had become "a symbol of sinister and mysterious foreign intrigue." ..."
Apr 23, 2019 | www.amazon.com

I was the first author to point out that the CIA's most important "Cover Story" is that of an "Intelligence" agency. Of course the CIA does make use of "intelligence" and "intelligence gathering," but that is largely a front for its primary interest, "Fun and Games." The CIA is the center of a vast mechanism that specializes in Covert Operations ... or as Allen Dulles used to call it, "Peacetime Operations."

In this sense, the CIA is the willing tool of a higher level Secret Team, or High Cabal, that usually includes representatives of the CIA and other instrumentalities of the government, certain cells of the business and professional world and, almost always, foreign participation. It is this Secret Team, its allies, and its method of operation that are the principal subjects of this book.

It must be made clear that at the heart of Covert Operations is the denial by the "operator," i.e. the U.S. Government, of the existence of national sovereignty. The Covert operator can, and does, make the world his playground ... including the U.S.A. Today, early 1990, the most important events of this century are taking place with the ending of the "Cold War" era, and the beginning of the new age of "One World" under the control of businessmen and their lawyers, rather than the threat of military power. This scenario for change has been brought about by a series of Secret Team operations skillfully orchestrated while the contrived hostilities of the Cold War were at their zenith.

... ... ...

We may wish to note that in a book "Gentleman Spy, the Life of Allen Dulles" the author, Peter Grose cites Allen Dulles response to an invitation to the luncheon table from Hoover's Secretary of State, Henry L. Stimson. Allen Dulles assured his partners in the Sullivan & Cromwell law firm, "Let it be known quietly that I am a lawyer and not a diplomat." He could not have made a more characteristic and truthful statement about himself. He always made it clear that he did not "plan" his work, he was always the "lawyer" who carried out the orders of his client whether the President of the United States, or the President of the local bank.

The Secret Team (ST) being described herein consists of securitycleared individuals in and out of government who receive secret intelligence data gathered by the CIA and the National Security Agency (NSA) and who react to those data, when it seems appropriate to them, wide paramilitary plans and activities, e.g. training and "advising" -- a not exactly impenetrable euphemism for such things as leading into battle and actual combat -- Laotian tribal troops, Tibetan rebel horsemen, or Jordanian elite Palace Guards.

Membership on the Team, granted on a "need-to-know" basis, varies with the nature and location of the problems that come to its attention, and its origins derive from that sometimes elite band of men who served with the World War II Office of Strategic Services (OSS) under the father of them all, General "Wild Bill" William J. Donovan, and in the old CIA.

The power of the team derives from its vast intergovernmental undercover infrastructure and its direct relationship with great private industries, mutual funds and investment houses, universities, and the news media, including foreign and domestic publishing houses. The Secret Team has very close affiliations with elements of power in more than three-score foreign countries and is able when it chooses to topple governments, to create governments, and to influence governments almost anywhere in the world.

Whether or not the Secret Team had anything whatsoever to do with the deaths of Rafael Trujillo, Ngo Dinh Diem, Ngo Dinh Nhu, Dag Hammarskjold, John F. Kennedy, Robert F. Kennedy, Martin Luther King, and others may never be revealed, but what is known is that the power of the Team is enhanced by the "cult of the gun" and by its sometimes brutal and always arbitrary anti-Communist flag waving, even when real Communism had nothing to do with the matter at hand.

The Secret Team docs not like criticism, investigation, or his- tory and is always prone to see the world as divided into but two camps -- "Them" and "Us." Sometimes the distinction may be as little as one dot, as in "So. Viets" and "Soviets," the So. Viets being our friends in Indochina, and the Soviets being the enemy of that period. To be a member, you don't question, you don't ask; it's "Get on the Team" or else. One of its most powerful weapons in the most political and powerful capitals of the world is that of exclusion. To be denied the "need to know" status, like being a member of the Team, even though one may have all the necessary clearances, is to be totally blackballed and eliminated from further participation. Politically, if you are cut from the Team and from its insider's knowledge, you are dead. In many ways and by many criteria the Secret Team is the inner sanctum of a new religious order.

At the heart of the Team, of course, arc a handful of top executives of the CIA and of the National Security Council (NSC), most notably the chief White House adviser to the President on foreign policy affairs. Around them revolves a sort of inner ring of Presidential officials, civilians, and military men from the Pentagon, and career professionals of the intelligence community. It is often quite difficult to tell exactly who many of these men really are, because some may wear a uniform and the rank of general and really be with the CIA and others may be as inconspicuous as the executive assistant to some Cabinet officer's chief deputy.

Out beyond this ring is an extensive and intricate network of government officials with responsibility for, or expertise in, some specific field that touches on national security or foreign affairs: "Think Tank" analysts, businessmen who travel a lot or whose businesses (e.g., import-export or cargo airline operations) are useful, academic experts in this or that technical subject or geographic region, and quite importantly, alumni of the intelligence community -- a service from which there are no unconditional resignations. All true members of the Team remain in the power center whether in office with the incumbent administration or out of office with the hard-core set. They simply rotate to and from official jobs and the business world or the pleasant haven of academe.

Thus, the Secret Team is not a clandestine super-planning-board or super-general-staff. But even more damaging to the coherent conduct of foreign and military affairs, it is a bewildering collection of semi-permanent or temporarily assembled action committees and networks that respond pretty much ad hoc to specific troubles and to flash-intelligence data inputs from various parts of the world, sometimes in ways that duplicate the activities of regular American missions, sometimes in ways that undermine those activities, and very often in ways that interfere with and muddle them. At no time did the powerful and deft hand of the Secret Team evidence more catalytic influence than in the events of those final ninety days of 1963, which the "Pentagon Papers" were supposed to have exposed. The New York Times shocked the world on Sunday, June 13,1971, with the publication of the first elements of the Pentagon Papers.

The first document the Times selected to print was a trip report on the situation in Saigon, credited to the Secretary of Defense, Robert S. McNamara, and dated December 21,1963. This was the first such report on the situation in Indochina to be submitted to President Lyndon B. Johnson. It came less than thirty days after the assassination of President John F. Kennedy and less than sixty days after the assassinations of President Ngo Dinh Diem of South Vietnam and his brother and counselor Ngo Dinh Nhu.

Whether from some inner wisdom or real prescience or merely simple random selection, the Times chose to publish first from among the three thousand pages of analysis and tour thousand pages of official documents that had come into its hands that report which may stand out in history as one of the key documents affecting national policy in the past quarter-century -- not so much for what it said as for what it signified. This report is a prime example of how the Secret Team, which has gained so much control over the vital foreign and political activities of this government, functions.

... ... ...

...President Harry S. Truman, observing the turn of events since the death of President Kennedy, and pondering developments since his Administration, wrote for the Washington Post a column also datelined December 21, 1963:

For some time I have been disturbed by the way the CIA has been diverted from its original assignment. It has become an operational and at times a policy-making arm of the government.... I never had any thought that when I set up the CIA that it would be injected into peacetime cloak-and-dagger operations.

Some of the complications and embarrassment that I think we have experienced arc in part attributable to the fact that this quiet intelligence arm of the President has been so removed from its intended role that it is being interpreted as a symbol of sinister and mysterious foreign intrigue and a subject for cold war enemy propaganda.

Truman was disturbed by the events of the past ninety days, those ominous days of October, November, and December 1963. Men all over the world were disturbed by those events. Few men, however could have judged them with more wisdom and experience than Harry S. Truman, for it was he who, in late 1947, had signed unto law the National Security Act. This Act, in addition to establishing the Department of Defense (DOD) with a single Secretary at its head and with three equal and independent services -- the Army, Navy, and Air Force -- also provided for a National Security Council and the Central Intelligence Agency. And during those historic and sometimes tragic sixteen years since the Act had become law, he had witnessed changes that disturbed him, as he saw that the CIA "had been diverted" from the original assignment that he and the legislators who drafted the Act had so carefully planned.

Although even in his time he had seen the beginning of the move of the CIA into covert activities, there can be little doubt that the "diversion" to which he made reference was not one that he would have attributed to himself or to any other President. Rather, the fact that the CIA had gone into clandestine operations and had been "injected into peacetime cloak-and-dagger operations," and "has been so much removed from its intended role" was more properly attributable to the growing and secret pressures of some other power source. As he said, the CIA had become "a symbol of sinister and mysterious foreign intrigue."


5.0 out of 5 stars XXX

The New Corporate (non-State acting) Privatized One World Order December 4, 2012

While we sit stunned into complete disbelief and silence trying to make sense of, understand, and decode the strongly suspected connections between the most curious political and military events of our times, this author, Colonel, L. Fletcher Prouty, in this book, "The Secret Team," has already decoded everything for us. From the JFK assassination, Watergate, the Iran-Contra Affair, the Gulf of Tonkin incident, repeated bank bust-outs (like BCCI and Silverado), the cocaine connection from Mena Arkansas to Nicaragua, the "crack" cocaine explosion in America's inner cities, the recent housing crash, and the general Wall Street sponsored financial meltdown, and now even from the wildest recesses of our collective imagination (dare I say it, maybe even 911?), Colonel Prouty, the fabled Mr. "X" in the movie "JFK," has the bureaucratic structure of all the answers here.

What Colonel Prouty tells us is that right before our own eyes, we are experiencing a paradigm shift in international relations and world affairs, one that has quietly moved us from the "old order" where the sovereign nation and its armies and national ideologies once sat at the center of world events and predominated, into a new "One World business run corporate, privatized global order," in which "the corporate powers that be" sit on the throne in the clock tower; and where, as a result of their machinations, true national sovereignty has seeped away to the point that we say safely say, it no longer exists.

The good Colonel tells us that the most important events of this century are taking place right before our eyes, as the Cold War era has already given way to a new age of "One World" under the control of businessmen and their hired guns, their lawyers -- rather than under the threat of military power and ideological differences. In this new, completely "privatized world order," big business, big lawyers, big bankers, big politicians, big lobbyists, and even bigger money-men, run and rule the entire world from behind a national security screen inaccessible to the average citizen. It is this paradigm shift, and the wall of secrecy that has brought us the "Secret Team" and the series of strange inexplicable events that it has skillfully orchestrated, and that keep recurring from time to time both within the U.S. and throughout the world.

This new bureaucratic entity is called a "Secret Team" for good reasons: because like any team, it does not create its own game plan, its own rules, or its own reality. The team plays for a coach and an owner. It is the coach and the owner that writes the scripts, creates and "calls" the plays. The drama of reality that we see on the international screen is a creation of the "Power elite, as it is executed by the "secret Team." The power of the team comes from its vast intergovernmental undercover infrastructure and its direct relationship with private industries, the military, mutual funds, and investment houses, universities, and the news media, including foreign and domestic publishing houses. The beauty of the "Secret team," is that it is not a clandestine super-planning-board, or super-general staff like as is frequently attributed to the Bilderburg Group, or the Trilateral Commission, but is a bewildering collection of ad hoc and semi-permanent action committees and networks that can come into being and then dissolve as specific needs troubles and flash-points dictate. It can create, influence or topple governments around the globe at the behest and on the whim of its coaches, "the Power Elite."

As the Sociologist C. Wright Mills told us nearly a half century ago, the members of the "Power Elite," operate beyond national borders, beyond the reach of the public, and have no national loyalties -- or even return addresses. They operate in the shadows and run the world by remote control and by making us completely dependent upon them and their hidden machinations. Invisibly, they maneuver and jockey to control every aspect of our lives and the infrastructure and markets upon which we depend for our survival: The most important and essential among them being our ability to produce and distribute our own food, water, and energy. As a result of this dependency, and despite mythology to the contrary, Colonel Prouty tells us that we are becoming the most dependent society that has ever lived. And the future viability of an infrastructure that is not controlled and manipulated by this "global power Elite," is diminishing to the point of non-existence.

With climate changes and terrorism already causing serious disruptions in the normal flow of our lives, governments are becoming less and less able to serve as the people's protector of last resort. Already, one of the politicians who ran for President of the United States in its most recent election, Governor Mitt Romney, suggested that FEMA be turned over to a private run firm? And all of the agencies of government that he did not suggest be privatized (or that have not already been privatized), except for the military, he suggested be abolished. As well, we also see the concomitant rise of the Backwaters' of the world, a private firm that has already begun to take over a lion's share of the responsibilities of our volunteer military. Likewise, our prisons, healthcare system and schools are also being privatized, and everything else is being "outsourced" to the lowest bidder on the global labor market. The book however is not just about international politics or international economics, per se, but is also about the primary bureaucratic instrumentality through which the "Power Elite" operates. This instrumentality, as noted above, is called "the Secret Team."

How does Colonel L. Fletcher Prouty know about the "Secret Team:" because he used to be one of its Pentagon operational managers. I believe then that out of prudence, when the man who oversaw management of and liaised with "the Secret team" for nine years as a Pentagon as an Air Force Colonel, (and who incidentally was also sent on a wild goose chase to Antarctica in order to get him out of the country, days before the JFK assassination), tells us that something is wrong in Denmark, I believe it is high time to listen up. In a chilling narrative, Colonel Prouty relates to us how he found out about the assassination of JFK. It was during a stopover in New Zealand on his return from the wild goose chase his superiors had sent him on to get him out of the way. Hours BEFORE the assassination had even occurred, somehow the New Zealand press already had the pre-planned talking points on Lee Harvey Oswald. Somehow they mistakenly deployed them prematurely, reporting well in advance of the assassination itself, that Oswald was JFK's lone assassin? How could such a thing happen unless there was a very high level conspiracy?

The Secret team, according to Prouty consists of a bunch of renegade CIA intelligence operatives that are signed up for life and operate under the full protection and pay of the "Power Elite," itself a cabal of wealthy men with interlocking interests beholden only to their own hunger for power, profit and greed. The "Power Elite" relies upon this covert team of highly trained specialists to get things done without questions being asked and without moral squeamishness.

Operating outside the normal parameters of political authorization, morality, direction, and law, and hiding behind a wall shielded by national security secrecy, very much like the mafia, the "Secret Team" always gets the job done. They are allowed to ply their immoral trade with both impunity and with legal immunity. In short, in the modern era, in the new "One WorldCorporate Order," they have proven again and again that, at worse they are lawless, and at best, they are a law unto themselves. The members of the "Secret Team" have become the new Jack-booted foot soldiers we see trampling over our dying democracy. As we move deeper and deeper into the uncharted realms of the new Corporate run "One World Order," "we the people" have a lot of questions we must ask ourselves if the democracy we once knew is to endure.

The climax of the book appears here in chapter 22 ( entitled "Camelot.") It is a beautifully crafted object lesson for the future of what remains of our democracy. It is a narrative summary of how JFK tried but failed to deal with the emerging paradigm shift in power from the Executive branch of the UGS, to the CIA and the "Secret Team," that is to say, from a system of duly elected Representatives to one dictated by the whims of the "Power Elite" through their "Secret Team." JFK's assassination is just the most dramatic consequence of how our then young President failed to save the USG from usurpation of its power by a cabal of anonymous evil men intent on ruling the world. Colonel Prouty's story ends somewhat as follows.

The Bay of Pigs operation was the seminal event in the clandestine transfer of power from the "normal government" to the CIA's Secret Team." It was done primarily via the thinly transparent interface of the military -- playing a dual role as both military officers reporting to their Commander in Chief, and at the same time as undercover "clandestine operatives" reporting (behind the President's back) to the CIA (and of course through it, to the "Power Elite."). In the book, there is little question where their split loyalties lay.

The key ruse that provided the glue that made this high level "grifter-like scam" (with the U.S. President, as its "mark)" work to perfection, was the words "anti-Communist counterinsurgency." Put to skilful use in hands of trained Specialists, these words had a powerful and purposeful dual meaning. They meant one thing to "clandestine insider members of the "Secret Team," and quite another to "no need to know outsiders" like the American public (and in this case the whole USG, including the Commander in Chief, the President of the U.S. JFK himself). This willful ambiguity in terminology and the duality in the roles of those involved does most of the heavy lifting in the drama played out by the "insiders" and that resulted in the usurpation and the shift of power from the Presidency to the CIA.

The "Bay of Pigs operation"proved to be the defining, the seminal and pivotal case in point. It began as a small clandestine "anti-Communist counterinsurgency" operation run by the CIA (as also was the case with Iran, Guatemala, Nicaragua, Indonesia, Laos, Cambodia, Granada, Angola, and Santo Domingo), ostensibly under the oversight of the "USG," but in fact ended up as a huge CIA-run military failure, one minus the requisite oversight from the US President. The devil of how this happened lies in the slimy details that went on behind the scenes and that are skillfully unveiled in this book. They are details that the reader can also get from a careful reading between the lines of "The Pentagon Papers."

As the Bay of Pigs Operation slowly morphed from a small-scale USG run operation "with oversight," into a huge, expensive and poorly run CIA operation without any oversight whatsoever, the rules of the game also changed. They changed from being about U.S. security, to being about the greed, power and profits of the "Power Elite, as those objectives were implemented through the "Secret Team." The key to the "Power Elite" getting what they wanted was always accomplished by stoking the ideological fires up to an international boiling point, so that more and more military hardware could be produced, bought and sold.

Likewise, the roles of the primary players also morphed and changed -- from "clandestine operators" in military uniforms, to "military operators" reporting to their CIA handlers, and thus to the "Power Elite." The executive branch (the ostensible oversight body of the government) was none the wiser, since it was not yet aware that it was "being played" by the CIA and thus did not yet know it was being treated in the same way the public is normally treated: as an "excluded outsider" lacking the required "need to know."

Through this bureaucratic sleigh of hand, the partial control and power the USG normally exercised in its oversight role had been covertly usurped, as the military operators (and even members of the Presidents own staff proved to be "insiders," i.e., members of the "Secret Team," "playing" the President like a bass fiddle as he and his team became the "marks" in an insider's "con game" in which power and control of the USG was at stake.

When JFK finally "wised up," it was too late. By then the train had already left the station, with the CIA firmly in the driver's seat. Since JFK era, U.S. foreign policy has become a clear case of the CIA tail wagging the USG dog. And the best proof of the evil intentions of the "Secret Team" calling the shots within the CIA is that no sooner than the Bay of Pigs literally blew up in a spectacular and embarrassing failure did the CIA then put the wheels back in motion to duplicate, expand and even generalize this failed bureaucratic formulate in Vietnam.

But this time JFK was ready for them and issued NSM-55 and NSM-57, both of which were decision directives designed to put the brakes on the CIA and return the usurped power back to the military where the President was the Commander in Chief. But the CIA was already two steps ahead of JFK. His own staff had been so compromised that he had nowhere to turn? He was penetrated and thus effectively checkmated by an agency of his own government? The more he fought back, the more he lost ground, and the more his back was up against the wall. By the time November, 22, 1963 came around, JFK literally had no bureaucratic friends and nowhere to turn?

I only regret that an earlier edition of this book had been lying around unread in my library for more than a decade. Five Stars.

Stephen Courts , August 7, 2012

Secret Team (CIA) By Colonel Fletcher Prouty

Though this book is now over 40 years old, I found the information very relevant and 100% trustworthy from one of America's true Patriots. Colonel Prouty served his country for decades as a pilot and as an integral part of the Department of Defense and CIA. Though for nine years Colonel Prouty was the liason between the Air Force and the CIA's clandestine affairs, he is able to reveal confidential information that would typically be classified "Top Secret", because Colonel Prouty did not work for the CIA and therefore did not have to sign a confidentiality agreement with the nefarious CIA.

What is fascinating about Colonel Prouty is that he was everywhere throughout his career. He watched world affairs as they unfolded, meeting the most influencial leaders of his time. From FDR, Stalin, Churchill, Ike and every general and admiral in our military. For the nine years from 1954 to 1963, he was involved as the go to guy for the military leaders and the president, including both Ike and JFK. In other words, Colonel Prouty writes from personal and direct experience.

Now the meat of the book is about the creation and abuses of the 1947 created CIA. From the end of World War Two until the mid 1970's, the CIA abused its primary responsibility of intelligence gathering to literally unchecked clandestine and covert upheavels in every part of the world. The CIA, particularly under Allen Dulles, created one coup d'etat after another. The reader will realize that from 1945 until the Marines reached the shores of Viet Nam in 1965, every piece of skulldruggery in Viet Nam was done by the CIA. The CIA had infiltrated the entire government, from the Department of Defense to the Department of State. Many people would be shocked to know that what passed as Defense activity was acually generals and admirals, wearing their uniforms and working for the CIA. Whether it was advising the President, subverting Ambassadors or lying to Congress, the CIA ruled and few knew what they were really doing. Colonel Prouty tells the stories accurately of every subversive, nefarious act the CIA was involved in. One example in particular stands out. It was Ike's goal at the end of his 2nd term as president to have a peace conference with the USSR, one to sign a peace treaty and end the cold war. In direct violation of the presidents specific instructions not to fly U-2 flights prior to the conference in June of 1960, the CIA flew the ill fated Gary Powers flight that guaranteed that the conference would go forth. This was a most important conference that could have brought nuclear peace accords decades before they were eventually signed. Dulles and his henchmen deliberately insured that Gary Powers not only violated the order not to fly these observations flights, they insured that it would be downed by sabotaging the flight and thus force Ike to either admit he knew or fire the bastards who embarrassed him. Ike chose to take responsibility and thus the peace talks were cancelled. There was also another flight in 1958 that was downed in the Soviet Union.

Most Americans would be shocked to know the CIA has their own private air lines, Air America. This is no small air lines. Had Colonel Prouty written this book later, he could connect the CIA with the massive drug smuggling that has devastated American cities. They use the proceeds of this smuggling to finance their illicit involvement of other sovereign countries.

Bottom line is this is an important book as is his 1993 JFK & Viet Nam. Colonel Prouty was a significant advisor to Oliver Stone and his masterpiece, JFK. I am currently finishing the rereading of said book. If you want to know who has controled our foreign policy (against the charter that created this monstrosity) since the mid 1940's, this is an excellent book to begin with. It is my personal opinion, having read many books on the CIA, that their main function is to serve the multi-national corportations and the bankers that exploit the less developed countries around the world and to insure that there will never be peace. There will not be a World War Three, because nuclear weapons would most likely be used and earth as we know it will cease to exist. Therefore, limited, no win conflicts will continually persist. Beginning with Korea, to Viet Nam, to Iraq to Afganistan. The irony is we are wasting our human resources and our treasury to bankrupt our country while both Russia and China sit back and spend zero (USSR & Afganistan is the exception) and develope the kind of infrastruture and consumer goods as well as education that we should be doing.

Finally, the record of the CIA leaves a lot to be desired. There were many failures despite billions of dollars spent and the infiltration into every branch of our society, from education to media to think tanks to the military. Read this book and you will also discover the misadventure in Viet Nam that cost 58,000 plus American casualities, millions of Viet Namese, millions of service men who would never be the same after this debacle. Colonel Prouty explains this better than anyone I have yet to read. He predicted another debacle (Iraq & Afganistan) after the Viet Nam debacle. I believe Cononel Prouty passed away last decade, but he would not have been shocked by the rediculous misadventures in both of the above foremetioned countries. Think of the trillions of dollars and the bloodshed lost on a military misadventure that has no way of producing a positive outcome for the United States.

Stephen Courts
August 7, 2012

<img src="https://images-na.ssl-images-amazon.com/images/I/11bV+h26SGL._CR0,0,115,115_SX48_.jpg"> Jeff Marzano , December 17, 2014
An American Hero Reveals The Shocking Truth

This book provides a rare glimpse into the secret history and evil machinations of the CIA as it mutated from its original form between 1946 up until the time the book was published in 1973 when it had become a cancerous blight within the government.

It should not be surprising that most people never really understood the so called Vietnam War and they still don't. Even people in the American government like the Secretary Of Defense were completely confused and manipulated by the Agency as it's called.

President Kennedy was somewhat inexperienced when he first entered office. JFK thought he could handle problems in the government in the same way he handled problems during his presidential campaign. He had an informal style at first where he would just ask a friend to take care of it. This caused JFK to disregard important checks and balances which had been set up to hopefully prevent the CIA from crossing the line from being just an intelligence agency into the realm of initiating clandestine military operations.

The National Security Counsel was supposed to give direction to the CIA and then the Operations Coordination Board was supposed to verify that the CIA had done what they were told and only what they were told. But even before JFK got into office the Agency had taken many determined steps to undermine those controls.

JFK's informal style opened the door even wider for the Agency to circumvent whatever controls may have still been effective to put some sort of limits on their 'fun and games'. Having an informal style with them was dangerous because they were experts at getting around all sorts of rules and laws.

The Agency double crossed JFK during the Bay Of Pigs debacle. Publicly JFK took the blame for what happened but according to Fletcher it was the CIA who cancelled the air support that would have destroyed Fidel Castro's planes on the ground. As a result JFK's only options were to accept the blame or admit to the world that things were being done by the American military establishment that he wasn't even aware of. John Kennedy was a fast learner however and he stated that he would break the CIA up into a thousand tiny pieces. JFK was fed up with all of the Agency's fun and games.

Something similar happened with the Gary Powers U2 spy plane that had to land in the Soviet Union. The evil Secret Team sabotaged the U2 to derail President Eisenhower's lifelong dream of holding a worldwide peace summit. Like JFK Ike accepted the blame publicly.

Ike's only other option would have been to admit that the U2 flight was unauthorized and then fire Allan Dulles and the other leaders of the evil Secret Team. But Fletcher says Ike couldn't do this for various reasons even though Nikita Khrushchev probably realized that Eisenhower did not break his word and authorize the U2 mission.

Ike's comments about the Military Industrial Complex which he made during his farewell address turned out to be very prophetic indeed.

These examples provide the picture of an Agency that had become a law unto itself which reinterpreted whatever orders it was given to make those orders conform to their evil schemes. Fletcher provides many details in the book about how the Agency was able to circumvent laws and regulations and manipulate anyone and everyone in the government starting with the president. They did this mainly by abusing their control of secrecy but they used many other methods as well.

Secret Team leader Allan Dulles wrote a book called 'The Craft of Intelligence'. The title of this book sort of indicates the very problem Fletcher Prouty explains in his book. Dulles viewed himself as a sort of artist or craftsman who could distort information and make it appear in any form he wanted. Strangely Fletcher refers to his close personal friendship with Allan Dulles in the acknowledgements at the beginning of the book but then spends the rest of the book portraying Dulles as a sort of Joseph Goebbels figure.

Fletcher spends over 300 pages describing the metamorphosis which occurred with the CIA as it veered very far afield from what president Truman had intended when he created the Agency. Then towards the end of the book Fletcher finally reveals his shocking conclusions about what this massive abuse of power lead to.

Fletcher felt that the assassination of president Kennedy was the single most pivotal event in modern American history as far as the changes that the assassination caused.

Sadly as Fletcher points out the Vietnam War never really had any military objective. The theory was that if South Vietnam fell this would cause a domino effect and the dreaded communism monster would start gobbling up the entire world. Then when South Vietnam did fall with no domino effect the Secret Team published a group of documents called the Pentagon Papers. These documents deflected blame away from the CIA and said nobody listened to the CIA when they warned that the Vietnam situation was not winnable.

But it wouldn't matter if anyone listened to the Secret Team anyway because they always lie.

This book presents an American government in chaos during the Vietnam era. It was a government that had been high jacked by the evil Secret Team.

After the Bay Of Pigs incident Fidel Castro apparently got fed up with the CIA and America in general. Castro turned to the Soviet Union instead. This lead to the Cuban Missile Crisis. It was only in the last 10 years or so that people realized just how close the world came to an all out nuclear exchange at that time.

This was a very dangerous game master craftsman Allan Dulles and his other liars were playing. They were like kids starting fires all over the place in a big field and then just sitting back and seeing which of those fires would become an inferno as Vietnam did.

Also in recent years people have implicated Lyndon Johnson as being part of the conspiracy to assassination JFK. So LBJ was on the team also.

I'm not sure if Fletcher ever really spells out what the true motivations of the Secret Team were but he hints at it. Probably the three main reasons that people engage in criminal activity are sex, money, and revenge. Usually when crimes are committed there's a money trail somewhere. And in the case of government military spending that's a very long trail.

This is a serious book which contains many details about an approximately 25 year period that began after World War II. It is not light reading.

Watch this documentary series on the internet. The hypocrites have pulled it off the market:

The Men Who Killed Kennedy

The Men Who Killed Kennedy DVD Series - Episode List

1. "The Coup D'Etat" (25 October 1988)
2. "The Forces Of Darkness" (25 October 1988)
3. "The Cover-Up" (20 November 1991)
4. "The Patsy" (21 November 1991)
5. "The Witnesses" (21 November 1991)
6. "The Truth Shall Set You Free" (1995)

The Final Chapter episodes (internet only):

7. "The Smoking Guns" (2003)
8. "The Love Affair" (2003)
9. "The Guilty Men" (2003)

Herman , February 4, 2017
Extensive analysis of the CIA from its inception to the 1970's

The fact that this book all but disappeared when it was distributed in the 1970's tells all that the CIA did not want any of its "dirty laundry" aired in public. Prouty does an excellent (almost over the top) job of describing the rise and strategies and evolution of the CIA up through the 70's. That the Vietnam War was still controlled by the CIA at the writing of the original book also shows JFK had not gained control of the military-industrial complex. For those who are wanting to fill in more pieces of the puzzle this is an excellent source from a man who found himself in the thick of things for many years. The one shot-coming comes in the last chapter in his description of Nixon and especially LBJ not being able to control the military industrial complex either.

Consequent independent research over many years seems to show LBJ who was about to go to jail and be dropped from the 1964 ticket, knew about and helped cover up the JFK assassination and is known to have remarked: "Just get me elected and you can have your damn war".

There is also evidence Nixon and company undermined the 1968 peace talks as LBJ was trying to end the war and LBJ actually called Nixon and asked him to back off. ( Kinda like the Oct 1980 surprise by Reagan). Consequently we know from Judyth Vary Baker that Lee Oswald was the the assassin of JFK and he in fact was on the payroll of the FBI and CIA.

James E Files has confessed to being one of the shooters and E. Howard Hunt told his son, he was involved and he was CIA at the time. But no One man can possibly know everything. Given the pervasive infiltration of government, military and probably many civil institutions by the CIA, one wonders who comprises the shadow government in reality?

Boyce Hart , July 22, 2010
The Critical Sinews btw CIA and other Gov. Agencies

What does it mean when we say " the CIA did such and such an action"? Just what is the CIA, a whole or a part? Given its emphasis on compartmentalization, is it accurate to say "the CIA was heavily involved in the JFK assassination" or would it be more accurate to say parts of the CIA were? Moreover, who is the CIA, and what are the powers behind it? Also, perhaps most importantly, what were the relations between the CIA and other parts of government, and how and when did these relationships change and evolve. Were these changes done democratically or secretly. These last two questions are the essence of this book. Yes, it is true as one reviewer noted, this book could have used an editor. Some times it has the feel of a collection of speeches, but not always. So why the five instead of 4. The subject matter-- in particular the last two questions typed above-- are just too rarely mentioned and discussed. This book really helps us understand the curiously evolving nervous system of the CIA btw 1947 and 1963, as very very few other books do. It sees the inception of the CIA in 1947 as just the first step, and makes it clear that later developments were neither willed nor pre-ordained by many of the elected officials who wrote the National Security Act of 1947.

The only other book that really addresses this BETWEEN WORLD--i.e. between CIA and other government agencies is one of the Three most important books published in the last 50 years IMO. Thy Will Be Done: Nelson Rockefeller, Evangelism, and the Conquest of the Amazon In the Age of OIl by Colby and Dennett. Thy Will Be Done: The Conquest of the Amazon : Nelson Rockefeller and Evangelism in the Age of Oil

Still there is one book I recommend even more than that one. This is not the current Gold Standard merely for all current JFK research. It is far more than that; it is the Gold Standard for all US Cold War History Research. JFK and the Unspeakable: Why He Died and Why It Matters by James W. Douglass. This book is so important because it is not merely who done it but why done it. It is a book that mixes how and why of JFK and those crucial-because-contestable Cold War years 1960-63 like no other. JFK and the Unspeakable: Why He Died and Why It Matters

Luc REYNAERT , November 30, 2008
A symbol of sinister and mysterious foreign intrigue (H. Truman)

This is an extremely important book. The proof of it is that even the official copy in the Library of Congress disappeared (!). Moreover, even after his death, the author continues to be the object of a smear campaign (see internet).

His book is not less than a frontal attack on US intelligence and concomitantly on those who control it.
Its portrait of Allen Dulles, a longtime intelligence director, says it all: `I am a lawyer'; in other words, a servant. But of whom?
This book unveils the existence of a secret cabal, a Power Elite (G. William Domhoff), a `deep State' (P.D. Scott) within the US and its government as well as in about 40 host countries.
This Power Elite uses the Secret Team of top intelligence and military commanders as its long arm and protects it. Together they stand above the law and the democratic process. They get things done, whether they have the political authorization or not.
They dispose of a vast undercover political, military, intelligence, business, media and academic infrastructure, in the US as well as worldwide. They don't respect the nation State and are able to create, to influence and to topple governments in the hemisphere controlled by them.

The author gives a remarkable insight into the inner workings, the logistics, the strategies and the tactics of the intelligence agency. Its creation and history show that President H. Truman never intended to create an autonomous operational agency in the clandestine field. L.F. Prouty also gives valuable information about the U2- G. Powers incident (apparently to torpedo the US/USSR peace talks) and the Pentagon papers (an intelligence whitewash).

At the end, the author poses the all important question: `Can any President ever be strong enough really to rule?'

This book is a must read for all those interested in US history and for all those who want to understand the world we live in.

For more information on the Power Elite, I recommend the works of O. Tunander, D. Estulin, Peter Dale Scott, Carroll Quigley, Gary Allen and G. W. Domhoff.

anarchteacher , April 30, 2008
An Insider's Candid Expose' of the National Security State

As in the case of the brilliant Jules Archer volume, The Plot To Seize The White House, it is terrific to have this masterful study of the inner workings of the early CIA back in print after so many years of unavailability.

Skyhorse Publishing is to be commended in seeing to it that both of these crucial works are again available to the attentive reading public who want to know the truth concerning our dark hidden history that the government has so actively strived to keep buried.

The late Colonel L. Fletcher Prouty served as chief of special operations for the Joint Chiefs of Staff where he was in charge of the global system designed to provide military support for covert activities of the Central Intelligence Agency.

In Oliver Stone's highly acclaimed film on the assassination of President John Fitzgerald Kennedy, JFK, the mysterious character "X" portrayed by Donald Sutherland was in fact Colonel Prouty, who assisted director Stone in the production and scripting of this historical epic. Prouty had relayed the shocking information detailed in the movie to the actual New Orleans District Attorney Jim Garrison, played by Kevin Cosner, in a series of communiques.

The Secret Team was first published in 1973 during the Watergate scandal, when many Americans were first learning about the dark side of covert government, an outlaw executive branch headed by a renegade chief of state. Richard Nixon would not be the last of this foul breed.

This was years before Frank Church's Senate Committee's damning revelations of CIA misdeeds and assassination plots against foreign leaders rocked the nation.

In each chapter in his book, Prouty speaks frankly with an insiders knowledge of what he describes as the inner workings of "the Secret Team."

This prudential judgment and keen assessment of the National Security Establishment was gained from years as a behind-the-scenes seasoned professional in military intelligence working intimately with those of the highest rank in policy making and implimentation.

The important story Prouty boldly tells should be read by every reflective American.

SER , December 6, 2001
Best Book On CIA Misdeeds

The author was the liason officer between the CIA and the military during the 50's and 60's. As an air force officer (Colonel), he was excempt from taking the CIA oath of secrecy and therefore was in a position to write the book in 1973. Apparently, shortly after the book's publication, almost all copies disappeared, probably bought up by the CIA. I was lucky to find a copy, published in Taiwan (Imperial Books & Records), in a used bookstore several years ago. The author details not only how the CIA conducts its operations, but more importantly, how it manages to keep most or all of its deeds from the eyes of congress, the population and even the President, if necessary. This is the best book I've read on the secret workings of the CIA and its misdeeds during the 50' and early 60's. Not to belittle them, but The Secret Team is a far more informative book than Marchetti and Marks' The CIA And The Cult Of Intelligence....

added, Jan09:

Actually, practically ever since I posted the review, I've been wanting to write a more detailed one, but since it's now been some 20 years since I read the book, I can't remember enough details to do it justice. If I ever reread it, I'll be sure to post a better review. I frankly think my present "review" isn't much of one - and it was cut short after my reference to the Marchetti/Marks book, the linking to which was not allowed at the time.

For example, one item of considerable current interest which I remember from the book is the author's detailing of Operation Northwoods, from the early 1960's - the plan by the intelligence agencies to conduct a false flag attack against American interests and blame it on Cuba, in order to justify a war against that country.
There was a big deal made about this (deservedly, in my opinion), only four or five years ago, when the National Security Archive (an apparently independent non-governmental research institute at George Washington University) discovered the details of this proposed operation, supposedly for the first time, in declassified documents. (This was in light of the ongoing conspiratorial controversies surrounding the 9-11 events.)
Yet, author Prouty detailed Operation Northwoods in his The Secret Team, first published long ago in 1973.
This is but one detail that indicates a much-needed elaborate review of this book.

I'd like to also add (since it is now apparently allowed) that The Secret Team, among other items, is available on CD from the L. Fletcher Prouty Reference Site: http://www.prouty.org/

Finally, for readers still obsessed with the JFK assassination, I would like to recommend Final Judgment - The Missing Link in the JFK Assassination Conspiracy, by Michael Collins Piper, a book which lives up to it's title. My use of the word "obsessed" is not meant derogatorily, as I have my own bookshelf-full as testament to that particular subject, but as an inducement to read the book, which will make the big picture very clear indeed. Do yourselves the favor.

Last edit: Jan09

Michael Tozer , July 7, 2006
Great!

Colonel Prouty's book on the Secret Team should be required reading for all concerned Americans. Herein, the author, a retired Air Force Colonel and CIA insider, reveals for all to see the machinations of the Secret Team and their impact on US history in the post World War II era. This is terribly important information.

I was particularly impressed with Prouty's depiction of Eisenhower's peace initiative and how it was sabatoged by the Secret Team. Ike was preparing for his peace summit with Kruschev when Gary Powers was sent off on his fool's errand on April 30th, 1960, a date with significant occult emblematics. The capture of Powers by the Soviets effectively scuttled the Eisenhower peace plan, which would have ruined the plans of the Secret Team, for continued Cold War tension, and treasure for the merchants of venom.

The essential truths in this important book are still relevant today. Of course, the ineffectual George Walker Bush is not entirely in charge of American foreign policy in this critical time. He is certainly still being manipulated by the sucessors of the Secret Team depicted in this excellent and well written book. Any serious student of American foreign policy in the post World War II era ought to read this important book.

D. E. Tench , May 24, 2013
Conspiracy History - not Theory!

The Colonel's book contains valuable and legitimate insider information about how factions within our government have been dishonest, selfish, and ruthlessly brutal for a very long time now. He shows the reader more than one vivid picture of how our American Presidents are routinely hoodwinked and manipulated by CIA moles - covert operators who often work within the D.C. Beltway.

I only wish he had expanded on the following statement (from page 15 of the 1973 edition): "There were and are many men who are not in government who are prime movers of Secret Team activity." Perhaps he knew enough to mention their connection to and influence over the Agency, but not enough to elaborate upon it. Or perhaps he knew better than to push that topic too far if he wanted to get published. In 1973 there were no on-demand self-publishing formats like what we have available to us today.

Prouty also mentions the non-governmental elements of secrecy in Chapter 23, but it's closer to a defining of terms than an elaboration. He ends the book with a view of the Secret Team as an evolved and faceless mechanism serving the cause of anti-Communism. Today, the enemy du jour is anti-terrorism. However, I argue that secret teams are never faceless, but made up of individuals.

The Secret Team that Col. Prouty revealed was part of a larger Secret Team. My book: "Know Your Enemy: Exposing Satan's Human Army" discusses the spiritual state of secretive operators and some of what scripture reveals on the topic.

[Apr 04, 2019] Fascism A Warning by Madeleine Albright

Junk author, junk book of the butcher of Yugoslavia who would be hanged with Bill clinton by Nuremberg Tribunal for crimes against peace. Albright is not bright at all. she a female bully and that shows.
Mostly projection. And this arrogant warmonger like to exercise in Russophobia (which was the main part of the USSR which saved the world fro fascism, sacrificing around 20 million people) This book is book of denial of genocide against Iraqis and Serbian population where bombing with uranium enriched bombs doubled cancer cases.If you can pass over those facts that this book is for you.
Like Robert Kagan and other neocons Albright is waiving authoritarism dead chicken again and again. that's silly and disingenuous. authoritarism is a method of Governance used in military. It is not an ideology. Fascism is an ideology, a flavor of far right nationalism. Kind of "enhanced" by some socialist ideas far right nationalism.
The view of fascism without economic circumstances that create fascism, and first of immiseration of middle and working class and high level of unemployment is a primitive ahistorical view. Fascism is the ultimate capitalist statism acting simultaneously as the civil religion for the population also enforced by the power of the state. It has a lot of common with neoliberalism, that's why neoliberalism is sometimes called "inverted totalitarism".
In reality fascism while remaining the dictatorship of capitalists for capitalist and the national part of financial oligarchy, it like neoliberalism directed against working class fascism comes to power on the populist slogans of righting wrong by previous regime and kicking foreign capitalists and national compradors (which in Germany turned to be mostly Jewish) out.
It comes to power under the slogans of stopping the distribution of wealth up and elimination of the class of reinters -- all citizens should earn income, not get it from bond and other investments (often in reality doing completely the opposite).
While intrinsically connected and financed by a sizable part of national elite which often consist of far right military leadership, a part of financial oligarchy and large part of lower middle class (small properties) is is a protest movement which want to revenge for the humiliation and prefer military style organization of the society to democracy as more potent weapon to achieve this goal.
Like any far right movement the rise of fascism and neo-fascism is a sign of internal problem within a given society, often a threat to the state or social order.
Apr 04, 2019 | www.amazon.com

Still another noted that Fascism is often linked to people who are part of a distinct ethnic or racial group, who are under economic stress, and who feel that they are being denied rewards to which they are entitled. "It's not so much what people have." she said, "but what they think they should have -- and what they fear." Fear is why Fascism's emotional reach can extend to all levels of society. No political movement can flourish without popular support, but Fascism is as dependent on the wealthy and powerful as it is on the man or woman in the street -- on those who have much to lose and those who have nothing at all.

This insight made us think that Fascism should perhaps be viewed less as a political ideology than as a means for seizing and holding power. For example, Italy in the 1920s included self-described Fascists of the left (who advocated a dictatorship of the dispossessed), of the right (who argued for an authoritarian corporatist state), and of the center (who sought a return to absolute monarchy). The German National Socialist Party (the

Nazis) originally came together ar ound a list of demands that ca- tered to anti-Semites, anti-immigrants, and anti-capitalists but also advocated for higher old-age pensions, more educational op- portunities for the poor, an end to child labor, and improved ma- ternal health care. The Nazis were racists and, in their own minds, reformers at the same time.

If Fascism concerns itself less with specific policies than with finding a pathway to power, what about the tactics of lead- ership? My students remarked that the Fascist chiefs we remem- ber best were charismatic. Through one method or another, each established an emotional link to the crowd and, like the central figure in a cult, brought deep and often ugly feelings to the sur- face. This is how the tentacles of Fascism spread inside a democ- racy. Unlike a monarchy or a military dictatorship imposed on society from above. Fascism draws energy from men and women who are upset because of a lost war, a lost job, a memory of hu- miliation, or a sense that their country is in steep decline. The more painful the grounds for resentment, the easier it is for a Fascist leader to gam followers by dangling the prospect of re- newal or by vowing to take back what has been stolen.

Like the mobilizers of more benign movements, these secular evangelists exploit the near-universal human desire to be part of a meaningful quest. The more gifted among them have an apti- tude for spectacle -- for orchestrating mass gatherings complete with martial music, incendiary rhetoric, loud cheers, and arm-

lifting salutes. To loyalists, they offer the prize of membership in a club from which others, often the objects of ridicule, are kept out. To build fervor, Fascists tend to be aggressive, militaristic, and -- when circumstances allow -- expansionist. To secure the future, they turn schools into seminaries for true believers, striv- ing to produce "new men" and "new women" who will obey without question or pause. And, as one of my students observed, "a Fascist who launches his career by being voted into office will have a claim to legitimacy that others do not."

After climbing into a position of power, what comes next: How does a Fascist consolidate authority? Here several students piped up: "By controlling information." Added another, "And that's one reason we have so much cause to worry today." Most of us have thought of the technological revolution primarily as a means for people from different walks of life to connect with one another, trade ideas, and develop a keener understanding of why men and women act as they do -- in other words, to sharpen our perceptions of truth. That's still the case, but now we are not so sure. There is a troubling "Big Brother" angle because of the mountain of personal data being uploaded into social media. If an advertiser can use that information to home in on a consumer because of his or her individual interests, what's to stop a Fascist government from doing the same? "Suppose I go to a demonstra- tion like the Women's March," said a student, "and post a photo

on social media. My name gets added to a list and that list can end up anywhere. How do we protect ourselves against that?"

Even more disturbing is the ability shown by rogue regimes and their agents to spread lies on phony websites and Facebook. Further, technology has made it possible for extremist organiza- tions to construct echo chambers of support for conspiracy theo- ries, false narratives, and ignorant views on religion and race. This is the first rule of deception: repeated often enough, almost any statement, story, or smear can start to sound plausible. The Internet should be an ally of freedom and a gateway to knowledge; in some cases, it is neither.

Historian Robert Paxton begins one of his books by assert- ing: "Fascism was the major political innovation of the twentieth century, and the source of much of its pain." Over the years, he and other scholars have developed lists of the many moving parts that Fascism entails. Toward the end of our discussion, my class sought to articulate a comparable list.

Fascism, most of the students agreed, is an extreme form of authoritarian rule. Citizens are required to do exactly what lead- ers say they must do, nothing more, nothing less. The doctrine is linked to rabid nationalism. It also turns the traditional social contract upside down. Instead of citizens giving power to the state in exchange for the protection of their rights, power begins with the leader, and the people have no rights. Under Fascism,

the mission of citizens is to serve; the government's job is to rule.

When one talks about this subject, confusion often arises about the difference between Fascism and such related concepts as totalitarianism, dictatorship, despotism, tyranny, autocracy, and so on. As an academic, I might be tempted to wander into that thicket, but as a former diplomat, I am primarily concerned with actions, not labels. To my mind, a Fascist is someone who identifies strongly with and claims to speak for a whole nation or group, is unconcerned with the rights of others, and is willing to use whatever means are necessary -- including violence -- to achieve his or her goals. In that conception, a Fascist will likely be a tyrant, but a tyrant need not be a Fascist.

Often the difference can be seen in who is trusted with the guns. In seventeenth-century Europe, when Catholic aristocrats did battle with Protestant aristocrats, they fought over scripture but agreed not to distribute weapons to their peasants, thinking it safer to wage war with mercenary armies. Modern dictators also tend to be wary of their citizens, which is why they create royal guards and other elite security units to ensure their personal safe- ty. A Fascist, however, expects the crowd to have his back. Where kings try to settle people down, Fascists stir them up so that when the fighting begins, their foot soldiers have the will and the firepower to strike first.


petarsimic , October 21, 2018

Madeleine Albright on million Iraqis dead: "We think the price is worth It"

Hypocrisy at its worst from a lady who advocated hawkish foreign policy which included the most sustained bombing campaign since Vietnam, when, in 1998, Clinton began almost daily attacks on Iraq in the so-called no-fly zones, and made so-called regime change in Iraq official U.S. policy.

In May of 1996, 60 Minutes aired an interview with Madeleine Albright, who at the time was Clinton's U.N. ambassador. Correspondent Leslie Stahl said to Albright, in connection with the Clinton administration presiding over the most devastating regime of sanctions in history that the U.N. estimated took the lives of as many as a million Iraqis, the vast majority of them children. , "We have heard that a half-million children have died. I mean, that's more children than died in Hiroshima. And -- and, you know, is the price worth it?"

Madeleine Albright replied, "I think this is a very hard choice, but the price -- we think the price is worth it.

<img src="https://images-na.ssl-images-amazon.com/images/S/amazon-avatars-global/default._CR0,0,1024,1024_SX48_.png"> P. Bierre , June 11, 2018
Does Albright present a comprehensive enough understanding of fascism to instruct on how best to avoid it?

While I found much of the story-telling in "Fascism" engaging, I come away expecting much more of one of our nation's pre-eminent senior diplomats . In a nutshell, she has devoted a whole volume to describing the ascent of intolerant fascism and its many faces, but punted on the question "How should we thwart fascism going forward?"

Even that question leaves me a bit unsatisfied, since it is couched in double-negative syntax. The thing there is an appetite for, among the readers of this book who are looking for more than hand-wringing about neofascism, is a unifying title or phrase which captures in single-positive syntax that which Albright prefers over fascism. What would that be? And, how do we pursue it, nurture it, spread it and secure it going forward? What is it?

I think Albright would perhaps be willing to rally around "Good Government" as the theme her book skirts tangentially from the dark periphery of fascistic government. "Virtuous Government"? "Effective Government"? "Responsive Government"?

People concerned about neofascism want to know what we should be doing right now to avoid getting sidetracked into a dark alley of future history comparable to the Nazi brown shirt or Mussolini black shirt epochs. Does Albright present a comprehensive enough understanding of fascism to instruct on how best to avoid it? Or, is this just another hand-wringing exercise, a la "you'll know it when you see it", with a proactive superficiality stuck at the level of pejorative labelling of current styles of government and national leaders? If all you can say is what you don't want, then the challenge of threading the political future of the US is left unruddered. To make an analogy to driving a car, if you don't know your destination, and only can get navigational prompts such as "don't turn here" or "don't go down that street", then what are the chances of arriving at a purposive destination?

The other part of this book I find off-putting is that Albright, though having served as Secretary of State, never talks about the heavy burden of responsibility that falls on a head of state. She doesn't seem to empathize at all with the challenge of top leadership. Her perspective is that of the detached critic. For instance, in discussing President Duterte of the Philippines, she fails to paint the dire situation under which he rose to national leadership responsibility: Islamic separatists having violently taken over the entire city of Marawi, nor the ubiquitous spread of drug cartel power to the level where control over law enforcement was already ceded to the gangs in many places...entire islands and city neighborhoods run by mafia organizations. It's easy to sit back and criticize Duterte's unleashing of vigilante justice -- What was Mrs. Albright's better alternative to regain ground from vicious, well-armed criminal organizations? The distancing from leadership responsibility makes Albright's treatment of the Philippines twin crises of gang-rule and Islamist revolutionaries seem like so much academic navel-gazing....OK for an undergrad course at Georgetown maybe, but unworthy of someone who served in a position of high responsibility. Duterte is liked in the Philippines. What he did snapped back the power of the cartels, and returned a deserved sense of security to average Philippinos (at least those not involved with narcotics). Is that not good government, given the horrendous circumstances Duterte came up to deal with? What lack of responsibility in former Philippine leadership allowed things to get so out of control? Is it possible that Democrats and liberals are afraid to be tough, when toughness is what is needed? I'd much rather read an account from an average Philippino about the positive impacts of the vigilante campaign, than listen of Madame Secretary sermonizing out of context about Duterte. OK, he's not your idea of a nice guy. Would you rather sit back, prattle on about the rule of law and due process while Islamic terrorists wrest control over where you live? Would you prefer the leadership of a drug cartel boss to Duterte?

My critique is offered in a constructive manner. I would certainly encourage Albright (or anyone!) to write a book in a positive voice about what it's going to take to have good national government in the US going forward, and to help spread such abundance globally. I would define "good" as the capability to make consistently good policy decisions, ones that continue to look good in hindsight, 10, 20 or 30 years later. What does that take?

I would submit that the essential "preserving democracy" process component is having a population that is adequately prepared for collaborative problem-solving. Some understanding of history is helpful, but it's simply not enough. Much more essential is for every young person to experience team problem-solving, in both its cooperative and competitive aspects. Every young person needs to experience a team leadership role, and to appreciate what it takes from leaders to forge constructive design from competing ideas and champions. Only after serving as a referee will a young person understand the limits to "passion" that individual contributors should bring to the party. Only after moderating and herding cats will a young person know how to interact productively with leaders and other contributors. Much of the skill is counter-instinctual. It's knowing how to express ideas...how to field criticism....how to nudge people along in the desired direction...and how to avoid ad-hominem attacks, exaggerations, accusations and speculative grievances. It's learning how to manage conflict productively toward excellence. Way too few of our young people are learning these skills, and way too few of our journalists know how to play a constructive role in managing communications toward successful complex problem-solving. Albright's claim that a journalist's job is primarily to "hold leaders accountable" really betrays an absolving of responsibility for the media as a partner in good government -- it doesn't say whether the media are active players on the problem-solving team (which they have to be for success), or mere spectators with no responsibility for the outcome. If the latter, then journalism becomes an irritant, picking at the scabs over and over, but without any forward progress. When the media takes up a stance as an "opponent" of leadership, you end up with poor problem-solving results....the system is fighting itself instead of making forward progress.

"Fascism" doesn't do nearly enough to promote the teaching of practical civics 101 skills, not just to the kids going into public administration, but to everyone. For, it is in the norms of civility, their ability to be practiced, and their defense against excesses, that fascism (e.g., Antifa) is kept at bay.
Everyone in a democracy has to know the basics:
• when entering a disagreement, don't personalize it
• never demonize an opponent
• keep a focus on the goal of agreement and moving forward
• never tell another person what they think, but ask (non-rhetorically) what they think then be prepared to listen and absorb
• do not speak untruths or exaggerate to make an argument
• do not speculate grievance
• understand truth gathering as a process; detect when certainty is being bluffed; question sources
• recognize impasse and unproductive argumentation and STOP IT
• know how to introduce a referee or moderator to regain productive collaboration
• avoid ad hominem attacks
• don't take things personally that wrankle you;
• give the benefit of the doubt in an ambiguous situation
• don't jump to conclusions
• don't reward theatrical manipulation

These basics of collaborative problem-solving are the guts of a "liberal democracy" that can face down the most complex challenges and dilemmas.

I gave the book 3 stars for the great story-telling, and Albright has been part of a great story of late 20th century history. If she would have told us how to prevent fascism going forward, and how to roll it back in "hard case" countries like North Korea and Sudan, I would have given her a 5. I'm not that interested in picking apart the failure cases of history...they teach mostly negative exemplars. Much rather I would like to read about positive exemplars of great national government -- "great" defined by popular acclaim, by the actual ones governed. Where are we seeing that today? Canada? Australia? Interestingly, both of these positive exemplars have strict immigration policies.

Is it possible that Albright is just unable, by virtue of her narrow escape from Communist Czechoslovakia and acceptance in NYC as a transplant, to see that an optimum immigration policy in the US, something like Canada's or Australia's, is not the looming face of fascism, but rather a move to keep it safely in its corner in coming decades? At least, she admits to her being biased by her life story.

That suggests her views on refugees and illegal immigrants as deserving of unlimited rights to migrate into the US might be the kind of cloaked extremism that she is warning us about.

Anat Hadad , January 19, 2019
"Fascism is not an exception to humanity, but part of it."

Albright's book is a comprehensive look at recent history regarding the rise and fall of fascist leaders; as well as detailing leaders in nations that are starting to mimic fascist ideals. Instead of a neat definition, she uses examples to bolster her thesis of what are essential aspects of fascism. Albright dedicates each section of the book to a leader or regime that enforces fascist values and conveys this to the reader through historical events and exposition while also peppering in details of her time as Secretary of State. The climax (and 'warning'), comes at the end, where Albright applies what she has been discussing to the current state of affairs in the US and abroad.

Overall, I would characterize this as an enjoyable and relatively easy read. I think the biggest strength of this book is how Albright uses history, previous examples of leaders and regimes, to demonstrate what fascism looks like and contributing factors on a national and individual level. I appreciated that she lets these examples speak for themselves of the dangers and subtleties of a fascist society, which made the book more fascinating and less of a textbook. Her brief descriptions of her time as Secretary of State were intriguing and made me more interested in her first book, 'Madame Secretary'. The book does seem a bit slow as it is not until the end that Albright blatantly reveals the relevance of all of the history relayed in the first couple hundred pages. The last few chapters are dedicated to the reveal: the Trump administration and how it has affected global politics. Although, she never outright calls Trump a fascist, instead letting the reader decide based on his decisions and what you have read in the book leading up to this point, her stance is quite clear by the end. I was surprised at what I shared politically with Albright, mainly in immigration and a belief of empathy and understanding for others. However, I got a slight sense of anti-secularism in the form of a disdain for those who do not subscribe to an Abrahamic religion and she seemed to hint at this being partly an opening to fascism.

I also could have done without the both-sides-ism she would occasionally push, which seems to be a tactic used to encourage people to 'unite against Trump'. These are small annoyances I had with the book, my main critique is the view Albright takes on democracy. If anything, the book should have been called "Democracy: the Answer" because that is the most consistent stance Albright takes throughout. She seems to overlook many of the atrocities the US and other nations have committed in the name of democracy and the negative consequences of capitalism, instead, justifying negative actions with the excuse of 'it is for democracy and everyone wants that' and criticizing those who criticize capitalism.

She does not do a good job of conveying the difference between a communist country like Russia and a socialist country like those found in Scandinavia and seems okay with the idea of the reader lumping them all together in a poor light. That being said, I would still recommend this book for anyone's TBR as the message is essential for today, that the current world of political affairs is, at least somewhat, teetering on a precipice and we are in need of as many strong leaders as possible who are willing to uphold democratic ideals on the world stage and mindful constituents who will vote them in.

Matthew T , May 29, 2018
An easy read, but incredibly ignorant and one eyed in far too many instances

The book is very well written, easy to read, and follows a pretty standard formula making it accessible to the average reader. However, it suffers immensely from, what I suspect are, deeply ingrained political biases from the author.

Whilst I don't dispute the criteria the author applies in defining fascism, or the targets she cites as examples, the first bias creeps in here when one realises the examples chosen are traditional easy targets for the US (with the exception of Turkey). The same criteria would define a country like Singapore perfectly as fascist, yet the country (or Malaysia) does not receive a mention in the book.

Further, it grossly glosses over what Ms. Albright terms facist traits from the US governments of the past. If the author is to be believed, the CIA is holier than thou, never intervened anywhere or did anything that wasn't with the best interests of democracy at heart, and American foreign policy has always existed to build friendships and help out their buddies. To someone ingrained in this rhetoric for years I am sure this is an easy pill to swallow, but to the rest of the world it makes a number of assertions in the book come across as incredibly naive. out of 5 stars Trite and opaque

Avid reader , December 20, 2018
Biast much? Still a good start into the problem

We went with my husband to the presentation of this book at UPenn with Albright before it came out and Madeleine's spunk, wit and just glorious brightness almost blinded me. This is a 2.5 star book, because 81 year old author does not really tell you all there is to tell when she opens up on a subject in any particular chapter, especially if it concerns current US interest.

Lets start from the beginning of the book. What really stood out, the missing 3rd Germany ally, Japan and its emperor. Hirohito (1901-1989) was emperor of Japan from 1926 until his death in 1989. He took over at a time of rising democratic sentiment, but his country soon turned toward ultra-nationalism and militarism. During World War II (1939-45), Japan attacked nearly all of its Asian neighbors, allied itself with Nazi Germany and launched a surprise assault on the U.S. naval base at Pearl Harbor, forcing US to enter the war in 1941. Hirohito was never indicted as a war criminal! does he deserve at least a chapter in her book?

Oh and by the way, did author mention anything about sanctions against Germany for invading Austria, Czechoslovakia, Romania and Poland? Up until the Pearl Harbor USA and Germany still traded, although in March 1939, FDR slapped a 25% tariff on all German goods. Like Trump is doing right now to some of US trading partners.

Next monster that deserves a chapter on Genocide in cosmic proportions post WW2 is communist leader of China Mao Zedung. Mr Dikötter, who has been studying Chinese rural history from 1958 to 1962, when the nation was facing a famine, compared the systematic torture, brutality, starvation and killing of Chinese peasants compares to the Second World War in its magnitude. At least 45 million people were worked, starved or beaten to death in China over these four years; the total worldwide death toll of the Second World War was 55 million.

We learn that Argentina has given sanctuary to Nazi war criminals, but she forgets to mention that 88 Nazi scientists arrived in the United States in 1945 and were promptly put to work. For example, Wernher von Braun was the brains behind the V-2 rocket program, but had intimate knowledge of what was going on in the concentration camps. Von Braun himself hand-picked people from horrific places, including Buchenwald concentration camp. Tsk-Tsk Madeline.

What else? Oh, lets just say that like Madelaine Albright my husband is Jewish and lost extensive family to Holocoust. Ukrainian nationalists executed his great grandfather on gistapo orders, his great grandmother disappeared in concentration camp, grandfather was conscripted in june 1940 and decommissioned september 1945 and went through war as infantryman through 3 fronts earning several medals. his grandmother, an ukrainian born jew was a doctor in a military hospital in Saint Petersburg survived famine and saved several children during blockade. So unlike Maideline who was raised as a Roman Catholic, my husband grew up in a quiet jewish family in that territory that Stalin grabbed from Poland in 1939, in a polish turn ukrainian city called Lvov(Lemberg). His family also had to ask for an asylum, only they had to escape their home in Ukraine in 1991. He was told then "You are a nice little Zid (Jew), we will kill you last" If you think things in ukraine changed, think again, few weeks ago in Kiev Roma gypsies were killed and injured during pogroms, and nobody despite witnesses went to jail. Also during demonstrations openly on the streets C14 unit is waving swastikas and Heils. Why is is not mentioned anywhere in the book? is is because Hunter Biden sits on the board of one of Ukraine's largest natural gas companies called Burisma since May 14, 2014, and Ukraine has an estimated 127.9 trillion cubic feet of unproved technically recoverable shale gas resources? ( according to the U.S. Energy Information Administration (EIA).1 The most promising shale reserves appear to be in the Carpathian Foreland Basin (also called the Lviv-Volyn Basin), which extends across Western Ukraine from Poland into Romania, and the Dnieper-Donets Basin in the East (which borders Russia).
Wow, i bet you did not know that. how ugly are politics, even this book that could have been so much greater if the author told the whole ugly story. And how scary that there are countries where you can go and openly be fascist.

&amp;amp;amp;amp;lt;img src="https://images-na.ssl-images-amazon.com/images/S/amazon-avatars-global/0e64e0cb-01e4-4e58-bcae-bba690344095._CR0,0.0,333,333_SX48_.jpg"&amp;amp;amp;amp;gt; NJ , February 3, 2019
Interesting...yes. Useful...hmmm

To me, Fascism fails for the single reason that no two fascist leaders are alike. Learning about one or a few, in a highly cursory fashion like in this book or in great detail, is unlikely to provide one with any answers on how to prevent the rise of another or fend against some such. And, as much as we are witnessing the rise of numerous democratic or quasi-democratic "strongmen" around the world in global politics, it is difficult to brand any of them as fascist in the orthodox sense.

As the author writes at the outset, it is difficult to separate a fascist from a tyrant or a dictator. A fascist is a majoritarian who rouses a large group under some national, racial or similar flag with rallying cries demanding suppression or exculcation of those excluded from this group. A typical fascist leader loves her yes-men and hates those who disagree: she does not mind using violence to suppress dissidents. A fascist has no qualms using propaganda to popularize the agreeable "facts" and theories while debunking the inconvenient as lies. What is not discussed explicitly in the book are perhaps some positive traits that separate fascists from other types of tyrants: fascists are rarely lazy, stupid or prone to doing things for only personal gains. They differ from the benevolent dictators for their record of using heavy oppression against their dissidents. Fascists, like all dictators, change rules to suit themselves, take control of state organizations to exercise total control and use "our class is the greatest" and "kick others" to fuel their programs.

Despite such a detailed list, each fascist is different from each other. There is little that even Ms Albright's fascists - from Mussolini and Hitler to Stalin to the Kims to Chavez or Erdogan - have in common. In fact, most of the opponents of some of these dictators/leaders would calll them by many other choice words but not fascists. The circumstances that gave rise to these leaders were highly different and so were their rules, methods and achievements.

The point, once again, is that none of the strongmen leaders around the world could be easily categorized as fascists. Or even if they do, assigning them with such a tag and learning about some other such leaders is unlikely to help. The history discussed in the book is interesting but disjointed, perfunctory and simplistic. Ms Albright's selection is also debatable.

Strong leaders who suppress those they deem as opponents have wreaked immense harms and are a threat to all civil societies. They come in more shades and colours than terms we have in our vocabulary (dictators, tyrants, fascists, despots, autocrats etc). A study of such tyrant is needed for anyone with an interest in history, politics, or societal well-being. Despite Ms Albright's phenomenal knowledge, experience, credentials, personal history and intentions, this book is perhaps not the best place to objectively learn much about the risks from the type of things some current leaders are doing or deeming as right.

Gderf , February 15, 2019
Wrong warning

Each time I get concerned about Trump's rhetoric or past actions I read idiotic opinions, like those of our second worst ever Secretary of State, and come to appreciate him more. Pejorative terms like fascism or populism have no place in a rational policy discussion. Both are blatant attempts to apply a pejorative to any disagreeing opinion. More than half of the book is fluffed with background of Albright, Hitler and Mussolini. Wikipedia is more informative. The rest has snippets of more modern dictators, many of whom are either socialists or attained power through a reaction to failed socialism, as did Hitler. She squirms mightily to liken Trump to Hitler. It's much easier to see that Sanders is like Maduro. The USA is following a path more like Venezuela than Germany.

Her history misses that Mussolini was a socialist before he was a fascist, and Nazism in Germany was a reaction to Wiemar socialism. The danger of fascism in the US is far greater from the left than from the right. America is far left of where the USSR ever was. Remember than Marx observed that Russia was not ready for a proletarian revolution. The USA with ready made capitalism for reform fits Marx's pattern much better. Progressives deny that Sanders and Warren are socialists. If not they are what Lenin called "useful idiots."
Albright says that she is proud of the speech where she called the USA the 'Indispensable Nation.' She should be ashamed. Obama followed in his inaugural address, saying that we are "the indispensable nation, responsible for world security." That turned into a policy of human rights interventions leading to open ended wars (Syria, Yemen), nations in chaos (Libya), and distrust of the USA (Egypt, Russia, Turkey, Tunisia, Israel, NK). Trump now has to make nice with dictators to allay their fears that we are out to replace them.
She admires the good intentions of human rights intervention, ignoring the results. She says Obama had some success without citing a single instance. He has apologized for Libya, but needs many more apologies. She says Obama foreign policy has had some success, with no mention of a single instance. Like many progressives, she confuses good intentions with performance. Democracy spreading by well intentioned humanitarian intervention has resulted in a succession of open ended war or anarchy.

The shorter histories of Czechoslovakia, Yugoslavia and Venezuela are much more informative, although more a warning against socialism than right wing fascism. Viktor Orban in Hungary is another reaction to socialism.

Albright ends the book with a forlorn hope that we need a Lincoln or Mandela, exactly what our two party dictatorship will not generate as it yields ever worse and worse candidates for our democracy to vote upon, even as our great society utopia generates ever more power for weak presidents to spend our money and continue wrong headed foreign policy.

The greatest danger to the USA is not fascism, but of excessively poor leadership continuing our slow slide to the bottom.

[Apr 02, 2019] Mr Cohen and I Live on Different Planets

Apr 02, 2019 | www.amazon.com

Looks like the reviewer is a typical neocon. Typical neocon think tanks talking points that reflect the "Full Spectrum Dominance" agenda.

As for Ukraine yes, of course, Victoria Nuland did not interfere with the event, did not push for the deposing Yanukovich to spoil agreement reached between him and the EU diplomats ("F**k EU" as this high level US diplomat eloquently expressed herself) and to appoint the US stooge Yatsenyuk. The transcript of Nuland's phone call actually introduced many Americans to the previously obscure Yatsenyuk.

And the large amount of cash confiscated in the Kiev office of Yulia Timostchenko Batkivshchina party (the main opposition party at the time run by Yatsenyuk, as Timoshenko was in jail) was just a hallucination. It has nothing to do with ";bombing with dollars"; -- yet another typical color revolution trick.

BTW "government snipers of rooftops" also is a standard false flag operation used to instill uprising at the critical moment of the color revolution. Ukraine was not the first and is not the last. One participant recently confessed. The key person in this false flag operation was the opposition leader Andriy Parubiy -- who was responsible for the security of the opposition camp. Google "Parubiy and snipergate" for more information.

His view on DNC hack (which most probably was a leak) also does not withstand close scrutiny. William Binney, a former National Security Agency high level official who co-authored an analysis of a group of former intelligence professionals thinks that this was a transfer to the local USB drive as the speed of downloads was too high for the Internet connection. In this light the death of Seth Rich looks very suspicious indeed.

As for Russiagate, he now needs to print his review and the portrait of Grand Wizard of Russiagate Rachel Maddow, shed both of them and eat with Borscht ;-)

[Apr 01, 2019] Amazon.com War with Russia From Putin Ukraine to Trump Russiagate (9781510745810) Stephen F. Cohen Books

Highly recommended!
Important book. Kindle sample
Notable quotes:
"... Washington has made many policies strongly influenced by' the demonizing of Putin -- a personal vilification far exceeding any ever applied to Soviet Russia's latter-day Communist leaders. ..."
"... As with all institutions, the demonization of Putin has its own history'. When he first appeared on the world scene as Boris Yeltsin's anointed successor, in 1999-2000, Putin was welcomed by' leading representatives of the US political-media establishment. The New York Times ' chief Moscow correspondent and other verifiers reported that Russia's new leader had an "emotional commitment to building a strong democracy." Two years later, President George W. Bush lauded his summit with Putin and "the beginning of a very' constructive relationship."' ..."
"... But the Putin-friendly narrative soon gave away to unrelenting Putin-bashing. In 2004, Times columnist Nicholas Kristof inadvertently explained why, at least partially. Kristof complained bitterly' of having been "suckered by' Mr. Putin. He is not a sober version of Boris Yeltsin." By 2006, a Wall Street Journal editor, expressing the establishment's revised opinion, declared it "time we start thinking of Vladimir Putin's Russia as an enemy of the United States." 10 , 11 The rest, as they' say, is history'. ..."
"... In America and elsewhere in the West, however, only purported "minuses" reckon in the extreme vilifying, or anti-cult, of Putin. Many are substantially uninformed, based on highly selective or unverified sources, and motivated by political grievances, including those of several Yeltsin-era oligarchs and their agents in the West. ..."
"... Putin is not the man who, after coming to power in 2000, "de-democratized" a Russian democracy established by President Boris Yeltsin in the 1990s and restored a system akin to Soviet "totalitarianism." ..."
"... Nor did Putim then make himself a tsar or Soviet-like autocrat, which means a despot with absolute power to turn his will into policy, the last Kremlin leader with that kind of power was Stalin, who died in 1953, and with him his 20-year mass terror. ..."
"... Putin is not a Kremlin leader who "reveres Stalin" and whose "Russia is a gangster shadow of Stalin's Soviet Union." 13 , 14 These assertions are so far-fetched and uninfoimed about Stalin's terror-ridden regime, Putin, and Russia today, they barely warrant comment. ..."
"... Nor did Putin create post-Soviet Russia's "kleptocratic economic system," with its oligarchic and other widespread corruption. This too took shape under Yeltsin during the Kremlin's shock-therapy "privatization" schemes of the 1990s, when the "swindlers and thieves" still denounced by today's opposition actually emerged. ..."
"... Which brings us to the most sinister allegation against him: Putin, trained as "a KGB thug," regularly orders the killing of inconvenient journalists and personal enemies, like a "mafia state boss." ..."
"... More recently, there is yet another allegation: Putin is a fascist and white supremacist. The accusation is made mostly, it seems, by people wishing to deflect attention from the role being played by neo-Nazis in US-backed Ukraine. ..."
"... Finally, at least for now. there is the ramifying demonization allegation that, as a foreign-policy leader. Putin has been exceedingly "aggressive" abroad and his behavior has been the sole cause of the new cold war. ..."
"... Embedded in the "aggressive Putin" axiom are two others. One is that Putin is a neo-Soviet leader who seeks to restore the Soviet Union at the expense of Russia's neighbors. Fie is obsessively misquoted as having said, in 2005, "The collapse of the Soviet Union was the greatest geopolitical catastrophe of the twentieth century," apparently ranking it above two World Wars. What he actually said was "a major geopolitical catastrophe of the twentieth century," as it was for most Russians. ..."
"... The other fallacious sub-axiom is that Putin has always been "anti-Western," specifically "anti-American," has "always viewed the United States" with "smoldering suspicions." -- so much that eventually he set into motion a "Plot Against America." ..."
"... Or, until he finally concluded that Russia would never be treated as an equal and that NATO had encroached too close, Putin was a full partner in the US-European clubs of major world leaders? Indeed, as late as May 2018, contrary to Russiagate allegations, he still hoped, as he had from the beginning, to rebuild Russia partly through economic partnerships with the West: "To attract capital from friendly companies and countries, we need good relations with Europe and with the whole world, including the United States." 3 " ..."
"... A few years earlier, Putin remarkably admitted that initially he had "illusions" about foreign policy, without specifying which. Perhaps he meant this, spoken at the end of 2017: "Our most serious mistake in relations with the West is that we trusted you too much. And your mistake is that you took that trust as weakness and abused it." 34 ..."
"... <img src="https://images-na.ssl-images-amazon.com/images/S/amazon-avatars-global/default._CR0,0,1024,1024_SX48_.png"> P. Philips ..."
"... "In a Time of Universal Deceit -- Telling the Truth Is a Revolutionary Act" ..."
"... Professor Cohen is indeed a patriot of the highest order. The American and "Globalists" elites, particularly the dysfunctional United Kingdom, are engaging in a war of nerves with Russia. This war, which could turn nuclear for reasons discussed in this important book, is of no benefit to any person or nation. ..."
"... If you are a viewer of one of the legacy media outlets, be it Cable Television networks, with the exception of Tucker Carlson on Fox who has Professor Cohen as a frequent guest, or newspapers such as The New York Times, you have been exposed to falsehoods by remarkably ignorant individuals; ignorant of history, of the true nature of Russia (which defeated the Nazis in Europe at a loss of millions of lives) and most important, of actual military experience. America is neither an invincible or exceptional nation. And for those familiar with terminology of ancient history, it appears the so-called elites are suffering from hubris. ..."
Apr 01, 2019 | www.amazon.com

THE SPECTER OF AN EVIL-DOING VLADIMIR PUTIN HAS loomed over and undermined US thinking about Russia for at least a decade. Inescapably, it is therefore a theme that runs through this book. Henry' Kissinger deserves credit for having warned, perhaps alone among prominent American political figures, against this badly distorted image of Russia's leader since 2000: "The demonization of Vladimir Putin is not a policy. It is an alibi for not having one." 4

But Kissinger was also wrong. Washington has made many policies strongly influenced by' the demonizing of Putin -- a personal vilification far exceeding any ever applied to Soviet Russia's latter-day Communist leaders. Those policies spread from growing complaints in the early 2000s to US- Russian proxy wars in Georgia, Ukraine, Syria, and eventually even at home, in Russiagate allegations. Indeed, policy-makers adopted an earlier formulation by the late Senator .Tolm McCain as an integral part of a new and more dangerous Cold War: "Putin [is] an unreconstructed Russian imperialist and K.G.B. apparatchik.... His world is a brutish, cynical place.... We must prevent the darkness of Mr. Putin's world from befalling more of humanity'." 3

Mainstream media outlets have play'ed a major prosecutorial role in the demonization. Far from aty'pically', the Washington Post's editorial page editor wrote, "Putin likes to make the bodies bounce.... The rule-by-fear is Soviet, but this time there is no ideology -- only a noxious mixture of personal aggrandizement, xenophobia, homophobia and primitive anti-Americanism." 6 Esteemed publications and writers now routinely degrade themselves by competing to denigrate "the flabbily muscled form" of the "small gray ghoul named Vladimir Putin." 7 , 8 There are hundreds of such examples, if not more, over many years. Vilifying Russia's leader has become a canon in the orthodox US narrative of the new Cold War.

As with all institutions, the demonization of Putin has its own history'. When he first appeared on the world scene as Boris Yeltsin's anointed successor, in 1999-2000, Putin was welcomed by' leading representatives of the US political-media establishment. The New York Times ' chief Moscow correspondent and other verifiers reported that Russia's new leader had an "emotional commitment to building a strong democracy." Two years later, President George W. Bush lauded his summit with Putin and "the beginning of a very' constructive relationship."'

But the Putin-friendly narrative soon gave away to unrelenting Putin-bashing. In 2004, Times columnist Nicholas Kristof inadvertently explained why, at least partially. Kristof complained bitterly' of having been "suckered by' Mr. Putin. He is not a sober version of Boris Yeltsin." By 2006, a Wall Street Journal editor, expressing the establishment's revised opinion, declared it "time we start thinking of Vladimir Putin's Russia as an enemy of the United States." 10 , 11 The rest, as they' say, is history'.

Who has Putin really been during his many years in power? We may' have to leave this large, complex question to future historians, when materials for full biographical study -- memoirs, archive documents, and others -- are available. Even so, it may surprise readers to know that Russia's own historians, policy intellectuals, and journalists already argue publicly and differ considerably as to the "pluses and minuses" of Putin's leadership. (My own evaluation is somewhere in the middle.)

In America and elsewhere in the West, however, only purported "minuses" reckon in the extreme vilifying, or anti-cult, of Putin. Many are substantially uninformed, based on highly selective or unverified sources, and motivated by political grievances, including those of several Yeltsin-era oligarchs and their agents in the West.

By identifying and examining, however briefly, the primary "minuses" that underpin the demonization of Putin, we can understand at least who he is not:

Embedded in the "aggressive Putin" axiom are two others. One is that Putin is a neo-Soviet leader who seeks to restore the Soviet Union at the expense of Russia's neighbors. Fie is obsessively misquoted as having said, in 2005, "The collapse of the Soviet Union was the greatest geopolitical catastrophe of the twentieth century," apparently ranking it above two World Wars. What he actually said was "a major geopolitical catastrophe of the twentieth century," as it was for most Russians.

Though often critical of the Soviet system and its two formative leaders, Lenin and Stalin, Putin, like most of his generation, naturally remains in part a Soviet person. But what he said in 2010 reflects his real perspective and that of very many other Russians: "Anyone who does not regret the break-up of the Soviet Union has no heart. Anyone who wants its rebirth in its previous form has no head." 28 , 29

The other fallacious sub-axiom is that Putin has always been "anti-Western," specifically "anti-American," has "always viewed the United States" with "smoldering suspicions." -- so much that eventually he set into motion a "Plot Against America." 30 , 31 A simple reading of his years in power tells us otherwise. A Westernized Russian, Putin came to the presidency in 2000 in the still prevailing tradition of Gorbachev and Yeltsin -- in hope of a "strategic friendship and partnership" with the United States.

How else to explain Putin's abundant assistant to US forces fighting in Afghanistan after 9/1 1 and continued facilitation of supplying American and NATO troops there? Or his backing of harsh sanctions against Iran's nuclear ambitions and refusal to sell Tehran a highly effective air-defense system? Or the information his intelligence services shared with Washington that if heeded could have prevented the Boston Marathon bombings in April 2012?

Or, until he finally concluded that Russia would never be treated as an equal and that NATO had encroached too close, Putin was a full partner in the US-European clubs of major world leaders? Indeed, as late as May 2018, contrary to Russiagate allegations, he still hoped, as he had from the beginning, to rebuild Russia partly through economic partnerships with the West: "To attract capital from friendly companies and countries, we need good relations with Europe and with the whole world, including the United States." 3 "

Given all that has happened during the past nearly two decades -- particularly what Putin and other Russian leaders perceive to have happened -- it would be remarkable if his views of the W^est, especially America, had not changed. As he remarked in 2018, "We all change." 33

A few years earlier, Putin remarkably admitted that initially he had "illusions" about foreign policy, without specifying which. Perhaps he meant this, spoken at the end of 2017: "Our most serious mistake in relations with the West is that we trusted you too much. And your mistake is that you took that trust as weakness and abused it." 34


P. Philips , December 6, 2018

"In a Time of Universal Deceit -- Telling the Truth Is a Revolutionary Act"

"In a Time of Universal Deceit -- Telling the Truth Is a Revolutionary Act" is a well known quotation (but probably not of George Orwell). And in telling the truth about Russia and that the current "war of nerves" is not in the interests of either the American People or national security, Professor Cohen in this book has in fact done a revolutionary act.

Like a denizen of Plato's cave, or being in the film the Matrix, most people have no idea what the truth is. And the questions raised by Professor Cohen are a great service in the cause of the truth. As Professor Cohen writes in his introduction To His Readers:

"My scholarly work -- my biography of Nikolai Bukharin and essays collected in Rethinking the Soviet Experience and Soviet Fates and Lost Alternatives, for example -- has always been controversial because it has been what scholars term "revisionist" -- reconsiderations, based on new research and perspectives, of prevailing interpretations of Soviet and post-Soviet Russian history. But the "controversy" surrounding me since 2014, mostly in reaction to the contents of this book, has been different -- inspired by usually vacuous, defamatory assaults on me as "Putin's No. 1 American Apologist," "Best Friend," and the like. I never respond specifically to these slurs because they offer no truly substantive criticism of my arguments, only ad hominem attacks. Instead, I argue, as readers will see in the first section, that I am a patriot of American national security, that the orthodox policies my assailants promote are gravely endangering our security, and that therefore we -- I and others they assail -- are patriotic heretics. Here too readers can judge."

Cohen, Stephen F.. War with Russia (Kindle Locations 131-139). Hot Books. Kindle Edition.

Professor Cohen is indeed a patriot of the highest order. The American and "Globalists" elites, particularly the dysfunctional United Kingdom, are engaging in a war of nerves with Russia. This war, which could turn nuclear for reasons discussed in this important book, is of no benefit to any person or nation.

Indeed, with the hysteria on "climate change" isn't it odd that other than Professor Cohen's voice, there are no prominent figures warning of the devastation that nuclear war would bring?

If you are a viewer of one of the legacy media outlets, be it Cable Television networks, with the exception of Tucker Carlson on Fox who has Professor Cohen as a frequent guest, or newspapers such as The New York Times, you have been exposed to falsehoods by remarkably ignorant individuals; ignorant of history, of the true nature of Russia (which defeated the Nazis in Europe at a loss of millions of lives) and most important, of actual military experience. America is neither an invincible or exceptional nation. And for those familiar with terminology of ancient history, it appears the so-called elites are suffering from hubris.

I cannot recommend Professor Cohen's work with sufficient superlatives; his arguments are erudite, clearly stated, supported by the facts and ultimately irrefutable. If enough people find Professor Cohen's work and raise their voices to their oblivious politicians and profiteers from war to stop further confrontation between Russia and America, then this book has served a noble purpose.

If nothing else, educate yourself by reading this work to discover what the *truth* is. And the truth is something sacred.

America and the world owe Professor Cohen a great debt. "Blessed are the peace makers..."

[Mar 31, 2019] George Nader (an adviser to the crown prince of Abu Dhab): Nobody would even waste a cup of coffee on him if it wasn't for who he was married to

Notable quotes:
"... She suggests, "Kushner was increasingly caught up in his own mythology. He was the president's son-in-law, so he apparently thought he was untouchable." (Pg. 114) She notes, "allowing Kushner to work in the administration broke with historical precedent, overruling a string of Justice Department memos that concluded it was illegal for presidents to appoint relatives as White House staff." (Pg. 119) ..."
"... She observes, "Those first few days were chaotic for almost everyone in the new administration. A frantic Reince Priebus would quickly discover that it was impossible to impose any kind of order in this White House, in large part because Trump didn't like order. What Trump liked was having people fight in front of him and then he'd make a decision, just like he'd made snap decisions when his children presented licensing deals for the Trump Organization. This kind of dysfunction enabled a 'floater' like Kushner, whose job was undefined, to weigh in on any topic in front of Trump and have far more influence than he would have had in a top-down hierarchy." (Pg. 125) ..."
Mar 31, 2019 | www.amazon.com

Steven H Propp TOP 50 REVIEWER 5.0 out of 5 stars March 27, 2019

AN INFORMATIVE BOOK ABOUT THE PRESIDENT'S DAUGHTER AND SON-IN-LAW

Author Vicky Ward wrote in the Prologue to this 2019 book, "Donald Trump was celebrating being sworn in as president And the whole world knew that his daughter and son-in-law were his most trusted advisers, ambassadors, and coconspirators. They were an attractive couple---extremely wealthy and, now, extraordinarily powerful. Ivanka looked like Cinderella Ivanka and her husband swept onto the stage, deftly deflecting attention from Donald Trump's clumsy moves, as she had done do often over the past twenty years. The crowd roared in approval They were now America's prince and princess."

She notes, "Jared Kushner learned about the company [his father's] he would later run. Jared was the firm's most sheltered trainee. On his summer vacations, he'd go to work at Kushner Companies construction sites, maybe painting a few walls, more often sitting and listening to music No one dared tell him this probably would not give him a deep understanding of the construction process. But Charlie [Jared's father] doggedly groomed his eldest son for greatness, seeing himself as a Jewish version of Joseph Kennedy " (Pg. 17-18)

She states, "Ivanka had to fight for her father's attention and her ultimate role as the chief heir in his real estate empire When Donald Trump divorced her mother, Ivana she would go out of her way to see more of her father, not less she'd call him during the day and to her delight, he'd always take her call. (Trump's relationship with the two sons he had with Ivana, Don Jr. and Eric, was not nearly so close for years.) 'She was always Daddy's little girl,' said a family friend." (Pg. 32-33) She adds, "As Ivanka matured, physically and emotionally, her father talked openly about how impressed he was with her appearance---a habit he has maintained to this day." (Pg. 35)

She recounts, "at a networking lunch thrown by a diamond heir Jared was introduced to Ivanka Jared and Ivanka quickly became an intriguing gossip column item. They seemed perfectly matched But after a year of dating, they split in part because Jared's parents were dismayed at the idea of their son marrying outside the faith Soon after, Ivanka agreed to convert to Judaism Trump was said to be discombobulated by the enormity of what his daughter had done. Trump, a Presbyterian, who strikes no one as particularly religious, was baffled by his daughter's conversion 'Why should my daughter convert to marry anyone?'" (Pg. 51-53)

She observes, "Ivanka Trump was critical in promoting her husband as the smoother, softer counterpart to his father's volatility.. they could both work a room, ask after people's children, talk without notes, occasionally fake a sense of humor And unlike her husband, she seemed to have a ready command of figures and a detail, working knowledge of all the properties she was involved in Ivanka seemed to control the marital relationship, but she also played the part of devoted, traditional Orthodox wife." (Pg. 70-71)

Of 2016, she states, "No one thought Kushner or Ivanka believed in Trump's populist platform. 'The two of them see this as a networking opportunity,' said a close associate. Because Kushner and Ivanka only fully immersed themselves in Trump's campaign once he became the presumptive Republican nominee they had to push to assert themselves with the campaign staff Kushner quickly got control of the campaign's budget, but he did not have as much authority as he would have liked." (Pg. 74-75) She adds, "Ivanka appeared thrilled by her husband's rising prominence in her father's campaign. It was a huge change from the days when Trump had made belittling jokes about him. If Don Jr. and Eric were irked by the new favorite in Trump's court, they did not show it publicly." (Pg. 85)

She points out, "Trump tweeted an image [Hillary with a backdrop of money and a Star of David] widely viewed as anti-Semitic an 'Observer' writer, criticized Kushner in his own newspaper for standing 'silent and smiling in the background' while Trump made 'repeated accidental winks' to white supremacists Kushner wrote a response [that] insisted that Trump was neither anti-Semitic nor a racist Not all of Kushner's relatives appreciated his efforts to cover Trump's pandering to white supremacists." (Pg. 86-87) Later, she adds, "U.S.-Israel relations was the one political issue anyone in the campaign ever saw Kushner get worked up about." (Pg. 96)

On election night, "Kushner was shocked that Trump never mentioned him in his speech and would later tell people he felt slighted. He was going to find a way to get Trump to notice him more. Ivanka would help him the couple would become known as a single, powerful entity: 'Javanka.'" (Pg. 101) She suggests, "Kushner was increasingly caught up in his own mythology. He was the president's son-in-law, so he apparently thought he was untouchable." (Pg. 114) She notes, "allowing Kushner to work in the administration broke with historical precedent, overruling a string of Justice Department memos that concluded it was illegal for presidents to appoint relatives as White House staff." (Pg. 119)

She observes, "Those first few days were chaotic for almost everyone in the new administration. A frantic Reince Priebus would quickly discover that it was impossible to impose any kind of order in this White House, in large part because Trump didn't like order. What Trump liked was having people fight in front of him and then he'd make a decision, just like he'd made snap decisions when his children presented licensing deals for the Trump Organization. This kind of dysfunction enabled a 'floater' like Kushner, whose job was undefined, to weigh in on any topic in front of Trump and have far more influence than he would have had in a top-down hierarchy." (Pg. 125)

She recounts, "Another epic [Steve] Bannon/Ivanka fight came when bannon was in the Oval Office dining room while Trump was watching TV and eating his lunch Ivanka marched in, claiming Bannon had leaked H.R. McMaster's war plan [Bannon said] 'No, that was leaked by McMaster ' Trump [told her], 'Hey, baby, I think Steve's right on this one ' Bannon thought he would be fired on the spot. But he'd learned something important: much as Trump loved his daughter and hated saying no to her, he was not always controlled by her." (Pg. 138-139)

She notes, "[Ivanka] also found a way to be near Trump when he received phone calls from foreign dignitaries -- while she still owned her business. While Ivanka's behavior was irritating, Kushner was playing a game on a whole different level: he was playing for serious money at the time of the Qatari blockade Kushner's family had been courting the Qataris for financial help and had been turned town. When that story broke the blockade and the Trump administration's response to it suddenly all made sense." (Pg. 156)

Arguing that "Kushner was behind the decision to fire [FBI Director James] Comey" (Pg. 163-164), "Quickly, Trump realized he'd made an error, and blamed Kushner. It seemed clear to Trump's advisers, and not for the first time, that he wished Kushner were not in the White House. He said to Kushner in front of senior staff, 'Just go back to New York, man '" (Pg. 167) She adds, "[Ivanka's] reluctance to speak frankly to her father was the antithesis of the story she had been pushing in the media Ivanka had told Gayle King 'Where I disagree with my father, he knows it. And I express myself with total candor.'" (Pg. 170)

She states, "at the Group of 20 summit in Germany she briefly took her father's seat when he had to step out The gesture seemed to send the message that the U.S. government was now run on nepotism." (Pg. 182)

E-mails from George Nader [an adviser to Shiekh Mohammed bin Zayed Al Nahyan, the crown prince of Abu Dhabi] "made it clear that Kushner's friends in the Gulf mocked him behind his back Nader wrote 'Nobody would even waste a cup of coffee on him if it wasn't for who he was married to.'" (Pg. 206)

She points out, "since October 2017, hundreds of children had been taken from their parents while attempting to cross the U.S.-Mexico border and detained separately news shows everywhere showed heartbreaking images of young children being detained. The next month, Ivanka posted on Instagram a photograph of herself holding her youngest child in his pajamas. Not for the first time, her tone-deaf social media post was slammed as being isolated in her elitist, insulated wealthy world On June 20, Trump signed an executive order that apparently ended the border separations. Minutes later, Ivanka finally spoke publicly on the issue Her tactic here was tell the public you care about an issue; watch silently while your father does the exact opposite; and when he moves a little, take all the credit." (Pg. 225)

She asserts, "Kushner's friendship with a Saudi crown prince was now under widespread scrutiny [because] Rather than expressing moral outrage over the cold-blooded murder of an innocent man [Saudi journalist Jamal Khashoggi], Kushner did what he always does in a crisis: he went quiet." (Pg. 232)

She concludes, "Ivanka Trump has made no secret of the fact that she wants to be the most powerful woman in the world. Her father's reign in Washington, D.C., is, she believes, the beginning of a great American dynasty Ivanka has been carefully positioning herself as [Trump's] political heir " (Pg. 236)

While not as "scandalous" as the book's subtitle might suggest, this is a very interesting book that will be of great interest to those wanting information about these crucial members of the Trump family and presidency.

[Mar 28, 2019] Was MAGA is con job ?

Notable quotes:
"... Until the Crash of the Great Recession, after which we entered a "Punitive" stage, blaming "Those Others" for buying into faulty housing deals, for wanting a safety net of health care insurance, for resurgent terrorism beyond our borders, and, as the article above indicates, for having an equal citizen's voice in the electoral process. ..."
"... What needs to be restored is the purpose that "the economy works for the PEOPLE of the nation", not the other way around, as we've witnessed for the last four decades. ..."
Feb 26, 2019 | www.amazon.com

Kindle Customer, December 8, 2018

5.0 out of 5 stars How and Why the MAGA-myth Consumed Itself

Just finished reading this excellent book on how corporatist NeoLiberalism and the Xristianists merged their ideologies to form the Conservative Coalition in the 1970s, and to then hijack the RepubliCAN party of Abe, Teddy, Ike (and Poppy Bush).

The author describes three phases of the RepugliCONs' zero-sum game:

The "Combative" stage of Reagan sought to restore "family values" (aka patriarchal hierarchy) to the moral depravity of Sixties youth and the uppity claims to equal rights by blacks and feminists.

In the "Normative" stage of Gingrich and W Bush, the NeoConservatives claimed victory over Godless Communism and the NeoLibs took credit for an expanding economy (due mostly by technology, not to Fed policy). They were happy to say "Aren't you happy now?" with sole ownership of the Free World and its markets, yet ignoring various Black Swan events and global trends they actually had no control over.

Until the Crash of the Great Recession, after which we entered a "Punitive" stage, blaming "Those Others" for buying into faulty housing deals, for wanting a safety net of health care insurance, for resurgent terrorism beyond our borders, and, as the article above indicates, for having an equal citizen's voice in the electoral process.

What was unexpected was that the libertarian mutiny by the TeaParty would become so nasty and vicious, leading to the Pirate Trump to scavenge what little was left of American Democracy for his own treasure.

What needs to be restored is the purpose that "the economy works for the PEOPLE of the nation", not the other way around, as we've witnessed for the last four decades.

[Jan 14, 2019] Spygate: The Attempted Sabotage of Donald J. Trump

Notable quotes:
"... Elections are just for show like many trials in the old USSR. The in power Party is the power NOT the individual voting citizens. In the end this book is about exposing the pernicious activities of those who would place themselves above the voting citizens of America. ..."
Jan 14, 2019 | www.amazon.com

Johnny G 5.0 out of 5 stars The Complex Made Easy! October 9, 2018 Format: Hardcover Verified Purchase

Regardless of your politics this is a must read book. The authors do a wonderful job of peeling back the layered onion that is being referred to as "Spy Gate." The book reads like an imaginative spy thriller. Except it is as real a fist in the stomach or the death of your best friend. In this case it is our Constitution that is victimized by individuals entrusted with "protecting and defending it from all enemies DOMESTIC and foreign."

Tis is in many ways a sad tail of ambition, weak men, political operatives & hubris ridden bureaucrats. The end result IF this type of activity is not punished and roundly condemned by ALL Americans could be a descent into Solzhenitsyn's GULAG type of Deep State government run by unaccountable political appointees and bureaucrats.

Elections are just for show like many trials in the old USSR. The in power Party is the power NOT the individual voting citizens. In the end this book is about exposing the pernicious activities of those who would place themselves above the voting citizens of America. ALL Americans should be aware of those forces seen and unseen that seek to injure our Constitutional Republic. This book is footnoted extensively lest anyone believes it is a polemic political offering.

JAK 5.0 out of 5 stars The truth hurts and that's the truth October 11, 2018 Format: Hardcover Verified Purchase

This book has content that you will not see or find anywhere else. while the topic itself is covered elsewhere in large mainstream media Outlets the truth of what is actually happening is rarely ever exposed.

If there was a six-star recommendation or anything higher because the truth is all that matters, he would receive it.

This book is put together with so many far-left (CNN, BLOOMBERG, DLSTE, YAHOO ECT) leading news stories as being able to support the fact of what happened, it's possible to say oh well that just didn't happen but it was reported by the left and when you put all of the pieces of the puzzle together it is painfully obvious to see what happened......

If these people involved don't go to jail the death of our Republic has already happened

[Dec 12, 2015] 11 New Open Source Development Tools

Datamation

YAPF

Short for "Yet Another Python Formatter," YAPF reformats Python code so that it conforms to the style guide and looks good. It's a Google-owned project. Operating System: OS Independent

Python Execute Unix - Linux Command Examples

The os.system has many problems and subprocess is a much better way to executing unix command. The syntax is:
import subprocess
subprocess.call("command1")
subprocess.call(["command1", "arg1", "arg2"]) 

In this example, execute the date command:

 
import subprocess
subprocess.call("date")
 

Sample outputs:

Sat Nov 10 00:59:42 IST 2012
0

You can pass the argument using the following syntax i.e run ls -l /etc/resolv.conf command:

 
import subprocess
subprocess.call(["ls", "-l", "/etc/resolv.conf"])
 

Sample outputs:

<-rw-r--r-- 1 root root 157 Nov  7 15:06 /etc/resolv.conf
0

[Feb 09, 2014] build - How to package Python as RPM for install into -opt

Stack Overflow

Q: How to create a binary RPM package out of Python 2.7.2 sources for installation into a non-standard prefix such as /opt/python27?

Assume the following builds correctly.

wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar zxvf Python-2.7.2.tgz
cd Python-2.7.2
./configure --prefix=/opt/python27 --enable-shared
make
make test
sudo make install

Instead of the last command I'd like to build a binary RPM.

A:

RPMs are built using rpmbuild from a .spec file. As an example, look at python.spec from Fedora.

If you don't need to build from sources then try rpm's --relocate switch on a pre-built RPM for your distribution:

rpm -i --relocate /usr=/opt/python27 python-2.7.rpm

Python 2.7 RPMs - Gitorious

Python 2.7 RPMs

Port of the Fedora 15 Python 2.7 RPM and some of the related stack to build on RHEL 5 & 6 (and derivatives such as CentOS). Can be installed in parallel to the system Python packages.

[Feb 09, 2014] Building and Installing Python 2.7 RPMs on CentOS 5.7 by Nathan Milford


I was asked today to install Python 2.7 on a CentOS based node and I thought I'd take this oportunity to add a companion article to my Python 2.6 article.

We're all well aware that CentOS is pretty backwards when it comes to having the latest and greatest sotware packages and is particularly finicky when it comes to Python since so much of RHEL depends on it.

As a rule, I refuse to rush in and install anything in production that isn't in a manageable package format such as RPM. I need to be able to predictably reproduce software installs across a large number of nodes.

The following steps will not clobber your default Python 2.4 install and will keep both CentOS and your developers happy.

So, here we go.

Install the dependancies.

sudo yum -y install rpmdevtools tk-devel tcl-devel expat-devel db4-devel \
                    gdbm-devel sqlite-devel bzip2-devel openssl-devel \
                    ncurses-devel readline-devel

Setup you RPM build envirnoment.

rpmdev-setuptree

Grab my spec file.

wget https://raw.github.com/nmilford/specfiles/master/python-2.7/python27-2.7.2.spec \
     -O ~/rpmbuild/SPECS/python27-2.7.2.spec 
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2 \
     -O ~/rpmbuild/SOURCES/Python-2.7.2.tar.bz2

Build RPM. (FYI, the QA_RPATHS variable tells the rpmbuild to skip some file path errors).

QA_RPATHS=$[ 0x0001|0x0010 ] rpmbuild -bb ~/rpmbuild/SPECS/python-2.7.2.spec

Install the RPMs.

sudo rpm -Uvh ~/rpmbuild/RPMS/x86_64/python27*.rpm

Now on to the the setuptools.

Grab my spec file.

wget https://raw.github.com/nmilford/specfiles/master/python-2.7/python27-setuptools-0.6c11.spec \
     -O ~/rpmbuild/SPECS/python27-setuptools-0.6c11.spec 

Grab the source.

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz \
     -O ~/rpmbuild/SOURCES/setuptools-0.6c11.tar.gz

Build the RPMs.

rpmbuild -bb ~/rpmbuild/SPECS/python27-setuptools-0.6c11.spec

Install the RPMs.

sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/python27-setuptools-0.6c11-milford.noarch.rpm

Now, we'll install MySQL-python as an example.

Grab the mysql-dev package

yum -y install mysql-devel

Grab, build and install the MySQL-python package.

curl http://superb-sea2.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz | tar zxv
cd MySQL-python-1.2.3
python2.7 setup.py build
python2.7 setup.py install

Like with the previous Python 2.6 article, note how I called the script explicitly using the following python binary: /usr/bin/python2.7

Now we're good to give it the old test thus:

python2.7 -c "import MySQLdb"

If it doesn't puke out some error message, you're all set.

Happy pythoning.

List of Python software

Wikipedia

[Oct 21, 2012] Last File Manager freshmeat.net

Written in Python. The last version is LFM 2.3 dated May 2011. Codebase is below 10K lines.
Lfm is a curses-based file manager for the Unix console written in Python

21 May 2011

Python 2.5 or later is required now. PowerCLI was added, an advanced command line interface with completion, persistent history, variable substitution, and many other useful features.

Persistent history in all forms was added. Lots of improvements were made and bugs were fixed

[Oct 06, 2011] Text Processing in Python (a book)

A couple of you make donations each month (out of about a thousand of you reading the text each week). Tragedy of the commons and all that... but if some more of you would donate a few bucks, that would be great support of the author.

In a community spirit (and with permission of my publisher), I am making my book available to the Python community. Minor corrections can be made to later printings, and at the least errata noted on this website. Email me at <mertz@gnosis.cx> .

A few caveats:

(1) This stuff is copyrighted by AW (except the code samples which are released to the public domain). Feel free to use this material personally; but no permission is given for further distribution beyond your personal use.

(2) The book is provided in "smart ASCII" format. This is converted to print (and maybe to fancier electronic formats) by automated scripts (txt->LaTeX->PDF for the printed version).

As a highly sophisticated "digital rights management" system, those scripts are not themselves made readily available. :-)

acknowledgments.txt FOLKS WHO HAVE MADE THIS BOOK BETTER
intro.txt INTRODUCTION
chap1.txt PYTHON BASICS
chap2.txt BASIC STRING OPERATIONS
chap3.txt REGULAR EXPRESSIONS
chap4.txt PARSERS AND STATE-MACHINES
chap5.txt INTERNET TOOLS AND TECHNIQUES
appendix_a.txt A SELECTIVE AND IMPRESSIONISTIC SHORT REVIEW OF PYTHON
appendix_b.txt A DATA COMPRESSION PRIMER
appendix_c.txt UNDERSTANDING UNICODE
appendix_d.txt A STATE-MACHINE FOR ADDING MARKUP TO TEXT
glossary.txt GLOSSARY TERMS

[Apr 04, 2011] Scripting the Linux desktop, Part 1 Basics by Paul Ferrill

Jan 18, 2011 | developerWorks

Developing applications for the Linux desktop typically requires some type of graphical user interface (GUI) framework to build on. Options include GTK+ for the GNOME desktop and Qt for the K Desktop Environment (KDE). Both platforms offer everything a developer needs to build a GUI application, including libraries and layout tools to create the windows users see. This article shows you how to build desktop productivity applications based on the screenlets widget toolkit (see Resources for a link).

A number of existing applications would fit in the desktop productivity category, including GNOME Do and Tomboy. These applications typically allow users to interact with them directly from the desktop through either a special key combination or by dragging and dropping from another application such as Mozilla Firefox. Tomboy functions as a desktop note-taking tool that supports dropping text from other windows.

Getting started with screenlets

You need to install a few things to get started developing screenlets. First, install the screenlets package using either the Ubuntu Software Center or the command line. In the Ubuntu Software Center, type screenlets in the Search box. You should see two options for the main package and a separate installation for the documentation.

Python and Ubuntu

You program screenlets using Python. The basic installation of Ubuntu 10.04 has Python version 2.6 installed, as many utilities depend on it. You may need additional libraries depending on your application's requirements. For the purpose of this article, I installed and tested everything on Ubuntu version 10.04.

Next, download the test screenlet's source from the screenlets.org site. The test screenlet resides in the src/share/screenlets/Test folder and uses Cairo and GTK, which you also need to install. The entire source code for the test program is in the TestScreenlet.py file. Open this file in your favorite editor to see the basic structure of a screenlet.

Python is highly object oriented and as such uses the class keyword to define an object. In this example, the class is named TestScreenlet and has a number of methods defined. In TestScreenlet.py, note the following code at line 42:

def __init__(self, **keyword_args):
Python uses the leading and trailing double underscore (__) notation to identify system functions with predefined behaviors. In this case, the __init__ function is for all intents and purposes the constructor for the class and contains any number of initialization steps to be executed on the creation of a new instance of the object. By convention, the first argument of every class method is a reference to the current instance of the class and is named self. This behavior makes it easy to use self to reference methods and properties of the instance it is in:
self.theme_name = "default"
The screenlets framework defines several naming conventions and standards, as outlined on screenlets.org's developer's page (see Resources for a link). There's a link to the source code for the screenlets package along with the application programming interface (API) documentation. Looking at the code also gives you insight into what each function does with the calling arguments and what it returns.

Writing a simple screenlet

The basic components of a screenlet include an icon file, the source code file, and a themes folder. The themes folder contains additional folders for different themes. You'll find a sample template at screenlets.org with the required files and folders to help you get started.

For this first example, use the template provided to create a basic "Hello World" application. The code for this basic application is shown in Listing 1.

Listing 1. Python code for the Hello World screenlet
	
#!/usr/bin/env python

import screenlets

class HelloWorldScreenlet(screenlets.Screenlet):
    __name__ = 'HelloWorld'
    __version__ = '0.1'
    __author__ = 'John Doe'
    __desc__ = 'Simple Hello World Screenlet'
    
    def __init__(self, **kwargs):
        # Customize the width and height.
        screenlets.Screenlet.__init__(self, width=180, height=50, **kwargs)
    
    def on_draw(self, ctx):
        # Change the color to white and fill the screenlet.
        ctx.set_source_rgb(255, 255, 255)
        self.draw_rectangle(ctx, 0, 0, self.width, self.height)

        # Change the color to black and write the message.
        ctx.set_source_rgb(0, 0, 0)
        text = 'Hello World!'
        self.draw_text(ctx, text, 10, 10, "Sans 9" , 20, self.width)


if __name__ == "__main__":
    import screenlets.session
    screenlets.session.create_session(HelloWorldScreenlet)

Each application must import the screenlets framework and create a new session. There are a few other minimal requirements, including any initialization steps along with a basic draw function to present the widget on screen. The TestScreenlet.py example has an __init__ method that initializes the object. In this case, you see a single line with a call to the screenlet's __init__ method, which sets the initial width and height of the window to be created for this application.

The only other function you need for this application is the on_draw method. This routine sets the background color of the box to white and draws a rectangle with the dimensions defined earlier. It sets the text color to black and the source text to "Hello World!" and then draws the text. ...

Reusing code in a more complex screenlet

One nice thing about writing screenlets is the ability to reuse code from other applications. Code reuse opens a world of possibilities with the wide range of open source projects based on the Python language. Every screenlet has the same basic structure but with more methods defined to handle different behaviors. Listing 2 shows a sample application named TimeTrackerScreenlet.

Listing 2. Python code for the Time Tracker screenlet

	
#!/usr/bin/env python

import screenlets
import cairo
import datetime

class TimeTrackerScreenlet(screenlets.Screenlet):
	__name__ = 'TimeTrackerScreenlet'
	__version__ = '0.1'
	__author__ = 'John Doe'
	__desc__ = 'A basic time tracker screenlet.'
	
	theme_dir = 'themes/default'
	image = 'start.png'

	def __init__(self, **keyword_args):
		screenlets.Screenlet.__init__(self, width=250, height=50, **keyword_args)
		self.add_default_menuitems()
		self.y = 25
		self.theme_name = 'default'
		self.on = False
		self.started = None

	def on_draw(self, ctx):
		self.draw_scaled_image(ctx, 0, 0, self.theme_dir + '/' + 
		self.image, self.width, self.height)
		
	def on_mouse_down(self, event):
		if self.on:
			self.started = datetime.datetime.now()
			self.image = 'stop.png'
			self.on = False
		else:
			if self.started:
				length = datetime.datetime.now() - self.started
				screenlets.show_message(None, '%s seconds' % 
				length.seconds, 'Time')
				self.started = None
			self.image = 'start.png'
			self.on = True

	def on_draw_shape(self, ctx):
		self.on_draw(ctx)
		ctx.rectangle(0, 0, self.width, self.height)
		ctx.fill()
	

if __name__ == "__main__":
	import screenlets.session
	screenlets.session.create_session(TimeTrackerScreenlet)
This example introduces a few more concepts that you need to understand before you start building anything useful. All screenlet applications have the ability to respond to specific user actions or events such as mouse clicks or drag-and-drop operations. In this example, the mouse down event is used as a trigger to change the state of your icon. When the screenlet runs, the start.png image is displayed. Clicking the image changes it to stop.png and records the time started in self.started. Clicking the stop image changes the image back to start.png and displays the amount of time elapsed since the first start image was clicked.

Responding to events is another key capability that makes it possible to build any number of different applications. Although this example only uses the mouse_down event, you can use the same approach for other events generated either by the screenlets framework or by a system event such as a timer. The second concept introduced here is persistent state. Because your application is running continuously, waiting for an event to trigger some action, it is able to keep track of items in memory, such as the time the start image was clicked. You could also save information to disk for later retrieval, if necessary.

Automating tasks with screenlets

Now that you have the general idea behind developing screenlets, let's put all together. Most users these days use a Really Simple Syndication (RSS) reader to read blogs and news feeds. For this last example, you're going to build a configurable screenlet that monitors specific feeds for keywords and displays any hits in a text box. The results will be clickable links to open the post in your default Web browser. Listing 3 shows the source code for the RSS Search screenlet.

Listing 3. Python code for the RSS Search screenlet
	
#!/usr/bin/env python

from screenlets.options import StringOption, IntOption, ListOption
import xml.dom.minidom
import webbrowser
import screenlets
import urllib2
import gobject
import pango
import cairo

class RSSSearchScreenlet(screenlets.Screenlet):
    __name__ = 'RSSSearch'
    __version__ = '0.1'
    __author__ = 'John Doe'
    __desc__ = 'An RSS search screenlet.'
    
    topic = 'Windows Phone 7'
    feeds = ['http://www.engadget.com/rss.xml',
             'http://feeds.gawker.com/gizmodo/full']
    interval = 10
    
    __items = []
    __mousesel = 0
    __selected = None
    
    def __init__(self, **kwargs):
        # Customize the width and height.
        screenlets.Screenlet.__init__(self, width=250, height=300, **kwargs)
        self.y = 25
        
    def on_init(self):
        # Add options.
        self.add_options_group('Search Options',
                               'RSS feeds to search and topic to search for.')
        self.add_option(StringOption('Search Options',
            'topic',
            self.topic,
            'Topic',
            'Topic to search feeds for.'))
        self.add_option(ListOption('Search Options',
                                   'feeds',
                                   self.feeds,
                                   'RSS Feeds',
                                   'A list of feeds to search for a topic.'))
        self.add_option(IntOption('Search Options',
                                  'interval',
                                  self.interval,
                                  'Update Interval',
                                  'How frequently to update (in seconds)'))

        self.update()
        
    def update(self):
        """Search selected feeds and update results."""
        
        self.__items = []

        # Go through each feed.
        for feed_url in self.feeds:
            
            # Load the raw feed and find all item elements.
            raw = urllib2.urlopen(feed_url).read()
            dom = xml.dom.minidom.parseString(raw)
            items = dom.getElementsByTagName('item')
            
            for item in items:
                
                # Find the title and make sure it matches the topic.
                title = item.getElementsByTagName('title')[0].firstChild.data
                if self.topic.lower() not in title.lower(): continue
                
                # Shorten the title to 30 characters.
                if len(title) > 30: title = title[:27]+'...'
                
                # Find the link and save the item.
                link = item.getElementsByTagName('link')[0].firstChild.data
                self.__items.append((title, link))

        self.redraw_canvas()

        # Set to update again after self.interval.
        self.__timeout = gobject.timeout_add(self.interval * 1000, self.update)
        
    def on_draw(self, ctx):
        """Called every time the screenlet is drawn to the screen."""
        
        # Draw the background (a gradient).
        gradient = cairo.LinearGradient(0, self.height * 2, 0, 0)
        gradient.add_color_stop_rgba(1, 1, 1, 1, 1)
        gradient.add_color_stop_rgba(0.7, 1, 1, 1, 0.75)
        ctx.set_source(gradient)
        self.draw_rectangle_advanced (ctx, 0, 0, self.width - 20,
                                      self.height - 20,
                                      rounded_angles=(5, 5, 5, 5),
                                      fill=True, border_size=1,
                                      border_color=(0, 0, 0, 0.25),
                                      shadow_size=10,
                                      shadow_color=(0, 0, 0, 0.25))
        
        # Make sure we have a pango layout initialized and updated.
        if self.p_layout == None :
            self.p_layout = ctx.create_layout()
        else:
            ctx.update_layout(self.p_layout)
            
        # Configure fonts.
        p_fdesc = pango.FontDescription()
        p_fdesc.set_family("Free Sans")
        p_fdesc.set_size(10 * pango.SCALE)
        self.p_layout.set_font_description(p_fdesc)

        # Display our text.
        pos = [20, 20]
        ctx.set_source_rgb(0, 0, 0)
        x = 0
        self.__selected = None
        for item in self.__items:
            ctx.save()
            ctx.translate(*pos)
            
            # Find if the current item is under the mouse.
            if self.__mousesel == x and self.mouse_is_over:
                ctx.set_source_rgb(0, 0, 0.5)
                self.__selected = item[1]
            else:
                ctx.set_source_rgb(0, 0, 0)
            
            self.p_layout.set_markup('%s' % item[0])
            ctx.show_layout(self.p_layout)
            pos[1] += 20
            ctx.restore()
            x += 1

    def on_draw_shape(self, ctx):
        ctx.rectangle(0, 0, self.width, self.height)
        ctx.fill()
        
    def on_mouse_move(self, event):
        """Called whenever the mouse moves over the screenlet."""
        
        x = event.x / self.scale
        y = event.y / self.scale
        self.__mousesel = int((y -10 )/ (20)) -1
        self.redraw_canvas()
    
    def on_mouse_down(self, event):
        """Called when the mouse is clicked."""
        
        if self.__selected and self.mouse_is_over:
            webbrowser.open_new(self.__selected)


if __name__ == "__main__":
    import screenlets.session
    screenlets.session.create_session(RSSSearchScreenlet) 

Building on the concepts of the first two examples, this screenlet uses a number of new concepts, including the config page. In the on_init routine, three options are added for the user to specify: a list of RSS feeds to track, a topic of interest to search for, and an update interval. The update routine then uses all of these when it runs.

Python is a great language for this type of task. The standard library includes everything you need to load the Extensible Markup Language (XML) from an RSS feed into a searchable list. In Python, this takes just three lines of code:

raw = urllib2.urlopen(feed_url).read()
dom = xml.dom.minidom.parseString(raw)
items = dom.getElementsByTagName('item')
The libraries used in these three lines include urllib2 and xml. In the first line, the entire contents found at the feed_url address are read into the string raw. Next, because you know that this string contains XML, you use the Python XML library dom.minidom.parseString method to create a document object made up of node objects.

Finally, you create a list of element objects corresponding to the individual XML elements named item. You can then iterate over this list to search for your target topic. Python has a very elegant way of iterating over a list of items using the for keyword, as in this code snippet:

for item in items:
    # Find the title and make sure it matches the topic.
    title = item.getElementsByTagName('title')[0].firstChild.data
    if self.topic.lower() not in title.lower(): continue

Each item matching your criteria is added to the currently displayed list, which is associated with this instance of the screenlet. Using this approach makes it possible to have multiple instances of the same screenlet running, each configured to search for different topics. The final part of the update function redraws the text with the updated list and fires off a new update timer based on the interval on the config page. By default, the timer fires every 10 seconds, although you could change that to anything you want. The timer mechanism comes from the gobject library, which is a part of the GTK framework.

This application expands the on_draw method quite heavily to accommodate your new functionality. Both the Cairo and Pango libraries make it possible to create some of the effects used in the text window. Using a gradient gives the background of the widget a nice look along with rounded angles and semi-transparency. Using Pango for layout adds a number of functions for saving and restoring the current context easily. It also provides a way to generate scalable fonts based on the current size of the screenlet.

The trickiest part in the on_draw method is handling when a user hovers over an item in the list. Using the for" keyword, you iterate over the items in the screenlet to see whether the user is hovering over that particular item. If so, you set the selected property and change the color to provide visual feedback. You also use a bit of markup to set the link property to bold-probably not the most elegant or efficient way to deal with the problem, but it works. When a user clicks one of the links in the box, a Web browser is launched with the target URL. You can see this functionality in the on_mouse_down function. Python and its libraries make it possible to launch the default web browser to display the desired page with a single line of code. Figure 2 shows an example of this screenlet.

[Dec 25, 2010] Linux Developers choose Python as Best Programming Language and ...

Such polls mainly reflect what industry is using, no so much the quality of the language. In other poll the best Linux distribution is Ubuntu, which is probably the most primitive among the major distributions available.
According to Linux Journal readers, Python is both the best programming language and the best scripting language out there. This year, more than 12,000 developers on weighed in on what tools are helping them work and play as part of the Linux Journal's 2010 Readers' Choice Award - and it came as no surprise to those of us at ActiveState that Python came out on top as both the Best Scripting Language (beating out PHP, bash, PERL and Ruby) - and for the second straight year, Python also won as the Best Programming Language, once again edging out C++, Java, C and Perl for the honors.

At ActiveState, we continue see a steady stream of ActivePython Community Edition downloads, more enterprise deployments of ActivePython Business Edition, and a steady increase in the number of enterprise-ready Python packages in our PyPM Index that are being used by our customers over a wide range of verticals including high-tech, financial services, healthcare, and aerospace companies. Python has matured into an enterprise-class programming language that continues to nuture it's scripting world roots. We're happy to see Python get the recognition that it so justly deserves!

[Dec 25, 2010] Russ's Notes on Python

Those notes span six years. It in six year a person did not switched he/she will never switch...
"I'm not entirely sure why Python has never caught on with me as a language to use on a regular basis. Certainly, one of the things that always bugs me is the lack of good integrated documentation support like POD (although apparently reStructured Text is slowly becoming that), but that's not the whole story. I suspect a lot is just that I'm very familiar with Perl and with its standard and supporting library, and it takes me longer to do anything in Python. But the language just feels slightly more awkward, and I never have gotten comfortable with the way that it uses exceptions for all error reporting. "

On the subject of C program indentation: In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt.

- Blair P. Houghton

Introduction

Around the beginning of April, 2001, I finally decided to do something about the feeling I'd had for some time that I'd like to learn a few new programming languages. I started by looking at Python. These are my notes on the process.

Non-religious comments are welcome. Please don't send me advocacy.

I chose Python as a language to try (over a few other choices like Objective Caml or Common Lisp) mostly because it's less of a departure from the languages that I'm already comfortable with. In particular, it's really quite a bit like Perl. I picked this time to start since I had an idea for an initial program to try writing in Python, a program that I probably would normally write in Perl. I needed a program to help me manage releases of the various software package that I maintain, something to put a new version on an ftp site, update a series of web pages, generate a change log in a nice form for the web, and a few other similar things.

I started by reading the Python tutorial off www.python.org, pretty much straight through. I did keep an interactive Python process running while I did, but I didn't type in many of the examples; the results were explained quite well in the tutorial, and I generally don't need to do things myself to understand them. The tutorial is exceptionally well-written; after finishing reading it straight through (which took me an evening) and skimming the library reference, I felt I had a pretty good grasp on the language.

Things that immediately jumped out at me that I liked a lot:

There were a few things that I immediately didn't like, after having just read the tutorial:

There were also a couple of things that I immediately missed from other languages:

2001-04-08

Over the next few days, I started reading the language manual straight through, as well as poking around more parts of the language reference and writing some code. I started with a function to find the RCS keywords and version string in a file and from that extract the version and the last modified date (things that would need to be modified on the web page for that program). I really had a lot of fun with this.

The Python standard documentation is excellent. I mean truly superb. I can't really compare it to Perl (the other language that has truly excellent standard documentation), since I know Perl so well that I can't evaluate its documentation from the perspective of the beginner, but Python's tutorial eased me into the language beautifully and the language manual is well-written, understandable, and enjoyable to read.

The library reference is well-organized and internally consistent, and I never had much trouble finding things. And they're available in info format as well as web pages, which is a major advantage for me; info is easier for me to read straight through, and web pages are easier for me to browse.

The language proved rather fun to write. Regex handling is a bit clunky since it's not a language built-in, but I was expecting that and I don't really mind it. The syntax is fun, and XEmacs python-mode does an excellent job handling highlighting and indentation. I was able to put together that little function and wrap a test around it fairly quickly (in a couple of hours while on the train, taking a lot of breaks to absorb the language reference manual or poke around in the library reference for the best way of doing something).

That's where I am at the moment. More as I find time to do more....

2001-05-04

I've finished my first Python program, after having gotten distracted by a variety of other things. It wasn't the program I originally started writing, since the problem of releasing a new version of a software package ended up being more complicated than I expected. (In particular, generating the documentation looks like it's going to be tricky.) I did get the code to extract version numbers and dates written, though, and then for another project (automatically generating man pages from scripts with embedded POD when installing them into our site-wide software installation) I needed that same code. So I wrote that program in Python and tested it and it works fine.

The lack of a way to safely execute a program without going through the shell is really bothering me. It was also the source of one of the three bugs in the first pass at my first program; I passed a multiword string to pod2man and forgot to protect it from the shell. What I'm currently doing is still fragile in the presence of single quotes in the string, which is another reason why I much prefer Perl's safe system() function. I feel like I must be missing something; something that fundamental couldn't possibly fail to be present in a scripting language.

A second bug in that program highlights another significant difference from Perl that I'm finding a little strange to deal with, namely the lack of equivalence between numbers and strings. My program had a dictionary of section titles, keyed by the section numbers, and I was using the plain number as the dictionary key. When I tried to look up a title in the dictionary, however, I used as the key a string taken from the end of the output filename, and 1 didn't match "1". It took me a while to track that down. (Admittedly, the problem was really laziness on my part; given the existence of such section numbers as "1m" and "3f", I should have used strings as the dictionary keys in the first place.)

The third bug, for the record, was attempting to use a Perl-like construct to read a file (while line = file.readline():). I see that Python 2.1 has the solution I really want in the form of xreadlines, but in the meantime that was easy enough to recode into a test and a break in the middle of the loop.

The lack of a standard documentation format like Perl's POD is bothering me and I'm not sure what to do about it. I want to put the documentation (preferrably in POD, but I'm willing to learn something else that's reasonably simple) into the same file as the script so that it gets updated when the script does and doesn't get lost in the directory. This apparently is just an unsolved problem, unless I'm missing some great link to an embedded documentation technique (and I quite possibly am). Current best idea is to put a long triple-quoted string at the end of my script containing POD. Ugh.

I took a brief look at the standard getopt library (although I didn't end up using it), and was a little disappointed; one of the features that I really liked about Perl's Getopt::Long was its ability to just stuff either the arguments to options or boolean values into variables directly, without needing something like the long case statement that's a standard feature of main() in many C programs. Looks like Python's getopt is much closer to C's, and requires something quite a bit like that case statement.

Oh, and while the documentation is still excellent, I've started noticing a gap in it when it comes to the core language (not the standard library; the documentation there is great). The language reference manual is an excellent reference manual, complete with clear syntax descriptions, but is a little much if one just wants to figure out how to do something. I wasn't sure of the syntax of the while statement, and the language reference was a little heavier than was helpful. I find myself returning to the tutorial to find things like this, and it has about the right level of explanation, but the problem with that is that the tutorial is laid out as a tutorial and isn't as easy to use as a reference. (For example, the while statement isn't listed in the table of contents, because it was introduced in an earlier section with a more general title.)

I need to get the info pages installed on my desktop machine so that I can look things up in the index easily; right now, I'm still using the documentation on the web.

2001-11-13

I've unfortunately not had very much time to work on this, as one can tell from the date.

Aahz pointed out a way to execute a program without going through the shell, namely os.spawnv(). That works, although the documentation is extremely poor. (Even in Python 2.1, it refers me to the Visual C++ Runtime Library documentation for information on what spawnv does, which is of course absurd.) At least the magic constants that it needs are relatively intuitive. Unfortunately, spawnv doesn't search the user's PATH for a command, and there's nothing like spawnvp. Sigh.

There's really no excuse for this being quite this hard. Executing a command without going through the shell is an extremely basic function that should be easily available in any scripting language without jumping through these sorts of hoops.

But this at least gave me a bit of experience in writing some more Python (a function to search the PATH to find a command), and the syntax is still very nice and convenient. I'm bouncing all over the tutorial and library reference to remember how to do things, but usually my first guesses are right.

I see that Debian doesn't have the info pages, only the HTML documentation. That's rather annoying, but workable. I now have the HTML documentation for Python 2.1 on local disk on my laptop.

2002-07-20

I've now written a couple of real Python programs (in addition to the simple little thing to generate man pages by running pod2man). You can find them (cvs2xhtml and cl2xhtml) with my web tools. They're not particularly pretty, but they work, and I now have some more experience writing simple procedural Python code. I still haven't done anything interesting with objects. Comments on the code are welcome. Don't expect too much.

There are a few other documentation methods for Python, but they seem primarily aimed at documenting modules and objects rather than documenting scripts. Pydoc in particular looks like it would be nice for API documentation but doesn't really do anything for end-user program documentation. Accordingly, I've given up for the time being on finding a more "native" approach and am just documenting my Python programs the way that I document most things, by writing embedded POD. I've yet to find a better documentation method; everything else seems to either be far too complicated and author-unfriendly to really write directly in (like DocBook) or can't generate Unix man pages, which I consider to be a requirement.

The Python documentation remains excellent, if scattered. I've sometimes spent a lot of time searching through the documentation to find the right module to do something, and questions of basic syntax are fairly hard to resolve (the tutorial is readable but not organized as a reference, and the language reference is too dense to provide a quick answer).

2004-03-03

My first major Python application is complete and working (although I'm not yet using it as much as I want to be using it). That's Tasker, a web-based to-do list manager written as a Python CGI script that calls a Python module.

I've now dealt with the Python module building tools, which are quite nice (nicer in some ways than Perl's Makefile.PL system with some more built-in functionality, although less mature in a few ways). Python's handling of the local module library is clearly less mature than Perl, and Debian's Python packages don't handle locally installed modules nearly as well as they should, but overall it was a rather positive experience. Built-in support for generating RPMs is very interesting, since eventually I'd like to provide .deb and RPM packages for all my software.

I played with some OO design for this application and ended up being fairly happy with how Python handled things. I'm not very happy with my object layout, but that's my problem, not Python's. The object system definitely feels far smoother and more comfortable to me than Perl's, although I can still write OO code faster in Perl because I'm more familiar with it. There's none of the $self hash nonsense for instance variables, though, which is quite nice.

The CGI modules for Python, and in particular the cgitb module for displaying exceptions nicely in the browser while debugging CGI applications, are absolutely excellent. I was highly impressed, and other than some confusion about the best way to retrieve POST data that was resolved after reading the documentation more closely, I found those modules very easy to work. The cgitb module is a beautiful, beautiful thing and by itself makes me want to use Python for all future CGI programming.

I still get caught all the time by the lack of interchangability of strings and numbers and I feel like I'm casting things all the time. I appreciate some of the benefits of stronger typing, but this one seems to get in my way more often than it helps.

I'm also still really annoyed at the lack of good documentation for the parts of the language that aren't considered part of the library. If I want documentation on how print works, I have only the tutorial and the detailed language standard, the former of which is not organized for reference and the latter of which is far too hard to understand. This is a gaping hole in the documentation that I really wish someone would fix. Thankfully, it only affects a small handful of things, like control flow constructs and the print statement, so I don't hit this very often, but whenever I do it's extremely frustrating.

I've given up on documentation for scripts and am just including a large POD section at the end of the script, since this seems to be the only option that will generate good man pages and good web pages. I'm not sure what to do about documentation for the module; there seem to be a variety of different proposals but nothing that I can really just use.

Oh, and one last point on documentation: the distutils documentation needs some work. Thankfully I found some really good additional documentation on the PyPI web site that explained a lot more about how to write a setup.py script.

2010-03-25

Six years later, I still find Python an interesting language, but I never got sufficiently absorbed by it for it to be part of my standard toolkit.

I've subsequently gotten some additional experience with extending Python through incorporating an extension written by Thomas Kula into the remctl distribution. The C interface is relatively nice and more comfortable than Perl, particularly since it doesn't involve a pseudo-C that is run through a preprocessor. It's a bit more comfortable to read and write.

Python's installation facilities, on the other hand, are poor. The distutils equivalent of Perl's ExtUtils::MakeMaker is considerably worse, despite ExtUtils::MakeMaker being old and crufty and strange. (I haven't compared it with Module::Build.) The interface is vaguely similar, but I had to apply all sorts of hacks to get the Python extension to build properly inside a Debian packaging framework, and integrating it with a larger package requires doing Autoconf substitution on a ton of different files. It was somewhat easier to avoid embedding RPATH into the module, but I'd still much rather work with Perl's facilities.

Similarly, while the test suite code has some interesting features (I'm using the core unittest framework), it's clearly inferior to Perl's Test::More support library and TAP protocol. I'm, of course, a known fan of Perl's TAP testing protocol (I even wrote my own implementation in C), but that's because it's well-designed, full-featured, and very useful. The Python unittest framework, by comparison, is awkward to use, has significantly inferior reporting capabilities, makes it harder to understand what test failed and isolate the failure, and requires a lot of digging around to understand how it works. I do like the use of decorators to handle skipping tests, and there are some interesting OO ideas around test setup and teardown, but the whole thing is more awkward than it should be.

I'm not entirely sure why Python has never caught on with me as a language to use on a regular basis. Certainly, one of the things that always bugs me is the lack of good integrated documentation support like POD (although apparently reStructured Text is slowly becoming that), but that's not the whole story. I suspect a lot is just that I'm very familiar with Perl and with its standard and supporting library, and it takes me longer to do anything in Python. But the language just feels slightly more awkward, and I never have gotten comfortable with the way that it uses exceptions for all error reporting.

I may get lured back into it again at some point, though, since Python 3.0 seems to have some very interesting features and it remains popular with people who know lots of programming languages. I want to give it another serious look with a few more test projects at some point in the future.

[Aug 18, 2009] THE NEXT SNAKE BY RAINER GRIMM

What do Python 2.x programmers need to know about Python 3?

With the latest major Python release, creator Guido van Rossum saw the opportunity to tidy up his famous scripting language. What is different about Python 3.0? In this article, I offer some highlights for Python programmers who are thinking about making the switch to 3.x.

Read full article as PDF "

[Jun 20, 2009] A Python Client/Server Tutorial by Phillip Watts

June 16, 2009

There can be many reasons why you might need a client/server application. For a simple example, purchasing for a small retail chain might need up to the minute stock levels on a central server. The point-of-sale application in the stores would then need to post inventory transactions to the central server in real-time.

This application can easily be coded in Python with performance levels of thousands of transactions per second on a desktop PC. Simple sample programs for the server and client sides are listed below, with discussions following.

[Jul 8, 2008] Python Call Graph 0.5.1 by Gerald Kaszuba

About: pycallgraph is a Python library that creates call graphs for Python programs.

About: pycallgraph is a Python library that creates call graphs for Python programs.

Changes: The "pycg" command line tool was renamed to "pycallgraph" due to naming conflicts with other packages.

[Jun 23, 2008] freshmeat.net Project details for cfv

About:
cfv is a utility to both test and create .sfv (Simple File Verify), .csv, .crc, .md5(sfv style), md5sum, BSD md5, sha1sum, and .torrent checksum verification files. It also includes test-only support for .par and .par2 files. These files are commonly used to ensure the correct retrieval or storage of data.

Release focus: Major bugfixes

Changes:
Help output is printed to stdout under non-error conditions. A mmap file descriptor leak in Python 2.4.2 was worked around. The different module layout of BitTorrent 5.x is supported. A "struct integer overflow masking is deprecated" warning was fixed. The --private_torrent flag was added. A bug was worked around in 64-bit Python version 2.5 and later which causes checksums of files larger than 4GB to be incorrectly calculated when using mmap.

[Jun 20, 2008] BitRock Download Web Stacks

BitRock Web Stacks provide you with the easiest way to install and run the LAMP platform in a variety of Linux distributions. BitRock Web Stacks are free to download and use under the terms of the Apache License 2.0. To learn more about our licensing policies, click here.

You can find up-to-date WAMP, LAMP and MAMP stacks at the BitNami open source website. In addition to those, you will find freely available application stacks for popular open source software such as Joomla!, Drupal, Mediawiki and Roller. Just like BitRock Web Stacks, they include everything you need to run the software and come packaged in a fast, easy to use installer.

BitRock Web Stacks contain several open source tools and libraries. Please be sure that you read and comply with all of the applicable licenses. If you are a MySQL Network subscriber (or would like to purchase a subscription) and want to use a version of LAMPStack that contains the MySQL Certified binaries, please send an email to sales@bitrock.com.

For further information, including supported platforms, component versions, documentation, and support, please visit our solutions section.

[Mar 12, 2008] Terminator - Multiple GNOME terminals in one window

Rewrite of screen in Python?

This is a project to produce an efficient way of filling a large area of screen space with terminals. This is done by splitting the window into a resizeable grid of terminals. As such, you can produce a very flexible arrangements of terminals for different tasks.

Read me

Terminator 0.8.1
by Chris Jones <cmsj@tenshu.net>

This is a little python script to give me lots of terminals in a single window, saving me valuable laptop screen space otherwise wasted on window decorations and not quite being able to fill the screen with terminals.

Right now it will open a single window with one terminal and it will (to some degree) mirror the settings of your default gnome-terminal profile in gconf. Eventually this will be extended and improved to offer profile selection per-terminal, configuration thereof and the ability to alter the number of terminals and save meta-profiles.

You can create more terminals by right clicking on one and choosing to split it vertically or horizontally. You can get rid of a terminal by right clicking on it and choosing Close. ctrl-shift-o and ctrl-shift-e will also effect the splitting.

ctrl-shift-n and ctrl-shift-p will shift focus to the next/previous terminal respectively, and ctrl-shift-w will close the current terminal and ctrl-shift-q the current window

Ask questions at: https://answers.launchpad.net/terminator/
Please report all bugs to https://bugs.launchpad.net/terminator/+filebug

It's quite shamelessly based on code in the vte-demo.py from the vte widget package, and on the gedit terminal plugin (which was fantastically useful).

vte-demo.py is not my code and is copyright its original author. While it does not contain any specific licensing information in it, the VTE package appears to be licenced under LGPL v2.

the gedit terminal plugin is part of the gedit-plugins package, which is licenced under GPL v2 or later.

I am thus licensing Terminator as GPL v2 only.

Cristian Grada provided the icon under the same licence.

[Apr 3, 2007] Charming Python Python elegance and warts, Part 1

Generators as not-quite-sequences

Over several versions, Python has hugely enhanced its "laziness." For several versions, we have had generators defined with the yield statement in a function body. But along the way we also got the itertools modules to combine and create various types of iterators. We have the iter() built-in function to turn many sequence-like objects into iterators. With Python 2.4, we got generator expressions, and with 2.5 we will get enhanced generators that make writing coroutines easier. Moreover, more and more Python objects have become iterators or iterator-like; for example, what used to require the .xreadlines() method or before that the xreadlines module, is now simply the default behavior of open() to read files.

Similarly, looping through a dict lazily used to require the .iterkeys() method; now it is just the default for key in dct behavior. Functions like xrange() are a bit "special" in being generator-like, but neither quite a real iterator (no .next() method), nor a realized list like range() returns. However, enumerate() returns a true generator, and usually does what you had earlier wanted xrange() for. And itertools.count() is another lazy call that does almost the same thing as xrange(), but as a full-fledged iterator.

Python is strongly moving towards lazily constructing sequence-like objects; and overall this is an excellent direction. Lazy pseudo-sequences both save memory space and speed up operations (especially when dealing with very large sequence-like "things").

The problem is that Python still has a schizoaffective condition when it comes to deciding what the differences and similarities between "hard" sequences and iterators are. The troublesome part of this is that it really violates Python's idea of "duck typing": the ability to use a given object for a purpose just as long as it has the right behaviors, but not necessarily any inheritance or type restriction. The various things that are iterators or iterator-like sometimes act sequence-like, but other times do not; conversely, sequences often act iterator-like, but not always. Outside of those steeped in Python arcana, what does what is not obvious.

Divergences

The main point of similarity is that everything that is sequence- or iterator-like lets you loop over it, whether using a for loop, a list comprehension, or a generator comprehension. Past that, divergences occur. The most important of these differences is that sequences can be indexed, and directly sliced, while iterators cannot. In fact, indexing into a sequence is probably the most common thing you ever do with a sequence -- why on earth does it fall down so badly on iterators? For example:


Listing 9. Sequence-like and iterator-like things
>>> r = range(10)

>>> i = iter(r)

>>> x = xrange(10)

>>> g = itertools.takewhile(lambda n: n<10, itertools.count())

#...etc...

For all of these, you can use for n in thing. In fact, if you "concretize" any of them with list(thing), you wind up with exactly the same result. But if you wish to obtain a specific item -- or a slice of a few items -- you need to start caring about the exact type of thing. For example:


Listing 10. When indexing succeeds and fails
>>> r[4]
4

>>> i[4]
TypeError: unindexable object

With enough contortions, you can get an item for every type of sequence/iterator. One way is to loop until you get there. Another hackish combination might be something like:


Listing 11. Contortions to obtain an index
>>> thing, temp = itertools.tee(thing)

>>> zip(temp, '.'*5)[-1][0]
4

The pre-call to itertools.tee() preserves the original iterator. For a slice, you might use the itertools.islice() function, wrapped up in contortions.


Listing 12. Contortions to obtain a slice
>>> r[4:9:2]
[4, 6, 8]

>>> list(itertools.islice(r,4,9,2))  # works for iterators
[4, 6, 8]

A class wrapper

You might combine these techniques into a class wrapper for convenience, using some magic methods:


Listing 13. Making iterators indexable
>>> class Indexable(object):
...     def __init__(self, it):
...         self.it = it
...     def __getitem__(self, x):
...         self.it, temp = itertools.tee(self.it)
...         if type(x) is slice:
...             return list(itertools.islice(self.it, x.start, x.stop, x.step))
...         else:
...             return zip(temp, range(x+1))[-1][0]
...     def __iter__(self):
...         self.it, temp = itertools.tee(self.it)
...         return temp
...

>>> integers = Indexable(itertools.count())

>>> integers[4]
4
>>> integers[4:9:2]
[4, 6, 8]
      

So with some effort, you can coax an object to behave like both a sequence and an iterator. But this much effort should really not be necessary; indexing and slicing should "just work" whether a concrete sequence or a iterator is involved.

Notice that the Indexable class wrapper is still not as flexible as might be desirable. The main problem is that we create a new copy of the iterator every time. A better approach would be to cache the head of the sequence when we slice it, then use that cached head for future access of elements already examined. Of course, there is a trade-off between memory used and the speed penalty of running through the iterator. Nonetheless, the best thing would be if Python itself would do all of this "behind the scenes" -- the behavior might be fine-tuned somehow by "power users," but average programmers should not have to think about any of this.

In the next installment in this series, I'll discuss accessing methods using attribute syntax.

[Oct 26, 2006] ONLamp.com -- What's New in Python 2.5

It's clear that Python is under pressure from Ruby :-)

It's hard to believe Python is more than 15 years old already. While that may seem old for a programming language, in the case of Python it means the language is mature. In spite of its age, the newest versions of Python are powerful, providing everything you would expect from a modern programming language.

This article provides a rundown of the new and important features of Python 2.5. I assume that you're familiar with Python and aren't looking for an introductory tutorial, although in some cases I do introduce some of the material, such as generators.

[Sep 30, 2006] Python 2.5 Release We are pleased to announce the release of Python 2.5 (FINAL), the final, production release of Python 2.5, on September 19th, 2006.

with open('/etc/passwd', 'r') as f:
    for line in f:
        print line
        ... more processing code ...
why to stray from mainstream C-style is unlear to me. When developing computer language syntax, natural language imitation should not be the priority - also being different for the sake of being different is so very early 90s
cout << ( a==b ? "first option" : "second option" )

[Sept 20, 2006] Python 101 cheat sheet

[01 Feb 2000] Python columnist Evelyn Mitchell brings you a quick reference and learning tools for newbies who want to get to know the language. Print it, keep it close at hand, and get down to programming!

[Jul 27, 2006] Microsoft Ships Python on .Net by Darryl K. Taft

eWeek

Microsoft has shipped the release candidate for IronPython 1.0 on its CodePlex community source site.

In a July 25 blog post, S. "Soma" Somasegar, corporate vice president of Microsoft's developer division, praised the team for getting to a release candidate for a dynamic language that runs on the Microsoft CLI (Common Language Infrastructure). Microsoft designed the CLI to support a variety of programming languages. Indeed, "one of the great features of the .Net framework is the Common Language Infrastructure," Somasegar said.

"IronPython is a project that implements the dynamic object-oriented Python language on top of the CLI," Somasegar said. IronPython is both well-integrated with the .Net Framework and is a true implementation of the Python language, he said.

And ".Net integration means that this rich programming framework is available to Python developers and that they can interoperate with other .Net languages and tools," Somasegar said. "All of Python's dynamic features like an interactive interpreter, dynamically modifying objects and even metaclasses are available. IronPython also leverages the CLI to achieve good performance, running up to 1.5 times faster than the standard C-based Python implementation on the standard Pystone benchmark."

Click here to read an eWEEK interview with Python creator Guido van Rossum.

Moreover, the download of the release candidate for IronPython 1.0 "includes a tutorial which gives .Net programmers a great way to get started with Python and Python programmers a great way to get started with .Net," Somasegar said.

Somasegar said he finds it "exciting to see that the Visual Studio SDK [software development kit] team has used the IronPython project as a chance to show language developers how they can build support for their language into Visual Studio. They have created a sample, with source, that shows some of the basics required for integrating into the IDE including the project system, debugger, interactive console, IntelliSense and even the Windows forms designer. "

IronPython is the creation of Jim Hugunin, a developer on the Microsoft CLR (Common Language Runtime) team. Hugunin joined Microsoft in 2004.

In a statement written in July 2004, Hugunin said: "My plan was to do a little work and then write a short pithy article called, 'Why .Net is a terrible platform for dynamic languages.' My plans changed when I found the CLR to be an excellent target for the highly dynamic Python language. Since then I've spent much of my spare time working on the development of IronPython."

However, Hugunin said he grew frustrated with the slow pace of progress he could make by working on the project only in his spare time, so he decided to join Microsoft.

IronPython is governed by Microsoft's Shared Source license.

Dig Deep into Python Internals by Gigi Sayfan Part 1 of 2

Python's objects are basically a bunch of attributes. These attributes include the type of the object, fields, methods, and base classes. Attributes are also objects, accessible through their containing objects.
Python, the open source scripting language, has grown tremendously popular in the last five years-and with good reason. Python boasts a sophisticated object model that wise developers can exploit in ways that Java, C++, and C# developers can only dream of.

This article is the first in a two-part series that will dig deep to explore the fascinating new-style Python object model, which was introduced in Python 2.2 and improved in 2.3 and 2.4. The object model and type system are very dynamic and allow quite a few interesting tricks. In this article I will describe the object, model, and type system; explore various entities; explain the life cycle of an object; and introduce some of the countless ways to modify and customize almost everything you thought immutable at runtime.

The Python Object Model

Python's objects are basically a bunch of attributes. These attributes include the type of the object, fields, methods, and base classes. Attributes are also objects, accessible through their containing objects.

The built-in dir() function is your best friend when it comes to exploring python objects. It is designed for interactive use and, thereby, returns a list of attributes that the implementers of the dir function thought would be relevant for interactive exploration. This output, however, is just a subset of all the attributes of the object. The code sample below shows the dir function in action. It turns out that the integer 5 has many attributes that seem like mathematical operations on integers.


dir(5)

['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', 
'__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getnewargs__', 
'__hash__', '__hex__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__',
'__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '
__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__',
'__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__',
'__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__str__', '__sub__', '__truediv__', '__xor__']
The function foo has many attributes too. The most important one is __call__ which means it is a callable type. You do want to call your functions, don't you?

def foo()
      pass
...
dir(foo)

['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', '__getattribute__',
'__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 
'func_doc', 'func_globals', 'func_name']
Next I'll define a class called 'A' with two methods, __init__ and dump, and an instance field 'x' and also an instance 'a' of this class. The dir function shows that the class's attributes include the methods and the instance has all the class attributes as well as the instance field.

>>> class A(object):
...     def __init__(self):
...             self.x = 3
...     def dump(self):
...             print self.x
...
>>> dir(A)

['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', 
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 
'__weakref__', 'dump']

>>> a = A()
>>> dir(a)

['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__',
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__weakref__', 'dump', 'x']

The Python Type System
Python has many types. Much more than you find in most languages (at least explicitly). This means that the interpreter has a lot of information at runtime and the programmer can take advantage of it by manipulating types at runtime. Most types are defined in the types module, which is shown in the code immediately below. Types come in various flavors: There are built-in types, new-style classes (derived from object), and old-style classes (pre Python 2.2). I will not discuss old-style classes since they are frowned upon by everybody and exist only for backward compatibility.


>>> import types
>>> dir(types)

['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType',
'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 
'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'InstanceType', 'IntType', 'LambdaType',
'ListType', 'LongType', 'MethodType', 'ModuleType', 'NoneType', 'NotImplementedType', 'ObjectType',
'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 
'UnboundMethodType', 'UnicodeType', 'XRangeType', '__builtins__', '__doc__', '__file__', '__name__']
Python's type system is object-oriented. Every type (including built-in types) is derived (directly or indirectly) from object. Another interesting fact is that types, classes and functions are all first-class citizens and have a type themselves. Before I delve down into some juicy demonstrations let me introduce the built-in function 'type'. This function returns the type of any object (and also serves as a type factory). Most of these types are listed in the types module, and some of them have a short name. Below I've unleashed the 'type' function on several objects: None, integer, list, the object type, type itself, and even the 'types' module. As you can see the type of all types (list type, object, and type itself) is 'type' or in its full name types.TypeType (no kidding, that's the name of the type).

>>> type(None)
<type 'NoneType'>

>>> type(5)
<type 'int'>

>>> x = [1,2,3]
>>> type(x)
<type 'list'>

>>> type(list)
<type 'type'> 

>>> type(type)
<type 'type'>

>>> type(object)
<type 'type'>
>>>

>>> import types
>>> type(types)
<type 'module'>

>>> type==types.TypeType
True
What is the type of classes and instances? Well, classes are types of course, so their type is always 'type' (regardless of inheritance). The type of class instances is their class.

>>> class A(object):
...     pass


>>> a = A()

>>> type(A)
<type 'type'>

>>> type(a)
<class '__main__.A'>

>>> a.__class__
<class '__main__.A'>
It's time for the scary part-a vicious cycle: 'type' is the type of object, but object is the base class of type. Come again? 'type' is the type of object, but object is the base class of type. That's right-circular dependency. 'object' is a 'type' and 'type' is an 'object'.

>>> type(object)
<type 'type'>

>>> type.__bases__
(<type 'object'>,)

>>> object.__bases__
()
How can it be? Well, since the core entities in Python are not implemented themselves in Python (there is PyPy but that's another story) this is not really an issue. The 'object' and 'type' are not really implemented in terms of each other.

The one important thing to take home from this is that types are objects and are therefore subject to all the ramifications thereof. I'll discuss those ramifications very shortly.

Instances, Classes, Class Factories, and Metaclasses
When I talk about instances I mean object instances of a class derived from object (or the object class itself). A class is a type, but as you recall it is also an object (of type 'type'). This allows classes to be created and manipulated at runtime. This code demonstrates how to create a class at runtime and instantiate it.


def init_method(self, x, y):
      self.x = x
      self.y = y
def dumpSum_method(self):
      print self.x + self.y

D = type('DynamicClass',
                   (object,),
                   {'__init__':init_method, 'dumpSum':dumpSum_method})
d = D(3, 4)
d.dumpSum()
As you can see I created two functions (init_method and dumpSum_method) and then invoked the ubiquitous 'type' function as a class factory to create a class called 'DynamicClass,' which is derived from 'object' and has two methods (one is the __init__ constructor).

It is pretty simple to create the functions themselves on the fly too. Note that the methods I attached to the class are regular functions that can be called directly (provided their self-argument has x and y members, similar to C++ template arguments).

Functions, Methods and other Callables
Python enjoys a plethora of callable objects. Callable objects are function-like objects that can be invoked by calling their () operator. Callable objects include plain functions (module-level), methods (bound, unbound, static, and class methods) and any other object that has a __call__ function attribute (either in its own dictionary, via one of its ancestors, or through a descriptor).

It's truly complicated so the bottom line is to remember that all these flavors of callables eventually boil down to a plain function. For example, in the code below the class A defines a method named 'foo' that can be accessed through:

  1. an instance so it is a bound method (bound implicitly to its instance)
  2. through the class A itself and then it is an unbound method (the instance must be supplied explicitly)
  3. directly from A's dictionary, in which case it is a plain function (but you must still call it with an instance of A).
So, all methods are actually functions but the runtime assigns different types depending on how you access it.

class A(object):
    def foo(self):
        print 'I am foo'

>>> a = A()
>>> a.foo
<bound method A.foo of <__main__.A object at 0x00A13EB0>>

>>> A.foo
<unbound method A.foo>

>>> A.__dict__['foo']
<function foo at 0x00A0A3F0>
>>> a.foo

>>> a.foo()
I am foo
>>> A.foo(a)
I am foo
>>> A.__dict__['foo'](a)
I am foo
Let's talk about static methods and class methods. Static methods are very simple. They are similar to static methods in Java/C++/C#. They are scoped by their class but they don't have a special first argument like instance methods or class methods do; they act just like a regular function (you must provide all the arguments since they can't access any instance fields). Static methods are not so useful in Python because regular module-level functions are already scoped by their module and they are the natural mapping to static methods in Java/C++/C#.

Class methods are an exotic animal. Their first argument is the class itself (traditionally named cls) and they are used primarily in esoteric scenarios. Static and class methods actually return a wrapper around the original function object. In the code that follows, note that the static method may be accessed either through an instance or through a class. The class method accepts a cls instance as its first argument but cls is invoked through a class directly (no explicit class argument). This is different from an unbound method where you have to provide an instance explicitly as first argument.


class A(object):
    def foo():
        print 'I am foo'
    def foo2(cls):
        print 'I am foo2', cls 
    def foo3(self):
        print 'I am foo3', self       
    foo=staticmethod(foo)
    foo2=classmethod(foo2)
        
>>> a = A()
>>> a.foo()
I am foo

>>> A.foo()
I am foo

>>> A.foo2()
I am foo2 <class '__main__.A'>

>>> a.foo3()
I am foo3 <__main__.A object at 0x00A1AA10>
Note that classes are callable objects by themselves and operate as instance factories. When you "call" a class you get an instance of that class as a result.

A different kind of callable object is an object that has a __call__ method. If you want to pass around a function-like object with its context intact, __call__ can be a good thing. Listing 1 features a simple 'add' function that can be replaced with a caching adder class that stores results of previous calculations. First, notice that the test function expects a function-like object called 'add' and it just invokes it as a function. The 'test' function is called twice-once with a simple function and a second time with the caching adder instance. Continuations in Python can also be implemented using __call__ but that's another article.

Metaclasses
Metaclasse is a concept that doesn't exist in today's mainstream programming languages. A metaclass is a class whose instances are classes. You already encountered a meta-class in this article called 'type'. When you invoke "type" with a class name, a base-classes tuple, and an attribute dictionary, the method creates a new user-defined class of the specified type. So the __class__ attribute of every class always contains its meta-class (normally 'type').

That's nice, but what can you do with a metaclass? It turns out, you can do plenty. Metaclasses allow you to control everything about the class that will be created: name, base classes, methods, and fields. How is it different from simply defining any class you want or even creating a class dynamically on the fly? Well, it allows you to intercept the creation of classes that are predefined as in aspect-oriented programming. This is a killer feature that I'll be discussing in a follow-up to this article.

After a class is defined, the interpreter looks for a meta-class. If it finds one it invokes its __init__ method with the class instance and the meta-class gets a stab at modifying it (or returning a completely different class). The interpreter will use the class object returned from the meta-class to create instances of this class.

So, how do you stick a custom metaclass on a class (new-style classes only)? Either you declare a __metaclass__ field or one of your ancestors has a __metaclass__ field. The inheritance method is intriguing because Python allows multiple inheritance. If you inherit from two classes that have custom metaclasses you are in for a treat-one of the metaclasses must derive from another. The actual metaclass of your class will be the most derived metaclass:


class M1(type): pass
class M2(M1):   pass

class C2(object): __metaclass__=M2    
class C1(object): __metaclass__=M1
class C3(C1, C2): pass


classes = [C1, C2, C3]
for c in classes:
    print c, c.__class__
    print '------------'                 

Output:
    
<class '__main__.C1'> <class '__main__.M1'>
------------
<class '__main__.C2'> <class '__main__.M2'>
------------
<class '__main__.C3'> <class '__main__.M2'>

Day In The Life of a Python Object
To get a feel for all the dynamics involved in using Python objects let's track a plain object (no tricks) starting from its class definition, through its class instantiation, access its attributes, and see it to its demise. Later on I'll introduce the hooks that allow you to control and modify this workflow.

The best way to go about it is with a monstrous simulation. Listing 2 contains a simulation of a bunch of monsters chasing and eating some poor person. There are three classes involved: a base Monster class, a MurderousHorror class that inherits from the Monster base class, and a Person class that gets to be the victim. I will concentrate on the MurderousHorror class and its instances.

Class Definition
MurderousHorror inherits the 'frighten' and 'eat' methods from Monster and adds a 'chase' method and a 'speed' field. The 'hungry_monsters' class field stores a list of all the hungry monsters and is always available through the class, base class, or instance (Monster.hungry_monsters, MurderousHorror.hungry_monsters, or m1.hungry_monsters). In the code below you can see (via the handy 'dir' function) the MurderousHorror class and its m1 instance. Note that methods such as 'eat,' 'frighten,' and 'chase' appear in both, but instance fields such as 'hungry' and 'speed' appear only in m1. The reason is that instance methods can be accessed through the class as unbound methods, but instance fields can be accessed only through an instance.


class NoInit(object):
    def foo(self):
        self.x = 5
        
    def bar(self):
        print self.x
                            
if __name__ == '__main__':            
    ni = NoInit()
    assert(not ni.__dict__.has_key('x'))
    try:
        ni.bar()
    except AttributeError, e:
        print e
    ni.foo()
    assert(ni.__dict__.has_key('x'))
    ni.bar()
    
Output:

'NoInit' object has no attribute 'x'
5
Object Instantiation and Initialization
Instantiation in Python is a two-phase process. First, __new__ is called with the class as a first argument, and later as the rest of the arguments, and should return an uninitialized instance of the class. Afterward, __init__ is called with the instance as first argument. (You can read more about __new__ in the Python reference manual.)

When a MurderousHorror is instantiated __init__ is the first method called. __init__ is similar to a constructor in C++/Java/C#. The instance calls the Monster base class's __init__ and initializes its speed field. The difference between Python and C++/Java/C# is that in Python there is no notion of a parameter-less default constructor, which, in other languages, is automatically generated for every class that doesn't have one. Also, there is no automatic call to the base class' default __init__ if the derived class doesn't call it explicitly. This is quite understandable since no default __init__ is generated.

In C++/Java/C# you declare instance variables in the class body. In Python you define them inside a method by explicitly specifying 'self.SomeAttribute'. So, if there is no __init__ method to a class it means its instances have no instance fields initially. That's right. It doesn't HAVE any instance fields. Not even uninitialized instance fields.

The previous code sample (above) is a perfect example of this phenomenon. The NoInit class has no __init__ method. The x field is created (put into its __dict__) only when foo() is called. When the program calls ni.bar() immediately after instantiation the 'x' attribute is not there yet, so I get an 'AttributeError' exception. Because my code is robust, fault tolerant, and self healing (in carefully staged toy programs), it bravely recovers and continues to the horizon by calling foo(), thus creating the 'x' attribute, and ni.bar() can print 5 successfully.

Note that in Python __init__ is not much more then a regular method. It is called indeed on instantiation, but you are free to call it again after initialization and you may call other __init__ methods on the same object from the original __init__. This last capability is also available in C#, where it is called constructor chaining. It is useful when you have multiple constructors that share common initialization, which is also one of the constructors/initializers. In this case you don't need to define another special method that contains the common code and call it from all the constructors/initializers; you can just call the shared constructor/initializer directly from all of them.

Attribute Access
An attribute is an object that can be accessed from its host using the dot notation. There is no difference at the attribute access level between methods and fields. Methods are first-class citizens in Python. When you invoke a method of an object, the method object is looked up first using the same mechanism as a non-callable field. Then the () operator is applied to the returned object. This example demonstrates this two-step process:


class A(object):
    def foo(self):
        print 3
                            
if __name__ == '__main__':            
    a = A()
    f = a.foo
    print f
    print f.im_self
    a.foo()
    f()
    
    
Output:

<bound method A.foo of <__main__.A object at 0x00A03EB0>>
<__main__.A object at 0x00A03EB0>
3
3
The code retrieves the a.foo bound method object and assigns it to a local variable 'f'. 'f' is a bound method object, which means its im_self attribute points to the instance to which it is bound. Finally, a.foo is invoked through the instance (a.foo()) and by calling f directly with identical results. Assigning bound methods to local variables is a well known optimization technique due to the high cost of attribute lookup. If you have a piece of Python code that seems to perform under the weather there is a good chance you can find a tight loop that does a lot of redundant lookups. I will talk later about all the ways you can customize the attribute access process and why it is so costly.

Destruction
The __del__ method is called when an instance is about to be destroyed (its reference count reaches 0). It is not guaranteed that the method will ever be called in situations such as circular references between objects or references to the object in an exception. Also the implementation of __del__ may create a new reference to its instance so it will not be destroyed after all. Even when everything is simple and __del__ is called, there is no telling when it will actually be called due to the nature of the garbage collector. The bottom line is if you need to free some scarce resource attached to an object do it explicitly when you are done using it and don't wait for __del__.

A try-finally block is a popular choice for garbage collection since it guarantees the resource will be released even in the face of exceptions. The last reason not to use is __del__ is that its interaction with the 'del' built-in function may confuse programmers. 'del' simply decrements the reference count by 1 and doesn't call '__del__' or cause the object to be magically destroyed. In the next code sample I use the sys.getrefcount() function to determine the reference count to an object before and after calling 'del'. Note that I subtract 1 from sys.getrefcount() result because it also counts the temporary reference to its own argument.


import sys

class A(object):
    def __del__(self):
        print "That's it for me"
                            
if __name__ == '__main__':            
    a = A()
    b = a
    print sys.getrefcount(a)-1
    del b
    print sys.getrefcount(a)-1

Output:

2
1
That's it for me


Hacking Python

Let the games begin. In this section I will explore different ways to customize attribute access. The topics include the __getattribute__ hook, descriptors, and properties.


- __getattr__, __setattr__ and __getattribute__
These special methods control attribute access to class instances. The standard algorithm for attribute lookup returns an attribute from the instance dictionary or one of its base class's dictionaries (descriptors will be described in the next section). They are supposed to return an attribute object or raise AttributeError exception. If you define some of these methods in your class they will be called upon during attribute access under some conditions. Listing 3 is an interactive example. It is designed to allow you to play around with it and comment out various functions to see the effect. It introduces the class A with a single 'x' attribute. It has __getattr__, __setattr__, and __getattribute__ methods. __getattribute__ and __setattr__ simply forward any attribute access to the default (lookup or set value in dictionary). __getattr__ always returns 7. The main program starts by assigning 6 to the non-existing attribute 'y' (happens via __setattr__) and then prints the preexisting 'x', the newly created 'y', and the still non-existent 'z'. 'x' and 'y' exist now, so they are accessible via __getattribute__. 'z' doesn't exist so __getattribute__ fails and __getattr__ gets called and returns 7. (Author's Note: This is contrary to the documentation. The documentation claims if __getattribute__ is defined, __getattr__ will never be called, but this is not the actual behavior.)

Descriptors
A descriptor is an object that implements three methods __get__, __set__, and __delete__. If you put such a descriptor in the __dict__ of some object then whenever the attribute with the name of the descriptor is accessed one of the special methods is executed according to the access type (__get__ for read, __set__ for write, and __delete__ for delete).This simple enough indirection scheme allows total control on attribute access.

The following code sample shows a silly write-only descriptor used to store passwords. Its value may not be read nor deleted (it throws AttributeError exception). Of course the descriptor object itself and the password can be accessed directly through A.__dict__['password'].


class WriteOnlyDescriptor(object):
    def __init__(self):
        self.store = {}

    def __get__(self, obj, objtype=None):
        raise AttributeError 

    def __set__(self, obj, val):
        self.store[obj] = val
    
    def __del(self, obj):
        raise AttributeError

class A(object):
    password = WriteOnlyDescriptor()
      
if __name__ == '__main__': 
    a = A()
    try:
        print a.password
    except AttributeError, e:
        print e.__doc__
    a.password = 'secret'
    print A.__dict__['password'].store[a]
Descriptors with both __get__ and __set__ methods are called data descriptors. In general, data descriptors take lookup precedence over instance dictionaries, which take precedence over non-data descriptors. If you try to assign a value to a non-data descriptor attribute the new value will simply replace the descriptor. However, if you try to assign a value to a data descriptor the __set__ method of the descriptor will be called.

Properties
Properties are managed attributes. When you define a property you can provide get, set, and del functions as well as a doc string. When the attribute is accessed the corresponding functions are called. This sounds a lot like descriptors and indeed it is mostly a syntactic sugar for a common case.

This final code sample is another version of the silly password store using properties. The __password field is "private." Class A has a 'password' property that, when accessed as in 'a.password,' invokes the getPassword or setPassword methods. Because the getPassword method raises the AttributeError exception, the only way to get to the actual value of the __password attribute is by circumventing the Python fake privacy mechanism. This is done by prefixing the attribute name with an underscore and the class name a._A__password. How is it different from descriptors? It is less powerful and flexible but more pleasing to the eye. You must define an external descriptor class with descriptors. This means you can use the same descriptor for different classes and also that you can replace regular attributes with descriptors at runtime.


class A(object):
    def __init__(self):
        self.__password = None

    def getPassword(self):
        raise AttributeError

    def setPassword(self, password):        
        self.__password = password

    password = property(getPassword, setPassword)    
      
if __name__ == '__main__':
    a = A()
    try:
        print a.password
    except AttributeError, e:
        print e.__doc__
    a.password = 'secret'
    print a._A__password
    
Output:
    
Attribute not found.
secret 
Properties are more cohesive. The get, set functions are usually methods of the same class that contain the property definition. For programmers coming from languages such as C# or Delphi, Properties will make them feel right at home (too bad Java is still sticking to its verbose java beans).

Python's Richness a Mixed Blessing
There are many mechanisms to control attribute access at runtime starting with just dynamic replacement of attribute in the __dict__ at runtime. Other methods include the __getattr__/__setattr, descriptors, and finally properties. This richness is a mixed blessing. It gives you a lot of choice, which is good because you can choose whatever is appropriate to your case. But, it is also bad because you HAVE to choose even if you just choose to ignore it. The assumption, for better or worse, is that people who work at this level should be able to handle the mental load.

In my next article, I will pick up where I've left off. I'll begin by contrasting metaclasses with decorators, then explore the Python execution model, and explain how to examine stack frames at runtime. Finally, I'll demonstrate how to augment the Python language itself using these techniques. I'll introduce a private access checking feature that can be enforced at runtime.

Gigi Sayfan is a software developer working on CELL applications for Sony Playstation3. He specializes in cross-platform object-oriented programming in C/C++/C#/Python with emphasis on large-scale distributed systems.

[Feb 20, 2006] freshmeat.net Project details for Meld

Meld is a GNOME 2 visual diff and merge tool. It integrates especially well with CVS. The diff viewer lets you edit files in place (diffs update dynamically), and a middle column shows detailed changes and allows merges. The margins show location of changes for easy browsing, and it also features a tabbed interface that allows you to open many diffs at once.

Information about CWM - TimBL's Closed World Machine

CWM is a popular Semantic Web program that can do the following tasks:-

CWM was written in Python from 2000-10 onwards by Tim Berners-Lee and Dan Connolly of the W3C.

This resource is provided so that people can use CWM, find out what it does (documentation used to be sparse), and perhaps even contribute to its development.

What's new in Python 2.4

New or upgraded built-ins

Extending and Embedding the Python Interpreter

Extending Python with C (Score:1)
by frehe (6916) <frehe491@NoSpaM.student.liu.se> on Wednesday April 16, @03:41PM (#5745981)

If you need more speed than native Python provides, you can always write code in C and wrap it so it is callable from Python. The wrapping is really easy to do, once you have understood the general concepts involved in it. The product I currently work on has about 10000 lines of C code (crypto and networking) which is used this way, and it works perfectly. For more information about extending Python with C, see:

Extending and Embedding the Python Interpreter [python.org]

Dive Into Python Python for experienced programmers

Dive Into Python is a free Python book for experienced programmers. You can read the book online, or download it in a variety of formats. It is also available in multiple languages.

This book is still being written. The first three chapters are a solid overview of Python programming. Chapters covering HTML processing, XML processing, and unit testing are complete, and a chapter covering regression testing is in progress. This is not a teaser site for some larger work for sale; all new content will be published here, for free, as soon as it's ready. You can read the revision history to see what's new. Updated 28 July 2002

Wing IDE for Python Python IDS that includes source browser and editor. The editor supports folding

Reference Manual Wing IDE Version 1.1.4

Python IDS that includes source browser and editor.

developerWorks Linux Open source projects Charming Python Iterators and simple generators

What's New in Python 2.2

Generators is a very interesting feature of Python 2.2 that is essentially a co-routine.

Generators are another new feature, one that interacts with the introduction of iterators.

You're doubtless familiar with how function calls work in Python or C. When you call a function, it gets a private namespace where its local variables are created. When the function reaches a return statement, the local variables are destroyed and the resulting value is returned to the caller. A later call to the same function will get a fresh new set of local variables. But, what if the local variables weren't thrown away on exiting a function? What if you could later resume the function where it left off? This is what generators provide; they can be thought of as resumable functions.

Here's the simplest example of a generator function:

def generate_ints(N):
    for i in range(N):
        yield i

A new keyword, yield, was introduced for generators. Any function containing a yield statement is a generator function; this is detected by Python's bytecode compiler which compiles the function specially as a result. Because a new keyword was introduced, generators must be explicitly enabled in a module by including a from __future__ import generators statement near the top of the module's source code. In Python 2.3 this statement will become unnecessary.

When you call a generator function, it doesn't return a single value; instead it returns a generator object that supports the iterator protocol. On executing the yield statement, the generator outputs the value of i, similar to a return statement. The big difference between yield and a return statement is that on reaching a yield the generator's state of execution is suspended and local variables are preserved. On the next call to the generator's .next() method, the function will resume executing immediately after the yield statement. (For complicated reasons, the yield statement isn't allowed inside the try block of a try...finally statement; read PEP 255 for a full explanation of the interaction between yield and exceptions.)

Here's a sample usage of the generate_ints generator:

>>> gen = generate_ints(3)
>>> gen
<generator object at 0x8117f90>
>>> gen.next()
0
>>> gen.next()
1
>>> gen.next()
2
>>> gen.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 2, in generate_ints
StopIteration

You could equally write for i in generate_ints(5), or a,b,c = generate_ints(3).

Inside a generator function, the return statement can only be used without a value, and signals the end of the procession of values; afterwards the generator cannot return any further values. return with a value, such as return 5, is a syntax error inside a generator function. The end of the generator's results can also be indicated by raising StopIteration manually, or by just letting the flow of execution fall off the bottom of the function.

You could achieve the effect of generators manually by writing your own class and storing all the local variables of the generator as instance variables. For example, returning a list of integers could be done by setting self.count to 0, and having the next() method increment self.count and return it. However, for a moderately complicated generator, writing a corresponding class would be much messier. Lib/test/test_generators.py contains a number of more interesting examples. The simplest one implements an in-order traversal of a tree using generators recursively.

# A recursive generator that generates Tree leaves in in-order.
def inorder(t):
    if t:
        for x in inorder(t.left):
            yield x
        yield t.label
        for x in inorder(t.right):
            yield x

Two other examples in Lib/test/test_generators.py produce solutions for the N-Queens problem (placing queens on an chess board so that no queen threatens another) and the Knight's Tour (a route that takes a knight to every square of an chessboard without visiting any square twice).

The idea of generators comes from other programming languages, especially Icon (http://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from ``An Overview of the Icon Programming Language'' at http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:

sentence := "Store it in the neighboring harbor"
if (i := find("or", sentence)) > 5 then write(i)

In Icon the find() function returns the indexes at which the substring ``or'' is found: 3, 23, 33. In the if statement, i is first assigned a value of 3, but 3 is less than 5, so the comparison fails, and Icon retries it with the second value of 23. 23 is greater than 5, so the comparison now succeeds, and the code prints the value 23 to the screen.

Python doesn't go nearly as far as Icon in adopting generators as a central concept. Generators are considered a new part of the core Python language, but learning or using them isn't compulsory; if they don't solve any problems that you have, feel free to ignore them. One novel feature of Python's interface as compared to Icon's is that a generator's state is represented as a concrete object (the iterator) that can be passed around to other functions or stored in a data structure.

See Also:

PEP 255, Simple Generators
Written by Neil Schemenauer, Tim Peters, Magnus Lie Hetland. Implemented mostly by Neil Schemenauer and Tim Peters, with other fixes from the Python Labs crew.

Dive Into Python Dive Into Python is a free Python book for experienced programmers.

You can read the book online, or download it in a variety of formats. It is also available in multiple languages.

Seventh International Python Conference Papers

Applications I: The Internet

Optimizing Python

Extending and Compiling

Applications II: Science and Simulation

Slashdot: What Makes a Powerful Programming Language

Slashdot
by NeuroMorphus on Monday February 11, @07:26PM (#2991161)
(User #463324 Info | http://slashdot.org/)
You also have my Python vote. Python is not only a powerful language on its own, but it's also a good glue language, pulling C++ together to speed up particular modules, or using Jython for a Java perspective(IMHO, I like programming in Jython better than Java itself:)

Python is also good for server-side scripting as well as operating system scripts. Not to mention that Python has lots of support including, Twisted Matrix [twistedmatrix.com], which is an event-based framework for internet applications that include a web server, a telnet server, a multiplayer RPG engine, a generic client and server for remote oject access, and API's for creating new protocols and services.

If you want GUI design, you have wxWindows, wxPython for wxGTK, Tk, PyQt, PyGTK, etc.

I would tell your boss to got with Python; You'll end up using it down the road anyway ;)

Consider Python carefully (Score:3, Informative)
by pclminion on Monday February 11, @09:17PM (#2991850)
(User #145572 Info)
I can definitely speak for the elegance of Python; I've used it to build some pretty large-scale AI projects, among about a zillion other things.

If you're looking for the weirder OO features like operator overloading, you'll find them in Python, but the calisthenics you have to go through to do it might make you think twice about using it.

The only real drawback to Python is the execution speed. One of the AI projects I previously mentioned worked great (and I completed it probably 10 times faster than I would have had I been using C/C++), but it ran very very slowly. The cause of the problem is clear -- no static typing, reference-count garbage collection, a stack-based VM (I ain't knockin' it! It's just hard to optimize)...

If you are planning to do anything compute-intensive, maybe Python is not the right choice. It's always possible to break out to C/C++ with the Python API (to do your compute-intensive tasks), but there are drawbacks: over time, the Python C-API will probably drift, and you'll have to keep tweaking your native code to keep it working. Also, the inner workings of Python, especially refcounts, can be boggling and the source of bugs and memory leaks that can be fantastically hard to track down.

If you consider Python, then great. Just keep these points in mind.

Python for you and "Clean C" for Cliff (Score:1)
by Nice2Cats on Tuesday February 12, @04:56AM (#2993069)
(User #557310 Info | http://slashdot.org/)
It does sound like your boss was trying to tell you to use Python, unless it needs to be blindingly fast (as in "operating system" or "3d shooter"). I'd like to second that recommendation and the arguments already posted.

To respond to Cliff's question: The one thing that every new language should have is that "significant whitespace" look-ma-no-braces syntax used by Python - or at least the option of not having to spend your life typing semicolons.

In fact, you could probably retrofit the common C and C++ compilers to accept significant whitespace. This would mean the Linux kernel people would be reading:

static int proc_sel(struct task_struct *p, int which, int who):
if(p->pid):
switch (which):
case PRIO_PROCESS:
if (!who && p == current):
return 1
return(p->pid == who)
case PRIO_PGRP:
if (!who):
who = current->pgrp
return(p->pgrp == who)
case PRIO_USER:
if (!who):
who = current->uid
return(p->uid == who)
return 0

(Modified from /linux/kernel/sys.c (C) Linus Torvalds)

Of course, there is a problem of finding a new name for this sort of C without violating somebodys copyright...is "Clean C" still available?

[Jun 2, 2003] Python and the Programmer A Conversation with Bruce Eckel by Bill Venners

Bruce Eckel wrote the best-selling books Thinking in C++ and Thinking in Java, but for the past several years he's preferred to think in Python. Two years ago, Eckel gave a keynote address at the 9th International Python Conference entitled "Why I love Python." He presented ten reasons he loves programming in Python in "top ten list" style, starting with ten and ending with one.
Python and the Programmer: A Conversation with Bruce Eckel, Part I by Bill Venners Jun 2, 2003

Summary
Bruce Eckel talks with Bill Venners about why he feels Python is "about him," how minimizing clutter improves productivity, and the relationship between backwards compatibility and programmer pain.

Bruce Eckel wrote the best-selling books Thinking in C++ and Thinking in Java, but for the past several years he's preferred to think in Python. Two years ago, Eckel gave a keynote address at the 9th International Python Conference entitled "Why I love Python." He presented ten reasons he loves programming in Python in "top ten list" style, starting with ten and ending with one.

In this interview, which is being published in weekly installments, I ask Bruce Eckel about each of these ten points. In this installment, Bruce Eckel explains why he feels Python is "about him," how minimizing clutter improves productivity, and the relationship between backwards compatibility and programmer pain.

Bill Venners: In the introduction to your "Why I Love Python" keynote, you said what you love the most is "Python is about you." How is Python about you?

Bruce Eckel: With every other language I've had to deal with, it's always felt like the designers were saying, "Yes, we're trying to make your life easier with this language, but these other things are more important." With Python, it has always felt like the designers were saying, "We're trying to make your life easier, and that's it. Making your life easier is the thing that we're not compromising on."

For example, the designers of C++ certainly attempted to make the programmer's life easier, but always made compromises for performance and backwards compatibility. If you ever had a complaint about the way C++ worked, the answer was performance and backwards compatibility.

Bill Venners: What compromises do you see in Java? James Gosling did try to make programmers more productive by eliminating memory bugs.

Bruce Eckel: Sure. I also think that Java's consistency of error handling helped programmer productivity. C++ introduced exception handling, but that was just one of many ways to handle errors in C++. At one time, I thought that Java's checked exceptions were helpful, but I've modified my view on that. (See Resources.)

It seems the compromise in Java is marketing. They had to rush Java out to market. If they had taken a little more time and implemented design by contract, or even just assertions, or any number of other features, it would have been better for the programmer. If they had done design and code reviews, they would have found all sorts of silliness. And I suppose the way Java is marketed is probably what rubs me the wrong way about it. We can say, "Oh, but we don't like this feature," and the answer is, "Yes, but, marketing dictates that it be this way."

Maybe the compromises in C++ were for marketing reasons too. Although choosing to be efficient and backwards compatible with C was done to sell C++ to techies, it was still to sell it to somebody.

I feel Python was designed for the person who is actually doing the programming, to maximize their productivity. And that just makes me feel warm and fuzzy all over. I feel nobody is going to be telling me, "Oh yeah, you have to jump through all these hoops for one reason or another." When you have the experience of really being able to be as productive as possible, then you start to get pissed off at other languages. You think, "Gee, I've been wasting my time with these other languages."

Number 10: Reduced Clutter

Bill Venners: In your keynote, you gave ten reasons you love Python. Number ten was reduced clutter. What did you mean by reduced clutter?

Bruce Eckel: They say you can hold seven plus or minus two pieces of information in your mind. I can't remember how to open files in Java. I've written chapters on it. I've done it a bunch of times, but it's too many steps. And when I actually analyze it, I realize these are just silly design decisions that they made. Even if they insisted on using the Decorator pattern in java.io, they should have had a convenience constructor for opening files simply. Because we open files all the time, but nobody can remember how. It is too much information to hold in your mind.

The other issue is the effect of an interruption. If you are really deep into doing something and you have an interruption, it's quite a number of minutes before you can get back into that deeply focused state. With programming, imagine you're flowing along. You're thinking, "I know this, and I know this, and I know this," and you are putting things together. And then all of a sudden you run into something like, "I have to open a file and read in the lines." All the clutter in the code you have to write to do that in Java can interrupt the flow of your work.

Another number that used to be bandied about is that programmers can produce an average of ten working lines of code per day. Say I open up a file and read in all the lines. In Java, I've probably already used up my ten working lines of code for that day. In Python, I can do it in one line. I can say, "for line in file('filename').readlines():," and then I'm ready to process the lines. And I can remember that one liner off the top of my head, so I can just really flow with that.

Python's minimal clutter also helps when I'm reading somebody else's code. I'm not tripping over verbose syntax and idioms. "Oh I see. Opening the file. Reading the lines." I can grok it. It's very similar to the design patterns in that you have a much denser form of communication. Also, because blocks are denoted by indentation in Python, indentation is uniform in Python programs. And indentation is meaningful to us as readers. So because we have consistent code formatting, I can read somebody else's code and I'm not constantly tripping over, "Oh, I see. They're putting their curly braces here or there." I don't have to think about that.

Number 9: Not Backwards Compatible in Exchange for Pain

Bill Venners: In your keynote, your ninth reason for loving Python was, "Not backwards compatible in exchange for pain." Could you speak a bit about that?

Bruce Eckel: That's primarily directed at C++. To some degree you could say it refers to Java because Java was derived primarily from C++. But C++ in particular was backwards compatible with C, and that justified lots of language issues. On one hand, that backwards compatibility was a great benefit, because C programmers could easily migrate to C++. It was a comfortable place for C programmers to go. But on the other hand, all the features that were compromised for backwards compatibility was the great drawback of C++.

Python isn't backwards compatible with anything, except itself. But even so, the Python designers have actually modified some fundamental things in order to fix the language in places they decided were broken. I've always heard from Sun that backwards compatibility is job one. And so even though stuff is broken in Java, they're not going to fix it, because they don't want to risk breaking code. Not breaking code always sounds good, but it also means we're going to be in pain as programmers.

One fundamental change they made in Python, for example, was "type class unification." In earlier versions, some of Python's primitive types were not first class objects with first class characteristics. Numbers, for example, were special cases like they are in Java. But that's been modified so now I can inherit from integer if I want to. Or I can inherit from the modified dictionary class. That couldn't be done before. After a while it began to be clear that it was a mistake, so they fixed it.

Now in C++ or Java, they'd say, "Oh well, too bad." But in Python, they looked at two issues. One, they were not breaking anybody's existing world, because anyone could simply choose to not upgrade. I think that could be an attitude taken by Java as well. And two, it seemed relatively easy to fix the broken code, and the improvement seemed worth the code-fixing work. I find that attitude so refreshing, compared to the languages I'd used before where they said, "Oh, it's broken. We made a mistake, but you'll have to live with it. You'll have to live with our mistakes."

Next Week

Come back Monday, June 9 for Part I of a conversation with Java's creator James Gosling. I am now staggering the publication of several interviews at once, to give the reader variety. The next installment of this interview with Bruce Eckel will appear on Monday, June 23. If you'd like to receive a brief weekly email announcing new articles at Artima.com, please subscribe to the Artima Newsletter.

Talk Back!

Have an opinion about programmer productivity, backwards compatibility, or breaking code versus programmer pain. Discuss this article in the News & Ideas Forum topic, Python and the Programmer.

Resources

Bruce Eckel's Mindview, Inc.:
http://www.mindview.net/

Bruce Eckel's essay on checked exceptions: Does Java Need Checked Exceptions?:
http://www.mindview.net/Etc/Discussions/CheckedExceptions

Bruce Eckel's Public and In-House Seminars:
http://mindview.net/Seminars

Bruce Eckel's Weblog:
http://www.mindview.net/WebLog

Python.org, the Python Language Website:
http://www.python.org/

Introductory Material on Python:
http://www.python.org/doc/Intros.html

Python Tutorial:
http://www.python.org/doc/current/tut/tut.html

Python FAQ Wizard:
http://www.python.org/cgi-bin/faqw.py

[Dec 28, 2001] http://www.dotfunk.com/projects/pylint/pylint.0.1.tar.gz

Pylint is a static type checker for Python (compare with PyChecker 0.4) David Jeske and Scott Hassan proved that it is possible to do this. They are working on a type inference engine that understands the Python language and can detect type errors and violations. Adding type checking to python without
changing the language will ease the maintenance of a large python project with lots of developers. Please remember that eGroups before it was bought by Yahoo was a huge Python project (more than 180,000 lines of Python doing everything from a 100% dynamic website to all email delivery, pumping out 200 messages/second on a single 400 MHz Pentium!)

[Dec 20, 2001] Semi-coroutines in Python 2.2

Search Result 31

From: Steven Majewski (sdm7g@Virginia.EDU)
Subject: Re: (semi) stackless python
Newsgroups: comp.lang.python

View: Complete Thread (2 articles) | Original Format

Date: 2001-12-20 13:01:46 PST

 The new generators in Python2.2 implement semi-coroutines, not
full coroutines:  the limitation is that they always return to
their caller -- they can't take an arbitrary continuation as
a return target.

 So you can't do everything you can do in Stackless, or at least,
you can't do it the same way. I'm not sure what the limitations
are yet, but you might be surprised with what you CAN do.
 If all the generator objects yield back to the same 'driver'
procedure, then you can do a sort of cooperative multithreading.
In that case, you're executing the generators for their side
effects -- the value returned by yield may be unimportant except
perhaps as a status code.

[ See also Tim Peters' post on the performance advantages of
  generators -- you only parse args once for many generator
  calls, and you keep and reuse the same stack frame. So I
  believe you get some of the same benefits of Stackless
  microthreads. ]

Maybe I can find the time to post an example of what I mean.
In the mean time, some previous posts on generators might give
you some ideas.

<http://groups.google.com/groups?q=generators+group:comp.lang.python+author:Majewski&hl=en&scoring=d&as_drrb=b&as_mind=12&as_minm=1&as_miny=2001&as_maxd=20&as_maxm=12&as_maxy=2001&rnum=1&selm=mailman.1008090197.6318.python-list%40python.org>

<http://groups.google.com/groups?hl=en&threadm=mailman.996870501.28562.python-list%40python.org&rnum=6&prev=/groups%3Fas_q%3Dgenerators%26as_ugroup%3Dcomp.lang.python%26as_uauthors%3DMajewski%26as_drrb%3Db%26as_mind%3D12%26as_minm%3D1%26as_miny%3D2001%26as_maxd%3D20%26as_maxm%3D12%26as_maxy%3D2001%26num%3D100%26as_scoring%3Dd%26hl%3Den>

The ungrammatical title of that last thread above:
"Nested generators is the Python equivalent of unix pipe cmds."
might also suggest the solution I'm thinking of.


-- Steve Majewski

[Nov 02, 2001] Perl to Python Migration by Martin C. Brown

Martin C Brown is the author of several books on Perl (including Debugging Perl) and a book on Python (Python The Complete Reference, 2001) so he knows both languages. which makes the book pretty unique. there is no other books that cover Python from the position of Perl programmer.
My conclusion

Python is an excellent language for my intended use. It is a good language for many of the applications that one would use Lisp as a rapid prototyping environment for. The three main drawbacks are (1) execution time is slow, (2) there is very little compile-time error analysis, even less than Lisp, and (3) Python isn't called "Java", which is a requirement in its own right for some of my audience. I need to determine if JPython is close enough for them.

Python can be seen as either a practical (better libraries) version of Scheme, or as a cleaned-up (no $@&%) version of Perl. While Perl's philosophy is TIMTOWTDI (there's more than one way to do it), Python tries to provide a minimal subset that people will tend to use in the same way. One of Python's controversial features, using indentation level rather than begin/end or {/}, was driven by this philosophy: since there are no braces, there are no style wars over where to put the braces. Interestingly, Lisp has exactly the same philosophy on this point: everyone uses emacs to indent their code. If you deleted the parens on control structure special forms, Lisp and Python programs would look quite similar.

Python has the philosophy of making sensible compromises that make the easy things very easy, and don't preclude too many hard things. In my opinion it does a very good job. The easy things are easy, the harder things are progressively harder, and you tend not to notice the inconsistencies. Lisp has the philosophy of making fewer compromises: of providing a very powerful and totally consistent core. This can make Lisp harder to learn because you operate at a higher level of abstraction right from the start and because you need to understand what you're doing, rather than just relying on what feels or looks nice. But it also means that in Lisp it is easier to add levels of abstraction and complexity; Lisp makes the very hard things not too hard.

[May 6, 2001] Zope for the Perl-CGI programmer by Michael Roberts

Zope is written in Python

Zope (the Z Object Publishing Environment) is an application server that is gaining in popularity. But what is it? What's an application server, anyway? How does all this compare with nice familiar paradigms like CGI? More importantly, is Zope a fad, or is it here to stay?

In a nutshell, here's what you get from Zope:

And you get all this in an easily installed, easily maintained package. But the most significantly new thing about Zope is how it encourages you to look at your Web site differently than you do now. Let's talk about that a little before we get down to brass tacks.

Python creator: Perl users are moving to Python

searchEnterpriseLinux: Are there situations in which it's better to use Perl than Python, or vice versa?
van Rossum: They're both competing for the same niche, in some cases. If all you need to do is simple text processing, you might use Perl. Python, much more than Perl, encourages clean coding habits to make it easy for other people to follow what you are doing. I've seen a lot of people who were developing in Perl moving to Python because it's easier to use. Where Python wins is when you have users who are not very sophisticated but have to write some code. An example would be in educational settings, where you have students who have no prior programming experience. Also, Python seems to work better when you have to write a large system, working together in a large group of developers, and when you want the lifetime of your program to be long.
searchEnterpriseLinux: In what situations would people use Java instead of Python?
van Rossum: Java and Python have quite different characteristics. Java is sophisticated language. It takes a longer time to learn Java than Python. With Java, you have to get used to the compile-edit-run cycle of software development. Python is a lighter-weight language. There is less to learn to get started. You can hit the ground running when you have only a few days of Python training under your belt. Python and Java can be used in the same project. Python would be used for higher level control of an application, and Java would be used for implementing the lower level that needs to run relatively efficiently. Another place where Python is used is an extension language. An example of that is Object Domain, a UML editing tool written in Java. It uses Python as an extension language.
searchEnterpriseLinux: Will use of Python in developing applications increase?
van Rossum: It's going to increase dramatically. There's a definite need for a language that's as easy to use as Python. Python is used to teach students how to program, so that is creating a base of people who know and like the language.
searchEnterpriseLinux: Are there technology developments that will benefit Linux developers?
van Rossum: Python developer tools are becoming available that work well in the Linux world. Until a year ago, the Python developer was stuck with using Emacs or VI to edit source code. Both of those editors have support for Python, but they're just editors. Now there are tools like Wing IDE, which is a development tool that is written in Python. Komodo is more ambitious and less finished at the moment, and it also supports program development with Perl. There is a Swedish company called Secret Labs which have had Windows development tools for Python, but which is now focusing on the Linux market. As more development environments become available for Python, we'll see a lot more users on the Linux platform.

Dave Warner wrote an excellent article on XML-RPC and Python here, using Meerkat as an example of a real XML-RPC server

Another article about XML-RPC

According to Jeff Walsh's InfoWorld article, Microsoft is planning to open up their operating system using XML-RPC. Such a protocol could be deployed quickly in other operating systems that support HTTP, ranging from Perl scripts running on Linux, to Quark publishing systems running on Macs, to relational databases running on mainframe systems. It could put Windows at the center of a new kind of web, one built of logic, storing objects and methods, not just pages and graphics.

The XML-RPC HOWTO is here.

People interested in XML-RPC might be interested in checking it out using KDE. Since KDE 2.0 a DCOP XMLRPC bridge has been included allowing easy access to a wide range of the desktops APIs.

My experiencie implementing XML-RPC (Score:3, Interesting)
by Nicopa (nick@debian.org) on Tuesday February 20, @08:04PM EST (#88)
(User #87617 Info)
This is my experience with XML-RPC:

I work for a company (Technisys) which have created several years ago an RPC tool called "tmgen". This tool is built as a layer on top of rpcgen, adding session cookie handling, SSL support, a stateless server, handling of enumerated values with associated long and short descriptions, and many other thing. It's in fact, an application server built on top of RPC.

This baby have been running for many years in the most important banks and credit cards companies here in Argentina (yes, you know the brands, but I'm not sure I can tell you which ones =) ).

The "tmgen" tool reads a ".def" file that defines the datatyes, and ".trn" files which have the code of the different "transactions". Having read those files, it automatically generates the server source (including the rpcgen input source).

I was asked to make it possible for the clients to be programmed in the Java language. I evaluated several possibilities, one of them using a Java client for RPC. This required us to go for a proprietary solution, besides, being in control of both sides it looked silly to be tied to a protocol. Another possibility would have been to modify tmgen to create an RMI server. But the best was to create an XML server (IMO). I then evaluated SOAP and XML-RPC. SOAP seemed very nice, but XML-RPC was *direct* mapping of the semantics and types of our existing solution. The benefits of SOAP were a drawback in this case, we just wanted to have strings, structs, ints and floats.

So, now it's working. It takes a definition of the structs, the method and which parameters they get, and it creates code (using the gnome-xml library (which I recommend). The automatically generated code works as a standalone inetd webserver which reads an XML-RPC query from the net, parses the query, loads it in the generated C structures, run the "transaction", and creates a response from the reply structures. The final result was that all those old C, RPC-only, programs started to have an XML interface.

I added the Helma RPC-XML client and voila, we had a Java client. So I must say that my experience in this legacy system with XML-RPC was great.

Talking about new systems, I think that XML-RPC does the wrong thing, by defining markup for the types instead of marking the semantic of the data.

XML-RPC, SOAP, and the Rest... (Score:2, Informative)
by edashofy on Tuesday February 20, @08:17PM EST (#95)
(User #265252 Info)
I've used XML-RPC before, written my own version of it, and used SOAP extensively (and even posted a few patches to the IBM SOAP for Java implementation). My conclusion has been that while RPC is slow, XML-RPC (and its variants) are necessarily slower. The idea itself is good, and it may be useful for so-called "web services" where there is a strict client-server relationship between communicating machines and there are few RPC's bouncing around the network. However, the overhead of a full XML parser, plus a protocol implementation, plus a marshaller and demarshaller to and from XML (especially since no language really provides this) is a big problem for XML-RPC and its kin. According to Dave Winer... "Conceptually, there's no difference between a local procedure call and a remote one, but they are implemented differently, perform differently (RPC is much slower) and therefore are used for different things." Bzzt! A local procedure call can pass references, pointers, etc. A remote procedure call is not just slower, but it also limits what kind of data you can reasonably expect to pass in the parameters. A pointer to a database driver, for instance, or a function pointer (for callbacks) are entirely different beasts! From the slashdot header: "It's deliberately minimalist but nevertheless quite powerful, offering a way for the vast majority of RPC applications that can get by on passing around boolean/integer/float/string datatypes to do their thing in a way that is lightweight and easy to to understand and monitor" Lightweight? Simple to understand and monitor? First of all, XML parsers are NEVER lightweight, especially if you want to do SOAP and use things like namespaces. Second of all, if you're doing only booleans/integers/floats/strings as the above suggests, then you're fine. More complex datatype marshalling? Ouch! I'm going to leave XML-RPC, SOAP, and its kin behind for a while and see what happens. Until then, caveat earlius adopterus!
Why isn't XML-RPC considered bloat? (Score:3, Interesting)
by Carnage4Life on Tuesday February 20, @09:16PM EST (#116)
(User #106069 Info) http://www.25hoursaday.com
I am a big fan of distributed computing, heck I wrote an article about it on K5, and have always wondered what the XML-RPC payoff is.

From what I can tell, XML-RPC is a way to replace the binary protocols that current distributed systems use (e.g. Corba's IIOP or DCOM's ORPC) with an XML based one. So when an object needs perform a remote method call, instead of just sending it's arguments in a compact efficient binary packet, it builds an XML string which has to be parsed oand call a few functions. But it means that an extra layer of abstraction has been added to operations that should be performed rather quickly for the dubious benefit of compatibility across platforms (which is yet to be realized) which seems to be more jumping on the XML hype bandwagon than reality. My biggest issue is that for XML-RPC to support things that are the biggest issues of distributed computing (e.g. keeping track of state) would add so much bloat to the XML parsing, string building, etc process for making a remote call as to make it unfeasible.

Anyone see any errors in this thinking?

Grabel's Law
2 is not equal to 3 - not even for very large values of 2.

Re:Why isn't XML-RPC considered bloat? (Score:4, Informative)
by Hrunting (hrunting@nospam.texas.net) on Tuesday February 20, @10:19PM EST (#134)
(User #2191 Info) http://hrunting.home.texas.net/

Anyone see any errors in this thinking?

Yes. It's true that as a consequence of its text-based nature, communication via XML is decidedly more bandwidth-intensive than any binary counterpart. The problem, though, lies in translation of that binary format two and from different machines, architectures, languages, and implementations.

I currently do quite a bit of work using SOAP, which is similar to XML-RPC, but a little less well-developed. It's a no-brainer. If I'm using Java, Perl, C, C++ or even Python, it's relatively easy to make calls between these different languages. I don't have to worry about the endianess of the data I'm working with. I don't have to worry about learning some new data encoding scheme (XML is very well-defined, and very ubiquitous; almost every language has a translator). Communicating between a language like Perl, which has no typing, and Java, which has more strict typing is a no brainer, because the data structures are defined by a well-documented, human readable schema, and when I look at the data I'm sending, I can see the raw information.

Bandwidth concerns might have been paramount two years ago, but the world in which XML-RPC and SOAP are being used has already shifted to broadband. Now, human clarity and complete interoperability, as well as the ease of use of porting XML-RPC (or SOAP) constructs to another language (since it's just XML text) make it a much more efficient model in terms of programmer time.

Yes, from a strictly bandwidth concern, CORBA or DCOM beat XML hands down, but when you remove that consideration, it's not that big a deal. Couple it with existing protocols (I've seen SOAP implementations via HTTP, FTP, and even SMTP), and the opportunity to grow via existing infrastructure and well-known technologies, and you just have an easier (and thus, I would argue, more open) model to work with.

[Nov 22, 2000] Random links

O'Reilly Network: Introduction to Stackless Python(Oct 19, 2000)

Linux.com: Programming with Python - Part 3: Extending Python(Nov 19, 2000)

Security Portal: Python: Security Aspects (Nov 17, 2000)

Python-dev summary, November 1-15, 2000 (Nov 16, 2000)

IBM developerWorks: Charming Python: Inside Python's implementations(Nov 13, 2000)

O'Reilly Network: Python Roadmap(Oct 22, 2000)

O'Reilly Network: Python 2.0 and Beyond(Oct 22, 2000

[Nov 22, 2000] LinuxPR: PythonWorks Pro v1.1 - Now Also for Linux and Solaris!

"PythonWorks Pro, entirely developed in Python, contains an editor, project manager, a deployment tool, an integrated browser, debugger, and a proprietary interface design tool. PythonWorks Pro allows the developer to easily create Python applications using the built-in tools."

[Nov 14, 2000] Linux Charming Python -- Inside Python's implementations See also Slashdot Interviews With The Creators of Vyper and Stackless

developerWorks

Stackless Python: An interview with creator Christian Tismer
At first brush, Stackless Python might seem like a minor fork to CPython. In terms of coding, Stackless makes just a few changes to the actual Python C code (and redefines "truth"). The concept that Christian Tismer (the creator of Stackless Python) introduces with Stackless is quite profound, however. It is the concept of "continuations" (and a way to program them in Python).

To attempt to explain it in the simplest terms, a continuation is a representation, at a particular point in a program, of everything the program is capable of doing subsequently. A continuation is a potential that depends on initial conditions. Rather than loop in a traditional way, it is possible to invoke the same continuation recursively with different initial conditions. One broad claim I have read is that continuations, in a theoretical sense, are more fundamental and underlie every other control structure. Don't worry if these ideas cause your brain to melt; that is a normal reaction.

Reading Tismer's background article in the Resources is a good start for further understanding. Pursuing his references is a good way to continue from there. But for now, let's talk with Tismer at a more general level:

Mertz: Exactly what is Stackless Python? Is there something a beginner can get his or her mind around that explains what is different about Stackless?

Tismer: Stackless Python is a Python implementation that does not save state on the C stack. It does have stacks -- as many as you want -- but these are Python stacks.

The C stack cannot be modified in a clean way from a language like C, unless you do it in the expected order. It imposes a big obligation on you: You will come back, exactly here, exactly in the reverse way as you went off.

"Normal" programmers do not see this as a restriction in the first place. They have to learn to push their minds onto stacks from the outset. There is nothing bad about stacks, and usually their imposed execution order is the way to go, but that does not mean that we have to wait for one such stack sequence to complete before we can run a different one.

Programmers realize this when they have to do non-blocking calls and callbacks. Suddenly the stack is in the way, we must use threads, or explicitly store state in objects, or build explicit, switchable stacks, and so on. The aim of Stackless is to deliver the programmer from these problems.

Mertz: The goal of Stackless is to be 100% binary compatible with CPython. Is it?

Tismer: Stackless is 100% binary compatible at the moment. That means: You install Python 1.5.2, you replace Python15.dll with mine, and everything still works, including every extension module. It is not a goal, it was a demand, since I didn't want to take care about all the extensions.

Mertz: Stackless Python has been absolutely fascinating to read about for me. Like most earthbound programmers, I have trouble getting my mind wholly around it, but that is part of what makes it so interesting.

Tismer: Well, I'm earthbound, too, and you might imagine how difficult it was to implement such a thing, without any idea what a continuation is and what it should look like in Python. Getting myself into doing something that I wasn't able to think was my big challenge. After it's done, it is easy to think, also to redesign. But of those six months of full-time work, I guess five were spent goggling into my screen and banging my head onto the keyboard.

Continuations are hard to sell. Coroutines and generators, and especially microthreads are easier. All of the above can be implemented without having explicit continuations. But when you have continuations already, you find that the step to these other structures is quite small, and continuations are the way to go. So I'm going to change my marketing strategy and not try any longer to sell the continuations, but their outcome. Continuations will still be there for those who can see the light.

Mertz: There is a joke about American engineers and French engineers. The American team brings a prototype to the French team. The French team's response is: "Well, it works fine in practice; but how will it hold up in theory?" I think the joke is probably meant to poke fun at a "French" style, but in my own mind I completely identify with the "French" reaction. Bracketing any specific national stereotypes in the joke, it is my identification in it that draws me to Stackless. CPython works in practice, but Stackless works in theory! (In other words, the abstract purity of continuations is more interesting to me personally than is the context switch speedups of microthreads, for example).

Tismer: My feeling is a bit similar. After realizing that CPython can be implemented without the C stack involved, I was sure that it must be implemented this way; everything else looks insane to me. CPython already pays for the overhead of frame objects, but it throws all their freedom away by tying them to the C stack. I felt I had to liberate Python. :-)

I started the project in May 1999. Sam Rushing was playing with a hardware coroutine implementation, and a discussion on Python-dev began. Such a stack copying hack would never make it into Python, that was clear. But a portable, clean implementation of coroutines would, possibly. Unfortunately, this is impossible. Steve Majewski gave up five years ago, after he realized that he could not solve this problem without completely rewriting Python.

That was the challenge. I had to find out. Either it is possible, and I would implement it; or it is not, and I would prove the impossibility. Not much later, after first thoughts and attempts, Sam told me about call/cc and how powerful it was. At this time, I had no idea in what way they could be more powerful than coroutines, but I believed him and implemented them; after six or seven times, always a complete rewrite, I understood more.

Ultimately I wanted to create threads at blinding speed, but my primary intent was to find out how far I can reach at all.

Mertz: On the practical side, just what performance improvements is Stackless likely to have? How great are these improvements in the current implementation? How much more is possible with tweaking? What specific sorts of applications are most likely to benefit from Stackless?

Tismer: With the current implementation, there is no large advantage for Stackless over the traditional calling scheme. Normal Python starts a recursion to a new interpreter. Stackless unwinds up to a dispatcher and starts an interpreter from there. This is nearly the same. Real improvements are there for implementations of coroutines and threads. They need to be simulated by classes, or to be real threads in Standard Python, while they can be implemented much more directly with Stackless.

Much more improvement of the core doesn't seem possible without dramatic changes to the opcode set. But a re-implementation, with more built-in support for continuations et. al., can improve the speed of these quite a lot.

Specific applications that might benefit greatly are possibly Swarm simulations, or multiuser games with very many actors performing tiny tasks. One example is the EVE game (see Resources below), which is under development, using Stackless Python.

Mertz: What do you think about incorporating Stackless into the CPython trunk? Is Stackless just as good as an available branch, or does something get better if it becomes the core version?

Tismer: There are arguments for and against it. Against: As long as I'm sitting on the Stackless implementation, it is mine, and I do not need to discuss the hows and whys. But at the same time, I'm struggling (and don't manage) to keep up with CVS. Better to have other people doing this.

Other Python users, who aren't necessarily interested in kinky stuff, won't recognize Stackless at all; just the fact that it happens to be faster, and that the maximum recursion level now is an option and not a hardware limit. And there is another promise for every user: There will be pickleable execution states. That means you can save your program while it is running, send it to a friend, and continue running it.

Finally, I'm all for it, provided that all my stuff makes it into the core; at the same time, I do not want to see a half-baked solution, as has been proposed several times.

Mertz: Any thoughts on future directions for Stackless? Anything new and different expected down the pipeline? Stackless still suffers from some recursions. Will they vanish?

Tismer: Pickling support will be partially implemented. This will be working first for microthreads since they provide the cleanest abstraction at the moment. They are living in a "clean room" where the remaining recursion problem doesn't exist. My final goal is to remove all interpreter recursion from Python. Some parts of Stackless still have recursions, especially all the predefined __xxx__ methods of objects. This is very hard to finalize since we need to change quite a few things, add new opcodes, unroll certain internal calling sequences, and so on.

Resources

BeOpen.com Swallows Python Whole

LinuxMall.com

Python's fearless leader and self-proclaimed "Benevolent Dictator for Life" (BDFL), Guido van Rossum, recently wrote an open letter to the community, proclaiming Python's decision to move the project to new auspices in the Open Source realm.

"Python is growing rapidly. In order to take it to the next level, I've moved with my core development group to a new employer, BeOpen.com," van Rossum wrote. "BeOpen.com is a startup company with a focus on Open Source communities, and an interest in facilitating next-generation application development. It is a natural fit for Python."

BeOpen.com develops online communities for Open Source application users, developers and interested parties through its network of portal Web sites. It also offers support and custom development for Open Source applications specific to major corporations and governmental entities.

Van Rossum created Python in the early 1990s at CWI (the National Research Institute for Mathematics and Computer Science in the Netherlands) in Amsterdam. In 1995, he moved to the United States, and lives in Reston, Virginia.

In the past five years, van Rossum has worked as a researcher at the Corporation for National Research Initiatives (CNRI). He also is technical director of the Python Consortium, a CNRI-hosted international consortium that promotes Python use and development.

Van Rossum has headed up Python's development for the past decade. He said he expects to remain in the position for at least another 10 years and although he "is not worried about getting hit by a bus," he also has announced that he soon will be married and the union between Python and BeOpen.com will give him some time for a honeymoon.

At BeOpen.com, van Rossum is the director of a new development team recently dubbed PythonLabs. The team includes three of his colleagues from CNRI: Fred Drake, Jeremy Hylton, and Barry Warsaw. "Another familiar face will join us shortly: Tim Peters. We have our own Web site where you can read more about us, our plans and our activities. We've also posted a FAQ there specifically about PythonLabs, our transition to BeOpen.com, and what it means for the Python community," he said.

[Jun 06, 2000]The Python Refactoring Browser By Shae Erisson

Jun 06, 2000 | comp.lang.python

[ Shae Erisson writes: Help write the Refactoring Browser for Python :) I think it would improve many things about medium to large Python projects. https://sourceforge.net/project/?group_id=4298 ]

The Python Refactoring Browser, helping Pythonistas everywhere glide over the gory details of refactoring their code. Watch him extract jumbled code into well ordered classes. Gasp, as he renames all occurrences of a method.

Thank You Bicycle Repair Man!

TechNetCast Archives

PyChecker 0.4 PyChecker is a python source code checking tool to help you find common bugs.

[Vaults of Parnassus]

Python for Lisp Programmers

This is a brief introduction to Python for Lisp programmers. Basically, Python can be seen as a dialect of Lisp with "traditional" syntax (what Lisp people call "infix" or "m-lisp" syntax). One message on comp.lang.python said "I never understood why LISP was a good idea until I started playing with python." Python supports all of Lisp's essential features except macros, and you don't miss macros all that much because it does have eval, and operator overloading, so you can create custom languages that way. (Although it wasn't my intent, Python programmers have told me this page has helped them learn Lisp.)

I looked into Python because I was considering translating the code for the Russell & Norvig AI textbook from Lisp to Java so that I could have (1) portable GUI demos, (2) portable http/ftp/html libraries, (3) free development environments on all major platforms, and (4) a syntax for students and professors who are afraid of parentheses. But writing all that Java seemed much too daunting, and I think that students who used Java would suffer by not having access to an interactive environment to try things out. Then I discovered JPython, a version of Python that is neatly integrated into Java, giving us access to the Java GUIs. Of course, Python already has web libraries, so JPython can use either those or Java's.

[Jun 3, 2000] BeOpen Interview with Guido van Rossum

Linux Today

As open source projects go, Python, the "very high level language" developed by Guido Van Rossum 10 years ago, is a prime example of the "scratch your own itch" design philosophy.

Van Rossum, a 44 year old developer who spent much of his collegiate and post- collegiate years working with instructional software languages such as ABC and Pascal, freely admits that it was his annoyance with these languages' real-word performance that drove him to create Python.

"The history of Python came out of the frustration I had with ABC when it wasn't being used for teaching but for day-to-day ad hoc programming," says Van Rossum, who in 1999 received an "Excellence in Programming" award from the Dr. Dobb's Journal for his Python work.

Nearly a decade after releasing the first version of Python, Van Rossum is currently looking at how to bridge the gap between languages that are easy for non-technical users to grasp and languages that are capable of performing industrial-strength computational tasks. Recently, he and other Python developers have joined together to form Computer Programming for Everybody, or CP4E, a project that is currently seeking funds from DARPA, the modern day descendant of the organization that helped build the early Internet. According to Van Rossum, CP4E will explore the way non-technical users engage in computing, in a way that will gain new insights into smoothing the human/machine interaction.

Fast, Free Prototyping in Python by Andrea Provaglio

Though Visual Basic has unbeatable GUI and COM capabilities, Python is an open-source tool with surprising utility for corporate development.

[Apr 02, 2000] Linux Gazette; Exploring parsing and virtual machines with Python


Recommended Links

Google matched content

Softpanorama Recommended

Top articles

[Apr 01, 2019] Amazon.com War with Russia From Putin Ukraine to Trump Russiagate (9781510745810) Stephen F. Cohen Books Published on Apr 01, 2019 | www.amazon.com

Sites

General

List of Python software - Wikipedia, the free encyclopedia

Reddit: python education

Free e-books (see also Best Python books for system administrators )

Stackless Python (actively maintained as of October 2017)


Tutorials

Give Python a try. I think you'll like it. The language itself rather tricky but small subset corresponding Basic is OK (see also discussion of the braces problem below).

All the power of Python is found in the extension modules and here you are in real jungle. For well written and widely use and documented modules you chances of success are higher, but still you are forced to operate of very high level of complexity.

In no way you can learn Python faster that classic programming languages. It is better to have an access to Python guru in the process. IMHO nobody has any change to master Perl in a week ;-). Here are some book that might slightly help.

One well written book and pretty recent book is

Online courses

A Gentle Introduction to Programming Using Python


Continuations


Jython



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2020 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: May, 30, 2021