Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite 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
A volunteer job requires us to convert a large number of LaTeX documents into ePub file format. It's a series of open-source fiction book which has so far only been produced only on paper via a print on demand service. We'd like to be able to offer the book to users of book-reader devices (such as Kindle) which require the ePub format for best results.
Fortunately, ePub is a very simple format, however there's no trivial way for LaTeX to produce the XHTML output required.
We experimented with alternative LaTeX compilers (e.g. plastex) but in the end we figured that it would probably be a lot easier to simply write our own compiler which understands a tiny subset of the LaTeX language and compiles directly to XHTML / ePub.
Previously I used a tool on Windows called GOLD. This allowed me to go directly from BNF grammars to a stub parser. It also alllowed me to implement the parser in any language I liked. (I'd choose Python).
This product has to work on Linux, so I'm wondering if there's an equivalent toolchain that works as well under Ubutnu / Eclipse / Python. The idea is that we will take the grammar of TeX and just implement a teeny subset of that, but we do not want to spend a huge amount of time worrying about grammar and parsing. A parser generator would obviously save us a great deal of time.
Sal
UPDATE 1: Bonus marks for a solution with excellent documentation or tutorials.
UPDATE 2: Extra bonus if there is grammar file for TeX already available, since all I'd have to do is implement the functions we care about.
Try pyparsing.
Se http://pyparsing.wikispaces.com/WhosUsingPyparsing, search for TeX. There's a project where pyparsing is used to parse a subset of TeX syntax mentioned on that page.
For documentation, I recommend the "Getting started with pyparsing" e-book, by pyparsing's author.
EDIT: According to PaulMcG, Pyparsing is no longer hosted on wikispaces.com. Go to the new GitHub site
Try PLY.
I once used tex4ht to convert LaTeX to XHTML+MathML. Worked quite nice. From that on, you could use the output HTML as base for the ePub.
Of course, this breaks the Python toolchain, so it might not become your favorite method...
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.
Questions asking us to recommend or find a tool, library or favorite 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 9 years ago.
Improve this question
I'm looking to get into web development. My goal is to create some interactive webpages that interact with MS SQL databases (read/insert/updates), and also possibly sites that interact with XML files.
I've got some basic understanding of Python and Perl scripting. Can someone point me in the right direction in either of those languages to accomplish what i'm looking to do, or if it's easier to accomplish in another language what would that be?
Apologies if my stated goal is too broad.
I'd strongly suggest you to look into some of the web development frameworks. They take care of many low-level tasks which is needed in order to build a solid web page. I'm not very familiar with perl, so I can only suggest Python frameworks, especially one of the my favourites - Django. It has very good documentation which is essential for the first-timer. I believe you should be fine as long as you follow the official documentation.
Good luck
You can use SQL Alchamy in python, and lxml or the default ElementTree xml module for simple cases.
I have done both for a webservice I maintain, and they work nice.
You can also use a web development framework. I personally suggest Flask based on that it is a lightweight framework as opposted to django for instance. However, depending on your exact use case the latter might be better.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite 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 9 years ago.
Improve this question
Because I want to use Lisp's syntax and Python's libraries.
Maybe some tools like Parenscript but generates Python code instead of Javascript.
I've been experimenting a bit with a Lisp compiler targeting Python bytecode.
You can see a small video here.
It's just a proof-of-concept toy but it's IMO a viable path and the end result would be able to call and be called from python freely (and it would be compatible with any python extension library). All this keeping however the power of macros (metaprogramming is probably the area in which Python is farthest from lisp).
Targeting Python source code instead is quite more annoying to do because there are explicit syntax limitations that make compiling Lisp difficult (e.g. assignment is not an expression, no statement is permitted in lambda, captured variables are read-only in Python 2.x).
The VM runtime however doesn't have these limitations and Python bytecode is reasonably nice.
My toy currently can target Python 2.x, Python 3.x and works even with PyPy (so you get a JIT compiler too).
Of course aiming at becoming a full compliant Common Lisp implementation would be IMO nonsense from a technical point of view, but a lisp dialect based on Python runtime types and compatible with Python object system could instead be a reasonable tool with practical applications.
I believe that Hy is what you are looking for. From the tutorial:
Hy converts to python’s own abstract syntax tree, so you’ll soon start
to find that all the familiar power of python is at your fingertips.
However note that Hy isn't Common Lisp, so you can't cut and paste.
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'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.