473,473 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

mutable string?

Hi,

is there some string class that i can change in place,
like perls strings?

Is it possible to do some regex replacement functions
that would even change its length?

Can i append to this string?

Is there some wrapper for C++ STL string class (if that
would make sense)?
Thanks,
Torsten.

Jul 18 '05 #1
2 2832
Torsten Mohr wrote:
is there some string class that i can change in place,
like perls strings?
array.array is mutable. You can use the 'c' code if
you want an array of characters.
Is it possible to do some regex replacement functions
that would even change its length?
You can't use re.sub array, but you can use re.search,
and you can perform slice assigment.
Can i append to this string?
Yes.
Is there some wrapper for C++ STL string class (if that
would make sense)?


It would be possible, but I cannot see why one would want
to do that.

Regards,
Martin
Jul 18 '05 #2
"Torsten Mohr" <tm***@s.netic.de> wrote in message
news:cs**********@schleim.qwe.de...
Hi,

is there some string class that i can change in place,
like perls strings?

Is it possible to do some regex replacement functions
that would even change its length?

Can i append to this string?

Is there some wrapper for C++ STL string class (if that
would make sense)?
A mutable string class would be fairly useful; as Martin
says in his post, you can use the array.array class, but
that doesn't have all of the useful string methods.

It might not be as useful as one would think at first
glance, however. The only operation that's fast on
the typical array implementation is replacement of
same size substrings; anything that involves a size
change requires either moving lots of characters
around, reallocating memory or both. For most
applications, the workarounds involving lists of
small strings would probably be faster.

Writing it and getting it accepted into the core
would be a major project, and so far the idea doesn't
seem to have attracted anyone who wants to do that
much work. The process starts with writing a PEP
so it can be discussed.

John Roth

Thanks,
Torsten.


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Gordon Airport | last post by:
Has anyone suggested introducing a mutable string type (yes, of course) and distinguishing them from standard strings by the quote type - single or double? As far as I know ' and " are currently...
3
by: Thomas Matthews | last post by:
Hi, I understand that a member function can be declared as const {meaning it doesn't alter the member variables), but can it be declared as mutable? I have class that stores its members into...
12
by: Kjetil Kristoffer Solberg | last post by:
What is a mutable struct? regards Kjetil Kristoffer Solberg
12
by: Water Cooler v2 | last post by:
Are JavaScript strings mutable? How're they implemented - 1. char arrays 2. linked lists of char arrays 3. another data structure I see that the + operator is overloaded for the string class...
12
by: Vincent RICHOMME | last post by:
Hi, I am currently implementing some basic classes from .NET into modern C++. And I would like to know if someone would know a non mutable string class.
3
by: Sambo | last post by:
By accident I assigned int to a class member 'count' which was initialized to (empty) string and had no error till I tried to use it as string, obviously. Why was there no error on assignment( near...
122
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was...
2
by: Simon Woods | last post by:
Hi I wonder if someone could explain the above to me. The examples I've seen seem to indicate that it is effectively a read-only class, but I'm sure that's being over simplistic. But what is the...
2
by: subramanian100in | last post by:
I am reading David Musser's "STL Tutorial and Reference Guide" Second Edition. In that book, on pages 68-69, definition has been given that "an iterator can be mutable or constant depending on...
24
by: Steven D'Aprano | last post by:
Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.