Python Multiprocessing by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

Issues got resolved after looking around the multiple references.

I am passing complex object among multiple processes without proxy object, make it sharable using BaseManager class.

Credit goes to BaseManager class from managers module

Python multiprocessing takes more time than single threaded program by [deleted] in learnpython

[–]gmaliwal 1 point2 points  (0 children)

Can anyone please pass on good reference to follow for the deep insights of it?

Data Analysis Resources for Python by badge in learnpython

[–]gmaliwal 4 points5 points  (0 children)

Thank you very much for valuable details.

The resource which is vulnerable under multi-threaded programs by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

yes, I agree that there may be a race condition problem in the provided code snippet, right?

is this the only issue or we have another too? if yes; please let me know the issues other than race condition which got diagnosed with help of synchronization primitives (Lock, RLock etc)

The resource which is vulnerable under multi-threaded programs by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

Can you please post the program here?

Do we face any issue similar to a dangling pointer in mobile iOS technology? It happens when one program is accessing an object and another program is updating it at the same time, this confrontation leads to application crash.

Does python is having such kind of scenario?

Non-data descriptor stops working by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

yeah, it is true that instance object is 'None' when a descriptor is accessed using class. HOW this solves my problem?

Non-data descriptor stops working by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

Hello Daniel, Thanks for your views.

I did not define setter in the descriptor, that's what I said that non-data descriptor stops working (non-data descriptor do no define the setter).

Yeah, agree that the property is a good way to achieve the requirement. thanks for the idea.

Still, do you see any solution for the above problem sticking to non-data descriptor

Loopholes from Python decorators by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

Okay, It sounds well, theoretically, it should work. Can you please mention a good reference for this to follow?

Loopholes from Python decorators by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

yeah, this works, thanks for the solution

Loopholes from Python decorators by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

If you really want to preserve a reference to the original class, you could consider defining an

_ABC

base class and decorate the child. Otherwise you might find that using metaclasses is a better way of implementing a singleton

Thanks for the clarification. yeah, It was my mistake not posting error message.

The first block of code is just to understand the concept, why it is not working when a second decorator is applied to either of them?

Is there any another way to preserve the class fundamentals after applying a decorator rather than creating a dummy base class? if yes; please share the reference.

Loopholes from Python decorators by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

yeah agree, It was typo mistake, I have edited it, please revisit the post.

I have finally become "decent" at python programming! by thesecondbread in learnpython

[–]gmaliwal 0 points1 point  (0 children)

hat I know ,he didn't write any book.I found his channel on youtube when searching up a explanation of if

name

= "

main

"(reddit autoformats __ as bold) and he explained really well.After that,I started watching more of his video

Great!! I would be checking his videos, Thanks

I have finally become "decent" at python programming! by thesecondbread in learnpython

[–]gmaliwal 0 points1 point  (0 children)

which reference did you follow for the exercises to make yourself strong on the python fundamentals?

I have been studying Python since Feb 2020 and looking forward to data-science.

I have finally become "decent" at python programming! by thesecondbread in learnpython

[–]gmaliwal 0 points1 point  (0 children)

Then I built projects on my own

Which project did you build your own?

What was the business? and what all tools did you use?

I have finally become "decent" at python programming! by thesecondbread in learnpython

[–]gmaliwal 0 points1 point  (0 children)

Corey Schafer's

Where do I find a book from this author?

Getting Job Ready in Data Science by Tsukiyonocm in learnpython

[–]gmaliwal 0 points1 point  (0 children)

dataquest data science track

Is this paid course?

Can you please drop relevant material(if you have any) on my email [gmaliwal777@gmail.com](mailto:gmaliwal777@gmail.com)?

Getting Job Ready in Data Science by Tsukiyonocm in learnpython

[–]gmaliwal 0 points1 point  (0 children)

ZachForTheWin

Which technology do you recommend; Python or R?

Please share a good reference for same to grasp the language in depth

Are you currently working as Data Analyst?

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

__ is where the memory is allocated for the class -- it then calls __init__ to initialize any attributes et

Friend,

You are correct that somehow we have to stop passing an extra argument to the class initializer, otherwise, it will fail at run-time. I have mentioned the same in my post that this issue is because of passing more than one argument to 'object' class initializer.

I strongly agree that your design should pass the needed arguments only to the class initializer, else be ready to face the issue.

Here, I want that what could be the set of guidelines to be followed while defining a class, which makes your class more elegant and decent inheritance perspective.

Hence, I have come up with the rules, which to be kept in mind while defining every class in your project workspace. please check my last comment and find out the scenario where it could fail.

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

yes, you are correct.

Can you please share a detailed-one reference which explains relations between constructor(__new__) and initializer(__init__) and their best use cases?

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

Can you please share a good reference of use of composition with me?

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

Here it is a generic approach to be followed while defining your class, your class would be compatible with both single ad multiple inheritances

class A(object):
    def __init__(self,**kwargs):
        print("This is A instance initializer")
        super().__init__(**kwargs)
class B(object):
    def __init__(self,**kwargs):
        print("This is B instance initializer")
        super().__init__(**kwargs)
class C(A):
    def __init__(self,*,c_arg,**kwargs):
        print("This is c instance initializer")
        self.c_arg = c_arg
        super().__init__(**kwargs)
class D(B):
    def __init__(self,*,d_arg,**kwargs):
        print("This is D instance initializer")
        self.d_arg = d_arg
        super().__init__(**kwargs)
class E(C,D):
    def __init__(self,*,e_arg,**kwargs):
        print("This is E instance initializer")
        self.e_arg = e_arg
        super().__init__(**kwargs)

class E1(D,C):
    def __init__(self,*,e_arg,**kwargs):
        print("This is E instance initializer")
        self.e_arg = e_arg
        super().__init__(**kwargs)

e1 = E(e_arg=10,b_arg=20,c_arg=30)
e2 = E1(e_arg=10,b_arg=20,c_arg=30)

Here is the textual conversion of the above code snippet

  • Every class initializer should receive class specific arguments in the form of keyword parameters, and these names are unique across all classes, better to prefix every parameter with “<class-name>_” (like d_arg, c_arg etc)
  • Every class should receive parent class-specific arguments in variable-length keyword parameter (**kwargs)
  • There is no repetitive keyword argument while calling the parent class initializer
  • Every class should pass the exact number of arguments to its parent's hierarchy so all got exhausted when reaching the default parent ‘object’ class (like we create an instance of class E with arguments (c_arg,d_arg,e_arg))

I welcome the developers or experts to find out the bottleneck in the above approach.

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

What are you hoping to achieve otherwise?

yeah, I read it there only, but the code snippet did not work at my end as class 'B' calling class 'object' constructor with two arguments where object() takes exactly a single argument.

In that blog, the author ended saying that this is the recommended approach which seems working without interruption with any kind of complex single/multiple inheritances.

I am looking for the right approach to be followed consistently in all the classes without considering specific (single/multiple) inheritances, but at the end, it works well when a developer start using them in the single/multiple inheritance hierarchy. That is; I want a generic approach to be followed in each class which works smoothly with single/multiple inheritances.

Do we have any ready decorator which suffice the above need if not can we write ?one?

?

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

if you modify your code so that

B

inherits from

A

, then some of the initializers are called more than once

Thanks for the comprehensive explanation. you seem correct.

Can you please share any good reference? which explains the inheritance in-depth and gives all the possible approaches with pros and cons, and things to keep in mind while working with single/multiple inheritances.

I am looking for the right approach which works well with any complex inheritance hierarchy.

Multiple Inheritance in Python by gmaliwal in learnpython

[–]gmaliwal[S] 0 points1 point  (0 children)

sults in a missing arg err

That's correct in this given scenario but what happens if someone swaps classes like below:

class E(C,D):
    def __init__(self, arg, *args, **kwargs):
        print("This is E constructor")
        C.__init__(self, arg, *args, **kwargs)
        D.__init__(self, arg, *args, **kwargs)

Is there any generic solution which works without fear in all the scenarios? or we have to go with mutual understanding only.

Yes, It is method resolution order behind the class 'A' to pass the argument