Re: [Tutor] Generate list-of-transforms
On Wednesday 2013 December 04 19:56, R. Alan Monroe wrote: > This seems like the kind of thing that probably exists, but there > isn't a simple googlable term for searching it out conveniently. Try "sorting algorithm". -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to generate random numbers in Python
On Thursday 2013 October 03 09:31, Joe Jacques wrote: > Problems in the link > > http://home.manhattan.edu/~ankur.agrawal/cmpt101/assgn5.txt > > Sent from my iPhone Python 2.7.2 (default, Oct 10 2011, 10:47:36) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> help(random) should get you started. -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Beep sound
On Friday 2013 March 22 18:48, Phil wrote: > Just out of curiosity how can a beep sound be generated? > > My interest in this came about because echo -e '\a' no longer works. > Also print '\a' doesn't work, presumably for the same reason. The > following is also mute: > > import Tkinter > Tkinter.Tk().bell() > > Print '\a', under Idle, causes a bell icon to be displayed so it seems > that the lack of a beep is due to a system setting. > > A Google search has shown several methods to play .wav files, some > easier than others. Perhaps Pulse Audio has made '\a' redundant? Maybe something here: http://code.activestate.com/search/recipes/#q=beep -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help
On Wednesday 2013 March 20 13:39, Robert Sjoblom wrote: > A word of advice: next is a keyword in python ~/Packages/Python/Notable-0.1.5b> python Python 2.5 (r25:51908, May 25 2007, 16:14:04) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import keyword >>> keyword.iskeyword('next') False >>> 14:44 Wed 2013 Mar 20 ~/Packages/Python/Notable-0.1.5b> python2.7 Python 2.7.2 (default, Oct 10 2011, 10:47:36) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import keyword >>> keyword.iskeyword('next') False >>> 14:44 Wed 2013 Mar 20 ~/Packages/Python/Notable-0.1.5b> python3.3 Python 3.3.0 (default, Sep 30 2012, 09:02:56) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import keyword >>> keyword.iskeyword('next') False >>> -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] functions and iterations
On Monday 2012 November 12 21:07, you wrote: > I tried it with i == n as well and it still doesnt work :/ Check the documentation on range and xrange and you will find out why i never equals n. >>> n = 5 >>> range(n) [0, 1, 2, 3, 4] >>> for i in xrange(n): print i ... 0 1 2 3 4 >>> -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] functions and iterations
On Monday 2012 November 12 19:56, Rufino Beniga wrote: > def IterateLogistic(x,r,n): > for i in xrange(n): > x = r*(1-x) > if i = n: > print x > > I want this function to take in x and r which can be any two real numbers > and after a certain number of iterations (n), the function should print the > current state which is x. I tried this function and it doesn't do anything. > May you please tell me what i did wrong? Python 2.7.2 (default, Oct 10 2011, 10:47:36) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def IterateLogistic(x,r,n): ... for i in xrange(n): ... x = r*(1-x) ... if i = n: File "", line 4 if i = n: ^ SyntaxError: invalid syntax >>> print x -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hasattr()
On Saturday 2012 October 13 11:29, Matthew Ngaha wrote: > >>> hasattr(e, e.att) > > False >>> hasattr(e, "att") True hasattr wants the second parameter to be a string. You gave it a string. The string you gave it was "Testing". -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Error in apparently correct code
On Monday 2012 August 20 14:27, Mark Lawrence wrote: > Give a man a fish, and you feed him for a day; show him how to catch > fish, and you feed him for a lifetime. > > -- > Cheers. > > Mark Lawrence. Teach a man to steal fish and he will live until he dies. -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] PyQT GUI Threading example
On Wednesday 2012 February 08 06:46, R.S. wrote: > I can't find any full example of threading with many threads working and > updating GUI (precisely i need QTreeWidget). I can only find: not updating > GUI examples, updating GUI examples with one thread. But i just can't find > what i need. Could anyone share working example with many threads updating > GUI like for example connecting to several www sites and adding the > response in a list on QTreeWidget? You might have better luck asking on pyGUI's mailing list: http://mail.python.org/mailman/listinfo/pygui -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] best book for OOP
On Sunday 2011 December 11 08:45, Alan Gauld wrote: > On 11/12/11 14:49, surya k wrote: > > Finally there is Bruce Eckel's ever popular pair: "Thinking In Java/C++" > But frankly these are more likely to lead to bad habits for the Python > programmerr because C++ and Java share a very narrow view of OOP which > does not align well with Pythons more dynamic approach. > Bruce has written one specifically for Python: Thinking In Python http://www.mindview.net/Books/TIPython -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Method to create small and simple database
On Saturday 2011 October 29 11:28, Joel Montes de Oca wrote: > After looking at the Python module documentation for sqlite3 > (http://docs.python.org/library/sqlite3.html#module-sqlite3), it seems > to me it's the best way to make the small database that I am looking for. First, have a look at shelve, it is in the std library. -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Infinite Loop
On Saturday 2011 September 24 07:43, Cameron Macleod wrote: > Hi, > > I've been trying to code a simple guess my number game as a starter > programming project but I've generated an infinite loop accidentally. Since > I'm new to programming in general, I can't really figure out what's causing > it. Thanks > > === > > import random > > print("\tWelcome to 'Guess my Number'!") > print("\nI'm thinking of a number between 1 and 100.") > print("Try to guess it in as few attempts as possible.\n") > > #set the initial values > the_number = random.randint(1, 100) > guess = int(input("Take a guess: ")) > tries = 1 > > # guessing loop > while guess != the_number: > if guess > the_number: > print("Lower...") > else: > print("Higher...") > > guess = int(input("Take a guess: ")) > tries += 1 > > print("You guessed it! The number was", the_number) > print("And it only took you", tries, "tries!\n") > > if tries <= 5: > print("I didn't know roadrunners could type!") > elif tries >= 99: > print("P'raps 'Only' wasn't the right word...") > elif tries == 100: > print("0_0 You are the unluckiest person in the world. Or the > stupidest...") > > input("\n\nPress the enter key to exit.") I suspect that your test procedure was invalid. When I converted your code to run with python 2.5 and lowered the randint to (1, 5), it ran alright. -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help!
Move the following two lines to immediately follow the while. player=raw_input("Please pick your throw: (r,s,p):") computer= random.choice(['r','s','p']) -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Coin Flipping Program
On Sunday 2011 August 21 09:14, Joel Preston wrote: > Hello Programmers, > > I am trying to learn Python on my own through a book called "Python > Programming for the Absolute Beginner". I am stuck on a challenge at the > end of a chapter and I am hoping for a little help. > > The challenge is to write a program that flips a coin 100 times and tells > you the number of heads and tails that come up. So far I can write a > program that will flip a coin 100 times but it will only come up tails or > heads all 100 times. I have been stuck on this for about 3 days now. I > have attached the program and am hoping for some advice. > Move coin = random.randint(1, 2) inside the "flipping loop". -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
On Sunday 2011 August 21 04:57, Lisi wrote: > If sys.py is a file, it must be somewhere; but I can't find it. Where is > it? I would like to look at it. > > The modules within it must surely be somewhere too. But since I can't find > sys, I obviously can't find the modules. Again, I'd like to look at them. > > In case it is relevant, I am using Python 2.5.2 on Debian 5. The source is in C, try locate */Python/sysmodule.c if you have the source for your Python. -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python 2.3.4, how to use os.system and collect it's output to a file.
On Tuesday 2011 August 02 08:40, Thirupathaiah Gande (tgande) wrote: > Hi, > > > > I have Python 2.3.4. > > I want to use os.system command and collect a command's output to a > file. But it is not collecting all the output. It is truncating.. > > > > Code is as below. > > > > cmd = "%s rl -comp %s@%s/%d >> %s" % (C_CMD, i, branch, x, > temp_acme_rl_log) > > cmd_res = os.system( cmd ) > > > > What I am missing? > The stdlib has the commands module just for this sort of thing if your OS is Unix. -- I have seen the future and I am not in it. ___ 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?
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 HTH -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hello World in Python without space
On Friday 2011 July 15 15:58, Richard D. Moores wrote: > On Fri, Jul 15, 2011 at 14:47, Stefan Behnel wrote: > > Richard D. Moores, 15.07.2011 23:21: > >> What do I do to test.txt to make it "an object with a write(string) > >> method"? > > > > Oh, there are countless ways to do that, e.g. > > > > class Writable(object): > > def __init__(self, something): > > print("Found a %s" % something)) > > def write(self, s): > > print(s) > > > > print("Hello, world!", file=Writable("C:\\test\\test.txt")) > > > > However, I'm fairly sure what you want is this: > > > > with open("C:\\test\\test.txt", "w") as file_object: > > print("Hello, world!", file=file_object) > > Yes, went with > > with open("C:\\test\\test.txt", "a+") as file_object: > print("Hello, world!", file=file_object) > > > Look up "open()" (open a file) and the "with statement" (used here > > basically as a safe way to make sure the file is closed after writing). > > > > Also note that "\t" refers to a TAB character in Python, you used this > > twice in your file path string. I believe on Windows, you can almost always use a forward slash in a path: C:/somewhere/somewhereelse/ -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Invisible Characters in Fortran/Python
On Saturday 2011 April 09 15:12, Tyler Glembo wrote: > Hi All, > So I have a ~3000 line fortran code that needs to be updated to run new > files by simply updating a few lines in the code (~10 lines). I thought > python would be a great way to do so since I know a little python but not > fortran. So, my plan was to read in each line, and then at a certain line > number, write out the changed code. A short snippet is as follows: > > dest= open( f1, "w" ) > source= open( f2, "r" ) > for line in source: >if X: > dest.write( newline + "\n" ) >else: > dest.write( line ) > dest.close() > source.close() > > The problem I am having is with hidden/invisible character. In the fortran > code, there are line indents which are denoted with an invisible character > ^I. When I write with python, there is no ^I at the beginning of the line > and the fortran code no longer compiles. I know how to put in the > invisible line return character (\n), but how can I put in other invisible > characters? > > Thank you kindly, > Tyler > > P.S. In VI when I "set invlist" the hidden character ^I shows up in blue at > the beginning of the line in place of 4 red spaces that are normally there. > I'm assuming it is like a tab indent, but I don't know what it is. It is a tab. -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need some clarification on this
On Saturday 2011 March 19 08:35, Emmanuel Ruellan wrote: > 2011/3/19 Yaşar Arabacı > > > >>>a=5 > > >>>b=5 > > >>>a == b > > > > True > > > > >>>a is b > > > > True > > > > My question is, why "a is b" is true. What I expected it to be is that, a > > and b are different things with same value. > > Even stranger: > >>> a = 10**10 > >>> b = 10**10 > >>> a == b > > True > > >>> a is b > > False > > >>> a = 5 > >>> b = 5 > >>> a == b > > True > > >>> a is b > > True > > In the general case, you're right: a and b point to two different objects, > but there is also some kind of optimisation for small numbers, and as a > result when a = 5 and b = 5, both point the same '5' object. > > Emmanuel Ruellan From http://docs.python.org/c-api/int.html The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object. -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor