[BangPypers] Favorite tips/techniques
kracekumar ramaraju
kracethekingmaker at gmail.com
Tue Sep 10 14:20:51 CEST 2013
I personally like to use IPython.
To see all variables, constants, modules.
n [9]: import requests
In [10]: requests.
requests.ConnectionError requests.api requests.models
requests.HTTPError requests.auth requests.options
requests.NullHandler requests.certs requests.packages
requests.PreparedRequest requests.codes requests.patch
requests.Request requests.compat requests.post
requests.RequestException requests.cookies requests.put
requests.Response requests.delete requests.request
requests.Session requests.exceptions requests.session
requests.Timeout requests.get requests.sessions
requests.TooManyRedirects requests.head requests.status_codes
requests.URLRequired requests.hooks requests.structures
requests.adapters requests.logging requests.utils
Now to read about `Session`
In [10]: requests.Session?
Type: type
String Form:<class 'requests.sessions.Session'>
File: /Library/Python/2.7/site-packages/requests/sessions.py
Docstring:
A Requests session.
Provides cookie persistience, connection-pooling, and configuration.
Basic Usage::
>>> import requests
>>> s = requests.Session()
>>> s.get('http://httpbin.org/get')
200
Constructor information:
Definition:requests.Session(self)
Now to open the file.
In [12]: !/Applications/Sublime\ Text\
2.app/Contents/SharedSupport/bin/subl
/Library/Python/2.7/site-packages/requests/sessions.py &
Note: IPython can't open alias so I dint use subl
How to read source code inside IPython ?
In [13]: requests.Session??
Type: type
String Form:<class 'requests.sessions.Session'>
File: /Library/Python/2.7/site-packages/requests/sessions.py
Source:
class Session(SessionRedirectMixin):
"""A Requests session.
Provides cookie persistience, connection-pooling, and configuration.
Basic Usage::
>>> import requests
>>> s = requests.Session()
>>> s.get('http://httpbin.org/get')
200
"""
....
On Tue, Sep 10, 2013 at 5:19 PM, Anand Chitipothu <anandology at gmail.com>wrote:
> Another utility script that I use very heavily, pyvi.
>
> https://github.com/anandology/hacks/blob/master/pyvi
>
> $ pyvi json.tool
>
> That opens json.tool module (or any other module) in vim. It also changes
> the current dir to that module directory so that you can easily open other
> modules in the same package very easily.
>
> You can press :e <tab> to see all available modules. :e deco<tab> will
> expand it to :e decoder.py and so on.
>
> I find this very hard for reading code when documentation is not enough.
> Noufal has an emacs port of this script.
>
> Anand
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>
--
*
Thanks & Regards
"Talk is cheap, show me the code" -- Linus Torvalds
kracekumar
www.kracekumar.com
*
More information about the BangPypers
mailing list