A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.python.org/pipermail/python-dev/2000-July/005680.html below:

[Python-Dev] 's' vs 'z' format (was: CVS: python/dist/src/Modules readline.c,2.18,2.19)

[Python-Dev] 's' vs 'z' format (was: CVS: python/dist/src/Modules readline.c,2.18,2.19)Greg Stein gstein@lyra.org
Thu, 6 Jul 2000 16:05:40 -0700
Good point!

Ignore me, then :-)

Cheers,
-g

On Thu, Jul 06, 2000 at 06:58:17PM -0500, Guido van Rossum wrote:
> > On Thu, Jul 06, 2000 at 11:55:14AM -0700, Skip Montanaro wrote:
> > >...
> > > + /* Exported function to load a readline history file */
> > > + 
> > > + static PyObject *
> > > + read_history_file(self, args)
> > > + 	PyObject *self;
> > > + 	PyObject *args;
> > > + {
> > > + 	char *s = NULL;
> > > + 	if (!PyArg_ParseTuple(args, "|z:read_history_file", &s))
> > 
> > This allows somebody to pass read_history_file(None). That doesn't feel
> > right. I'd suggest using the 's' format code.
> > 
> > (if they want the default, then pass nothing at all)
> 
> Hm, I actually like this style and would recommend it.  There are
> often times where it's useful to pass an explicit parameter that says
> "use the default".  For example when writing a Python wrapper:
> 
> def my_read_hist(file=None):
>     ...do-something...
>     readline.read_history_file(file)
>     ...do-something-else...
> 
> With what you propose, you'd have to write
> 
> def my_read_hist(file=None):
>     ...do-something...
>     if file is None:
>         readline.read_history_file()
>     else:
>         readline.read_history_file(file)
>     ...do-something-else...
> 
> I don't see how forcing users to do that would be considered elegant.
> 
> --Guido van Rossum (home page: http://dinsdale.python.org/~guido/)

-- 
Greg Stein, http://www.lyra.org/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4