Python's os.path libraries equivalent in Groovy - python

Is there an equivalent module for Groovy as Python's os.path?

Most of the os.path functionality is found in the methods on the java.io.File class. In addition, if you're using Java 1.7, there are some additional methods in java.nio.file.Files.
Also note that groovy transparently adds some new addtional functionality on top of Java. These additional methods are documented here: http://groovy.codehaus.org/groovy-jdk/java/io/File.html

The standard java.io.File Java class can do a lot of the same things, and Groovy adds its own extensions (see http://groovy.codehaus.org/groovy-jdk).

Related

Are built-in types implementations avaliable in Python?

It's easy to find implementation of any library module in python (you just go to CPython repository on Github: https://github.com/python/cpython/), but where could I find implementations of build-in CPython types? It's important for example to prove that complex build-in type is inherited from numbers.Complex abc. Or it is also could be useful to explore attributes of function type.

python str.casefold() implementation location

Where is the implementation of the str.casefold() method in the python source code?
I searched for the string "casefold" in the github repository cpython. I found a test but not the definition of the method.
https://docs.python.org/3/library/stdtypes.html#str.casefold
https://github.com/python/cpython
https://github.com/python/cpython/blob/83d544b9292870eb44f6fca37df0aa351c4ef83a/Lib/test/test_unicode.py#L829
The casefold dispatcher is implemented there, you can just look up the functions it dispatches to.
https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Objects/unicodeobject.c#L10967

calling standard python functions from rubypython

I am trying to use the rubypython gem. Not sure how to call standard python functions like len and set. In the python examples I see len(text3) and set(text3).
How do I call these in rubypython?
Here is the link to rubypython: http://rubypython.rubyforge.org/
Well, my Ruby knowledge is limited, and my knowledge of the rubypython gem is non-existent. However, I do know the standard functions you refer to a part of the __builtin__ module, which is automatically imported into the python namespace. Fortunately, there's nothing preventing you from importing it explicitly again (which is perfectly safe in Python). You then might be able do something like __builtin__.set(). No guarantees, though.
RubyPython::PyMainClass has a public instance method builtin()
You can use that to call the standard functions.

Is it possible to use POD(plain old documentation) with Python?

I was wondering if it is possible to use POD(plain old documentation) with Python? And how should I do it?
There does not appear to be a directly supported way to use POD inline in a Python file. However, Python modules (including the Python standard library) are documented using reStructuredText. This is usually done using Sphinx, which produces documentation from reStructuredText-formatted docstrings. Sphinx and rst were specifically designed to fill a similar niche to POD.
Yes. Use '''.
#!/usr/bin/python3
'''
=pod
=head1 NAME
...
=cut
'''
import sys

compatibility between CPython and IronPython cPickle

I was wondering whether objects serialized using CPython's cPickle are readable by using IronPython's cPickle; the objects in question do not require any modules outside of the built-ins that both Cpython and IronPython include. Thank you!
If you use the default protocol (0) which is text based, then things should work. I'm not sure what will happen if you use a higher protocol. It's very easy to test this ...
It will work because when you unpickle objects during load() it will use the current definitions of whatever classes you have defined now, not back when the objects were pickled.
IronPython is simply Python with the standard library implemented in C# so that everything emits IL. Both the CPython and the IronPython pickle modules have the same functionality, except one is implemented in C and the other in C#.

Categories