a = 'abcdef' Why is a[-1] == 'f', but a[0:-1] == 'abcde' ? I know I need to use a[0:] or a[0:len(a)], but I want to understand why the intuitive solution is (again) not the pythonic one.
I need a good explanation (references are a plus) on Python's slice notation.   To me, this notation needs a bit of picking up.   It looks extremely powerful, but I haven't quite got my head around it.
What is involved in moving over to Lightning Web Components? Need Help Fixing Grub after Installing Ubuntu 13.04 x64 Alongside Windows 8 on a Lenovo IdeaPad Y400 with UEFI I have a Lenovo IdeaPad Y400 that came pre-installed with Windows 8. I would like to run Ubuntu alongside it in a dual-boot configuration. I've spent the past week fiddling around, re-installing both Windows and Linux in various configurations, and I've come awfully close to success, but seem to have hit a snag with Grub.  For my most recent attempt, I took the following steps:   Disabled Secure Boot Re-imaged Windows 8 from a hidden recovery partition, effectively restoring the machine to factory state Activated an option called Legacy Support in the BIOS (or is it UEFI now?) Booted Ubuntu 13.04 x64 from a USB stick, chose "install alongside Windows" and accepted all default options After a restart, found that I could boot Ubuntu, but could not boot Windows Once into Ubuntu, I ran Boot Repair with recommended settings and accepted all defaults. When Boot Repair finished, I was presented with the following message:      The boot files of [The OS now in use - Ubuntu 13.04] are far from the   start of the disk. Your BIOS may not detect them. You may want to   retry after creating a /boot partition (EXT4, >200MB, start of the   disk). This can be performed via tools such as gParted. Then select   this partition via the [Separate /boot partition:] option of [Boot   Repair]. ()    I followed the instructions at the url in the message, creating a 1GB EXT 4 partition near the start of the drive  when I tried to run Boot Repair again, the "Separate /boot partition" option on the "Grub Location" tab was disabled.  The new partition is /dev/sda11 and has the label GRUB. On restart, I get the following error message:      error: file '/boot/grub/i386-pc/normal.mod' not found.    grub rescue>    However, if I manually choose the boot partition by hitting F12, I can boot into Windows no problems. Selecting Ubuntu from the boot device menu gives me a Grub menu with the following options:      Ubuntu      Advanced options for Ubuntu       Windows UEFI recovery bootmgfw.efi      Windows Boot UEFI recovery       Windows UEFI recovery LrsBootmgr.efi      Windows Boot UEFI recovery bkpbootx64.efi       Windows Recovery Environment (loader) (on /dev/sda3)       Windows 8 (loader) (on /dev/sda5) System setup    Selecting Ubuntu from this menu allows me to get to my Ubuntu desktop. I haven't tried the other options yet for fear of losing the progress that I've made.   So it looks like I have successfully dual-booted the machine, but that Grub is broken for some reason or another.   My current partition scheme can be seen at:   Thanks in advance - Jonathan Page range truncation with imakeidx This is a followup question to egreg's answer to  The answer runs into a problem if an index topic occurs in more than one page range. The following MWE, based on egreg's answer:  \begin{filecontents*}{subjind.ist} delim_0 ", \\checkrange{" delim_t "}" \end{filecontents*}  \documentclass{book} \usepackage{xparse} \usepackage{imakeidx}  \makeindex[title=Subject Index,options=-s subjind]  \ExplSyntaxOn \NewDocumentCommand{\checkrange}{&gt;{\SplitArgument{1}{--}}m}  {   \formatrange#1  } \NewDocumentCommand{\formatrange}{mm}  {   \IfNoValueTF { #2 }    { % no --, it's not a range     #1    }    { % it's a range     \egreg_range:nn { #1 } { #2 }    }  }  \bool_new:N \l__egreg_range_compare_bool  \cs_new_protected:Nn \egreg_range:nn  {   % print the start number   #1--   \int_compare:nNnTF { \str_count:n { #1 } } = { \str_count:n { #2 } }    {% same number of digits, remove equal ones at the start     \__egreg_range_compare:nn { #1 } { #2 }    }    {% different number of digits, print both     #2    }  } \cs_new_protected:Nn \__egreg_range_compare:nn  {   \bool_set_true:N \l__egreg_range_compare_bool   % do a loop on the digits in the first number   \int_step_inline:nn { \str_count:n { #1 } }    {     \bool_if:NTF \l__egreg_range_compare_bool      {       % if the digits coincide, print nothing       \str_if_eq:eeF { \str_item:nn { #1 } { ##1 } } { \str_item:nn { #2 } { ##1 } }        {         \str_item:nn { #2 } { ##1 }         % at the first differing digit, don't compare any longer         \bool_set_false:N \l__egreg_range_compare_bool        }      }      { \str_item:nn { #2 } { ##1 } }    }  } \ExplSyntaxOff  \begin{document} \setcounter{page}{95}\index{Topic0|(}Text\newpage \setcounter{page}{101}\index{Topic0|)}Text\newpage \setcounter{page}{124}\index{Topic1|(}\index{Topic2|(}Text\newpage \setcounter{page}{126}\index{Topic1|)}Text\newpage \setcounter{page}{134}\index{Topic2|)}Text\newpage \setcounter{page}{141}\index{Topic0}Text\newpage \index{Topic0}Text\newpage \index{Topic0}Text \printindex \end{document}   yields the following error message:  ! LaTeX3 Error: Too many '--' tokens when trying to split argument.  For immediate help type H &lt;return&gt;.  ...                                                l.3   \item Topic0, \checkrange{95--101, 141--143}   Entering non-stop yields the following output:    which omits "-3" from the second index entry of Topic0. The question is how to get around this.  Edit following up on egreg's ingenious solution.  I don't know if I should ask a new follow up question, so I'm posing it first here in this edit.  egreg's solution doesn't seem to handle index sub-topics.  If one adds the following 4 lines  \setcounter{page}{135}\index{Topic0!sub0|(}Text\newpage \setcounter{page}{136}\index{Topic0!sub0!subsub0|(}Text\newpage \setcounter{page}{139}\index{Topic0!sub0!subsub0|)}Text\newpage \setcounter{page}{140}\index{Topic0!sub0|)}Text\newpage   after  \setcounter{page}{134}\index{Topic2|)}Text\newpage   in the solution, one gets the following errors:  Output written in mwe.ind. Transcript written in mwe.ilg.  (mwe.ind ! Extra }, or forgotten \endgroup. l.4     \subitem sub0, 135--140}  ? r OK, entering \nonstopmode... ! Extra }, or forgotten \endgroup. l.5       \subsubitem subsub0, 136--139}  ) [145] (mwe.aux) )   and this output:    Alas I don't understand egreg's code well enough to make the required changes. Restored database missing views, stored procs and foreign keys What is dependency injection? How to use an existing database with an Android application Extending from two classes Is there a way to transfer thousand of small files faster on Windows 7? I noticed that if I transfer a few large files between two hard drives, it's pretty speedy, at around at least 30&nbsp;MB per second, but if I transfer thousands of files less than 5&nbsp;KB, it is pretty damn too slow.. around 1 to 2&nbsp;MB per second.   Is there a way to speed up the copy/paste process with thousands of small files on Windows 7? Why can't two series-connected diodes act as a BJT? Another form of the question is: will joining two diodes with wires (pn-np) make a transistor-equivalent?  I read that they are not equivalent, but why? How to write a query for exact pairs of groups How do the bonus perks from the Advanced Warfare Center work? Checking for a null int value from a Java ResultSet Today I was cut off in the middle of the following sentence:     Between Cook, Strauss, and Pietersen—   My friend said I was wrong. He said that for more than two entities, among/amongst are used, and that between is only for two entities.   I vaguely remember some rule like this, but I asked him to hear the whole sentence, which was:     Between Cook, Strauss, and Pietersen, they’ve notched up 56 centuries in Test cricket.   Should I have used among here? Seems correct to me to use between, but my friend was certain.   Another friend pointed out the following sentence:     I’m still choosing between Harvard, Yale, and MIT.    Certainly among doesn’t seem to fit here, and she, to me, was correct in using between. Got 2,919 PB/s in Ubuntu Terminal I have problem (seems to be trivia) about Ubuntu Terminal. Once my network connection slow down then it (sometimes but very rare to happened) showed some information like this.     I shocked because I have been got 2,919 PB/s. Sorry my mouse block some part of letter 'P' (I actually rush to print screen) but I believe you can recognize it.    EDIT    based on answer given to me, and I got similar info then, I'd like to add more clearly new image after.    Can someone explain it to me?  Best Regards! What do you call someone who always puts blame on others? Do numbers exist independently from observers? Plotting heat equation in a Manipulate expression Why is an orthogonal matrix called orthogonal? Obtain the joint PDF of $\theta_{1} - \theta_{2}$ and $\theta_{1}$ where $\theta_{1}$ and $\theta_{2}$ are i.i.d $\text{Uniform}[0, 2\pi)$ I have 2 i.i.d Uniform random variables $\theta_{1}$ and $\theta_{2}$ on $[0, 2\pi)$. Here the problem pushes us to consider that all operations are made modulo $2\pi$. My question is how to obtain the joint PDF of $\theta_{1} - \theta_{2}$ and $\theta_{1}$ and then obtain the conditional PDF of $\theta_{1}$ given $\theta_{1} - \theta_{2}$??. For the second part It can be deduced from the first by writing it as the joint PDF divided by the PDF of $\theta_{1}$. But for the first part, A common idea that I saw is to derive the $\text{CDF}(x, y) = P(\theta_{1} - \theta_{2} \le x$, $\theta_{1} \le y$) and then perform derivations respect to $x$ and $y$. Is this a right approach? If yes, how to proceed with CDF especially with our uniform distribution restrictions? Some ships in Star Trek are referred to with definite articles. "The Enterprise", "The Defiant". Other ships are referred to without them. "Voyager", "Enterprise". Is there a pattern to or explanation for this behavior?