Re: [Tutor] Open Source database software

2008-11-24 Thread W W
On Mon, Nov 24, 2008 at 6:19 PM, Mike Meisner <[EMAIL PROTECTED]> wrote:

>  Y'all have been so good with suggestions on my programming problems in
> the past, I wonder if anyone could provide a suggestion on a more general
> topic.
> 5.  And, everything either in Python or with APIs that Python can
> easily use.
>
> Has anyone used products that would meet my needs?
>

I haven't used anything, but you can connect to mysql databases with python,
from what I've read it seems to have all the bells & whistles (and then go
ahead and add the ability to do whatever you want/can do with python).

I'm sure there are plenty of folks with more experience, but that's
something to get you started!

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


[Tutor] Open Source database software

2008-11-24 Thread Mike Meisner
Y'all have been so good with suggestions on my programming problems in the 
past, I wonder if anyone could provide a suggestion on a more general topic.

I'd like to get away from using Microsoft Access.  I have a number of Access 
databases to convert.

My needs are:

1.  A relational database management system for a single user (i.e, I don't 
need client/server and all the extra baggage that goes with it).  The RDMS must 
be able to handle graphics objects.

2.  Open source with a decent track record.

3.  A good GUI front end for creating the database, creating forms for user 
data input, queries, reports, etc.

4.  Smart enough to easily read and convert an Access (.mdb) database file.

5.  And, everything either in Python or with APIs that Python can easily use.

Has anyone used products that would meet my needs?

Thanks.

Mike

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


Re: [Tutor] file locations

2008-11-24 Thread Kent Johnson
On Mon, Nov 24, 2008 at 2:10 PM, Jeff Peery <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a wxapp from which I would like to execute another wxapp. the 'child'
> wxapp is located in a sub directory of the 'parent' wxapp. The problem I'm
> having is that I execute the child app from the parent app and it cannot
> find the modules/images/files etc that it needs because it is looking in the
> parents directory location and not its own. I want to keep the child wxapp
> in its own sub directory for organizational

If the child app is being run in a separate process, then specify the
child dir as the working dir of the process. For example if you are
using subprocess.Popen() use the cwd parameter.

If the child app is imported and run in the parent process, then you
need to add the child dir to sys.path, and not have any duplicate
module names between the parent and child directories.

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


Re: [Tutor] My horrible looking program needs improvement.

2008-11-24 Thread Peter van der Does
On Mon, 24 Nov 2008 11:00:59 -0500
Peter van der Does <[EMAIL PROTECTED]> wrote:

> I wrote my 1st Python program and it works as I want it to work but
> ,IMHO, it looks horrible.
> 
> As to what my program does:
> It downloads a file from the web, downloads .htaccess and Apache log
> file from a FTP site, using the IP's from the Apache log it checks if
> the IP exists in the web-file, if it is it's added to the .htaccess as
> a deny from.
> 
> Most actions are logged to file and console.
> 
> Why I think it looks horrible:
> Everything is in main(), I would like to use functions but ran into
> problems with the scope of my variables.
> The CLI arguments check is just a bunch of IF's
> 
> Is this the place where somebody could go over my program and give
> some pointers on how to improve the structure or is there a forum out
> on the Net that can help me out.
> 
> If this is the place, how do I show the program, in-line or attached?
> 
> Thanks in  advance.
> 
OK, I put the code here:

http://pdoes.pastebin.com/m47109194

Thanks people.

-- 
Peter van der Does

GPG key: E77E8E98

WordPress Plugin Developer
http://blog.avirtualhome.com

GetDeb Package Builder/GetDeb Site Coder
http://www.getdeb.net - Software you want for Ubuntu


signature.asc
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] file locations

2008-11-24 Thread W W
On Mon, Nov 24, 2008 at 1:10 PM, Jeff Peery <[EMAIL PROTECTED]> wrote:

> Hello,
> I have a wxapp from which I would like to execute another wxapp. the
> 'child' wxapp is located in a sub directory of the 'parent' wxapp. The
> problem I'm having is that I execute the child app from the parent app and
> it cannot find the modules/images/files etc that it needs because it is
> looking in the parents directory location and not its own. I want to keep
> the child wxapp in its own sub directory for organizational purposes, but
> what is the best way to deal with this problem?
>
>
I don't know much (read just about zero) about wxapp, but at first blush I
would think you should be able to give an absolute directory for all the
modules/images/files, etc. rather than relative. Though I have no clue how
you would do that.

HTH, good luck,
Wayne


-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] file locations

2008-11-24 Thread Jeff Peery
  Hello,
  I have a wxapp from which I would like to execute another wxapp. the 'child' 
wxapp is located in a sub directory of the 'parent' wxapp. The problem I'm 
having is that I execute the child app from the parent app and it cannot find 
the modules/images/files etc that it needs because it is looking in the parents 
directory location and not its own. I want to keep the child wxapp in its own 
sub directory for organizational purposes, but what is the best way to deal 
with this problem?
   
  thanks,
  Jeff
  


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


Re: [Tutor] My horrible looking program needs improvement.

2008-11-24 Thread Kent Johnson
On Mon, Nov 24, 2008 at 11:00 AM, Peter van der Does
<[EMAIL PROTECTED]> wrote:
> I wrote my 1st Python program and it works as I want it to work but
> ,IMHO, it looks horrible.
>
> Is this the place where somebody could go over my program and give
> some pointers on how to improve the structure or is there a forum out
> on the Net that can help me out.
>
> If this is the place, how do I show the program, in-line or attached?

Yes, we can help with that. If the program is not too long (maybe
40-50 lines max), in-line or attached is fine. For longer programs you
can use something like http://pastebin.com/. The shorter your program
is, the more likely someone will read and respond to it - we are all
volunteers.

You might also consider asking specific questions, for example post a
short code snippet and ask how to solve a particular problem.

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


Re: [Tutor] My horrible looking program needs improvement.

2008-11-24 Thread Alan Gauld

Everything is in main(), I would like to use functions but ran into
problems with the scope of my variables.


Did your functions have parameters?
Thats usually how to deal with passing names between scopes.


Is this the place where somebody could go over my program


Yes.

If this is the place, how do I show the program, in-line or 
attached?


If its short (<100 lines?) just paste it into a mail - try to preserve
formatting please! Otherwise posting it on a web site like
pastebin is a good option - provides good formatting and colouring...

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



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


Re: [Tutor] My horrible looking program needs improvement.

2008-11-24 Thread W W
On Mon, Nov 24, 2008 at 10:00 AM, Peter van der Does <[EMAIL PROTECTED]
> wrote:

> I wrote my 1st Python program and it works as I want it to work but
> ,IMHO, it looks horrible.


Nothing to be ashamed of, unless you don't mind it looking horrible. The
fact that you want a clean program is a good sign!


> 


> Why I think it looks horrible:
> Everything is in main(), I would like to use functions but ran into
> problems with the scope of my variables.
> The CLI arguments check is just a bunch of IF's


You would probably benefit from using a class then (especially if you have
worries about your "main" program looking clean).

You can create global class variables that each of the methods/functions
have access to with the self. - for instance

In [11]: class IP:
   : address = "192.168.1.1"
   : def printAddress(self):
   : print self.address
   :
   :

In [12]: x = IP()

In [13]: x.printAddress()
192.168.1.1
---

Then you just declare a new instance of your class (see In[12]) and you have
access to all its methods and variables;

In [15]: x.address = "127.0.0.1"

In [16]: x.printAddress()
127.0.0.1


> Is this the place where somebody could go over my program and give
> some pointers on how to improve the structure or is there a forum out
> on the Net that can help me out.


I don't know about anyone else, but I suspect most people are at least as
busy as myself, but perfectly willing to help answer your questions, but I
doubt anyone has the time (even if they want) to re-write your program /for/
you, but we'll be glad to help if you get stuck on a problem (or even need
pointers on where else to look, if Google or your favourite search engine
fails to turn up any information)

Using a class should really help clean up your program and help eliminate
your scope problems. Here's a nifty little tutorial on python classes:
http://www.diveintopython.org/object_oriented_framework/defining_classes.html

Give classes a try and see if helps. If you're still having issues or you
don't understand something, feel free to ask!

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


[Tutor] My horrible looking program needs improvement.

2008-11-24 Thread Peter van der Does
I wrote my 1st Python program and it works as I want it to work but
,IMHO, it looks horrible.

As to what my program does:
It downloads a file from the web, downloads .htaccess and Apache log
file from a FTP site, using the IP's from the Apache log it checks if
the IP exists in the web-file, if it is it's added to the .htaccess as
a deny from.

Most actions are logged to file and console.

Why I think it looks horrible:
Everything is in main(), I would like to use functions but ran into
problems with the scope of my variables.
The CLI arguments check is just a bunch of IF's

Is this the place where somebody could go over my program and give
some pointers on how to improve the structure or is there a forum out
on the Net that can help me out.

If this is the place, how do I show the program, in-line or attached?

Thanks in  advance.

-- 
Peter van der Does

GPG key: E77E8E98

WordPress Plugin Developer
http://blog.avirtualhome.com

GetDeb Package Builder/GetDeb Site Coder
http://www.getdeb.net - Software you want for Ubuntu


signature.asc
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] the sense of brackets

2008-11-24 Thread Lie Ryan
On Sat, 22 Nov 2008 22:58:48 +0100, spir wrote:

> W W a écrit :
>  > On Sat, Nov 22, 2008 at 9:42 AM, spir <[EMAIL PROTECTED]> wrote:
>  >
>  >> I have long thought "[]" /simply/ is a list constructor syntax. What
>  >> do you think of the following?
>  >>
>  >> t = "aze"
>  >> print t, list(t), [t]
>  >> print list(list(t)), list([t]), [list(t)], [[t]] ==>
>  >> aze ['a', 'z', 'e'] ['aze']
>  >> ['a', 'z', 'e'] ['aze'] [['a', 'z', 'e']] [['aze']]
>  >
>  > Consider the following:
>  > In [1]: list("Hello")
>  > Out [1]: ['H', 'e', 'l', 'l', 'e', 'o'] and the list docstring:
>  > list() -> new list
>  > list(sequence) -> new list initialized from sequence's items so
>  > list(list(t)) makes perfect sense: list(t) is ['a', 'z' ,'e'] and
>  > list(list(t)) simply creates a new list initialized from that list's
>  > items HTH,
>  > Wayne
> 
> Yep! What surprises me is the behaviour of [] instead. I can understand
> that list(t) != [t]
> but
> [list(t)], [[t]] --> [['a', 'z', 'e']] [['aze']] is a bit strange to me.
> 

what do you expect [] should do on that case? I think it's perfectly 
reasonable and consistent with the semantic for [] to just simply 
"enclose" whatever inside it with []s instead of converting an iterable 
to a list as list() does.

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


Re: [Tutor] faulty code (maths)

2008-11-24 Thread Roel Schroeven

David schreef:

Hello everybody,

I recently came across a book by Prof. Langtangen: Indroduction to 
Computer Programming: http://folk.uio.no/hpl/INF1100/INF1100-ebook-Aug08.pdf


I am trying to solve exercise 1.18 ("Why does the following program not 
work correctly?"), but I don't find the mistake: why does the line


q = sqrt(b*b - 4*a*c)

cause an error? I was playing around with the code, but got nowhere.

Here the entire code:

a = 2; b = 1; c = 2
from math import sqrt
q = sqrt(b*b - 4*a*c)
x1 = (-b + q)/2*a
x2 = (-b - q)/2*a
print x1, x2


Many thanks for a pointer!


Apart from the problem of taking the square root of a negative number, 
there is another problem in the code in the book: to calculate the roots 
of a * x**2 + b*x + c, there should be parentheses around 2*a in the 
calculation of x1 and x2:


x1 = (-b + q)/(2*a)
x2 = (-b - q)/(2*a)

Otherwise the code multiplies by a instead while it should instead 
divide by a.


--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

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