User Tools

Site Tools


software_carpentary3

Python --- Interpreted Programming Language!!!

>>>Authors = [Medhamsh, medhamsh@swecha.net](Mail suggestions, typos please)

Interpreted –???

  • The instructions are executed immediately after parsing
  • Relative ease of programming (since once you type your instructions into a text file, the interpreter can run it) and no linker is required
  • Interpreted languages also tend to be more portable, able to be run without being modified for different computing environments
  • Suited for ad hoc requests or even for prototyping an application

Starting Python

Type 'python' at your shell and that should take you to the screen like this:

medhamsh@myhost:~$python

Python 2.7.2 (default, Jun 12 2011, 03:11:18) 
[GCC 4.6.0 20110603 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

That ">>>" is called a “prompt”, which means it’s something the computer displays to tell you it’s ready for your instructions. You can type things into that window, and the computer will obey them.

Python Calculator

What if we want to find out the sum of two and three?
Try the following at your python shell!

>>> Tell me the sum of two and three

Unfortunately the computer does not understand english! And we have to talk to it in special language. That special language here being python, fortunately is pretty easy for humans as well!!!

So, try it out like this: Type 2+3 and hit enter.

>>> 2+3
5
>>> 

As python is an interpreted programming language, you will have the results as you just hit on enter. Try various mathematical calculations.

  • Use + for addition
  • Use - for subtraction
  • Use * for multiplication (Not X)
  • Use / for division

Try using python as your pocket calculator!

Now try this. 1+2*3-4

>>> 1+2*3-4
3
>>> 

Is that what you expected? If you expected 5, try getting the output. You can use all sorts of paranthesis.

>>> (3+4)*(4+7)
77
>>> 

Incidentally, if you’re still confused about the fact that 1+2*3-4 gives 3 and not 5, the reason is that “multiplication happens before addition”. Your maths teacher at school probably calls this BODMAS or something similar.

Now, try this. 8/6

>>> 8/6
1
>>>

Did you expect it to be 1.3333333? Then you should try it like this: 8.0/6.0

>>> 8.0/6.0
1.3333333333333333
>>> 

Did you see the magical output?
This is how python treats numbers and how mathematical operations are performed.
Don’t be afraid to experiment. Whenever you learn something new that you can do with Python, try making slight changes (or bigger changes!) and play around until you’re confident that you understand just what’s going on. Don’t limit yourself to what’s actually printed here.

Objects

Till now we have played with python as your pocket calculator. Apart from that python can handle many things.
For Instance: Lets consider the hello world program.

>>> 'hello, ' + 'world'
'hello, world'
>>> 

Things between quotation marks are called “strings”. As you might guess from the lines above, you can apply + to strings as well as to numbers. It “concatenates” strings; that is, puts one immediately after the other.

Try this: 3 * 'hella '

>>>3*'hella '
'hella hella hella '
>>> 

You can surround strings in either single quotes or double quotes; Python doesn’t mind.

>>>'Doll' + "ar"
Dollar
>>>

Why would this(' , “) all matter?? Try printing: I'm Sorry!

Naming things

Giving names to things!

Suppose you know that you’re going to need to do a lot of calculations involving the number 123456. (Maybe it’s your annual salary in pounds, or something.) You could just type the number in every time:

>>> 123456*3
370368
>>> 123456/6
20576
>>> 123456-1000
122456

This might get very boring after a while. And if anyone else wanted to read what you were doing, they might be confused by the mysterious number 123456 and wonder why it appeared so often. We can solve either of these problems by giving the number a name. To save typing, give it a short name, like n (short for “number”, maybe). To make it more obvious what it means, give it a longer name, like salary. Here’s how we do that.

>>> salary=123456
>>> salary*4
493824
>>> salary/12
10288
>>> salary
123456

What we’ve called “names”, most people call “variables”. You’ll find out later why they’re called that.For now, “names” is fine.

Lists

Python also has lists!

Simple Lists

[1,2,3]

>>> [1,2,3]+[7,8]
[1, 2, 3, 7, 8]
>>> 

Methods of Lists

  • list.append(x): Add an item to the end of the list
  • list.extend(L): Extend the list by appending all the items in the given list
  • list.insert(i, x): Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list
  • list.remove(x): Remove the first item from the list whose value is x. It is an error if there is no such item
  • list.pop([i]): Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list
  • list.index(x): Return the index in the list of the first item whose value is x. It is an error if there is no such item
  • list.count(x): Return the number of times x appears in the list
  • list.sort(): Sort the items of the list, in place
  • list.reverse(): Reverse the elements of the list, in place

Lists as stack

The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (“last-in, first-out”). To add an item to the top of the stack, use append(). To retrieve an item from the top of the stack, use pop() without an explicit index.

>>> stack = [3, 4, 5]
>>> stack.append(6)
>>> stack.append(7)
>>> stack
[3, 4, 5, 6, 7]
>>> stack.pop()
7
>>> stack
[3, 4, 5, 6]
>>> stack.pop()
6
>>> stack.pop()
5
>>> stack
[3, 4]

Doing something Over and Over Again

So far we have done what your pocke calculator could do in math. Here's something your pocket calculator isn't so good at:

>>> for x in 1,2,3,4,5:
...    print x,x*x
...

The prompt changes to ... from >>>.It tells you that Python is expecting more. Just press Enter.

This is basically what people call as a 'for loop'.

Lists of lists of lists of...

Sometimes one list isn’t enough. Suppose you wanted to keep a list of what you had eaten for breakfast; it’s easy enough to write

>>> breakfast = [’idly’, ’puri’, ’dosa’, ’chapathi’]

and carry on. But suppose you wanted to list what you had eaten for breakfast every day, and you don’t always eat the same thing. What would we do?

Fortunately, Python is very helpful about this. Remember that we said earlier that lists were just collections of things. Well, lists are things too, so making lists of lists is just like making lists of anything else!

>>>breakfast = [
...   'Monday', ['idly', 'coffee'],
...   'Tuesday', ['dosa', 'juice', 'chutney'],
...   'Wednesday', ['coffee'] ]
>>> breakfast[3]
['dosa', 'juice', 'chutney']
>>> breakfast[1]
['idly', 'coffee']
>>> breakfast[0]
'Monday'
>>> breakfast[4]
'Wednesday'

Observed what happened? Try several things like that! Numbers in the square brackets indicate the indices.

Some people call lists of lists “2-dimensional arrays” or “tables”, because you can write them out in rows and columns (two dimensions!) like a table. Unlike real tables (and many other computer languages), in Python you don’t have to have every row the same length.

Excersises

  • Implement Fibonacci Series
  • Find a Palindrome
  • Find a if a number is divided by
    • 3
    • 5
    • 6
    • 9
    • 11
  • Factorial of a number
  • Write a program which takes a slice out of text
    • For example : text = “python” now, slice it to yt py ho hon.
  • Finding Unique words in a given text
    • Count of unique words, spaces, number
    • Count the number of occurrences of unique words
    • The unique words should be stored in a file.
    • The Unique words file should have only text, no numbers, no characters.
  • Find vowels consonants in a given text

This is the text. Copy the the text to a file and give the name of the file as fs-dataset.txt

The Free Software Definition

We maintain this free software definition to show clearly what must be true about a particular software program for it to be considered free software. From time to time we revise this definition to clarify it. If you would like to review the changes we've made, please see the History section below for more information.

“Free software” is a matter of liberty, not price. To understand the concept, you should think of “free” as in “free speech,” not as in “free beer.”

Free software is a matter of the users' freedom to run, copy, distribute, study, change and improve the software. More precisely, it means that the program's users have the four essential freedoms:

    * The freedom to run the program, for any purpose (freedom 0).
    * The freedom to study how the program works, and change it to make it do what you wish (freedom 1). Access to the source code is a precondition for this.
    * The freedom to redistribute copies so you can help your neighbor (freedom 2).
    * The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

A program is free software if users have all of these freedoms. Thus, you should be free to redistribute copies, either with or without modifications, either gratis or charging a fee for distribution, to anyone anywhere. Being free to do these things means (among other things) that you do not have to ask or pay for permission to do so.

You should also have the freedom to make modifications and use them privately in your own work or play, without even mentioning that they exist. If you do publish your changes, you should not be required to notify anyone in particular, or in any particular way.

The freedom to run the program means the freedom for any kind of person or organization to use it on any kind of computer system, for any kind of overall job and purpose, without being required to communicate about it with the developer or any other specific entity. In this freedom, it is the user's purpose that matters, not the developer's purpose; you as a user are free to run the program for your purposes, and if you distribute it to someone else, she is then free to run it for her purposes, but you are not entitled to impose your purposes on her.

The freedom to redistribute copies must include binary or executable forms of the program, as well as source code, for both modified and unmodified versions. (Distributing programs in runnable form is necessary for conveniently installable free operating systems.) It is OK if there is no way to produce a binary or executable form for a certain program (since some languages don't support that feature), but you must have the freedom to redistribute such forms should you find or develop a way to make them.

In order for freedoms 1 and 3 (the freedom to make changes and the freedom to publish improved versions) to be meaningful, you must have access to the source code of the program. Therefore, accessibility of source code is a necessary condition for free software. Obfuscated “source code” is not real source code and does not count as source code.

Freedom 1 includes the freedom to use your changed version in place of the original. If the program is delivered in a product designed to run someone else's modified versions but refuse to run yours — a practice known as “tivoization” or (in its practitioners' perverse terminology) as “secure boot” — freedom 1 becomes a theoretical fiction rather than a practical freedom. This is not sufficient. In other words, these binaries are not free software even if the source code they are compiled from is free.

One important way to modify a program is by merging in available free subroutines and modules. If the program's license says that you cannot merge in a suitably licensed existing module — for instance, if it requires you to be the copyright holder of any code you add — then the license is too restrictive to qualify as free.

Freedom 3 includes the freedom to release your modified versions as free software. A free license may also permit other ways of releasing them; in other words, it does not have to be a copyleft license. However, a license that requires modified versions to be nonfree does not qualify as a free license.

In order for these freedoms to be real, they must be permanent and irrevocable as long as you do nothing wrong; if the developer of the software has the power to revoke the license, or retroactively change its terms, without your doing anything wrong to give cause, the software is not free.

However, certain kinds of rules about the manner of distributing free software are acceptable, when they don't conflict with the central freedoms. For example, copyleft (very simply stated) is the rule that when redistributing the program, you cannot add restrictions to deny other people the central freedoms. This rule does not conflict with the central freedoms; rather it protects them.

“Free software” does not mean “noncommercial.” A free program must be available for commercial use, commercial development, and commercial distribution. Commercial development of free software is no longer unusual; such free commercial software is very important. You may have paid money to get copies of free software, or you may have obtained copies at no charge. But regardless of how you got your copies, you always have the freedom to copy and change the software, even to sell copies.

Whether a change constitutes an improvement is a subjective matter. If your modifications are limited, in substance, to changes that someone else considers an improvement, that is not freedom.

However, rules about how to package a modified version are acceptable, if they don't substantively limit your freedom to release modified versions, or your freedom to make and use modified versions privately. Thus, it is acceptable for the license to require that you change the name of the modified version, remove a logo, or identify your modifications as yours. As long as these requirements are not so burdensome that they effectively hamper you from releasing your changes, they are acceptable; you're already making other changes to the program, so you won't have trouble making a few more.

Rules that “if you make your version available in this way, you must make it available in that way also” can be acceptable too, on the same condition. An example of such an acceptable rule is one saying that if you have distributed a modified version and a previous developer asks for a copy of it, you must send one. (Note that such a rule still leaves you the choice of whether to distribute your version at all.) Rules that require release of source code to the users for versions that you put into public use are also acceptable.

In the GNU project, we use copyleft to protect these freedoms legally for everyone. But noncopylefted free software also exists. We believe there are important reasons why it is better to use copyleft, but if your program is noncopylefted free software, it is still basically ethical. (See Categories of Free Software for a description of how “free software,” “copylefted software” and other categories of software relate to each other.)

Sometimes government export control regulations and trade sanctions can constrain your freedom to distribute copies of programs internationally. Software developers do not have the power to eliminate or override these restrictions, but what they can and must do is refuse to impose them as conditions of use of the program. In this way, the restrictions will not affect activities and people outside the jurisdictions of these governments. Thus, free software licenses must not require obedience to any export regulations as a condition of any of the essential freedoms.

Most free software licenses are based on copyright, and there are limits on what kinds of requirements can be imposed through copyright. If a copyright-based license respects freedom in the ways described above, it is unlikely to have some other sort of problem that we never anticipated (though this does happen occasionally). However, some free software licenses are based on contracts, and contracts can impose a much larger range of possible restrictions. That means there are many possible ways such a license could be unacceptably restrictive and nonfree.

We can't possibly list all the ways that might happen. If a contract-based license restricts the user in an unusual way that copyright-based licenses cannot, and which isn't mentioned here as legitimate, we will have to think about it, and we will probably conclude it is nonfree.

When talking about free software, it is best to avoid using terms like “give away” or “for free,” because those terms imply that the issue is about price, not freedom. Some common terms such as “piracy” embody opinions we hope you won't endorse. See Confusing Words and Phrases that are Worth Avoiding for a discussion of these terms. We also have a list of proper translations of “free software” into various languages.

Finally, note that criteria such as those stated in this free software definition require careful thought for their interpretation. To decide whether a specific software license qualifies as a free software license, we judge it based on these criteria to determine whether it fits their spirit as well as the precise words. If a license includes unconscionable restrictions, we reject it, even if we did not anticipate the issue in these criteria. Sometimes a license requirement raises an issue that calls for extensive thought, including discussions with a lawyer, before we can decide if the requirement is acceptable. When we reach a conclusion about a new issue, we often update these criteria to make it easier to see why certain licenses do or don't qualify.

If you are interested in whether a specific license qualifies as a free software license, see our list of licenses. If the license you are concerned with is not listed there, you can ask us about it by sending us email at <licensing@gnu.org>.

If you are contemplating writing a new license, please contact the Free Software Foundation first by writing to that address. The proliferation of different free software licenses means increased work for users in understanding the licenses; we may be able to help you find an existing free software license that meets your needs.

If that isn't possible, if you really need a new license, with our help you can ensure that the license really is a free software license and avoid various practical problems.
Beyond Software

Software manuals must be free, for the same reasons that software must be free, and because the manuals are in effect part of the software.

The same arguments also make sense for other kinds of works of practical use — that is to say, works that embody useful knowledge, such as educational works and reference works. Wikipedia is the best-known example.

Any kind of work can be free, and the definition of free software has been extended to a definition of free cultural works applicable to any kind of works.
Open Source?

Another group has started using the term “open source” to mean something close (but not identical) to “free software.” We prefer the term “free software” because, once you have heard that it refers to freedom rather than price, it calls to mind freedom. The word “open” never refers to freedom.
History

From time to time we revise this Free Software Definition to clarify it. Here we provide a list of those modifications, along with links to illustrate exactly what changed, so that others can review them if they like.

    * Version 1.92: Clarify that obfuscated code does not qualify as source code.
    * Version 1.90: Clarify that freedom 3 means the right to distribute copies of your own modified or improved version, not a right to participate in someone else's development project.
    * Version 1.89: Freedom 3 includes the right to release modified versions as free software.
    * Version 1.80: Freedom 1 must be practical, not just theoretical; i.e., no tivoization.
    * Version 1.77: Clarify that all retroactive changes to the license are unacceptable, even if it's not described as a complete replacement.
    * Version 1.74: Four clarifications of points not explicit enough, or stated in some places but not reflected everywhere:
          o "Improvements" does not mean the license can substantively limit what kinds of modified versions you can release. Freedom 3 includes distributing modified versions, not just changes.
          o The right to merge in existing modules refers to those that are suitably licensed.
          o Explicitly state the conclusion of the point about export controls.
          o Imposing a license change constitutes revoking the old license.
    * Version 1.57: Add "Beyond Software" section.
    * Version 1.46: Clarify whose purpose is significant in the freedom to run the program for any purpose.
    * Version 1.41: Clarify wording about contract-based licenses.
    * Version 1.40: Explain that a free license must allow to you use other available free software to create your modifications.
    * Version 1.39: Note that it is acceptable for a license to require you to provide source for versions of the software you put into public use.
    * Version 1.31: Note that it is acceptable for a license to require you to identify yourself as the author of modifications. Other minor clarifications throughout the text.
    * Version 1.23: Address potential problems related to contract-based licenses.
    * Version 1.16: Explain why distribution of binaries is important.
    * Version 1.11: Note that a free license may require you to send a copy of versions you distribute to the author.

There are gaps in the version numbers because there are many other changes that do not affect the substance of the definition at all. Instead, they fix links, add translations, and so on. If you would like to review the complete list of changes, you can do so on our cvsweb interface.

What is Copyleft?

Copyleft is a general method for making a program (or other work) free, and requiring all modified and extended versions of the program to be free as well.

The simplest way to make a program free software is to put it in the public domain, uncopyrighted. This allows people to share the program and their improvements, if they are so minded. But it also allows uncooperative people to convert the program into proprietary software. They can make changes, many or few, and distribute the result as a proprietary product. People who receive the program in that modified form do not have the freedom that the original author gave them; the middleman has stripped it away.

In the GNU project, our aim is to give all users the freedom to redistribute and change GNU software. If middlemen could strip off the freedom, we might have many users, but those users would not have freedom. So instead of putting GNU software in the public domain, we “copyleft” it. Copyleft says that anyone who redistributes the software, with or without changes, must pass along the freedom to further copy and change it. Copyleft guarantees that every user has freedom.

Copyleft also provides an incentive for other programmers to add to free software. Important free programs such as the GNU C++ compiler exist only because of this.

Copyleft also helps programmers who want to contribute improvements to free software get permission to do so. These programmers often work for companies or universities that would do almost anything to get more money. A programmer may want to contribute her changes to the community, but her employer may want to turn the changes into a proprietary software product.

When we explain to the employer that it is illegal to distribute the improved version except as free software, the employer usually decides to release it as free software rather than throw it away.

To copyleft a program, we first state that it is copyrighted; then we add distribution terms, which are a legal instrument that gives everyone the rights to use, modify, and redistribute the program's code, or any program derived from it, but only if the distribution terms are unchanged. Thus, the code and the freedoms become legally inseparable.

Proprietary software developers use copyright to take away the users' freedom; we use copyright to guarantee their freedom. That's why we reverse the name, changing “copyright” into “copyleft.”

Copyleft is a way of using of the copyright on the program. It doesn't mean abandoning the copyright; in fact, doing so would make copyleft impossible. The “left” in “copyleft” is not a reference to the verb “to leave”—only to the direction which is the inverse of “right”.

Copyleft is a general concept, and you can't use a general concept directly; you can only use a specific implementation of the concept. In the GNU Project, the specific distribution terms that we use for most software are contained in the GNU General Public License (available in HTML, text, and Texinfo format). The GNU General Public License is often called the GNU GPL for short. There is also a Frequently Asked Questions page about the GNU GPL. You can also read about why the FSF gets copyright assignments from contributors.

An alternate form of copyleft, the GNU Lesser General Public License (LGPL) (available in HTML, text, and Texinfo format), applies to a few (but not all) GNU libraries. To learn more about properly using the LGPL, please read the article Why you shouldn't use the Lesser GPL for your next library.

The GNU Free Documentation License (FDL) (available in HTML, text and Texinfo) is a form of copyleft intended for use on a manual, textbook or other document to assure everyone the effective freedom to copy and redistribute it, with or without modifications, either commercially or noncommercially.

The appropriate license is included in many manuals and in each GNU source code distribution.

All these licenses are designed so that you can easily apply them to your own works, assuming you are the copyright holder. You don't have to modify the license to do this, just include a copy of the license in the work, and add notices in the source files that refer properly to the license.

Using the same distribution terms for many different programs makes it easy to copy code between various different programs. When they all have the same distribution terms, there is no problem. The Lesser GPL, version 2, includes a provision that lets you alter the distribution terms to the ordinary GPL, so that you can copy code into another program covered by the GPL. Version 3 of the Lesser GPL is built as an exception added to GPL version 3, making the compatibility automatic.

If you would like to copyleft your program with the GNU GPL or the GNU LGPL, please see the license instructions page for advice. Please note that you must use the entire text of the license you choose. Each is an integral whole, and partial copies are not permitted.

If you would like to copyleft your manual with the GNU FDL, please see the instructions at the end of the FDL text, and the GFDL instructions page. Again, partial copies are not permitted.

Why Software Should Not Have Owners

by Richard Stallman

Digital information technology contributes to the world by making it easier to copy and modify information. Computers promise to make this easier for all of us.

Not everyone wants it to be easier. The system of copyright gives software programs “owners”, most of whom aim to withhold software's potential benefit from the rest of the public. They would like to be the only ones who can copy and modify the software that we use.

The copyright system grew up with printing—a technology for mass-production copying. Copyright fit in well with this technology because it restricted only the mass producers of copies. It did not take freedom away from readers of books. An ordinary reader, who did not own a printing press, could copy books only with pen and ink, and few readers were sued for that.

Digital technology is more flexible than the printing press: when information has digital form, you can easily copy it to share it with others. This very flexibility makes a bad fit with a system like copyright. That's the reason for the increasingly nasty and draconian measures now used to enforce software copyright. Consider these four practices of the Software Publishers Association (SPA):

    * Massive propaganda saying it is wrong to disobey the owners to help your friend.
    * Solicitation for stool pigeons to inform on their coworkers and colleagues.
    * Raids (with police help) on offices and schools, in which people are told they must prove they are innocent of illegal copying.
    * Prosecution (by the US government, at the SPA's request) of people such as MIT's David LaMacchia, not for copying software (he is not accused of copying any), but merely for leaving copying facilities unguarded and failing to censor their use.[1]

All four practices resemble those used in the former Soviet Union, where every copying machine had a guard to prevent forbidden copying, and where individuals had to copy information secretly and pass it from hand to hand as samizdat. There is of course a difference: the motive for information control in the Soviet Union was political; in the US the motive is profit. But it is the actions that affect us, not the motive. Any attempt to block the sharing of information, no matter why, leads to the same methods and the same harshness.

Owners make several kinds of arguments for giving them the power to control how we use information:

    * Name calling.

      Owners use smear words such as “piracy” and “theft”, as well as expert terminology such as “intellectual property” and “damage”, to suggest a certain line of thinking to the public—a simplistic analogy between programs and physical objects.

      Our ideas and intuitions about property for material objects are about whether it is right to take an object away from someone else. They don't directly apply to making a copy of something. But the owners ask us to apply them anyway.
    * Exaggeration.

      Owners say that they suffer “harm” or “economic loss” when users copy programs themselves. But the copying has no direct effect on the owner, and it harms no one. The owner can lose only if the person who made the copy would otherwise have paid for one from the owner.

      A little thought shows that most such people would not have bought copies. Yet the owners compute their “losses” as if each and every one would have bought a copy. That is exaggeration—to put it kindly.
    * The law.

      Owners often describe the current state of the law, and the harsh penalties they can threaten us with. Implicit in this approach is the suggestion that today's law reflects an unquestionable view of morality—yet at the same time, we are urged to regard these penalties as facts of nature that can't be blamed on anyone.

      This line of persuasion isn't designed to stand up to critical thinking; it's intended to reinforce a habitual mental pathway.

      It's elementary that laws don't decide right and wrong. Every American should know that, in the 1950s, it was against the law in many states for a black person to sit in the front of a bus; but only racists would say sitting there was wrong.
    * Natural rights.

      Authors often claim a special connection with programs they have written, and go on to assert that, as a result, their desires and interests concerning the program simply outweigh those of anyone else—or even those of the whole rest of the world. (Typically companies, not authors, hold the copyrights on software, but we are expected to ignore this discrepancy.)

      To those who propose this as an ethical axiom—the author is more important than you—I can only say that I, a notable software author myself, call it bunk.

      But people in general are only likely to feel any sympathy with the natural rights claims for two reasons.

      One reason is an overstretched analogy with material objects. When I cook spaghetti, I do object if someone else eats it, because then I cannot eat it. His action hurts me exactly as much as it benefits him; only one of us can eat the spaghetti, so the question is, which one? The smallest distinction between us is enough to tip the ethical balance.

      But whether you run or change a program I wrote affects you directly and me only indirectly. Whether you give a copy to your friend affects you and your friend much more than it affects me. I shouldn't have the power to tell you not to do these things. No one should.

      The second reason is that people have been told that natural rights for authors is the accepted and unquestioned tradition of our society.

      As a matter of history, the opposite is true. The idea of natural rights of authors was proposed and decisively rejected when the US Constitution was drawn up. That's why the Constitution only permits a system of copyright and does not require one; that's why it says that copyright must be temporary. It also states that the purpose of copyright is to promote progress—not to reward authors. Copyright does reward authors somewhat, and publishers more, but that is intended as a means of modifying their behavior.

      The real established tradition of our society is that copyright cuts into the natural rights of the public—and that this can only be justified for the public's sake.
    * Economics.

      The final argument made for having owners of software is that this leads to production of more software.

      Unlike the others, this argument at least takes a legitimate approach to the subject. It is based on a valid goal—satisfying the users of software. And it is empirically clear that people will produce more of something if they are well paid for doing so.

      But the economic argument has a flaw: it is based on the assumption that the difference is only a matter of how much money we have to pay. It assumes that production of software is what we want, whether the software has owners or not.

      People readily accept this assumption because it accords with our experiences with material objects. Consider a sandwich, for instance. You might well be able to get an equivalent sandwich either gratis or for a price. If so, the amount you pay is the only difference. Whether or not you have to buy it, the sandwich has the same taste, the same nutritional value, and in either case you can only eat it once. Whether you get the sandwich from an owner or not cannot directly affect anything but the amount of money you have afterwards.

      This is true for any kind of material object—whether or not it has an owner does not directly affect what it is, or what you can do with it if you acquire it.

      But if a program has an owner, this very much affects what it is, and what you can do with a copy if you buy one. The difference is not just a matter of money. The system of owners of software encourages software owners to produce something—but not what society really needs. And it causes intangible ethical pollution that affects us all.

What does society need? It needs information that is truly available to its citizens—for example, programs that people can read, fix, adapt, and improve, not just operate. But what software owners typically deliver is a black box that we can't study or change.

Society also needs freedom. When a program has an owner, the users lose freedom to control part of their own lives.

And, above all, society needs to encourage the spirit of voluntary cooperation in its citizens. When software owners tell us that helping our neighbors in a natural way is “piracy”, they pollute our society's civic spirit.

This is why we say that free software is a matter of freedom, not price.

The economic argument for owners is erroneous, but the economic issue is real. Some people write useful software for the pleasure of writing it or for admiration and love; but if we want more software than those people write, we need to raise funds.

Since the 1980s, free software developers have tried various methods of finding funds, with some success. There's no need to make anyone rich; a typical income is plenty of incentive to do many jobs that are less satisfying than programming.

For years, until a fellowship made it unnecessary, I made a living from custom enhancements of the free software I had written. Each enhancement was added to the standard released version and thus eventually became available to the general public. Clients paid me so that I would work on the enhancements they wanted, rather than on the features I would otherwise have considered highest priority.

Some free software developers make money by selling support services. In 1994, Cygnus Support, with around 50 employees, estimated that about 15 percent of its staff activity was free software development—a respectable percentage for a software company.

In the early 1990s, companies including Intel, Motorola, Texas Instruments and Analog Devices combined to fund the continued development of the GNU C compiler. Most GCC development is still done by paid developers. The GNU compiler for the Ada language was funded in the 90s by the US Air Force, and continued since then by a company formed specifically for the purpose.

The free software movement is still small, but the example of listener-supported radio in the US shows it's possible to support a large activity without forcing each user to pay.

As a computer user today, you may find yourself using a proprietary program. If your friend asks to make a copy, it would be wrong to refuse. Cooperation is more important than copyright. But underground, closet cooperation does not make for a good society. A person should aspire to live an upright life openly with pride, and this means saying no to proprietary software.

You deserve to be able to cooperate openly and freely with other people who use software. You deserve to be able to learn how the software works, and to teach your students with it. You deserve to be able to hire your favorite programmer to fix it when it breaks.

You deserve free software.
Footnotes

   1. The charges were subsequently dismissed.

Copyleft: Pragmatic Idealism

by Richard Stallman

Every decision a person makes stems from the person's values and goals. People can have many different goals and values; fame, profit, love, survival, fun, and freedom, are just some of the goals that a good person might have. When the goal is a matter of principle, we call that idealism.

My work on free software is motivated by an idealistic goal: spreading freedom and cooperation. I want to encourage free software to spread, replacing proprietary software that forbids cooperation, and thus make our society better.

That's the basic reason why the GNU General Public License is written the way it is—as a copyleft. All code added to a GPL-covered program must be free software, even if it is put in a separate file. I make my code available for use in free software, and not for use in proprietary software, in order to encourage other people who write software to make it free as well. I figure that since proprietary software developers use copyright to stop us from sharing, we cooperators can use copyright to give other cooperators an advantage of their own: they can use our code.

Not everyone who uses the GNU GPL has this goal. Many years ago, a friend of mine was asked to rerelease a copylefted program under noncopyleft terms, and he responded more or less like this:

    “Sometimes I work on free software, and sometimes I work on proprietary software—but when I work on proprietary software, I expect to get paid.” 

He was willing to share his work with a community that shares software, but saw no reason to give a handout to a business making products that would be off-limits to our community. His goal was different from mine, but he decided that the GNU GPL was useful for his goal too.

If you want to accomplish something in the world, idealism is not enough—you need to choose a method that works to achieve the goal. In other words, you need to be “pragmatic.” Is the GPL pragmatic? Let's look at its results.

Consider GNU C++. Why do we have a free C++ compiler? Only because the GNU GPL said it had to be free. GNU C++ was developed by an industry consortium, MCC, starting from the GNU C compiler. MCC normally makes its work as proprietary as can be. But they made the C++ front end free software, because the GNU GPL said that was the only way they could release it. The C++ front end included many new files, but since they were meant to be linked with GCC, the GPL did apply to them. The benefit to our community is evident.

Consider GNU Objective C. NeXT initially wanted to make this front end proprietary; they proposed to release it as .o files, and let users link them with the rest of GCC, thinking this might be a way around the GPL's requirements. But our lawyer said that this would not evade the requirements, that it was not allowed. And so they made the Objective C front end free software.

Those examples happened years ago, but the GNU GPL continues to bring us more free software.

Many GNU libraries are covered by the GNU Lesser General Public License, but not all. One GNU library which is covered by the ordinary GNU GPL is Readline, which implements command-line editing. I once found out about a nonfree program which was designed to use Readline, and told the developer this was not allowed. He could have taken command-line editing out of the program, but what he actually did was rerelease it under the GPL. Now it is free software.

The programmers who write improvements to GCC (or Emacs, or Bash, or Linux, or any GPL-covered program) are often employed by companies or universities. When the programmer wants to return his improvements to the community, and see his code in the next release, the boss may say, “Hold on there—your code belongs to us! We don't want to share it; we have decided to turn your improved version into a proprietary software product.”

Here the GNU GPL comes to the rescue. The programmer shows the boss that this proprietary software product would be copyright infringement, and the boss realizes that he has only two choices: release the new code as free software, or not at all. Almost always he lets the programmer do as he intended all along, and the code goes into the next release.

The GNU GPL is not Mr. Nice Guy. It says no to some of the things that people sometimes want to do. There are users who say that this is a bad thing—that the GPL “excludes” some proprietary software developers who “need to be brought into the free software community.”

But we are not excluding them from our community; they are choosing not to enter. Their decision to make software proprietary is a decision to stay out of our community. Being in our community means joining in cooperation with us; we cannot “bring them into our community” if they don't want to join.

What we can do is offer them an inducement to join. The GNU GPL is designed to make an inducement from our existing software: “If you will make your software free, you can use this code.” Of course, it won't win 'em all, but it wins some of the time.

Proprietary software development does not contribute to our community, but its developers often want handouts from us. Free software users can offer free software developers strokes for the ego—recognition and gratitude—but it can be very tempting when a business tells you, “Just let us put your package in our proprietary program, and your program will be used by many thousands of people!” The temptation can be powerful, but in the long run we are all better off if we resist it.

The temptation and pressure are harder to recognize when they come indirectly, through free software organizations that have adopted a policy of catering to proprietary software. The X Consortium (and its successor, the Open Group) offers an example: funded by companies that made proprietary software, they strived for a decade to persuade programmers not to use copyleft. When the Open Group tried to make X11R6.4 nonfree software, those of us who had resisted that pressure were glad that we did.

In September 1998, several months after X11R6.4 was released with nonfree distribution terms, the Open Group reversed its decision and rereleased it under the same noncopyleft free software license that was used for X11R6.3. Thank you, Open Group—but this subsequent reversal does not invalidate the conclusions we draw from the fact that adding the restrictions was possible.

Pragmatically speaking, thinking about greater long-term goals will strengthen your will to resist this pressure. If you focus your mind on the freedom and community that you can build by staying firm, you will find the strength to do it. “Stand for something, or you will fall for anything.”

And if cynics ridicule freedom, ridicule community…if “hard-nosed realists” say that profit is the only ideal…just ignore them, and use copyleft all the same.

Why Free Software needs Free Documentation

    * The GNU Free Documentation License

The biggest deficiency in free operating systems is not in the software—it is the lack of good free manuals that we can include in these systems. Many of our most important programs do not come with full manuals. Documentation is an essential part of any software package; when an important free software package does not come with a free manual, that is a major gap. We have many such gaps today.

Once upon a time, many years ago, I thought I would learn Perl. I got a copy of a free manual, but I found it hard to read. When I asked Perl users about alternatives, they told me that there were better introductory manuals—but those were not free.

Why was this? The authors of the good manuals had written them for O'Reilly Associates, which published them with restrictive terms—no copying, no modification, source files not available—which exclude them from the free software community.

That wasn't the first time this sort of thing has happened, and (to our community's great loss) it was far from the last. Proprietary manual publishers have enticed a great many authors to restrict their manuals since then. Many times I have heard a GNU user eagerly tell me about a manual that he is writing, with which he expects to help the GNU Project—and then had my hopes dashed, as he proceeded to explain that he had signed a contract with a publisher that would restrict it so that we cannot use it.

Given that writing good English is a rare skill among programmers, we can ill afford to lose manuals this way.

Free documentation, like free software, is a matter of freedom, not price. The problem with these manuals was not that O'Reilly Associates charged a price for printed copies—that in itself is fine. (The Free Software Foundation sells printed copies of free GNU manuals, too.) But GNU manuals are available in source code form, while these manuals are available only on paper. GNU manuals come with permission to copy and modify; the Perl manuals do not. These restrictions are the problems.

The criterion for a free manual is pretty much the same as for free software: it is a matter of giving all users certain freedoms. Redistribution (including commercial redistribution) must be permitted, so that the manual can accompany every copy of the program, on line or on paper. Permission for modification is crucial too.

As a general rule, I don't believe that it is essential for people to have permission to modify all sorts of articles and books. The issues for writings are not necessarily the same as those for software. For example, I don't think you or I are obliged to give permission to modify articles like this one, which describe our actions and our views.

But there is a particular reason why the freedom to modify is crucial for documentation for free software. When people exercise their right to modify the software, and add or change its features, if they are conscientious they will change the manual too—so they can provide accurate and usable documentation with the modified program. A manual which forbids programmers from being conscientious and finishing the job, or more precisely requires them to write a new manual from scratch if they change the program, does not fill our community's needs.

While a blanket prohibition on modification is unacceptable, some kinds of limits on the method of modification pose no problem. For example, requirements to preserve the original author's copyright notice, the distribution terms, or the list of authors, are OK. It is also no problem to require modified versions to include notice that they were modified, even to have entire sections that may not be deleted or changed, as long as these sections deal with nontechnical topics. (Some GNU manuals have them.)

These kinds of restrictions are not a problem because, as a practical matter, they don't stop the conscientious programmer from adapting the manual to fit the modified program. In other words, they don't block the free software community from making full use of the manual.

However, it must be possible to modify all the technical content of the manual, and then distribute the result through all the usual media, through all the usual channels; otherwise, the restrictions do block the community, the manual is not free, and so we need another manual.

Unfortunately, it is often hard to find someone to write another manual when a proprietary manual exists. The obstacle is that many users think that a proprietary manual is good enough—so they don't see the need to write a free manual. They do not see that the free operating system has a gap that needs filling.

Why do users think that proprietary manuals are good enough? Some have not considered the issue. I hope this article will do something to change that.

Other users consider proprietary manuals acceptable for the same reason so many people consider proprietary software acceptable: they judge in purely practical terms, not using freedom as a criterion. These people are entitled to their opinions, but since those opinions spring from values which do not include freedom, they are no guide for those of us who do value freedom.

Please spread the word about this issue. We continue to lose manuals to proprietary publishing. If we spread the word that proprietary manuals are not sufficient, perhaps the next person who wants to help GNU by writing documentation will realize, before it is too late, that he must above all make it free.

We can also encourage commercial publishers to sell free, copylefted manuals instead of proprietary ones. One way you can help this is to check the distribution terms of a manual before you buy it, and prefer copylefted manuals to noncopylefted ones.

[Note: We maintain a page that lists free books available from other publishers].

Selling Free Software

Some views on the ideas of selling exceptions to free software licenses, such as the GNU GPL are also available.

Many people believe that the spirit of the GNU Project is that you should not charge money for distributing copies of software, or that you should charge as little as possible — just enough to cover the cost. This is a misunderstanding.

Actually, we encourage people who redistribute free software to charge as much as they wish or can. If this seems surprising to you, please read on.

The word “free” has two legitimate general meanings; it can refer either to freedom or to price. When we speak of “free software”, we're talking about freedom, not price. (Think of “free speech”, not “free beer”.) Specifically, it means that a user is free to run the program, change the program, and redistribute the program with or without changes.

Free programs are sometimes distributed gratis, and sometimes for a substantial price. Often the same program is available in both ways from different places. The program is free regardless of the price, because users have freedom in using it.

Nonfree programs are usually sold for a high price, but sometimes a store will give you a copy at no charge. That doesn't make it free software, though. Price or no price, the program is nonfree because users don't have freedom.

Since free software is not a matter of price, a low price doesn't make the software free, or even closer to free. So if you are redistributing copies of free software, you might as well charge a substantial fee and make some money. Redistributing free software is a good and legitimate activity; if you do it, you might as well make a profit from it.

Free software is a community project, and everyone who depends on it ought to look for ways to contribute to building the community. For a distributor, the way to do this is to give a part of the profit to free software development projects or to the Free Software Foundation. This way you can advance the world of free software.

Distributing free software is an opportunity to raise funds for development. Don't waste it!

In order to contribute funds, you need to have some extra. If you charge too low a fee, you won't have anything to spare to support development.
Will a higher distribution price hurt some users?

People sometimes worry that a high distribution fee will put free software out of range for users who don't have a lot of money. With proprietary software, a high price does exactly that — but free software is different.

The difference is that free software naturally tends to spread around, and there are many ways to get it.

Software hoarders try their damnedest to stop you from running a proprietary program without paying the standard price. If this price is high, that does make it hard for some users to use the program.

With free software, users don't have to pay the distribution fee in order to use the software. They can copy the program from a friend who has a copy, or with the help of a friend who has network access. Or several users can join together, split the price of one CD-ROM, then each in turn can install the software. A high CD-ROM price is not a major obstacle when the software is free.
Will a higher distribution price discourage use of free software?

Another common concern is for the popularity of free software. People think that a high price for distribution would reduce the number of users, or that a low price is likely to encourage users.

This is true for proprietary software — but free software is different. With so many ways to get copies, the price of distribution service has less effect on popularity.

In the long run, how many people use free software is determined mainly by how much free software can do, and how easy it is to use. Many users do not make freedom their priority; they may continue to use proprietary software if free software can't do all the jobs they want done. Thus, if we want to increase the number of users in the long run, we should above all develop more free software.

The most direct way to do this is by writing needed free software or manuals yourself. But if you do distribution rather than writing, the best way you can help is by raising funds for others to write them.
The term “selling software” can be confusing too

Strictly speaking, “selling” means trading goods for money. Selling a copy of a free program is legitimate, and we encourage it.

However, when people think of “selling software”, they usually imagine doing it the way most companies do it: making the software proprietary rather than free.

So unless you're going to draw distinctions carefully, the way this article does, we suggest it is better to avoid using the term “selling software” and choose some other wording instead. For example, you could say “distributing free software for a fee”—that is unambiguous.
High or low fees, and the GNU GPL

Except for one special situation, the GNU General Public License (GNU GPL) has no requirements about how much you can charge for distributing a copy of free software. You can charge nothing, a penny, a dollar, or a billion dollars. It's up to you, and the marketplace, so don't complain to us if nobody wants to pay a billion dollars for a copy.

The one exception is in the case where binaries are distributed without the corresponding complete source code. Those who do this are required by the GNU GPL to provide source code on subsequent request. Without a limit on the fee for the source code, they would be able set a fee too large for anyone to pay—such as a billion dollars—and thus pretend to release source code while in truth concealing it. So in this case we have to limit the fee for source in order to ensure the user's freedom. In ordinary situations, however, there is no such justification for limiting distribution fees, so we do not limit them.

Sometimes companies whose activities cross the line stated in the GNU GPL plead for permission, saying that they “won't charge money for the GNU software” or such like. That won't get them anywhere with us. Free software is about freedom, and enforcing the GPL is defending freedom. When we defend users' freedom, we are not distracted by side issues such as how much of a distribution fee is charged. Freedom is the issue, the whole issue, and the only issue.

Motives For Writing Free Software

These are some of the motives for writing free software.

    * Fun. For some people, often the best programmers, writing software is the greatest fun, especially when there is no boss to tell you what to do. Nearly all free software developers share this motive.
    * Political idealism. The desire to build a world of freedom, and help computer users escape from the power of software developers.
    * To be admired. If you write a successful, useful free program, the users will admire you. That feels very good.
    * Professional reputation. If you write a successful, useful free program, that will suffice to show you are a good programmer.
    * Gratitude. If you have used the community's free programs for years, and it has been important to your work, you feel grateful and indebted to their developers. When you write a program that could be useful to many people, that is your chance to pay it forward.
    * Hatred for Microsoft. It is a mistake to focus our criticism narrowly on Microsoft. Indeed, Microsoft is evil, since it makes non-free software. Even worse, it implements Digital Restrictions Management in that software. But many other companies do one or both of these. Nonetheless, it is a fact that many people utterly despise Microsoft, and some contribute to free software based on that feeling.
    * Money. A considerable number of people are paid to develop free software or have built businesses around it.
    * Wanting a better program to use. People often work on improvements in programs they use, in order to make them more convenient. (Some commentators recognize no motive other than this, but their picture of human nature is too narrow.)

Human nature is complex, and it is quite common for a person to have multiple simultaneous motives for a single action.

Free software projects, and policies that affect software development (such as laws), can't limit themselves to maximising the profit motive. When encouraging software development is the goal, all these motivations have to be considered, not just any particular one.

Each person is different, and there could be other motives that are missing from this list. If you know of other motives not listed here, please send email to <campaigns@gnu.org>. If we think the other motives are likely to influence many developers, we will add them to the list.

Is Microsoft the Great Satan?

    This article was given a major rewrite in 2009. The old version is also available.

Many people think of Microsoft as the monster menace of the software industry. There is even a specific campaign to boycott Microsoft. This feeling has intensified since Microsoft expressed active hostility towards free software.

In the free software movement, our perspective is different. We see that Microsoft is doing something that mistreats software users: making software proprietary and thus denying users their rightful freedom. But Microsoft is not alone in this; many other companies do the same thing to the users. If other companies manage to dominate fewer users than Microsoft, that is not for lack of trying.

This is not meant to excuse Microsoft. Rather, it is meant as a reminder that Microsoft is the natural development of a software industry based on keeping users divided and subjugating them. When criticizing Microsoft, we should not focus so narrowly on Microsoft that we let other proprietary software developers off the hook.

When we reject Microsoft's proprietary software, that is not a boycott. The word “boycott” means rejection, as a protest, of products that are otherwise acceptable. Rejecting a product because it hurts you is not a boycott, just ordinary rationality. To maintain your freedom, you need to reject all proprietary software, regardless of who developed it or who distributes it.

There is no need to reject Microsoft non-software products, or services that you can use without proprietary software. (When you use a web service, whether Microsoft's or not, watch out for non-free JavaScript programs that it may try to slip into your browser.) When Microsoft releases free programs, which it occasionally does, they are acceptable in theory; but most of them depend fundamentally on Microsoft proprietary software, which we do need to reject, and that makes them useless for anyone that chooses to live in freedom.

In the “Halloween documents”, leaked in October 1998, Microsoft executives stated an intention to use various methods to obstruct the development of free software: specifically, designing secret protocols and file formats, and patenting algorithms and software features.

These obstructionist policies were not new: Microsoft, and many other software companies, had been doing them for years. Secrecy and patents have obstructed us greatly, and they may be more damaging in the future. For the most part, the companies' main motivation in doing these things is to attack each other; now, it seems, we are specifically targeted. Microsoft is using its patents directly to attack the free software community, and our community is fighting back.

But Microsoft's patents are not the only patents that threaten us (and software developers and users generally)—consider the harm that the MP3 patent has done. Thus, defending against specific attacks is necessary but not sufficient. The only full solution is to eliminate software patents.

Other Microsoft practices specifically harmful to the adoption of free software are the ones designed to build up social inertia that obstructs migration to GNU/Linux. For instance, when Microsoft “donates” copies of Windows to schools, it converts these schools into tools for implanting a dependence on Windows. There are indications that Microsoft systematically plans these activities as a campaign against the adoption of GNU/Linux.

Each Windows “upgrade” augments Microsoft's power over the users; Microsoft plans it that way. And each one is a step forward in malicious features, which include Digital Restrictions Management and back doors. So the FSF runs campaigns to warn users against “upgrading” to Windows Vista and Windows 7. We aim to reduce the amount of inertia they will create.

We don't hate Microsoft, and we don't consider it the Great Satan. But we do recognize it as the company that has separated more users from their freedom than any other, and a powerful avowed enemy of computer users' freedom. We act accordingly.

What is DRM? Digital Restrictions Management

Big Media describe DRM as Digital Rights Management. However, since its purpose is to restrict you the user, it is more accurate to describe DRM as Digital Restrictions Management. DRM Technology can restricts users’ access to movies, music, literature and software, indeed all forms of digital data. Unfree software implementing DRM technology is simply a prison in which users can be put to deprive them of the rights that the law would otherwise allow them.

After months of campaigning during 2006, DefectiveByDesign.org declared Tuesday October 3rd 2006, an international "Day Against DRM". With more than 10,000 technologists having joined in the campaign and pledged to take direct action to stop DRM, and with more than 200 "actions" planned across the globe on October 3rd, we had achieved our goal of raising public awareness to the threats posed by DRM.

Now we must move from awareness of DRM to rejection of DRM. DRM technology is not vanquished. It is still a growing problem for all computer users, and by extension all of society. DRM is being used to restrict individuals' use of their own copies of published works. To enforce these restrictions, DRM software, and now hardware, must monitor and control a computer users' behavior. Frequently it reports on what it sees.

Products with DRM

Certain categories of products are disproportionately impacted by DRM. When you're considering buying a product in one of these categories, it's a good idea to do a quick search (on Defective by Design or the web at large).

    * Music
    * Movies (see: bluray)
    * ebooks (see: Kindle Swindle)
    * Computers (Mac and Windows)
    * Mobile phones (e.g. the iPhone)
    * Games

The Fight

You might be aware that the DVDs (or Bluray disks) you buy are encrypted. All of the video and audio on these disks are coded using a key that the hardware attempts to keep secret. Hollywood requires that all DVD manufacturers participate in this restrictive practice, and they can use the DMCA to make any device that doesn't participate in their scheme illegal.

This type of nuisance is but the foreshadow of greater ones to come. Standing behind the technology companies, the film and music industry (Big Media) loom large. To increase their control, they demand technology companies impose DRM. The technology companies no longer resist. Of course many of the technology companies now see themselves as part of Big Media. Sony is a film and music company, Microsoft is an owner of MSNBC, and Steve Jobs, the CEO of Apple, sits on the board of Disney. These technology companies cannot be expected to serve the interests of the technology consumer.

Big Media hope that DRM will deliver to them what their political lobbying to change copyright law never has: they aim to turn our every interaction with a published work into a transaction, abolishing fair use and the commons, and making copyright effectively last forever. They will say that you accepted DRM and willingly surrendered your rights. That you did so under duress, they will call irrelevant.

Amazon's new movie download service is called Unbox and it outlines what DRM implies. The user agreement requires that you allow Unbox DRM software to monitor your hard drive and to report activity to Amazon. These reports would thus include a list of: all the software installed; all the music and video you have; all your computer's interaction with other devices. You will surrender your freedom to such an extent that you will only be able to regain control by removing the software. But if you do remove the software you will also remove all your movies along with it. You are restricted even geographically, and you lose your movies if you ever move out of the USA. You of course have to agree that they can change these terms at any time. Microsoft's newly upgraded Windows Media Player 11 (WMP11) user agreement has a similar set of terms.

Each time Big Media force you to upgrade your software, they downgrade your rights. Every new DRM system will enforce a harsher control regime. Apple's added more restrictions to their music service, and their new video service is yet more restrictive. And so it goes. But this is not just happening with music and video, DRM is being applied to knowledge and information. Libraries, schools, universities are adding DRM, sometimes under duress, often without understanding the consequences.

What does this mean for the future? No fair use. No purchase and resell. No private copies. No sharing. No backup. No swapping. No mix tapes. No privacy. No commons. No control over our computers. No control over our electronic devices. The conversion of our homes into apparatus to monitor our interaction with published works and web sites.

If this type of invasion of privacy were coming from any other source, it would not be tolerated. That it is the media and technology companies leading the way, does not make it benign.

Users of free software are not immune to DRM either. They can be locked out, and their computers won't play the movies or music under lock. Products can "tivoize" their code (remove their freedom through DRM), delivering it back with malicious features and blocking removal. The RIAA and the MPAA are actively lobbying Congress to pass new laws to mandate DRM and outlaw products and computers that don't enforce DRM. DRM has become a major threat to the freedom of computer users.

When we allow others to control our computers and monitor our actions we invite deeper surveillance. With our personal viewing, listening, reading, browsing records on file, are we not to be alarmed?

In September 2005 a Disney executive named Peter Lee told The Economist, "If consumers even know there's a DRM, what it is, and how it works, we've already failed,". A year later, on October 3rd we made that prediction come true. Now with your help, we can work to put an end to DRM. You are encouraged to Join the campaign at DefectiveByDesign.org and take action.

Peter Brown
Defective By Design
Free Software Foundation

Regular Expressions

Finding and matching strings.

Use Cases:

  • Adding a period(full stop) at the end of 100 lines in a file.
  • Finding and replacing certain word with another word.(Hello with Hi)
  • Changing Rs. to $ in several occurances.

Implementation

  • Editors
  • Vi
  • Emacs
  • gedit
  • Programming Languages
  • Perl
  • Bash Scripts
  • Ruby
  • Unix Command Line
  • rename
  • grep
  • find
  • sed
  • Others
  • Syntax Highliting
  • Search Engine(Google)

Pattern Matching

'.' matches with any character
'*' repeats the previous expression zero or more times

Metacharacters

a. matches with as, ab, arch etc
^ matches the begining of a line
$ matches end of a line
| alternation eg. H|h matches h or H
() grouping eg. H|hello matches H or hello
(H|h)ello matches Hello or hello
\ escapes any meta character
Mr. matches Mr. and Mrs.
Mr\. matches only Mr.

Character Classes

  • [Hh] means (h|H)
  • [0-9] means (0|1|2|3|4|5|6|7|8|9)
  • [0-9a-z] means ([0-9]|[a-z])
  • [^ab] matches any characters but not a and b
  • \x{0915} matches devanagari क
  • \n matches a new line
  • \r matches a return
  • \t matches a tab

Quantifiers

  • * matches 0 or more times
  • + matches 1 or more times
  • ? matches 0 or 1 times
  • {7} matches 7 times
  • {5,} matches at least 5 times
  • {2,5} matches at least 2 times but no more than 5 times

Substitutions

  • s/hello/Hello/ will substitute Hello with hello
  • s/(H|h)ello/Hi/ will substitute Hello or hello with Hi
  • () will extract a match
  • \1, \2 etc. hold the value of the match
  • s/([0-9])([0-9])/\2\1/ matches two digits and reverses them

Exercises

Consider the following two strings

STRING1   Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
STRING2   Mozilla/4.75 [en](X11;U;Linux2.2.16-22 i586)

Consider the following searches and find out what pattern gets returned in both the above given strings.

  • m
  • a/4
  • 5[
  • in
  • le
  • in[du]
  • x[0-9A-Z]
  • [^A-M]in
  • [a-z]\)$
  • .in
  • \(.*l
  • W*in
  • [xX][0-9a-z]{2}
  • ^([L-Z]in)
  • ((4\.[0-3])|(2\.[0-3]))
  • (W|L)in

Python Plotting

software_carpentary3.txt · Last modified: 2018/03/24 11:13 (external edit)