Re: [BangPypers] Favorite tips/techniques

2013-09-13 Thread Saju M
Saager,
As per python module-import semantics, sub-modules don't end up as names in
the
package-module[*] unless explicitly added.

I didn't get it, what you mean by package-module[*] ?.

--

One simple test.

dir(json) showing the module tool after from json import tool, but that
module not in json.__all__ list.


* import json*


 *dir(json)*
['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
'__doc__', '__file__', '__name__', '__package__', '__path__',
'__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
'dumps', 'encoder', 'load', 'loads', 'scanner']


* json.__all__*
['dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONEncoder']


 *from json import tool*


 dir(json)
['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
'__doc__', '__file__', '__name__', '__package__', '__path__',
'__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
'dumps', 'encoder', 'load', 'loads', 'scanner', *'tool'*]


 *json.__all__*
['dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONEncoder']



Regards
Saju Madhavan
+91 09535134654


On Fri, Sep 13, 2013 at 8:25 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Saager Mhatre saager.mha...@gmail.com writes:

  On Tue, Sep 10, 2013 at 4:54 PM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:
 
  Saju M sajup...@gmail.com writes:
  [...]
 
 
   * Why dir(json) not showing tool ??
 
  Because of the __all__ variable in the module.
  http://docs.python.org/2/tutorial/modules.html
 
 
  Noufal,
  Well, not quite, right? I posit it's basically because as per python
  module-import semantics, sub-modules don't end up as names in the
  package-module[*] unless explicitly added, right?

 Yes. I think that's more accurate. Mea culpa.

 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-13 Thread Saager Mhatre
On Sep 9, 2013 8:51 PM, CsquaredinOmaha c2inom...@yahoo.com wrote:


 For a while I had thought it would be interesting to hear
tips/techniques you
 find yourself often using  - or perhaps found useful at one point (and
thus would be valuable to newbies).

 It could be simple snippet, or some description of  logic, technique or
steps.
 From simple to sophisticated is less the issue - more that you  found it
handy and used it alot.

 Whatever use area:  ETL data files, servers, SQL maintenance,
webcrawlers, anything.

== Writing tests as top-level functions as opposed to methods of a
unittest.TestCase subclass ==

Aside from the obvious advantage of eliminating ceremony, this has the
effect of forcing me to make sure that each test is entirely and atomically
independent of other tests. That way, I only ever have to read one function
to understand the nature of a given test failure.

Also, not having the ability to easily slap on setup/teardown
functions/methods forces me to make tests self-contained. Add in the
heuristic that tests with long/complicated arrange and/or act sections are
indicative of potential design flaws and you have the requisite TDD
feedback.

It also helps tremendously that both nosetest and pytest support this idiom.

- d
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-13 Thread Saager Mhatre
On Sep 9, 2013 8:51 PM, CsquaredinOmaha c2inom...@yahoo.com wrote:


 For a while I had thought it would be interesting to hear
tips/techniques you
 find yourself often using  - or perhaps found useful at one point (and
thus would be valuable to newbies).

 It could be simple snippet, or some description of  logic, technique or
steps.
 From simple to sophisticated is less the issue - more that you  found it
handy and used it alot.

 Whatever use area:  ETL data files, servers, SQL maintenance,
webcrawlers, anything.

The 'returning' function = http://bit.ly/13VNdBJ

- d
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-12 Thread Saager Mhatre
On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj sha...@agiliq.com wrote:

  https://github.com/webpy/webpy/blob/master/web/utils.py#L52

 Wow, thats better than the bare bunch impl. Gonna use it now.


plug type=shamelessIt's just s much nicer when the map/dict in your
platform http://groovy.codehaus.org/Collections#Collections-Mapsmaps just
does that for you :)/plug

- d
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-12 Thread Saager Mhatre
On Tue, Sep 10, 2013 at 4:54 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Saju M sajup...@gmail.com writes:
 [...]


  * Why dir(json) not showing tool ??

 Because of the __all__ variable in the module.
 http://docs.python.org/2/tutorial/modules.html


Noufal,
Well, not quite, right? I posit it's basically because as per python
module-import semantics, sub-modules don't end up as names in the
package-module[*] unless explicitly added, right?

Saju,
I sincerely hope your head didn't just explode! :P

- d
[*] for lack of a better word!
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-12 Thread Noufal Ibrahim
Saager Mhatre saager.mha...@gmail.com writes:

 On Tue, Sep 10, 2013 at 4:54 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Saju M sajup...@gmail.com writes:
 [...]


  * Why dir(json) not showing tool ??

 Because of the __all__ variable in the module.
 http://docs.python.org/2/tutorial/modules.html


 Noufal,
 Well, not quite, right? I posit it's basically because as per python
 module-import semantics, sub-modules don't end up as names in the
 package-module[*] unless explicitly added, right?

Yes. I think that's more accurate. Mea culpa.

[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-12 Thread L Radhakrishna Rao
Not so complex, but the technique which I love is the comprehension, it
decreases the code size.


On Fri, Sep 13, 2013 at 8:25 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Saager Mhatre saager.mha...@gmail.com writes:

  On Tue, Sep 10, 2013 at 4:54 PM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:
 
  Saju M sajup...@gmail.com writes:
  [...]
 
 
   * Why dir(json) not showing tool ??
 
  Because of the __all__ variable in the module.
  http://docs.python.org/2/tutorial/modules.html
 
 
  Noufal,
  Well, not quite, right? I posit it's basically because as per python
  module-import semantics, sub-modules don't end up as names in the
  package-module[*] unless explicitly added, right?

 Yes. I think that's more accurate. Mea culpa.

 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-12 Thread Noufal Ibrahim

I often type this

x = Break this into a list.split()

instead of

x = [Break, this, into, a, list]

The latter is more tedious to type.



-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread s|s
This use case where one needs to keep related values together as logical
group:

Properties, getattr, setattr are quite interesting option but I prefer
collections.namedtuple

Example

EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title,
department, paygrade')
import csvfor emp in map(EmployeeRecord._make,
csv.reader(open(employees.csv, rb))):
print emp.name, emp.title
import sqlite3conn = sqlite3.connect('/companydata')cursor =
conn.cursor()cursor.execute('SELECT name, age, title, department,
paygrade FROM employees')for emp in map(EmployeeRecord._make,
cursor.fetchall()):
print emp.name, emp.title


My contribution to bag of tricks




On Tue, Sep 10, 2013 at 9:59 PM, Gopalakrishnan Subramani 
gopalakrishnan.subram...@gmail.com wrote:

 Attributes are stylish, readable, feel native as object compared to
 dictionary. Sometimes I use setter methods to override the default
 assignments, modify getter to format the values and getter for virtual
 attributes for DSL stuffs.


 class DictObj(dict):
 def __getattr__(self, key):
 if key.startswith(has_):
 arr = key.split(_)
 return arr[1] in self

 return self[key]

 def __setattr__(self, key, value):
 self[key] = value


 od = DictObj()

 od.name = Nila

 print (Has Name? , od.has_name)
 print (Has Age? , od.has_age)

 We have this sort of implementation for functional test verification. We
 are into Industrial Automation, we deal with measurement devices like flow,
 pressure, density, etc. Each device has got  100+ attributes like tag,
 address, current value, calibration etc.

 Injecting 'has' and 'is' helps test engineers write unit test based on
 device property itself.

 if (device.is_calibration_running): # here calibration_running is a value
 read from the device or cached and is is applied for dynamic conditions.
  ...

 Although it seems like magic, but certainly not a black magic, we have
 control over there.

 Python must have got similar stuff  like dynamic function hooks, we could
 done still better. But we are missing.







 On Tue, Sep 10, 2013 at 8:48 PM, BibhasD m...@bibhas.in wrote:

  I'm just curious. I faced a similar issue before while answering a
  question about Django on StackOverflow. Django turns context variable
  dictionaries into objects with attributes in template. So in one
  question in SO someone posted this question. Had to answer that Django
  doesn't really support distinguishing such keys. So when I saw the same
  thing discussed, thought of throwing it out here. :)
 
  On Tuesday 10 September 2013 08:42 PM, Dhananjay Nene wrote:
   Ignoring classes for the moment, how likely do you think you would
   have a dict like that :)
  
   On a separate note if you are using primitive types, I cannot think of
   any scenarios, where not coercing keys to be of the same type would be
   considered inappropriate (except in case of reverse dicts)
  
   On Tue, Sep 10, 2013 at 3:52 PM, Me@Bibhas m...@bibhas.in wrote:
   What would happen for a dictionary like this?
  
   d = {'1': 'foo', 1: 'bar'}
   d
   {'1': 'foo', 1: 'bar'}
  
  
   On Tuesday 10 September 2013 10:00 AM, Noufal Ibrahim wrote:
   Shabda Raaj sha...@agiliq.com writes:
  
  
 
 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
  
   With api responses after you have parsed the json, you start doing
  things
   like:
  
   api_response[attribute]
  
   I would much prefer to do
  
   api_response.attribute
   I generally like to use attributes instead of keys. One additional
   advantage is that I can, if necessary, later convert the attribute
 into
   a property that does more than just return a value.
  
   [...]
  
  
   ___
   BangPypers mailing list
   BangPypers@python.org
   https://mail.python.org/mailman/listinfo/bangpypers
  
  
 
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Supreet Sethi
Ph UK: +447859172473
Ph IN: +919811143517
Ph Skype: d_j_i_n_n
Profile: http://www.google.com/profiles/supreet.sethi
Twt: http://twitter.com/djinn
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread Anand Chitipothu
Another script I use often is repr.

https://github.com/anandology/hacks/blob/master/repr

It reads each line from stdin and prints it as python repr. Useful to see
hidden/non-alphanumeric characters.

$ echo -e a\bc
c
$ echo -e a\bc | repr
a\x08c\n

This is similar to od, but od prints fixed number of characters in each
line and sometimes you want to see the lines without breaking.

Couple of hours back, I noticed an issue with a row in a mysql dump, and
here is how I used it to inspect at that row.

$ head -28130 my-table.txt | tail -1 | repr
2006-05-25 00:19:12\t\t1900-01-01 00:00:00\t\tMetal1\t

Anand
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread s|s
There are times when the project requires a large blob of data which needs
to be loaded with the python code. A general practice is to use pickle and
json object which is opened using file functions etc.

I tend to convert this kind of data (depending on size) into python file
using pprint and store it as code included using python standard coding
convention. Saves hassle of packaging and caring about path convention. Of
course it is not correct convention for all situations.


On Wed, Sep 11, 2013 at 4:55 PM, Anand Chitipothu anandol...@gmail.comwrote:

 Another script I use often is repr.

 https://github.com/anandology/hacks/blob/master/repr

 It reads each line from stdin and prints it as python repr. Useful to see
 hidden/non-alphanumeric characters.

 $ echo -e a\bc
 c
 $ echo -e a\bc | repr
 a\x08c\n

 This is similar to od, but od prints fixed number of characters in each
 line and sometimes you want to see the lines without breaking.

 Couple of hours back, I noticed an issue with a row in a mysql dump, and
 here is how I used it to inspect at that row.

 $ head -28130 my-table.txt | tail -1 | repr
 2006-05-25 00:19:12\t\t1900-01-01 00:00:00\t\tMetal1\t

 Anand
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Supreet Sethi
Ph UK: +447859172473
Ph IN: +919811143517
Ph Skype: d_j_i_n_n
Profile: http://www.google.com/profiles/supreet.sethi
Twt: http://twitter.com/djinn
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread Amit Sethi
1.
I do like the accessing dict attributes as keys and specifically where they
make more sense as structure by itselfI do use

 class ABC(object):
a = ''

 def __init__(self, **kwargs):
self.__dict__.update(**kwargs)

2. When creating a dictionary of constants create it dynamically and
independently on an interpreter and then use pprint and use copy it in my
code







On Wed, Sep 11, 2013 at 5:37 PM, s|s supr.e.etse...@gmail.com wrote:

 There are times when the project requires a large blob of data which needs
 to be loaded with the python code. A general practice is to use pickle and
 json object which is opened using file functions etc.

 I tend to convert this kind of data (depending on size) into python file
 using pprint and store it as code included using python standard coding
 convention. Saves hassle of packaging and caring about path convention. Of
 course it is not correct convention for all situations.


 On Wed, Sep 11, 2013 at 4:55 PM, Anand Chitipothu anandol...@gmail.com
 wrote:

  Another script I use often is repr.
 
  https://github.com/anandology/hacks/blob/master/repr
 
  It reads each line from stdin and prints it as python repr. Useful to see
  hidden/non-alphanumeric characters.
 
  $ echo -e a\bc
  c
  $ echo -e a\bc | repr
  a\x08c\n
 
  This is similar to od, but od prints fixed number of characters in each
  line and sometimes you want to see the lines without breaking.
 
  Couple of hours back, I noticed an issue with a row in a mysql dump, and
  here is how I used it to inspect at that row.
 
  $ head -28130 my-table.txt | tail -1 | repr
  2006-05-25 00:19:12\t\t1900-01-01 00:00:00\t\tMetal1\t
 
  Anand
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 



 --
 Supreet Sethi
 Ph UK: +447859172473
 Ph IN: +919811143517
 Ph Skype: d_j_i_n_n
 Profile: http://www.google.com/profiles/supreet.sethi
 Twt: http://twitter.com/djinn
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
A-M-I-T S|S
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vinayak Hegde
On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Anand Chitipothu anandol...@gmail.com writes:

 [...]

  I use it very often. Here is my random-password script.

 [...]

 I use mkpasswd(1) :)


What ever you use, please use py-bcrypt or something similar before you
store it in the database.

Here is the site with easy usage of it -
http://www.mindrot.org/projects/py-bcrypt/

Another on how to use it well and store password in db.
http://dustwell.com/how-to-handle-passwords-bcrypt.html

-- Vinayak

-- Vinayak
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Lakshman Prasad
My first random password (until it is replaced with SHA, MD5, bCrypt,
whatever):

 str(random.random())[2:]
'742557965797'



On Tue, Sep 10, 2013 at 11:34 AM, Vinayak Hegde vinay...@gmail.com wrote:

 On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:

  Anand Chitipothu anandol...@gmail.com writes:
 
  [...]
 
   I use it very often. Here is my random-password script.
 
  [...]
 
  I use mkpasswd(1) :)
 

 What ever you use, please use py-bcrypt or something similar before you
 store it in the database.

 Here is the site with easy usage of it -
 http://www.mindrot.org/projects/py-bcrypt/

 Another on how to use it well and store password in db.
 http://dustwell.com/how-to-handle-passwords-bcrypt.html

 -- Vinayak

 -- Vinayak
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Mandar Vaze / मंदार वझे
Both Shabda and Nouful used the term prefer
Is there a best practice ?

http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python

This guy asked for pitfalls and caveats - but no one seem to have
addressed the question (There are several answers about How to do it
better)

-Mandar


On Tue, Sep 10, 2013 at 10:00 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Shabda Raaj sha...@agiliq.com writes:

 
 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
 
  With api responses after you have parsed the json, you start doing things
  like:
 
  api_response[attribute]
 
  I would much prefer to do
 
  api_response.attribute

 I generally like to use attributes instead of keys. One additional
 advantage is that I can, if necessary, later convert the attribute into
 a property that does more than just return a value.

 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Me@Bibhas
This thread is awesome. Keep them coming. :)

I've also been using random string generator Shabda posted for a long
time. Handy.

On Tuesday 10 September 2013 12:48 PM, Lakshman Prasad wrote:
 My first random password (until it is replaced with SHA, MD5, bCrypt,
 whatever):

 str(random.random())[2:]
 '742557965797'



 On Tue, Sep 10, 2013 at 11:34 AM, Vinayak Hegde vinay...@gmail.com wrote:

 On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:
 Anand Chitipothu anandol...@gmail.com writes:

 [...]

 I use it very often. Here is my random-password script.
 [...]

 I use mkpasswd(1) :)

 What ever you use, please use py-bcrypt or something similar before you
 store it in the database.

 Here is the site with easy usage of it -
 http://www.mindrot.org/projects/py-bcrypt/

 Another on how to use it well and store password in db.
 http://dustwell.com/how-to-handle-passwords-bcrypt.html

 -- Vinayak

 -- Vinayak
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Me@Bibhas
Don't know if I can call it a snippet, But this command on terminal -

$ python -m SimpleHTTPServer 8080

is really handy for sharing files(along with the use of `localtunnel`
maybe) and testing HTML/CSS.

On Tuesday 10 September 2013 12:48 PM, Lakshman Prasad wrote:
 My first random password (until it is replaced with SHA, MD5, bCrypt,
 whatever):

 str(random.random())[2:]
 '742557965797'



 On Tue, Sep 10, 2013 at 11:34 AM, Vinayak Hegde vinay...@gmail.com wrote:

 On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:
 Anand Chitipothu anandol...@gmail.com writes:

 [...]

 I use it very often. Here is my random-password script.
 [...]

 I use mkpasswd(1) :)

 What ever you use, please use py-bcrypt or something similar before you
 store it in the database.

 Here is the site with easy usage of it -
 http://www.mindrot.org/projects/py-bcrypt/

 Another on how to use it well and store password in db.
 http://dustwell.com/how-to-handle-passwords-bcrypt.html

 -- Vinayak

 -- Vinayak
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Noufal Ibrahim
Me@Bibhas m...@bibhas.in writes:

 Don't know if I can call it a snippet, But this command on terminal -

 $ python -m SimpleHTTPServer 8080

Similar but less well known.

Command line ftp client (similar to ftp(1))
python -m ftplib ftp.gnu.org

Command line mail client (similar to mail(1)) but needs a local MTA
running
python -m smtplib

Command line IMAP client (similar mutt -f imap://...)
python -m imaplib -d5 nou...@imap.gmail.com

Command line POP client
python -m poplib pop.gmail.com

There are probably others too.


[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Anand B Pillai
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 10 September 2013 03:07 PM, Me@Bibhas wrote:
 This thread is awesome. Keep them coming. :)
 
 I've also been using random string generator Shabda posted for a
 long time. Handy.
 
 On Tuesday 10 September 2013 12:48 PM, Lakshman Prasad wrote:
 My first random password (until it is replaced with SHA, MD5,
 bCrypt, whatever):
 
 str(random.random())[2:]
 '742557965797'

Also,

 import uuid uuid.uuid4().bytes.encode('base64')[:12]
'XH4yYJA7SxSd'


uuid1..3 are not cryptographically strong as they are linked to the
machine but uuid4 generates a random, cryptographically secure uuid.

 
 
 
Regards,

- --Anand

-
--
Software Architect/Consultant
anandpil...@letterboxes.org

Please note my updated email address anandpil...@letterboxes.org.
Kindly update your address books.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSLu1ZAAoJEMTxYeOp9eaoJcYIAMxqHSNKm1rD4oDj9Y5sSEGw
mPuIelLcJGjB/qx2i6+SMB6dMQbofFV3k3YPlkwibDvkcQABbDl2Uxxo5BIVWXHB
ntH6ecQXGGw+YKOEoeBTq0s/Sv9rAsUtudO1q9/ylnKYpDgfG9sNjCwmhY9uB9iM
63mjsAoHOaJlNi6aQiBX+ceKqO38F9N13o/z63IKETWmc7efEthKWTG1HVRAhzXX
ICUaAiBvHFj0s2cOyZXmkIWkjwMPlbLyFLu7pyFeUMx5hb5SVoZkbCJF/lu943OM
nXTxQWz0N/zT6VMZVPHTTl98vXOb9esXqJD8+CeivhhgYKagR2xaXHcxbEKvE84=
=T5RJ
-END PGP SIGNATURE-
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Anand B Pillai
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 10 September 2013 03:28 PM, Noufal Ibrahim wrote:
 Me@Bibhas m...@bibhas.in writes:
 
 Don't know if I can call it a snippet, But this command on
 terminal -
 
 $ python -m SimpleHTTPServer 8080
 
 Similar but less well known.
 
 Command line ftp client (similar to ftp(1)) python -m ftplib
 ftp.gnu.org
 
 Command line mail client (similar to mail(1)) but needs a local
 MTA running python -m smtplib
 
 Command line IMAP client (similar mutt -f imap://...) python -m
 imaplib -d5 nou...@imap.gmail.com
 
 Command line POP client python -m poplib pop.gmail.com
 
 There are probably others too.
 

$ python -m webbrowser -t http://www.python.org


 
 [...]
 
 


- -- 
Regards,

- --Anand

-
--
Software Architect/Consultant
anandpil...@letterboxes.org

Please note my updated email address anandpil...@letterboxes.org.
Kindly update your address books.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSLu8OAAoJEMTxYeOp9eaoLWgH/1EInQZDF8aqfDxiWzYICv+M
82UH8FHCOTZjtj9KLfKtguc4da95bopJZyTSA+24aHKMKfdk082drLULgp6AiUT4
FwSFESwmHhTmiLQwLSI22nFb/NLnl7XaGX33Png+zBhN3fZDSEt23YCOx00MXKTO
Lkb2q8g2oFcB8CisGQ0gIDr/oPzskhe8DffHV8eo7+7T/EDBv6mHoiT1MmLOQqJu
uD0NbHL9RNMsi3I70cvAnHFkjLo9cVqMWnDQlN1x9KnCQMdJJ5n2JsNRn1cdG12i
A1jw0D93mDeA6GmV+5cAQ8ZhBnHkuyAlnJWBHDB18y/Nn8khw6d/weFkjldegNM=
=+nso
-END PGP SIGNATURE-
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Shabda Raaj
Another tip:

Its common to write decorators which clober the docstring and other meta
data. If you use functools.wrap this metadata is preserved.

http://docs.python.org/2/library/functools.html
https://github.com/django/django/blob/master/django/contrib/auth/decorators.py#L19



On Tue, Sep 10, 2013 at 12:48 PM, Lakshman Prasad scorpion...@gmail.comwrote:

 My first random password (until it is replaced with SHA, MD5, bCrypt,
 whatever):

  str(random.random())[2:]
 '742557965797'



 On Tue, Sep 10, 2013 at 11:34 AM, Vinayak Hegde vinay...@gmail.comwrote:

 On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:

  Anand Chitipothu anandol...@gmail.com writes:
 
  [...]
 
   I use it very often. Here is my random-password script.
 
  [...]
 
  I use mkpasswd(1) :)
 

 What ever you use, please use py-bcrypt or something similar before you
 store it in the database.

 Here is the site with easy usage of it -
 http://www.mindrot.org/projects/py-bcrypt/

 Another on how to use it well and store password in db.
 http://dustwell.com/how-to-handle-passwords-bcrypt.html

 -- Vinayak

 -- Vinayak
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers





-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps https://play.google.com/store/apps/developer?id=Agiliq | Our
iOS Apps https://itunes.apple.com/us/artist/agiliq/id407918088
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vineet Naik
Command line json formatter
$ echo '{name: Bangpypers, location: Bangalore}' | python -m
json.tool


On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Me@Bibhas m...@bibhas.in writes:

  Don't know if I can call it a snippet, But this command on terminal -
 
  $ python -m SimpleHTTPServer 8080

 Similar but less well known.

 Command line ftp client (similar to ftp(1))
 python -m ftplib ftp.gnu.org

 Command line mail client (similar to mail(1)) but needs a local MTA
 running
 python -m smtplib

 Command line IMAP client (similar mutt -f imap://...)
 python -m imaplib -d5 nou...@imap.gmail.com

 Command line POP client
 python -m poplib pop.gmail.com

 There are probably others too.


 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Gopalakrishnan Subramani
Not all keys in the dictionary can be expressed as attributes. Attributes
has to follow the naming conventions.

I had problems  with user generated 'keys', JSON supported keys.






On Tue, Sep 10, 2013 at 2:41 PM, Mandar Vaze / मंदार वझे 
mandarv...@gmail.com wrote:

 Both Shabda and Nouful used the term prefer
 Is there a best practice ?


 http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python

 This guy asked for pitfalls and caveats - but no one seem to have
 addressed the question (There are several answers about How to do it
 better)

 -Mandar


 On Tue, Sep 10, 2013 at 10:00 AM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:

  Shabda Raaj sha...@agiliq.com writes:
 
  
 
 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
  
   With api responses after you have parsed the json, you start doing
 things
   like:
  
   api_response[attribute]
  
   I would much prefer to do
  
   api_response.attribute
 
  I generally like to use attributes instead of keys. One additional
  advantage is that I can, if necessary, later convert the attribute into
  a property that does more than just return a value.
 
  [...]
 
 
  --
  Cordially,
  Noufal
  http://nibrahim.net.in
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Me@Bibhas
What would happen for a dictionary like this?

 d = {'1': 'foo', 1: 'bar'}
 d
{'1': 'foo', 1: 'bar'}


On Tuesday 10 September 2013 10:00 AM, Noufal Ibrahim wrote:
 Shabda Raaj sha...@agiliq.com writes:

 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/

 With api responses after you have parsed the json, you start doing things
 like:

 api_response[attribute]

 I would much prefer to do

 api_response.attribute
 I generally like to use attributes instead of keys. One additional
 advantage is that I can, if necessary, later convert the attribute into
 a property that does more than just return a value.

 [...]



___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Navin Pai
Date: Tue, 10 Sep 2013 15:39:44 +0530

 From: Vineet Naik naik...@gmail.com
 To: Bangalore Python Users Group - India bangpypers@python.org
 Message-ID:
 CADmbCiP8Dq7BroEWovreG2AfB=
 g1u3z80zgnt6cg3lenrsb...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1

 Command line json formatter
 $ echo '{name: Bangpypers, location: Bangalore}' | python -m
 json.tool

 Just to add, this works great in Vim too :)

Just use

:%!python -m json.tool

to get formatted JSON output

--
Navin Pai
http://lifeofnav.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Saju M
echo '{name: Bangpypers, location: Bangalore}' | python -m json.tool

In this command, what is this json.tool ?

I could not find tool in dir(json)

 import json
 dir(json)
['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
'__doc__', '__file__', '__name__', '__package__', '__path__',
'__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
'dumps', 'encoder', 'load', 'loads', 'scanner']



Regards
Saju Madhavan
+91 09535134654


On Tue, Sep 10, 2013 at 3:39 PM, Vineet Naik naik...@gmail.com wrote:

 Command line json formatter
 $ echo '{name: Bangpypers, location: Bangalore}' | python -m
 json.tool


 On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:

  Me@Bibhas m...@bibhas.in writes:
 
   Don't know if I can call it a snippet, But this command on terminal -
  
   $ python -m SimpleHTTPServer 8080
 
  Similar but less well known.
 
  Command line ftp client (similar to ftp(1))
  python -m ftplib ftp.gnu.org
 
  Command line mail client (similar to mail(1)) but needs a local MTA
  running
  python -m smtplib
 
  Command line IMAP client (similar mutt -f imap://...)
  python -m imaplib -d5 nou...@imap.gmail.com
 
  Command line POP client
  python -m poplib pop.gmail.com
 
  There are probably others too.
 
 
  [...]
 
 
  --
  Cordially,
  Noufal
  http://nibrahim.net.in
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 



 --
 Vineet Naik
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Noufal Ibrahim
Saju M sajup...@gmail.com writes:

 echo '{name: Bangpypers, location: Bangalore}' | python -m json.tool

 In this command, what is this json.tool ?

 I could not find tool in dir(json)

 import json
 dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']

It needn't be. 
 from json import tool
 tool.__file__
'/usr/lib/python2.7/json/tool.pyc'
 

json is a package and tool is one of the modules inside that. 

To get to this, I have a little shell function that I stole from Anand that has
been super useful repeatedly. 

epy () {
cmd=import $1 as a ; print a.__file__.endswith('.pyc') and 
a.__file__[:-1] or a.__file__ 
file=$(/usr/bin/env python -c $cmd) 
echo $file
emacsclient --no-wait $file
}

If you want to read the source for the json module, just do

$ epy json 

and the json module is loaded into Emacs. 


[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vineet Naik
On Tue, Sep 10, 2013 at 4:16 PM, Saju M sajup...@gmail.com wrote:

 echo '{name: Bangpypers, location: Bangalore}' | python -m
 json.tool

 In this command, what is this json.tool ?

 I could not find tool in dir(json)

  import json
  dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']


It's a module by itself. Located at /usr/lib/python2.7/json/tool.py on my
machine




 Regards
 Saju Madhavan
 +91 09535134654


 On Tue, Sep 10, 2013 at 3:39 PM, Vineet Naik naik...@gmail.com wrote:

  Command line json formatter
  $ echo '{name: Bangpypers, location: Bangalore}' | python -m
  json.tool
 
 
  On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim nou...@nibrahim.net.in
  wrote:
 
   Me@Bibhas m...@bibhas.in writes:
  
Don't know if I can call it a snippet, But this command on terminal -
   
$ python -m SimpleHTTPServer 8080
  
   Similar but less well known.
  
   Command line ftp client (similar to ftp(1))
   python -m ftplib ftp.gnu.org
  
   Command line mail client (similar to mail(1)) but needs a local MTA
   running
   python -m smtplib
  
   Command line IMAP client (similar mutt -f imap://...)
   python -m imaplib -d5 nou...@imap.gmail.com
  
   Command line POP client
   python -m poplib pop.gmail.com
  
   There are probably others too.
  
  
   [...]
  
  
   --
   Cordially,
   Noufal
   http://nibrahim.net.in
   ___
   BangPypers mailing list
   BangPypers@python.org
   https://mail.python.org/mailman/listinfo/bangpypers
  
 
 
 
  --
  Vineet Naik
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread BibhasD

On Tuesday 10 September 2013 04:16 PM, Saju M wrote:
 echo '{name: Bangpypers, location: Bangalore}' | python -m json.tool

 In this command, what is this json.tool ?

 I could not find tool in dir(json)

 import json
 dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']

import json.tool
print json.tool.__doc__

Command-line tool to validate and pretty-print JSON

Usage::

$ echo '{json:obj}' | python -m json.tool
{
json: obj
}
$ echo '{ 1.2:3.4}' | python -m json.tool
Expecting property name enclosed in double quotes: line 1 column 3 (char
 2)




 Regards
 Saju Madhavan
 +91 09535134654


 On Tue, Sep 10, 2013 at 3:39 PM, Vineet Naik naik...@gmail.com wrote:

 Command line json formatter
 $ echo '{name: Bangpypers, location: Bangalore}' | python -m
 json.tool


 On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:
 Me@Bibhas m...@bibhas.in writes:

 Don't know if I can call it a snippet, But this command on terminal -

 $ python -m SimpleHTTPServer 8080
 Similar but less well known.

 Command line ftp client (similar to ftp(1))
 python -m ftplib ftp.gnu.org

 Command line mail client (similar to mail(1)) but needs a local MTA
 running
 python -m smtplib

 Command line IMAP client (similar mutt -f imap://...)
 python -m imaplib -d5 nou...@imap.gmail.com

 Command line POP client
 python -m poplib pop.gmail.com

 There are probably others too.


 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers



 --
 Vineet Naik
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Noufal Ibrahim
Vineet Naik naik...@gmail.com writes:


[...]

 If you are using jedi[1] with auto-complete in emacs, C-. takes you to
 the definition by opening the module file in a write protected
 buffer. I use jedi mainly for this feature and inline documentation
 popout rather than for autocomplete :-)

[...]

I'll check it out. Thanks!


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Saju M
Hi,
I have couple of doubts


* How do you find json has module named tool ?.


* Why dir(json) not showing tool ??

 import json
 dir(json)
['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
'__doc__', '__file__', '__name__', '__package__', '__path__',
'__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
'dumps', 'encoder', 'load', 'loads', 'scanner']



* How to list all modules of a package in python console ?.


* Is this what you guys are using to check modules of a package ?.

ls /usr/lib/python2.7/json/ | grep .py$
decoder.py
encoder.py
__init__.py
scanner.py
tool.py

Regards
Saju Madhavan
+91 09535134654


On Tue, Sep 10, 2013 at 4:21 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Saju M sajup...@gmail.com writes:

  echo '{name: Bangpypers, location: Bangalore}' | python -m
 json.tool
 
  In this command, what is this json.tool ?
 
  I could not find tool in dir(json)
 
  import json
  dir(json)
  ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
  '__doc__', '__file__', '__name__', '__package__', '__path__',
  '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
  'dumps', 'encoder', 'load', 'loads', 'scanner']

 It needn't be.
  from json import tool
  tool.__file__
 '/usr/lib/python2.7/json/tool.pyc'
 

 json is a package and tool is one of the modules inside that.

 To get to this, I have a little shell function that I stole from Anand
 that has
 been super useful repeatedly.

 epy () {
 cmd=import $1 as a ; print a.__file__.endswith('.pyc') and
 a.__file__[:-1] or a.__file__
 file=$(/usr/bin/env python -c $cmd)
 echo $file
 emacsclient --no-wait $file
 }

 If you want to read the source for the json module, just do

 $ epy json

 and the json module is loaded into Emacs.


 [...]


 --
 Cordially,
 Noufal
 http://nibrahim.net.in

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Noufal Ibrahim
Saju M sajup...@gmail.com writes:

 Hi,
 I have couple of doubts


 * How do you find json has module named tool ?.

I look at the code/docs. 



 * Why dir(json) not showing tool ??

Because of the __all__ variable in the module. 
http://docs.python.org/2/tutorial/modules.html

 import json
 dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']



 * How to list all modules of a package in python console ?.

I don't think that's possible. If you import a package, only what the
__init__.py in the package decides to show you is available directly. 

 * Is this what you guys are using to check modules of a package ?.

Sort of. 

[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Vineet Naik
On Tue, Sep 10, 2013 at 4:48 PM, Saju M sajup...@gmail.com wrote:

 Hi,
 I have couple of doubts


 * How do you find json has module named tool ?.


 * Why dir(json) not showing tool ??

  import json
  dir(json)
 ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
 '__doc__', '__file__', '__name__', '__package__', '__path__',
 '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
 'dumps', 'encoder', 'load', 'loads', 'scanner']
 


 * How to list all modules of a package in python console ?.


 * Is this what you guys are using to check modules of a package ?.

 ls /usr/lib/python2.7/json/ | grep .py$
 decoder.py
 encoder.py
 __init__.py
 scanner.py
 tool.py


Don't know how to get all modules of a package as a list but if you just
need to refer to the package contents, then pydoc gives this info. eg. run,

$ pydoc json

and then search for the section titled PACKAGE CONTENTS and you can find
tool listed there along with the other modules in the package.



 Regards
 Saju Madhavan
 +91 09535134654


 On Tue, Sep 10, 2013 at 4:21 PM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:

  Saju M sajup...@gmail.com writes:
 
   echo '{name: Bangpypers, location: Bangalore}' | python -m
  json.tool
  
   In this command, what is this json.tool ?
  
   I could not find tool in dir(json)
  
   import json
   dir(json)
   ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
   '__doc__', '__file__', '__name__', '__package__', '__path__',
   '__version__', '_default_decoder', '_default_encoder', 'decoder',
 'dump',
   'dumps', 'encoder', 'load', 'loads', 'scanner']
 
  It needn't be.
   from json import tool
   tool.__file__
  '/usr/lib/python2.7/json/tool.pyc'
  
 
  json is a package and tool is one of the modules inside that.
 
  To get to this, I have a little shell function that I stole from Anand
  that has
  been super useful repeatedly.
 
  epy () {
  cmd=import $1 as a ; print a.__file__.endswith('.pyc') and
  a.__file__[:-1] or a.__file__
  file=$(/usr/bin/env python -c $cmd)
  echo $file
  emacsclient --no-wait $file
  }
 
  If you want to read the source for the json module, just do
 
  $ epy json
 
  and the json module is loaded into Emacs.
 
 
  [...]
 
 
  --
  Cordially,
  Noufal
  http://nibrahim.net.in
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
Vineet Naik
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Anand Chitipothu
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 decotab 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@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread kracekumar ramaraju
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.compatrequests.post
requests.RequestException  requests.cookies   requests.put
requests.Response  requests.deleterequests.request
requests.Session   requests.exceptionsrequests.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 anandol...@gmail.comwrote:

 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 decotab 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@python.org
 https://mail.python.org/mailman/listinfo/bangpypers




-- 
*
Thanks  Regards

Talk is cheap, show me the code -- Linus Torvalds
kracekumar
www.kracekumar.com
*
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Sreekandh Balakrishnan


 This thread is awesome. Keep them coming. :)
Prettyprint comes very handy when it comes to object debugging. Use it in my 
logger method always ;) 

http://docs.python.org/2/library/pprint.html
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Ramchandra Apte
Obligatory comic: https://xkcd.com/936/


On 10 September 2013 10:42, Anand Chitipothu anandol...@gmail.com wrote:

 On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj sha...@agiliq.com wrote:

   https://github.com/webpy/webpy/blob/master/web/utils.py#L52
 
  Wow, thats better than the bare bunch impl. Gonna use it now.
 
  Unrelated tip:
 
  Here is a one liner I use to generate passwords and other random strings.
 
  ''.join(random.choice(string.ascii_uppercase + string.digits) for x in
  range(N))
 

 I use it very often. Here is my random-password script.

 $ cat ~/bin/random-password
 #! /usr/bin/env python

 import random
 import sys
 import string

 try:
 n = int(sys.argv[1])
  except IndexError:
 n = 20

 print(.join(random.choice(string.ascii_letters) for i in range(n)))

 Anand
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Shabda Raaj
 I personally like to use IPython.

 To see all variables, constants, modules.

Ipython is amazing. To see a library code, I jsut tab-out lib_name.__file__
and then

!vim paste_the_file_path

Going to add something like anand's pyvi to ipy_user_conf.py.

Ipython with treat anything after bang(!) as a shell command to never felt
the need till now.

Related: You can get a ipython shell within your django runserver's

from IPython.Shell import IPShellEmbed
ipython = IPShellEmbed()

http://agiliq.com/blog/2009/12/using-bpython-shell-with-django-and-some-ipython-f/

I also like to debug with ipdb (rather than the pdb). Add this to your
Django views.

import ipdb; ipdb.set_trace() and debug away.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread CsquaredinOmaha
Bibhas,

Glad you are pleased.
I started the thread in consideration of  your comment that list had not enough 
interesting being posted.
Again, it is ok to start threads yourself (so keep something to throw out there 
maybe when current flurry slows down and the list needs some fresh discussion).

Regards,
Chris



 From: Me@Bibhas m...@bibhas.in
To: Bangalore Python Users Group - India bangpypers@python.org 
Sent: Tuesday, September 10, 2013 4:37 AM
Subject: Re: [BangPypers] Favorite tips/techniques
 

This thread is awesome. Keep them coming. :)

I've also been using random string generator Shabda posted for a long
time. Handy.

On Tuesday 10 September 2013 12:48 PM, Lakshman Prasad wrote:
 My first random password (until it is replaced with SHA, MD5, bCrypt,
 whatever):

 str(random.random())[2:]
 '742557965797'



 On Tue, Sep 10, 2013 at 11:34 AM, Vinayak Hegde vinay...@gmail.com wrote:

 On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.in
 wrote:
 Anand Chitipothu anandol...@gmail.com writes:

 [...]

 I use it very often. Here is my random-password script.
 [...]

 I use mkpasswd(1) :)

 What ever you use, please use py-bcrypt or something similar before you
 store it in the database.

 Here is the site with easy usage of it -
 http://www.mindrot.org/projects/py-bcrypt/

 Another on how to use it well and store password in db.
 http://dustwell.com/how-to-handle-passwords-bcrypt.html

 -- Vinayak

 -- Vinayak
 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Dhananjay Nene
Ignoring classes for the moment, how likely do you think you would
have a dict like that :)

On a separate note if you are using primitive types, I cannot think of
any scenarios, where not coercing keys to be of the same type would be
considered inappropriate (except in case of reverse dicts)

On Tue, Sep 10, 2013 at 3:52 PM, Me@Bibhas m...@bibhas.in wrote:
 What would happen for a dictionary like this?

 d = {'1': 'foo', 1: 'bar'}
 d
 {'1': 'foo', 1: 'bar'}


 On Tuesday 10 September 2013 10:00 AM, Noufal Ibrahim wrote:
 Shabda Raaj sha...@agiliq.com writes:

 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/

 With api responses after you have parsed the json, you start doing things
 like:

 api_response[attribute]

 I would much prefer to do

 api_response.attribute
 I generally like to use attributes instead of keys. One additional
 advantage is that I can, if necessary, later convert the attribute into
 a property that does more than just return a value.

 [...]



 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread BibhasD
I'm just curious. I faced a similar issue before while answering a
question about Django on StackOverflow. Django turns context variable
dictionaries into objects with attributes in template. So in one
question in SO someone posted this question. Had to answer that Django
doesn't really support distinguishing such keys. So when I saw the same
thing discussed, thought of throwing it out here. :)

On Tuesday 10 September 2013 08:42 PM, Dhananjay Nene wrote:
 Ignoring classes for the moment, how likely do you think you would
 have a dict like that :)

 On a separate note if you are using primitive types, I cannot think of
 any scenarios, where not coercing keys to be of the same type would be
 considered inappropriate (except in case of reverse dicts)

 On Tue, Sep 10, 2013 at 3:52 PM, Me@Bibhas m...@bibhas.in wrote:
 What would happen for a dictionary like this?

 d = {'1': 'foo', 1: 'bar'}
 d
 {'1': 'foo', 1: 'bar'}


 On Tuesday 10 September 2013 10:00 AM, Noufal Ibrahim wrote:
 Shabda Raaj sha...@agiliq.com writes:

 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/

 With api responses after you have parsed the json, you start doing things
 like:

 api_response[attribute]

 I would much prefer to do

 api_response.attribute
 I generally like to use attributes instead of keys. One additional
 advantage is that I can, if necessary, later convert the attribute into
 a property that does more than just return a value.

 [...]


 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers



___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Gopalakrishnan Subramani
Attributes are stylish, readable, feel native as object compared to
dictionary. Sometimes I use setter methods to override the default
assignments, modify getter to format the values and getter for virtual
attributes for DSL stuffs.


class DictObj(dict):
def __getattr__(self, key):
if key.startswith(has_):
arr = key.split(_)
return arr[1] in self

return self[key]

def __setattr__(self, key, value):
self[key] = value


od = DictObj()

od.name = Nila

print (Has Name? , od.has_name)
print (Has Age? , od.has_age)

We have this sort of implementation for functional test verification. We
are into Industrial Automation, we deal with measurement devices like flow,
pressure, density, etc. Each device has got  100+ attributes like tag,
address, current value, calibration etc.

Injecting 'has' and 'is' helps test engineers write unit test based on
device property itself.

if (device.is_calibration_running): # here calibration_running is a value
read from the device or cached and is is applied for dynamic conditions.
 ...

Although it seems like magic, but certainly not a black magic, we have
control over there.

Python must have got similar stuff  like dynamic function hooks, we could
done still better. But we are missing.







On Tue, Sep 10, 2013 at 8:48 PM, BibhasD m...@bibhas.in wrote:

 I'm just curious. I faced a similar issue before while answering a
 question about Django on StackOverflow. Django turns context variable
 dictionaries into objects with attributes in template. So in one
 question in SO someone posted this question. Had to answer that Django
 doesn't really support distinguishing such keys. So when I saw the same
 thing discussed, thought of throwing it out here. :)

 On Tuesday 10 September 2013 08:42 PM, Dhananjay Nene wrote:
  Ignoring classes for the moment, how likely do you think you would
  have a dict like that :)
 
  On a separate note if you are using primitive types, I cannot think of
  any scenarios, where not coercing keys to be of the same type would be
  considered inappropriate (except in case of reverse dicts)
 
  On Tue, Sep 10, 2013 at 3:52 PM, Me@Bibhas m...@bibhas.in wrote:
  What would happen for a dictionary like this?
 
  d = {'1': 'foo', 1: 'bar'}
  d
  {'1': 'foo', 1: 'bar'}
 
 
  On Tuesday 10 September 2013 10:00 AM, Noufal Ibrahim wrote:
  Shabda Raaj sha...@agiliq.com writes:
 
 
 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
 
  With api responses after you have parsed the json, you start doing
 things
  like:
 
  api_response[attribute]
 
  I would much prefer to do
 
  api_response.attribute
  I generally like to use attributes instead of keys. One additional
  advantage is that I can, if necessary, later convert the attribute into
  a property that does more than just return a value.
 
  [...]
 
 
  ___
  BangPypers mailing list
  BangPypers@python.org
  https://mail.python.org/mailman/listinfo/bangpypers
 
 

 ___
 BangPypers mailing list
 BangPypers@python.org
 https://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Favorite tips/techniques

2013-09-09 Thread CsquaredinOmaha
 
For a while I had thought it would be interesting to hear tips/techniques you 
find yourself often using  - or perhaps found useful at one point (and thus 
would be valuable to newbies).

It could be simple snippet, or some description of  logic, technique or steps.
From simple to sophisticated is less the issue - more that you  found it 
handy and used it alot.

Whatever use area:  ETL data files, servers, SQL maintenance, webcrawlers, 
anything. 



#--here is a snippet to open Windows File Explorer to select a file 
#--file explorer to select,open, and then parse network IP logfile
from Tkinter import *
import tkFileDialog
logfilename = tkFileDialog.askopenfilename()

#print logfilename
logfile = open(logfilename, r)
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/

With api responses after you have parsed the json, you start doing things
like:

api_response[attribute]

I would much prefer to do

api_response.attribute

Which the bunch pattern can enable.
I don't use it as frequently as I would like, as code is read much more
frequently than it is written, and not everyone would be aware of the
bunch pattern.


-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps https://play.google.com/store/apps/developer?id=Agiliq | Our
iOS Apps https://itunes.apple.com/us/artist/agiliq/id407918088
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Shabda Raaj sha...@agiliq.com writes:

 http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/

 With api responses after you have parsed the json, you start doing things
 like:

 api_response[attribute]

 I would much prefer to do

 api_response.attribute

I generally like to use attributes instead of keys. One additional
advantage is that I can, if necessary, later convert the attribute into
a property that does more than just return a value.

[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
 I generally like to use attributes instead of keys.

If you are parsing json, aren't you limited to using keys? The bunch
pattern can fix this, but its not widely known/used, so I don't use it as
frequently as I would like.

-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps https://play.google.com/store/apps/developer?id=Agiliq | Our
iOS Apps https://itunes.apple.com/us/artist/agiliq/id407918088
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Shabda Raaj sha...@agiliq.com writes:

 I generally like to use attributes instead of keys.

 If you are parsing json, aren't you limited to using keys? 

Of course. I was making a general statement about attributes vs. keys. 

 The bunch pattern can fix this, but its not widely known/used, so I
 don't use it as frequently as I would like.

Yes. It's quite neat. 

-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:09 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Shabda Raaj sha...@agiliq.com writes:

  I generally like to use attributes instead of keys.
 
  If you are parsing json, aren't you limited to using keys?

 Of course. I was making a general statement about attributes vs. keys.

  The bunch pattern can fix this, but its not widely known/used, so I
  don't use it as frequently as I would like.

 Yes. It's quite neat.


web.py has something similar, but it works both like a dict and object at
the same time. More like a javascript object.

https://github.com/webpy/webpy/blob/master/web/utils.py#L52

Couple of issues with the Bunch pattern:

* it is hard to check for existence of a key
* hard to iterate over the keys
* how do you convert a bunch object into JSON?

Anand
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
 https://github.com/webpy/webpy/blob/master/web/utils.py#L52

Wow, thats better than the bare bunch impl. Gonna use it now.

Unrelated tip:

Here is a one liner I use to generate passwords and other random strings.

''.join(random.choice(string.ascii_uppercase + string.digits) for x in
range(N))






On Tue, Sep 10, 2013 at 10:18 AM, Anand Chitipothu anandol...@gmail.comwrote:


 On Tue, Sep 10, 2013 at 10:09 AM, Noufal Ibrahim 
 nou...@nibrahim.net.inwrote:

 Shabda Raaj sha...@agiliq.com writes:

  I generally like to use attributes instead of keys.
 
  If you are parsing json, aren't you limited to using keys?

 Of course. I was making a general statement about attributes vs. keys.

  The bunch pattern can fix this, but its not widely known/used, so I
  don't use it as frequently as I would like.

 Yes. It's quite neat.


 web.py has something similar, but it works both like a dict and object at
 the same time. More like a javascript object.

 https://github.com/webpy/webpy/blob/master/web/utils.py#L52

 Couple of issues with the Bunch pattern:

 * it is hard to check for existence of a key
 * hard to iterate over the keys
 * how do you convert a bunch object into JSON?

 Anand




-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps https://play.google.com/store/apps/developer?id=Agiliq | Our
iOS Apps https://itunes.apple.com/us/artist/agiliq/id407918088
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj sha...@agiliq.com wrote:

  https://github.com/webpy/webpy/blob/master/web/utils.py#L52

 Wow, thats better than the bare bunch impl. Gonna use it now.

 Unrelated tip:

 Here is a one liner I use to generate passwords and other random strings.

 ''.join(random.choice(string.ascii_uppercase + string.digits) for x in
 range(N))


I use it very often. Here is my random-password script.

$ cat ~/bin/random-password
#! /usr/bin/env python

import random
import sys
import string

try:
n = int(sys.argv[1])
 except IndexError:
n = 20

print(.join(random.choice(string.ascii_letters) for i in range(n)))

Anand
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Anand Chitipothu anandol...@gmail.com writes:

[...]

 I use it very often. Here is my random-password script.

[...]

I use mkpasswd(1) :)


-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Anand Chitipothu
On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote:

 Anand Chitipothu anandol...@gmail.com writes:

 [...]

  I use it very often. Here is my random-password script.

 [...]

 I use mkpasswd(1) :)


$ sudo apt-cache search mkpasswd
libstring-mkpasswd-perl - Perl module implementing a random password
generator

Oh, no!

Anand
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Shabda Raaj
Real programmers pipe /dev/urandom :)

Let me preempt the xkcd: http://xkcd.com/378/


On Tue, Sep 10, 2013 at 10:47 AM, Anand Chitipothu anandol...@gmail.comwrote:


 On Tue, Sep 10, 2013 at 10:45 AM, Noufal Ibrahim 
 nou...@nibrahim.net.inwrote:

 Anand Chitipothu anandol...@gmail.com writes:

 [...]

  I use it very often. Here is my random-password script.

 [...]

 I use mkpasswd(1) :)


 $ sudo apt-cache search mkpasswd
 libstring-mkpasswd-perl - Perl module implementing a random password
 generator

 Oh, no!

 Anand




-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps https://play.google.com/store/apps/developer?id=Agiliq | Our
iOS Apps https://itunes.apple.com/us/artist/agiliq/id407918088
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-09 Thread Noufal Ibrahim
Anand Chitipothu anandol...@gmail.com writes:


[...]


 $ sudo apt-cache search mkpasswd
 libstring-mkpasswd-perl - Perl module implementing a random password
 generator

I think that's something else. 

noufal@sanitarium% dpkg -S =mkpasswd
whois: /usr/bin/mkpasswd

noufal@sanitarium% file =mkpasswd
/usr/bin/mkpasswd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), 
dynamically linked (uses shared libs), for GNU/Linux 2.6.26, 
BuildID[sha1]=0x2427549126fc6c2dda9f8420a090fc65a1c16130, stripped

noufal@sanitarium% whatis mkpasswd
mkpasswd (1) - Overfeatured front end to crypt(3)



-- 
Cordially,
Noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers