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

  • SEARCH
  • Home
  • 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 8152697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:47:22+00:00 2026-06-06T15:47:22+00:00

I’m using Python since some times and I am discovering the pythonic way to

  • 0

I’m using Python since some times and I am discovering the “pythonic” way to code.
I am using a lot of tuples in my code, most of them are polar or Cartesian positions.

I found myself writing this :

window.set_pos([18,8])

instead of this :

window.set_pos((18,8))

to get rid of the double parenthesis I found hard to read.

It seems that python is automatically doing the type conversion from list to tuple, as my code works properly.

But is it a good way to code ?
Do you have any presentation tip I could use to write readable code ?

Thank you in advance for your surely enlightening answers.

  • 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-06-06T15:47:24+00:00Added an answer on June 6, 2026 at 3:47 pm

    I’d be careful deciding to eschew tuples in favor of lists everywhere. Have you ever used the dis module? Watch what Python is doing at the bytecode level when you make a list verses making a tuple:

    >>> def f():
    ...     x = [1,2,3,4,5,6,7]
    ...     return x
    ... 
    >>> def g():
    ...     x = (1,2,3,4,5,6,7)
    ...     return x
    ... 
    >>> import dis
    >>> dis.dis(f)
      2           0 LOAD_CONST               1 (1)
                  3 LOAD_CONST               2 (2)
                  6 LOAD_CONST               3 (3)
                  9 LOAD_CONST               4 (4)
                 12 LOAD_CONST               5 (5)
                 15 LOAD_CONST               6 (6)
                 18 LOAD_CONST               7 (7)
                 21 BUILD_LIST               7
                 24 STORE_FAST               0 (x)
    
      3          27 LOAD_FAST                0 (x)
                 30 RETURN_VALUE     
    >>>
    >>>   
    >>> dis.dis(g)
      2           0 LOAD_CONST               8 ((1, 2, 3, 4, 5, 6, 7))
                  3 STORE_FAST               0 (x)
    
      3           6 LOAD_FAST                0 (x)
                  9 RETURN_VALUE   
    

    Though it will probably never be an issue in a GUI application (as your example seems to be), for performance reasons you may want to be careful about doing it everywhere in your code.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

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.