question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disallow single character arguments

See original GitHub issue

Description of the desired feature

A major usability problem for GMT are the complex and cryptic single character arguments and modifiers. This is why we implemented the entire alias system in GMT/Python (which is making its way back into GMT 6). Our docs all encourage using the long form names and this is not strange in the Python ecosystem. Since we’re actively discouraging the use of B and the like, why are we maintaining the capability of doing so? Hardcore GMT users who value brevity are not our target audience. And if you’re using Jupyter or any modern text editor, tab completion eliminates the hassle of longer names (which we currently can’t use because of the alias system).

I propose getting rid of the single letter arguments all together.

Doing this will allow us to:

  • Define functions arguments normally in the Python functions instead of relying on **kwargs.
  • Get rid of the use_alias decorator and replace it with a translator function that’s called inside the function body. This functions would be a lot easier than the decorator to maintain (which is an ugly function inside a function inside a function).
  • Use tab completion for the long argument names
  • Simplify the testing a lot but not needing to test the aliases

The one downside I see that we will have to fully implement all arguments in order for them to be used (like X and Y, etc). But we were gonna have to do this eventually any way.

I’d love to get some feedback on this.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mjziebarthcommented, Jan 18, 2019

Good idea!

@liamtoney @leouieda Regarding the dict of keywords a small issue highjacking: If classes are autocomplete friendly (I must admit I work using simple text editors), one could also do something like

fig.basemap(frame='af', scale=Scale(location_type='g', location=SCALE_LOC, ...))

That would surely take a lot of work setting up but may be helpful.

0reactions
leouiedacommented, Jan 18, 2019

@mjziebarth that was my initial idea but I’d be more prone to using a function instead of a class. The only thing needed is to convert the arguments into a GMT-compatible string, so a class wouldn’t really do much besides store the values and define a __str__ method that does the conversion. The benefit of the class is that the documentation might be more straight-forward (the required value of scale would be either a string or a Scale instance). Another advantage is that we can add them as needed and still allow the normal string input. The only problem with this is that it’s kind of unnatural to require these objects. But I don’t see a good way around it without completely changing the GMT way of doing things.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Single-character switches in block [-abc] with parameters
In programs using getopt() , if -a takes an argument, then foo -abc opt1 opt2 opt3 is -a with the argument bc ,...
Read more >
Google style: allow single character variables #3702 - GitHub
Based on google/styleguide#214 Local variables and catch arguments, method parameters should be allowed to be one characters.
Read more >
Why does Pylint object to single-character variable names?
I.e., if you want to allow single characters as variables: pylint --variable-rgx="[a-z0-9_]{1,30}$" <filename>.
Read more >
Getopt::Long - Extended processing of command line options
Enabling bundling_values will disable the other two styles of bundling. When configured for bundling, single-character options are matched case sensitive while ...
Read more >
22.3.3. Formatted Output to Character Streams
It is an error if no argument remains for a directive requiring an argument, but it is not an error if one or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found