Changes

Jump to navigation Jump to search
746 bytes added ,  08:46, 10 February 2016
no edit summary
Line 664: Line 664:  
== Delete *.pyc ==
 
== Delete *.pyc ==
 
  find . -name "*.pyc" -exec rm -rf {} \;
 
  find . -name "*.pyc" -exec rm -rf {} \;
 +
 +
== format hex ==
 +
 +
 +
Use the format() function with a '02x' format.
 +
 +
>>> format(255, '02x')<br />
 +
'ff'<br />
 +
>>> format(2, '02x')<br />
 +
'02'<br />
 +
 +
The 02 part tells format() to use at least 2 digits and to use zeros to pad it to length, x <br />means lower-case hexadecimal.<br />
 +
 +
The Format Specification Mini Language also gives you X for uppercase hex output, and you can <br />prefix the field width with # to include a 0x or 0X prefix (depending on wether you used <br />x or X as the formatter). Just take into account that you need to adjust the field width <br />to allow for those extra 2 characters:<br />
 +
 +
>>> format(255, '02X')<br />
 +
'FF'<br />
 +
>>> format(255, '#04x')<br />
 +
'0xff'<br />
 +
>>> format(255, '#04X')<br />
 +
'0XFF'<br />
 +
 +
    
== nose debug ==
 
== nose debug ==
 
  nosetests --debug=nose,nose.importer --debug-log=nose_debug <your usual args>
 
  nosetests --debug=nose,nose.importer --debug-log=nose_debug <your usual args>

Navigation menu