139 karma · joined May 28, 2013
Note for anyone who tries this out - to get back to your main session, try ctrl+alt+F1 or ctrl+alt+F2
You can memoize methods to the instance to get lazy evaluation, properties can be explicitly defined up-front, and the fact that everything is namespaced is nice. You can also make judicious use of @staticmethod to write functional code whenever possible.
It's important to distinguish what kind of "things" you're talking about, though. There's a pretty big moral difference between not being able to afford consumer goods and not being able to find an appropriate place to perform basic bodily functions.
You can work as a web dev at a small company without being part of the mainstream silicon valley rat race. Sysadmin-type skills are pretty hard to hire for, and very useful at small companies. It sounds like you've got that going for you. I'd change your definition of success and focus on finding a job at a company with a culture you'd enjoy, and not worry so much about its perceived prestige.
def absolute_path(path):
if not path.startswith('/'):
return '/' + path
return path
This way you don't have to keep track of mutating the path variable. I do find that more readable - it's clearer that there are two paths through the code. That said, this example is trivial enough that I'd probably do it with an inline if/else statement, although still probably not a lambda: def absolute_path(path):
return path if path.startswith('/') else '/' + path
This way it's more obvious at a glance that you're defining a function. It's easier to follow someone else's code if they generally adhere to standards, and Python is a very convention-oriented language.Neovim is working quite well already. I fully switched from vim to nvim months ago without any issues. Plugins are still written for vim though, so I don't think many take advantage of neovim-specific features yet. It does have a full terminal already though, which is pretty awesome.
edit: Oh, I'm guessing you're referring to the promises of embedding neovim inside IDEs. I'm looking forward to that too!
In [1]: %load_ext autoreload
In [2]: %autoreload 2
In [3]: from foo import some_function
In [4]: some_function()
Out[4]: 42
In [5]: # open foo.py in an editor and change some_function to return 43
In [6]: some_function()
Out[6]: 43
It's nothing like a proper lisp repl, but you can sorta do this in vanilla python too, if you don't mind some annoyances. `reload` reloads a module:
>>> import mymodule
>>> print mymodule.myfunction()
3
>>> reload(mymodule)
>>> print mymodule.myfunction()
5
Downside is you have to use the module, `from mymodule import function` won't reload.
- It completely takes over emacs. Your modifications now go in ~/.spacemacs. Don't touch ~/.emacs.d/ Want to install something from melpa? Make a spacemacs configuration layer. That aspect feels like a strong step away from the emacs ethos where you're on the same footing as the editor authors. I don't like the inversion of control.
- It's unstable. Fairly often I'll update and something will fail, leaving me helplessly with emacs keybindings. Thankfully, a revert is easy.
- The last one is a problem with evil in general, you'll still occasionally find yourself in emacs mode, where hjlk and more importantly ":q" don't work
This title and article are misleading, no where in the NYT piece does it say cats think we're "big stupid cats", just that they use their social norms towards us, as that's all they know. The cnet article is juvenile speculation.
What about pure carnivores? Surely their food doesn't want to be food, but carnivores do just fine.
While I agree that the amount of corn we eat is absurd, to call it inedible is ludicrous. Raw corn on the cob is plenty edible, and sweet corn is quite tasty, although that's admittedly not what's grown on large corn plantations.
from http://docs.python.org/2/library/traceback.html#traceback-ex...
In game.py, at the top, put
import sys, traceback
and around line 285, replace this: except Exception:
next_action = ['guard']
with this: except Exception:
print "The robot at (%s, %s) raised an exception:" % robot.location
print '-'*60
traceback.print_exc(file=sys.stdout)
print '-'*60
next_action = ['guard']
That makes your robot a lot easier to debug. Awesome game, have you thought about putting it on github so people can submit patches? python kit/run.py yourcode.py yourothercode.py --render
If you try to run run.py from outside of its directory, it can't import settings.py Traceback (most recent call last):
File "kit/run.py", line 1, in <module>
import game
File "/home/<name>/robotgame/kit/game.py", line 30, in <module>
settings = SettingsDict('settings.py').d
File "/home/<name>/robotgame/kit/game.py", line 28, in __init__
self.d = AttrDict(ast.literal_eval(open('settings.py').read()))
IOError: [Errno 2] No such file or directory: 'settings.py'Why not use metric prefixes on a day to come up with the names? This requires no new definitions, just a new application of existing terminology.
simple hour = deciday
simple minute = milliday
simple second = 10 microdays