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 4612892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:28:05+00:00 2026-05-22T01:28:05+00:00

I’m a novice programmer with basic Java experience, and currently learning Python. I’ve stumbled

  • 0

I’m a novice programmer with basic Java experience, and currently learning Python.
I’ve stumbled across this blog post in another question thread:

http://dirtsimple.org/2004/12/python-is-not-java.html

and I’ve got a couple of questions regarding the topic posted:


1) “Oh, and all those Foo.Bar.Baz attribute chains don’t come for free, … , so each dot counts. “

Is the solution to this particular problem is importing module and its method beforehand? Such as:

       from Foo.Bar import Baz
       ...
       #now Baz() can be called directly without using Foo.Bar.Baz() everytime

2) Got a switch statement? The Python translation is a hash table, not a bunch of if-then statments.

There are several related answers regarding this topic, but they also raise a couple of questions:

  1. Use of if-else is cleaner, but it doesn’t have the advantage of constant time O(1) in switch statement.
  2. Use of hash for constant time O(1)
  3. Use of lambda function in hash for comparison (not recommended)
    • Why is it not recommended? Is it because the lambda function removes the constant factor of hash?
  4. Use of bisect module
    • Does this method retain the constant time O(1), or it is just another type of lambda function?
    • So what method in Python, that is equal to switch statement, with constant time O(1), while at the same time allowing comparison statement?

3) Getters and setters are evil. Evil, evil…don’t write getters and setters … This is what the ‘property’ built-in is for … In Python, this (getter and setter) is silly, because you can start with a normal attribute and change your mind at any time, without affecting any clients of the class.

I don’t really quite understand this part.

Also, it seems that in Python public and private method or variable can be easily accessed, in contrast of that in C++ and Java. Is there any design reason for this behavior?


Finally, is there any recommended further good read on Python vs. any other programming language?

  • 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-22T01:28:05+00:00Added an answer on May 22, 2026 at 1:28 am
    1. It rarely matters. If it does, you’d be better off writing C (or letting Cython do that for you, with static type annotations to make it really count), using PyPy (their JIT can completely remove such lookups and many more things, even memory allocations, in certain loops), etc.
    2. “lambda” is in a different category than “if-elif chain” or “bisect”. What technique are you referring to specifically? Many dislike lambda as they consider it relatively verbose or unreadable (at least some of its uses can become this quickly). bisect is just maitaining an ordered list, so the best lookup you get is O(log N) binary search. You want a switch statement? Use dicts. Comparisions (apart from ==, of course) are outside the scope of switch and most things commonly compared to them and make O(1) lookup impossible anyway.
    3. What about it isn’t understandable? When you write Python, you don’t write getter or setter methods. You use normal attributes. If you later see that you need some further logic upon attribute access/modification, you turn it into a property and all code using it can run on without changes.
    4. As for the absence of real privacy – this has been asked and answered many times, the short answer is that “we’re all adults in here”, i.e. programmers are trusted not to fiddle with private things unless they have a very good reason. Another, weaker reason is that this is hard to implement in a dynamic language, at least with the current object model (where methods are just normal functions, for instance).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.