Re: [Tutor] How to select particular lines from a text

2004-12-04 Thread R. Alan Monroe
> Name: > City: > > > Characterstics of this text: > 1. This text is divided into blocks and every block > start with 'Name'. The number of lines after this > identifier is random. [snip] > 1. mark the identifier i need and select all the lines > after

Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread R. Alan Monroe
> IMO, instead of doing this you should use cron to make your script > start at 08:05. It's probably cleaner. > (and yes, there are some versions of cron for Windows -- I don't know > where they can be found, but I used one called nnCron Lite at my job > this summer) There's the "at" com

Re: [Tutor] Address book sort of

2004-12-06 Thread R. Alan Monroe
> spaceMult=(highLength+minimumSpaces)-len(key) > outString=str(index)+". "+key+(spaceMult * " ") + item > print outString > while len(display_name) < 25: > display_name += '.' > count += 1 > print count, display_name, d[item]

Re: [Tutor] check_range

2004-12-14 Thread R. Alan Monroe
> def check_range(myrange): > if range(myrange) != range(10,89): > return "False" > else: > return "True" For this to work out, the user's input would have to be a giant string containing 10, 11, 12, 13, etc. Unless I mistunderstood your requirement

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread R. Alan Monroe
> print "0x%0X" % 12345 > displays > 0x3039 > instead of 0x03039 >>> "%05x" % (12345,) '03039' >>> "0x%05x" % (12345,) '0x03039' ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] can any one help

2010-01-31 Thread R. Alan Monroe
> 1 1.1 Write a Python program with a loop that prints out a sequence > of numbers as follows:15 13 11...3 1 -1 Hint 1: Learn about FOR loops. Hint 2: Learn about the RANGE command. Hint 3: Show us some code you have written. Even if yours doesn't work, we can probably spot WHY it doesn't work.

Re: [Tutor] query

2010-01-31 Thread R. Alan Monroe
> i just don wana index all the characters rather i wana double it too like > ['d','a','v','i','d'] > would b > ['d','dd','a','aa','v','vv','i','ii','d','dd'] > and then i wana replace all non 'd' characters with '.' a dot > i know how replace a specific character, but i don know how to > rep

Re: [Tutor] Odds and even exercise

2010-03-27 Thread R. Alan Monroe
> odd = numbers[::2] > I can't find a way to easily list the even numbers, Hint: You can designate a start number before the first colon. Alan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.or

Re: [Tutor] conventions for establishing and saving default values for variables

2010-06-16 Thread R. Alan Monroe
> On Tue, Jun 15, 2010 at 2:27 PM, Pete O'Connell > wrote: >> Hi I was wondering if anyone could give me some insight as to the best way >> to get and save variables from a user the first time a script is opened. For >> example if the script prompts something like "What is the path to the >> fold

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread R. Alan Monroe
> That's the goal of the latest version of my script at > . The best I've been able to do > so far is a file with 800 million digits. I don't think anyone else has suggested this: the numpy module can generate random bytes and has a built-in tofile() method.

Re: [Tutor] continuous running of a method

2010-08-25 Thread R. Alan Monroe
> Any modern multi-tasking operating system will ensure than a while loop > doesn't kill your computer's responsiveness. A decent operating system > will still remain responsive even at 100% CPU usage. Even Windows does > that! Opinions vary. If you try this on a laptop, the end user will be qui

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread R. Alan Monroe
> if coinToss(1,2) == 1: > heads += 1 > tossNo += 1 > else: > tails += 1 > tossNo += 1 Looking good. You can hoist "tossNo += 1" out of each branch of your if statement too, if you like, to make it even more streamlined (In other words, execute it once, righ

Re: [Tutor] list dll functions?

2010-09-14 Thread R. Alan Monroe
> the win32 lib, but is there any way to simply "examine" a loaded dll > to see all of the functions and attributes it exposes for use? I would http://www.dependencywalker.com/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] system()? popen2()? How to execute a command & save itsoutput?

2010-09-30 Thread R. Alan Monroe
>> I'm needing to transfer the following shell construct to Python, >> plus save >> the output of execution: >> FTP_SITE='ftp.somesite.com' >> ftp -a $FTP_SITE <> binary >> prompt off >> cd /some_dir >> dir >> bye >> EOF > Are you sure? It looks like you would be better writing a python > prog

Re: [Tutor] perl or python

2010-10-05 Thread R. Alan Monroe
> Is it better to learn Perl or Python since i can manage only writing > simple bash shell scripts. > Please suggest/guide. Do you already have both installed (seeing bash, I bet you're on some version of Linux, so it's likely you do). You could try writing a very simple "guess my number" game

Re: [Tutor] Programs for Newbies?

2010-11-14 Thread R. Alan Monroe
> Any suggestions for a newbie to program while learning python? I am new to > programming and python. Port one of the old games from http://www.atariarchives.org/basicgames/ or similar antique books. Alan ___ Tutor maillist - Tutor@python.org To u

Re: [Tutor] "if n % 2 == 0" vs. "if not n % 2" compared for speed: aesthetics lose

2010-11-23 Thread R. Alan Monroe
> I've always disliked using "if not n % 2" to test for even/odd ints > because of its convoluted logic. But I ran some speed tests and found > it was the way to go over "if n % 2 == 0". Did you try bitwise-and with 1? Alan ___ Tutor maillist - Tuto

Re: [Tutor] "if n % 2 == 0" vs. "if not n % 2" compared for speed: aesthetics lose

2010-11-23 Thread R. Alan Monroe
>>> >> I've always disliked using "if not n % 2"  to test for even/odd ints >>> >> because of its convoluted logic. But I ran some speed tests and found >>> >> it was the way to go over "if n % 2 == 0". >>> > Did you try bitwise-and with 1? >>> What's that? > 2 & 1 >> 0 > 3 & 1 >> 1 >

Re: [Tutor] Simple User Entry Verification

2009-03-14 Thread R. Alan Monroe
> while type(start)!=float: Did you try quotes around the word "float"? Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Simple User Entry Verification

2009-03-14 Thread R. Alan Monroe
> Newbie here who can't figure out why this doesn't work: > start = input("Please enter the starting number.\n>") > print(type(start)) > while type(start)!=float: > start = input("Sorry, that number was invalid.\nPlease enter the starting number.\n>>") > print(type(start)) Google to the r

Re: [Tutor] for loop

2009-04-16 Thread R. Alan Monroe
for letter in "python": >  print "Current letter:", letter for chic in "python": >  print "chic:", chic When you write a for-in loop, you can use any variable name you feel like using (letter, chic, mycoolvariable, x, etc.) It's that simple :) Alan __

Re: [Tutor] Reading from files problem

2009-04-19 Thread R. Alan Monroe
> gradesfile = open("grades.dat", "r > for lines in gradesfile: > [snip] > That's what I have so far but I have a feeling I shouldn't use a for > loop. Actually a for loop seems like the right tool for this job, assuming you really _do_ want to process every line in the file. Alan _

Re: [Tutor] sorting algorithim

2009-04-23 Thread R. Alan Monroe
> i know how to print for bubble sort in python, is there a way to > print each pass in the sort so i can see what happens at each step?  > thanks A good first guess would be to try sticking "print list" in there in a few different places. Others will probably point out that "list" is a built-in

Re: [Tutor] Monitoring a logfile

2009-12-01 Thread R. Alan Monroe
> Varnish has a dedicated (but not always) reliable logger service. I'd > like to monitor the logs - specifically I want to check that a known > entry appears in there every minute (it should be there about 10 times > a minute). > What's going to be the best way to carry out this kind of check?

Re: [Tutor] faster substring replacement

2009-12-15 Thread R. Alan Monroe
> Hi folks, > I'm trying to do something like this: evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'} def make_evil(text) > ...        for a in evildict: > ...              text=text.replace(a, evildict[a]) > ...              return text >     > This works fine, but it so

Re: [Tutor] Generating Unique Permutations

2009-12-18 Thread R. Alan Monroe
> I'm looking for an efficient way to create all the unique, non-duplicated > permutations of a list This may or may not help: http://code.activestate.com/recipes/190465/ Alan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscripti

Re: [Tutor] computer basics

2009-12-29 Thread R. Alan Monroe
> I am learning Python slowly.  I would like to begin learning all > about how computers work from the bottom up.  I have an > understanding of binary code.  Where should I go from here; can you > suggest continued reading, on line or off to continue my education? This might be worth a look: Digi-

[Tutor] Is there a way to force update the screen in tkinter?

2005-01-10 Thread R. Alan Monroe
I don't have the code here at home, but today I tried my first experiments in Tkinter. I set up a button that fired off a function to resize a rectangle in a canvas, with a for loop. Only problem is that the screen isn't repainted in all the steps of the for loop - only at the very end, when the re

Re: [Tutor] carriage return on windows

2005-01-29 Thread R. Alan Monroe
> print "Percent completed:" + str(percent) + "\r" Print forces a newline. Try sys.stdout.write instead. Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread R. Alan Monroe
> code to run it on a different platform. But most existing Java projects > have platform-specific versions, if only to make the GUI (try to) look > native. You can spot a Java app from a hundred meters away. > (then again, the same critic could be made of Python's and Perl's > "standard

Re: [Tutor] Hex to Str - still an open issue

2005-02-10 Thread R. Alan Monroe
> I am not so clued up on the 'base 2' and 'base 8' stuff. > Care to explain that a little? Easy. Imagine the numerals 2,3,4,5,6,7,8,9 were never invented. You'd start counting at 0. Next would come 1. Now you've maxed out your first column so you have to carry to the next column, so next would c

Re: Fwd: [Tutor] Create list of IPs

2005-02-20 Thread R. Alan Monroe
>> Liam Clarke wrote: > [ snip ] >> - increment an IP. This is the hardest part. > Why? An ip (V4) is just an 32bit integer :-) Indeed. Some early versions of MacTCP for MacOS made you input the address as a single large decimal number :^) Alan ___

Re: [Tutor] threads

2005-02-25 Thread R. Alan Monroe
> Remember that I am generating cars even while the > simulation is running, hence calculating this HCF at > the beginning is not going to work. > Any comments? This won't help you much in writing your program, but you might find it interesting and vaguely similar to what you're doing: www.simut

[Tutor] How to read unicode strings from a binary file and display them as plain ascii?

2005-02-28 Thread R. Alan Monroe
I started writing a program to parse the headers of truetype fonts to examine their family info. But I can't manage to print out the strings without the zero bytes in between each character (they display as a black block labeled 'NUL' in Scite's output pane) I tried: stuff = f.read(nlength)

Re: [Tutor] Re: How to read unicode strings from a binary file and display them as plain ascii?

2005-03-01 Thread R. Alan Monroe
> R. Alan Monroe wrote: >> I started writing a program to parse the headers of truetype fonts to >> examine their family info. But I can't manage to print out the strings >> without the zero bytes in between each character (they display as a >> black block labe

Re: [Tutor] How to read unicode strings from a binary file and display them as plain ascii?

2005-03-01 Thread R. Alan Monroe
> R. Alan Monroe wrote: >> I started writing a program to parse the headers of truetype fonts to >> examine their family info. But I can't manage to print out the strings >> without the zero bytes in between each character (they display as a >> black block labe

Re: [Tutor] Re: How to read unicode strings from a binary file and display them as plain ascii?

2005-03-03 Thread R. Alan Monroe
print type(stuff), 'stuff', stuff.encode() This prints: stuff [NUL]C[NUL]o[NUL]p[NUL]y[NUL]r[NUL]i[NUL]g[NUL] >> >> >>> I don't understand what you tried to accomplish here. >> >> >> That's evidence of what I failed to accomplish. My expected results >> was to prin

[Tutor] Anyone know of a window utility to reverse engineer unknown binary graphic file format?

2005-03-05 Thread R. Alan Monroe
I know it's a long shot but... I have some graphics files from an old DOS game that I want to convert to a normal .png or whatever. Anyone know of a program that can load binary data and view it multiple different ways? Like treating the raw data as 1 bit, 4 bit, 8 bit, planar, linear, adjust the

Re: [Tutor] (no subject)

2005-03-06 Thread R. Alan Monroe
>> Is the tutor list mirrored on usenet such as google groups? I've >> searched and not found it. > Nope, the archives are available but there is no usenet mirroe. What about this: http://dir.gmane.org/gmane.comp.python.tutor Alan ___ Tutor maillist

[Tutor] Can you get python to force a number to remain 32 bit instead of autoconverting to type 'long'?

2005-03-07 Thread R. Alan Monroe
I tried to convert this pseudocode function IntNoise(32-bit integer: x) x = (x<<13) ^ x; return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fff) / 1073741824.0); end IntNoise function from this website http://freespace.virgin.net/hugo.elias/models/m_perlin.htm to py

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread R. Alan Monroe
> I have a script that converts data relating to my work. > It works great on my Linux system but some of my colleagues run windows. > I am attempting to convert the file paths to windows but am having no luck. > I need to access 'memo.txt' in 'my documents' on windows & am struggling. > I have

Re: [Tutor] help

2005-03-13 Thread R. Alan Monroe
> ok i have learned that on the python shell or new window you can type in..print "hello world"...and the output is ..'hello world'.. or you can > put in anything realy and it say it back to you.is this a program or what Yep, that's a program. Just an ultra, ultra-simple one.

Re: [Tutor] I need some guidance

2005-03-23 Thread R. Alan Monroe
> My first question is do i need to really understand everything first time I > come across or does it get easier if you kind of move along and get back to > it later? My personal experience is that anything makes more sense when you come back to it later, so yes :^) > Third question: Does anyb

Re: [Tutor] comparison function/built-in needed

2005-04-06 Thread R. Alan Monroe
> I am attempting to compare the items in two lists across two criteria - > membership and position. For example: > list_a = [ 0, 4, 3, 6, 8 ] > list_b = [ 1, 8, 4, 6, 2 ] > Membership = There are 3 items that are common to both lists, that is 3 > items in list_a have membership in list_b (viz

Re: [Tutor] Multithreading and Daemon Program

2005-04-13 Thread R. Alan Monroe
> An IP Camera will send images to the server via ftp to a folder. > Each user has a folder and I want to know how I can make my app to > check the folders ('cause there is going to be many cameras sending > files and that means that the app will have to check every folder) > every x seconds? > Wi

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread R. Alan Monroe
> I know that the Eight Queens puzzle is a good recursion candidate, > but I don't understand why as yet. I'm still on simple recursion, > and am just beginning to understand backtracking in a simple > example, like adding numbers in an array. If you make a typo when typing an email, do you delet

Re: [Tutor] high score lists

2005-04-14 Thread R. Alan Monroe
> Anyone have some good beginning ideas/references to creating a high > score list and storing scores in a simple python game? (if there's > something in the pygames module, or a simpler python way). I'm > mod'ing a space invaders-type game and would like to add a high score > list :) Quick and d

Re: [Tutor] Re: newbie intro to pickle

2005-04-16 Thread R. Alan Monroe
> Now my question is how do you keep people from just loading > the high score file with whatever scores they want? > This is not to disparage a simple (and probably very useful) > high score file. It is just something that I have been thinking > about doing myself for quite a while, but I can ne

[Tutor] Has anyone ever tried to convert the textual output of the dis module to another language

2005-04-16 Thread R. Alan Monroe
Just curious. Googling for 'python "dis module" convert "another language" ' only got two hits. So maybe no one is trying it? I was just daydreaming about a native python compiler, and wondered how feasible it would be. Alan ___ Tutor maillist - Tutor

Re: [Tutor] Has anyone ever tried to convert the textual output of thedis module to another language

2005-04-16 Thread R. Alan Monroe
>> Just curious. Googling for 'python "dis module" convert "another >> language" ' only got two hits. So maybe no one is trying it? I was >> just daydreaming about a native python compiler, and wondered how >> feasible it would be. > I hope that your true google search string doesn't contain the t

Re: [Tutor] Has anyone ever tried to convert the textual output of the dis module to another language

2005-04-17 Thread R. Alan Monroe
> R. Alan Monroe wrote: >> Just curious. Googling for 'python "dis module" convert "another >> language" ' only got two hits. So maybe no one is trying it? I was >> just daydreaming about a native python compiler, and wondered how >> feas

Re: [Tutor] Has anyone ever tried to convert the textual output of the dis module to another language

2005-04-18 Thread R. Alan Monroe
>> > Just curious. Googling for 'python "dis module" convert "another >> > language" ' only got two hits. So maybe no one is trying it? I was >> > just daydreaming about a native python compiler, and wondered how >> > feasible it would be. >> >> You might be interested in Pyrex and Psyco: >> http:/

Re: [Tutor] Installation Routines (Joseph Quigley)

2005-04-18 Thread R. Alan Monroe
> He told me that it > was for writing an installation program for Windows and that he considered > python and Tkinter as an option. > I know there are installers written in python for Linux. I suppose they are > easier to write, than one for Windows? > Now, I'm still new, and can't do GUI yet,

Re: [Tutor] TKinter and things over Linux

2005-04-20 Thread R. Alan Monroe
> apt-get and yum are available for Redhat style releases. They will > download and install packages and figure out the dependency issues. > (yum is written in Python so this is slightly on topic.) Gentoo's "emerge" system is also written in Python. Alan ___

Re: [Tutor] Python Challenge - Riddle 2

2005-05-09 Thread R. Alan Monroe
> Hi John, took me awhile to solve this one too, it's quite good, teaches you > about a part of Python that you wouldn't normally use. > Do you want hints or spoilers? > I've give hints for now, search the Python docus for 'trans', check the > string methods. You can also do it with a convolut

Re: [Tutor] Python Challenge - Riddle 2

2005-05-09 Thread R. Alan Monroe
> Am I looking for something like this - > XXXjXXX? or something like XjXX or XXjX? I've also looked for - Take the challenge's hint a little more literally, it's quite specific. This one had me stumped for a little while until I realized my mistake. Alan

Re: [Tutor] zip question

2005-05-10 Thread R. Alan Monroe
> I need some pointers to solve number 7. For what I can see on that picture > the only hint is the gray line inside the .png drawing, but what can I do > with it? > Just tell me where to start and I will try to get from there Have you ever learnt about graphics and pixel colors? You know

Re: [Tutor] Riddle 8

2005-05-11 Thread R. Alan Monroe
> Do I really have to connect the dots > And how can I do that using the obviuos module? I used pygame to do it. Also you could probably do it with Image, to a file (and then view that file with your favorite picture viewer). Alan ___ Tutor ma

Re: [Tutor] Running RPG game again.

2005-05-21 Thread R. Alan Monroe
> I'm trying to make the RPG game to be able to run again. > But, when I type "run", nothing happens. It's because your continue statement on line 45 loops around to line 19 (I double checked in the debugger). Then it checks if the monster is still alive (AGAIN) on line 20, but the monster is al

Re: [Tutor] python/ pygame on XP: window not responding

2005-06-29 Thread R. Alan Monroe
> I am a new python/ pygame user. In attempting the simple > command pygame.display.set_mode((640,480)) > The newly created window is not responding. I am using these programs with > the Windows XP operating system. Can you provide any suggestions or help > with this issue?? Does the chimp.py ex

Re: [Tutor] [pygame] Fwd: A more Pythonic way to do this

2005-07-05 Thread R. Alan Monroe
> should be returning each to its original starting position. Since I > create initialx/initialy for each enemy when the screen full of > enemies is drawn (and I know I do create a new initialx/initialy for > each one - because I had it print the initialx, initialy when the > screen was drawn and I

Re: [Tutor] OT python Licences

2005-07-14 Thread R. Alan Monroe
> As far as I know, all GTK+ 2.x > applications under Windows have a native look. I don't know my self as > I don't have Windows. My personal experience is that GTK apps (Ones I've used like GAIM, Inkscape, Ethereal) on Windows stick out like a sore thumb, GUI-wise. They tend not to use the same

Re: [Tutor] Performance difference, ``in'' vs ``has_key()''

2005-07-17 Thread R. Alan Monroe
> Is there any significant performance difference between the > tests, ``key in dictionary'' and ``dictionary.has_key(key)''? > I would prefer using the ``key in'' because it's a bit easier to > type, and can also be used with lists in addition to dictionaries. Dunno about speed, but they do disas

Re: [Tutor] Web Browser in Python

2005-08-03 Thread R. Alan Monroe
>> I need to program a web browser in python.I dont have any idea of how to >> start, what i do have is time and willingness to learn.Could anyone direct >> me to some suitable reference? >> Shitiz >> > How about Grail http://grail.sourceforge.net/ ? Looks neat, but it doesn't run on my box: C

Re: [Tutor] XMMS song search

2005-08-07 Thread R. Alan Monroe
> songsearch = raw_input(Enter song name: ") > f = file(/home/joe/.xmms/xmms.pls) Don't forget your quotation marks around the filename. > f.find(songsearch) You _find_ stuff in strings, not in the file itself. Read each line of the file one at a time, because each line will be a string. for

Re: [Tutor] screen scraping web-based email

2007-04-18 Thread R. Alan Monroe
> I'm starting graduate school (econ!) in the Fall; the school I'll be > attending uses Lotus for email You can drive the fat client via COM if you install the Win32 extensions for python. > (I know I could do it with a torturous combination of applescript and Except judging by this, you're on

Re: [Tutor] trying to figure out what this means

2007-05-07 Thread R. Alan Monroe
> when you are doing print these two characters keep showing up in this book > "%s" % > What do they do? "Fill in the blank" Kind of like generic paper forms where they have a blank underline for you to fill in your information. Give it a variable name, and it will fill in the "blank" (the %s)

Re: [Tutor] Sum of Scores

2007-07-26 Thread R. Alan Monroe
> I want to be able to calculate in the program,.. the total score,.. > either at each successive score,... or when they finally get out. > Not sure how to do that at this point. You're on the right track. You need an additional variable to hold the running total. Alan _

Re: [Tutor] LosingtheexpressivenessofC'sfor-statement?/RESENDwithexample

2007-08-11 Thread R. Alan Monroe
> "Noufal Ibrahim" <[EMAIL PROTECTED]> wrote >> I think such treatment of the various python constructs should be >> reserved for documents like say, "Python for C programmers"( > Actually that's not a bad idea, except I'm not sure such convertion > courses exist? > But it would be useful to ha

[Tutor] A fun puzzle

2007-08-22 Thread R. Alan Monroe
I wrote a lame, but working script to solve this in a few minutes. A fun puzzle. http://weblogs.asp.net/jgalloway/archive/2006/11/08/Code-Puzzle-_2300_1-_2D00_-What-numbers-under-one-million-are-divisible-by-their-reverse_3F00_.aspx Alan ___ Tutor mai

Re: [Tutor] Logging with proper format

2007-10-07 Thread R. Alan Monroe
> logger.info("Checked %s records in %s seconds, yielding an average of > \ > %s seconds per record." % (len(self.data), duration, avgquery) ) ^ Remove these spaces. It makes the source code look weird, but the output will be correct. Alan _

[Tutor] How to get python to differentiate between CR, LF, and CRLF in a string (not a file)?

2007-12-14 Thread R. Alan Monroe
Is is possible to get python to differentiate between CR, LF, and CRLF in a string (not a file)? This is a triple quoted string I've pasted into the source (putting r to indicate raw string made no difference). It contains a mixture of CR, LF and CRLF (I can see this by enabling visible End of Line

Re: [Tutor] Program Specification Request

2008-01-16 Thread R. Alan Monroe
>I would like to learn and teach my 2 girls a mini > database GUI program in Python and >They are Girl Scouts (and advanced MS & HS > students) http://davidbau.com/archives/2005/07/29/haaarg_world.html Alan ___ Tutor maillist - Tutor@py

Re: [Tutor] how to parse a multiple character words from plaintext

2008-02-23 Thread R. Alan Monroe
> I am looking to parse a plaintext from a document. However, I am > confused about the actual methodology of it. This is because some of > the words will be multiple digits or characters. However, I don't > know the length of the words before the parse. Is there a way to > somehow have open() grab

Re: [Tutor] What can I do with this code?

2005-08-09 Thread R. Alan Monroe
> print random.choice(cool) > What can I do with it, other than let it be a fun example of coding? Make a Magic 8 ball! :^) Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How can I make this run right?

2005-08-15 Thread R. Alan Monroe
> The following code is supposed to take in a number, and print number!: > n = int(raw_input("Number: ")) > x = n-1 > while 1: > t = n*x > while x > 1: > x -= 1 > else: > break > print t > Why isn't it working, and how can I make it print out the correct output? One th

Re: [Tutor] Searching Sorted Lists

2005-08-21 Thread R. Alan Monroe
> [EMAIL PROTECTED] wrote: >> Hi, Can someone tell me if there is a bulit in Binary search function for >> python lists ? >> >> I am currently building lists and sorting them with a comparison function. >> The only list search function I know is List.Index(X), which is pretty >> inefficient I reck

Re: [Tutor] Network Programming Information and terminology

2005-08-22 Thread R. Alan Monroe
> Hello. It's me again. Thanks for all the help with > the Python Networking Resources, but does anyone know > what I'll need to know to write a paper on Network > Programming and Python. Like terminology and all > that. Maybe I'll have a section on socketets, TCP, > Clients (half of the stuff I

Re: [Tutor] running scripts with windows

2005-09-15 Thread R. Alan Monroe
>> Cygwin (http://www.cygwin.com/) It gives you a bash shell in >> Windows. > Actually it gives you a whole Unix environment including X Windows > and over 500 unix command line tools plus GNU C, sendmail, etc etc... Watch out, because cygwin-native python can conflict with win32 python, if the

Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread R. Alan Monroe
> Bernard Lebel wrote: > >>> import math > >>> math.acos(-0.0634) > 1.6342388771557625 > >>> math.degrees(_) <--- in all my time on tutor I have never noticed this underscore trick before > 93.63499037722380

Re: [Tutor] Binary 2 text & text 2 binary

2005-09-23 Thread R. Alan Monroe
> I thought lists would be the best but I really don't know how to use > them They're easy. Just put stuff in square brackets with commas between. mycoollist = [1,5,9,3,6,9,2,6] mystringlist = ['a', 'u', 'e', 'b', 'd', 'h', 'q', 't'] Can you predict what this code will do? print mycoollist[0]

Re: [Tutor] Sum of List Elements

2005-09-24 Thread R. Alan Monroe
> Hi All, > I have spent an embarrassingly large amount of time trying to solve what on > its face seems like a simple problem. > I have a list of intergers, and I want to assign the sum of the intergers in > the list to a variable. There are only intergers in the list. > The best I have been ab

Re: [Tutor] printing an acronym

2005-09-24 Thread R. Alan Monroe
> Hello > How could I get the following to print out an acronym for each phrase > entered such as if I entered random access memory it word print out RAM? > import string > def main(): > phrase = (raw_input("Please enter a phrase:")) > acr1 = string.split(phrase) > acr2 = string

Re: [Tutor] 'print' without newline or space appended

2005-09-25 Thread R. Alan Monroe
> Hello, > This statement: > for c in 'hello': print c > will generate following output: > h > e > l > l > o > and by adding comma at the end of the print statement: > for c in 'hello': print c, > we get this output: > h e l l o > How do I output something using 'print' such that t

Re: [Tutor] script question

2005-09-26 Thread R. Alan Monroe
> for i in passwordlist: > if i == port: > os.system("d:\\tnd\\bin\\cawto.exe -cat NetNet " + sys.argv[1] + " " + >sys.argv[2] + " " + sys.argv[3] + " " + sys.argv[4]) If you don't have duplicates in your list, a "break" after the os.system line might help, because once you've found

Re: [Tutor] 2 questions......novice but not beginner

2005-09-27 Thread R. Alan Monroe
> I need to know how to render graphics without the windowed enviroment.I > know with pygame you can have a windowless enviroment but I need to be able > to have only the graphics i choose displayed on the screen without pygame > filling the rest of the screen with black if thats possible. No

Re: [Tutor] Embedding

2005-09-27 Thread R. Alan Monroe
> Well we are three programmers. I know python, another knows Java and the > other C++. We are trying to figure out how to combine all three > langauges to make a game. I checked out this book from the local library: MUD Game Programming by Ron Penton http://www.amazon.com/exec/obidos/tg/detail/-

Re: [Tutor] Frustrated Beginner

2005-09-28 Thread R. Alan Monroe
> I am trying to learn Python to use in my lesson plans. I am using Windows XP > and the textbooks I am using are Beginning Python by WROX and Learning > Pyhton by O'Reilly. > I am definning a range of words 0 to 55, if the number is divisible by > 3,7,11 with no remainder print eggs, else prin

Re: [Tutor] Generalising system processes

2005-09-29 Thread R. Alan Monroe
> Is there a library in Python that generalises the display of processes > in the system. > I am looking for a consistent way of seeing processess, (a python > equivalent of ps(unix) or tasklist (windows). > I have googled but the only suggestion I have found was to install ps > on Windows. On Wi

[Tutor] Did anyone get the Kamaelia "Conversing" chapter 5 to work?

2005-10-06 Thread R. Alan Monroe
I was working through their tutorial: > * http://kamaelia.sourceforge.net/MiniAxon/ Chapter 5 claims the output should be: Hello World 2 Hello World 3 ... Hello World 97 Hello World 98 But mine outputs only: Hello World 2 (no further output) I can see in Pythonwin's debugger that p.boxes['o

Re: [Tutor] Did anyone get the Kamaelia "Conversing" chapter 5 to work?

2005-10-06 Thread R. Alan Monroe
>> I can see in Pythonwin's debugger that p.boxes['outbox'] fills up with >> the hundred or so messages intended for display, but they never get >> displayed. I suspect an indentation problem, but I can't spot it, even >> stepping through in the debugger. > I made exactly the same mistake! You hav

Re: [Tutor] Did anyone get the Kamaelia "Conversing" chapter 5 to work?

2005-10-06 Thread R. Alan Monroe
> I've just double checked what happens when running the contents of that > page, and it works as expected (here at least), so I suspect the problems > you're seeing are simply due to "code being in HTML" issues. Yeah I was writing as much as I was able on my own rather than copying/pasting the co

Re: [Tutor] Did anyone get the Kamaelia "Conversing" chapter 5 to work?

2005-10-08 Thread R. Alan Monroe
> On Friday 07 October 2005 03:04, R. Alan Monroe wrote: > That's great to hear - not the oversight part but the fact you were talking > about your work. Out of interest, how did you find the tutorial/exercises and > what level of experience would you say you have? Around 2-3

Re: [Tutor] Please look at my wordFrequency.py

2005-10-10 Thread R. Alan Monroe
> IDLE's debugger isn't pretty but it does work, try it. > Use the context menus and mouse to set a break point, > then just step through using the step and next buttons. Has anyone else experienced this? I tried debugging in IDLE with the source checkbox enabled, but when the sourcecode window lo

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread R. Alan Monroe
> From: "Jeff Peery" <[EMAIL PROTECTED]> >> is it possible to take python code and compile it for use in a >> microprocessor? >> > In the same way that Sun have been threatening to build a chip that has Java > as its machine code then it would be possible to build a chip that ran > Python > byte

Re: [Tutor] : Threads?

2005-10-22 Thread R. Alan Monroe
> I wanted to find out whether os.system() calls block other threads. > It seems that they don't. (That's a good thing, it means it should > work for you!) Here is a program to test this: For threads that run longer than a few seconds, you can visibly verify this with Sysinterals Process Explorer

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread R. Alan Monroe
>> I send a command to os.system(cmd) and want to send a break signal in >> the same way. Is this possible? The break signal is ctrl c (^c). >> I tried this, but it didn't work: os.system('\x03') I think Hex 03 is >> the signal for ctrl c. > Its not possible with os.system because os.system runs

Re: [Tutor] Can anyone help me?

2005-10-27 Thread R. Alan Monroe
> Hey all, > I am trying to create a program that draws 6 numbers between 1 and 49 at > random for creating lottery tickets. I want to have a better chance when I > play. Can anyone help me code this or show me how > to, please? Create (empty for now) list to hold your final numbers. Have a for-

Re: [Tutor] Recursion and List Comprehensions

2005-10-28 Thread R. Alan Monroe
> Unfortunately, I don't understand how list comprehensions work and how to > implement them. Can someone point me in the right direction, please. Compare these two pieces of code x=[1,2,3,4] y=[] for eachnum in x: y.append(eachnum * 2) versus x=[1,2,3,4] y = [each * 2 for each in x

Re: [Tutor] while/if/elif/else loops

2005-10-31 Thread R. Alan Monroe
> while tosses = 100<0: I didn't run the program, but this immediately caught my eye as looking kind of suspect. Was it a typo? Most programs usually have a need for comparisons of equal, or greater/less, but it's really rare to need both combined in one statement... Also if you really _do_ want

  1   2   >