473,705 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

interactive help on string functions - howto

Hi,

entering
help('rstrip')
or
help('ljust')

into IDLE's shell window I only get
no Python documentation found ...

Am I missing something?

Thanks for a hint,
Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #1
11 2883
Helmut Jarausch wrote:
Hi,

entering
help('rstrip')
or
help('ljust')

into IDLE's shell window I only get
no Python documentation found ...

Am I missing something?

Thanks for a hint,
Helmut.


Make sure you've imported string. Then you can do:
help(string.rst rip)

Help on function rstrip in module string:

rstrip(s, chars=None)
rstrip(s [,chars]) -> string

Return a copy of the string s with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Jeremy Jones
Jul 18 '05 #2
Jeremy Jones <zanesdad <at> bellsouth.net> writes:
Make sure you've imported string.


No need to import string, you can use the builtin str:
help(str.rstrip ) Help on method_descript or:

rstrip(...)
S.rstrip([chars]) -> string or unicode

Return a copy of the string S with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping
help(str.ljust)

Help on method_descript or:

ljust(...)
S.ljust(width[, fillchar]) -> string

Return S left justified in a string of length width. Padding is
done using the specified fill character (default is a space).
Steve

Jul 18 '05 #3
Helmut Jarausch wrote:
entering
help('rstrip')
or
help('ljust')

into IDLE's shell window I only get
no Python documentation found ...

Am I missing something?


You need to remove quotes from arguments, i.e.,
help(rstrip) # help('rstrip') is a no-no


I have to say this error message is really annoying. You can't
guess what went wrong from it.
George
Jul 18 '05 #4
George Yoshida <ml <at> dynkin.com> writes:

I have to say this error message is really annoying. You can't
guess what went wrong from it.


Yeah, maybe it would be clearer if it said something like "No Python
documentation found for module, keyword or topic 'rstrip'" That would make it
clearer that you can only use a string if the string is the name of a module,
keyword or a topic (not a function like the OP's example).

STeve

Jul 18 '05 #5
George Yoshida wrote:
Helmut Jarausch wrote:
entering
help('rstrip')
or
help('ljust')

into IDLE's shell window I only get
no Python documentation found ...

Am I missing something?

You need to remove quotes from arguments, i.e.,
help(rstrip) # help('rstrip') is a no-no

But note that help(rstrip) doesn't provide any useful help either:
help(rstrip) Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
NameError: name 'rstrip' is not defined


What's needed is help(str.rstrip ), which does indeed work. (As already
pointed out by other posters.)

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #6
Helmut Jarausch <ja******@skyne t.be> writes:
Hi,

entering
help('rstrip')
or
help('ljust')

into IDLE's shell window I only get
no Python documentation found ...

Am I missing something?


If you install the Python HTML pages in the correct place, it will
indeed work this way.

Or you press F1, and enter rstrip in the CHM search box (on Windows).

Thomas
Jul 18 '05 #7
Many thanks for the hint.

Still I wonder why I have to prefix it with 'str.'
I don't need to import str and I don't need to prefix rstrip
with 'str.' to USE it - why do I have to do so with HELP then?

Steven Bethard wrote:
Jeremy Jones <zanesdad <at> bellsouth.net> writes:
Make sure you've imported string.

No need to import string, you can use the builtin str:

help(str.rs trip)
Help on method_descript or:

rstrip(...)
S.rstrip([chars]) -> string or unicode

Return a copy of the string S with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping

help(str.lj ust)


Help on method_descript or:

ljust(...)
S.ljust(width[, fillchar]) -> string

Return S left justified in a string of length width. Padding is
done using the specified fill character (default is a space).

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #8
Many thanks for the hint.

Still I wonder why I have to prefix it with 'str.'
I don't need to import str and I don't need to prefix rstrip
with 'str.' to USE it - why do I have to do so with HELP then?

Steven Bethard wrote:
Jeremy Jones <zanesdad <at> bellsouth.net> writes:
Make sure you've imported string.

No need to import string, you can use the builtin str:

help(str.rs trip)
Help on method_descript or:

rstrip(...)
S.rstrip([chars]) -> string or unicode

Return a copy of the string S with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to unicode before stripping

help(str.lj ust)


Help on method_descript or:

ljust(...)
S.ljust(width[, fillchar]) -> string

Return S left justified in a string of length width. Padding is
done using the specified fill character (default is a space).

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #9
Helmut Jarausch wrote:
Many thanks for the hint.

Still I wonder why I have to prefix it with 'str.'
I don't need to import str and I don't need to prefix rstrip
with 'str.' to USE it - why do I have to do so with HELP then?

But you *do* prefix rstrip() with *a* str when you use it.

rstrip() is a string method. Strings are of type 'str'. So an
expression like

"my text".rstrip()

is exactly equivalent to

str.rstrip("my text")

as can easily be demonstrated.
str.rstrip('foo ! ') 'foo!' 'foo! '.rstrip() 'foo!'


Python doesn't know where rstrip() is unless you *tell* it that it's a
string method. When you're calling it, you're telling it that it's a
string method by calling it from an instance of type str. When passing
it to help(), you need to tell it that it's a string method by
prepending 'str.' to it.

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #10

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

Similar topics

22
2258
by: SeeBelow | last post by:
Is there any way, in C, of interacting with a running program, but still using code that is portable, at least between linux and Windows? By "interacting" it could be something as simple as detecting a key board hit so that it could invoke scanf(). So a portable key board data available routine would satisfy my minimum requirements. But more generally I want to know if one can write portable C code that allows a user to change the...
37
8533
by: Shri | last post by:
hi all, i am writing a code in which i have a char buffer "cwdir" which hold the current working directory by calling the function getcwd(). later i change the directory to "/" as i have to make my code Deamon. and later again i want to run some other executable available at the path holded by the "cwdir" using the system() system call. presently i concatenate program name (to be executed) to the "cwdir" and use system(chdir)to run the...
5
1567
by: sugaray | last post by:
Right now, the code I wrote below seems works fine, i know it's definitely not the best solution, so if there are better solutions to eschew from using goto statements to jump out of multiple loops ? and any other suggestions or good ideas that are pertain to construct a more powerful and common interactive menu system is also welcomed, and if there's any primitive but better interactive system that is written in C suitable for educational...
2
2008
by: WJ | last post by:
I have three ASPX pages: 1. "WebForm1.aspx" is interactive, responsible for calling a web site (https://www.payMe.com) with $$$. It is working fine. 2. "WebForm2.aspx" is non-interactive, a listener in my site to capture a "STATUS_CD" returned by www.payMe.com. It is working fine. 3. "WebForm3.aspx" is interactive page, responsibe to display the STATUS CODE "POSTED" by "WebForm2.aspx". 4. My goal is to use "WebForm2.aspx" to call...
3
1945
by: Coffee | last post by:
I have asked this before, but the offered solution did not work. I want to have a command button, that transfers any text from a textbox to a variable which is an array. so that i can print out single letters of the text. e.g. if i have "hello" in the textbox and i print out the forth letter it should list "l".... can someone tell me howto?
4
2640
by: j_macaroni | last post by:
I know you can start php -a and go into interactive mode. This works well exept you have to keep putting <?php code here ; bla blah code ; Couple of problems with this. 1) Exits php when you make an error. 2) When you type a command; it displays the result but does not do an automatic CR/LF
4
24879
by: Jim Langston | last post by:
Is there any builtin lowercase std::string compare? Right now I'm doing this: if ( _stricmp( AmmoTypeText.c_str(), "GunBullet" ) == 0 ) AmmoType = Item_Ammo_GunBullet; Is there anything the standard library to do this? I'm not interested in Boost until it becomes part of the standard.
0
3079
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not want to replace all of them. You need to look at it in a case-by-case basis. What can you do? Answer: emacs.
7
5094
by: dmitrey | last post by:
hi all, can anyone explain howto get function from module, known by string names? I.e. something like def myfunc(module_string1, func_string2, *args): eval('from ' + module_string1 + 'import ' + func_string2') return func_string2(*args) or, if it's impossible, suppose I have some modules
0
9136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9030
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7893
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6605
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5933
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4439
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2081
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.