I've this working code:  ', '.join('%s=%r' % item for item in list)   where list is list of tuples ('key', 'value').  I want to refactore the code to use the new style string.format. I've tried it this way:  ', '.join(['{!s}={!r}'.format(item) for item in list])   This results in an IndexError: tuple index out of range. Are there any better solutions than:  arguments = [] for key, value in list:     arguments.append('{!s}={!r}'.format(key, value))  ', '.join(arguments)   Context:  def __repr__(self):     """     This method returns a string representation of the object such that eval() can recreate the object.     The class attributes will be ordered     e.g. Class(attribute1='String', attribute2=3)     """     list =[]     for item in vars(self).items():         list.append(item)     list.sort(key=lambda tup: tup[0])      arguments = []     for key, value in list:         arguments.append('{!s}={!r}'.format(key, value))      return '{!s}({!s})'.format(         type(self).__name__,         ', '.join(arguments)     )
Currently, I'm trying to get a method in Python to return a list of zero, one, or two strings to plug into a string formatter, and then pass them to the string method. My code looks something like this:  class PairEvaluator(HandEvaluator):   def returnArbitrary(self):     return ('ace', 'king')  pe = PairEvaluator() cards = pe.returnArbitrary() print('Two pair, {0}s and {1}s'.format(cards))   When I try to run this code, the compiler gives an IndexError: tuple index out of range. How should I structure my return value to pass it as an argument to .format()?
Localisation is isomorphic to a quotient of polynomial ring I am having trouble with the following problem.      Let $R$ be an integral domain, and let $a \in R$ be a non-zero element. Let $D = \{1, a, a^2, ...\}$. I need to show that $R_D \cong R[x]/(ax-1)$.    I just want a hint.  Basically, I've been looking for a surjective homomorphism from $R[x]$ to $R_D$, but everything I've tried has failed. I think the fact that $f(a)$ is a unit, where $f$ is our mapping, is relevant, but I'm not sure. Thanks "Think of" versus "think about" Could someone help me to understand when I should use think of and when think about in sentences?  What is the difference between using one or the other? Can a monk make a bonus unarmed attack after using shocking grasp? I'm playing a 5e Wizard/ Monk build. My DM and I are questioning the viability of the cantrip Shocking Grasp. As a monk I can do another unarmed strike as a bonus action after I attack with a melee attack. Being a touch spell, can I punch (touch) with Shocking Grasp and then do my monk's bonus action? How to automatically fetch missing dependencies when installing software from .deb? Lecturer with anxiety. How to survive in academia? I've been a long time member of academia.SE but I created this alt account because the question is a bit embarrassing. I finished my PhD 4 years ago and after a 2 year postdoc at a different university secured a contractual lecturership. During my PhD I never realised I had fear of public speaking, because I always felt secure presenting in front of my supervisor. Even at conferences, his presence in the audience was enough to keep me relaxed.  Fast forward to my postdoc, I was mostly working and publishing by myself. So, even if I had to present something it was to my coauthors, with which I am okay. But as a lecturer doing research part of my time, I am involved in projects and seminars where I am expected to present my latest work. Being on my own has brought out my inner anxiety, so much so that I choked during a presentation, had to drink water to calm my nerves and apologise for my breathlessness and slurred speech. That was the most embarrasing thing in my life. Please note that the anxiety is not the result of me not publishing or doing research. I have published more than most in my department. Knowing that hasn't helped with the anxiety though. I am constantly making excuses to get out of project presentations and seminar talks. Fortunately, the anxiety is less intense in teaching and I am able to manage.   How do I survive as an academic? Now even conference presentations seem daunting. I can publish exclusively in journals, but how do I get out of giving project and departmental presentations? How can I politely refuse to present without revealing my situation? Or better yet, how do I fix the whole thing? That one bad presentation has really messed me up. Custom ordering of duplicate targets is not necessarily honored on mobile apps Torsion on $\pi_1(X)$, $X$ connected and open in $\mathbb{R}^n$ Can the fundamental group of an open connected subset $X$ of $\mathbb{R}^n$ have a torsion element? Mathematica not plotting whole logarithmic function Volume calculation of truncated cones with elipses as base and top I wish to calculate the volumes of a truncated cone whith asymetry over all axes and ellipses as base and top - how do I do that?  I have height and radii of the corresponding ellipses. (I assume correctly I need the geometric means of the 2 radii describing the ellipsis.)  Kind Regards Can we have a black hole without a singularity? Assuming we have a sufficiently small and massive object such that it's escape velocity is greater than the speed of light, isn't this a black hole? It has an event horizon that light cannot escape, time freezes at this event horizon, etc. However this object is not a singularity.  If a large star's mass were compressed to the size of, say, a proton, it would certainly have these properties but it would still not be a singularity as a proton does have volume.  The reason "physics breaks down" at singularities is because we cannot divide by zero, but as long as the proton-sized object has volume, physics won't "break down", yet we still have an event horizon and an object that is invisible (but not undetectable) from the outside.  I have read the answers to  related question. I'm not sure if they don't address my specific question or if I don't understand the answers. $$ \sum_{i=1}^N\left\lfloor\frac{N}{i}\right\rfloor $$ Is there a closed form expression to the above sum? (Mathematica doesn't give me anything) I accidentally killed the orphanage lady before I started the quest. She just pissed me off, sadly it will not acknowledge that I have finished the quest and I haven't been contacted. Is there another way to join the Dark Brotherhood? How do I parse command line arguments in Java? What is a good way of parsing command line arguments in Java? ResultSet: Retrieving column values by index versus retrieving by label When using JDBC, I often come across constructs like    ResultSet rs = ps.executeQuery(); while (rs.next()) {     int id = rs.getInt(1);     // Some other actions }   I asked myself (and authors of code too) why not to use labels for retrieving column values:    int id = rs.getInt("CUSTOMER_ID");   The best explanation I've heard is something concerning performance. But actually, does it make processing extremely fast? I don't believe so, though I have never performed measurements. Even if retrieving by label would be a bit slower, nevertheless, it provide better readability and flexibility, in my opinion. So could someone give me good explanation of avoiding to retrieve column values by column index instead of column label? What are pros and cons of both approaches (maybe, concerning certain DBMS)? Since my previous questions were not answered I will try to ask again more precisely.  I previously had the Nvidia driver installed and working correctly.  Then the ubuntu software update did something which broke it.  In fact, it completely de-configured it so that the standard display driver is used when the computer reboots.  I would like to re-enable the existing Nvidia  driver without re-installing the Nvidia driver.  How do I do that?  This machine is no longer connected to the internet.  NOTE: I am not asking how to disable automatic updates in this question.  I asked that elsewhere (and it wasn't answered).  NOTE: I am not asking how to stop the Ubuntu software updater from breaking the Nvidia driver the next time it updates the system.  That would be nice to know, but I asked that already and did not receive the correct answer either.  NOTE: Please don't make this as duplicate simply because someone else asked a question about Ubuntu and the software updater.  Try to read the actual question and see how it's different and try to realize how annoying it is when users have to spend hours of their own time to correct the problems that other people causing by incorrectly designing software updaters. Although we didn't do any changes, this new error appeared in the GSC Structured Data section:    I don't really get what it means. There are many fields for Schema.org, is homeLocation suddenly a required field? Does that make any sense? Change font size of the verbatim environment I want to apply small fonts inside the Verbatim environment e.g.  {\small  \begin{Verbatim}  1   double x, y; 2   double z, w; 3   main(); 4   return 0;  \end{Verbatim}}   Before the command \small and after the closing braket } text has normal size, which is obvious but the font size should be small inside the brakets.     Why is this command not applied to the environment's contents? i keep getting the script error problem every time i try using polygon to raster tool in ArcGIS 10.1. Please help me how I can solve this?  screenshot embedded mbstring is missing for phpmyadmin in ubuntu 16.04 When I installed phpmyadmin in Ubuntu 16.04 LTS, it gives me an error mentioned below.     The mbstring extension is missing. Please check your PHP configuration   then I tried to install php-mbstring, it says mbstring is up to date, Can anyone help me to solve this? Are PDO prepared statements sufficient to prevent SQL injection?