473,382 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

It is fun.the result of str.lower(str())

Guess what would be the result of these functions:
str.lower('ASFA')
str.join(str(),['1','1','1'])
str.join('a','b')


If you guess them correctly, please explain.

Mar 7 '06 #1
5 1169
"Sullivan WxPyQtKinter" wrote:
Guess what would be the result of these functions:
str.lower('ASFA')
str.join(str(),['1','1','1'])
str.join('a','b')


If you guess them correctly, please explain.


as I just said, I.method() and C.method(I) are equivalent,
so that's just an odd way to write

'ASFA'.lower()
str().join(['1', '1', '1'])
'a'.join('b')

which, given that str() returns an empty string, and a string
behaves like a sequence of individual characters, is equivalent
to

'ASFA'.lower() => 'asfa'
''.join(['1', '1', '1']) => '111'
'a'.join(['b']) => 'b'

</F>

Mar 7 '06 #2
Sullivan WxPyQtKinter wrote:
Guess what would be the result of these functions:
str.lower('ASFA')
str.join(str(),['1','1','1'])
str.join('a','b')


If you guess them correctly, please explain.


I think it was because I've read the manuals.
Mar 7 '06 #3
Sullivan WxPyQtKinter wrote:
Guess what would be the result of these functions:
s/functions/method calls/
str.lower('ASFA')
=> 'ASFA'.lower() => 'asfa'
str.join(str(),['1','1','1'])
=> ''.join(['1','1','1']) => '111'
str.join('a','b')

=> 'a'.join('b') => 'b'

If you guess them correctly,
No need to guess, there's this thing named the python interactive shell,
you know... And it even has an integrated help system.
please explain.


Explain what ? It's all in the fine manual.

* Klass() is a call to Klass's constructor and returns an instance of Klass.

* Klass.method(klass_instance) is the same as klass_instance.method()
* str is the builtin string class.
* without any args, the str constructor returns an empty string
* str.join() takes a sequence of strings and join'em with the target str
instance as separator

Now would you be kind enough to explain what's funny about all this ?

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Mar 7 '06 #4
On Tue, 07 Mar 2006 10:23:59 +0100, rumours say that bruno at modulix
<on***@xiludom.gro> might have written:

<snip various python expressions>
Now would you be kind enough to explain what's funny about all this ?


I would guess it's the statement: "Funny, it works!"
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Mar 7 '06 #5
"Sullivan WxPyQtKinter" <su***********@gmail.com> wrote:

Guess what would be the result of these functions:
str.lower('ASFA')
str.join(str(),['1','1','1'])
str.join('a','b')


If you guess them correctly, please explain.


Can you tell us what you expected these to do? It might help future
questioners.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Mar 9 '06 #6

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

Similar topics

6
by: jerrygarciuh | last post by:
Hi all, I am iterating through a result set to generate a second set of queries but no matter what I do I get the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...
2
by: maceo | last post by:
I have a script that will print out the results of a table and make a calculation of a total of one of the columns. See example: <?php /* Database connection */...
4
by: John Davis | last post by:
<html> <body> <Form action="calc.asp" method="post" name="calc"> <P>NUM1: <input type="text" name="num1"> <P>NUM2: <input type="text" name="num2"> <P>RESULT: <input type="text" name="result">...
2
by: swhite76 | last post by:
I have a section of code that adds some double values and gives an incorrect result. This occurs with data that isn't really waht I would call high precision. An example is the following code...
4
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I am quite confused on a equation, as following: #include <iostream> int main(){ int i = 2;
3
by: Michael C# | last post by:
Hi all, I'm sending a command via SqlClient, and it returns two result sets. I can successfully read the first result set, but how can I access the second result set? Here's an example of my...
12
by: Mick_fae_Glesga | last post by:
OK, the solution to this is probably blindingly obvious to everyone, but... surely it can't be right. I am compiling with borland bcc32 free compiler this piece of code is designed to identify...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
5
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done...
9
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.