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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:58:16+00:00 2026-06-16T22:58:16+00:00

Okay, so I made this little function that allows me to make a string

  • 0

Okay, so I made this little function that allows me to make a string into multiplier of 32 characters, but when I use String .replace I get some really, really weird bug. Since its making me pull my hair, can you guys take a look and see what I’m missing.

Variables:
        self.blockSize = 32
        self.interrupt = '$^EnD#Block^$'
        self.filler = '#'

Functions:
    def pad(self, data):
        joint1 = ''.join([data, self.interrupt])
        joint2 = self.filler * ((self.blockSize - len(joint1)) % self.blockSize) 
        return ''.join([joint1, joint2])

    def unpad(self, data):
        data = str(data).rstrip(self.interrupt)
        return data.replace(self.filler, '')

Call:
p = e.pad('this is not a very good idea  yo')
print(p)
print(e.unpad(p))


Output:
    Jans-MacBook-Pro:test2 jan$ ../../bin/python3 data.py 
    this is not a very good idea  yo123$^EnD#Block^$################
    this is not a very good idea  yo123
    Jans-MacBook-Pro:test2 jan$ ../../bin/python3 data.py 
    this is not a very good idea  yo$^EnD#Block^$###################
    this is not a very good idea  y
    Jans-MacBook-Pro:test2 jan$ 

It makes o in yo disappear. Ahhhh! But nothing disappears if I add some random numbers after.

SOLUTION – EDIT: My bad. I have misplaced self.filler and self.interrupt. I am so embarrassed now. The code should have been:

def unpad(self, data):
    data = str(data).rstrip(self.filler)
    return data.replace(self.interrupt, '')
  • 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-16T22:58:17+00:00Added an answer on June 16, 2026 at 10:58 pm

    Read the documentation for rstrip:

    The chars argument is a string specifying the set of characters to be removed.

    rstrip removes all trailing characters present in the passed set of characters. It doesn’t remove a trailing substring consisting of those characters in that order. 'abczyx'.rstrip('xyz') gives 'abc', and 'abczyx'.rstrip('zyx') also gives 'abc'.

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

Sidebar

Related Questions

Okay, this is pretty weird. I made an app that listens for changes inside
Okay, I kinda asked this question already, but noticed that i might have not
Okay, this has made me feel a little peevish because it seems like it
Okay, I feel a bit foolish for having to ask this but I guess
Okay, this is probably a very basic question; but, I'm just getting back in
Okay this is going to seem really dumb but bear with me please. A
Okay, I have heard about it but I can confirm now that the Javascript
Okay, so I built a database that allows me to keep track of calls
I finished my little project that does some heavy lifting. i realized in this
Okay, I made a database and i realised that each time i change something

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.