[Tutor] Online Scripting

2008-09-07 Thread Omer
Hello.

I started a project with a goal: To have a script "read" an entire message
board, dedicated to various events,
process this information into an iCalendar file,
and finally- base a Google Calendar on the iCal file.

Now,
The script is done and it works great on my desktop.
The problem is, seeing as I plan this a sort of a service for the forum
people,
It can't be based off of my desktop, which is only available 5 ~ 6 days a
week.

So,

Has anyone a clue as to where might I host my script, so's A: the host
"runs" my script periodical (Once every Two hours? If I can configure it to
only run during the day than that's even better), and B: The host lets my
script create an iCal file (a single, <1MB file) and C: lets GCal have
access to this file.

I've looked Google App Engine. It's a huge effort: First remodeling my
script to use the GAE way of opening urls, to use the GAE way of storing
information, and I haven't as yet even looked into how do I store the
prepared iCal file, or how do I schedule the runs of my script. The need to
learn an entire platform, (Although I do plan to learn it someday), is too
large for me now. (Although, if there's no choice that's what I'll do.)

Sorry about this message's length,
Help will be appreciated, thank you for your time.
Omer.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking at a String as a Struct?

2008-09-11 Thread Omer
Class Person:
def __init__(str):
self.Firstname = str[0:4]
self.Surname = str[5:7]
(...)

If your string separates the values of each person using tags rather than
fixed lengthes, build it like:

or:
self.Firstname = str[0:str.find("Last name:")]
self.Surname = str[str.find("Last name:")+len("Last
name:"):str.find("date_of_birth")]

And just create a list of these, adding various get methods for easy
information retrieval.

(Here's for wandering whether my way of doing it counts as Pythonic.)
HTH.
Omer.

On Thu, Sep 11, 2008 at 4:58 PM, Wayne Watson
<[EMAIL PROTECTED]>wrote:

>  True enough, but that gets messy. I'd have to keep them perhaps as global
> variables or pass then around a lot from function to function as a
> collection.  I see WW posted above you about  dictionaries. Maybe that's the
> way to do it.  I'll look into it.
>
> Kent Johnson wrote:
>
> On Thu, Sep 11, 2008 at 6:58 AM, Wayne Watson<[EMAIL PROTECTED]> <[EMAIL 
> PROTECTED]> wrote:
>
>
>  Is it possible in Python to look at a string as a "struct". I don't think a
> struct exists in python. Actually, is there something analogous to a record.
> In the case of strings, suppose I have string that is composed of
> sub-strings like, first_name, last-name, date_of birth, which consists of
> month, day, and year, and finally SSN, street_address, state, city, and
> zip_code. I'd like to access these fields directly instead of lastname =
> record[38:55]. What if fields are not just strings, but some numeric values?
>
>
>  For numeric fields, just convert as needed:
> quantity = int(record[55:60])
> price = float(record[60::70])
>
> If the numbers are binary, rather than ascii, see the struct module.
>
> Kent
>
>
>
>
> --
>
>Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>  (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
>   Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet   
>"If voting made any difference they wouldn't let us do it."
> -- Mark Twain
>
> Web Page: 
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Win32 extensions

2008-09-13 Thread Omer
On Fri, Sep 12, 2008 at 2:31 AM, Alan Gauld <[EMAIL PROTECTED]>wrote:

> Yes if you spend a lot of money.
> You can buy a set of libraries from a comany called Bristol
> Technology (I think, it's over 8 years since I used it!) that allows
> you to build Windows software on a Unix box. A bit like cygwin
> in reverse! Some Microsoft developers actually used it during the
> development of the first version of Windows NT I believe!
>


Errm, What'd be the difference between this and WINE ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Printing Scripts with color/good formatting

2008-09-14 Thread Omer
I went through a similar process:
I got used to PyWin on XP, then when switching to Vista pywin did not
install with Python.
So I simply downloaded and installed it.
(link: http://sourceforge.net/projects/pywin32/
)
Hth,
Omer.

On Sat, Sep 13, 2008 at 5:41 AM, Mike Meisner <[EMAIL PROTECTED]> wrote:

>  I've been working with Python on two different machines:  under Windows
> XP and under 64-bit Vista.
>
> In the XP version, the Python 32-bit editor prints my scripts using the
> color coding in the editor and a comfortable to read font.  Under Vista
> 64-bit, only the IDLE environment is available which prints my scripts
> without color and a larger, more difficult to read font (and there appears
> to be no way to customize the output).
>
> Is there an open-source editor I could use with Vista to get the more
> attractive, color coded script printout that I get with the 32--bit system?
>
> Thanks for your help.
>
> Mike
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Current path (of program)

2008-09-26 Thread Omer
No, I shouldn't think it is. Lots o' folk use this list in archived mode and
the important bit is that each question comes with an answer, regardless of
the actual persons involved.

On Thu, Sep 25, 2008 at 10:58 PM, Adrian Greyling <[EMAIL PROTECTED]
> wrote:

> Is it a faux pas to answer your own question??  I found this after I
> tweaked my search terms..
>
> From "Dive Into Python" (
> http://diveintopython.org/functional_programming/finding_the_path.html)
>
> pathname = os.path.dirname(sys.argv[0])
> currpath = os.path.abspath(pathname)
>
> "Regardless of how you run a script, sys.argv[0] will always contain the
> name of the script, exactly as it appears on the command line.  This may or
> may not include any path information.  os.path.dirname takes a filename as a
> string and returns the directory path portion. If the given filename does
> not include any path information, os.path.dirname returns an empty string.
>  os.path.abspath is the key here. It takes a pathname, which can be partial
> or even blank, and returns a fully qualified pathname."
>
>
> Sorry about that folks...
> Adrian
>
>
>
>
>
>
>
> On Thu, Sep 25, 2008 at 3:25 PM, Adrian Greyling <
> [EMAIL PROTECTED]> wrote:
>
>> I've been using "os.getcwd()" to get my program's "current path".  I know
>> it's actually returning my "current working directory", but it's been
>> working okay, until today...  I used py2exe (and InnoSetup) to create a
>> standalone executable (for Windows) and then a shortcut icon on the desktop
>> to "MyProg.exe".  Problem is, now "os.getcwd()" returns "C:\Documents and
>> Settings\ME\Desktop\" as it's current working directory, not the "C:\Program
>> Files\MyCoolProgram\" that I was expecting.
>>
>> I'm trying to use a "relative path reference" so that the user can install
>> the program to whatever directory he/she wants, but that my program won't
>> "lose track" of the subdirectories it requires for additional files.
>>
>> Anyone run into the same sort of problem?  Better yet, anyone know how to
>> solve this?
>>
>> Thanks everyone!
>> Adrian
>>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Archives and PC Crash

2008-10-04 Thread Omer
(Or you could start using Gmail, which conveniantly archives Qs with their
As, based on subject line,)

On Wed, Oct 1, 2008 at 12:26 AM, Alan Gauld <[EMAIL PROTECTED]>wrote:

>
> "Danny Yoo" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>> Yup.  See:
>>
>>   http://mail.python.org/pipermail/tutor/
>>
>> for the archive.  There's also a searchable interface from GMANE:
>>
>>   http://dir.gmane.org/gmane.comp.python.tutor
>>
>
>
> And another at ActiveState.com
>
> http://lists.activestate.com/tutor@python.org
>
> Alan G
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Text Scatter Plots?

2008-10-04 Thread Omer
You could check out Google Visualization API. supposed to be fairly nifty;
haven't had time to check it out myself though.

On Wed, Oct 1, 2008 at 4:49 PM, R. Alan Monroe <[EMAIL PROTECTED]>wrote:

> > Is there a text graphics module that does say scatter plots or
> > histograms? I'm thinking of stuff prior to the graphics era of
> > computing. I'm looking for something really simple.
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] dealing with user input whose value I don't know

2008-10-05 Thread Omer
On Fri, Oct 3, 2008 at 9:45 AM, David <[EMAIL PROTECTED]> wrote:

> Here is the code:
>
> def main():
>   import string
>

Hey,
lagging a bit behind the list,

"import string" is unnecessary, mate.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Class Extend Help

2008-12-20 Thread Omer
Hey.

I'm trying to do something I think is basic and am failing.

The goal is:
[mimicking the google urlopen syntax]

try:
from google.appengine.api.urlfetch import fetch
except:
from urllib import urlopen as fetch


How do I add this "fetch" the property of content?

I basically want fetch(url.com).content to replace urlopen(url.com).read()

Mind, content is not a method.

Thoughts?

Thx. Omer.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Class Extend Help

2008-12-23 Thread Omer
Hey!

Thx for the help,

@Martin,
At the moment my only need is basic retrievals of source code of basic files
from the internet, so no need for urllib2 or response objects just yet.


Now, copying and pasting line by line into the interactive mode I get this:

>>> from urllib import urlopen
>>> class fetch(urlopen):
... def __init__(self,*args):
... urlopen.__init__(self, *args)
... self.content = self.read()
...

Traceback (most recent call last):
  File "", line 1, in 
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str

Anybody, any idea what's up with that?


On Sat, Dec 20, 2008 at 6:49 PM, Richard Lovely
wrote:

> There are three ways as I see it: using __getattr__, using a new init,
> or using a property decorator.  The last two are probably the most
> pythonic, but I'm not familiar with decorators, so here's how I'd do
> the second of the three:
>
> try:
> from google.appengine.api.urlfetch import fetch
> except:
> from urllib import urlopen
>
>  class fetch(urlopen):
> def __init__(self, *args):
> urlopen.__init__(self, *args)
> self.content = self.read()
>
>
> This probably doesn't behave exactly the same way as the google class,
> but it should be similar enough?
> ---
> Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
> www.theJNP.com
>
>
>
> 2008/12/20 Omer >:
> > Hey.
> >
> > I'm trying to do something I think is basic and am failing.
> >
> > The goal is:
> > [mimicking the google urlopen syntax]
> >
> > try:
> > from google.appengine.api.urlfetch import fetch
> > except:
> > from urllib import urlopen as fetch
> >
> >
> > How do I add this "fetch" the property of content?
> >
> > I basically want fetch(url.com).content to replace urlopen(url.com
> ).read()
> >
> > Mind, content is not a method.
> >
> > Thoughts?
> >
> > Thx. Omer.
> >
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Class Extend Help

2008-12-28 Thread Omer
Thx for help,
extreme lack of free time lately,
will look into it.

[Wouldn't've noticed myself that urlopen is not a class.]

On Tue, Dec 23, 2008 at 6:03 PM, Richard Lovely
wrote:

> OK, going on Kent's post:
>
> from urllib import urlopen
>
> class fetch(object):
>def __init__(self, *args):
>self.response = urlopen(*args)
>self.content = self.response.read()
>
>
> I forgot urlopen was a function.  It made sense in my head for it to
> be a class, instead of _returning_ a class.
>
> It's trying to call __init__ on a functionType instance, and it's
> getting confused.
>
> See http://dpaste.com/hold/101951/ for another example.  The error
> message is something cryptic, but between #python and I we think it's
> something to do with calling type().
> ---
> Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
> www.theJNP.com
>
>
>
> 2008/12/23 Kent Johnson :
> > On Tue, Dec 23, 2008 at 9:31 AM, Omer 
> > >
> wrote:
> >
> >>>>> from urllib import urlopen
> >>>>> class fetch(urlopen):
> >> ... def __init__(self,*args):
> >> ... urlopen.__init__(self, *args)
> >> ... self.content = self.read()
> >> ...
> >>
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >> TypeError: Error when calling the metaclass bases
> >> function() argument 1 must be code, not str
> >>
> >> Anybody, any idea what's up with that?
> >
> > That's pretty obscure, not sure why you get exactly that error!
> >
> > Anyway the code should be
> > class fetch(object):
> >
> > urlopen is a function, not a class, so it can't be a base class of
> > fetch. There is no need for it to be a base class, either; just use
> > object.
> >
> > Kent
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] RE Silliness

2009-01-04 Thread Omer
I'm sorry, burrowed into the reference until my eyes bled.

What I want is to have a regular expression with an optional ending of
""

(For those interested,
urlMask = r"http://[\w\Q./\?=\R]+";
is ther version w/o the optional  ending.)

I can't seem to make a string optional- only a single character via []s. I
for some reason thuoght it'll be ()s, but no help there- it just returns
only the . Anybody?

Thx,
Omer.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] RE Silliness

2009-01-05 Thread Omer
Bob, I tried your way.

>>> import re
>>> urlMask = r"http://[\w\Q./\?=\R]+()?"
>>> text=u"Not working examplehttp://this.is.a/url?header=nullAnd
another linehttp://and.another.url";
>>> re.findall(urlMask,text)
[u'', u'']

spir, I did understand it. What I'm not understanding is why isn't this
working.

(Whereas,

>>> OldurlMask = r"http://[\w\Q./\?=\R]+";   #Not f-ing working.
>>> re.findall(OldurlMask,text)
['http://this.is.a/url?header=null', 'http://and.another.url']

does work. Which is what had me frowning.
Also,
this ugly url mask is working:

>>> UglyUrlMask = r"(http://[\w\Q./\?=\R]+|http://[\w\Q./\?=\R]+)"
>>> re.findall(UglyUrlMask,text)
['http://this.is.a/url?header=null', 'http://and.another.url']

Anyone?)

On Mon, Jan 5, 2009 at 12:08 AM, spir  wrote:

> On Sun, 04 Jan 2009 14:09:53 -0500
> bob gailer  wrote:
>
> > Omer wrote:
> > > I'm sorry, burrowed into the reference until my eyes bled.
> > >
> > > What I want is to have a regular expression with an optional ending of
> > > ""
> > >
> > > (For those interested,
> > > urlMask = r"http://[\w\Q./\?=\R]+";
> > > is ther version w/o the optional  ending.)
> > >
> > > I can't seem to make a string optional- only a single character via
> > > []s. I for some reason thuoght it'll be ()s, but no help there- it
> > > just returns only the . Anybody?
> > >
> > urlMask = r"http://[\w\Q./\?=\R]+()?"
> >
> >  From the docs: ? Causes the resulting RE to match 0 or 1 repetitions of
> > the preceding RE. ab? will match either 'a' or 'ab'.
> >
> >
>
> Maybe Omer had not noted that a sub-expression can be grouped in () so that
> an operator (?+*) applies on the whole group.
> Denis
>
> --
> la vida e estranya
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor