Re: [Tutor] "Sounding" Off, IDLE (Win7)
Wayne Watson wrote on 16 February 2010 at 17:58:- > In Win7 IDLE, when I type in something with a syntax > problem, a bell rings. How do I stop that? I've looked > at Control Panel Sounds, but don't see anything of > apparent use. I don't get this on my Win7 machine. But anyway, the sound is probably the same sound you get if you type CTRL-G at a command prompt in a DOS box, in which case it isn't one of the sounds you set in Control Panel. You can disable it using Device Manager. It's called 'System Speaker' and it's under 'System devices'. Right-click and choose 'Disable'. -- Michael ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cannot open SQLite database
ALAN GAULD wrote on 25 February 2010 at 08:50:- > So I think that was a red herring, sorry. > It also looks like the Read Only check box in the main > Explorer property dialog tab doesn't mean what it says... Doesn't the Read Only checkbox have a coloured square rather than a tick? AFAIK the coloured square is intended to mean "doesn't apply", and you should see the same thing on all folders. You can tick the checkbox and click the "Apply" button to make all the files in the folder Read-Only in one easy move. It doesn't make the folder Read-Only, and if you close and re-open the Properties dialog after ticking the checkbox you'll find the coloured square will reappear. -- Michael ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I don't understand this code
> The thing is, the "passed list of strings" is called "words", > not "wordList", so I see it shouldn't work. > > On the other hand, the variable "wordList" is defined nowhere! "wordList" is just a name that the function (getRandomWord) uses to refer to whatever values get passed to it. Remember that you don't have to put your list of words into a variable before you call the function. You could just do this:- getRandomWord('ant baboon badger bat bear') ...and it will work. Or consider having two or three variables:- words = 'ant baboon badger bat bear' mylist= 'left right backward forward up down' morestuff = 'run walk stand sit' Naturally you can feed any of these into the function:- getRandomWord(words) getRandomWord(mylist) getRandomWord(morestuff) You can think of "getRandomWord(wordList)" as a convenient shorthand for:- wordList = words getRandomWord(wordList) Hope this helps -- Michael ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] To write data in two different fonts?
Dave Angel wrote on 11 August 2009 at 16:42:- > The brute-force way might be to replace each space in "l" with > which is a "nonbreaking space." But I think you want the > tag, which means the text is pre-formatted. And you could put that > around the whole sorce file, instead of doing for each line. I think the tag will work, but it will force the font to be monospaced, overriding the "" tag that the OP has included. -- Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] packing a list of lists
Kevin Parks wrote: > def pack(in_seq): > out_list=[] > x = 1 > ll=[1, 1] > for each in in_seq: > ll[0] = x > ll[1] = each > out_list.append(ll) > #print ll > x = x + 1 > print out_list Variable out_list consists of list ll repeated however many times. Each time you change ll you're changing it everywhere it appears in out_list. That is, what's being appended to out_list isn't a copy of ll, it's a pointer to ll. You need something like:- out_list.append([ll[0],ll[1]]) And you need to add a return at the end of the function, otherwise it returns None: return out_list -- Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] run command
"upasara wulung" wrote: (1) In a certain working folder, I produced simple python file, for an example, hello.py, which is free of error. (2) I called python from the same working folder using command 'python' (3) In the python shell, I executed: >>> run hello.py But I got only an error message: SyntaxError: invalid syntax. The "SyntaxError: invalid syntax" message occurs because there is no "run" command in python. Run the python file from the command prompt like this: python hello.py Alternatively, start python and then enter this at the python prompt (>>>): import hello The import command loads the python file and executes the code in the file. Note that you use "hello" and not "hello.py". -- Michael ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] nested loops
Alan Gauld wrote:- > "Wayne Werner" wrote > found = False > > highscore = 0 > > alignment = somealignment > > for x in something and not found: > > for y in somethingelse and not found: > > for z in evenmoresomething: > > if x+y+z > highscore: > > highscore = x+y+z > > alignment = newalignment > found = True > break > > HTH, That's going to exit first time through, isn't it? -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
Michael M Mason wrote on 07 July 2011 at 15:38:- > > In error, I downloaded ex26 before I had done ex25. So I left > > it and did ex25. > > > > Having finally given up on ex25, I am now doing ex26. And guess > > what?! Line 10 has a missing colon. > > > > So _how_ did a missing colon in ex26 cause problems in ex25 > > Maybe you've been editing ex25 and then executing ex26. That'd get you > the same error in the same place over and over again. Looks like this might be it. In your earlier post the error reported is in ex26:- : lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex26.py : File "ex26.py", line 10 : def print_first_word(words) : ^ : SyntaxError: invalid syntax : lisi@Tux:~/Python/LearnPythonTheHardWay$ -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On 07 July 2011 at 15:07 Lisi wrote: > In error, I downloaded ex26 before I had done ex25. So I left > it and did ex25. > > Having finally given up on ex25, I am now doing ex26. And guess > what?! Line 10 has a missing colon. > > So _how_ did a missing colon in ex26 cause problems in ex25 Maybe you've been editing ex25 and then executing ex26. That'd get you the same error in the same place over and over again. -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Is the Python 3.2.1 documentation available as a .chm file?
Richard D. Moores wrote on 20 July 2011 at 18:11 > On Wed, Jul 20, 2011 at 09:04, xDog Walker wrote: > > On Wednesday 2011 July 20 06:41, Richard D. Moores wrote: > > > Is the Python 3.2.1 documentation available as a .chm file from > > > Python.org? > > > > http://www.python.org/ftp/python/3.2.1/python321.chm > Did that work for you? It got me a chm file that says everywhere, > "Navigation to the web page was cancelled". The CHM file you downloaded is being blocked by Windows because it knows you downloaded it from the Internet and you haven't told Windows that it's safe yet. You need to right-click the CHM file, select 'Properties', and then click the 'Unblock' button. -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.
On 11 November 2011 at 02:00 Nathaniel Trujillo wrote:- > Okay, I typed in python -c "import sys; print sys.version" at the command > prompt. I didn't see a prompt ending with %. Instead I saw a prompt ending > with >. But here is the message I got. > > Microsoft Windows [Version 6.1.7600] > Copyright (c) 2009 Microsoft Corporation. All rights reserved. > C:\Users\net2010>python -c "import sys; print sys.version" > 'python' is not recognized as an internal or external command, > operable program or batch file. > C:\Users\net2010> This is normal with Python on Windows. The Python installer doesn't add the program directory to the PATH, so you have to include the full pathname to run Python from the command line, something like this:- C:\Python27\python -c "import sys; print sys.version" -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Weird Try..Except Error
Alan Gauld wrote on 25 November 2011 at 21:11:- > This is one of the annoying ambiguities of Windows. > The way it finds the executable for executables(exe, bat cmd etc) is > different to how it finds the executable for associations. > > In the former case it uses PATH, in the latter it relies on the file > association set in the file properties. > > When you install a new Python it tends to set itself as > the default interpreter for .py files. You can use the DOS commands to manipulate file associations on Windows so that you can run two or more versions of Python on the same computer. The DOS commands are ASSOC and FTYPE. First you need to use ASSOC to discover the file type for .py, .pyw and .pyc files. To use ASSOC type ASSOC followed by the extension you are interested in. For example, find the file type for .py files, type:- assoc .py Typical results from ASSOC will be:- .py = Python.File .pyw = Python.NoConFile .pyc = Python.CompiledFile Next, use FTYPE to discover the 'open' commands associated with each of these file types. To use FTYPE type FTYPE followed by the file type as given by the ASSOC command. For example:- ftype Python.File Typical results from FTYPE will be something like this:- Python.File="C:\Python27\python.exe" "%1" %* Python.NoConFile="C:\Python27\pythonw.exe" "%1" %* Python.CompiledFile="C:\Python27\python.exe" "%1" %* What we can do now is create our own set of file types, one for Python 2.7 and one for Python 3.2. This is done using the FTYPE command (of course, your paths may be different to the ones shown):- ftype Python32.File="C:\Python3\python.exe" "%1" %* ftype Python32.NoConFile="C:\Python3\pythonw.exe" "%1" %* ftype Python32.CompiledFile="C:\Python3\python.exe" "%1" %* ftype Python27.File="C:\Python27\python.exe" "%1" %* ftype Python27.NoConFile="C:\Python27\pythonw.exe" "%1" %* ftype Python27.CompiledFile="C:\Python27\python.exe" "%1" %* That's the preparatory work completed. We can now choose which version of Python will run when a *.py file is executed using the ASSOC command. To select Python 3 we'd use these commands:- assoc .py = Python32.File assoc .pyw = Python32.NoConFile assoc .pyc = Python32.CompiledFile ...and to use Python 2.7 we'd use these commands:- assoc .py = Python27.File assoc .pyw = Python27.NoConFile assoc .pyc = Python27.CompiledFile -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Notepad++ question
Marc Tompkins wrote on 07 June 2012 at 08:53:- > In Notepad++, select Settings/Preferences. > There's a tab called "Language Menu/Tab Settings" (they've put the two things > on > one tab to save space; the tab settings are on the right side.) You'll find a > setting for "Tab size"; the default is 4 - and also a checkbox for "Replace > by space", > which is NOT checked by default. If you're going to be writing Python in > Notepad++, > you should _definitely_ check that box. > Click "Close", and off you go! There is also an option to make tab characters and space characters visible. In the 'View' menu, select 'Show Symbol' and then make sure the 'Show White Space and TAB' option is ticked. That makes it very easy to see where tabs and spaces are being used. -- Michael This mail was sent via Mail-SeCure System. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor