Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197826

Re: No more Redirect page.

Path csiph.com!weretis.net!feeder9.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer05.iad!feed-me.highwinds-media.com!news.highwinds-media.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!fx12.ams4.POSTED!not-for-mail
From Gilmeh Serda <gilmeh.serda@nothing.here.invalid>
Subject Re: No more Redirect page.
Newsgroups comp.lang.python, alt.comp.software.firefox
References <p9v66l1ltn55trg0vccg1cj83jcpm89mu1@4ax.com> <1141eb5$16llq$1@dont-email.me>
MIME-Version 1.0
x-no-archive yes
User-Agent Pan/0.165 (Kostiantynivka)
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Lines 54
Message-ID <b359S.248240$5lP1.187364@fx12.ams4> (permalink)
X-Complaints-To abuse@easynews.com
Organization Easynews - www.easynews.com
X-Complaints-Info Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date Sat, 25 Jul 2026 15:59:03 GMT
X-Received-Bytes 2138
Xref csiph.com comp.lang.python:197826 alt.comp.software.firefox:17918

Cross-posted to 2 groups.

Show key headers only | View raw


On Sat, 25 Jul 2026 04:33:42 -0000 (UTC), Lawrence D’Oliveiro wrote:

> I often copy and paste links into the following script for this reason.

Why not use pyperclip? Then you can just use clipboard:

1. Copy original URL
2. Run script (+ options)
3. Paste resulting URL

https://pypi.org/project/pyperclip/

You may also want to read this:
https://github.com/asweigart/pyperclip/blob/master/src/pyperclip/
__init__.py  row 19.


If there are only a few options you might even wanna create an alias for 
each version, like scra and scrb or something and put it in your .bashrc:

    alias scra='scriptname -option1';
    alias scrb='scriptname -option2';

Your use of shebang suggests *nix, so...


If I think ArgumentParser is too bulky for a small script, I usually just 
use sys module, which you already have imported.

def main(opt):
    URL = pyperclip.paste()

    if opt == 1:
	[...]
    elif opt == 2:
        [...]

    pyperclip.copy(resulting_URL)

if __name__ == '__main__':
    args = sys.argv[1:]
    if '-option1' in args:
	main(1)
    elif '-option2' in args:
        main(2)
    else:
        print(usage)

But each to their own... It's your script.

-- 
Gilmeh

Everybody likes a kidder, but nobody lends him money. -- Arthur Miller

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: No more Redirect page. Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-07-25 04:33 +0000
  Re: No more Redirect page. Gilmeh Serda <gilmeh.serda@nothing.here.invalid> - 2026-07-25 15:59 +0000
    Re: No more Redirect page. ram@zedat.fu-berlin.de (Stefan Ram) - 2026-07-25 16:24 +0000
      Re: No more Redirect page. Gilmeh Serda <gilmeh.serda@nothing.here.invalid> - 2026-07-26 18:32 +0000
    Re: No more Redirect page. Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-07-29 23:36 +0000
      Re: No more Redirect page. Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-07-29 23:45 +0000

csiph-web