r/Python • • Mar 07 '17

CIA uses Python (a lot)

From the latest Vault 7 leaks from Wikileaks, we can see that CIA uses a lot of Python in its secret hacking tools.

Most notably in the Assassin, Caterpillar, MagicViking and Hornet projects.

Unfortunatelly, no files from these projects have been released yet. But if you look at the dump that was released, there are plenty of .py files, and even PIL is included.

There are even Coding Conventions: https://wikileaks.org/ciav7p1/cms/page_26607631.html

You can see more Python-related stuff here: https://search.wikileaks.org/?query=python&exact_phrase=&any_of=&exclude_words=&document_date_start=&document_date_end=&released_date_start=&released_date_end=&publication_type%5B%5D=51&new_search=False&order_by=most_relevant#results

1.1k Upvotes

220 comments sorted by

View all comments

Show parent comments

165

u/can_dry Mar 07 '17

Indentation

Indent your code blocks with 4 spaces.

Never use tabs or mix tabs and spaces.

Sorry, you're just not CIA material.

10

u/[deleted] Mar 07 '17

Question from a not so experienced programmer: what's wrong with tabs?

62

u/nickbob00 Mar 07 '17 edited Jun 03 '25

cake physical direction wise fanatical march tap mountainous melodic station

This post was mass deleted and anonymized with Redact

18

u/DonaldPShimoda Mar 07 '17

The right answer is to use smart tabs, where you get a feature where your editor tab button makes 4 spaces in the file, but it works like a tab as far as you care.

Nah, I think it's much better to actually press the space bar the requisite number of times.

4

u/Corbichon Mar 08 '17

Vim for ever <3

7

u/AZNman1111 Mar 08 '17

I do use Vim over Emacs

→ More replies (2)

0

u/[deleted] Mar 08 '17

[deleted]

→ More replies (2)

0

u/[deleted] Mar 07 '17

[deleted]

8

u/wolf2600 Mar 07 '17

You don't have to count whether you have 3 spaces or 4. ON. EVERY. LINE.

And don't even get started with deeply nested sections.... Was that 24 spaces or 25? Better delete them all and start again.

17

u/[deleted] Mar 07 '17

Sounds like you just need a proper editor :P

4

u/wolf2600 Mar 08 '17

Notepad++ works fine

0

u/[deleted] Mar 08 '17

[deleted]

3

u/ArmoredPancake Mar 08 '17

We've found a CIA agent!

9

u/trekkiemage Mar 07 '17 edited Mar 10 '17

I have sublime set up so that I hit tab and it enters four spaces. I've also got whitespace visibility turned on and it allows me to control indentation with a hot-key instead of the space bar.

Basically if you're using the space bar to do 4-space indents you're doing it wrong.

2

u/caramba2654 Mar 08 '17

If you use tabs for indentation and spaces for alignment it solves the inconsistent display.

4

u/jcdyer3 Mar 08 '17

This is the most theoretically correct answer, and the one that produces the most abominable real code bases, as it's nearly impossible for a team to follow consistently.

2

u/baubleglue Mar 07 '17

It just you need to choose one or tabs or spaces

7

u/Dillinur Mar 07 '17

To nitpick, you just need to be consistent, but you can totally mix them.

For instance, your indentation block choice can be "one tab", "4 spaces", or "space-tab-space", as long as you keep the same indentation block choice along the whole file.

6

u/Hawkknight88 Mar 08 '17

Maybe I'm misunderstanding you... It is not okay to mix tabs and spaces in python. The interpreter doesn't like it and it's confusing to humans.

Pick tabs or pick spaces, and be consistent.

5

u/[deleted] Mar 07 '17

[removed] — view removed comment

8

u/Exodus111 Mar 07 '17

A Tab will leave a line symbol, and a space will leave a dot symbol in the file. If you mix these two Python will crash.

Most modern IDE's and Text editors will auto translate your Tab symbol over to spaces for you, usually 4 spaces, but this number can usually be set.

This was a bigger issue back in the day.

4

u/ebilgenius Mar 07 '17

It's important in almost everything, but it's particularly helpful in coding since everyone has a preference when it comes to how they like their code, and once you know what their preferences are and that they're consistent you can reliably make changes, debug it, or work with it in general.

That and programmers tend to be particularly anal about perfection.

2

u/baubleglue Mar 08 '17

I know, but the editors don't and convert depending on settings and version control can't be set to ignore white spaces in Python, so one programmer uses spaces check in code, other programmer checkout the code, his IDE converts 4 spaces to tabs - 100% of code changed.

2

u/baubleglue Mar 08 '17

I know, but the editors don't and convert depending on settings and version control can't be set to ignore white spaces in Python, so one programmer uses spaces check in code, other programmer checkout the code, his IDE converts 4 spaces to tabs - 100% of code changed.

→ More replies (1)
→ More replies (1)