"Courageous" <jkraska1 at san.rr.com> wrote ... > On Mon, 23 Apr 2001 18:36:48 -0600, Bjorn Pettersen <BPettersen at NAREX.com> wrote: > > >>>> x = [1,2,3] > >>>> str(x) > >'[1, 2, 3]' > >>>> eval(str(x)) > >[1, 2, 3] > > Not getting it: I want > > s = "abc" > l = list(s) > <something>(l) > "abc" > Well, perhaps if your original enquiry hadn't said """ So. I forget how to do this AGAIN. I know how to convert a string to a list: mylist = str ("alpha") but I don't remember the shorthand for converting it back? """ we might have understood that you really meant mylist=list(alpha). The collective brainpower of c.l.py is indeed impressive, and I have seen the smarter members pull off some pretty amazing feats of psychic response ("the answer to the question you *really* meant to ask is ..."). That doesn't mean you can expect it all the time! > Where something is some expression. The worst part here is that sometime in > the last year, I've asked this very same question before. *IRK* Is this in the FAQ? > It outta be. > How embarrassing! Good for you for confessing ;-) Good for the soul, doncha know... > >>>> s = "a!b%c^" > >>>> import string > >>>> t = string.maketrans(s,s) > >>>> s.translate(t, "!%^") > >'abc' > > Hrm. I read the documentation for string.maketrans() and string.translate() just now. > I don't get it. The documentation doesn't make this clear, and I don't understand > from your example what's going on. While I can see that it works, I don't get the > basic principle. I would think a maketrans of s,s would just translate one character > to the same character. > Part of your cinfusion could be that you are reading the wrong documentation. The translate used above is the translate method of the string type, not the translate function of the string module. Although the reponse could have made that clearer, the clue is that the answer used string.maketrans() but s.translate(). Given this new information, does the example make sense now you understand that the "!%^" argument is specifying delete characters (you do understand that now, right)? > ??? > !!! we're-only-human-(except-the-bots)-you-know-ly y'rs - steve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4