Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-15 Thread Luke Paireepinart
ate_age(self): birth_date = date( self.year, self.month, self.day) date_today = date.today() time_delta = date_today - birth_date number_of_years = time_delta.days / 365 return number_of_years I don't think you really want to inherit from date. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] [Fwd: Re: Is Python the language for me?]

2007-01-15 Thread Luke Paireepinart
scale use, even rcs is adequate for single user scenarios. Luke: I think if you have a large project in Python, the equivalent project in C++ would be much harder to manage. Not necesarily true since the C++ header/implementation paradigm and strict typing leads to more easily managed code. But a

Re: [Tutor] Difference between 'yield' and 'print'

2007-01-17 Thread Luke Paireepinart
pt: #we ran out of things to generate (the generator stopped yielding results -- supposedly it raises an error here?) print "End of generator." break Anyway, I've never used them but that sounds like a reasonable way for them to work. If you'd like a better explanation you might poke around Alan Gauld's tutorial, he probably has a section on generators. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sets in python

2007-01-21 Thread Luke Paireepinart
anil maran wrote: > http://www.linuxforums.org/programming/introduction_to_python__part_1.html > > [snip article excerpt] why did you copy someone else's text verbatim and create a new thread? Assuming you were trying to

Re: [Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress

2007-01-21 Thread Luke Paireepinart
János Juhász wrote: > Dear Karl, > > > I use getch() when I start my script from the windows desktop and > I am interested about its output. > > import msvcrt > raw_input('Are you distressed ?\n') > print ('It will be better, I am sure :)') > msvcrt.getch() # append as last line And where is the i

Re: [Tutor] direction and draw

2007-01-22 Thread Luke Paireepinart
linda.s wrote: > I have a segment (two ending points are A and B) which is 0 degree. > How to draw a segment with 10 degrees and 15 in length? > You'll need a pen, some paper, a protractor, a ruler, and a steady hand. Good luck. -Luke ___

Re: [Tutor] pyw bug ?

2007-01-22 Thread Luke Paireepinart
mm, maybe check where sys.stdout is directed? -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Inputting elements of a list

2007-01-22 Thread Luke Paireepinart
gt;> int('1000') Traceback (most recent call last): File "", line 1, in ? int('1000') TypeError: 'int' object is not callable HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Branches

2007-01-23 Thread Luke Paireepinart
vanam wrote: > > i started slowly learning python as i dont have much exposure to it > and i wanted to know what are all branches there in python actually i > installed py 2.5 recently i come across question in groups about the > gui where in pygtk should be installed.My question is without thi

Re: [Tutor] Global values & import scope

2007-01-24 Thread Luke Paireepinart
can accomplish the same thing with a variable that is global to all instances of the class. something like (may not work): class Foo: itemID = 0 def __init__(self): itemID += 1 HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tracking time

2007-01-24 Thread Luke Paireepinart
learn how to use it. It's unclear what exactly a 'project' is from your e-mail so my reply is similarly vague, sorry. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python re without string consumption

2007-01-24 Thread Luke Paireepinart
> > def searchall(expr, text, fall_back_len=0): > [snip] > > text = text[end-fallbacklen:] oops, those look like two different variables to me. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] converting tab-delimited text files to csv

2007-01-26 Thread Luke Paireepinart
arated values, right? you should be able to just do a string replace of tabs -> commas on each line in the new file... or is the csv format more complicated than that? -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reassigning/replacing sys.stdout

2007-01-30 Thread Luke Paireepinart
of object it's calling, just that it has a method called 'write', you can write your own object and drop it in here. E.G. class GuiUpdater(object): def write(astring): #update your textbox here. sys.stdout = GuiUpdater print 'teststr' Hmm, actually that mi

Re: [Tutor] Python 2.5 and PHP 5.2.0

2007-02-01 Thread Luke Paireepinart
ct back to the PHP file with whatever data you want to return. However, this is a bad way to go about it. You should be able to use python scripts on the server side without relying on the client's browser to pass data. Not exactly sure how

Re: [Tutor] How does this work?

2007-02-07 Thread Luke Paireepinart
-- no separate processes, threads, or any of that nastiness. Because it's imported, the contents of the 'if __name__...' conditional statement are never executed, so the cmdline functionality is disabled. Hope that helps, -Luke > Using popen() in a thread was a nice clean way

Re: [Tutor] Range of float value

2007-02-08 Thread Luke Paireepinart
35 <= a <= 48.45) to (assuming the right condition is met) if (48.35 <= true) because it evaluates these things right to left, doesn't it? does python treat chained comparisons differently than C++ or is C++ behaving differently than I think it does? Thanks for your help, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Range of float value

2007-02-08 Thread Luke Paireepinart
Kent Johnson wrote: > Luke Paireepinart wrote: >> Kent Johnson wrote: > >>> You can't generate all the float values in a range. (OK, you >>> probably could, but it would not be practical or useful.) You can >>> test for a value in a range, e.g. >&g

Re: [Tutor] Creating an Identifier or Object Name from a String?

2007-02-10 Thread Luke Paireepinart
; > def __init__(self, id): > self.name = id > > # main > cmdstr = "Ireland = nsf('Ireland')" > eval(cmdstr) > >>> exec('x = "hello"') >>> print x hello you're using the wrong function

Re: [Tutor] Trouble getting os.execl() command to work

2007-02-10 Thread Luke Paireepinart
27;cr2': > jpg_dest = name[:-4]+".jpg" > cmd_string = "/home/richard/ExifTool/exiftool -TagsFromFile " > + name + " -exif:all " + jpg_dest > print cmd_string#this string l

Re: [Tutor] question about importing threads

2007-02-11 Thread Luke Paireepinart
shawn bright wrote: > great, saves me 15 lines. > thanks You have 15 lines of imports? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accessing class attributes: use methods only?

2007-02-13 Thread Luke Paireepinart
unctionality in a method. You probably want to wait for someone else to answer, because they'll be able to give you more information on whether or not it's bad. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question

2007-02-14 Thread Luke Paireepinart
Alan Gauld wrote: > "Doug Potter" <[EMAIL PROTECTED]> wrote > >> I don't get the output I would expect from the following. >> > > > a = open('arp.txt') > file = a.read() > file = file.split('\n') > > > Easier to do > > file = open('arp.txt').readlines() > > Bu

Re: [Tutor] question

2007-02-14 Thread Luke Paireepinart
shell you mean you have a python interpreter you can type statements into, right? the default prompt for the interpreter is >>>. HTH, -Luke > > > > ___ > Tuto

Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Luke Paireepinart
Rikard Bosnjakovic wrote: > On 2/15/07, Nathan Pinno <[EMAIL PROTECTED]> wrote: > > >> and that was a suggestion. (Thanks!) But can anyone explain why I can >> shorten the code? I looked at it a long while yesterday, and came up with >> nothing. The only thing I decided was to try to get it to t

Re: [Tutor] Replying to the tutor-list

2007-02-15 Thread Luke Paireepinart
Bill Campbell wrote: > The major reason for not setting Reply-To: thelist is that it makes it > *SLIGHTLY* more difficult to post something to the list and replys should > go to the sender. IHMO, one should have to go to a little bit of effort > before posting a message that may go to thousands of

Re: [Tutor] Main program confusion

2007-02-19 Thread Luke Paireepinart
this module. Where did this code come from? Have you tried the code? Either run is some builtin I haven't heard of, or the code is in some library/turorial that defines a custom module. -Luke > > What am I missing? > > Thanks for any help. > > Les Hazlett > >

Re: [Tutor] Main program confusion

2007-02-19 Thread Luke Paireepinart
anything else. Coincidentally, Idle has a module named 'run' and since the interpreter's current working directory is IDLE's directory, it imports that one. Try using the commands import os os.chdir("Path/To/Demo/Directory") and import the module. You should get the correct one, then. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to read one bit of a byte

2007-02-20 Thread Luke Paireepinart
w do i know what the msb of a is ? > > i need to know because i have to see if the msb is set and i also need > to know the value of the next bit. Well, you know the value of the MSB is... 1 2 4 8 16 32 64 128 so if you divide the value by 128, and get a 1 and not a 0, then it's set. Peop

Re: [Tutor] list problem

2007-02-20 Thread Luke Paireepinart
ou give us an excerpt, the cliffs notes version, if you will, than for one of us to read through your code. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] list problem

2007-02-20 Thread Luke Paireepinart
is forwarded to the list, so use a 'reply-all' on it so everyone can see your reply. -Luke Original e-mail: Kirk Bailey wrote: > ok, here comes some code: > > f1=open(pagename,'r') > page=f1.readlines() > f1.close() > > at the end of which, the data is i

[Tutor] [Fwd: Re: list problem]

2007-02-21 Thread Luke Paireepinart
Please stop sending me private messages. And as I said before, include the file as an attachment. It does us no good to see the text. We need to see the line endings. And your (or my) e-mail program may mess with these. -Luke --- Begin Message --- Sure. Here's the PAGE source. i already p

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread Luke Paireepinart
hat i do not add them. > > like byte_a = 39 > byte_b = 138 > > together, they make 2599 > > in hex they look like this > byte_a = 0x27 > byte_b = 0x8A > > together = 0x0A27 > > i am making the integers with ord(a) and ord(b) > > how do i put them to

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread Luke Paireepinart
erations: >>> 0x0A * 256 + 0x27 2599 >>> 0x0A * 2**8 + 0x27 2599 But like Kent said, you probably should use struct or something like that. Just in case you're interested, I'm sending this e-mail as well. HTH, -Luke >> > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] miniwiki 1.3 BETA bugs

2007-02-23 Thread Luke Paireepinart
Kirk Z. Bailey wrote: > ok, let's post this again. last time went into purgatory instead of the list. > hmmm > > I am working on updating miniwiki. the current beta code has rendering > problems with wikiwords and external sites under some circumstances. What circumstances are these, exactly

Re: [Tutor] Dictionaries of Tuples of Strings

2007-02-23 Thread Luke Paireepinart
>>> x = ('somestring') you might think it's creating a single-value tuple, but it's not. Consider this: y = 5 z = 23 x = (y * (z + y) / y ** 3) In this case you wouldn't expect these parenthesis to build tuples, would you? Hope that helps somewhat, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread Luke Paireepinart
last 4 bits are in the first item. Hope that helps. It's better if you take the time to really understand what is happening in all these cases, so you won't have to experiment with trial and error. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Dictionaries of Tuples of Strings

2007-02-23 Thread Luke Paireepinart
Tim Golden wrote: > Luke Paireepinart wrote: > >> That's because you can't make tuples of single values. >> Parenthesis are ways of controlling order of operation. >> They don't create tuples unless there's more than one value. > >> Think o

Re: [Tutor] Dictionaries of Tuples of Strings

2007-02-23 Thread Luke Paireepinart
Terry Carroll wrote: > On Fri, 23 Feb 2007, Luke Paireepinart wrote: > > >> That's because you can't make tuples of single values. >> Think of it like this: >> a TUple needs TWO elements or more. >> > > No, a tuple can also be of one

Re: [Tutor] Group sequence pairwise

2007-02-25 Thread Luke Paireepinart
g a None at the end. That's just the way I chose to do it, but if you need it to not modify it should be possible as well. HTH, -Luke > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Telnet and special characters

2007-02-27 Thread Luke Paireepinart
Down arrow You could have a special sequence of characters that wouldn't normally be used, like \1\1\2\3\1\2\4, and if the server receives this, you can use pyHook or something to generate a keypress on the other end. It seems to me that the function k

Re: [Tutor] httpd in your laptop?!? serve web pages and wikis in your notebook?

2007-02-27 Thread Luke Paireepinart
want to make the user have to install another webserver to use your program. You're writing it in Python, why not use a Python HTTP server library, and have that included in your distribution when you py2exe it? It seems by far a better solution. JMO, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Two sys.exit questions

2007-02-28 Thread Luke Paireepinart
') sys.exit(0) except IOError: print "You had an error on file input" hope that clears some things up for you. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Two sys.exit questions

2007-02-28 Thread Luke Paireepinart
to open for input, so it will throw an IOError and print out "You had an error on file input" If you do have such a file, the assignment to f will pass successfully, sys.exit will throw a SystemExit, and the except block won't catch it because it

Re: [Tutor] httpd in your laptop?!? serve web pages and wikis in your notebook?

2007-03-02 Thread Luke Paireepinart
> forth uses a dictionary to locate and execute all its functions and > subfunctions. it is a threaded language. so it spends much of it's > time looking up functions in the dictionary. in large programs this > results in the majority of it's excecutiojn time being spent in the > dictionary, a

Re: [Tutor] using tarfile on strings or filelike objects

2007-03-02 Thread Luke Paireepinart
Barton David wrote: > I like that I can access the contents of a zip archive that's stored > in memory (rather than on disk) by packing the archive contents into a > StringIO or cStringIO object and feeding that to ZipFile... > > i.e. > > filelike=cStringIO.StringIO(archive_as_string) > zf=zi

Re: [Tutor] Regular expressions - Ignoring linefeeds

2007-03-02 Thread Luke Paireepinart
rst, yield is a reserved keyword in python 2.4+ (probably earlier, too.) Second, re.match takes 2 arguments, not 1. What you really want to do is re.match(snippy,s) > > Anything after the linefeed is not matched, yielding naught but pain. Nothing is matched because the code doesn't work. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Regular expressions - Ignoring linefeeds

2007-03-02 Thread Luke Paireepinart
Kent Johnson wrote: > Luke Paireepinart wrote: > >> doug shawhan wrote: >> >>> I've been looking through various sites, but cannot find the magic >>> button that allows me to match a string with linefeeds >>> I'd rather not strip out

Re: [Tutor] trouble with function-- trying to check differences btwn 2 strings

2007-03-06 Thread Luke Paireepinart
gests what's really happening is >>> (0 == 0) in word2 True So it's searching the list for anything that makes the condition true. But that's not actually true. >>> (555 == 555) in word2 True >>> 555 == 555 in word2 False So It appears to

Re: [Tutor] trouble with function-- trying to check differences btwn 2 strings

2007-03-06 Thread Luke Paireepinart
d to. def stringdiff(string1,string2): return [i for i in range(len(string1)) if string1[i] != string2[i]] but I doubt your professor has covered list comprehensions yet, so the way you solved the problem is most likely what he was looking for. -Luke ___

Re: [Tutor] executing a string representing python code

2007-03-06 Thread Luke Paireepinart
de you read in from a plain text file, they could change easily. HTH, -Luke > > --C > > 2007/3/5, ALAN GAULD <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>>: > > > That's neat. When just the function call is the string, > > eval() seems approp

Re: [Tutor] What/Why this Cookbook recipe?

2007-03-06 Thread Luke Paireepinart
if you decide to > make a user class and get rid of the username and userage vars. > I don't see what you mean here. The string in the example, interp('Name: #{username}\nAge: #{userage}') could be translated too. > - format strings give you more control, so you can e.g. specify how many > digits a float should have when formatted. The dictionary method would allow you this control. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Best IDE for python?

2007-03-08 Thread Luke Paireepinart
has a list of *IDEs*. This question is asked every few weeks on comp.lang.python so searching the archives will yield many opinions. " HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] please unsubscribe me

2007-03-09 Thread Luke Paireepinart
Please read the text of what you just posted: See that part down there that says 'to unsubscribe'? I bet that's a good starting point. [EMAIL PROTECTED] wrote: > On Thu, 08 Mar 2007 03:00:15 -0800 [EMAIL PROTECTED] wrote: > >> Send Tutor mailing list submissions to >> tutor@python.org >> >

Re: [Tutor] Roman Numeral - To - Digital Converter

2007-03-11 Thread Luke Paireepinart
x,l,c,d, or m, how would I tell Python to capitalize those and go > on with working the function? > >>> 'heLlo'.upper() 'HELLO' >>> print 'i' in 'hilly' True >>> print 'i' in 'holy' False I hope that gives you some clues. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] cookie expiration date format

2007-03-16 Thread Luke Paireepinart
okie to expire 24 hours from now, time.time() + 3600 * 24 #(seconds in a day) See http://en.wikipedia.org/wiki/Unix_epoch for more info on the epoch. look into the time and the datetime modules, there should be an easy way to find the seconds since epoch for whatever date you want. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Built-in function to check a character is ASCII character?

2007-03-16 Thread Luke Paireepinart
ammar azif wrote: > Is there any Built-in function to check whether a character is an > ASCII character? > > I am trying to learn event driven programming in python. Heres my code: > > while 1: > key=msvcrt.getch() > if key==255: > continue Here's your problem. >>> import msvcrt

Re: [Tutor] Rounding number

2007-03-18 Thread Luke Paireepinart
Per Jr. Greisen wrote: > Hi, > > I use the method from math in order to round off the number: > > import math > > a = 1.3 > > b = round(a,3) > > which equals gives > b=1.4 > > is it possible to have the rounding such that > b = 1.400 Trailing zeroes aren't significant values so the computer won

Re: [Tutor] breaking the 'while' loop

2007-03-20 Thread Luke Paireepinart
> > > I want to limit the number of tries to 5. To do that, I have tried the > /_if structure_/ along with the /_break statement_/ immediately below the > > ‘tries += 1’ line: > Or you could just add this condition to the while loop. while (guess != the_number and tries < 6): > > if tries > 5: > >

Re: [Tutor] Should I use python for parsing text

2007-03-20 Thread Luke Paireepinart
eandata.txt file > I got: > > A.-C.䴀愀渀甀昀愀挀琀甀爀椀渀最 �Company.⠀匀攀攀�Sebastian,䄀⸀�A.,�and > 䌀愀瀀攀猀Ⰰ�assignors.)�A.䜀⸀�A.刀愀椀氀眀愀礀 �Light☀�Signal䌀漀⸀� > (See䴀攀搀攀渀Ⰰ�Elof�Hassignor.)�A-N䌀漀洀瀀愀渀礀Ⰰ�The.⠀匀攀攀 > �Alexander愀渀搀�Nasb,愀猀ⴀ�猀椀最渀漀爀猀⸀㬀�䄀一�Company,吀栀攀⸀� > (See一愀猀栀Ⰰ�It.䨀⸀Ⰰ�and䄀氀攀砀愀渀搀攀爀Ⰰ�as-� Not sure what caused all of those characters. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Should I use python for parsing text

2007-03-22 Thread Luke Paireepinart
Jay Mutter III wrote: > Luke; I'm a bit pressed for time right now and I can't look over this e-mail. Please reply on-list in the future using the 'reply-all' feature. You're more likely to get a prompt response. (this e-mail is carbon copied to the list, so don&#x

Re: [Tutor] Developing a GUI application

2007-03-23 Thread Luke Paireepinart
Terry Carroll wrote: > I'm pretty much just a dabbler in Python. > > Up to now I've mostly been doing line-oriented programs, but I have a > small app I want to write that I think would be a good candidate to write > as a GUI-based app. > > I'd like advice from the more seasoned programmers here:

Re: [Tutor] Developing a GUI application

2007-03-23 Thread Luke Paireepinart
R. Alan Monroe wrote: >> On Fri, 23 Mar 2007, Luke Paireepinart wrote: >> > > >> I've also thought of having a twist here for MP3 files, specifically, >> distinguishing between the files' audio frames and identification info >> frames, and ch

Re: [Tutor] 3 recent short essays by Kent Johnson

2007-03-28 Thread Luke Paireepinart
: > http://www.pysig.org > Ah, never before have I desired more to live in New England ;) . Wish I could check that out, Kent. Sounds like great fun. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Filesystem vs Database vs Lucene OOPS

2007-03-28 Thread Luke Paireepinart
>50. Please confirm that average length IS 50? > I need to implement a system which stores Strings(average length 50 > chars). is how it showed up on my computer, so I bet the > sign is really just those things e-mail clients add to denote quoted text. -Luke

Re: [Tutor] reafline reads file, not just 1 line

2007-03-29 Thread Luke Paireepinart
t; Let us take a gander at this file. Include it as an attachment. I see no reason why your code wouldn't work. You sure you didn't accidentally make the first a call to readlines()? (note the 's') -Luke > > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reafline reads file, not just 1 line

2007-03-30 Thread Luke Paireepinart
Kirk Bailey wrote: > #!C:\Python25\pythonw.exe #! is only for Unix, it's pointless here. > # > import os, os.path, random, sys, string, time, cgitb; cgitb.enable() > # > print "Content-Type: text/html\n" > # > try: > pagename=os.environ['QUERY_STRING']# try to retreive the page > name req

Re: [Tutor] reafline reads file, not just 1 line

2007-03-30 Thread Luke Paireepinart
for source code (and input files and such). E-mail clients will wrap code at odd places, mess with tabs and spacing, and things like that. You should always send source as an attachment unless it's a short snippet (or you don't expect people to run it). Well, your problem got so

Re: [Tutor] windows and python and shebangs, oh my!

2007-04-04 Thread Luke Paireepinart
this issue in reply to your readlines question earlier: """""""""""""""""""""""""""""" Kirk Bailey wrote: > #!C:\Python25\pythonw.exe

Re: [Tutor] Command line args

2007-04-09 Thread Luke Paireepinart
ents. > filename='FooBar' > You said you wanted the input from standard input, so just put a raw_input here. so the new code is: try: filename = sys.argv[1] except IndexError: filename = raw_input("Prompt: ") HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] [Fwd: Re: Command line args]

2007-04-09 Thread Luke Paireepinart
filename=sys.argv[1] if condition: do something else: do this instead else: filename="foo" which avoids try altogether. It terminates your program if the precondition isn't met, instead of u

Re: [Tutor] ANN: Next NYC Python User Group meeting, Tues May 8th, 2007, 6:30 pm

2007-04-11 Thread Luke Paireepinart
John Clark wrote: > My apologies for the comical timing of the below announcement - I > actually sent the announcement on April 4th, but it obviously didn't > clear the moderator's desk in time for the meeting mentioned below. > In an attempt to avoid this same problem, let me announce next mon

Re: [Tutor] Correct way to call an outside program?

2008-03-13 Thread Luke Paireepinart
Allen Fowler wrote: > Thank you for the help. :) > > - Original Message > > simplest way to run external commands ! > > import os > cmd="/usr/bin/ssh 10.0.0.20 uptime" > os.popen(cmd) This is deprecated in python 2.5+. Use subrpocess instead of os.popen to make sure y

Re: [Tutor] hypotenuse

2008-03-13 Thread Luke Paireepinart
while, lambda, def, is, and, and names like that. For example: >>> int('12345') 12345 >>> int = 3 * 3 >>> int('12345') Traceback (most recent call last): File "", line 1, in int('12345') TypeError: 'int' ob

Re: [Tutor] noob python cgi

2008-03-15 Thread Luke Paireepinart
void e-mail programs mangling the code, unless it's just a few lines. Thanks, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Stupid Pythony Newbie Question: Basic Operators;

2008-03-16 Thread Luke Paireepinart
y should give us a specific case where you don't understand, cause then we could explain it better. By the way, don't put [TUTOR] in the subject. The mailing list automatically adds [Tutor] so if you manually add it, it just makes your subject harder to read because there are then two tags. Hope that helps, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to get response from os.system()

2008-03-16 Thread Luke Paireepinart
shawn bright wrote: > Lo there all, > > I am needing to get a response back from a system command. > i can do this: > > os.system('mailq | wc -l") > > if i do this in the terminal mailq | wc -l , it will spit out a number. > How do i get that number as a python variable ? You need to use t

Re: [Tutor] how to get response from os.system()

2008-03-16 Thread Luke Paireepinart
linuxian iandsd wrote: > use os.popen("your cmd here") This is deprecated in 2.5+, you're supposed to use subprocess module now. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to get response from os.system()

2008-03-16 Thread Luke Paireepinart
Nathan McBride wrote: > Would you mind perhaps show an example running an interactive command like su > and show how to send input to the commands waiting propmts? Using the subprocess module, open a command and save the stdin and stdout pipes as variables. Then write to the stdin to send data t

Re: [Tutor] python, wxpython and postgresql

2008-03-17 Thread Luke Paireepinart
al, we can help you with that as well. > Can someone point me in the right direction. > It's always helpful to do a bit of googling before you ask. You don't want people assuming you're just being lazy ;) > I've got more specific questions but figured this

Re: [Tutor] how to get response from os.system()

2008-03-17 Thread Luke Paireepinart
Nathan McBride wrote: > That's a great tip I'll have to save than. Nathan, I'm not sure why you sent this three times, but we've gotten it, if you're worried about it. Thanks, -Luke ___ Tutor maillist - Tutor@python.org ht

Re: [Tutor] Need help with structure unpacking module

2008-03-18 Thread Luke Paireepinart
ent of length 4 That's because \x02\x00 is only 2 characters long. You don't get direct access to the hex, just to the characters. vals = struct.unpack('cc','\x02\x00') #unpack values > > My desired result would be the string '0200'.

Re: [Tutor] c++::return

2008-03-19 Thread Luke Paireepinart
elis aeris wrote: > I actually said "ending" to avoid problems with different terminology > between different languages - but i guess a return is still a return > in python. Return does not exit a program. A return statement denotes a point in a function when the function will stop executing an

Re: [Tutor] windows: pop up window

2008-03-23 Thread Luke Paireepinart
On Sat, Mar 22, 2008 at 5:17 PM, elis aeris <[EMAIL PROTECTED]> wrote: > sweet, I love built in functions. thanks ! Seriously, Elis. You would have learned raw_input in *any* Python tutorial. You need to read some tutorials. Serious

Re: [Tutor] Saving an Image in a Given Format

2008-03-29 Thread Luke Paireepinart
On Sat, Mar 29, 2008 at 8:15 PM, Wayne Watson <[EMAIL PROTECTED]> wrote: > I see that I misunderstood the syntax of Python for: > > current_image.convert > current_image.save > > current_image is a "pointer" whose type is some class, so convert() and > save() must be methods in that class. Yes, t

Re: [Tutor] Creating Sudoku

2008-04-06 Thread Luke Paireepinart
int(some_value) conversion on your raw_inputs so you can use the values to index your list. Let us know if this is not enough of a hint! Hope it goes okay. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] MemoryError !!! Help Required

2008-04-06 Thread Luke Paireepinart
? > get more RAM, store the list on your hard drive, etc. etc. Why are you trying to do this? Are you sure you can't use existing tools for this such as wget? -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] glade integration

2008-04-07 Thread Luke Paireepinart
the generated code. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Creating Sudoku

2008-04-07 Thread Luke Paireepinart
W W wrote: > Actually, a dictionary might be a good idea. > I just played with this so youcan get a little picture. > [snip] > > You could easily run int(val) to convert to the integer value to store > in the dict. The other benefit is that python ignores whitespace in > between dictionary elements

Re: [Tutor] Creating Sudoku

2008-04-07 Thread Luke Paireepinart
W W wrote: > On 4/7/08, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > >> W W wrote: >> What are you talking about? I don't understand what you mean by "ignores >> whitespace between dictionary elements." >> >> >>> foo =

Re: [Tutor] Writing dictionaries to a file

2008-04-07 Thread Luke Paireepinart
st > for k in rowdict.keys(): > AttributeError: 'str' object has no attribute 'keys' This error sounds like d is a string, not a dictionary. Are you sure it's a dictionary? -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Creating Sudoku

2008-04-08 Thread Luke Paireepinart
> That's not quite right. It is the open brace/bracket/parenthesis that > tells Python to continue the line; the comma is not part of it. [snip] Thanks for the correction, Kent. -Luke ___ Tutor maillist - Tutor@python.org http://mail

[Tutor] [Fwd: Re: Hoping to benefit from someone's experience...]

2008-04-15 Thread Luke Paireepinart
Sorry, forgot to cc the list. --- Begin Message --- On Tue, Apr 15, 2008 at 7:18 PM, <[EMAIL PROTECTED]> wrote: > Recommendation: Find a very old version of Word (Word 95) to generate > your RTF 'templates'. The older versions of Word generate much simpler > RTF that is forward compatible. > Exc

[Tutor] Fwd: Need help with Factorial algorithm using Python

2008-09-04 Thread Luke Paireepinart
Oops, accidentally replied off list. -- Forwarded message -- From: Luke Paireepinart <[EMAIL PROTECTED]> Date: Thu, Sep 4, 2008 at 9:39 AM Subject: Re: [Tutor] Need help with Factorial algorithm using Python To: Robert Berman <[EMAIL PROTECTED]> On Thu, Sep 4, 200

Re: [Tutor] Hands-on beginner's project?

2008-10-02 Thread Luke Paireepinart
room == start is a comparison (check if room is equal to start - doesn't make a whole lot of sense to be doing that here). The "room" variable name doesn't exist in the current namespace, so it can't be compared to start. It looks like you wanted room = start. On 10/2/08, nathan virgil <[EMAIL PR

Re: [Tutor] syntax error with a simple print command

2008-10-02 Thread Luke Paireepinart
You are having an issue with the interpreter. You can only submit 1 command at a time to the interpreter. Therefore, you need to finish your for loop and hit enter *twice* so that the interpreter knows you're done with the loop. The reason you're getting an error is it's trying to put your "print

Re: [Tutor] syntax error with a simple print command

2008-10-02 Thread Luke Paireepinart
note that I meant it's not tabbed correctly *to be part of the for loop*. On Thu, Oct 2, 2008 at 9:42 AM, Luke Paireepinart <[EMAIL PROTECTED]>wrote: > You are having an issue with the interpreter. You can only submit 1 > command at a time to the interpreter. > Therefore

Re: [Tutor] Idle and windows XP firewall

2008-10-02 Thread Luke Paireepinart
On Thu, Oct 2, 2008 at 10:31 AM, David Holland <[EMAIL PROTECTED]>wrote: > I am using python 2.5.2. Is there an alternative to idle that does not > have this problem? > (I also fixed that this was no longer a problem). > > Open IDLE without using the "edit with IDLE" link. Or use a different edit

Re: [Tutor] Idle and windows XP firewall

2008-10-02 Thread Luke Paireepinart
just does not open - very > annoying. > > --- On *Thu, 2/10/08, Luke Paireepinart <[EMAIL PROTECTED]>* wrote: > > From: Luke Paireepinart <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Idle and windows XP firewall > To: [EMAIL PROTECTED] > Cc: tutor@python.org > Date:

Re: [Tutor] Idle and windows XP firewall

2008-10-02 Thread Luke Paireepinart
do this before just not in my new job > > --- On *Thu, 2/10/08, Luke Paireepinart <[EMAIL PROTECTED]>* wrote: > > From: Luke Paireepinart <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Idle and windows XP firewall > To: [EMAIL PROTECTED] > Cc: tutor@python.org > Date

<    3   4   5   6   7   8   9   >