This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #python 2.7 | |
| with warnings.catch_warnings(record=False) as w: | |
| soup = BeautifulStoneSoup("<b />") | |
| self.assertEqual(u"<b/>", unicode(soup.b)) | |
| #python 2.5 | |
| warnings_manager = warnings.catch_warnings(record=True) | |
| w = warnings_manager.__enter__() | |
| try: | |
| soup = BeautifulStoneSoup("<b />") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I have two parsers: one looks at sys.argv while the other looks at some of the tokens the first slurped up. So from argparse's perspective, it does seem like there should just be one parser. I assert that isn't appropriate for my purposes, though: | |
| The first parser is looking at general lay-of-the-land-type stuff: "username to use when calling that API", etc. | |
| The second is looking at specific what-to-do stuff: "what you should do with that API." | |
| I want the settings for the first part to be configurable in a couple different ways: config file, env vars, command-line arguments. For that, I really want my various "configuration getters" to live together. The "what to do" parser has no business in that domain, though; I want it at the top-level script where it can determine a dispatch to some library function. So I have two parsers. | |
| All I'm trying to get argparse to do is "if you are displaying a usage message, display the message for the general script and also the one describing the various subparsers." sys.e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> require 'some_class' | |
| => true | |
| >> foo = SomeClass.new | |
| => #<SomeClass:0x100a23900> | |
| >> foo.doit | |
| SomeClass=> nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SomeThing(object): | |
| def doathing(self): | |
| pass | |
| class OtherThing(SomeThing): | |
| make_it_happen_capn(self): | |
| doathing() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> def do_something(): | |
| ... print 'here' | |
| ... for x in xrange(0, 8): | |
| ... yield x | |
| ... | |
| >>> do_something() | |
| <generator object do_something at 0x100428aa0> | |
| >>> foo = do_something() | |
| >>> foo | |
| <generator object do_something at 0x100428b40> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| § echo " | |
| . | |
| . | |
| . | |
| " | |
| . | |
| . | |
| . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module SomeModule | |
| @foo = 1234 | |
| def self.some_method | |
| @foo | |
| end | |
| end | |
| class SomeClass | |
| def bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> a, a, b = [1, 2, 3] | |
| => [1, 2, 3] | |
| >> a | |
| => 2 | |
| >> _, _, b = [1, 2, 3] | |
| => [1, 2, 3] | |
| >> _ | |
| => [1, 2, 3] | |
| >> a | |
| => 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| § nosetests | |
| ..........................................................................................................................E | |
| ====================================================================== | |
| ERROR: test suite for <module 'tests' from '/Users/andrew/code/catsnap/tests/__init__.pyc'> | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/Users/andrew/Envs/catsnap/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 227, in run | |
| self.tearDown() | |
| File "/Users/andrew/Envs/catsnap/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 350, in tearDown | |
| self.teardownContext(ancestor) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var auth, querystring, sha1, sign, strftime, test_auth; | |
| strftime = require('strftime'); | |
| querystring = require('querystring'); | |
| sha1 = require('sha1'); | |
| module.exports = function(robot) { | |
| return robot.respond(/test/, function(msg) { |