Hello,
I've this code:
print "Login1:", login
login.replace(" @","_")
print "Login2:", login
Which produces this output:
Login1: tester@root
Login2: tester@root
Why is Login2 still tester@root and not tester_root? I thought that I've
replaced the @ with _??
Thx,
Florian 2 1213
Florian Lindner wrote: Hello, I've this code:
print "Login1:", login login.replace(" @","_") print "Login2:", login
Which produces this output:
Login1: tester@root Login2: tester@root
Why is Login2 still tester@root and not tester_root? I thought that I've replaced the @ with _??
Trying it at the command line might be instructive: login = 'tester@root' print "Login1:", login
Login1: tester@root login.replace(" @", "_")
'tester_root' login
'tester@root'
Strings are immutable. The call to replace() does not modify
the original string, but returns a new one. You'll see similar
behaviour with other string methods (or any methods on immutables).
-Peter
Florian Lindner wrote: Hello, I've this code:
print "Login1:", login login.replace(" @","_") print "Login2:", login
Which produces this output:
Login1: tester@root Login2: tester@root
Why is Login2 still tester@root and not tester_root? I thought that I've replaced the @ with _??
Thx, Florian
Florian, x = "tester@roo t" y = x.replace("@"," _") print y
tester_root This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Pether (john |
last post by:
have been working with a site and today started getting an error when uploaded page on the live server...everything works well locally...
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
...
|
by: yilled_fred |
last post by:
Hi can anyone tell me why the following code cannot/doesn't compile?
I get the following error while compiling (g++ -c ):
"In member function `void derivedclass<S>::foo()':
test.h:20 error: parse error before `;' token
Here is the code, am I missing something?
#include <stdio.h>
#include <stdlib.h>
|
by: Razzbar |
last post by:
I'm using a div as a floating dialog box. I'd rather use a popup
window, but due to all the popup blockers in use, I have to use
another method, a div that has absolute positioning.
The damn thing won't get in front of dropdown listboxes! I
check the currentstyle.zindex of the listoxes, and they're
set at 0. I set the div.style.zindex to...
|
by: Markus Fischer |
last post by:
Hi,
I'm experiencing a wierd problem with IE 6 in Windows with two
_slightly_ different Version.
Give the following HTMl-Code, ideally the output of offsetTop should be
"105"; a few pixel plus minus would still be ok, whyever.
I've tested this successfully on 6.0.2800.1106 on a german W2KPro
machine, also with 6.0.2800.1106 on a german...
|
by: Tom |
last post by:
OK, here's a wierd one... I have a listbox, which I fill with strings (in my
case, file names). I normally load this via a loop, adding each item to the
list box in the loop. I put lb.BeginUpdate before the start of the loop, and
lb.EndUpdate at the conclusion of the loop.
Here's the wierd part: If there is only ONE line loaded into the list...
| |
by: Tom |
last post by:
We are experiencing some wierd debugging behavior. What happens is
that, during debugging with VS 2003, the debugger seems to 'skip'
statements that are associated with database operations. For instance,
I can be single-stepping through a VB.NET program, and once I hit a DB
related statement (such as setting command parameters, executing a...
|
by: ApexData |
last post by:
I know that somethimes when I make changes to the tables (like adding
new fields), these changes do not always appear in the field list. If
I remove the table name from the forms record source, run my code, and
then replace the table name in the forms record source it finally
appears. I found this soultion in the news group.
This time, I...
|
by: desktop |
last post by:
I am confused about the use of the template parameter "E" in the below
class. Since when is it allowed to use these parameters like "E(1)" and
what does it mean (where can I read more about this kind of use)?
template <typename E>
class Mytest {
public:
Mytest(int n) {
s = E(0);
|
by: chromis |
last post by:
Hi,
I've created a utf8 encoded RSS feed which presents news data drawn from a database. I've set all aspects of my database to utf8 and also saved the text which i have put into the database as utf8 by pasting it into notepad and saving as utf8. So everything should be encoded in utf8 when the RSS feed is presented to the browser, however I am...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |