I have a list in python that looks like that: [a,b,c,d,e,f,g,h,i]. I would like to convert this list to a list of lists (nested list). The second level of lists should contain four elements maximal. Therefore, the new list should look like that:  [   [a,b,c,d],   [e,f,g,h],   [i], ]   Is there a pythonic way to do this? I will have to do this several times so I would be pleased if anybody knows a way of doing this without using hundreds of indexes.
I have a list of arbitrary length, and I need to split it up into equal size chunks and operate on it. There are some obvious ways to do this, like keeping a counter and two lists, and when the second list fills up, add it to the first list and empty the second list for the next round of data, but this is potentially extremely expensive.  I was wondering if anyone had a good solution to this for lists of any length, e.g. using generators.  I was looking for something useful in itertools but I couldn't find anything obviously useful. Might've missed it, though.  Related question:
If $\operatorname{rank}\left( \begin{bmatrix} A &B \\ C &D \end{bmatrix}\right)=n$ prove that $\det(AD)=\det(BC)$ Recursively delete empty directories in Windows Image looks embossed when converted to SVG Create a virtual file that is actually a command Is there any way to create a virtual file, such that reading from the file actually reads from the stdout of a command; writing to the file is acually writing to the stdin of a command?  So far I have kludged this with an inotifywait on a file, which calls a command when the file is modified, taking it's input from the file and writing back to it.  I don't like that the inotifywait has to be constantly restarted though (and I have to ensure that it is always running). I only use this file perhaps twice a week. Wikipedia lists the following pseudocode for HMAC:  function hmac (key, message)     if (length(key) &gt; blocksize) then         key = hash(key) // keys longer than blocksize are shortened     end if     if (length(key) &lt; blocksize) then         // keys shorter than blocksize are zero-padded ('∥' is concatenation)          key = key ∥ [0x00 * (blocksize - length(key))]      end if      // Where blocksize is that of the underlying hash function        o_key_pad = [0x5c * blocksize] ⊕ key      // Where ⊕ is exclusive or (XOR)     i_key_pad = [0x36 * blocksize] ⊕ key       // Where '∥' is concatenation        return hash(o_key_pad ∥ hash(i_key_pad ∥ message))  end function   Why are they there?  How were they chosen?  It seems to me that  $hash(key + hash(message))$ (where + is concatenation) would suffice.    Obviously I'm missing something.  What is it? I am on a MacBook Pro 13 running latest Sierra. I have an external Seagate solid state hard drive that was working and out of the blue stopped working. The only thing on it was my Adobe Lightroom images/videos. Not the LR DB files. I'm sure you have all heard this woe before, so I won't dwell on that. And yes, I back up to the cloud. AWS S3 specifically. Though I am traveling South East Asia for the last year, and staying in cheap hostels. So good internet is hard to come by sometimes. I can't back it up after every export. While most of it is backed up, there is some that is not.  Moving on. The symptoms seems to change every time I plug it in. The first sign was it ejected on it's own. I plugged it in again, and it wouldn't mount. Disk Utility recognized it, so did the command line diskutil list but it wouldn't mount. I rebooted and it worked for a second. Then I could only get to it from the command line. Then trying to frantically back up to my local what was not backed up to the cloud, it all failed. Basically just a cp -R [directory] [local-directory] command.  After some more frantic unplugging and re-plugging plus some command line manual mounts, I finally got it to where the Disk Utility would be able to run first aid on it. It failed. I don't recall the error. So I put it in a freezer. After a few hours I tried again. It is not any better. It still will not mount. Now Disk Utility sees it, but with no partition. I can't even give me information about how much space is used on it.  I have also tried it from a Windows machine. It did not mount. I have tried other cables. No success. As well as tried my other USB port. I also have another working external hard drive exactly like the one giving me issues. It works on all cables and USB ports.  I do have Docker running with a Ubuntu container, I'm trying to think of a way to see if I can try to get to the USB from there. I also have a USB that I have thought about running a live Ubuntu on there to see if I can mount and retrieve the data or fix the HDD that way. But if it will not mount, I doubt these will work.  Can anyone else think of any other tricks I can try myself to see if I can repair this or at least retrieve the data without paying for a service or software? If not, those suggestions are also welcome.  Update   I made the mistake in original post that it was a Solid State Drive. This is my mistake, it is actually a spinning disk hard drive. I bought them long ago and have been traveling with them for so long I just forgot. Question is updated to reflect this. Now diskutil list does not show it at all. The Disk Utility app also does not see it. Based on suggestion from @Allen I seeked out the USB to SATA cable. I did not quite find it, as my options are extremely limited where I am at. Though a local expat on a facebook group was able to help me with a empty 2.5 casing that I was able to extract the drive from original casing and put it in his blank case. It now mounts. Though it has the "click of death" sound to it. And data is not really reachable. While I can ls the directories and Adobe Lightroom does not have the exclamation mark when it can not reach the actual external files. Right clicking on the images and clicking on "Show in Finder" or any other variation of trying to get to the files through Finder or terminal, I have no success. It usually hangs and I get the spinning wheel. Since Adobe Lightroom imports these images into directories named by date, I am going to send the drive off to a data recovery service and ask to recover just unbacked up directories i.e. dates. Next time I will make harder efforts to backup and probably get an actual SSD.   I think this can be closed, due to my low reputation points I can not close this myself. "This is a favorite question" tooltip when not favorite Becoming Thieves Guild Guildmaster, am I bugged? I've completed the Thieves Guild main questline () and chosen my special power (Shadowcloak of Nocturnal). It says completed in my quest log.  I also completed the  in each city you can give Thieves guild influence to (Markarth, Whiterun, Windhelm, and Solitude) and done their special jobs from Delvin. They show completed in my quest log. I've even done at least one of each kind of job from Vex and Delvin (but not in each city).  I got  in the Ragged Flagon and have done the quest for Tonilia (delivering the Moon Sugar to a caravan) and Vekel (getting the 4 books). I've also upgrade one of my pieces of Thief Armor.  I talk to  to become guild master and I get no dialogue options but he just says he's busy and we'll talk another time. There is a guild chest in front of his desk but it's locked and I don't have the key.  What am I missing? Is there some bug I've encountered? How do I get rid of eggs? Simplest way to send one-line mail out via command line using gmail? Using Raspbian and Ubunntu 16.04 LTS so need a generic Linux solution.  Requirement is simple:  I need a way to send one-line email messages from the command line.  I have set up a gmail account just for this particular Rpi3, with the address of rpi3abc@gmail.com - with no 2FA  So now I need to be able to send one-line mail messages from anywhere (including cron) without user intervention.    I also would like it to be able to send text files; basically, anything from stdin. What does it take to understand Maxwell's equations? Assume I want to learn math and physics enough to reach a level where I understand Maxwell's equations (The terms and reasoning in the equations I.e. why they "work"). What would I have to learn in order to have the tools I need to make sense out of it?  I'm kindof looking for a road map which I can use to get started and know what to focus on. The fields are pretty big so some pruning would be very helpful (if possible) Comparing $\pi^e$ and $e^\pi$ without calculating them Same gravatar is displayed for different users in stackexchange.com filters Same gravatar is displayed for different users in the stackexchange.com , under the Top Network Askers in the right side bar.   The red circled image's source (&lt;img src=) are from   https://www.gravatar.com/avatar/?s=18&amp;d=identicon&amp;r=PG&amp;s=30                                ^   Seems the gravatar id is missing here in the image source.  For an example from the list, the user  gravatar id should be    https://www.gravatar.com/avatar/66c66c4d97a7bc3859a85253f003e1fb?s=18&amp;d=identicon&amp;r=PG&amp;s=30   but it is mapped with   https://www.gravatar.com/avatar/?s=18&amp;d=identicon&amp;r=PG&amp;s=30   which caused the display issue. I have two tables A &amp; B. Table A id | name | num  Table B id | date | roll  id in table B is a foreign key which relates to the id in table A. I want to get the contents of table B where id is given and also along with that data, I need the name whose id is given from table A. NOTE: cannot use multiple queries separated by commas; need to do both the SELECTs in one query. past simple or present perfect Positioning of decorations on parallel lines I'm displayed three lines on a pgfplot. I want to show a marker for the slope of each line and the difference in height between lines.     I'm showing the slopes by adding triangles under the lines  (at a manual position) and placing an annotation inside the triangle (at a manual position). I'm showing the difference between the height of the lines by adding a brace manually as well.   How can I place the braces on the plot and anchor them at a certain point on each line? The triangles can be added at the end of each line declaration, but doing it like this is ok. The braces are put in place manually, which is not sustainable as I create more plots.   I want to avoid using xshift, yshiftand manual adjustment to put the braces,traingles and annotations in the right place. How can I do this?      \documentclass{article} \usepackage{pgfplots}  \pgfplotsset{compat=1.9}  \begin{document}   \begin{tikzpicture}[scale=0.45,trim axis left, trim axis right]     \begin{axis}[ylabel={$\hat{S(4)}$},xlabel={$S{^*}_{breakeven}$},ylabel style={rotate=-90},domain=1:25, legend style={legend pos=north west,font=\scriptsize}, legend cell align=left]  \addplot+[samples=200,mark=none]                                    {6.26 + 0.28*x} coordinate[pos=0.5](x) coordinate[pos=0.9] (y) (x)-| (y) node [midway,xshift=-0.6cm,yshift=0.3cm] {\footnotesize $Slope X$};;  \addplot+[samples=200,mark=none, dotted, thick]             {2.66 + 0.28*x}  coordinate[pos=0.3](a) coordinate[pos=0.6] (b) (a)-| (b) node [midway,xshift=-0.5cm,yshift=0.2cm] {\footnotesize $Slope 1$};  \draw [decorate,decoration={brace,amplitude=5pt,raise=4pt},xshift=4pt]  (225,107) -- (225,73)  node [midway,xshift=0.6cm] {\footnotesize $\beta_1$};  \end{axis} \end{tikzpicture} \end{document} Strange Pop-up appldnld.apple.com:80 I received a strange Pop Up message. The unsettling part is password will be sent in clear text.  Is my phone affected with any malware or app virus ? Native Youtube app suddenly stopped working on iPad 1 It's been some weeks now, whenever I try to used my Youtube app, it tells me it's impossible to connect to Youtube. Since it's an iPad 1, I have had trouble finding information online.  Did Google or Apple stop supporting the app? Is it finally obsolete? Is there another app I could use that works on iOS 5?  Just to be clear, I did not tinker with my device. I did not change its parameters, I did not jailbreak it, it connects to the Internet just fine and I've tried the app on different Internet connections. Also, this is not a login problem, the app just refuses to let me browse videos, whether I'm logged in or not.  Thanks for your help. "Ghost" UI elements Occasionally, I get part of an application lingering behind on my desktop:    This is part of a context menu for an application. It is always top-most, meaning that it is always on the screen, and I cannot click on it (it just clicks through it). It has happened before, sometimes with whole windows. It remains on screen even if the application it originated from is no longer running.  How do I get rid of it without rebooting? How can I access the apache basic-auth username in a PHP script?