473,799 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why should input(prompt="h ello:") fail?

zhi
Really confused, when I use keyword style argument as following:
input(prompt="h ello")


Traceback (most recent call last):
File "<pyshell#5 2>", line 1, in -toplevel-
input(prompt="h ello")
TypeError: input() takes no keyword arguments

While the library reference says the function is: input( [prompt])
so, it should work.:(

I am using python 2.3 for windows.
Have anyone tried this?
I am new to python, please help me, thanks.
Jul 18 '05 #1
12 6437
zhi wrote:

Really confused, when I use keyword style argument as following:
input(prompt="h ello")


Traceback (most recent call last):
File "<pyshell#5 2>", line 1, in -toplevel-
input(prompt="h ello")
TypeError: input() takes no keyword arguments

While the library reference says the function is: input( [prompt])
so, it should work.:(


No, it shouldn't. The argument is not shown with a name, so you
are supposed to use just a position argument, as in input('hello').

Note however that input() is a poor choice for serious work: you
should quickly get past the point of wanting to use it and learn
why raw_input() is a better choice.

-Peter
Jul 18 '05 #2
wo******@hotmai l.com (zhi) writes:
Really confused, when I use keyword style argument as following:


Often builtin functions don't take keyword arguments. There's been a
gentle move towards supporting them over the years, but there are
many, many places that haven't been reached.

Cheers,
mwh

--
Usenet is like a herd of performing elephants with diarrhea --
massive, difficult to redirect, awe-inspiring, entertaining, and
a source of mind-boggling amounts of excrement when you least
expect it. -- spaf (1992)
Jul 18 '05 #3
djw
Peter Hansen wrote:
zhi wrote:

Really confused, when I use keyword style argument as following:
>>> input(prompt="h ello")


Traceback (most recent call last):
File "<pyshell#5 2>", line 1, in -toplevel-
input(prompt="h ello")
TypeError: input() takes no keyword arguments

While the library reference says the function is: input( [prompt])
so, it should work.:(


No, it shouldn't. The argument is not shown with a name, so you
are supposed to use just a position argument, as in input('hello').

Note however that input() is a poor choice for serious work: you
should quickly get past the point of wanting to use it and learn
why raw_input() is a better choice.

-Peter


Doesn't this have more to do with the difference between C-based and Python
based modules in the std. lib?

Discussion on this topic:
http://tinyurl.com/wcgn

My spot checking indicates that you can use keyword args as shown in the
documentation, as long as its a Python based module. C-based modules seem
to be hit-or-miss, some support it, some don't. I actually think this could
be an improvement to the docs - actually show the way the function is
defined so that it is clear what (if any) keyword args are possible.

The docs are ambiguous about this currently, for example, in builtins:

# Function as shown in docs:
cmp(x,y)
cmp(x=1,y=2) TypeError: cmp() takes no keyword arguments

(I would assume that cmp() has a C implementation? )

In calendar:

# Function as shown in docs:
leapdays(y1,y2)
calendar.leapda ys(y2=2004,y1=2 003)

0

I agree that for standard, heavily used functions/methods, this is probably
OK, but it does seem rather inconsistent. Certainly for single parameter
methods like the OP asked about (input()), having a keyword adds very
little value.

-Don

Jul 18 '05 #4
djw wrote:

Peter Hansen wrote:
zhi wrote:

Really confused, when I use keyword style argument as following:

>>> input(prompt="h ello")

Traceback (most recent call last):
File "<pyshell#5 2>", line 1, in -toplevel-
input(prompt="h ello")
TypeError: input() takes no keyword arguments

While the library reference says the function is: input( [prompt])
so, it should work.:(


No, it shouldn't. The argument is not shown with a name, so you
are supposed to use just a position argument, as in input('hello').

Note however that input() is a poor choice for serious work: you
should quickly get past the point of wanting to use it and learn
why raw_input() is a better choice.

-Peter


Doesn't this have more to do with the difference between C-based and Python
based modules in the std. lib?


Yes, no... *if* the input() function supported keyword arguments, then
of course it would respond to a keyword argument of the correct name.

Since it doesn't, you can't exactly say that the name "prompt" is the
proper one to use. For a Python function, you would of course be able
to go and check the source and, if it used "prompt" for the name of its
sole positional argument, then you could use that name as a keyword
argument as well. For the builtin, I think the keyword argument support
has to be provided explicitly, as Michael Hudson is, I think, saying.

-Peter
Jul 18 '05 #5
In article <3F************ ***@engcorp.com >,
Peter Hansen <pe***@engcorp. com> wrote:
Note however that input() is a poor choice for serious work: you
should quickly get past the point of wanting to use it and learn
why raw_input() is a better choice.


Not a propos of the O.P.'s point, but `input` is bad,
bad, bad:

Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright" , "credits" or "license" for more information.
import sys
d=input("Number , please ") Number, please sys.setrecursio nlimit(1) d
d
d

I agree with everything the 2.3 Library Reference says
about input, except "not safe from user errors!" seems
understated.

input can be a handy tool for showing your friends
how viruses work.

Regards. Mel.
Jul 18 '05 #6
Peter Hansen <pe***@engcorp. com> wrote in message news:<3F******* ********@engcor p.com>...
Note however that input() is a poor choice for serious work: you
should quickly get past the point of wanting to use it and learn
why raw_input() is a better choice.

-Peter


Very true. Is "input" a candidate for deprecation in 3.0?
If not, here I give my vote to put "input" in the black list ;)
Michele
Jul 18 '05 #7

"Michele Simionato" <mi**@pitt.ed u> wrote in message
news:22******** *************** ***@posting.goo gle.com...
Very true. Is "input" a candidate for deprecation in 3.0?
If not, here I give my vote to put "input" in the black list ;)


There have been serious (I believe) suggestions to execute

raw_input = input
del raw_input

TJR
Jul 18 '05 #8
"Terry Reedy" <tj*****@udel.e du> writes:
There have been serious (I believe) suggestions to execute

raw_input = input
del raw_input


So it wasn't

input = raw_input
del raw_input

?

I could understand (and support) that one...
--
Ville Vainio http://www.students.tut.fi/~vainio24
Jul 18 '05 #9
"djw" <do************ *****@hp.com> wrote:
Doesn't this have more to do with the difference between C-based and Python
based modules in the std. lib?

Discussion on this topic:
http://tinyurl.com/wcgn

My spot checking indicates that you can use keyword args as shown in the
documentation, as long as its a Python based module. C-based modules seem
to be hit-or-miss, some support it, some don't. I actually think this could
be an improvement to the docs - actually show the way the function is
defined so that it is clear what (if any) keyword args are possible.


if you care the slightest about maintainability , don't use keyword arguments
unless the documentation *explicitly* says that you can or should.

and if the documentation says that you *should* use keyword arguments,
don't use positional arguments just because you think you can.

</F>


Jul 18 '05 #10

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

Similar topics

2
28577
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds to this problem? thanks!!
0
1638
by: Woody Lemcke | last post by:
Hello all, Would you gurus please share your wisdom on any DB2 equivalents to the Informix "Forms" input form utility and "Ace" report generating utility? The input form will probably be accessed by telneting from a Linux shell or Windows command prompt and used for updating a lab database. Thanks and regards, Woody Lemcke
4
11430
by: Ying Lu | last post by:
Hello all, Is it possible that we setup the password in the pg_dump command line instead of let users input it through prompt command. E.g., pg_dump test -c -d --host=localhost -U testUser1 --file='a.dmp' --no-privileges Thanks a lot! Ly
11
11187
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in a text box. I know that there are certain control characters embedded in the data that I want to display substitutions for in the text box, for instance I want to replace ASCII character 04 with the string "<EOT>". I have tried doing a simple...
0
1529
by: Adam | last post by:
Hello, I have a small app I am creating to crawl a directory and check that if it is moved to another a location it's path will not break a character limit. Usually the Windows path limit. Now the script is working but every time I want to scan again I have to restart for the log files to be written. I want to just be able to change the parameter as I please and click scan without having to restart the app for the log file to change.
0
9544
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10238
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
10030
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
9077
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
7570
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
6809
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
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
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.