Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"

Sarah Jay

Ranch Hand
+ Follow
since Dec 10, 2019
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sarah Jay

Bear Bibeault wrote:In your first example the keys are numbers, not strings. In the second case they are strings. The second case works because you are using the strings from phone_num as the indexes, not numbers.

Thanks, Bear...

You mean to say I should not cast it to list then it will work fine...I have tried that too...It dint worked for me...Could you please explain to me little in a little bit clearer way...
1 week ago
Hi All,

As per my understanding if we have not defined the value in dictionary then we will get the None. But am getting none even though if the value is defined. Could anyone explain to me the below scenario?

And the out put is:

Enter the phone number12343
['1', '2', '3', '4', '3']

And I will get it worked when I put the keys of dictionaries inside the quotes as below:

So, is it mandatory to use quotes for keys?
1 week ago
Ok Thank you So much Stephan.

I will make changes without SSL with a change in LDAP to ldaps in the URL.
1 week ago

Instead of requesting the use of SSL via the use of the Context.SECURITY_PROTOCOL property, you can also request the use of SSL via the use of LDAPS URLs.

I think this statement leaves little open to interpretation.

Thank you so much Stephan.

So now for LDAPS we should use SSL for both ways..... Either it might be  Context.SECURITY_PROTOCOL  or For URL change.. SSL certificate is mandatory ...Correct me if am wrong.. Am little confused..

And if I have to use SSL certificates could you please give me an Idea how can I do it...As I am new to this topic I have been reading some articles but still I am not sure How to do it...

1 week ago

Could anyone help on how to switch from LDAP to LDAPS.
I read this Article :

What I got is either we can add below piece of code and use certificate

OR we can make the changes in LDAP URL That is ldap to ldaps

as mentioned below:

And could anyone say me that will we use SSL for LDAP also..? OR we will use ssl certificates inly for SECURE LDAPS connection.

Is it enough if I change in the URL?
1 week ago
Hi Can anyone help me to print the below pattern.


I am able to print the half diagonal using the below logic;

And being able to get the below output:

3 weeks ago

Tim Holloway wrote:Python was not originally designed as an object-oriented language, and like other retro-fit OOP implementations, it has warts.

In Python's case, since a function is essentially procedure-oriented, there's no "self" or "this" keyword implicit in the language and thus when you declare a class member method, you have to explicitly define a variable (conventionally named "self") to hold the instance reference.

On the other hand, the Python compiler does have enough OOP-awareness to know that if you code a "x.y(a, b, c)" function call, then the "x" part should be passed as the "self" parameter and and the "a, b, c" valies are then appended to the parameter list.

Thanks Tim. Still, I have doubts like when to use self or more precisely I can ask as when to use Static methods , instance methods and class methods.

Basically I am aware of static methods. But why do we have class methods again
3 weeks ago

Stephan van Hulst wrote:Yes. On Windows you can use PowerShell. I think you could use the following command, but I haven't tried it out myself:

Obviously, you need to replace the value of the -DnsName parameter.
Also take a look at these links:

  • How to enable LDAP over SSL with a third-party certification authority
  • New-SelfSignedCertificate
  • Generating self-signed certificates on Windows

  • Thank you so much, Stephan.I will go through all the links you have provided and if any doubts I will post it.
    3 weeks ago
    Hi All,

    After googling  I got to know that I should call it:

    Instead of :

    And I got the expected result. But as per my understanding, we need not pass the self argument while calling the method.

    Can anyone help me on this?
    3 weeks ago
    Hi All,

    I am aware that we will use the super() method in the below scenario:

    To access a member of the base class from within its derived class, in the case when this base class member has the same name as a member of its derived class, we can use the super() function with the dot operator.

    And we can use the super method in two ways:
    1. In Python 3 and above, the syntax for super is:


    2.(in older builds of Python):

    super(subClass, instance).method(args)

    Now I am writing the below code and it is working fine for me. But I guess we can also access the superclass members using a fully qualified name.

    Output is:
    From Method A

    But When I use fully qualified name as follows I am facing the error:


    3 weeks ago

    Stephan van Hulst wrote:You can get a certificate from any CA. You can even create a certificate yourself, although you must only use such a certificate for development purposes, not for a live domain controller.

    For a production environment, what CA to use kinda depends on who will be accessing the domain controller. For instance, if you only want to use LDAPS within a company intranet, you can setup a CA for your own company, and add its root certificate to the trusted certificates of all systems within your company intranet. Then you request a certificate from your own CA as outlined here. Install the certificate in the domain controller's personal certificate store. Active Directory will now use this certificate to identify itself when accessing it through LDAPS. Systems in your intranet will authenticate the domain controller's identity by verifying that its certificate was issued by your company's CA, which they trust.

    If you need more help, you need to give us details like what kind of applications will be using LDAP, whether the domain controller will only be accessible in the intranet, and if so, why you want to secure it.

    Thanks, Stephan.

    I want your help in generating the certificate in a test environment.
    I am aware that we can generate it using OpenSSL command...But I don't have knowledge like how can I create using OpenSSL I mean what is the procedure...
    Do we require any tool or App to be installed in our system to generate the SSL certificate?

    Thanks for your help...
    3 weeks ago

    am new to LDAP / Active Directory environment.

    am trying to connect with LDAP / Active Directory using SSL support.

    to connect LDAP/Active Directory, SSL certificate is required to establish the connection.

    I have been googling, and most of the result is to "create a certificate using Microsoft CA (certificate authority)". Is this is the only way to generate a certificate for LDAP/Active Directory?

    How can i get SSL Certificate for LDAP / Active Directory? Is there any other way to get the SSL Certificate for LDAP/Active Directory?
    1 month ago

    Junilu Lacar wrote:Not quite there. You can use either, actually. It's not about + for String and , for numbers. These work, too:

    The difference really is that , adds a space. Look at the output of these two print statements carefully:

    Thanks Junilu.....

    Now After trying out what you have suggested ...My observation is:

    Placing Comma is mandatory to print Number Datatype
    And for String Reading, I should not use a comma.

    Here are my workarounds.

    And I got the expected output..But After using the Comma with Strings like

    I am facing this error..

    Traceback (most recent call last):
     File "", line 10, in <module>
       print("My name is" ,+a)
    TypeError: bad operand type for unary +: 'str'

    For Integers, I couldn't  execute the below code

    And error am facing is

    Traceback (most recent call last):
     File "", line 10, in <module>
       print("My Value is" + x)
    TypeError: Can't convert 'int' object to str implicitly

    1 month ago
    Hi There,

    I am getting confused that when to use "+" (Concatenation operator) and When to use COMMA(,) in print() method...

    As of now, I learnt that to print the value of the number we should use Comma...As shown below

    And for Strings, we have to use Concatenation Operator. As I did Below...It is working perfectly I just wanted to know whether my understanding is correct or not.
    1 month ago

    Joe Ess wrote:Input from the console is a String.  You need to cast those values to int to use them as numbers.

    Thanks Joe...

    You mean to say input() by default considers the given input as String?
    1 month ago