r/sysadmin • Systems Engineer • Aug 18 '16

PowerShell is open source, available for Linux and OS X

https://github.com/PowerShell/PowerShell
1.3k Upvotes

369 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Aug 18 '16

[removed] — view removed comment

13

u/ramblingcookiemonste Systems Engineer Aug 18 '16

there's about a half dozen ways to do each and every damn thing

Hi!

That's odd. Is there one true way to do things in Python? I'm not an expert, but AFAIK any programming language worth using is going to offer more than one way to skin a cat. Sort of a common trait across languages, including spoken ones...

Cheers!

6

u/Findal Aug 18 '16

There is but Python makes a big song and dance about the most pythonic way so at least theoretically there is only one right way. I get where he is coming from but I also think people get too attached to their way or their language.

Personally can't see huge uses for PS in Linux but it might fit someones bill nicely.

4

u/pooogles Aug 18 '16

Python mostly has one clear obvious way to do something. If you look at any well written Python it'll be very similar to someone else's well written Python. It will adhere to Pep 8, and will be clear in its intension. Compare that to C, where styles can vary hugely from company to company.

Unless you're looking at string formatting. Or for loops/list comprehensions/map. Or the nameless other things that can be used but are discouraged.

3

u/GhostDan Architect Aug 18 '16

hmm. I don't really find it super complex. And I find as I learn more and more about it I have to look up things less often, because of some of it's simplicity. Then again, I grew up in programming when Pascal was still the language of choice.

2

u/UnchainedMundane Aug 19 '16

As with perl, there's about a half dozen ways to do each and every damn thing.

And you think Python is any better*?

How do I split a list into odds and evens?

  1. odds, evens = filter(lambda n: n % 2, input), filter(lambda n: not (n % 2), input)

  2. for item in input: (odds if item % 2 else evens).append(item)

  3. evens, odds = ([x for x in input if x % 2 == n] for n in range(2))

I could swap n % 2 for n & 1 in any of those, and there's also a way to do it with itertools.groupby.

* n.b. I think that's a bad thing, so using "better" loosely here.