Re: [Tutor] Convert os.random output to a string

2014-03-06 Thread Jay Lozier
Alan I am planning to store the passwords encrypted. This part is allow a user to generate and view the generated password. Ben got me pointed to a snippet I can use. I was trying to do something the hard way. Jay On 03/06/2014 07:34 PM, Alan Gauld wrote: On 06/03/14 23:32, Jay Lozier wrot

Re: [Tutor] Convert os.random output to a string

2014-03-06 Thread Alan Gauld
On 06/03/14 23:32, Jay Lozier wrote: I am try to generate random password strings of an arbitrary user selected length. I read to generate a random string of a user supplied length I can use os.urandom(n). So far so good... > I want to convert the output to a human readable string. Define hu

Re: [Tutor] Convert os.random output to a string

2014-03-06 Thread Ben Finney
Jay Lozier writes: > I am try to generate random password strings of an arbitrary user > selected length. My first recommendation would be: Don't re-invent the wheel. Generating password strings is a complex request, not because it's particularly difficult but because the requirements are comple

[Tutor] Convert os.random output to a string

2014-03-06 Thread Jay Lozier
Hi, My first question I am try to generate random password strings of an arbitrary user selected length. I read to generate a random string of a user supplied length I can use os.urandom(n). I want to convert the output to a human readable string. I would like to store the string for later pr

Re: [Tutor] How to determine which function code is being called from

2014-03-06 Thread Jerry Hill
On Thu, Mar 6, 2014 at 12:00 PM, Jignesh Sutar wrote: > Hi I'm trying to exclude a certain line of code if the function is called by > another function, see illustration below: As other have said, this is not often a good idea. That said, it is possible to inspect the call stack to see what call

Re: [Tutor] How to determine which function code is being called from

2014-03-06 Thread Danny Yoo
On Thu, Mar 6, 2014 at 9:00 AM, Jignesh Sutar wrote: > Hi I'm trying to exclude a certain line of code if the function is called by > another function, see illustration below: > > > def funcA(): > print "running from funcA" # print only if running from funcA > print "running from funcA or

Re: [Tutor] How to determine which function code is being called from

2014-03-06 Thread Dave Angel
Jignesh Sutar Wrote in message: > > Hi I'm trying to exclude a certain line of code if the function is called by another function, see illustration below: Your code example is all confused, so perhaps you are as well. Why should any of your code in function A care who calls it? The main po

Re: [Tutor] How to determine which function code is being called from

2014-03-06 Thread spir
On 03/06/2014 06:00 PM, Jignesh Sutar wrote: Hi I'm trying to exclude a certain line of code if the function is called by another function, see illustration below: def funcA(): print "running from funcA" # print only if running from funcA print "running from funcA or funcB" #print whe

Re: [Tutor] How to determine which function code is being called from

2014-03-06 Thread Emile van Sebille
While there are ways of getting at the caller using introspection, there are no reliable ways of doing so and you would do well to rethink the need and take an alternate course such as passing a parameter in. Suppose the following: funcC=funcB what would you want to see? Emile On 3/6/2014

[Tutor] How to determine which function code is being called from

2014-03-06 Thread Jignesh Sutar
Hi I'm trying to exclude a certain line of code if the function is called by another function, see illustration below: def funcA(): print "running from funcA" # print only if running from funcA print "running from funcA or funcB" #print when running from either function print "running