From where to start Python - python

hi folks i am very new to python, i just intall it and configure it in netbeans but did't get from where to start and how to write my first program in python using netbean.
Any one recommend me some help, forume or any other resource.
Any kind of help will be greatly appreciated......

Try Zed Shaw's "Learning Python The Hard Way". Or S. Lott's "Building Python Skills".
UPDATE: I should have thought of the official tutorial first.
If you'd be willing to consider books, I've gotten a great deal out of Wesley Chun's "Core Python Programming".

I would recommend avoiding use of an IDE like NetBeans until you know how to use Python a bit more without it. I'd play around in the interactive terminal, accessible by typing python into a command prompt (or on windows, finding and running the python.exe file). As far as resources, there are a million easily available on Google. One you might want to use is "Learn Python the Hard Way"

Related

Best way to write Python Scripts on a Mac (IDE?) [duplicate]

This question already has an answer here:
What IDE to use for Python? [closed]
(1 answer)
Closed 9 years ago.
I would love to find out what the best way to go about writing Python scripts on a Mac would be. I've gone through two ways (mind you, I'm trying to avoid using vim because I want an IDE rather bland text editor). I went through using PyDev in Eclipse (the more I went through their recommendations and steps, the more of a hassle everything seemed to be.. although I do have everything set up and it can compile.. I want to know if there's a better way. I'm not too fond of Eclipse as is) and I tried to set up Xcode through the following steps: Xcode4 to run Python scripts. The problem with the Xcode version, is I would have to consistently setup the project like this every time. That, and every time I compiled something that needed to create a file it didn't (say using the command conn = sqlite3.connect('list.sqlite3'). Is there a simple way to do this? I've been trying to follow various iOS tutorials that want me to use python scripts (which I'm not familiar with at all) such as raywenderlich.com and Oreilly tutorials. Can anyone provide some guidelines on the best way to go about this?
Personally, I prefer the one that is found on the official Python website, IDLE, which can be downloaded here. It is very easy to deal with, and with the Shell it offers an area to test things out on, it has more than Eclipse can offer- in my opinion. I'm sure that people would feel the complete opposite that I do, but with my experience, IDLE is the way to go.
I think PyDev in Eclipse is pretty good. For scientific programming I wrote the following installation guide:
http://hywelowen.org/installing-python-for-scientific-computing-on-osx/
Spyder appears to be a decent alternative, but I haven't used it myself.

Python - Where do I start? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am quite comfortable with C/C++ but I felt that another language would surely help me. So, I decided that Python would be good language to start as I have heard many people talking about Python. I have the following questions :
Where do I start for Python ?
Do I have a compiler like Visual Studio for Python ? I use VS2010 for C/C++
Thanks in Advance.
Like most languages, reading a book might help
lpthw
is the suggested book for learning python. It will guide you through setup and more :)
Dive into python is a great one, will get you upto speed if you are already familiar to programming, which you are. Learn by building small and useful projects in each chapter.
Python website provides the python interpreter. which can be used. Python is not compiled like c/c++ but interpreted.
I'd suggest Head First Python. Even it seems a little childish when you start reading, it turns out to be very, very well suited to learn not only the basic concepts but to get an idea what the language is capable of and is used for (google app engine, python on android,...).
I think there are lots of python information throug internet, if you are a C++ programmer and already have programming knowlege you can just search for info there. Although you can just install the interpreter and start playing arround, by my experience its a fairly simple way of learning (interpreter + documentation)
Some interesting webpages:
http://www.python.org/
http://docs.python.org/py3k/tutorial/index.html
Some IDEs as visual studio but for python:
http://wingware.com/
http://www.eclipse.org/
A while ago, I wrote a blog post addressing the first part of your question:
http://codelike.com/blog/2011/07/07/a-jump-start-for-learning-python/
As for the second part: No, you don't need a compiler. Code is interpreted on the fly, which means you can type code in the Python shell (that comes with a Python installation) and instantly see what it does. That's a great way for exploring some language features. If you install iPython on top of Python, you even get auto-completion inside that shell.
It depends on what way of learning you prefer. I would recommend to read theory, play a little and write something useful using python.
Below are several points where to start at your choice.
Theory:
Official tutorial
Dive into Python book (for python 2)
Dive into Python 3
Learn Python The Hard Way by Zen A. Shaw
Learning Python: Powerful Object-Oriented Programming by Mark Lutz
Programming Python by Mark Lutz
Think Python by Allen B. Downey
Courses and video:
Google's Python Class
Python track at Codeacademy
Coursera's Introduction to Interactive Programming in Python
Playgrounds:
checkio.org - platform for competing in python programming, lots of tasks from easy to hard ones
pythonchallenge.com
I would recommend to read official tutorial and start playing with online tutorials that will guide you from simple "hello world" programs to more complex one, if you were newbie in programming. Then read Dive Into Python and go deeper.
In regards of IDEs there are several options, and you can try them to find what fits best for your goals.
IDE's: PyCharm, Eclipse + PyDev, Wing IDE.
Just Editor: vim or sublime or notepad++, I have used all of them and stopped on sublime.
Interactive interpreter: ipython - there are options to run it as a console or like a notebook on localserver. This is awesome tool and truly interactive programming experience. Watch some tutorials first. There are several very powerful things like matplotlib, numpy, scipy supported that makes this tool very efficient.
Also you have to take a look at virtualenv and virtualenvwrapper to configure your virtual environments.
I really enjoyed learning python from the python essential reference
As for the compiler part: Visual Studio is not a compiler. It's an IDE that uses the MSVC compiler. Python on the other hand is a interpreted dynamic language (well... it's not actually interpreted, as the interpreter compiles a module into bytecode when it imports it for the first time, so it's a bit of both, but these are technicalities that you need not worry about when you start learning the language)
For python you need:
the python iterpreter: http://www.python.org/getit/
an editor of your choice. I personally enjoy emacs, but if you're into the IDEs, then you could use PyDev or komodo or many many others.
To answer your second question, Python is an interpreted language so you don't need a compiler. So long as you have Python installed, just run the script.
You can use whatever IDE you prefer to write the code.
As swair said Dive into python is a great resource for experienced programmers in other languages.. If you want to stay in Windows Visual Studio environment you can give a chance to Iron Python http://ironpython.net/tools/ It is built in Visual Studio 2010.
But for a fresh start i recommend Python shell, iPython or PyCrust. PyCrust is my favorite.

PC^2 equivalent compatible with Python

I will be running a programming competition for high school students in the near future, and was originally going to use PC^2 (Programming Contest Control System) for the automated judging of the solutions. This software is commonly used in the ACM's International Collegiate Programming Contest regionals as well as the world finals. This is an excellent system which I have used before, but one of its pitfalls is its language support (Java, C, and C++). I'm a little bit concerned, as not all high school students who may be attending will have exposure to any of these languages. However, many local high schools teach introductory programming courses in Python. Is there an equivalent system to PC^2 which has Python support?
You can use some open source implementations of the online judges.
for example ONJ http://sourceforge.net/projects/onj/
It is easy to configure and it can be made compatible to run on languages of your choice. You dont need local copies of it on every system where the students will sit, you can just run it on a server and give the students its web-link to submit their solutions.
Do it with Sphere Online Judge, contest hosting is free of charge, many languages available.
I actually found a much better way to accomplish this. In their latest release, PC^2 added support for interpreted languages (such as Python, etc). Since PC^2 requires an executable, you need to "stub out" the compile command and simply invoke the interpreter with the script.
The full guide can be found at http://pc2.ecs.csus.edu/wiki/Interpreted_languages
Assuming you are still interested, PC^2 is very adaptable. I run a scripting contest using it and support Python, Perl, PHP and Ruby. Basically, PC^2 expects a language to compile and then run. You need to write a dinky script that pretends to compile the code and return success. Then the run script simply runs the scripting submission. Pretty easy to do.
You can visit http://acm2012.scusa.lsu.edu and look at the scripting contest info. Feel free to contact us for more info.
It's simpler than one may think. The following is for pc2 9.2.3-2565
Add language as follows (python here as an example):
Display Name: Python
Compile Cmd Line: touch OK
Executable Filename: OK
Program Execution Command Line: python {:mainfile}
python3.3 or python3.4 will work too.
pc2 could be easier, of course, but there does not seem to be much support left at CSUS. Reseting contest would be even greater feature; the current need to clone directories for test, practice, and actual contest is very awkward. Better management of the database (like the ability to remove things) would make it into a great tool. It is alright, but it could be great.

To IDE or Not? A beginner developer's dilemma [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
Basically, me and a friend of mine are just planning to work on a Python project which would have GUI interface, and enable file transfer over and remote file listing. We have most of the tools which we are going to use, Glade, Python etcetera.
I just want to know if I should use an IDE or not.
I've heard only good things about Anjuta, but not convinced of its Python support; care to comment?
And also is there any other good IDE I should check out?
Currently I am just planning on coding as usual in vim.
The ability to debug using an IDE makes your life so much easier.
Python is a particularly strange language in that having a full-fledged IDE doesn't really add much (and some would argue that an IDE tends to severely limit your thinking-flow in Python). I've been using regular Vim and Gedit to develop in Python and never really missed using IDE.
Text editors like Vim or Emacs itself can be configured quite flexibly to match an IDE power though, so it doesn't really matter which way you go.
There are numerous IDEs you can check out. Take a look at PyDev, PIDA, Komodo, Eric.
I personally don't think IDEs add that much to software development (on this scale and in this language). Python has fine external debugging tools and refactoring is not that hard with a program of this size.
Do you currently use or want to use any features you miss in your current editor? If so, pick another one, else, stick with what you like most.
As long as it has version control integration you should be fine.
Personally I do most my Python coding in Vim, but once in a while I feel like using a full-IDE and I use Eclipse with Pydev at those times.
It depends on your own preference, some people absolutely love Vim and won't use anything else. Others just can't work without an IDE.
Here's a list of:
Python IDEs: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
Python editors: http://wiki.python.org/moin/PythonEditors
In terms of using an IDE or not, it doesn't matter. I prefer using an IDE since I like having the tools I need bundled up into one nice, neat little package that can handle all of my development. However, using a text editor is just as good, especially ones as powerful and extensible as vi(m) and (x)emacs. The real reasons for using an IDE, though, are code completion, management of indentation, code folding, refactoring support, and debugging.
If you want to check out other IDEs for Python development, I would suggest also looking at NetBeans and Eclipse with the appropriate plugins. I, personally, prefer NetBeans since I have a feeling that PyDev is going to be going downhill since Aptana bought them (previously, they ruined RadRails, which is the Eclipse plugin for Ruby on Rails development) and don't want to get comfortable with a tool that might not be useful long-term.
With Java, I'd say no IDE for beginners, because you have to understand CLASSPATH first.
With Python, I'd say PyCharm from JetBrains. IntelliJ is the best Java IDE; PyCharm is making my Python work a pleasure.
IMHO, not using IDE to develop is just like using typewriter to write a novel. Nobody said you can't, but why you have to try that hard when you already have laptop?
I code in Vim for python. If you want to use an IDE then I would recommend IntelliJ's PyCharm. I use vim because the actual editing is far superior and if you are a power user there is very little that you can't do easily.
PyCharm provides help with api by providing completion and helps with some basic refactoring. These advantages though wear of sooner than you would expect. I use grep and vim regex to do refactoring - its a bit more work than pycharm but if you can manage it then the advantages of vim clearly outweigh using an ide.
I assume that you are developing in a *nix environment, if you use windows then I would recommend using an Ide.
As opposed to some other guys here, I think that an IDE does add much to software development, even for a dynamically typed language like Python which makes it harder to do static analysis.
My preferred IDE for Python development is Eclipse with PyDev. Before that, I coded in Notepad++ which isn't much different than the PyDev editor in terms of features. PyDev has some great features that you won't find in a "normal" editor:
It shows warnings and syntax errors (almost) in realtime. A text editor won't tell me about typos, but PyDev does. As another example, unresolved imports or undefined functions (e.g. because of a typo) are marked as warnings/errors. And there are many more common mistakes that are automatically detected, and PyDev can be integrated with pylint so that warnings and errors from pylint are displayed with the usual icons in the editor.
Autocompletion by introspection
Outline view of the current module and its classes
Additionally, Eclipse itself is also great for any kind of programming project. I especially like the fully integrated interface - project explorer, editor, outline, console, problems overview, run configurations and so on. When using Vim, Emacs or similar, I guess you would have to install lots of plugins or custom scripts to achieve the same.
As you said you want to do a project, I think that Eclipse is a good choice. For quickly hacking a small Python script, it's overkill of course.
If you just start learning python/glade/gtk stack, I'd say you should start without an IDE just to learn how it works internally. This will help you later when your code will be bigger and more complex.
However, good IDE helps in so many ways I wouldn't recommend against using any in the long run. This article might help you decide whether you need any: http://infoworld.com/d/developer-world/infoworld-review-nine-fine-python-development-tools-374
it's horses for courses, personally i'm much happier with textmate or vim and a nice cup of coffee but it's what feels more comfortable to you.
there's no shame in using an IDE, if it's what gets your idea out there to the masses the most productive then use whatever you like.
however when starting out i'd favour something with intellisense as it'll teach you the basics as you type, give it a year and you'll be a master at it.
Two ways to approach this:
Use what you're used to. If you have used an editor in the past and know its quirks, stick with it. You'll waste less time figuring out how to work with the tool and spend more time on the actual project.
Use something new. Anjuta, vim, whatever, as long as you haven't spent too much time with it so far. You'll learn a whole lot of stuff besides your actual project, but the project itself won't be done as fast as could be.
Personally, I prefer 2. Always learn something new, as long as it's not crunch time and it-has-to-be-done-by-friday. An IDE can help you only so much, but when you're still in the learning phase the more time you spend on the code yourself, the better.
I'm not a Python programmer, but I prefer not to use IDEs.
The reason for this is that I find IDEs are often big and do too many things for me, whereas using Notepad++ and the command prompt allows me to trim things down to suit my needs rather than being surrounded by features that I don't use. This allows me to learn more easily, because I have more control over what happens.
Don't learn coding with an IDE. Code with it!
I find using an IDE to dramatically help my Python code productivity. In particular, using wingide makes coding in python a pleasure. It has all the normal things you would expect (syntax highlighting, auto-complete, etc) but the killer features are the debugger and the debug probe.
These two features are worth the cost of the program. It lets you see the live state of the application and try out python statements live at breakpoints. I find this especially helpful to explore the current state and to try out some code to see if it will work. I often write some of the trickier sections of code in the debug probe live and them copy them into my application. Very nice.

How do I prepare myself for a summer of working on Python using Linux environment?

I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting.
I need some advice on how I can quickly learn to use the Linux terminal quickly. Any books or web resources that you can suggest?
Also, is there a particular IDE that is generally preferred for Python programming on Linux, or is Vim preferred? How can I best prepare myself for the internship ahead?
Thanks for taking the time.
As an intern you'll want to use the tools your mentor is most comfortable with. If you get stuck you'll be able to ask for advice quickly.
Learning your way around either vi, vim, or emacs to start with will help. The basic concepts used in one will transfer to the other. You'll need to be able to open and read files, search through files, edit and save files, and learn how to apply any python formatting helpers correctly.
You should also familiarize yourself with version control if you haven't already. Again any one will do, you need to focus on concepts and etiquette rather than the specific tool.
The goal of the internship (and really your entire time at university) should be used to learn concepts rather than specific tools. If you learn the concepts you'll be well placed to apply those concepts using any tool. You will also "learn how to learn" a new tool, which is really valuable.
Your lack of shell scripting knowledge shouldn't matter in this case, although it won't be hard to learn. I read over some shell tutorials and put them into practice. Try doing everything from the command line, including find (grep), find/replace all (sed), finding files (find), automating things using python scripts etc. Basically, don't cheat. You'll pick up a lot this way. You'll also probably end up wondering how you ever managed with Windows.
What I use depends on the project. I really like Eclipse+PyDev but that's my personal preference, I also use Vim depending on where I am/what I'm doing. Remember you can just type python from the command line and it drops you into the python environment.
I recommend Eclipse + PyDev too. You can get started quickly with this develop environment. I also recommend the website Dive Into Python. It provides you a online free version of Dive Into Python book, which is very easy to read, easy to understand, and very suitable for Python beginners. If you really want a paper book at hand, Learning Python, a.k.a. The Animal Guide, is simply the best.
Learn to understand man(ual) pages.
For almost any old linux command/program there is a man page which usually explains the command in good detail.
So basics for filesystem navigation:
Show directory contents (list)
ls
Show hidden files
ls -a
Show details
ls -l
Change directory
cd /full/path/name
Print current directory
pwd
Delete a file
rm file
Delete a directory (recursive)
rm -r directoryName
Make a directory
mkdir directoryName
Move (or rename) a file
mv /path/to/file /new/path/to/file
Show the man page for mv
man mv
Learning vim might be necessary, depending on your intern environment. I do my Python (and everything that isn't simple text editing) in Eclipse. You should in any case learn enough to open a file, makes some changes and save the changes in Vim.
Keep in mind, Ubuntu is very easy. To make things harder on yourself, use the command line for every conceivable thing. Open programs by typing their names into a terminal. Browse your files with the terminal. Do simple editing with vim. That should provide good practice for the day you need to SSH into a computer in Neverland and download and install a local copy of your favorite interpreter from source in order to set up a cron job to run a script to play a clock noise.
In addition to the great advice already written, I'd suggest you install IPython (Open a terminal with Applications>Accessories>Terminal and type):
sudo apt-get install ipython
Also at the terminal, you can then type ipython to start the Python interpreter.
Unlike the built in python interpreter, ipython gives you tab completion.
For example, if you type the name of an object followed by a period and TAB (e.g. sys.[TAB]), ipython will show you (almost) all of object's attributes.
Type a question mark after an object name (e.g. sys?), and you get documentation on that object.
This is a great way to explore Python.
have no exposure to shell scripting
Good! You've got Python so hopefully there should be no need to resort to writing actual scripts with the shell. It may be more powerful than DOS batch files, but it's just as ugly.
I need some advice on how I can quickly learn to use the Linux terminal quickly.
Something like this?
As well as learning the commands, you'll want to get used to using tab-completion and arrow key command recall (if you don't already do that with the Windows Command Prompt), scrolling with shift-arrows, and so on. Also useful to know the & (perform in background) command suffix, ctrl-C-to-stop, ctrl-Z-to-pause, jobs, and screen.
Incidentally if you will be spending any amount of time in the interactive Python interpreter it is well worth adding tab completion there, too. (This is just as much the case on Windows, but on Win you tend not to get pyreadline by default.)
is there a particular IDE that is generally preferred for Python programming on Linux
Just like on Windows, there are IDEs available if you want them but many people just use a normal text editor. vim is fine if that's what you like. nano is another in-terminal text editor you usually get that's relatively simple. Ubuntu's default desktop-based editor gedit is also fine. It's a matter of personal taste.
(If you are interning at a particular company they might have their own development environment they'd prefer you to use.)
For a Python IDE, I recommend using either IDLE or Eclipse with PyDev.
Keep in mind you can also just use python on the linux command-line. It supports loading code from files, and if you use two command windows then one of them will be your "REPL" where you will be running python and dynamically loading code - and the other window can run your editor.
Regarding linux command line, I cannot recommend any great resources. However, you will be off to a great start if you immerse yourself in this environment and only use linux for the next 2 weeks. Just keep learning, and when you do not know how to do something, read a manpage or google it to find the answer.
for a very beginner intro to the command line, check out: http://en.flossmanuals.net/CommandLineIntro/GettingStarted
As far as a Python editor goes, I personally prefer to use SciTE. It's just a programmer's text editor with syntax highlighting for various languages. I prefer a lightweight editor over a more complicated environment, but if you want a full-fledged IDE you can always try out NetBeans, IDLE, or Komodo (all of which are available in both Windows and Linux).
as for terminall and quick way to understand it's and learn it there are a nice cheat sheets on net like this:
http://fosswire.com/post/2007/8/unixlinux-command-cheat-sheet/

Categories