I'd like to be able to include python code snippets in Excel (ideally, in a nice format -- all colors/formats should be kept the same).
What would be the best way to go about it?
EDIT: I just want to store python code in an Excel spreadsheet for an easy overview -- I am not going to run it -- just want it to be nicely visible/formatted as part of an Excel worksheet.
I think that gist (from github) is precisely what you are looking for. From the description:
Gist is a simple way to share snippets
and pastes with others. All gists are
git repositories, so they are
automatically versioned, forkable and
usable as a git repository.
While Excel itself doesnot support other scripting Langauges than VBA, the open source OpenOffice and LibreOffice packages - which include a spreadsheet - can be scriptable with Python. Still, they won't allow Python code to be pasted on teh cells out of the box - but it is possible to write Python code which can act on the spredsheet contents (and do all the other things Python can do).
Related
I've downloaded the python 3.6.6 source from here...
https://www.python.org/downloads/release/python-366/
...and followed the instruction on how to build on Windows (run ../PCbuild/build.bat). Python compiles and seems to be working (funny and scary: while fetching externals, it actually downloads python-3.7.0 as a dependency... :/ ). However, it looks like the build is somehow 'in place', and the binaries end up in some sub-folder of the source (../PCbuild/amd64/python.exe). This means I'm left with source and compiled code mixed up instead of some clean/lean and deployable package.
can I somehow provide '--prefix=/target/build/path' to define a target location to build to, like I would on linux?
is there a way of removing all src files/folders and leave only the required files/folders (../lib, ../include, etc...).
Or in general, is there a way of making the build process more behave like on linux?
Thanks for your help,
Max
The build.bat from PCBuild is intended for developers, that is, for testing purposes. What you want is under \Tools\msi\buildrelease.bat. This creates a subdirectory under \PCBuild\ that places all msi, cab and exe files ready for later installation. According to the readme, there doesn't seem to be an option to pack all those files in a single .exe file, like all installers eventually do, but another option is under \Tools\msi\build.bat which does have an option for packing (namely build.bat --pack). "But", the readme does state that the buildrelease.bat should be used for an official release. The advantage of doing so is that Pyhton would be optimized using PGO to your own hardware. I am also trying to compile from source using this method but I am having an issue with a recurring error (and other ones):
PGO run did not succeed (no python36!*.pgc files) and there is no data to merge [E:\RepoGiT\3.6\PCbuild\pythoncore.vcxproj]
so, if you do go this route, and find this, or other errors, please send the bug report to python's bug tracker webpage. And better yet, if you find errors and their solution, please report back here!
So this is my situation:
I am writing Ansible playbooks and roles in a huge project directory. Currently my documentation is stored in .md files. But I want to use Ansible's documentation mechanism, so I looked into the sphinx documentation system. It seems pretty neat to me, so I installed it and got into the mechanisms.
But what I cant figure out: How does Ansible include the documentation that is located in the python modules into the sphinx documentation?
I am sorry to be not able to be more specific, but currently I am just scratching the surface I assume.
So here is what I want to achieve:
I have the typical roles directory
In it there are several roles
The files are mainly .yaml or .yml files
I at least want to include documentation from one file within these role directories
Ideally I want to pull documentation from several files within the directory
If too much is unclear please tell me and I will try to improve the question as I can't figure out for hours how to achieve this or even how to ask precisely.
Thanks in advance for every comment and answer!
Auto doc is only for Ansible modules, not playbooks.
If you want to document your playbooks, you are on your own.
There is a small project on github: ansible-docgen – it fetches a list of tasks into MD files and adds a couple of headers.
You can achive comparable result by calling ansible-playbook --list-tasks myplaybook.yml
In my personal opinion, reading playbooks with comments is very convenient.
I've been looking for ways to do this and haven't found a good solution to this. I'm trying to copy a sheet in an .xlsx file that has macros to another workbook. I know I could do this if the sheet contained data in each cell but that's not the case. The sheet contains checkboxes and SOME text. Is there a way to do this in python (or any other language for that matter?) I just need it done programmatically as it will be part of a larger script.
Try win32com package.
This offers an interface of VBA for python
You can find it on SourceForge.
I've done some projects with this package, we can discuss more on your problem if this package helps.
Is there a way to get eclipse to read .pyc files?
I'm trying to avoid downloading an external program and I would rather not trust an on-line service.
There is no open-source/free decompiler for Python - just a "disassembler" (see the dis-module in the stdlib). Getting back from the Python Stack-VM-assembly (which is stored in .pyc-files) to working Python code is mostly easy, as the general structure of the code is preserved, even when using "-O".
For special case solutions (i.e., marshalling .pyc-s in the old [pre 2.3]-format), see the answer #FabioZadrozny linked, but especially when you're using Python >=2.5 to produce the .pyc-s, this will most probably not work, though, as a lot of opcodes have changed/been added.
I have some data in CSV format that I want to pull into an Excel spreadsheet and then create some standard set of graphs for. Since the data is originally generated in a Python app, I was hoping to simply extend the app so that it could do all the post processing and I wouldn't have to do it by hand. Is there an easy interface with Python to work with and manipulate Excel spreadsheets? Any good samples of doing this? Is this Windows only (I'm primarily working on a Mac and have Excel, but could do this on Windows if necessary).
xlutils (and the included packages xlrd and xlwt) should allow your Python program to handily do any creation, reading and manipulation of Excel files you might want!
On Windows you could use the pywin32 package to create an Excel COM Object and then manipulate it from a script. You need to have an installed Excel on that machine though. I haven't done this myself so I can't give you and details but I've seen this working so can at least confirm that it's possible. No idea about OS X, unfortunately.