Re: Mutually exclusive options with argparse.

2021-09-01 Thread Lee Congdon
Does a mutually exclusive group, as described in "Mutual exclusion" at
https://docs.python.org/3/library/argparse.html meet your needs?

On Wed, Sep 1, 2021 at 9:48 AM hongy...@gmail.com 
wrote:

> See the following code snippets [1] for implementation of the exclusive
> options with argparse:
>
> def query_builder(args):
> if args.r and args.s:
> sys.exit(Term.FAIL + 'Only one of -re and -sql should be set' +
> Term.ENDC)
> sum_status = sum(1 for x in [args.failure, args.code != -1] if x)
> if sum_status > 1:
> sys.exit(Term.FAIL + ('Only one of --failure and --code has to be
> set') + Term.ENDC)
>
> [1]
> https://github.com/hongyi-zhao/recent2/blob/5486afbd56a6b06bb149a3ea969fb33d9d8b288f/recent2.py#L391
>
> It seems that the above method is awkward, but I'm out of idea to work out
> more graceful solutions. Any comment/suggestion/enhancement will be highly
> appreciated.
>
> Regards,
> HY
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
+1-202-507-9867, Twitter @lcongdon
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A 35mm film camera represented in Python object

2021-03-18 Thread Lee Congdon
Note also 36 exposure film.

 -- Film -
Speed:  100 ISO
Rewound into cartridge: False
Exposed frames: 0 (of 24)
Ruined: False

On Sun, Mar 7, 2021 at 5:20 AM D.M. Procida <
real-not-anti-spam-addr...@apple-juice.co.uk> wrote:

> Hi everyone, I've created  -
> a representation of a Canonet G-III QL17 in Python.
>
> There's also documentation: .
>
> It's a pure Python model of the physical sub-systems of a camera and
> their interactions. So far it's at a fairly high level - I haven't yet
> got down to the level of individual springs and levers yet.
>
> I spend quite a bit of my time repairing old cameras. To me they feel
> like computer programs encoded into physical objects, and figuring out
> how a mechanism works feels like working out how code works (but more
> fun).
>
> The Canonet G-III QL17 is one of my favourites. One of my reasons for
> writing this code is to appreciate the intricate mechanical logic
> embodied in the machine.
>
> You can do things like advance the film, release the shutter, meter the
> scene with the built-in light meter (if the camera has a battery of
> course) and even spoil your film if you make the mistake of opening the
> back in daylight.
>
> >>> from camera import Camera
> >>> c = Camera()
>
> >>> c.state()
> == Camera state =
>
> -- Controls -
> Selected speed:1/120
>
> -- Mechanical ---
> Back closed:   True
> Lens cap on:   False
> Film advance mechanism:False
> Frame counter: 0
> Shutter cocked:False
> Shutter timer: 1/128 seconds
> Iris aperture: ƒ/16
> Camera exposure settings:  15.0 EV
>
> -- Metering -
> Light meter reading:4096 cd/m^2
> Exposure target:15.0 EV
> Mode:   Shutter priority
> Battery:1.44 V
> Film speed: 100 ISO
>
> -- Film -
> Speed:  100 ISO
> Rewound into cartridge: False
> Exposed frames: 0 (of 24)
> Ruined: False
>
> -- Environment --
> Scene luminosity:   4096 cd/m^2
>
> >>> c.film_advance_mechanism.advance()
> Cocking shutter
> Cocked
>
> >>> c.shutter.trip()
> Shutter opens
> Shutter closes
> Shutter opened for 1/128 seconds
> Shutter uncocked
>
> You can't do impossible things:
>
> >>> c.shutter_speed = 1/33
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Users/daniele/Repositories/camera/camera.py", line 29, in
> shutter_speed
> raise self.NonExistentShutterSpeed(f"Possible shutter speeds are
>   {possible_settings}")
> camera.NonExistentShutterSpeed: Possible shutter speeds are 1/4,
>   1/8, 1/15, 1/30, 1/60, 1/120, 1/240, 1/500
>
> But you can also do things that you shouldn't do, like opening the back
> of the camera in daylight with a partially-exposed roll of film inside -
> which will spoil the film::
>
> >>> c.back.open()
> Opening back
> Resetting frame counter to 0
> 'Film is ruined'
>
> I hope this interesting to someone.
>
> Daniele
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
+1-202-507-9867, Twitter @lcongdon
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem finding my folder via terminal

2018-06-09 Thread Lee Congdon
On Sat, Jun 9, 2018 at 4:45 PM T Berger  wrote:

> [snip]



> Sorry. That's terrible. But I did run the code a number of times
> correctly. I just did it again and got the same key icon:
>
> Last login: Sat Jun  9 13:26:14 on ttys000
> 192:~ TamaraB$ cd Desktop/mymodules/dist
> 192:dist TamaraB$ dist TamaraB$ sudo python3 -m pip install
> vsearch-1.0.tar.gz
> -bash: dist: command not found
> 192:dist TamaraB$ sudo python3 -m pip install vsearch-1.0.tar.gz
> Password:
>
> What next?
>
> Thanks,
>
> Tamara
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Assuming your account has administrator rights on your Mac, enter the
password you use to sign on. If not, or you don't use a password to sign
on, see https://support.apple.com/en-us/HT202035

-- 
Lee
-- 
https://mail.python.org/mailman/listinfo/python-list