Using Python to get push notifications from an RSS feed?

2014-04-25 Thread John Salerno
As a little project for myself (and to help get immediate player notes for my fantasy baseball team), I'm wondering what modules I might need to do this. Basically, I'd like to get immediate notification when a new player note has been added to an RSS feed. Since it will only be for specified p

Re: What's the best way to parse this HTML tag?

2012-03-11 Thread John Salerno
On Mar 11, 7:28 pm, Roy Smith wrote: > In article > <239c4ad7-ac93-45c5-98d6-71a434e1c...@r21g2000yqa.googlegroups.com>, >  John Salerno wrote: > > > > > > > > > > > Getting the time that the song is played is easy, because the time is > >

What's the best way to parse this HTML tag?

2012-03-11 Thread John Salerno
I'm using Beautiful Soup to extract some song information from a radio station's website that lists the songs it plays as it plays them. Getting the time that the song is played is easy, because the time is wrapped in a tag all by itself with a class attribute that has a specific value I can searc

Re: What's the best way to write this regular expression?

2012-03-08 Thread John Salerno
On Thursday, March 8, 2012 9:38:51 PM UTC-6, alex23 wrote: > John Salerno wrote: > > So much work just to get a 3rd party module installed! > > "New! Try out the beta release of Beautiful Soup 4. (Last updated > February 28, 2012) > easy_install beautifulsoup4 or pip

Re: What's the best way to write this regular expression?

2012-03-08 Thread John Salerno
Thanks, I had no idea about either option, since I don't use the command prompt very much. Needless to say, the Linux console is much nicer :) On Thu, Mar 8, 2012 at 4:19 PM, Dave Angel wrote: > On 03/08/2012 04:40 PM, John Salerno wrote: >> >> >> http://i271.ph

Re: What's the best way to write this regular expression?

2012-03-08 Thread John Salerno
On Mar 8, 3:40 pm, John Salerno wrote: > Now I have no idea what to do. Hmph, I suppose I should have more patience. I realized that the easy_install for lxml only tried to install a binary version, which doesn't exist for the version it found (the latest, 2.3.3). I just had to look thr

Re: What's the best way to write this regular expression?

2012-03-08 Thread John Salerno
On Mar 8, 3:33 pm, John Salerno wrote: > Alright, I'm simply lost about how to install these modules. I > extracted the folders from the .tar.gz files and then went into those > folders in my command prompt. I typed: > > C:\Python32\python setup.py install > > and

Re: What's the best way to write this regular expression?

2012-03-08 Thread John Salerno
Alright, I'm simply lost about how to install these modules. I extracted the folders from the .tar.gz files and then went into those folders in my command prompt. I typed: C:\Python32\python setup.py install and for a while something was happening (I was doing the lxml one) and then it stopped wi

Re: What's the best way to write this regular expression?

2012-03-07 Thread John Salerno
On Mar 7, 4:02 pm, Evan Driscoll wrote: > On 01/-10/-28163 01:59 PM, Prasad, Ramit wrote: > > > gz stands for gzip and is a form of compression (like rar/zip ). > > tar stands for a tape archive. It is basically a box that holds the > > files. So you need to "unzip" and then "open the box". > > >

Re: What's the best way to write this regular expression?

2012-03-07 Thread John Salerno
On Mar 7, 11:03 pm, Chris Angelico wrote: > On Thu, Mar 8, 2012 at 7:39 AM, John Salerno wrote: > > it only > > seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum > > version it requires? It didn't say something like "2.7+", so I w

Re: What's the best way to write this regular expression?

2012-03-07 Thread John Salerno
On Wed, Mar 7, 2012 at 3:34 PM, Ian Kelly wrote: > The setup.py file (as well as the other files) would be inside the > .tar file.  Unlike a Windows zip file, which does both archival and > compression, Unix files are typically archived and compressed in two > separate steps: "tar" denotes the ar

Re: What's the best way to write this regular expression?

2012-03-07 Thread John Salerno
On Wed, Mar 7, 2012 at 3:01 PM, Ian Kelly wrote: > There is a fork of setuptools called "distribute" that supports Python 3. Thanks, I guess I'll give this a try tonight! > setup.py is a file that should be included at the top-level of the > .tar files you downloaded.  Generally, to install som

Re: What's the best way to write this regular expression?

2012-03-07 Thread John Salerno
Ok, first major roadblock. I have no idea how to install Beautiful Soup or lxml on Windows! All I can find are .tar files. Based on what I've read, I can use the easy_setup module to install these types of files, but when I went to download the setuptools package, it only seemed to support Python 2

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
After a bit of reading, I've decided to use Beautiful Soup 4, with lxml as the parser. I considered simply using lxml to do all the work, but I just got lost in the documentation and tutorials. I couldn't find a clear explanation of how to parse an HTML file and then navigate its structure. The Be

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
> Also, you're still double-posting. Grr. I just reported it to Google, but I think if I start to frequent the newsgroup again I'll have to switch to Thunderbird, or perhaps I'll just try switching back to the old Google Groups interface. I think the issue is the new interface. Sorry. -- http

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
gh that I won't have to learn another method later. On Tue, Mar 6, 2012 at 5:35 PM, Ian Kelly wrote: > On Tue, Mar 6, 2012 at 4:05 PM, John Salerno wrote: >>> Anything that allows me NOT to use REs is welcome news, so I look forward >>> to learning about something new!

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
On Tuesday, March 6, 2012 5:05:39 PM UTC-6, John Salerno wrote: > > Anything that allows me NOT to use REs is welcome news, so I look forward > > to learning about something new! :) > > I should ask though...are there alternatives already bundled with Python that > I co

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
On Tuesday, March 6, 2012 5:05:39 PM UTC-6, John Salerno wrote: > > Anything that allows me NOT to use REs is welcome news, so I look forward > > to learning about something new! :) > > I should ask though...are there alternatives already bundled with Python that > I co

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
> Anything that allows me NOT to use REs is welcome news, so I look forward to > learning about something new! :) I should ask though...are there alternatives already bundled with Python that I could use? Now that you mention it, I remember something called HTMLParser (or something like that) a

Re: What's the best way to write this regular expression?

2012-03-06 Thread John Salerno
On Tuesday, March 6, 2012 4:52:10 PM UTC-6, Chris Rebert wrote: > On Tue, Mar 6, 2012 at 2:43 PM, John Salerno wrote: > > I sort of have to work with what the website gives me (as you'll see > > below), but today I encountered an exception to my RE. Let me just give a

Re: Tkinter: Why aren't my widgets expanding when I resize the window?

2012-03-05 Thread John Salerno
On Monday, March 5, 2012 7:10:50 PM UTC-6, Steven D'Aprano wrote: > On Mon, 05 Mar 2012 14:07:05 -0800, John Salerno quoted: > > >> Wah! > >> > >> Stop whining and act like a professional! You complain about qualifying > >> constants but you happi

Re: Tkinter: Why aren't my widgets expanding when I resize the window?

2012-03-05 Thread John Salerno
> > I don't like importing things piecemeal. I suppose I could do: > > So you prefer to pollute? How bout we just auto import the whole > Python stdlib so you can save a few keystrokes? > > so that's four more constants I'd have to explicitly import. And > > (tk.N, tk.S, tk.E, tk.W) is just horri

Re: Tkinter: Why aren't my widgets expanding when I resize the window?

2012-03-05 Thread John Salerno
> You will need to configure the root columns and rows also because the > configurations DO NOT propagate up the widget hierarchy! Actually, for > this example, I would recommend using the "pack" geometry manager on > the frame. Only use grid when you need to use grid. Never use any > functionality

Tkinter: Why aren't my widgets expanding when I resize the window?

2012-03-04 Thread John Salerno
I can't seem to wrap my head around all the necessary arguments for making a widget expand when a window is resized. I've been following along with a tutorial and I feel like I'm doing everything it said, but I must be missing something. Here's what I have. What I expect is that when I resize th

Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-04 Thread John Salerno
On Sunday, March 4, 2012 7:39:27 PM UTC-6, Rick Johnson wrote: > On Mar 2, 11:06 pm, John Salerno wrote: > > I'm tempted just to go back to wxPython. Two sets of widgets in Tkinter is > > a little annoying. > > Your complaint is justified. The Tkinter API is a disgrac

Re: Is this the right location to launch IDLE?

2012-03-04 Thread John Salerno
> That would be a Notepad++ problem. That "" gibberish is what you > get when a Unicode BOM (Byte Order Mark) character is encoded as UTF-8 > but decoded as ISO-8859-1 or CP-1252. A BOM is not recommended for > UTF-8 text; there should be some setting in Notepad++ to suppress it. You are my new

Re: Is this the right location to launch IDLE?

2012-03-04 Thread John Salerno
Unfortunately neither method worked. Adding "-r" to the path created this error when I tried it: >>> *** Error in script or command! Traceback (most recent call last): File "C:\Users\John\Documents\Python Scripts\chess_pieces.py", line 1 class ChessPiece: ^ SyntaxError: i

Is this the right location to launch IDLE?

2012-03-04 Thread John Salerno
I'm trying to get Notepad++ to launch IDLE and run the currently open file in IDLE, but all my attempts have failed so far. I'm wondering, am I even using the IDLE path correctly? I'm using this: "C:\Python32\Lib\idlelib\idle.pyw" "$(FULL_CURRENT_PATH)" (That last part puts in the full path to

Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-02 Thread John Salerno
> I suppose the 'advantage' of this is that it will replace tk widgets > with equivalent ttk widgets, if they exist and have the same name. I > believe one has to program them differently, however, so the replacement > cannot be transparent and one mush know anyway what gets replaced and > what

How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-02 Thread John Salerno
According to the Python docs, the way to use tkinter.ttk is this: from tkinter import * from tkinter.ttk import * But what if I don't like this import method and prefer to do: import tkinter as tk How then do I utilize tkinter.ttk using the same name? Or is that not possible? Will I have to us

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-03-02 Thread John Salerno
> After that, you can nest as > many frames, toplevels, and blah widgets under that root window as you > so desire. Actually you don't even need a "frame", you can pack > widgets directly into a Toplevel or Tk widget. This is interesting. I completely understand your point about always calling (a

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-03-02 Thread John Salerno
> Indeed. One of the things that motivated me to write the tutorial at > http://www.tkdocs.com is the rather poor state (in terms of being out of > date, incorrect, or demonstrating poor practices) of most Tkinter > documentation. > > Call it self-serving, but I think the Tkinter world would b

Re: Is this the proper way to use a class method?

2012-03-02 Thread John Salerno
> Oh, but it does get passed, just implicitly. `super()` basically grabs > `self` magically from its caller, and uses it to bind method calls on > the magical object returned by `super()`. Thanks again, now I understand :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this the proper way to use a class method?

2012-03-01 Thread John Salerno
> That's just a coincidence. Your supercall is ought to be: super().move() > In contrast, super().move(self) calls the superclass instance method > `move` with 2 arguments, both `self`, which just happens to work given > your move() method, inside which `cls` isn't actually a class like it > ought

Is this the proper way to use a class method?

2012-03-01 Thread John Salerno
This is purely for fun and learning, so I know there are probably better ways of creating a chess program. Right now I'm just curious about my specific question, but I'd love to hear any other advice as well. Basically, I'm wondering if I'm using the class method properly with the move method.

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-03-01 Thread John Salerno
> Hmm, it seems as though i am the latest victim of the "copy/paste > error"! Oh well, if you were going to absorb my teachings, you would > have absorbed them by now. I am moving on unless a new subject needs > explaining. Well, I've certainly absorbed your recommendation to always create the roo

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-03-01 Thread John Salerno
> EXAMPLE 1: (this works, but is flawed!) > root = tk.Tk() > b = tk.Button(master=None, text='Sloppy Coder') > b.pack() > root.mainloop() > > EXAMPLE 2: (This is how to write code!) > root = tk.Tk() > widgetframe = tk.Frame(root) > b = tk.Button(master=None, text='Sloppy Coder') > b.pack()

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-03-01 Thread John Salerno
On Thursday, March 1, 2012 1:38:08 AM UTC-6, Steven D'Aprano wrote: > On Wed, 29 Feb 2012 22:41:53 -0800, John Salerno wrote: > > >> Yes. You must leave it out. > > > > Now I'm reading a Tkinter reference at > > http://infohost.nmt.edu/tcc/help/pubs/t

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-29 Thread John Salerno
> Yes. You must leave it out. Now I'm reading a Tkinter reference at http://infohost.nmt.edu/tcc/help/pubs/tkinter/minimal-app.html and it has this example: #!/usr/local/bin/python from Tkinter import * class Application(Frame): def __init__(self, master=None):

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-29 Thread John Salerno
> What exactly is the purpose of doing that? Does Tk do some extra work that a > simple call to Frame won't do? More specifically, what is the benefit of doing: root = tk.Tk() app = Application(master=root) app.mainloop() as opposed to: app = Application() app.mainloop() Also, in the first ex

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-29 Thread John Salerno
On Wednesday, February 29, 2012 11:40:45 PM UTC-6, Terry Reedy wrote: > On 2/29/2012 11:41 PM, John Salerno wrote: > > > window? If you only want the Windows "X" button to close the window, > > then is it okay to leave out any call to destroy()? > > Yes. You mu

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-29 Thread John Salerno
> Yes, but i think the REAL problem is faulty code logic. Remove the > last line "root.destroy()" and the problem is solved. Obviously the > author does not have an in-depth knowledge of Tkinter. The faulty code is not my own, which is part of the reason I asked the question. The book I'm reading

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-29 Thread John Salerno
> It is not necessarily to call Tk explicitly, which i think is a bug > BTW. Sure, for simple scripts you can save one line of code but only > at the expense of explicitness and intuitiveness. Observe > > ## START CODE ## > import Tkinter as tk > > root = tk.Tk() > root.title('Explicit Root') > r

Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-28 Thread John Salerno
The book I'm reading about using Tkinter only does this when creating the top-level window: app = Application() app.mainloop() and of course the Application class has subclassed the tkinter.Frame class. However, in the Python documentation, I see this: root = Tk() app = Application(master=root

Re: How can I make an instance of a class act like a dictionary?

2012-02-27 Thread John Salerno
On Feb 27, 1:39 am, Chris Rebert wrote: > On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: > > Hi everyone. I created a custom class and had it inherit from the > > "dict" class, and then I have an __init__ method like this: > > > def __init__(self): &g

How can I make an instance of a class act like a dictionary?

2012-02-26 Thread John Salerno
Hi everyone. I created a custom class and had it inherit from the "dict" class, and then I have an __init__ method like this: def __init__(self): self = create() The create function creates and returns a dictionary object. Needless to say, this is not working. When I create an instance of

Re: How can I make a program automatically run once per day?

2011-07-27 Thread John Salerno
On Jul 27, 7:58 am, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: > On 07/27/2011 08:35 AM, Chris Angelico wrote: > > > > > > > > > > > On Wed, Jul 27, 2011 at 10:27 PM, Dave Angel  wrote: > >> As Chris pointed out, you probably aren't getting the script's directo

Re: How can I make a program automatically run once per day?

2011-07-26 Thread John Salerno
On Jul 26, 9:22 pm, Andrew Berg wrote: > On 2011.07.26 08:05 PM,JohnSalernowrote:> Hmm, okay I'm finally trying Task > Scheduler, but how do I set it to > > run a Python script? It seems to not work, I suppose because it's > > running the script but doesn't know how to find Python to run it > > p

Re: How can I make a program automatically run once per day?

2011-07-26 Thread John Salerno
On Jul 9, 9:01 pm, John Salerno wrote: > Thanks everyone! I probably should have said something like "Python, > if possible and efficient, otherwise any other method" ! :) > > I'll look into the Task Scheduler. Thanks again! Hmm, okay I'm finally trying Task Sched

Re: How can I make a program automatically run once per day?

2011-07-09 Thread John Salerno
Thanks everyone! I probably should have said something like "Python, if possible and efficient, otherwise any other method" ! :) I'll look into the Task Scheduler. Thanks again! -- http://mail.python.org/mailman/listinfo/python-list

How can I make a program automatically run once per day?

2011-07-09 Thread John Salerno
I have a script that does some stuff that I want to run every day for maybe a week, or a month. So far I've been good about running it every night, but is there some way (using Python, of course) that I can make it automatically run at a set time each night? -- http://mail.python.org/mailman/listi

Re: Anyone want to critique this program?

2011-07-03 Thread John Salerno
On Jul 3, 1:06 pm, "OKB (not okblacke)" wrote: > > Yeah, I considered that, but I just hate the way it looks when the > > line wraps around to the left margin. I wanted to line it all up > > under the opening quotation mark. The wrapping may not be as much > > of an issue when assigning a variabl

Re: Why won't this decorator work?

2011-07-03 Thread John Salerno
On Jul 3, 1:01 pm, "OKB (not okblacke)" wrote: > subsequent calls to it will behave differently.  If you want ALL calls > to your method to roll a die to get a random number, and then use that > random number, why not just roll the die inside the method itself: I thought maybe it would be cleane

Re: Anyone want to critique this program?

2011-07-02 Thread John Salerno
On Jul 2, 10:02 pm, Chris Angelico wrote: > > game_information = '***Chutes and Ladders***\nUp to four (4) players > > may play.\n'\ > >                   'There are 90 spaces on the board. '\ > >                   'The player to reach space 90 first wins.' > > I'd do this with a triple-quoted st

Anyone want to critique this program?

2011-07-02 Thread John Salerno
Just thought I'd post this in the event anyone has a few spare minutes and feels like tearing apart a fairly simple attempt to write a game. :) I'll paste the exercise I was working on first, although I think it was meant to be an exercise in how to use lists. I went way beyond that, so maybe my p

Re: Why won't this decorator work?

2011-07-02 Thread John Salerno
On Jul 2, 9:11 pm, Steven D'Aprano wrote: > John Salerno wrote: > > But why does the documentation say "The return value of the decorator > > need not be callable"? > > The thing returned by a decorator does not need to be callable, but if you > want to cal

Re: Why won't this decorator work?

2011-07-02 Thread John Salerno
On Jul 2, 1:45 pm, Tim Chase wrote: > I must not be looking at the same documentation you are...could > you provide a link? The only time I know of that the return value > of a decorator need not be callable is if you want to totally > break the syntax of the function. :-/ http://docs.python.org

Re: Why won't this decorator work?

2011-07-02 Thread John Salerno
On Jul 2, 12:33 pm, MRAB wrote: > On 02/07/2011 17:56, John Salerno wrote: > > > > > > > > > > > I thought I had finally grasped decorators, but the error I'm getting > > ('str' type is not callable) is confusing me. Here is my code. Also,

Why won't this decorator work?

2011-07-02 Thread John Salerno
I thought I had finally grasped decorators, but the error I'm getting ('str' type is not callable) is confusing me. Here is my code. Also, the commented sentence is from the Python docs, which says it doesn't even need to be callable, if that matters. I also commented out a few things in the move m

Re: How do you print a string after it's been searched for an RE?

2011-06-23 Thread John Salerno
On Jun 23, 4:47 pm, "Thomas L. Shinnick" wrote: > There is also >        print(match_obj.string) > which gives you a copy of the string searched.  See end of section > 6.2.5. Match Objects I tried that, but the only time I wanted the string printed was when there *wasn't* a match, so the match ob

Re: How do you print a string after it's been searched for an RE?

2011-06-23 Thread John Salerno
On Jun 23, 3:47 pm, Ian Kelly wrote: > On Thu, Jun 23, 2011 at 1:58 PM, John Salerno wrote: > > After I've run the re.search function on a string and no match was > > found, how can I access that string? When I try to print it directly, > > it's an empty strin

How do you print a string after it's been searched for an RE?

2011-06-23 Thread John Salerno
After I've run the re.search function on a string and no match was found, how can I access that string? When I try to print it directly, it's an empty string, I assume because it has been "consumed." How do I prevent this? It seems to work fine for this 2.x code: import urllib.request import re

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 10:02 pm, Mel wrote: > John Salerno wrote: > > ::sigh:: Well, I'm stuck again and it has to do with my get_factors > > function again, I think. Even with the slight optimization, it's > > taking forever on 20! (factorial, not excitement)  :) It'

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 9:09 pm, Paul Rubin wrote: > John Salerno writes: > > It's frustrating because I have the Python right, but I'm getting > > stuck on the math > > "What is the smallest positive number that is evenly divisible by all > > of the numbers f

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
::sigh:: Well, I'm stuck again and it has to do with my get_factors function again, I think. Even with the slight optimization, it's taking forever on 20! (factorial, not excitement) :) It's frustrating because I have the Python right, but I'm getting stuck on the math. The problem: "What is the

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 4:41 pm, Ian Kelly wrote: > On Tue, Jun 21, 2011 at 3:09 PM, John Salerno wrote: > > Don't worry, I was still unclear about what to do after reading all > > the responses, even yours! But one thing that made me feel better was > > that I wasn't havin

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 3:22 pm, Irmen de Jong wrote: > On 21-06-11 22:10, Irmen de Jong wrote: > [stuff] > > I didn't read the last paragraph of John's message until just now, and > now realize that what I wrote is likely way too much information for > what he asked. > I'm sorry. Next time I'll read everythin

How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
I'm working on the Project Euler exercises and I'm stumped on problem 3: "What is the largest prime factor of the number 600851475143 ?" Now, I've actually written functions to get a list of the factors of any given number, and then another function to get the prime numbers from that list. It wor

Re: Do we still need to inherit from "object" to create new-style classes?

2011-06-20 Thread John Salerno
On Jun 20, 8:33 pm, Benjamin Kaplan wrote: > On Mon, Jun 20, 2011 at 6:26 PM, John Salerno wrote: > > I can't quite seem to find the answer to this anywhere. The book I'm > > reading right now was written for Python 3.1 and doesn't use (object), > > so I

Do we still need to inherit from "object" to create new-style classes?

2011-06-20 Thread John Salerno
I can't quite seem to find the answer to this anywhere. The book I'm reading right now was written for Python 3.1 and doesn't use (object), so I'm thinking that was just a way to force new-style classes in 2.x and is no longer necessary in 3.x. Is that right? (The documentation doesn't mention obj

Re: What's the best way to write this base class?

2011-06-19 Thread John Salerno
On Jun 19, 8:52 pm, Chris Kaynor wrote: > Having a character class (along with possibly player character, non-player > character, etc), make sense; however you probably want to make stuff like > health, resources, damage, and any other attributes not be handles by any > classes or inheritance

Re: What's the best way to write this base class?

2011-06-18 Thread John Salerno
Whew, thanks for all the responses! I will think about it carefully and decide on a way. I was leaning toward simply assigning the health, resource, etc. variables in the __init__ method, like this: def __init__(self, name): self.name = name self.health = 50 self.resource = 10 I never

What's the best way to write this base class?

2011-06-17 Thread John Salerno
Let's say I'm writing a game (really I'm just practicing OOP) and I want to create a "Character" base class, which more specific classes will subclass, such as Warrior, Wizard, etc. Which of the following ways is better, or is there another way? Note: I have in mind that when a specific subclass (

Re: How do you copy files from one location to another?

2011-06-17 Thread John Salerno
On Jun 17, 5:15 pm, Ethan Furman wrote: > John Salerno wrote: > > On Jun 17, 2:23 pm, Terry Reedy wrote: > > >> If you follow the second part of Greg's suggestion 'or one of the other > >> related function in the shutil module', you will find copytree

Re: How do you copy files from one location to another?

2011-06-17 Thread John Salerno
On Jun 17, 2:23 pm, Terry Reedy wrote: > If you follow the second part of Greg's suggestion 'or one of the other > related function in the shutil module', you will find copytree() > "Recursively copy an entire directory tree rooted at src. " Yeah, but shutil.copytree says: "The destination dire

Re: How do you copy files from one location to another?

2011-06-17 Thread John Salerno
On Jun 17, 2:25 am, Gregory Ewing wrote: > John Salerno wrote: > > I want it to copy a set of files/directories from a > > location on my C:\ drive to another directory on my E:\ drive. I don't > > want to rename or delete the originals, > > It sounds like shutil

How do you copy files from one location to another?

2011-06-16 Thread John Salerno
Based on what I've read, it seems os.rename is the proper function to use, but I'm a little confused about the syntax. Basically I just want to write a simple script that will back up my saved game files when I run it. So I want it to copy a set of files/directories from a location on my C:\ drive

Re: Using just the Mako part of Pylons?

2008-06-30 Thread John Salerno
Bruno Desthuilliers wrote: John Salerno a écrit : I just installed Pylons onto my hosting server so I could try out templating with Mako, but it seems a little more complicated than that. Err... Actually, it's certainly a little less complicated than that. First point: Mako is to

Re: How do web templates separate content and logic?

2008-06-28 Thread John Salerno
[EMAIL PROTECTED] wrote: For which definitions of "content" and "logic" ??? The point of mvc is to keep domain logic separated from presentation logic, not to remove logic from presentation (which just couldn't work). Templating systems are for presentation logic. Whether they work by embedding

Re: Mako vs. Cheetah?

2008-06-28 Thread John Salerno
Tim Roberts wrote: "John Salerno" <[EMAIL PROTECTED]> wrote: Is it correct to say that Mako allows you to embed Python code within HTML, whereas Cheetah requires a certain amount of "tweaking" of Python code so that it isn't really code you could just run in

Re: Using just the Mako part of Pylons?

2008-06-27 Thread John Salerno
John Salerno wrote: I just installed Pylons onto my hosting server so I could try out templating with Mako, but it seems a little more complicated than that. From the look of it all, the site seems to want a full Pylons application. Is it possible to just use regular HTML files with a bit of

Using just the Mako part of Pylons?

2008-06-27 Thread John Salerno
I just installed Pylons onto my hosting server so I could try out templating with Mako, but it seems a little more complicated than that. From the look of it all, the site seems to want a full Pylons application. Is it possible to just use regular HTML files with a bit of the Mako language embe

Re: what is meaning of "@" in pyhon program.

2008-06-27 Thread John Salerno
"Damon Getsman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Okay, maybe I just didn't understand the websites that were given as > examples as to 'decoration'. I first came across the unusual '@' when > I was browsing through some extreme beginner's information on os.x > method

How do web templates separate content and logic?

2008-06-27 Thread John Salerno
I've been doing some research on web templates, and even though I read that they help enforce the MVC pattern, I don't really understand how they are keeping content and logic separated. Layout is easy, it's just not there as far as I can see, and CSS can be used for that. But when you have a t

Re: Simple regular expression

2008-06-27 Thread John Salerno
"python_enthu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am trying this.. what is wrong in this.. > > IDLE 1.2.2 import re a="my name is fname lname" p=re.compile('name') m=p.match (a) print p.match(a) > None match( string[, pos[, endpos]]) If

Re: url.encore/quote

2008-06-26 Thread John Salerno
"ianitux" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> and see if that works? I'm not sure if quote() will convert the %20 into >> +, >> though, but it may. > > This is what quot do. > import urllib u = urllib u.quote(u.urlencode({'page': 'i', 'order': 'desc', 'st

Re: I Need A Placeholder

2008-06-26 Thread John Salerno
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > if 0: 42 How Pythonic. ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: url.encore/quote

2008-06-26 Thread John Salerno
"zowtar" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > urlencode({'page': i, 'order': 'desc', 'style': 'flex power'}) > return: > page=1&order=desc&style=flex+power > > but I want: > page=1&order=desc&style=flex%20power > > and url.quote don't put the &'s and ='s > any idea guys?

Re: I Need A Placeholder

2008-06-26 Thread John Salerno
"Joshua Kugler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > except: >pass > > is the usual technique there. Is there any other? -- http://mail.python.org/mailman/listinfo/python-list

Re: Mako vs. Cheetah?

2008-06-26 Thread John Salerno
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I always have the desire to learn one thing well instead of split my >attention between several options, so I'm trying to decide which of these >two to start learning. Are there any part

Mako vs. Cheetah?

2008-06-25 Thread John Salerno
I always have the desire to learn one thing well instead of split my attention between several options, so I'm trying to decide which of these two to start learning. Are there any particular things I should look at when deciding between them, in terms of features, for example? Do they do all th

Re: Using Python to run SSH commands on a remote server

2008-06-23 Thread John Salerno
Jeffrey Froman wrote: Also note that "all .py files on my web server" is not necessarily restricted to CGI scripts -- and therein lies the real gist of my cautionary note. Yeah, I realized that afterwards. Good point. I was assuming all my executable files would be CGI, but that's not a good

Re: Using Python to run SSH commands on a remote server

2008-06-23 Thread John Salerno
"Jeffrey Froman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Be careful, this procedure sounds potential risky, security-wise ;-) I guess a blanket process might be a tad risky, but don't you want all CGI files to be executable by all? -- http://mail.python.org/mailman/listi

Using Python to run SSH commands on a remote server

2008-06-23 Thread John Salerno
Generally speaking, what tools would I use to do this? Is there a built-in module for it? I looked at the telnetlib module, but the documentation wasn't really complete enough for me to get a good idea of it. Is Telnet and SSH even the same thing? Basically, I want to write a script that will a

Re: Buffer size when receiving data through a socket?

2008-06-21 Thread John Salerno
Dennis Lee Bieber wrote: On Wed, 18 Jun 2008 09:56:29 -0400, "John Salerno" <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: Interesting point. I'm not sure if it works that way though. I *think* I tried sending an empty string from the server back

Re: One more socket programming question

2008-06-18 Thread John Salerno
"Tim Roberts" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > John Salerno <[EMAIL PROTECTED]> wrote: >> >>I'm now experimenting with the SocketServer class. Originally I >>subclassed the StreamRequestHandler to make my own custom hand

Re: Buffer size when receiving data through a socket?

2008-06-18 Thread John Salerno
"Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The first if is checking for lack of interactive input -- and, as > coded, will never break out as ANY response to the > prompt will have a > newline attached. > > Try with raw_input("> ").strip() instead Well, I kn

One more socket programming question

2008-06-17 Thread John Salerno
I'm now experimenting with the SocketServer class. Originally I subclassed the StreamRequestHandler to make my own custom handler, but a result of this seems to be that the client socket closes after it has been used, instead of staying open. Just as a test, I decided to use BaseRequestHandler

Re: newbie question: for loop within for loop confusion

2008-06-17 Thread John Salerno
Gabriel Genellina wrote: En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <[EMAIL PROTECTED]> escribió: takayuki wrote: I'm early on in my python adventure so I'm not there yet on the strip command nuances.I'm reading "How to think like a python programmer&

Re: Buffer size when receiving data through a socket?

2008-06-17 Thread John Salerno
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Note that most of the time you want to use the sendall() method, because > send() doesn't guarantee that all the data was actually sent. > If I use sendall(), am I

  1   2   3   4   5   6   7   8   9   10   >