Re: I am out of trial and error again Lists
Rustom Mody rustompm...@gmail.com writes: What would you say to a person who - Buys a Lambhorgini I'd say: Don't buy a Lambhorgini from that nice guy you met at a party, but buy a Lamborghini by an authorized dealer ;-) -- I was a kid when Lamborghini launched the Miura! -- https://mail.python.org/mailman/listinfo/python-list
Side-effects [was Re: I am out of trial and error again Lists]
Chris Angelico wrote: On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody rustompm...@gmail.com wrote: Its generally accepted that side-effecting functions are not a good idea -- typically a function that returns something and changes global state. Only in certain circles. Not in Python. There are large numbers of functions with side effects (mutator methods like list.append, anything that needs lots of state like random.random, everything with external effect like I/O, heaps of stuff), and it is most definitely not frowned upon. Hmmm. You might be overstating it a tad. You are absolutely correct that Python is not a strict functional language with no side-effects. However, mutator methods on a class don't change global state, they change the state of an instance. Even random.random and friends don't change global state, they change a (hidden) instance, and you can create your own instances when needed. That gives you the convenience of pseudo-global state while still allowing the flexibility of having separate instances. Even global variables in Python are global to the module, not global to the entire application. So although Python code isn't entirely side-effect free, the general advice to avoid writing code that relies on global state and operates via side-effect still applies. To take an extreme example, we do this: print(len(something)) not this: LEN_ARGUMENT = something len() print(LEN_RESULT) We *could* write code like that in Python, but as a general rule we don't. If we did, it would be frowned upon. I would say that Python is a pragmatic language which uses whatever idiom seems best at the time, but over all it prefers mutable state for compound objects, prefers immutable state for scalar objects (like numbers), and discourages the unnecessary use of global mutable state. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Side-effects [was Re: I am out of trial and error again Lists]
On Sun, Oct 26, 2014 at 5:12 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: However, mutator methods on a class don't change global state, they change the state of an instance. Even random.random and friends don't change global state, they change a (hidden) instance, and you can create your own instances when needed. That gives you the convenience of pseudo-global state while still allowing the flexibility of having separate instances. Even global variables in Python are global to the module, not global to the entire application. True, but they do still change state; I oversimplified a bit, but certainly there are plenty of functions that change state in some way, and are not frowned upon. Module level variables really are global, though. You can't easily and conveniently reinstantiate a module in Python; if you import random; random.seed(1234), you can confidently expect that some other module that uses random.random will be affected. Sure, there are ways around that, but that's true of any form of global state - for a start, it's usually process level state, in that spawning a new process will isolate one from another. The only thing that isn't truly global is the namespace; I can write x = {} and you can write x = [] and they don't collide. They're still global (process-level), it's just that they're foo.x and bar.x and are thus distinct. I would say that Python is a pragmatic language which uses whatever idiom seems best at the time, but over all it prefers mutable state for compound objects, prefers immutable state for scalar objects (like numbers), and discourages the unnecessary use of global mutable state. It's not really compound vs scalar, but yes, I agree. Practicality beats purity, on so many levels. Functions with side effects aren't considered some sort of weird beast that we have to permit for the sake of I/O; they're a fundamental part of the language. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/26/2014 1:08 AM, Dennis Lee Bieber wrote: On Sat, 25 Oct 2014 18:48:59 -0400, Terry Reedy tjre...@udel.edu declaimed the following: C:\Users\Wulfraed\Documentspython3 You must have done something extra to make this work on Windows. Possibly hand-edited my system PATH -- I've got a rather nasty one (inserting line breaks)... I was referring to the existence of 'python3' (and 'python2'). I presume these are created by the ActiveState installer that you said you used. There are not created by the PSF Windows installer. It instead creates 'py' linked to the new launcher; 'py -2' and 'py -3' launch the latest available python 2 or python3. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote: On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody wrote: Its generally accepted that side-effecting functions are not a good idea -- typically a function that returns something and changes global state. Only in certain circles. Not in Python. There are large numbers of functions with side effects (mutator methods like list.append, anything that needs lots of state like random.random, everything with external effect like I/O, heaps of stuff), and it is most definitely not frowned upon. In Python 3 (or Python 2 with the future directive), print is a function, print() an expression. It's not semantically a statement. Ok So give me a valid (ie useful) use where instead of the usual l=[1,2,3] l.append(4) we have foo(l.append(4)) -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 4:55 PM, Rustom Mody rustompm...@gmail.com wrote: So give me a valid (ie useful) use where instead of the usual l=[1,2,3] l.append(4) we have foo(l.append(4)) Given that l.append(4) will always return None, there's not a lot of point passing that return value to something, unless you're doing this inside a lambda or something dumb like that. It won't be Pythonic. Your point? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/24/2014 09:37 AM, Seymore4Head wrote: snip import string Not needed, delete it. def nametonumber(name): lst=[] nx=[] digit=[] Not needed. You create digit as an empty list, them immediately follow by assigning a string to it (NOT a _list_ of characters, but an actual string.) digit=.join(str(i) for i in range(10)) digit is now the _string_ 0123456789. Actually, a direct assignment here would be easier and shorter; digit = 0123456789 for x in name: lst.append(x) lst is now a list of the characters in name. That works, but you can do the same thing with: lst = list(name) for y in (lst): Parentheses not needed. if y in lst(range(1,10)): This is the line the traceback is referring to. lst is a list, but the parentheses tell Python you are trying to call it as a function. That is what the TypeError: 'list' object is not callable means. Also it seems you are now trying to make a list of the digits 1-9 without the zero. Is this what you want? I don't think so, but if that IS what you want you can do it easier with slicing (look it up, VERY useful): (Remember, digit is already a string of the ten digits, with zero as the first character.) if y in digit[1:]: Otherwise if you do want zero included you simply need: if y in digit: #if y in 1234567890: #if y.isdigit(): #if y in digit: All of those should work, with the zero. #if y in string.digits: Ok (I think?), but the string module is effectively obsolete -- most of its capabilities have been replaced with newer, better string methods. It is RARELY useful. I have never used it myself so don't know too much about it. It is definitely not needed here, and is why I suggested deleting the import. nx.append(y) ... -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/24/2014 12:07 PM, Seymore4Head wrote: On Fri, 24 Oct 2014 19:40:39 +0100, Mark Lawrence snip How many more times, state what you expect to happen and what actually happens. doesn't work is useless. Please read this http://sscce.org/ Good suggestion. OK how is this? It doesn't print what I expect. That is NO different from the useless crap you consistently give us! Tell us EXACTLY WHAT YOU EXPECT!! Does it print what you expect? Yes it does. But what I expect is different from what you (erroneously) expect. name=123-xyz-abc for x in name: if x in range(10): x is a character (a one-element string). range(10) is a list of ints. A string will never match an int. BTW, as it is used here, range(10) is for Py2, for Py3 it needs to be list(range(10)). print (Range,(x)) if x in str(range(10)): Once again, find out what str(range(10)) actually is. It is NOT what you think it is. And I'll reiterate what everyone here keeps telling you: USE THE INTERACTIVE MODE to see what really goes on. If you keep resisting this you are making your understanding several hundred times more difficult. print (String range,(x)) Sorry for the harsh tone. I'm old, and the curmudgeon is starting to come out in me. -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 25/10/2014 03:41, Seymore4Head wrote: On Fri, 24 Oct 2014 19:16:21 -0700, Larry Hudson org...@yahoo.com wrote: On 10/24/2014 07:38 AM, Seymore4Head wrote: snip I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. So it is a pain to actually load Python 2. Exactly HOW are you trying to run Idle? A default install of Py2 and Py3 in Windows should have also installed Idle for each version. In my Win7 system, they are BOTH in the standard menu, you should be able to call up either one. OT: Side comment: I rarely use Windows these days, maybe once every two or three months -- I MUCH prefer Linux. Among other reasons its a far better environment for programming. I only have one (active) system with Windows installed, and two others with Linux only. Actually make that three, if you count my Raspberry Pi. :-) -=- Larry -=- I have a directory of my py files. I right click on one of the py files and open with IDLE Windows XP If I try to open a py file I have for Python 2 it still opens using IDLE 3. I don't have many py 2 files anyway. How about running your Python 2 version of IDLE and opening your files using File-Open or CTRL-O? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
Rustom Mody wrote: On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote: On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody wrote: Its generally accepted that side-effecting functions are not a good idea -- typically a function that returns something and changes global state. Only in certain circles. Not in Python. There are large numbers of functions with side effects (mutator methods like list.append, anything that needs lots of state like random.random, everything with external effect like I/O, heaps of stuff), and it is most definitely not frowned upon. In Python 3 (or Python 2 with the future directive), print is a function, print() an expression. It's not semantically a statement. Ok So give me a valid (ie useful) use where instead of the usual l=[1,2,3] l.append(4) we have foo(l.append(4)) Your question seems to be non-sequitor. To me, it doesn't appear to have any relationship to Chris' comments. But to answer your question, Ruby has mutator methods like list.append return the list being mutated, to make it easy to chain multiple calls: l.append(4).reverse().sort() That would make it easy and convenient to modify a list immediately pass the modified list to a function and embed it in an expression: # Python's way l.append(4) values = [1, 2, foo(l), 3] # Pseudo-Ruby way values = [1, 2, foo(l.append(4)), 3] Languages where all values are immutable *by definition* have to return a new list, since you can't modify the original, hence they too can easily be embedded in an expression. Many people try to write something like this: old_lists = [a, b, c, d] new_lists = [thelist.append(x) for thelist in old_lists if len(thelist) 5] only to be unpleasantly surprised to discover than new_lists now contains None instead of the lists. Having methods return a result rather than behave like a procedure is a valid (i.e. useful) design choice. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 12:46 AM, Larry Hudson org...@yahoo.com.dmarc.invalid wrote: name=123-xyz-abc for x in name: if x in range(10): x is a character (a one-element string). range(10) is a list of ints. A string will never match an int. BTW, as it is used here, range(10) is for Py2, for Py3 it needs to be list(range(10)). The last comment is incorrect. You can do membership tests on a Python 3 range object: range(2, 4) range(2, 4) for i in range(5): ... print(i, i in range(2, 4)) ... 0 False 1 False 2 True 3 True 4 False You can also index them: range(50, 100)[37] 87 slice them: range(0, 100, 2)[:25] range(0, 50, 2) get their length: len(range(25, 75)) 50 search them: range(25, 75).index(45) 20 and generally do most operations that you would expect to be able to do with an immutable sequence type, with the exceptions of concatenation and multiplication. And as I observed elsewhere in the thread, such operations are often more efficient on range objects than by constructing and operating on the equivalent lists. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 2014-10-24, Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: Thanks everyone for your suggestions. Try loading the following in codeskulptor: http://www.codeskulptor.org/#user38_j6kGKgeOMr_0.py No. We[1] aren't intested in whatever Python-like language is implemented in codeskulptor. [1] I know I'm being a bit presumptuous writing the the plural first person rather than the signular. If you _are_ interested in codeskulptor python then jump in... -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 1:15:09 PM UTC+5:30, Steven D'Aprano wrote: Rustom Mody wrote: On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote: On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody wrote: Its generally accepted that side-effecting functions are not a good idea -- typically a function that returns something and changes global state. Only in certain circles. Not in Python. There are large numbers of functions with side effects (mutator methods like list.append, anything that needs lots of state like random.random, everything with external effect like I/O, heaps of stuff), and it is most definitely not frowned upon. In Python 3 (or Python 2 with the future directive), print is a function, print() an expression. It's not semantically a statement. Ok So give me a valid (ie useful) use where instead of the usual l=[1,2,3] l.append(4) we have foo(l.append(4)) Your question seems to be non-sequitor. To me, it doesn't appear to have any relationship to Chris' comments. I am going to leave undisturbed Seymore's thread for whom these nit-picks are unlikely to be helpful Answer in another one -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, 25 Oct 2014 14:23:44 -0400, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head Seymore4Head@Hotmail.invalid declaimed the following: I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. So it is a pain to actually load Python 2. So don't use Idle... Open up a Windows command shell and invoke Python without giving a script file to execute. C:\Users\Wulfraed\Documentspython ActivePython 2.7.5.6 (ActiveState Software Inc.) based on Python 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. exit() C:\Users\Wulfraed\Documentspython3 ActivePython 3.3.2.0 (ActiveState Software Inc.) based on Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. exit() C:\Users\Wulfraed\Documents Note that my default Python is still 2.7, but I also have Python 3.3 installed, and can access it using python3 (I can also ensure Python 2.7 by using python2) I tried list(range(10) I thought that would work in Python 3. It didn't. I spent quite a bit of time last night trying to come up with Really? what did it do? SHOW US! C:\Users\Wulfraed\Documentspython3 ActivePython 3.3.2.0 (ActiveState Software Inc.) based on Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print(list(range(10))) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] repr(list(range(10))) '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' Recall that print is a function in Python 3, so the extra layer of () are required. C:\Users\Wulfraed\Documentspython ActivePython 2.7.5.6 (ActiveState Software Inc.) based on Python 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print(list(range(10))) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] repr(list(range(10))) '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' Print doesn't need the (), but they also don't hurt it in Python 2. (still in Py2) range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] xrange(10) xrange(10) print range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print xrange(10) xrange(10) exit Use exit() or Ctrl-Z plus Return to exit exit() Now Py3 C:\Users\Wulfraed\Documentspython3 ActivePython 3.3.2.0 (ActiveState Software Inc.) based on Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. range(10) range(0, 10) xrange(10) Traceback (most recent call last): File stdin, line 1, in module NameError: name 'xrange' is not defined print(range(10)) range(0, 10) I am not working on that any more. I have my assignment for this week so I am done with busy work. Thanks for all your help -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, 25 Oct 2014 15:01:54 +, Grant Edwards wrote: On 2014-10-24, Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: Thanks everyone for your suggestions. Try loading the following in codeskulptor: http://www.codeskulptor.org/#user38_j6kGKgeOMr_0.py No. I wasn't replying to you, I was replying to S4H. We[1] aren't intested in whatever Python-like language is implemented in codeskulptor. However S4H may be, and one thing I can be sure is that if I give him a cs url, he will at least be running the exact same python code I typed in the same python environment, and hence I know what results he should see, namely the same ones I saw. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 20:15:02 -0400, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: name=012 name is a string of 3 characters b=list(range(3)) b is a list of 3 numbers print (name[1]) name[1] is the string 1 print (b[1]) b[1] is the number 1 if name[1] == b[1]: print (Eureka!) This didn't happen else: print (OK, I get it) This happened -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/25/2014 2:23 PM, Dennis Lee Bieber wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head Seymore4Head@Hotmail.invalid declaimed the following: I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. This is wrong. Pythonx.y runs Idlex.y, not vice versa. Seymore installed some version of Python 3 as default, as he should have, and 'Edit with Idle' opens the default version of Python, with its version of Idle. So it is a pain to actually load Python 2. Not really, neither on linux or Windows. So don't use Idle... Since Seymore analysis is wrong, this advice in not the answer. If he is running on Windows, it is dubious in that the Windows console interpreter is a pain to use. Open up a Windows command shell and invoke Python without giving a script file to execute. C:\Users\Wulfraed\Documentspython python -m idlelib will open the corresponding Idle. So will the Start menu entry or an icon pinned to the taskbar. C:\Users\Wulfraed\Documentspython3 You must have done something extra to make this work on Windows. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 25/10/2014 23:48, Terry Reedy wrote: On 10/25/2014 2:23 PM, Dennis Lee Bieber wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head Seymore4Head@Hotmail.invalid declaimed the following: I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. This is wrong. Pythonx.y runs Idlex.y, not vice versa. Seymore installed some version of Python 3 as default, as he should have, and 'Edit with Idle' opens the default version of Python, with its version of Idle. So it is a pain to actually load Python 2. Not really, neither on linux or Windows. So don't use Idle... Since Seymore analysis is wrong, this advice in not the answer. If he is running on Windows, it is dubious in that the Windows console interpreter is a pain to use. Open up a Windows command shell and invoke Python without giving a script file to execute. C:\Users\Wulfraed\Documentspython python -m idlelib will open the corresponding Idle. So will the Start menu entry or an icon pinned to the taskbar. C:\Users\Wulfraed\Documentspython3 You must have done something extra to make this work on Windows. The Python launcher for Windows should be taken into account here http://legacy.python.org/dev/peps/pep-0397/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 22/10/2014 21:30, Seymore4Head wrote: def nametonumber(name): lst=[] for x,y in enumerate (name): lst=lst.append(y) print (lst) return (lst) a=[1-800-getcharter] print (nametonumber(a))#18004382427837 The syntax for when to use a () and when to use [] still throws me a curve. For now, I am trying to end up with a list that has each character in a as a single item. I get: None None Following on from the numerous responses you've had here, I've no idea if this helps your thought processes but there's only one way for you to find out http://www.greenteapress.com/thinkpython/ :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 24/10/2014 08:05, Mark Lawrence wrote: On 22/10/2014 21:30, Seymore4Head wrote: def nametonumber(name): lst=[] for x,y in enumerate (name): lst=lst.append(y) print (lst) return (lst) a=[1-800-getcharter] print (nametonumber(a))#18004382427837 The syntax for when to use a () and when to use [] still throws me a curve. For now, I am trying to end up with a list that has each character in a as a single item. I get: None None Following on from the numerous responses you've had here, I've no idea if this helps your thought processes but there's only one way for you to find out http://www.greenteapress.com/thinkpython/ :) And another http://tinyurl.com/k26vjhr -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Thu, 23 Oct 2014 21:56:31 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: On Thursday, October 23, 2014 10:33:57 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 15:55:35 + (UTC), Denis McMahon wrote: On Thu, 23 Oct 2014 10:04:56 -0400, Seymore4Head wrote: On Thu, 23 Oct 2014 09:15:16 + (UTC), Denis McMahon wrote: Try the following 3 commands at the console: You obviously didn't, so I'll try again. Try each of the following three commands in the python console at the prompt. 1) 10 10 2) range(10) range(0, 10) 3) str(range(10)) 'range(0, 10)' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Show *and* describe the output in each case. Describing the output that you see is actually the key here, as it will allow us to assess whether you understand what you are actually seeing or not, and if you don't understand the output you see in the console, then we need to fix that very fundamental and basic issue before moving on to more complex stuff! Ok Thanks You were expected to answer the question in the original. I have now set it as a clearer and more specific task. If you're not going to do these things that are intended to help you learn some of the basic features of the language, then I and everyone else here that has so far been attempting to help you are wasting our time. I did try them. I may have missed replying your to your specific comment, but I tried them. BTW str(range (10)) does work with Python 2 which is where I may have got the idea. I happened to be using Python 3 at the time I tried to implement it. It is a little confusing jumping back and forth, but for the moment, I am going to tough it out. I do appreciate all the help too. Hi Seymore! Happy to see that you are moving on from reading much; understanding nothing; thrashing to reading a bit; understanding a bit [And thanks to Denis to getting you out of your confusion-hole] So heres a small additional question set that I promise will more than repay you your time. Better done in python 2. But if you use python3, below replace range(10) with list(range(10)) So now in the python console, please try a. range(10) and b. print (range(10)) And then post back (without consulting google!!)¹ 1. Are they same or different? 2. If same, how come different expressions are same? 3. If different whats the difference? 4. [Most important]: When would you prefer which? = ¹ Actually its ok to consult google AFTER you try I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. So it is a pain to actually load Python 2. Range(10) stores the min max values and loads each number in between when needed. Ian explained that very clearly. I tried list(range(10) I thought that would work in Python 3. It didn't. I spent quite a bit of time last night trying to come up with the right combination of str and int commands to make range(10) work with my simple example. It didn't. I am pretty frustrated. I am just skipping that little bit of code for the moment. Thanks everyone for your suggestions. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 08:05:01 +0100, Mark Lawrence breamore...@yahoo.co.uk wrote: On 22/10/2014 21:30, Seymore4Head wrote: def nametonumber(name): lst=[] for x,y in enumerate (name): lst=lst.append(y) print (lst) return (lst) a=[1-800-getcharter] print (nametonumber(a))#18004382427837 The syntax for when to use a () and when to use [] still throws me a curve. For now, I am trying to end up with a list that has each character in a as a single item. I get: None None Following on from the numerous responses you've had here, I've no idea if this helps your thought processes but there's only one way for you to find out http://www.greenteapress.com/thinkpython/ :) I have at least 10 ebooks. I will get around to reading them soon. http://i.imgur.com/rpOcKP8.jpg Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 1:38 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: I tried list(range(10) I thought that would work in Python 3. It didn't. This is your problem: You say it didn't work. That is almost *never* the right thing to say or to think. What happened when you tried that? Did you get a SyntaxError because of the omitted close parenthesis? Did the interpreter prompt for more input? Did a velociraptor come out of nowhere and try to kill you [1]? When you come back to python-list, you should say exactly what you did and exactly what happened, not I tried X and it didn't work. Copy and paste from your interactive session - do NOT retype, because you introduce new errors. It's very hard to help you when you don't explain what you're doing, and just keep on telling us how frustrated you are. ChrisA [1] http://xkcd.com/292/ -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 09:12:28 +0100, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/10/2014 08:05, Mark Lawrence wrote: On 22/10/2014 21:30, Seymore4Head wrote: def nametonumber(name): lst=[] for x,y in enumerate (name): lst=lst.append(y) print (lst) return (lst) a=[1-800-getcharter] print (nametonumber(a))#18004382427837 The syntax for when to use a () and when to use [] still throws me a curve. For now, I am trying to end up with a list that has each character in a as a single item. I get: None None Following on from the numerous responses you've had here, I've no idea if this helps your thought processes but there's only one way for you to find out http://www.greenteapress.com/thinkpython/ :) And another http://tinyurl.com/k26vjhr Google. I have heard of that. :) -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, 25 Oct 2014 01:51:41 +1100, Chris Angelico ros...@gmail.com wrote: On Sat, Oct 25, 2014 at 1:38 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: I tried list(range(10) I thought that would work in Python 3. It didn't. This is your problem: You say it didn't work. That is almost *never* the right thing to say or to think. What happened when you tried that? Did you get a SyntaxError because of the omitted close parenthesis? Did the interpreter prompt for more input? Did a velociraptor come out of nowhere and try to kill you [1]? I understand that it makes it easier for you if I can describe better the error I get, but by the time I ask for help here I have tried many different things to get the error to go away. I will try in the future to do better at this. For now, I am just putting that exercise behind me. I do try to find out how to do things before asking first. I tried so many things last night, I had to go back to an old message to get code that worked again. Thanks When you come back to python-list, you should say exactly what you did and exactly what happened, not I tried X and it didn't work. Copy and paste from your interactive session - do NOT retype, because you introduce new errors. It's very hard to help you when you don't explain what you're doing, and just keep on telling us how frustrated you are. ChrisA [1] http://xkcd.com/292/ -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 2:04 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: I understand that it makes it easier for you if I can describe better the error I get, but by the time I ask for help here I have tried many different things to get the error to go away. That's part of the problem. You let yourself get frustrated and confused, and you still have no idea what you're doing. Ask sooner, if you have to; or develop the discipline to keep track of what you do and what happens. But regardless of what actually happens, it didn't work is not a helpful thing to say. Trust me, making it easier for us will make everything easier for you too. Even if we were to never answer a single question of yours ever again, learning to read error messages will benefit you more than you can imagine. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 8:11:12 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 21:56:31 -0700 (PDT), Rustom Mody wrote: On Thursday, October 23, 2014 10:33:57 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 15:55:35 + (UTC), Denis McMahon wrote: On Thu, 23 Oct 2014 10:04:56 -0400, Seymore4Head wrote: On Thu, 23 Oct 2014 09:15:16 + (UTC), Denis McMahon wrote: Try the following 3 commands at the console: You obviously didn't, so I'll try again. Try each of the following three commands in the python console at the prompt. 1) 10 10 2) range(10) range(0, 10) 3) str(range(10)) 'range(0, 10)' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Show *and* describe the output in each case. Describing the output that you see is actually the key here, as it will allow us to assess whether you understand what you are actually seeing or not, and if you don't understand the output you see in the console, then we need to fix that very fundamental and basic issue before moving on to more complex stuff! Ok Thanks You were expected to answer the question in the original. I have now set it as a clearer and more specific task. If you're not going to do these things that are intended to help you learn some of the basic features of the language, then I and everyone else here that has so far been attempting to help you are wasting our time. I did try them. I may have missed replying your to your specific comment, but I tried them. BTW str(range (10)) does work with Python 2 which is where I may have got the idea. I happened to be using Python 3 at the time I tried to implement it. It is a little confusing jumping back and forth, but for the moment, I am going to tough it out. I do appreciate all the help too. Hi Seymore! Happy to see that you are moving on from reading much; understanding nothing; thrashing to reading a bit; understanding a bit [And thanks to Denis to getting you out of your confusion-hole] So heres a small additional question set that I promise will more than repay you your time. Better done in python 2. But if you use python3, below replace range(10) with list(range(10)) Other details skipped I tried list(range(10) I thought that would work in Python 3. It didn't. I spent quite a bit of time last night trying to come up with the right combination of str and int commands to make range(10) work with my simple example. It didn't. I am pretty frustrated. I am just skipping that little bit of code for the moment. I asked you to try list(range(10)) Did you try EXACTLY (cut-paste) that? You are claiming to have tried list(range(10) Thats one closing parenthesis less The interaction with your version would go something like this: [Two versions The KeyboardInterrupt comes from giving a control-C Dunno what happens in codeskulptor ] list(range(10) ... ... ... ... ) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list(range(10) ... KeyboardInterrupt Thanks everyone for your suggestions. 1. You are reading too much 2. Trying to hard Think of riding a bicycle. Cant do it by reading many books on cycling -- thats 1. Nor by holding the handle so hard you tremble -- thats 2. Just relax a bit... And take small steps Chill... as Chris joked, no monster in the computer (or on this list!) Range(10) stores the min max values and loads each number in between when needed. It loads?? As in 'load-up-a-van'?? When you see: 10 10 1. Does someone (a clerk maybe) in the computer count to 10? 2. Or do you, seeing that interaction, count to 10? [If you do, replace the 10 by 1000] 3. Or do you, remember what it means to count to 10 without having to do it? Now go back to your statement about 'loading' and find a better verb -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
ERRATA CORRIGE: many different circumstances, by the very, very helpful folks of clp. many different circumstances, by the very, very helpful folks of clpy -- sapete contare fino a venticinque? Olimpia Milano Jugoplastika Split Partizan Beograd Roberto Premier Duska Ivanovic Zarko Paspalj -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, Oct 24, 2014 at 9:56 AM, Rustom Mody rustompm...@gmail.com wrote: Range(10) stores the min max values and loads each number in between when needed. It loads?? As in 'load-up-a-van'?? As in loads into memory. When you see: 10 10 1. Does someone (a clerk maybe) in the computer count to 10? 2. Or do you, seeing that interaction, count to 10? [If you do, replace the 10 by 1000] 3. Or do you, remember what it means to count to 10 without having to do it? I don't understand why you think any of these are implied by the word load. Now go back to your statement about 'loading' and find a better verb I presume he used load because that was the word I used in my explanatory post about the difference between range in Python 2 and Python 3 yesterday. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 08:56:31 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: On Friday, October 24, 2014 8:11:12 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 21:56:31 -0700 (PDT), Rustom Mody wrote: On Thursday, October 23, 2014 10:33:57 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 15:55:35 + (UTC), Denis McMahon wrote: On Thu, 23 Oct 2014 10:04:56 -0400, Seymore4Head wrote: On Thu, 23 Oct 2014 09:15:16 + (UTC), Denis McMahon wrote: Try the following 3 commands at the console: You obviously didn't, so I'll try again. Try each of the following three commands in the python console at the prompt. 1) 10 10 2) range(10) range(0, 10) 3) str(range(10)) 'range(0, 10)' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Show *and* describe the output in each case. Describing the output that you see is actually the key here, as it will allow us to assess whether you understand what you are actually seeing or not, and if you don't understand the output you see in the console, then we need to fix that very fundamental and basic issue before moving on to more complex stuff! Ok Thanks You were expected to answer the question in the original. I have now set it as a clearer and more specific task. If you're not going to do these things that are intended to help you learn some of the basic features of the language, then I and everyone else here that has so far been attempting to help you are wasting our time. I did try them. I may have missed replying your to your specific comment, but I tried them. BTW str(range (10)) does work with Python 2 which is where I may have got the idea. I happened to be using Python 3 at the time I tried to implement it. It is a little confusing jumping back and forth, but for the moment, I am going to tough it out. I do appreciate all the help too. Hi Seymore! Happy to see that you are moving on from reading much; understanding nothing; thrashing to reading a bit; understanding a bit [And thanks to Denis to getting you out of your confusion-hole] So heres a small additional question set that I promise will more than repay you your time. Better done in python 2. But if you use python3, below replace range(10) with list(range(10)) Other details skipped I tried list(range(10) I thought that would work in Python 3. It didn't. I spent quite a bit of time last night trying to come up with the right combination of str and int commands to make range(10) work with my simple example. It didn't. I am pretty frustrated. I am just skipping that little bit of code for the moment. I asked you to try list(range(10)) Did you try EXACTLY (cut-paste) that? You are claiming to have tried list(range(10) Thats one closing parenthesis less The interaction with your version would go something like this: [Two versions The KeyboardInterrupt comes from giving a control-C Dunno what happens in codeskulptor ] list(range(10) ... ... ... ... ) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list(range(10) ... KeyboardInterrupt Thanks everyone for your suggestions. 1. You are reading too much 2. Trying to hard Think of riding a bicycle. Cant do it by reading many books on cycling -- thats 1. Nor by holding the handle so hard you tremble -- thats 2. Just relax a bit... And take small steps Chill... as Chris joked, no monster in the computer (or on this list!) Range(10) stores the min max values and loads each number in between when needed. It loads?? As in 'load-up-a-van'?? When you see: 10 10 1. Does someone (a clerk maybe) in the computer count to 10? 2. Or do you, seeing that interaction, count to 10? [If you do, replace the 10 by 1000] 3. Or do you, remember what it means to count to 10 without having to do it? Now go back to your statement about 'loading' and find a better verb If I could explain to you why something doesn't work then I could fix it myself. I don't understand why it doesn't work. The best I can do is repost the code. When I use list(range(10)) I get: Traceback (most recent call last): File C:/Functions/name to number digit.py, line 37, in module print (nametonumber(a))#1800 438 2427 837 File C:/Functions/name to number digit.py, line 10, in nametonumber if y in lst(range(1,10)): TypeError: 'list' object is not callable All the lines I have commented out work. Trying to use list(range(10)) doesn't. (Python 3) http://i.imgur.com/LtiCyZS.jpg It doesn't work. It's broke. :) I don't know what else to say. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in lst(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -():
Re: I am out of trial and error again Lists
- On Fri, Oct 24, 2014 5:56 PM CEST Rustom Mody wrote: On Friday, October 24, 2014 8:11:12 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 21:56:31 -0700 (PDT), Rustom Mody wrote: On Thursday, October 23, 2014 10:33:57 PM UTC+5:30, Seymore4Head wrote: On Thu, 23 Oct 2014 15:55:35 + (UTC), Denis McMahon wrote: On Thu, 23 Oct 2014 10:04:56 -0400, Seymore4Head wrote: On Thu, 23 Oct 2014 09:15:16 + (UTC), Denis McMahon wrote: Try the following 3 commands at the console: You obviously didn't, so I'll try again. Try each of the following three commands in the python console at the prompt. 1) 10 10 2) range(10) range(0, 10) 3) str(range(10)) 'range(0, 10)' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Show *and* describe the output in each case. Describing the output that you see is actually the key here, as it will allow us to assess whether you understand what you are actually seeing or not, and if you don't understand the output you see in the console, then we need to fix that very fundamental and basic issue before moving on to more complex stuff! Ok Thanks You were expected to answer the question in the original. I have now set it as a clearer and more specific task. If you're not going to do these things that are intended to help you learn some of the basic features of the language, then I and everyone else here that has so far been attempting to help you are wasting our time. I did try them. I may have missed replying your to your specific comment, but I tried them. BTW str(range (10)) does work with Python 2 which is where I may have got the idea. I happened to be using Python 3 at the time I tried to implement it. It is a little confusing jumping back and forth, but for the moment, I am going to tough it out. u0_a100@condor_umts:/ $ python Python 3.2.2 (default, Jun 23 2014, 00:13:13) [GCC 4.8] on linux-armv7l Type help, copyright, credits or license for more information. list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] I do appreciate all the help too. Hi Seymore! Happy to see that you are moving on from reading much; understanding nothing; thrashing to reading a bit; understanding a bit [And thanks to Denis to getting you out of your confusion-hole] So heres a small additional question set that I promise will more than repay you your time. Better done in python 2. But if you use python3, below replace range(10) with list(range(10)) Other details skipped 1. You are reading too much 2. Trying to hard Think of riding a bicycle. Cant do it by reading many books on cycling -- thats 1. Nor by holding the handle so hard you tremble -- thats 2. Just relax a bit... And take small steps Chill... as Chris joked, no monster in the computer (or on this list!) +1 for that remark. Talking about chill: grab a couple of beers (suggest: sixpack) and enjoy an evening of Python! -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 3:37 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: When I use list(range(10)) I get: Traceback (most recent call last): File C:/Functions/name to number digit.py, line 37, in module print (nametonumber(a))#1800 438 2427 837 File C:/Functions/name to number digit.py, line 10, in nametonumber if y in lst(range(1,10)): TypeError: 'list' object is not callable Now, finally, you're showing us an actual line of code and an actual traceback. And from here, we can see that you misspelled list. That's why it isn't working. Several people have told you to use the interactive interpreter. Please do so. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
Totally befuddled myself! Are you deliberately misspelling list to lst and hoping the error will go away. And Puh LEESE dont post screen shots of good ol ASCII text -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 10:18:12 PM UTC+5:30, Chris Angelico wrote: On Sat, Oct 25, 2014 at 3:37 AM, Seymore4Head wrote: When I use list(range(10)) I get: Traceback (most recent call last): File C:/Functions/name to number digit.py, line 37, in module print (nametonumber(a))#1800 438 2427 837 File C:/Functions/name to number digit.py, line 10, in nametonumber if y in lst(range(1,10)): TypeError: 'list' object is not callable Now, finally, you're showing us an actual line of code and an actual traceback. And from here, we can see that you misspelled list. That's why it isn't working. Several people have told you to use the interactive interpreter. Please do so. ChrisA Right. Good. Sorry for being impatient Seymore You are now making progress -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, Oct 24, 2014 at 10:37 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: If I could explain to you why something doesn't work then I could fix it myself. I don't understand why it doesn't work. The best I can do is repost the code. You don't need to be able to explain why it doesn't work. You just need to be able to explain what you expected it to do and what it actually did. Posting the code and the traceback that you get is a fine start. if y in lst(range(1,10)): The name of the builtin is list. It's a function* that takes an argument and uses it to construct a list, which it returns. lst is the name of some specific list that you're using in your code. It's not a function, which is why the error is complaining that it isn't callable. *Actually it's a type object, and calling it causes an instance of the type to be constructed, but for all intents and purposes here it works exactly like a function. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, 25 Oct 2014 03:47:51 +1100, Chris Angelico ros...@gmail.com wrote: On Sat, Oct 25, 2014 at 3:37 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: When I use list(range(10)) I get: Traceback (most recent call last): File C:/Functions/name to number digit.py, line 37, in module print (nametonumber(a))#1800 438 2427 837 File C:/Functions/name to number digit.py, line 10, in nametonumber if y in lst(range(1,10)): TypeError: 'list' object is not callable Now, finally, you're showing us an actual line of code and an actual traceback. And from here, we can see that you misspelled list. That's why it isn't working. Several people have told you to use the interactive interpreter. Please do so. ChrisA Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 09:54:23 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: Totally befuddled myself! Are you deliberately misspelling list to lst and hoping the error will go away. And Puh LEESE dont post screen shots of good ol ASCII text I didn't do that on purpose. I make a lot of typing mistakes. Sorry -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 10:06:47 PM UTC+5:30, Ian wrote: On Fri, Oct 24, 2014 at 9:56 AM, Rustom Mody wrote: Range(10) stores the min max values and loads each number in between when needed. It loads?? As in 'load-up-a-van'?? As in loads into memory. When you see: 10 10 1. Does someone (a clerk maybe) in the computer count to 10? 2. Or do you, seeing that interaction, count to 10? [If you do, replace the 10 by 1000] 3. Or do you, remember what it means to count to 10 without having to do it? I don't understand why you think any of these are implied by the word load. Now go back to your statement about 'loading' and find a better verb I presume he used load because that was the word I used in my explanatory post about the difference between range in Python 2 and Python 3 yesterday. I would be very surprised (Ian) if we had any essential disagreement on this subject. [JFTR I see nothing wrong with your explanation] I would also be (pleasantly) surprised if Seymore were to benefit by these discussions at this stage. So is it ok if we drop it here (or start a new thread)? -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 4:05 AM, Ian Kelly ian.g.ke...@gmail.com wrote: The name of the builtin is list. It's a function* that takes an argument and uses it to construct a list, which it returns. *Actually it's a type object, and calling it causes an instance of the type to be constructed, but for all intents and purposes here it works exactly like a function. It's callable, that's all that matters. callable(object) - bool Return whether the object is callable (i.e., some kind of function). :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 19:03:47 +0200, Seymore4Head Seymore4Head@hotmail.invalid wrote: http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. It's what's on the left hand side of your screenshot. You can simply type Python statements following the prompt and hit enter to examine the result, instead of pushing F5 to run your code -- Vriendelijke groeten / Kind regards, Albert Visser Using Opera's mail client: http://www.opera.com/mail/ -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 10:37:45 PM UTC+5:30, Seymore4Head wrote: On Fri, 24 Oct 2014 09:54:23 -0700 (PDT), Rustom Mody wrote: Totally befuddled myself! Are you deliberately misspelling list to lst and hoping the error will go away. And Puh LEESE dont post screen shots of good ol ASCII text I didn't do that on purpose. I make a lot of typing mistakes. Sorry Right No sweat! I was genuinely asking: - Did you mis-spell list as lst? - Or did you go thrashing (Steven gave a picturesque description) just changing things until the error went? [Believe you me, I do the same when I am in a strange place and I am searching for something in my (suit|brief)case ] -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 19:18:12 +0200, Albert Visser albert.vis...@gmail.com wrote: On Fri, 24 Oct 2014 19:03:47 +0200, Seymore4Head Seymore4Head@hotmail.invalid wrote: http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. It's what's on the left hand side of your screenshot. You can simply type Python statements following the prompt and hit enter to examine the result, instead of pushing F5 to run your code I guess I am confusing the Interpreter with the debugger. Someone suggested I use the Interpreter to step through line by line. I don't know how to do that. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 10:55:44 PM UTC+5:30, Seymore4Head wrote: On Fri, 24 Oct 2014 19:18:12 +0200, Albert Visser wrote: On Fri, 24 Oct 2014 19:03:47 +0200, Seymore4Head wrote: http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. It's what's on the left hand side of your screenshot. You can simply type Python statements following the prompt and hit enter to examine the result, instead of pushing F5 to run your code I guess I am confusing the Interpreter with the debugger. Someone suggested I use the Interpreter to step through line by line. I don't know how to do that. Dont bother with the debugger just yet. For most python programmers, sticking a few print statements (expressions in python 3) in adroitly is good enough.* For now best if you concentrate on 1. What are the features of python -- the language 2. What are the standard data types and functions -- the libraries 3. How to use and jump between the two windows of your screenshot most effectively. What you should and should not type in each etc * One neat trick of using the print to debug. Say you have a line like nx.append(2) and nx is not getting to be what you expect. Change it to nx.append(2); print(nx) Cleaning up the print after debugging is easier than if you use a separate line like so nx.append(2) print(nx) [I think I learnt this trick from Mark Lawrence] -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 10:42:08 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: On Friday, October 24, 2014 10:55:44 PM UTC+5:30, Seymore4Head wrote: On Fri, 24 Oct 2014 19:18:12 +0200, Albert Visser wrote: On Fri, 24 Oct 2014 19:03:47 +0200, Seymore4Head wrote: http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. It's what's on the left hand side of your screenshot. You can simply type Python statements following the prompt and hit enter to examine the result, instead of pushing F5 to run your code I guess I am confusing the Interpreter with the debugger. Someone suggested I use the Interpreter to step through line by line. I don't know how to do that. Dont bother with the debugger just yet. For most python programmers, sticking a few print statements (expressions in python 3) in adroitly is good enough.* For now best if you concentrate on 1. What are the features of python -- the language 2. What are the standard data types and functions -- the libraries 3. How to use and jump between the two windows of your screenshot most effectively. What you should and should not type in each etc * One neat trick of using the print to debug. Say you have a line like nx.append(2) and nx is not getting to be what you expect. Change it to nx.append(2); print(nx) Cleaning up the print after debugging is easier than if you use a separate line like so nx.append(2) print(nx) [I think I learnt this trick from Mark Lawrence] Useful tips Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
I meant to type: if y in range(1,10) doesn't work. Sigh Sorry On Fri, 24 Oct 2014 14:15:13 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 24/10/2014 18:03, Seymore4Head wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. You've stated that you can use google so why not try it to find out about the interpreter? Or simply navigate to docs.python.org and see what the contents or index tell you? Failing that carry on charging around like a headless chicken and hope that the extremely patient folk here keep helping you out. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 24/10/2014 19:20, Seymore4Head wrote: I meant to type: if y in range(1,10) doesn't work. Sigh Sorry How many more times, state what you expect to happen and what actually happens. doesn't work is useless. Please read this http://sscce.org/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 11:17:53 AM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please Your code here is actually pretty close to a correct answer. Just a few things to consider... - Why are you converting your name string to a list? It is unnecessary. When you do for y in some string, then y will still be single characters on each iteration of the loop. - if y in string.digits should work fine. - if y in list(range(1,10) won't work for two reasons: First, it creates a list of numbers, not strings. Second, even if it did, it would be missing the 0 digit. - At the end, when you convert your list to a string, you don't need to use list comprehension, since nx is already a list. number = .join(nx) should work fine. Also, in general, you need to stop and slow down and think like a programmer. If you get an error, your instinct shouldn't be to just hack at it to make the error go away. Look at the error and try to make sense of it. Learn what the error means and try to fix the core problem. And for @#$%'s sake...stop saying It isn't working and not elaborating. You've been told by every other post in this thread to show us what you did and what the error was. You've also been told to *NOT* retype what you see and to copy/paste your code and the error because when you make a typo when copying, we might see a problem that doesn't exist and then you just get more confused. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 19:40:39 +0100, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/10/2014 19:20, Seymore4Head wrote: I meant to type: if y in range(1,10) doesn't work. Sigh Sorry How many more times, state what you expect to happen and what actually happens. doesn't work is useless. Please read this http://sscce.org/ Good suggestion. OK how is this? It doesn't print what I expect. Does it print what you expect? name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) http://i.imgur.com/EGKUpAb.jpg -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 11:57:12 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 11:17:53 AM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please Your code here is actually pretty close to a correct answer. Just a few things to consider... - Why are you converting your name string to a list? It is unnecessary. When you do for y in some string, then y will still be single characters on each iteration of the loop. - if y in string.digits should work fine. - if y in list(range(1,10) won't work for two reasons: First, it creates a list of numbers, not strings. Second, even if it did, it would be missing the 0 digit. - At the end, when you convert your list to a string, you don't need to use list comprehension, since nx is already a list. number = .join(nx) should work fine. Also, in general, you need to stop and slow down and think like a programmer. If you get an error, your instinct shouldn't be to just hack at it to make the error go away. Look at the error and try to make sense of it. Learn what the error means and try to fix the core problem. And for @#$%'s sake...stop saying It isn't working and not elaborating. You've been told by every other post in this thread to show us what you did and what the error was. You've also been told to *NOT* retype what you see and to copy/paste your code and the error because when you make a typo when copying, we might see a problem that doesn't exist and then you just get more confused. Ok I think I may have the question you guys are looking for. I just posted it. See above. But it's still broke. :( -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 12:12:10 PM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:57:12 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 11:17:53 AM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please Your code here is actually pretty close to a correct answer. Just a few things to consider... - Why are you converting your name string to a list? It is unnecessary. When you do for y in some string, then y will still be single characters on each iteration of the loop. - if y in string.digits should work fine. - if y in list(range(1,10) won't work for two reasons: First, it creates a list of numbers, not strings. Second, even if it did, it would be missing the 0 digit. - At the end, when you convert your list to a string, you don't need to use list comprehension, since nx is already a list. number = .join(nx) should work fine. Also, in general, you need to stop and slow down and think like a programmer. If you get an error, your instinct shouldn't be to just hack at it to make the error go away. Look at the error and try to make sense of it. Learn what the error means and try to fix the core problem. And for @#$%'s sake...stop saying It isn't working and not elaborating. You've been told by every other post in this thread to show us what you did and what the error was. You've also been told to *NOT* retype what you see and to copy/paste your code and the error because when you make a typo when copying, we might see a problem that doesn't exist and then you just get more confused. Ok I think I may have the question you guys are looking for. I just posted it. See above. But it's still broke. :( str(range(10)) doesn't do what you think it does. Run 'print(str(range(10)))' and look at what you get. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 12:25:33 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 12:12:10 PM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:57:12 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 11:17:53 AM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please Your code here is actually pretty close to a correct answer. Just a few things to consider... - Why are you converting your name string to a list? It is unnecessary. When you do for y in some string, then y will still be single characters on each iteration of the loop. - if y in string.digits should work fine. - if y in list(range(1,10) won't work for two reasons: First, it creates a list of numbers, not strings. Second, even if it did, it would be missing the 0 digit. - At the end, when you convert your list to a string, you don't need to use list comprehension, since nx is already a list. number = .join(nx) should work fine. Also, in general, you need to stop and slow down and think like a programmer. If you get an error, your instinct shouldn't be to just hack at it to make the error go away. Look at the error and try to make sense of it. Learn what the error means and try to fix the core problem. And for @#$%'s sake...stop saying It isn't working and not elaborating. You've been told by every other post in this thread to show us what you did and what the error was. You've also been told to *NOT* retype what you see and to copy/paste your code and the error because when you make a typo when copying, we might see a problem that doesn't exist and then you just get more confused. Ok I think I may have the question you guys are looking for. I just posted it. See above. But it's still broke. :( str(range(10)) doesn't do what you think it does. Run 'print(str(range(10)))' and look at what you get. Yeah, I know that. My question is why? The answer was that Python 3 only stores the min and max values but you can still iterate over them. I don't think that means what I think it means. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Friday, October 24, 2014 12:36:23 PM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 12:25:33 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 12:12:10 PM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:57:12 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 11:17:53 AM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please Your code here is actually pretty close to a correct answer. Just a few things to consider... - Why are you converting your name string to a list? It is unnecessary. When you do for y in some string, then y will still be single characters on each iteration of the loop. - if y in string.digits should work fine. - if y in list(range(1,10) won't work for two reasons: First, it creates a list of numbers, not strings. Second, even if it did, it would be missing the 0 digit. - At the end, when you convert your list to a string, you don't need to use list comprehension, since nx is already a list. number = .join(nx) should work fine. Also, in general, you need to stop and slow down and think like a programmer. If you get an error, your instinct shouldn't be to just hack at it to make the error go away. Look at the error and try to make sense of it. Learn what the error means and try to fix the core problem. And for @#$%'s sake...stop saying It isn't working and not elaborating. You've been told by every other post in this thread to show us what you did and what the error was. You've also been told to *NOT* retype what you see and to copy/paste your code and the error because when you make a typo when copying, we might see a problem that doesn't exist and then you just get more confused. Ok I think I may have the question you guys are looking for. I just posted it. See above. But it's still broke. :( str(range(10)) doesn't do what you think it does. Run 'print(str(range(10)))' and look at what you get. Yeah, I know that. My question is why? The answer was that Python 3 only stores the min and max values but you can still iterate over them. I don't think that means what I think it means. You can iterate over them pretty much just means you can use them as the source of a 'for' loop. But in your case, when you're calling 'for y in str(range(10))', you're not using 'range(10)' as the source of your loop, you're using the result of a str() function call, and you're calling str() on range(), which doesn't return a concrete value in Python 3. If you try to print a range(), you're just getting a string containing your original call to range. And that's why you're seeing
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 12:55:19 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 12:36:23 PM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 12:25:33 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 12:12:10 PM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:57:12 -0700 (PDT), sohcahto...@gmail.com wrote: On Friday, October 24, 2014 11:17:53 AM UTC-7, Seymore4Head wrote: On Fri, 24 Oct 2014 11:52:15 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head Seymore4Head@hotmail.invalid wrote: Actually I was a little frustrated when I added that line back in as the other lines all work. Using list(range(10)) Doesn't throw an error but it doesn't work. http://i.imgur.com/DTc5zoL.jpg The interpreter. I don't know how to use that either. Try both of these in the interpreter, and observe the difference: 7 in range(10) 7 in range(10) Do you understand what the difference between 7 and 7 is? I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. These hints are just not working. I am too thick for hints. :) If you could use it in the code, I might understand. The other work arounds that were posted work. I have used them. str(range(10)) doesn't work. import string def nametonumber(name): lst=[] nx=[] digit=[] digit=.join(str(i) for i in range(10)) for x in name: lst.append(x) for y in (lst): if y in list(range(1,10)): #if y in 1234567890: #if y.isdigit(): #if y in digit: #if y in string.digits: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(e for e in nx) return number a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 dialaho print (nametonumber(a)) Please Your code here is actually pretty close to a correct answer. Just a few things to consider... - Why are you converting your name string to a list? It is unnecessary. When you do for y in some string, then y will still be single characters on each iteration of the loop. - if y in string.digits should work fine. - if y in list(range(1,10) won't work for two reasons: First, it creates a list of numbers, not strings. Second, even if it did, it would be missing the 0 digit. - At the end, when you convert your list to a string, you don't need to use list comprehension, since nx is already a list. number = .join(nx) should work fine. Also, in general, you need to stop and slow down and think like a programmer. If you get an error, your instinct shouldn't be to just hack at it to make the error go away. Look at the error and try to make sense of it. Learn what the error means and try to fix the core problem. And for @#$%'s sake...stop saying It isn't working and not elaborating. You've been told by every other post in this thread to show us what you did and what the error was. You've also been told to *NOT* retype what you see and to copy/paste your code and the error because when you make a typo when copying, we might see a problem that doesn't exist and then you just get more confused. Ok I think I may have the question you guys are looking for. I just posted it. See above. But it's still broke. :( str(range(10)) doesn't do what you think it does. Run 'print(str(range(10)))' and look at what you get. Yeah, I know that. My question is why? The answer was that Python 3 only stores the min and max values but you can still iterate over them. I don't think that means what I think it means. You can iterate over them pretty much just means you can use them as the source of a 'for' loop. But in your case, when you're calling 'for y in str(range(10))', you're not using 'range(10)' as the source of your loop, you're using the result of a str() function call, and you're calling str() on range(), which doesn't return a concrete value in Python 3. If you try to print a range(), you're just getting a
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: I tried list(range(10) This is missing a ) It probably sat there waiting for you to finish the line. list(range(10)) You have two ( in the line, you need two ) to match them. I thought that would work in Python 3. It didn't. It does if you enter it properly. also try: str(list(range(10))) Note that that has three ( and three ) on the line. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 20:37:31 + (UTC), Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: I tried list(range(10) This is missing a ) It probably sat there waiting for you to finish the line. list(range(10)) You have two ( in the line, you need two ) to match them. I thought that would work in Python 3. It didn't. It does if you enter it properly. also try: str(list(range(10))) Note that that has three ( and three ) on the line. I make lots of typing mistakes. It is not that. Did you see the short example I posted? name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) It doesn't throw an error but it doesn't print what you would expect. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 16:58:00 -0400, Seymore4Head wrote: On Fri, 24 Oct 2014 20:37:31 + (UTC), Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: I tried list(range(10) This is missing a ) It probably sat there waiting for you to finish the line. list(range(10)) You have two ( in the line, you need two ) to match them. I thought that would work in Python 3. It didn't. It does if you enter it properly. also try: str(list(range(10))) Note that that has three ( and three ) on the line. I make lots of typing mistakes. It is not that. Did you see the short example I posted? name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) It doesn't throw an error but it doesn't print what you would expect. it prints what I expect, it probably does not print what you expect you have may times been told that str(range(10)) does not do what you expect but you keep failing to test you think that it crates a list of strings ['1','2','3'] but it does not it creates a list then turns the whole list into a string '[1,2,3...]' people are suggesting you try this things in the interactive prompt because doing teaches far better than just reading. -- Honesty's the best policy. -- Miguel de Cervantes -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 24/10/2014 15:47, Seymore4Head wrote: I have at least 10 ebooks. I will get around to reading them soon. Sooner would be better. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, Oct 24, 2014 at 2:58 PM, Seymore4Head Seymore4Head@hotmail.invalid wrote: name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) It doesn't throw an error but it doesn't print what you would expect. That prints exactly what I expect it to. The first if prints nothing, because you're testing whether a string is contained in a sequence of ints. That will always be false. The second if prints those characters from name that happen to be in the string range(10). That's the 1 and the a. Apparently it doesn't print what *you* expect, which is why you need to make your expectation clear and not assume that we will just read your mind and immediately understand what you expect the code to do. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 14:15:13 -0400, Seymore4Head wrote: I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. This is because str(range(10)) does not do what you think it does. In python 2.x, str(range(10)) creates a string representation of the complete list, not a list of the string representation of the separate list elements. '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' In python 3.x, str(range(10)) creates a string representation of the list object. 'range(0, 10)' the only single digit strings in the python3 representation are 0 and 1 To recreate the python2 behaviour in python 3, use: str(list(range(10))) which gives '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' howver the test: if x.isdigit(): is much better. But finally, with your telephone number decoder, look at: http://www.codeskulptor.org/#user38_QnR06Upp4AH6h0Q.py -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 21:19:22 + (UTC), Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 14:15:13 -0400, Seymore4Head wrote: I do understand that. 7 is a number and 7 is a string. What my question was...and still is...is why Python 3 fails when I try using y=1 800 get charter y in range str(range(10)) should work because y is a string and str(range(10)) should be y in str(1) fails. It doesn't give an error it's just not True when y is a number. This is because str(range(10)) does not do what you think it does. In python 2.x, str(range(10)) creates a string representation of the complete list, not a list of the string representation of the separate list elements. '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' In python 3.x, str(range(10)) creates a string representation of the list object. 'range(0, 10)' the only single digit strings in the python3 representation are 0 and 1 To recreate the python2 behaviour in python 3, use: str(list(range(10))) which gives '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' howver the test: if x.isdigit(): is much better. But finally, with your telephone number decoder, look at: http://www.codeskulptor.org/#user38_QnR06Upp4AH6h0Q.py That is much cleaner than mine. Nice. I did make one more change to mine that makes it easier to read. I changed treating all -() With a space. I am still thinking about how to treat the large space if it is a digit instead: 1 800 555 -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: Thanks everyone for your suggestions. Try loading the following in codeskulptor: http://www.codeskulptor.org/#user38_j6kGKgeOMr_0.py -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 15:07:06 -0400, Seymore4Head wrote: On Fri, 24 Oct 2014 19:40:39 +0100, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/10/2014 19:20, Seymore4Head wrote: I meant to type: if y in range(1,10) doesn't work. Sigh Sorry How many more times, state what you expect to happen and what actually happens. doesn't work is useless. Please read this http://sscce.org/ Good suggestion. OK how is this? It doesn't print what I expect. Does it print what you expect? name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) http://i.imgur.com/EGKUpAb.jpg I suspect you're discovering the difference between the python2 and python3 range() functions, and what happens when you encapsulate them in string. I've already posted about this once this evening. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
Seymore4Head Seymore4Head@Hotmail.invalid Wrote in message: On Fri, 24 Oct 2014 09:54:23 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: Totally befuddled myself! Are you deliberately misspelling list to lst and hoping the error will go away. And Puh LEESE dont post screen shots of good ol ASCII text I didn't do that on purpose. I make a lot of typing mistakes. Sorry That's what copy/paste are for. Copy from your console, and paste into your email. Don't ever retype unless you're trying to frustrate us, -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 21:48:14 + (UTC), Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote: Thanks everyone for your suggestions. Try loading the following in codeskulptor: http://www.codeskulptor.org/#user38_j6kGKgeOMr_0.py That is a useful way to test. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: Thanks for all the helpful replies. I just discovered that there is something wrong with my news feed. Some of the messages did not make it to me. I can go back and read this thread in Google Groups but I can't reply to it. If I missed thanking or replying to anyone, that is the reason. Thanks again -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 18:09:59 -0400 (EDT), Dave Angel da...@davea.name wrote: Seymore4Head Seymore4Head@Hotmail.invalid Wrote in message: On Fri, 24 Oct 2014 09:54:23 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: Totally befuddled myself! Are you deliberately misspelling list to lst and hoping the error will go away. And Puh LEESE dont post screen shots of good ol ASCII text I didn't do that on purpose. I make a lot of typing mistakes. Sorry That's what copy/paste are for. Copy from your console, and paste into your email. Don't ever retype unless you're trying to frustrate us, I promise I am not trying to frustrate anyone. I know I have. Sorry -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: name=123-xyz-abc a=range(10) b=list(range(10)) c=str(list(range(10))) print (a,(a)) print (b,(b)) print (c,(c)) for x in name: if x in a: print (a,(x)) if x in b: print (b,(x)) if x in c: print (c,(x)) B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. http://i.imgur.com/dT3sEQq.jpg -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 4:00:01 AM UTC+5:30, Seymore4Head wrote: On Fri, 24 Oct 2014 18:09:59 -0400 (EDT), Dave Angel wrote: Don't ever retype unless you're trying to frustrate us, I promise I am not trying to frustrate anyone. I know I have. Sorry No issues Seymore :-) As far as I am concerned this has been useful and educative for me -- I found out about codeskulptor. Though I am a bit conflicted whether it helps or confuses students. Also many other things... What I take as minor distinctions between python 2 and 3 may not be so minor if one doesn't know whats going on. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 17:35:34 -0400, Seymore4Head wrote: But finally, with your telephone number decoder, look at: http://www.codeskulptor.org/#user38_QnR06Upp4AH6h0Q.py That is much cleaner than mine. Nice. I did make one more change to mine that makes it easier to read. I changed treating all -() With a space. I am still thinking about how to treat the large space if it is a digit instead: 1 800 555 Note that my decoder assumes anything other than a letter can be copied straight to the output string. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 16:58:00 -0400, Seymore4Head wrote: I make lots of typing mistakes. It is not that. Did you see the short example I posted? name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) It doesn't throw an error but it doesn't print what you would expect. It prints exactly what I expect. Try the following: print(str(range(10)), type(str(range(10 print(str(list(range(10))), type(str(listr(range(10) In python 3, str(x) just wraps x up and puts it in a string. range(x) generates an iterable range object. hence str(range(10)) is a string telling you that range(10) is an iterable range object with certain boundaries. However, list(iterable) expands the iterable to the full list of possible values, so str(list(range(10))) is a string representation of the list containing the values that the iterable range(10) creates. Note that whether you're looking at a string representation of a value or the value itself is a lot clearer in the interpreter console where strings are displayed with quotes. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 24/10/2014 23:58, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: name=123-xyz-abc a=range(10) b=list(range(10)) c=str(list(range(10))) print (a,(a)) print (b,(b)) print (c,(c)) for x in name: if x in a: print (a,(x)) if x in b: print (b,(x)) if x in c: print (c,(x)) B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. http://i.imgur.com/dT3sEQq.jpg Why? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 4:30:47 AM UTC+5:30, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head wrote: name=123-xyz-abc a=range(10) b=list(range(10)) c=str(list(range(10))) print (a,(a)) print (b,(b)) print (c,(c)) for x in name: if x in a: print (a,(x)) if x in b: print (b,(x)) if x in c: print (c,(x)) B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. Lets simplify the problem a bit. Do all the following in interpreter window name=012 b=list(range(3)) for x in name: print x for x in b: print x Same or different? Now go back to Denis' nice example and put in type(x) into each print Same or different? -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 18:58:04 -0400, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: OK, assuming you tried to run this in python3, not python2 or codeskulptor. name=123-xyz-abc a=range(10) a is an iterable object giving the numbers 0 through 9 b=list(range(10)) b is an list containing the numbers 0 through 9 c=str(list(range(10))) c is an string representation of a list containing the numbers 0 through 9 print (a,(a)) print (b,(b)) print (c,(c)) for x in name: ^ x is a string representing one character in name if x in a: print (a,(x)) here you are looking for a string x amongst the numbers yielded by an iterable if x in b: print (b,(x)) here you are comparing a string x with the elements of a list of numbers if x in c: print (c,(x)) here you are comparing a string x with the characters in a string representation of a list of numbers B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. http://i.imgur.com/dT3sEQq.jpg a is the range object: range(0, 9) b is the list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] c is the string: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] When you try and compare a character x eg 8 with the numbers yielded by the iterable a, none of them match because character 8 is not the same as number 8 When you try and compare a character x eg 8 with the elements of the list b, none of them match because character 8 is not the same as number 8 When you try and compare a character x eg 8 with the string representation of the list b, you get a match of x 8 to the 25th character of string c which is also 8. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 16:27:58 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: On Saturday, October 25, 2014 4:30:47 AM UTC+5:30, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head wrote: name=123-xyz-abc a=range(10) b=list(range(10)) c=str(list(range(10))) print (a,(a)) print (b,(b)) print (c,(c)) for x in name: if x in a: print (a,(x)) if x in b: print (b,(x)) if x in c: print (c,(x)) B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. Lets simplify the problem a bit. Do all the following in interpreter window name=012 b=list(range(3)) for x in name: print x for x in b: print x Same or different? Now go back to Denis' nice example and put in type(x) into each print Same or different? First. The interpreter is not good for me to use even when I am using Python 3 because I forget to add : and I forget to put () around the print statements. To keep me from having to correct myself every time I use it, it is just easier to make a short py file. Here is mine: name=012 b=list(range(3)) for x in name: print (x) print (type (x)) for x in b: print (x) print (type (b)) I don't understand what I was supposed to learn from that. I know that name will be a string so x will be a string. I would still think if you compare a 1 from a string to a 1 from a list, it should be the same. Obviously I am wrong, but we knew that already. I get they are not the same, but I still think they should be. name=012 b=list(range(3)) print (name[1]) print ([1]) 1 [1] OK I get it. They are not the same. I was expecting 1 -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 23:21:43 + (UTC), Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 24 Oct 2014 16:58:00 -0400, Seymore4Head wrote: I make lots of typing mistakes. It is not that. Did you see the short example I posted? name=123-xyz-abc for x in name: if x in range(10): print (Range,(x)) if x in str(range(10)): print (String range,(x)) It doesn't throw an error but it doesn't print what you would expect. It prints exactly what I expect. Try the following: print(str(range(10)), type(str(range(10 print(str(list(range(10))), type(str(listr(range(10) In python 3, str(x) just wraps x up and puts it in a string. range(x) generates an iterable range object. hence str(range(10)) is a string telling you that range(10) is an iterable range object with certain boundaries. However, list(iterable) expands the iterable to the full list of possible values, so str(list(range(10))) is a string representation of the list containing the values that the iterable range(10) creates. Note that whether you're looking at a string representation of a value or the value itself is a lot clearer in the interpreter console where strings are displayed with quotes. I get it now. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 19:48:16 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: On Fri, 24 Oct 2014 16:27:58 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: On Saturday, October 25, 2014 4:30:47 AM UTC+5:30, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head wrote: name=123-xyz-abc a=range(10) b=list(range(10)) c=str(list(range(10))) print (a,(a)) print (b,(b)) print (c,(c)) for x in name: if x in a: print (a,(x)) if x in b: print (b,(x)) if x in c: print (c,(x)) B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. Lets simplify the problem a bit. Do all the following in interpreter window name=012 b=list(range(3)) for x in name: print x for x in b: print x Same or different? Now go back to Denis' nice example and put in type(x) into each print Same or different? First. The interpreter is not good for me to use even when I am using Python 3 because I forget to add : and I forget to put () around the print statements. To keep me from having to correct myself every time I use it, it is just easier to make a short py file. Here is mine: name=012 b=list(range(3)) for x in name: print (x) print (type (x)) for x in b: print (x) print (type (b)) I don't understand what I was supposed to learn from that. I know that name will be a string so x will be a string. I would still think if you compare a 1 from a string to a 1 from a list, it should be the same. Obviously I am wrong, but we knew that already. I get they are not the same, but I still think they should be. name=012 b=list(range(3)) print (name[1]) print ([1]) 1 [1] OK I get it. They are not the same. I was expecting 1 Wait! I don't get it. name=012 b=list(range(3)) print (name[1]) print (b[1]) 1 1 I forgot the b -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: name=012 b=list(range(3)) print (name[1]) print (b[1]) if name[1] == b[1]: print (Eureka!) else: print (OK, I get it) -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 2014-10-25 00:57, Seymore4Head wrote: [snip] Wait! I don't get it. name=012 b=list(range(3)) print (name[1]) print (b[1]) 1 1 I forgot the b If you print the int 1, you'll see: 1 If you print the string 1, you'll see: 1 Normally you want it to print only the characters of the string. Think how annoying it would be if every time you printed a string it appeared in quotes: print(Hello world!) 'Hello world!' How could you print just the text: Hello world! No, it's better that it prints the characters of the string. One function you can use is repr: x = 1 y = 1 print(repr(x)) print(repr(y)) This will print: 1 '1' OK, now it's clear that x is an int and y is a string. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/24/2014 6:27 PM, Seymore4Head wrote: I promise I am not trying to frustrate anyone. I know I have. Seymore, if you want to learn real Python, download and install 3.4.2 and either use the Idle Shell and Editor or the interactive console interpreter and a decent programmer editor. I cannot recommend CodeSkulptor to anyone. The opening statement # CodeSkulptor runs Python programs is deceptive. CodeSkulptor Python is not Python. It does not correspond to any x.y version of Python. It is a somewhat crippled subset of ancient Python (2.1) with selected additions of later features. It does not have exceptions, raise, and try: except:. These are an essential part of original Python and Python today It does not have complex (maybe introduced in 1.5) and unicode (introduced in 2.0). Let that pass. More important, it does not have new-style classes, an essential new feature introduced in 2.2. Python beginners should start with unified new-styled classes. If lucky, they need never learn about the original old style, dis-unified type versus class system that started going away in 2.2, is mostly gone in 2.7. and completely gone in 3.0. If you really want to continue with CodeSkulpter Python, you should find a CodeSkulpterPython list. You cannot expect people here to know that legal code like class I(int): pass will not run, but will fail with an exceeding cryptic message: Line 1: undefined: TypeError: a.$d is undefined Nor can you expect us to know all the other limitations. This is a list for Python. If you want help here, get and use a real Python interpreter, with a proper interactive mode, as multiple people have suggested. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, 25 Oct 2014 01:20:53 +0100, MRAB pyt...@mrabarnett.plus.com wrote: On 2014-10-25 00:57, Seymore4Head wrote: [snip] Wait! I don't get it. name=012 b=list(range(3)) print (name[1]) print (b[1]) 1 1 I forgot the b If you print the int 1, you'll see: 1 If you print the string 1, you'll see: 1 Normally you want it to print only the characters of the string. Think how annoying it would be if every time you printed a string it appeared in quotes: print(Hello world!) 'Hello world!' How could you print just the text: Hello world! No, it's better that it prints the characters of the string. One function you can use is repr: x = 1 y = 1 print(repr(x)) print(repr(y)) This will print: 1 '1' OK, now it's clear that x is an int and y is a string. Yes x = 123 y = 123 z = [1,2,3] print(repr(x)) print(repr(y)) print(repr(z)) 123 '123' [1, 2, 3] Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 20:27:03 -0400, Terry Reedy tjre...@udel.edu wrote: On 10/24/2014 6:27 PM, Seymore4Head wrote: I promise I am not trying to frustrate anyone. I know I have. Seymore, if you want to learn real Python, download and install 3.4.2 and either use the Idle Shell and Editor or the interactive console interpreter and a decent programmer editor. I cannot recommend CodeSkulptor to anyone. The opening statement # CodeSkulptor runs Python programs is deceptive. CodeSkulptor Python is not Python. It does not correspond to any x.y version of Python. It is a somewhat crippled subset of ancient Python (2.1) with selected additions of later features. It does not have exceptions, raise, and try: except:. These are an essential part of original Python and Python today It does not have complex (maybe introduced in 1.5) and unicode (introduced in 2.0). Let that pass. More important, it does not have new-style classes, an essential new feature introduced in 2.2. Python beginners should start with unified new-styled classes. If lucky, they need never learn about the original old style, dis-unified type versus class system that started going away in 2.2, is mostly gone in 2.7. and completely gone in 3.0. If you really want to continue with CodeSkulpter Python, you should find a CodeSkulpterPython list. You cannot expect people here to know that legal code like class I(int): pass will not run, but will fail with an exceeding cryptic message: Line 1: undefined: TypeError: a.$d is undefined Nor can you expect us to know all the other limitations. This is a list for Python. If you want help here, get and use a real Python interpreter, with a proper interactive mode, as multiple people have suggested. OK. I will. Thanks But the difference between Python 2 and Codeskulptor was not an issue with this question. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 24Oct2014 20:37, Seymore4Head Seymore4Head@Hotmail.invalid wrote: On Sat, 25 Oct 2014 01:20:53 +0100, MRAB pyt...@mrabarnett.plus.com One function you can use is repr: x = 1 y = 1 print(repr(x)) print(repr(y)) This will print: 1 '1' OK, now it's clear that x is an int and y is a string. Yes In particular, Python's interactive mode uses repr to print the result of any expression that whose value was not None: [/Users/cameron]fleet* python Python 2.7.8 (default, Oct 3 2014, 02:34:26) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin Type help, copyright, credits or license for more information. x=1 y='1' x 1 y '1' so you get this for free in that mode. Cheers, Cameron Simpson c...@zip.com.au If your new theorem can be stated with great simplicity, then there will exist a pathological exception.- Adrian Mathesis -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/24/2014 07:38 AM, Seymore4Head wrote: snip I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. So it is a pain to actually load Python 2. Exactly HOW are you trying to run Idle? A default install of Py2 and Py3 in Windows should have also installed Idle for each version. In my Win7 system, they are BOTH in the standard menu, you should be able to call up either one. OT: Side comment: I rarely use Windows these days, maybe once every two or three months -- I MUCH prefer Linux. Among other reasons its a far better environment for programming. I only have one (active) system with Windows installed, and two others with Linux only. Actually make that three, if you count my Raspberry Pi. :-) -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Fri, 24 Oct 2014 19:16:21 -0700, Larry Hudson org...@yahoo.com wrote: On 10/24/2014 07:38 AM, Seymore4Head wrote: snip I do get the difference. I don't actually use Python 2. I use CodeSkulptor. I do have Python 3 installed. Actually I have Python 2 installed but IDLE defaults to Python 3. So it is a pain to actually load Python 2. Exactly HOW are you trying to run Idle? A default install of Py2 and Py3 in Windows should have also installed Idle for each version. In my Win7 system, they are BOTH in the standard menu, you should be able to call up either one. OT: Side comment: I rarely use Windows these days, maybe once every two or three months -- I MUCH prefer Linux. Among other reasons its a far better environment for programming. I only have one (active) system with Windows installed, and two others with Linux only. Actually make that three, if you count my Raspberry Pi. :-) -=- Larry -=- I have a directory of my py files. I right click on one of the py files and open with IDLE Windows XP If I try to open a py file I have for Python 2 it still opens using IDLE 3. I don't have many py 2 files anyway. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 5:21:01 AM UTC+5:30, Seymore4Head wrote: On Fri, 24 Oct 2014 16:27:58 -0700 (PDT), Rustom Mody wrote: On Saturday, October 25, 2014 4:30:47 AM UTC+5:30, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head wrote: name=123-xyz-abc a=range(10) b=list(range(10)) c=str(list(range(10))) print (a,(a)) print (b,(b)) print (c,(c)) for x in name: if x in a: print (a,(x)) if x in b: print (b,(x)) if x in c: print (c,(x)) B is type list and C is type str. I guess I am still a little too thick. I would expect b and c to work. Lets simplify the problem a bit. Do all the following in interpreter window name=012 b=list(range(3)) for x in name: print x for x in b: print x Same or different? Now go back to Denis' nice example and put in type(x) into each print Same or different? First. The interpreter is not good for me to use even when I am using Python 3 because I forget to add : and I forget to put () around the print statements. What would you say to a person who - Buys a Lambhorgini - Hitches a horse (or bullock) to it - Moans how clumsily slow it is. ?? In case you dont get it: - the interpreter is one of the factors that puts python into the hi-end class. - the bullock/horse class is the C/Java type language where you always need to work through files Here is my list of points of sliding for bullock category to Lambhorgini: http://blog.languager.org/2012/10/functional-programming-lost-booty.html ['Interpreter' is called 'REPL' there] To keep me from having to correct myself every time I use it, it is just easier to make a short py file. Yes the intention is right, The implementation is wrong. Programmers consider it a virtue to be lazy. But you have to put it some work to learn to be lazy in an effective way And currently you are being lazy on the wrong front. Hints: 1. A good programmer tries out things at the interpreter ONE LINE AT A TIME 2. What he tries out are usually EXPRESSIONS like eg str(list(range(10))) And not STATEMENTS like if x in name: print x 3. IOW a good programmer rarely needs to type a colon at the interpreter 4. The least useful statement to try at the interpreter is print. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 9:17:12 AM UTC+5:30, Rustom Mody wrote: 4. The least useful statement to try at the interpreter is print. Yeah this is python2 thinking; in python 3, print is technically an expression. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
Rustom Mody rustompm...@gmail.com writes: On Saturday, October 25, 2014 9:17:12 AM UTC+5:30, Rustom Mody wrote: 4. The least useful statement to try at the interpreter is print. Yeah this is python2 thinking; in python 3, print is technically an expression. This is wrong thinking. In Python 3, print is a function. -- \ “[W]hoever is able to make you absurd is able to make you | `\unjust.” —Voltaire | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Saturday, October 25, 2014 9:56:02 AM UTC+5:30, Ben Finney wrote: Rustom Mody writes: On Saturday, October 25, 2014 9:17:12 AM UTC+5:30, Rustom Mody wrote: 4. The least useful statement to try at the interpreter is print. Yeah this is python2 thinking; in python 3, print is technically an expression. This is wrong thinking. In Python 3, print is a function. [tl;dr at bottom] Ok I was a bit sloppy -- should have said 'the print' But there was no specific prior use that 'the' would refer to. So one could say (if you like!): | | Python 2 | Python 3 | | print| syntax| function | | print(x) | statement | expression | I was really talking of the second row not the first So much for being legalistic -- An approach which is ultimately not helpful. For one thing function is one kind of expression ie its a subset not a disjoint relation. More important (in this case) its bad pedagogy. Its generally accepted that side-effecting functions are not a good idea -- typically a function that returns something and changes global state. In that sense its best to think of print(x) as syntactically an expression, semantically a statement. Or put differently, the following error is more poorly reported in python3 than in python2 Python 2.7.8 (default, Oct 7 2014, 17:59:21) [GCC 4.9.1] on linux2 Type help, copyright, credits or license for more information. 2 + (print 2) File stdin, line 1 2 + (print 2) ^ SyntaxError: invalid syntax Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type help, copyright, credits or license for more information. 2 + (print (2)) 2 Traceback (most recent call last): File stdin, line 1, in module TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' = tl;dr I dont think all this is very helpful to Seymore -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody rustompm...@gmail.com wrote: Its generally accepted that side-effecting functions are not a good idea -- typically a function that returns something and changes global state. Only in certain circles. Not in Python. There are large numbers of functions with side effects (mutator methods like list.append, anything that needs lots of state like random.random, everything with external effect like I/O, heaps of stuff), and it is most definitely not frowned upon. In Python 3 (or Python 2 with the future directive), print is a function, print() an expression. It's not semantically a statement. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/22/2014 10:58 PM, Larry Hudson wrote: This give you a list not a string, but that's actually what you want here. If you _really_ want a string, use join(): .join(list(range(10))) Interactive mode makes it really easy to test before posting. .join(list(range(10))) Traceback (most recent call last): File pyshell#0, line 1, in module .join(list(range(10))) TypeError: sequence item 0: expected string, int found .join(str(i) for i in range(10)) '0123456789' -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 10/22/2014 03:30 PM, Seymore4Head wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: One more question. if y in str(range(10) Why doesn't that work. I commented it out and just did it long hand def nametonumber(name): lst=[] nx=[] for x in (name): lst.append(x) for y in (lst): #if y in str(range(10)): if y in 1234567890: nx.append(y) if y in -(): nx.append(y) if y in abc: nx.append(2) if y in def: nx.append(3) if y in ghi: nx.append(4) if y in jkl: nx.append(5) if y in mno: nx.append(6) if y in pqrs: nx.append(7) if y in tuv: nx.append(8) if y in wxyz: nx.append(9) number=.join(str(e) for e in nx) return (number) a=1-800-getcharter print (nametonumber(a))#1800 438 2427 837 a=1-800-leo laporte print (nametonumber(a)) a=1 800 callaprogrammer print (nametonumber(a)) I know you are trying to explore lists here, but I found myself somewhat intrigued with the problem itself, so I wrote a different version. This version does not use lists but only strings. I'm just presenting it as-is to let you try to follow the logic, but if you ask, I'll explain it in detail. It turns your long sequence of if's essentially into a single line -- unfortunately 's' and 'z' have to be handled as special-cases, which turns that single line into a six-line if/elif/else set. You might consider this line 'tricky', but I'll just say it's just looking at the problem from a different viewpoint. BTW, this version accepts upper-case as well as lower-case. isdigit() and isalpha() are standard string methods. #-- Code -- def name2number(name): nstr = ''# Phone-number string to return codes = 'abcdefghijklmnopqrtuvwxy' # Note missing s and z for ch in name: if ch in -(): nstr += ch elif ch.isdigit(): nstr += ch elif ch.isalpha(): ch = ch.lower() # S and Z are special cases if ch == 's': nstr += '7' elif ch == 'z': nstr += '9' else: nstr += str(codes.index(ch) // 3 + 2) return nstr #--- End of Code - A possible variation would be to make nstr a list instead of a string, and use .append() instead of the +=, and finally return the string by using join() on the list. Also, the if and first elif in the for could be combined: if ch in -() or ch.isdigit(): -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 23/10/2014 02:57, Seymore4Head wrote: On Wed, 22 Oct 2014 21:35:19 -0400, Seymore4Head Seymore4Head@Hotmail.invalid wrote: On Thu, 23 Oct 2014 02:31:57 +0100, MRAB pyt...@mrabarnett.plus.com wrote: On 2014-10-23 01:10, Seymore4Head wrote: On Thu, 23 Oct 2014 11:05:08 +1100, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Seymore4Head wrote: Those string errors were desperate attempts to fix the append error I didn't understand. Ah, the good ol' make random changes to the code until the error goes away technique. You know that it never works, right? Start by *reading the error message*, assuming you're getting an error message. I'm the first person to admit that Python's error messages are not always as clear as they should be, especially syntax errors, but still there is a lot of information that can be gleamed from most error messages. Take this attempt to use append: py mylist.append(23) Traceback (most recent call last): File stdin, line 1, in module NameError: name 'mylist' is not defined That tells me that I have forgotten to define a variable mylist. So I fix that: py mylist = 23 py mylist.append(23) Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'int' object has no attribute 'append' That tells me that I can't append to a int. After googling for Python append I learn that I can append to a list, so I try again: py mylist = [] py mylist.append(23) py print(mylist) [23] Success! If you are familiar with other programming languages, it might help to think of append() as being like a procedure in Pascal, for example. You call append() with an argument, but don't expect a return result. Technically, *all* functions and methods in Python return something, even if just the special value None, which can lead to Gotchas! like this one: py mylist = mylist.append(42) # Don't do this! py print(mylist) # I expect [23, 42] but get None instead. None Oops. One of the small annoyances of Python is that there is no way to tell ahead of time, except by reading the documentation, whether something is a proper function that returns a useful value, or a procedure-like function that returns None. That's just something you have to learn. The interactive interpreter is your friend. Learn to experiment at the interactive interpreter -- you do know how to do that, don't you? If not, ask. At the interactive interpreter, if a function or method returns a value, it will be printed, *except for None*. So a function that doesn't print anything might be procedure-like, and one which does print something might not be: py mylist = [1, 5, 2, 6, 4, 3] py sorted(mylist) # proper function returns a value [1, 2, 3, 4, 5, 6] py mylist.sort() # procedure-like function returns None py print(mylist) # and modifies the list in place [1, 2, 3, 4, 5, 6] I am going to get around to learning the interpreter soon. Why wait? You're trying to learn the language _now_, and checking things interactively will help you. Because most of the practice I am getting is not using Python. I use Codeskulptor. OK.Now is as good a time as ever. Thanks Now I remember why...nothing happens http://i.imgur.com/MIRpqzY.jpg If I click on the shell window, I can get the grayed options to show up for one turn. I hit step and everything goes gray again. http://i.imgur.com/NtMdmU1.jpg Not a very fruitful exercise. :( If you were to read and digest what is written it would help. You're trying to run IDLE. We're talking the interactive interpreter. If (at least on Windows) you run a command prompt and then type pythoncr you should see something like this. Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Thu, Oct 23, 2014 at 1:20 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: If you were to read and digest what is written it would help. You're trying to run IDLE. We're talking the interactive interpreter. IDLE includes the interactive interpreter. If (at least on Windows) you run a command prompt and then type pythoncr you should see something like this. Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. Same thing comes up when I start IDLE, so what's your point? -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On 23/10/2014 08:56, Ian Kelly wrote: On Thu, Oct 23, 2014 at 1:20 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: If you were to read and digest what is written it would help. You're trying to run IDLE. We're talking the interactive interpreter. IDLE includes the interactive interpreter. If (at least on Windows) you run a command prompt and then type pythoncr you should see something like this. Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. Same thing comes up when I start IDLE, so what's your point? When you run the interactive interpreter thats all you get. The OP isn't the first person to try things with IDLE not realising you need to have a script loaded to do something. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Wed, 22 Oct 2014 18:30:17 -0400, Seymore4Head wrote: One more question. if y in str(range(10) Why doesn't that work. I commented it out and just did it long hand In the last post I made, I suggested to you the mechanisms of using the python console and using code which prints out variables after every line. Try the following 3 commands at the console: 10 range(10) str(range(10)) 10 is just the number 10 range(10) is a list of 10 integers in the sequence 0 to 9 str(range(10)) is? Please stop the stab in the dark trial and error coding followed by the plaintive why doesn't it work wailing, and put some effort into reading and understanding the manuals. If a function doesn't do what you expect with the input you think you've given it, there is invariably one of three causes: a) The input you actually gave it isn't the input you thought you gave it b) You didn't read the description of the function, and it doesn't in fact do what you thought c) Both a and b above -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Wed, 22 Oct 2014 19:11:51 -0400, Seymore4Head wrote: On Wed, 22 Oct 2014 22:43:14 + (UTC), Denis McMahon denismfmcma...@gmail.com wrote: On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head wrote: def nametonumber(name): lst=[] for x,y in enumerate (name): lst=lst.append(y) print (lst) return (lst) a=[1-800-getcharter] print (nametonumber(a))#18004382427837 The syntax for when to use a () and when to use [] still throws me a curve. For now, I am trying to end up with a list that has each character in a as a single item. I get: None None First of all, an empty list is created with: emptylist = [] whereas x = [] creates a list containing one element, that element being an empty string. Not the same thing! Did you try stepping through your code line by line in the interpreter to see what happened at each step? note that append is a method of a list object, it has no return value, the original list is modified in place. l = [a,b,c] # declare a list l.append( d ) # use the append method l # show the list ['a', 'b', 'c', 'd'] So your line: lst = lst.append(y) should be: lst.append(y) Finally, did you really intend to pass a single element list into the function, or did you intend to pass a string into the function? Those string errors were desperate attempts to fix the append error I didn't understand. If you don't understand the error, that is the point that you should ask for help, rather than make stab in the dark attempts to fix it and then asking why the solutions don't work. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: I am out of trial and error again Lists
On Thursday, October 23, 2014 1:39:32 PM UTC+5:30, Mark Lawrence wrote: On 23/10/2014 08:56, Ian Kelly wrote: On Thu, Oct 23, 2014 at 1:20 AM, Mark Lawrence wrote: If you were to read and digest what is written it would help. You're trying to run IDLE. We're talking the interactive interpreter. IDLE includes the interactive interpreter. If (at least on Windows) you run a command prompt and then type pythoncr you should see something like this. Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. Same thing comes up when I start IDLE, so what's your point? When you run the interactive interpreter thats all you get. The OP isn't the first person to try things with IDLE not realising you need to have a script loaded to do something. If I do (at the shell prompt with an example) $ python3 Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type help, copyright, credits or license for more information. 2+3 5 And if I do $ idle3 I get a new window containing Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type copyright, credits or license() for more information. 2+3 5 so... Still not clear whats your point. idle and python interpreter seem to be mostly the same [As best as I can make out the OP is not using the standalone interpreter nor idle nor (the many options like) python-interpreter-inside-emacs nor ipython nor ... ] -- https://mail.python.org/mailman/listinfo/python-list