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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:34:04+00:00 2026-06-14T14:34:04+00:00

I am just coming cross the following python code which confuses me a bit:

  • 0

I am just coming cross the following python code which confuses me a bit:

 res = self.result[::-1].encode('hex')

The encode stuff is pretty clear, it should be represented as hex value. However, what
does this self.result[::-1] mean, especially the colons?

  • 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-14T14:34:06+00:00Added an answer on June 14, 2026 at 2:34 pm

    It represents the ‘slice’ to take from the result. The first element is the starting position, the second is the end (non-inclusive) and the third is the step. An empty value before/after a colon indicates you are either starting from the beginning (s[:3]) or extending to the end (s[3:]). You can include actual numbers here as well, but leaving them out when possible is more idiomatic.

    For instance:

    In [1]: s = 'abcdefg'
    

    Return the slice of the string that starts at the beginning and stops at index position 2:

    In [2]: s[:3]
    Out[2]: 'abc'
    

    Return the slice of the string that starts at the third index position and extends to the end:

    In [3]: s[3:]
    Out[3]: 'defg'
    

    Return the slice of the string that starts at the end and steps backward one element at a time:

    In [4]: s[::-1]
    Out[4]: 'gfedcba'
    

    Return the slice of the string that contains every other element:

    In [5]: s[::2]
    Out[5]: 'aceg'
    

    They can all be used in combination with each other as well. Here, we return the slice that returns every other element starting at index position 6 and going to index position 2 (note that s[:2:-2] would be more idiomatic, but I picked a weird number of letters 🙂 ):

    In [6]: s[6:2:-2]
    Out[6]: 'ge'
    

    The step element determines the elements to return. In your example, the -1 indicates it will step backwards through the item, one element at a time.

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

Sidebar

Related Questions

I am just coming up to speed on WPF and would like to create
Just started coding in AS3 with FlashDevelop and coming from a C# background, I
I just started learning C++ (coming from Java ) and am having some serious
I am coming from Flex where you can do just about anything inside of
Coming from svn, just starting to become familiar with git. When a branch is
Trying to create a facebook app just to learn and coming across a strange
I'm just learning c++, and coming from c, some function calls I'm seeing in
So, I was just coding a bit today, and I realized that I don't
Firstly, I'm not against Opera. It just seems when I encounter cross browser issues,
The most recent release of the GAE states the following changes: Datastore Cross Group

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.