Recipe 577237
Use this code in your module to prevent people using the "from foo import *" syntax with your module.
@apply
class __all__(object):
def __getitem__(self, _):
raise ImportError("Star imports not supported")
Random thoughts around programming and CG
Recipe 577237
Use this code in your module to prevent people using the "from foo import *" syntax with your module.
@apply
class __all__(object):
def __getitem__(self, _):
raise ImportError("Star imports not supported")
I hope one of these stuffs is in the standard library.
>>> p = Path('/path/to/some/text.txt')
>>> p.parent()
Path('/path/to/some')
>>> p.parent().parent()
Path('/path/to')
>>> p.parent().parent().parent()
Path('/path')
>>> p.parent().parent().parent().parent()
Path('/')
>>> p.parent().parent().parent().parent().parent()
Path('/')
>>> p.parent().child('other').child('text.txt')
Path('/path/to/some/other/text.txt')
>>> p[:-1]
Path('/path/to/some')
>>> p[1:-1]
Path('path/to/some')
>>> p[2:-1]
Path('to/some')
import os
class Path(object):
def __init__(self, path):
if isinstance(path, Path):
path = path.path
self.path = path
def parent(self):
return Path(os.path.dirname(self.path))
def child(self, name):
if isinstance(name, Path):
name = name.path
childPath = os.path.join(self.path, name)
return Path(childPath)
def base(self):
return Path(os.path.basename(self.path))
def abspath(self):
return Path(os.path.abspath(self.path))
def __str__(self):
return self.path
def __repr__(self):
return self.__class__.__name__ + '(' + repr(self.path) + ')'
def __add__(self, rhs):
if isinstance(rhs, Path):
return self.child(rhs.path)
else:
return Path(self.path + rhs)
def __eq__(self, rhs):
if isinstance(rhs, Path):
rpath = rhs.path
elif isinstance(rhs, unicode):
rpath = rhs
else:
return False
return os.path.abspath(self.path) == os.path.abspath(rpath)
def __ne__(self, rhs):
return not self.__eq__(rhs)
def __getitem__(self, key):
this, parent = self, self.parent()
bases = [this.base()]
while this != parent:
bases[:0] = [parent.base()]
this, parent = parent, parent.parent()
bases[0] = this
bases = bases[key]
retPath = bases[0]
for base in bases[1:]:
retPath = retPath.child(base)
return retPath
@staticmethod
def getCurrent():
return Path(os.getcwd())
MRV v1.0.0-preview documentation
Looks like a high abstract level Maya API Python wrapper (and more?). Anybody tested it?

Detexify2 - LaTeX symbol classifier
What is this?
Anyone who works with LaTeX knows how time-consuming it can be to find a symbol in symbols-a4.pdf that you just can't memorize. Detexify is an attempt to simplify this search.
How does it work?
Just draw the symbol you are looking for into the square area above and look what happens!
Wrong usage.
Japanese:*****
google translate
-> English:I do not have to surgery. No way, thank you.
-> Japanese:*****
-> English:I do not need the surgery. So no thank you.
-> Japanese:*****
-> English:I do not need the surgery. Well, thank you.
-> Japanese:*****
-> English:I do not need the surgery. Well, thank you.
It's interesting the final translation of the second sentence is closer to the right meaning, though the first translation is completely opposite. Google translate needs convergence ;)
The meaning of the first sentence remained opposite. It means "You need to have an operation".
I haven't updated "on topic" issues for quite a long time. Now I'm working as a freelancer at a company which is making a GI renderer and mainly working with 3ds Max (especially with material part of its SDK, that explains why I am NOT a big fan of Max). At home I'm reading siggraph papers, papers, papers. Siggraph papers are like treasure boxes but they are often hard to open, the key of a box is often inside another, and it needs yet another to open ...