<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python class initialization - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/python-class-initialization/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/python-class-initialization/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Thu, 09 Sep 2021 11:27:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>python class initialization - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/python-class-initialization/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What is init function in Python ?</title>
		<link>https://www.wikitechy.com/interview-questions/python/what-is-init-function-in-python/</link>
					<comments>https://www.wikitechy.com/interview-questions/python/what-is-init-function-in-python/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Sun, 18 Jul 2021 14:00:00 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[__init__ python 3python init main]]></category>
		<category><![CDATA[__init__.py python]]></category>
		<category><![CDATA[__init__.py python 3]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[def __init__(self)]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[L&T Infotech interview questions and answers]]></category>
		<category><![CDATA[Mavenir interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[Prokarma Softech Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[python class definition]]></category>
		<category><![CDATA[python class definition example]]></category>
		<category><![CDATA[python class init]]></category>
		<category><![CDATA[python class init function]]></category>
		<category><![CDATA[python class init method]]></category>
		<category><![CDATA[python class init super]]></category>
		<category><![CDATA[python class initialization]]></category>
		<category><![CDATA[python class without __init__]]></category>
		<category><![CDATA[python data science interview questions]]></category>
		<category><![CDATA[python do classes need init]]></category>
		<category><![CDATA[python init not called]]></category>
		<category><![CDATA[python interview questions and answers for testers]]></category>
		<category><![CDATA[python programming questions]]></category>
		<category><![CDATA[python telephonic interview questions]]></category>
		<category><![CDATA[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Virtusa Consulting Services Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Wells Fargo interview questions and answers]]></category>
		<category><![CDATA[what is python class init ?]]></category>
		<category><![CDATA[Xoriant Soluti interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=856</guid>

					<description><![CDATA[Answer : In Python, __init__() method within a class is its constructor...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="python-init" class="color-purple" style="text-align: justify;">Python init():</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>In Python, __init__() method within a class is its constructor.Any method or variable that starts with double underscore is by default private.</li>
<li>Python defines several standard private methods that have a special meaning, and __init__() is one of them. Some others are __str__(), __repr__(), __add__() and others.</li>
</ul>
</div>
</div>
<h2 id="what-does-def-init-do-in-python" class="color-purple" style="text-align: justify;">What does def init do in Python ?</h2>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>The __init__ function is known as a constructor, or initializer, and is automatically called when you create a new instance of a class. Within that function, the recently created object is assigned to the parameter “self”. The notation self.legs is an attribute called legs of the object in the variable self.</li>
</ul>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="sample-code">Sample Code:</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">class my_class(object):<br/>  def __init(self, x, y):<br/>    self.x = x<br/>    self.y = y<br/>def f2(self):<br/>    return self.x + self.y<br/> a = my_class(10, 20)<br/>print a.f2()</code></pre> </div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="output">Output :</h2>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="python hljs" data-lang="python"><span class="nt">30 
</span></code></pre>
</figure>
</div>
</div>
<p style="text-align: justify;">In the constructor __init__() and method f2(), a initial parameter self is a reference to a object that will later invoke methods at run time. Actually leaving out self parameter in the definition makes it not possible to call it on behalf of the object.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/python/what-is-init-function-in-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
