Differences between revisions 13 and 14
Revision 13 as of 2006-03-10 05:50:54
Size: 1583
Editor: radlog
Comment: added base64 decoding
Revision 14 as of 2006-03-14 21:00:09
Size: 1582
Editor: rba-cache2-vif0
Comment: Corrected spelling.
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
This is a page that is devoted to short programs that can perform powerful opperations. The ability to write short programs that are just as powerful as a program written in another lanuage designed to do the same thing. However, it is sometimes fun to try and write a program in Python that is only one line. In other lanugages this would be nearly ''impossible'', but in Python it is a lot easier to do. The trick is to think up something that will "do a lot with a little." I, personally, would love to see this page expanded to the point where it needs some sort of organization system. This is a page that is devoted to short programs that can perform powerful operations. The ability to write short programs that are just as powerful as a program written in another lanuage designed to do the same thing. However, it is sometimes fun to try and write a program in Python that is only one line. In other lanugages this would be nearly ''impossible'', but in Python it is a lot easier to do. The trick is to think up something that will "do a lot with a little." I, personally, would love to see this page expanded to the point where it needs some sort of organization system.

Powerful Python One-Liners

This is a page that is devoted to short programs that can perform powerful operations. The ability to write short programs that are just as powerful as a program written in another lanuage designed to do the same thing. However, it is sometimes fun to try and write a program in Python that is only one line. In other lanugages this would be nearly impossible, but in Python it is a lot easier to do. The trick is to think up something that will "do a lot with a little." I, personally, would love to see this page expanded to the point where it needs some sort of organization system.

Thanks for Your Code, ["JAM"]

Contributed Code

  • ["JAM/Code/PlatformFinder"] - This program tells you what platform you are using.
  • ["JAM/Code/ComPYiler"] - This program compiles every .py file in the Python directory.
  • ["Powerful Python One-Liners/Hostname"] - This programs tells you what your hostname is.

BR Some thoughts by ewo:

  • Want to know how much Byte a Terabyte is? If you know further abbreviations you can extend the list.

import pprint;pprint.pprint(zip(('Byte', 'KByte', 'MByte', 'GByte', 'TByte'), [(2**10)**i for i in xrange(5)]))
  • And what's the largest number that can be represented by 8 Byte?

import pprint;pprint.pprint(["%i Byte = %i Bit = largest number: %i" %(j, j*8, 256**j) for j in [2**i for i in xrange(8)]])

Cute, isn't it?

Decode a base64 encoded file

import base64, sys; base64.decode(open(sys.argv[1], "rb"), open(sys.argv[2], "wb"))

Powerful Python One-Liners (last edited 2023-07-19 19:23:56 by HermannStammWilbrandt)

Unable to edit the page? See the FrontPage for instructions.