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 3 years ago.
Improve this question
I am looking for resources that help me interpret python documentation effectivley. In particular, I am reading through the pythondocx module documentation, but am finding it hard to understand some sections.
As an example, when I read the Style Objects Section
, I am confused by lines such as class docx.styles.styles.Styles and what it is actually saying.
Any ideas on what I can do the to interpret documentation better?
I honestly think reading pythondocx module documentation is a bit of overkill.
The hard part of reading python documentation is understanding the specific logic of how objects and builtin's are organized in python. The best place to start, IMHO, is the index Python 3.8.1 documentation together with standard library and collections.
Even if you had studied other common languages before, like Java and C#, their API's are laid out in a different style. Each takes its own time for the reader to get used to. The python docs were written to be self-explanatory and after an initial learning curve that isn't especially steep the docs start making lots of sense.
Related
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 months ago.
Improve this question
First time poster here. I'm trying to convert one or multiple .docx files to PDF but I can't figure out how to do it without importing any libraries/modules aside from what is available in python 3.3.
I've read through the packages documentation but nothing stuck out as a solution. I also don't know what I am looking for as I am pretty new to python. I found plenty of articles and resources that mention how to do it with an imported library, but not without.
Is it possible to accomplish this without importing a library?
Any advice/resources are welcome.
Code it from scratch. If you're not going to use an external library, that is by definition pretty much your only option.
You'll want to become an expert in the formal specifications for both PDF
and MS Word. Given the complexity and history of each of those, I expect a senior developer will want 6-12 months of experience with each to obtain the necessary understanding.
You should also have 6-12 months' experience with Python, since you'll likely need to be familiar with the language in order to define and use all the functions you'll need. But in just a few years of dedication, you should be able to write the necessary code.
MORE REALISTICALLY, import Python libraries for managing PDFs and MS Word. That should only take a week or two.
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 3 years ago.
Improve this question
For example,
import numpy
def text():
...
If there are a lot of import statements, I personally feel it seems better to import when it's needed, instead of importing all at the top of file. A major benefit of this is to make reader to understand the code easier and immediately know where the dependency is imported from.
Is there any side effect by doing this?
The ultimate guidelines for best practice in python are in the PEP-8 style guide. In the guide section linked:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
In your question, you assert:
A major benefit of this is to make reader to understand the code easier and immediately know where the dependency is imported from
But actually the opposite is often true. If I open a .py file, I can quickly scan the first few lines to see ALL dependencies needed to run the script. If each is imported below, then suddenly I have to scan through the whole file to see if and when a library is required.Remember that code is looked at a handful of times when it's written, and usually just by the author or someone close to the author, but could be read 10X more times, by people unfamiliar with the script
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
Sorry if the title is confusing.
What I am trying to say is this:
I have worked with Python before, but I'm by no means an expert. So far everything I have done has just been 'somefile.py' with lots of methods and code in it, but it doesn't really have any organizational structure. In Java (which I am more familiar with than Python), there are usually different classes that each have methods and are called from each other. How do you make a file full of code organized and structured when working on a large project? Break them up into files by class?
Hopefully this is clearer. Let me know if this needs clarification.
In Python, the file unit is called module. Modules are organized in packages.
You usually put your classes each in a module and also use modules to group related code that doesn't belong to any class. Related modules are grouped in packages (physically represented by directories) which effectively create namespaces.
Then you use the import command to import the desired pieces of the code into other modules.
You can read about modules, packages and import in the Python documentation here.
Logically, it isn't much different than Java or other languages.
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
So I've been thinking to make a programming language written in python but I have no idea where to start, and I really don't know the steps creating it.
You would probably start by first planning out your language. That should take a lot of time. Then in Python... you would write a parser that can understand the syntax of your language, and an interpreter that can take the results of the parser and perform the actions of the program.
Your language that is written in Python with Python in-turn being written in C is practically guaranteed to be very slow and will not succeed, but this could be a really fun thing to do as a learning or education experience.
You will likely want to look at Abstract Syntax Trees. This is the underlying structure that python is built on. Take a look here at the documentation: https://docs.python.org/2/library/ast.html
Using ASTs you can at least define the syntax of your language. You will still need to solve the problem of how to interpret it on a platform to get your code to execute.
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 8 years ago.
Improve this question
I've written a bunch of VBA code for various things in Excel. I'm looking at migrating to libreOffice. Under Tool->Macros->Organize Macros: the two choices are LibreOffice Basic and Python.
Should I learn one of those, both, or something else. Am I wasting my time altogether? Any suggestions appreciated.
Python is the way to go.
Start here: http://wiki.python.org/moin/BeginnersGuide
And no, you're not wasting time.
You'll look back and say, why didn't I do it sooner.
Python's a great skill to learn - I use it for everything. It's the glue language for virtually every tool out there (you can even use it with .Net).
Documentation for Python + LibreOffice is however a bit sketchy currently, although I don't have much experience with Calc.
There is some work-in-progress documentation at http://documenthacker.wordpress.com (or soon www.documenthacker.com). It has examples for working with Writer, rather than Calc, but you might still find it useful.