Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I've been having a hard time trying to understand PyPy's translation. It looks like something absolutely revolutionary from simply reading the description, however I'm hard-pressed to find good documentation on actually translating a real world piece of code to something such as LLVM. Does such a thing exist? The official PyPy documentation on it just skims over the functionality, rather than providing anything I can try out myself.
This document seems to go into quite a bit of detail (and I think a complete description is out of scope for a stackoverflow answer):
http://codespeak.net/pypy/dist/pypy/doc/translation.html
The general idea of translating from one language to another isn't particularly revolutionary, but it has only recently been gaining popularity / applicability in "real-world" applications. GWT does this with Java (generating Javascript) and there is a library for translating Haskell into various other languages as well (called YHC)
If you want some hand-on examples, PyPy's Getting Started document has a section titled "Trying out the translator".
PyPy translator is in general, not intended for more public use. We use it for translating
our own python interpreter (including JIT and GCs, both written in RPython, this restricted
subset of Python). The idea is that with good JIT and GC, you'll be able to speedups even
without knowing or using PyPy's translation toolchain (and more importantly, without
restricting yourself to RPython).
Cheers,
fijal
Are you looking for Python specific translation, or just the general "how do you compile some code to bytecode"? If the latter is your case, check the LLVM tutorial. I especially find chapter two, which teaches you to write a compiler for your own language, interesting.
It looks like something absolutely revolutionary from simply reading the description,
As far as I know, PyPy is novel in the sense that it is the first system expressly designed for implementing languages. Other tools exist to help with much of the very front end, such as parser generators, or for the very back end, such as code generation, but not much existed for connecting the two.
Related
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).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I know Python and I've come across a small C++ source file I would like to convert to Python. But the C++ code is too complex for me to understand without learning the language.
So I was wondering if there is a tool that does the opposite of what many people want: convert C++ code to Python, or another simpler language I could understand.
I know these tools work on very simple code and hardly do a perfect job even then, but the code I have is pretty small and simple.
I have found "ctopy", but there is no usage example, if I just pass a .cpp file to it, it just hangs, no error message or anything.
And maybe it won't work for C++ at all.
http://www.catb.org/~esr/ctopy/
Most translators produce inferior code which you can't really use anywhere; and the more complicated your code is, the worse the results are. Only real human brains can do that perfectly. I'd suggest that you learn the language. If you already know python, learning another language shouldn't be too difficult.
I've seen (and wanted) such a programming code converter and found exactly what you want in cpp2py although I personally haven't tried it for myself website https://github.com/hlamer/cpp2python
It's a little painful, but I have gotten some python code using
https://code.google.com/p/ctypesgen/
For some reason it doesn't handle bool's.
It probably uses regex substitutions, and other things like that, but it sure beats writing out your own ctypes wrapper without it.
http://docs.python.org/2/library/ctypes.html
Another option you could look into, is compiling your C++ into an executable and then running the executable using python.
And if you decide you need the power of C/C++ in your tool belt:
https://stackoverflow.com/questions/3973899/learning-c-java-coming-from-python
Hope that helps.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
What are the best (more or less mature, supporting more advanced logic, having acceptable performance, scalable to some extent) open source Semantic Web libraries and tools (RDF storage, reasoning, rules, queries) for Python nowadays? Historically Python tools (cwm) were among the first to appear, but it still seems that everyone uses Java back-ends for performance and Python as mere client if at all. My purpose is to learn the technology and maybe some future use in production system if it proves itself up to the task. The task is not yet defined, but as I see it its building a knowledge base, linked with some external resources, and customized facet-navigable web front-end.
If some building blocks based on Python are not good enough, then what is the suitable piece from Java/C/C++/whatever world.
Typical stack is also of interest, if there are one or two clear winners.
Thanks.
A survey of of Python libraries and tools for Semantic Web programming is available here. It includes libraries for working with RDF as well as Python-friendly triple stores.
Toby Segaran's book Programming the Semantic Web also has a lot of programming examples in Python.
You could check out the pyswip. It could work with the SWI-Prolog. Wish it would fit for requirement. :)
To name some, check out RDFLib and CubicWeb.
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
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I'd like to write a python library to wrap a REST-style API offered by a particular Web service. Does anyone know of any good learning resources for such work, preferably aimed at intermediate Python programmers?
I'd like a good article on the subject, but I'd settle for nice, clear code examples.
CLARIFICATION: What I'm looking to do is write a Python client to interact with a Web service -- something to construct HTTP requests and parse XML/JSON responses, all wrapped up in Python objects.
I can't point you to any article on how to do it, but I think there are a few libraries that can be good models on how to design your own.
PyAws for example. I didn't see the source code so I can't tell you how good it is as code example, but the features and the usage examples in their website should be a useful design model
Universal Feed Parser is not a wrapper for a webservice (it's an RSS parser library), but it's a great example of a design that prioritizes usage flexibility and hiding implementation details. I think you can get very good usage ideas for your wrapper there.
My favorite combination is httplib2 (or pycurl for performance) and simplejson. As REST is more "a way of design" then a real "protocol" there is not really a reusable thing (that I know of). On Ruby you have something like ActiveResource. And to be honest, even that would just expose some tables as a webservice, whereas the power of xml/json is that they are more like "views" that can contain multiple objects optimized for your application. I hope this makes sense :-)
This tutorial page could be a good starting place (but it doesn't contain everything you need).
You should take a look at PyFacebook. This is a python wrapper for the Facebook API, and it's one of the most nicely done API's I have ever used.
You could checkout pythenic jobs, a nice, simple, but well-formed "Python wrapper around the Authentic Jobs ... API" as a good example. That's what I'm doing now :)