Give every saved image a specific name How can I give a specific name to every saved image?  This is the code that I have now    for i in img_list:     im = PImage.fromarray(i)      im.save(dir + '/' + 'img' + str(i) +'.tiff', 'tiff')    The problem is that when they are saved the name of the images is img and the respective numpy array.  I would like to have an output like  img_1.tiff  img_2.tiff  and so on
Accessing the index in 'for' loops? How do I access the index in a for loop like the following?  ints = [8, 23, 45, 12, 78] for i in ints:     print('item #{} = {}'.format(???, i))   I want to get this output:  item #1 = 8 item #2 = 23 item #3 = 45 item #4 = 12 item #5 = 78   When I loop through it using a for loop, how do I access the loop index, from 1 to 5 in this case?
Why does C++ have header files and .cpp files? What's the difference between !, %, and @ in replacement tokens? I can’t for the life of me figure out where to use a and where to use the — and where there is no article at all. Is there a simple rule of thumb to memorize?   The standard rule you always hear:     “If a person knows which item you are talking about then use "the"   . . . doesn’t clear things up for me, as I have no idea whether or not they know. I have a script that I need to execute on an NTFS partition. The script's permission is set to 600.  I attempted to modify the permissions by running chmod 755 script.sh, which doesn't report a failure or anything - but it also doesn't change the permissions on the file:  $ stat script.sh    File: `script.sh'   Size: 297070      Blocks: 584        IO Block: 4096   regular file Device: 811h/2065d  Inode: 35515       Links: 1 Access: (0600/-rw-------)  Uid: ( 1000/  xxxxxx)   Gid: ( 1000/  xxxxxx) Access: 2010-09-30 14:05:16.041621000 -0700 Modify: 2010-09-30 14:05:05.070157000 -0700 Change: 2010-09-30 14:05:05.070475000 -0700  $ chmod 755 script.sh $ stat script.sh    File: `script.sh'   Size: 297070      Blocks: 584        IO Block: 4096   regular file Device: 811h/2065d  Inode: 35515       Links: 1 Access: (0600/-rw-------)  Uid: ( 1000/  xxxxxx)   Gid: ( 1000/  xxxxxx) Access: 2010-09-30 14:05:16.041621000 -0700 Modify: 2010-09-30 14:05:05.070157000 -0700 Change: 2010-09-30 14:05:05.070475000 -0700   As you can see, it remains unchanged. Diacritics and non-English letters in anglicized loan words: keep 'em, dump 'em, italicize the words, or what? How to access specific raw data on disk from java Why does the experience-to-next-level not change between some levels? At every level from 1st to 11th, the experience needed to reach the next level (from the current level) increases every level. However, this pattern gets broken for most of the later levels:   Going from 10th to 11th takes 21,000xp (= 85k - 64k), but 11th to 12th takes only 15,000xp! (= 100k - 85k). Both 13th and 14th level only take extra 20k experience each, i.e. the amount needed doesn't increase between those two levels. Levels 16 and 17 similarly only need 30k experience each, and 18 and 19 only need 40k experience each.   Why does the last half of the experience chart have some of these levels maintain the same experience costs, and even briefly decrease the experience cost for 12th level? If I make a scene and then render it with BR or Cycles, am I allowed to use that image in a commercial project? Do I need to include any copyright notice or license? What is the best way to remove accents (normalize) in a Python unicode string? I have a Unicode string in Python, and I would like to remove all the accents (diacritics). I found on the web an elegant way to do this (in Java):  convert the Unicode string to its long normalized form (with a separate character for letters and diacritics) remove all the characters whose Unicode type is &quot;diacritic&quot;.  Do I need to install a library such as pyICU or is this possible with just the Python standard library?  And what about python 3? Important note: I would like to avoid code with an explicit mapping from accented characters to their non-accented counterpart. My script (should) acts differently, depending on the presence of the data in the input stream. So I can invoke it like this:  $ my-script.sh   or:  $ my-script.sh &lt;&lt;-MARK     Data comes...     ...data goes. MARK   or:  $ some-command | my-script.sh   where two last cases should read the data, while first case should notice the data is missing and act accordingly.  The crucial part (excerpt) of the script is:  #!/bin/bash local myData; read -d '' -t 0 myData;  [ -z "${myData}" ] &amp;&amp; {     # Notice the lack of the data. } || {     # Process the data. }   I use read to read input data, then option -d '' to read multiple lines, as this is expected, and the -t 0 to set timeout to zero. Why the timeout? According to  (typing left unchanged; bold is mine):     -t timeout time out and return failure if a complete line of input is               not read withint TIMEOUT seconds.  The value of the TMOUT               variable is the default timeout.  TIMEOUT may be a               fractional number.  If TIMEOUT is 0, read returns success only               if input is available on the specified file descriptor.  The               exit status is greater than 128 if the timeout is exceeded   So I in case 2 and 3 it should read the data immediately, as I understand it. Unfortunately it doesn't. As -t can take fractional values (according to above man page), changing read line to:  read -d '' -t 0.01 myData;   actually reads the data when data is present and skips it (after 10ms timeout) if it is not. But it should also work when TIMEOUT is set to real 0.  Why it actually doesn't? How can this be fixed? And is there, perhaps, alternative solution to the problem of "act differently depending on the presence of the data"?  UPDATE  Thanks to @Isaac I found a misleading discrepancy between quoted on-line version and my local one (normally I do not have locale set to en_US, so help read gave me translation which I couldn't paste here, and looking up for on-line translation was faster than setting new env---but that caused the whole problem).  So for 4.4.12 version of Bash it says:     If TIMEOUT is 0, read returns               immediately, without trying to read any data, returning               success only if input is available on the specified               file descriptor.   This gives a little bit different impression than "If TIMEOUT is 0, read returns success only if input is available on the specified file descriptor"---for me it implied actually an attempt to read the data.  So finally I tested this and it worked perfectly:  read -t 0 &amp;&amp; read -d '' myData;   The meaning: see if there's anything to read and if it succeed, just read it.  So as to base question, the correct answer was provided by Isaac. And as to alternative solution I prefer the above "read &amp;&amp; read" method. I am trying to draw a cantor set in LaTeX and I am having issues doing this. I am trying multiple \put commands, but they just go to the right of one another. Does anyone know how to do this?  Any help would be much appreciated. Showing margins/frames in beamer slides I`m using the Newton-Raphson method for obtaining MLE for parameters for maximizing my objective function. At each iteration, I want to check that is the Hessian matrix negative definite or not and I see the Hessian matrix is not negative definite at some iterations. So, I want to use the Fisher scoring algorithm ( of derivation) In this situation, the Fisher information matrix is indefinite!! Is it possible? What are the reasons for this? Are the second-order derivatives wrong? Or are values of expectations incorrect? Setting custom UITableViewCells height Iterated self-composition of arbitrary function Does there exist some notation that represents the iterative composition of a single-input, single-output function with itself? As in, say, $f_5(x)=f(f(f(f(f(x)))))$.  In other words, going by the above (incorrect, I'm pretty sure) notation:  $f(x)=x+1$, $f_n(m)=m+n$  I'm looking for the correct way to express the notion of "$f_n(x)$" for any $f$. Event binding on dynamically created elements? How do I resize my current ubuntu partition? I've got Ubuntu 10.10 installed to use my whole hard-disk, but would like to use the 130GB of free space I've got to create a new partition and do some development on Unity and Natty.  Can I use gparted to do this?  If so how? Why Dumbledore kept mum until the very end of the "Deathly Hallows"? Why are my quotation marks causing an “unexpected token” error with this command? I need help with a specific command that I am using in a new game that I am creating inside of Minecraft. The command is:  /give @p sign 1 0 {BlockEntityTag:{Text1:"{"text":" [MF2]","color":"gold","clickEvent": {"action":"run_command","value":"tellraw @a [""{"text":"[MF2]  ","color":"gold"},{"selector":"@p","color":"dark_aqua"},{"text":" is now an admin of the server!","color":"white"}]"}}",Text3:"{"text":"Click to join Admin","color":"dark_aqua","clickEvent": {"action":"run_command","value":"scoreboard teams join admin @p"}}"},display: {Name:"Custom Sign"}}   If I take out the /tellraw command then the command works fine, but I need the command in there to announce to the game that a new admin has joined.  With the tellraw command, the error message is the following:  Data tag parsing failed: Unexpected token 't' at: text":" [MF2]","color":"gold","clickEvent":{"action":"run_command","value":"tellraw @a [""{"text":"[MF2] ","color":"gold"}, {"selector":"@p","color":"dark_aqua"},{"text":" is now an admin  of the server!","color":"white"}]"}}",Text3:"{"text":"Click to join Admin","color":"dark_aqua","clickEvent": {"action":"run_command","value":"scoreboard teams join admin @p"}}"   If anyone knows how to fix this, please let me know. Solve the recurrence relation:$ T(n) = \sqrt{n} T \left(\sqrt n \right) + n$