How can a total, complete beginner read source code? [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML.
I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for?
Thanks.
EDIT: Sorry guys, I forgot to mention that I already have both the online tutorial and a couple of books handy. I basically I don't quite understand how to "dismantle" and understand complex source code, in order to grasp programming techniques and concepts.
EDIT2: Thanks for the extremely quick comments, guys. I really appreciate it. This website is awesome.

Have you looked at these:
Python tutorial for total beginners?
What is the best quick-read Python book out there?
SO Python Book Search

I would recommend you understand the basics. What are methods, classes, variables and so on. It would be important to understand the constructs you are seeing. If you don't understand those then it's just going to be a bunch of characters.

To understand source code in any language, you first need to learn the language. It's as simple as that!
Usually, reading source code (as a sole activity) will hurt your head without giving much benefit in terms of learning the underlying language. You need a structured tour through carefully chosen small source code examples, such as a book or tutorial will give you.
Check Amazon out for books and Google for tutorials, try a few. The links offered by some of the other answers would also be a great starting point.

There is no magic way to learn anything without reading and writing code yourself. If you get stuck there are always folks in SO who will help you.

Donald Knuth suggests:
"It [is] basically the way you solve some kind of unknown puzzle -- make tables and charts and get a little more information here and make a hypothesis."
(From "Coders at Work", Chapter 15)
In my opinion, the easiest way to understand a program is to study the data structures first. Write them down, memorize them. Only then, think about how they move through program-time.
As an aside, it is sort of a shame how few books there are on code reading. "Coders at Work" is probably the best so far. Ironically, "Reading Code" is one of the worst so far.

If you don't have any experience in programming, even the simplest code might be too hard to understand. Just start reading the docs/tutorial (http://docs.python.org/tutorial/index.html) and write your own small apps. You'll get hang of it soon and will be able to understand what others created.

I would start with reading the Python tutorial. This wiki page looks good, too.

try python "Python in a Nutshell" it gives you from a to z in python..
however, python code is "eye-fiendly" clear and simple to read unlike other languages
http://books.google.jo/books?id=vpTAq4dnmuAC&dq=Python+in+a+Nutshell,+2nd+Edition+(O%27Reilly,+2006)&printsec=frontcover&source=bl&ots=AOQ5A-IdxA&sig=zh6PwVhjlNt5MRKYUZKl65h1goU&hl=en&ei=A7kgS8SiBouh4Qbd6e34CQ&sa=X&oi=book_result&ct=result&resnum=8&ved=0CB8Q6AEwBw

Maybe you have a project in mind that you want to code up? It's very hard to read what other people write, the best way to learn is to try something. Other people will have gone through the problems you will come across, and so why code is written the way it is may start to make sense. This is an excellent site to post questions, no matter how stupid you consider them.

Related

Is it possible to implement heuristic virus scanning in Python? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to create a virus scanner in Python, and I know that signature based detection is possible, but is heuristic based detection possible in Python, ie. run a program in a safe environment, or scan the program's code, or check what the program behaves like, and then decide if the program is a virus or not.
Python is described as a general purpose programming language so yes, this is defiantly possible but not necessarily the best implementation. In programming, just like a trade, you should use the best tools for the job.
It could be recommended prototyping your application with Python and Clamd and then consider moving to another language if you want a closed source solution, which you can sell and protect your intellectual property.
Newb quotes:
Anything written in python is typically quite easy to
reverse-engineer, so it won't do for real protection.
I disagree, in fact a lot but it is up for debate I suppose. I really depends how the developer packages the application.
Yes, it is possible.
...and...
No, it is probably not the easiest, fastest, best performing, or most efficient way to accomplish the task.
Well, sure it's possible. Python is turing-complete, so you can use it to the same ends as you can use other programming languages like C++. And you can certainly do a primitive signature-based or code-inspecting check in Python without great difficulty. So the answer to that question is yes.
Now for the deeper question: are you asking whether Python is a good tool for this job? I don't think so, primarily because Python Code is Hard to Obscure, which means that if you develop an anti-virus in Python, it becomes weak the moment you give it to other people. That's because a virus developer will find it easy to inspect your anti-virus engine, since you will not be able to obscure your python code. That means that they can find vulnerabilities in your virus scanner easily.
Indeed, one of the key components of a good anti-virus is making it as hard to reverse-engineer as possible, so that virus developers won't figure out what the weaknesses of your anti-virus engine are. Anything written in python is typically quite easy to reverse-engineer, so it won't do for real protection.

Is it good to read Python Documentation to learn Python for a beginner? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've started learning Python recently and started reading Head First Python and Learn Python The Hard Way. Both books doesn't seem to explain everything in detail. I wanna know if it's a good idea to read Python Documentation instead of these books. Any help would be appreciated. Thanks in advance!
The documentation has two parts; one is a basic tutorial which won't cover much beyond what you can find in the books, and the majority of it is a reference to the language itself. It is not a good learning resource, but it is (as good documentation is), an excellent reference for when you want to find out what a particular module does.
The documentation won't answer questions like "How do I download a file from the Internet?" (actually, it answers this specific question but the idea is that its not a teaching resource) but it will tell you what are all the methods of the urllib module, however you would already need to know that you need urllib to get the job done; this is the main problem when you are starting out.
I would say from the documentation you should probably skip the tutorial (especially if you are already reading a book), and then have a look at the standard library index which will give you an overview of what modules are available, broken down by function.
I would recommend the Programming Python book by Mark Lutz as a great starting point. It is quite a tome (at 1632 pages) but covers everything you need to know to be proficient in Python.
Once you have gone through that, the next book I would recommend is The Python Standard Library by Example by Doug Hellman. It is an excellent resource on how to use the comprehensive standard library.
Finally, after the two books you are now ready to solve real world problems and nothing helps more than having a cookbook/reference of sorts, for this I can recommend the following:
Python in Practice
Python Cookbook
Writing Idiomatic Python
If you want a comprehensive review of the language, the docs are your best resource.
http://docs.python.org/index.html
Nevertheless, you may prefer to start out with the tutorial (http://docs.python.org/tutorial/) and some introductory material such as the ones you've referenced, so that you can have some experience putting together the basics so that you have experiences to draw from when reviewing the docs, since the library reference (http://docs.python.org/library/index.html) and the language reference (http://docs.python.org/reference/index.html) don't necessarily have a lot of good examples, and frequently presume at least elementary knowledge of the language in its expositions.
The How-To's are a good in-depth review, with examples: http://docs.python.org/howto/index.html
The books are good to introduce you the language, with examples. You should definitely read them if you have time.
The documentation is useful to get technical details on some method, for a specific version of the language (eg Python 2.7.6 reference)
Finally, when you're developing an application, you can also learn by reading the source code, exploring where the code is going and what is happening. An excellent debugging tool is iPdb, which allows you to put breakpoints in your code and examine the current state at that position.
If the documentation is too crude, and the book too long, you can also try some online tutorial. Google is full of resources, like LearnPython.
It is, definitely :-).
I'd also read http://www.diveintopython3.net (or http://www.diveintopython.net for 2.x).

Sample django and python project [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am a newbie to python and its framework Django. I am learning both the technologies parallel from its documentation, so I thought if there are some projects which I can use as reference for learning then it will help me learn the things fast. Can someone suggest me any such links.
I would suggest that you learn Python well, really well, since django uses Python's myriad of features to almost their fullest extent. I would start off with any random Python tutorial, but Zed Shaw's Learn Python the Hard Way is the best, and you can find a free HTML version of what he wrote. You can then get a book that teaches you to make games (great way to learn); Invent your own games with Python.
Well since you're a newbie, you'll probably want to start off by making a blog or something and then slowly moving up and making more complicated websites. The best approach to learning django is to first make something simple, then look at other people's code and learn from that. You an pick up a lot from reading other people's code and how they've structured their logic.
For a free resource, I would check out Mike Hibbert's Django tutorials on YouTube. He teaches you pretty much everything. Don't worry about the IDE he is using, just use a text editor like Sublime Text 2.
After you've made your simple website, its best that you start reading a book called Two Scoops of Django, by Daniel Greenfield. Really good tips and tricks on how to use django right. Great for newbies.
After that, start reading code. Read other people's code and understand how they made their sites. You can take a look at many sample django projects on the web. I would suggest that you go over to github and just randomly search for django projects. Thats what I did, and I think looking at other people's code is the best way to learn.
Lastly, if you want to get even more into django, join the IRC. Great bunch of guys there, not as lively as the Rails bunch, but they're pretty awesome.
Seconding the tutorial. It really is one of the most comprehensive and easy-to-follow framework tutorials out there. By the time you've finished it you'll have a much greater understanding of how all the django pieces fit together. It also has plenty of room to expand so you can experiment with new ideas.
Completing the tutorial has an added benefit: the django documentation frequently refers back to the tutorial app in its examples. So having the tutorial project available means you can quickly try out the features you're reading up on in an actual project.
One of the things that I (and possibly most people that are new to python as well as django) struggled with was separating "what bits are python?" from "what bits are django?". There's no real quick-fix for this other than gaining experience but like another answer mentioned, learning python on the side (maybe doing a few projects just using python) can help you with writing clean code within django too, and also see what is "missing" without django.
First start with Python as indicated.
Then, with regard to Django: I learnt a lot from the http://www.gettingstartedwithdjango.com/ video series, especially on set up and interesting packages to use.
No need to watch the video if you don't want to, as everything is outlined below the video as well.
Next to that, http://www.effectivedjango.com is a great help.

A different approach to understanding programming [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am new to programming. I decided to stick with Python after messing around with objective-c.
I'm beginning to get a grasp on most of the basic concepts, but as an artist, I think visually. This said, I would like to attempt to work in reverse. In other words, I'd like to start out with a complete, functional piece of software and look at the code and mess around with it to see what does what. This is kind of a similar approach to CAD modeling, where you can see which features in the model affect it, and how. This may not make sense to those who are not familiar with CAD, but I hope someone out there can relate?
Exploring existing projects is an excellent way to learn programming. Breaking existing code and fixing it is an even better way.
There are many open source projects out there that you might want to explore. Some of them are code libraries, while others are entire applications. As you are new to programming, you may want to consider looking at projects that are not too gigantic as it might be overwhelming.
Additionally, it may be even more helpful for you to dissect a program that you would actually use. I have not used this program, but PythonCAD might interest you:
http://sourceforge.net/projects/pythoncad/
This most likely does not fall into the small or simple category of open source projects but it sounds like you may already understand the intended functionality which should be of considerable aid to you in your exploration.
Browse through Google Code for open source Python projects that are of interest to you:
http://code.google.com/query/#q=python
I recommend to take a look at the PyRoom project, a no non-sense text editor for writing without distractions. It's barely 2K lines of code and seems simple to understand. You can access the repository here.

Learning Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am going to need to learn advanced Python and must be good at it in about a year, Are there any books, recommendations. I am already very familiar with PHP, MySQL, JS + HTML, and know a bit of java and C (arduino programming).
Thanks,
RayQuang
Since you sound like a competent programmer, the best place to start may be the official Python 2.7 Tutorial. It's very thorough, certainly.
After that, I advise looking up through the language reference and standard library reference (the stdlib for Python is pretty massive) to get everything else.
It's not a book, but I found the Google Python Class very useful. There's video, reading material, and practice questions that I found very useful.
There are a lot of good resources, either at the python wiki, or here at previous similar questions.
Generally I would recommend starting with the official python tutorial. Alternatively, you might want to check other tutorials, aimed for people with previous programming experience.
Afterwards, you can try books, such as 'Dive Into Python', but I always preferred sharpening my skills by trying a set of problems, such as python challenge and Project Euler.
I think that trying to solve such problems is a good advice for every programmer who's trying to learn a new language.
It looks like there are a lot of good books being recommended. Be aware that there are two main versions of Python in circulation. 3.0 is the new, and a lot of 2.7 programs won't work with 3.0. Some of the syntax has been tidied up - and one of the most common problems is "print" which now has a syntax more consistent with the rest of the language.
As with any language, the best way to learn it is to start using it. Choose a project which pulls to Python's strengths (eg. text processing and data structures) and your probable needs in 12 months time, and start coding!
take a look at Mark Lutz's book..
it's more than an introduction, but it's not very thorough
http://oreilly.com/catalog/9781565924642
once you finished that one, if you found it useful you might want to pass at:
http://oreilly.com/catalog/9780596158118?green=18666053383&cmp=af-mybuy-9780596158118.IP
another interesting one is the Python Cookbook
http://oreilly.com/catalog/9780596001674 (careful, it's 6 years old)
the official tutorials are very useful, too ;)
I have good books, but I don't know exactly what do you want (CGI's, XML manipulation, ..).
A nice way to start your study is with this book: Apress Beginning Python From Novice to Professional.
After you see the examples and the simple structures, I suggest you to look the oficial site: http://www.python.org/ and the HOWTO examples: http://docs.python.org/dev/howto/index.html

Categories

Resources