Alan Gauld | 1 Sep 2007 01:14

Re: Starting classes


<christopher.henk <at> allisontransmission.com> wrote

> def look(here):
>        "Look around the place you are in"
>        print here.description
>
> Not sure if this works as is, I believe it depends on the 
> interpreter, but
> it is customary to use the word self as the first parameter,

It is just a custom and 'here' is as good a name as any
since its refering to the place object - ie here...

But self is more conventional and using here might confuse
some readers. The interpreters should all be happy enough
with either name.

Alan G 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Alan Gauld | 1 Sep 2007 01:20

Re: problem resulting from installing 3.0


"Dick Moores" <rdm <at> rcblue.com> wrote

> and ulipad.pyw. How can I get back to where I was before, without
> that annoying console opening?

Sorry, no idea - thats why I never install alpha software! :-)

> PYTHONPATH:
> E:\Python25\;E:\PythonWork\;E:\Programs\Ulipad3.7\
>
> And another question is, exactly what should go into PYTHONPATH? 
> I've
> never been clear about that.

Its what goes into sys.path.

In other words its where your local modules are stored. Using an
environment variable rather than a path file, as is often suggested,
allows each user to have their own module library, and even
multiple libraries by using a script to launch Python that redefines
PYTHONPATH before starting Python. Or you can do it manually.
Much more flexible. I'm a big fan of environment variables!

Alan G 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

(Continue reading)

Terry Carroll | 1 Sep 2007 02:17

Python 3000 has just become less mythical

The first Alpha release of Python 3000 was released today:

   http://python.org/download/releases/3.0/

Guido's post:

   http://www.artima.com/weblogs/viewpost.jsp?thread=213583

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Kent Johnson | 1 Sep 2007 02:22
Gravatar

Re: Starting classes

Ara Kooser wrote:
>     def look(here):
>         "Look around the place you are in"
>         print here.description

This is technicaly OK but conventionally the first argument to a method 
is 'self'. Since you are learning it would be good to keep to the 
convention.

> outside1 = Area("Outside")
> outside1.description = "You are standing outside with the town gate to
> your back"
> self.contents.append("dirt")
> 
> 
> look(bedroom)

Maybe you mean
   bedroom.look()
or
   outside1.look()

Kent
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Kent Johnson | 1 Sep 2007 02:25
Gravatar

Re: problem resulting from installing 3.0

Dick Moores wrote:
> XP, Python 2.5.1
> 
> I installed 3.0 alpha out of curiosity in a separate folder from 
> 2.5.1. Then I found that both 2.5.1's IDLE and my main Python editor 
> Ulipad would no longer open. My first idea was that the installation 
> of 3.0 somehow changed my path. But it didn't. After uninstalling 
> 3.0, and fiddling with the path and PYTHONPATH, IDLE and Ulipad now 
> open, but the console opens first. The files executed are idle.pyw 
> and ulipad.pyw. How can I get back to where I was before, without 
> that annoying console opening?

A guess - check the file association for .pyw files. Make sure they are 
associated with pythonw, not python.

Kent
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Dick Moores | 1 Sep 2007 02:54

Re: problem resulting from installing 3.0

At 04:20 PM 8/31/2007, you wrote:

>"Dick Moores" <rdm <at> rcblue.com> wrote
>
> > and ulipad.pyw. How can I get back to where I was before, without
> > that annoying console opening?
>
>Sorry, no idea - thats why I never install alpha software! :-)
>
> > PYTHONPATH:
> > E:\Python25\;E:\PythonWork\;E:\Programs\Ulipad3.7\
> >
> > And another question is, exactly what should go into PYTHONPATH?
> > I've
> > never been clear about that.
>
>Its what goes into sys.path.
>
>In other words its where your local modules are stored. Using an
>environment variable rather than a path file, as is often suggested,
>allows each user to have their own module library, and even
>multiple libraries by using a script to launch Python that redefines
>PYTHONPATH before starting Python. Or you can do it manually.
>Much more flexible. I'm a big fan of environment variables!

I don't think I follow you, Alan. I thought I was 
using environment variables. In XP, System 
Properties | Advanced | Environment Variables | 
System Variables. That's where path and PYTHONPATH are.

(Continue reading)

Dick Moores | 1 Sep 2007 03:03

Re: problem resulting from installing 3.0

At 05:25 PM 8/31/2007, Kent Johnson wrote:
>Dick Moores wrote:
>>XP, Python 2.5.1
>>I installed 3.0 alpha out of curiosity in a separate folder from 
>>2.5.1. Then I found that both 2.5.1's IDLE and my main Python 
>>editor Ulipad would no longer open. My first idea was that the 
>>installation of 3.0 somehow changed my path. But it didn't. After 
>>uninstalling 3.0, and fiddling with the path and PYTHONPATH, IDLE 
>>and Ulipad now open, but the console opens first. The files 
>>executed are idle.pyw and ulipad.pyw. How can I get back to where I 
>>was before, without that annoying console opening?
>
>A guess - check the file association for .pyw files. Make sure they 
>are associated with pythonw, not python.

Yes! Thanks, Kent.

Dick

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Che M | 1 Sep 2007 07:55
Picon
Favicon

date matching with python and sqlite3

I'm trying to allow users to select data from an sqlite database using 
Python by choosing either a date or a range of dates.  I'm stuck at just 
allowing the to select data that entered the database "today" and return 
values from a column called duration.  I have this mess at the moment:

#assume they have already chosen this self.datechoice to be today

if self.datechoice == "today":
    todaystring = str(datetime.datetime.today())
    today = todaystring[0:10]
    cur.execute('SELECT duration FROM datatable WHERE date =' + '"' + today 
+ '"')

The 3rd line is a way to take just the first part 10 chars of the 
datetime.today string, so
instead of "2007-09-01 12:00:03" it would be just "2007-09-01", since I just 
want
to match it to today, not a particular time during today.  But this only 
works if the
dates have been saved that way--typically they are saved with the time as 
well, so
this method is not good and obviously not the right way to do it.

I can tell I am going about this totally wrongly and that I should be able 
to use either
the Python datetime functions or SQLite's date functions much better, so any 
insight
would be appreciated.   Thank you.

_________________________________________________________________
(Continue reading)

Alan Gauld | 1 Sep 2007 10:08

Re: problem resulting from installing 3.0


"Dick Moores" <rdm <at> rcblue.com> wrote

> > > And another question is, exactly what should go into PYTHONPATH?
>
> >Its what goes into sys.path.
>
> >In other words its where your local modules are stored.
> >Much more flexible. I'm a big fan of environment variables!
>
> I don't think I follow you, Alan. I thought I was
> using environment variables.

You are, but you asked about what should go in PYTHONPATH

I was pointing out the advantages of using PYHONPATH over
just putting a path file into your installation, which is another
way of telling Python where too look. I wasn't suggesting that
you weren't doing it, merely affirming that its a good idea.

> There are subfolders with local modules in
> E:\PythonWork\. Do I have to list them too?

Thats exactly what should be in there.

> modules such as datetime.py, and random.py-are not local?

These would more typically be installed in the site-packages
folder within your installation since they are not your own scripts.
But if you chodse to store them outside the Python folders then
(Continue reading)

Righard/Riku van Roy | 1 Sep 2007 13:46
Picon
Gravatar

Re: date matching with python and sqlite3

I sorry, maybe I am stupid at the moment but I cannot follow your
question,....

1) User can select a date, or a range of dates.

2) At the moment you are only able to let the user select a date that
has entered the database today.

3) A value from a table called duratation will be returned for the
selected date?

4) It will only work if the date is saved in this? "2007-09-01", way.,
What other way can the date be saved?

5) You want to now how you can improve your program?

Can you give some more info please, again sorry if others understeand it
perfectly,
Righard

Op za, 01-09-2007 te 01:55 -0400, schreef Che M:
> I'm trying to allow users to select data from an sqlite database using 
> Python by choosing either a date or a range of dates.  I'm stuck at just 
> allowing the to select data that entered the database "today" and return 
> values from a column called duration.  I have this mess at the moment:
> 
> #assume they have already chosen this self.datechoice to be today
> 
> if self.datechoice == "today":
>     todaystring = str(datetime.datetime.today())
(Continue reading)


Gmane