Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3798502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:34:58+00:00 2026-05-19T13:34:58+00:00

I recently started using Python 2.6 for Ubuntu Server admin and have two minor

  • 0

I recently started using Python 2.6 for Ubuntu Server admin and have two minor issues concerning redundancy:

First thing are imports: They all look something like

import Class from Class

from class import Class

And the second thing are __init__ methods:

__init__(self,arg1,...,argn):
    self.arg1 = arg1
    ...
    self.argn = argn

Are there ways to avoid these duplications?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:34:59+00:00Added an answer on May 19, 2026 at 1:34 pm

    The second thing is not redundancy – it is setting instance attributes. You can do it also like this:

    class Foo:
    
       def __init__(self, **kwargs):
           for name, value in kwargs.items():
              setattr(self, name, value)
    

    But then you need to call Foo like this:

       Foo(arg1=1, arg2=2, arg3=3)
    

    Also your import seems to have improper syntax. It should be from Class import Class. This looks redundant to you, because it seems, that you are storing each class in a separate file (module) – and that is exactly redundant. Python is not Java, you should usually hold more objects in one module. Keep in mind, that module itself is an object. Also you should name modules properly – the default code style guide says that modules should be all lowercase with no special chars. Like re or urllib for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using Python for web development recently, it's kinda cool; I have
I have recently started using Vim as my text editor and am currently working
I have recently started learning Python and I have 2 questions relating to modules.
I've recently started using git, and also begun unit testing (using Python's unittest module).
I've recently been learning python and I just started playing with networking using python's
I started using Pyant recenently to do various build/release tasks but have recently discovered
I recently started using Mercurial and like the way I have VCS protection for
I have recently started using the -Wall compiler switch in an attempt to improve
I have recently started using the MVVM-Light toolkit and I am stuck on the
I recently started using Eclipse at work for my Java servlet projects. I've been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.