Re: [Tutor] Expletive Deleted

2006-06-11 Thread Alan Gauld
> I think XML is a tool that allows non-programmers to look at 
> structured
> data and have it a in human readable form that gives us a chance of
> understanding that structure.

Thats not a great reason to choose a file format IMHO.
Tools can be written to display data in a readable format.
For example SQL can be used to view the data in a database.
File formats should be designed to store data, compactly
and with easy access.

> The other strength that I can see is this:  Once data is in this 
> format,
> and a tool has been written to parse it,  data can be added to the
> structure (more elements) and the original tool will not be broken 
> by
> this.  Whatever it is parsed for is found and the extra is ignored.

But this is a very real plus point for XML.
And this IMHO is the biggest single reason for using it, if you have
data where the very structure itself is changing yet the same file
has to be readable by old and new clients then XML is a good choice.

> Without a doubt, the overhead XML adds over say, something as simple 
> as
> CSV is considerable, and XML would appear to be rather more hard to 
> work
> with in things like Python and PERL.

Considerable is an understatement, its literally up to 10 or 20 times
more space and that means bandwidth and CPU resource to
process it.

Using XML as a storage medium - a file - is not too bad, you suck
it up, process it and foirget the file. MY big gripe is that people 
are
inceasingly trying to use XML as the payload in comms systems,
sending XML messages around. This is crazy! The extra cost of the
network and hardware needed to process that kind of architecture
is usually far higher than the minimal savings it gives in developer
time.
[As an example I recently had to uplift the bandwidth of the
intranet pipe in one of our buildings from 4Mb to a full ATM pipe
of 34Mb just to accomodate a system 'upgrade' that now used XML.
That raised the network operations cost of that one building
from $10k per year to over $100k! - The software upgrade by
contrast was only a one-off cost of $10K]

> So, I think XML has it's place but I will not fault anyone for 
> trying to
> make it easier to get code to work.

Absolutely agree with that. Just be careful how you use it and
think of the real cost impact you may be having if its your choice.
Your customers will thank you.

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] problems with python and glade

2006-06-11 Thread Alan Gauld
Can you send the complete error trace. The line you have
copied looks like it is from inside GTk somewhere, we
need the stack trace to see where it originates in your code.

But I'm no GTk expert so I probably can't help anyway! :-)

Alan G.

- Original Message - 
From: "Alfonso" <[EMAIL PROTECTED]>
To: 
Sent: Saturday, June 10, 2006 7:48 PM
Subject: [Tutor] problems with python and glade


> Hi,
> I'm trying to learn to use python with glade. As start I have tried 
> to
> run a program from a tutorial, but when I run it I become this
> exception:  class GladeXML(_gtk.GtkData): AttributeError: 'module'
> object has no attribute 'GtkData'
>
>
> This ist the program:
>
> import pygtk
> pygtk.require('2.0')
> import gtk
> import libglade
> import gtk.glade
>
> class HellowWorldGTK:
>"""This is an Hello World GTK application"""
>
>def __init__(self):
>
>#Set the Glade file
>self.gladefile = "proyecto2.glade"
>self.wTree = gtk.glade.XML(self.gladefile)
>
>#Get the Main Window, and connect the "destroy" event
>self.window = self.wTree.get_widget("MainWindow")
>if (self.window):
>self.window.connect("destroy", gtk.main_quit)
>
>
> Does anyone know what could be wrong? Thank you for your attention.
>
>
>
>
> __
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
> 


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


Re: [Tutor] buggy bug in my program

2006-06-11 Thread Kent Johnson
Kermit Rose wrote:
> # def insertw(j1,k,w1,w2,jar,limit):
> #trace = 1
> #if k == 0:
> #jar[k][0] = k
> #jar[k][1] = w1
> #jar[k][2] = w2
> #return
> #if j1 > k:
> #jar[j1][0] = k
> #jar[j1][1] = w1
> #jar[j1][2] = w2
> #return
> #
> #for j2 in range(j1+1,k+1):
> #j3 = k + j1 - j2 
> #if trace > 0:
> #print " insertw:  move jar[",j3,"] up one"," j1 = ",j1," k = "
> k," w1 = ",w1," w2 = ",w2
> #f = jar[j3]
> #jar[j3+1] = f

I think you want to copy jar[j3] here. In your code, jar[j3] and 
jar[j3+1] both refer to the same list! If you change the list, you will 
see it in both places.

Assignment in Python is not a copy, it is a name binding. Assignment 
creates a name for an object. If you assign the same object to two 
names, they both are bound to the same thing. If the object is mutable, 
like a list, changes to the object will be seen regardless of which name 
you use to refer to it.

For example:
In [14]: d = [1, 2, 3]

In [15]: e=d

d and e are now references to the same list

In [18]: d[0]=55

The changes the list, the change can be seen regardless of which 
reference to the list is used to access it.
In [19]: d
Out[19]: [55, 2, 3]

In [20]: e
Out[20]: [55, 2, 3]

Here is one way to make a copy; d and f refer to different lists:
In [21]: f=d[:]

In [22]: f
Out[22]: [55, 2, 3]

Changing f doesn't affect d or e:
In [23]: f[1]=23

In [24]: f
Out[24]: [55, 23, 3]

In [25]: d
Out[25]: [55, 2, 3]

In [26]: e
Out[26]: [55, 2, 3]

This may help:
http://www.effbot.org/zone/python-objects.htm

Kent

> #if trace > 0:
> #print " insertw: jar[",j3+1," is now ",jar[j3+1]
> #
> #
> #jar[j1][0] = k
> #jar[j1][1] = w1
> #jar[j1][2] = w2
> #
> #if trace > 0:
> #for j in range(k+1):
> #print " insertw: jar[",j,"] = ",jar[j]
> #return
> #
> 
>  
> debug trace shows the following puzzling behavior.
>  
>  
> fermat2: before insertw:  jar[ 0 ] =  [0, 2, 4]
>  fermat2: before insertw:  jar[ 1 ] =  [1, 4, 16]
>  fermat2: before insertw:  jar[ 2 ] =  [-1, -1, -1]
>  
>  
> I show the array jar before going into insert.
>  
> remember the heading of  insertw is
>  
> # def insertw(j1,k,w1,w2,jar,limit):
>  
>  
> 
>  insertw:  move jar[ 1 ] up one  j1 =  1  k =  2  w1 =  16  w2 =  13
> 
> This shows that insert made one shift, and sifted jar[1] to jar[2].
> j1 = 1 means that insertw was supposed to insert new value into jar[1]
>  
>  insertw: jar[ 2]  is now  [1, 4, 16]
> 
> I print out jar[2] to show that insertw really did shift jar[1] to jar[2].
>  
>  
>  
>  
>  insertw: jar[ 0 ] =  [0, 2, 4]
>  insertw: jar[ 1 ] =  [2, 16, 13]
>  insertw: jar[ 2 ] =  [2, 16, 13]
>  
> Now, outside the loop,  
> I  set jar[j1] to the new values.
>  
> And I print the resulting array, still within the routine insertw.
>  
> jar[1] has been set to the new values.
>  
> BUT, and this is the problem,
>  
> jar[2] has been also set to the new values.
>  
> WHY???
>  
>  
>  
>  
>  
>  
>
> 
> ___
> 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] connect to a remote machine - Linux

2006-06-11 Thread Patricia
Hi All,

I need to connect to a remote computer on the same network to store data into 
its mysql database, and I need to do this using python script.

Although I've used mysql and python before, I have no idea how to access a 
remote computer with Python. Also, I would have to enter a passphrase and 
password to successfully connect to it.. 

I'd appreciate any help.
Thanks!!

Patricia

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


Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Michael Sullivan
On Sun, 2006-06-11 at 15:19 +, Patricia wrote:
> Hi All,
> 
> I need to connect to a remote computer on the same network to store data into 
> its mysql database, and I need to do this using python script.
> 
> Although I've used mysql and python before, I have no idea how to access a 
> remote computer with Python. Also, I would have to enter a passphrase and 
> password to successfully connect to it.. 
> 
> I'd appreciate any help.
> Thanks!!
> 
> Patricia




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


Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Python
On Sun, 2006-06-11 at 15:19 +, Patricia wrote:
> Hi All,
> 
> I need to connect to a remote computer on the same network to store data into 
> its mysql database, and I need to do this using python script.
> 
> Although I've used mysql and python before, I have no idea how to access a 
> remote computer with Python. Also, I would have to enter a passphrase and 
> password to successfully connect to it.. 

I could not simply cut and paste working code, but this should get you
started.  There is no programming difference in using a remote sql
server.

import MySQLdb

dbparms = { 
'host':'dbserver.example.com',  # name of sql server
# (localhost for your local computer)
'user':'dbusername',# your identifier
'passwd':'dbpassword',  # your password
'db':'dbname_to_use',   # initial database
}
conn = MySQLdb.connect( **dbparms)


> 
> I'd appreciate any help.
> Thanks!!
> 
> Patricia
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Lloyd Kvam
Venix Corp

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


Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Roy Mac
Try looking at PyDO - This provides an interface between Python and your
database.  This allows you to change your database at a later time and not
have to change any Python.

The excerpt below is from:
http://skunkweb.sourceforge.net/PyDO2/api/html/public/pydo-module.html

PyDO (Python Data Objects) is an object-relational wrapper for
relational databases.  It provides a convenient API for retrieving and
manipulating data without constraining in any way how the data is
persisted at the RDBMS level.  Supported databases are:

   * postgresql
   * mysql
   * sqlite
   * mssql
   * oracle 



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Patricia
Sent: Sunday, June 11, 2006 4:19 PM
To: tutor@python.org
Subject: [Tutor] connect to a remote machine - Linux

Hi All,

I need to connect to a remote computer on the same network to store data
into its mysql database, and I need to do this using python script.

Although I've used mysql and python before, I have no idea how to access a
remote computer with Python. Also, I would have to enter a passphrase and
password to successfully connect to it.. 

I'd appreciate any help.
Thanks!!

Patricia

___
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] connect to a remote machine - Linux

2006-06-11 Thread Patricia G.

I'm sorry. I think I didn't explain myself well. My problem is not with the database.. The part I'm not sure how to do is connect to the remote computer.. I read somewhere that os.popen would work, but I'm not sure if that will do for me because I have to enter a passphrase and password to connect to the remote machine. 

Any ideas??
 
Thanks,

Patricia   
On 6/11/06, Roy Mac <[EMAIL PROTECTED]> wrote:
Try looking at PyDO - This provides an interface between Python and yourdatabase.  This allows you to change your database at a later time and not
have to change any Python.The excerpt below is from:http://skunkweb.sourceforge.net/PyDO2/api/html/public/pydo-module.html
PyDO (Python Data Objects) is an object-relational wrapper forrelational databases.  It provides a convenient API for retrieving andmanipulating data without constraining in any way how the data ispersisted at the RDBMS level.  Supported databases are:
  * postgresql  * mysql  * sqlite  * mssql  * oracle-Original Message-From: [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED]] On BehalfOf PatriciaSent: Sunday, June 11, 2006 4:19 PMTo: tutor@python.orgSubject: [Tutor] connect to a remote machine - LinuxHi All,
I need to connect to a remote computer on the same network to store datainto its mysql database, and I need to do this using python script.Although I've used mysql and python before, I have no idea how to access a
remote computer with Python. Also, I would have to enter a passphrase andpassword to successfully connect to it..I'd appreciate any help.Thanks!!Patricia___
Tutor maillist  -  Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Python
(back on list)
On Sun, 2006-06-11 at 18:59 -0400, Patricia G. wrote:
> I'm sorry. I think I didn't explain myself well. My problem is not
> with the database.. The part I'm not sure how to do is connect to the
> remote computer.. 
MySQL will accept connections from other computers.  It listens on port
3306.  There are network setup and security issues, but those would be
outside the scope of a Python database program.

> I read somewhere that os.popen would work, but I'm not sure if that
> will do for me because I have to enter a passphrase and password to
> connect to the remote machine.
I presume that was using os.popen to talk to stdin/stdout files
connected to a telnet or ssh session established from outside Python.
That is likely to prove pretty clumsy for all but the simplest cases.

> Any ideas??
Logging on to a remote computer should not have anything to do with
accessing a remote MySQL database.

ssh would probably be the preferred way to login to a remote computer.
http://www.lag.net/paramiko/
would appear to do the trick.

If you're stuck with telnet, the stdlib has a telnetlib module that
would help.

http://pexpect.sourceforge.net/
Provides an expect like module to help manage a terminal session
conversation.

In general, program-to-program interaction between computers works best
with protocols that were designed for programs.  Telnet expects a person
who will interpret error strings, not type too quickly, and understand
(and wait for) prompts.

Obviously, I don't know your situation, but scripting remote terminal
sessions should be a last resort.  (I used to do it a lot (15 - 20 years
ago) over serial connections where there was no alternative protocol.)

>  
> Thanks,
> Patricia  
> 
>  
> On 6/11/06, Python <[EMAIL PROTECTED]> wrote: 
> On Sun, 2006-06-11 at 15:19 +, Patricia wrote:
> > Hi All,
> >
> > I need to connect to a remote computer on the same network
> to store data into 
> > its mysql database, and I need to do this using python
> script.
> >
> > Although I've used mysql and python before, I have no idea
> how to access a
> > remote computer with Python. Also, I would have to enter a
> passphrase and 
> > password to successfully connect to it..
> 
> I could not simply cut and paste working code, but this should
> get you
> started.  There is no programming difference in using a remote
> sql
> server.
> 
> import MySQLdb 
> 
> dbparms = {
>'host':'dbserver.example.com',  # name of sql server
># (localhost for your local
> computer)
>'user':'dbusername',# your identifier 
>'passwd':'dbpassword',  # your password
>'db':'dbname_to_use',   # initial database
>}
> conn = MySQLdb.connect( **dbparms)
> 
> 
> >
> > I'd appreciate any help.
> > Thanks!!
> > 
> > Patricia
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> --
> Lloyd Kvam
> Venix Corp
> 
> 
-- 
Lloyd Kvam
Venix Corp

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


Re: [Tutor] combo box

2006-06-11 Thread kakada
Michael Lange wrote:
> On Tue, 06 Jun 2006 13:39:21 +0700
> kakada <[EMAIL PROTECTED]> wrote:
>
>   
>> Dear Friends,
>>
>> I am now working on GUI python (Tkinter).
>> I want to use combobox as my widget, but I cannot find it in any document.
>>
>> Does anybody have experience with that?
>>
>> 
>
> There is no ComboBox widget in plain Tkinter.
> Probably the easiest way to get one is to use Tix which is included in the 
> windows python
> distribution and should be available in any recent linux distro.
>
> If you want to use Tix simply replace the import line
>
> from Tkinter import *
>
> with
>
> from Tix import *
>
> You then can use your Tknter widgets as usual, plus a nice set of extra 
> widgets (ComboBox, NoteBook, DirTree etc.) .
>
> I hope this helps
>
> Michael
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>   
Thank Michael,

How about putting an icon on an Windows Manager, do you know?

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


[Tutor] icon on windows manager

2006-06-11 Thread kakada
Hi everyone!

Does any body know how to put icon on windows manager using Tix module?

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


[Tutor] assignment statements in python

2006-06-11 Thread Kermit Rose
  
Message: 1
Date: Sun, 11 Jun 2006 06:58:39 -0400
From: Kent Johnson <[EMAIL PROTECTED]>
Subject: Re: [Tutor] buggy bug in my program
Cc: tutor@python.org
 
Assignment in Python is not a copy, it is a name binding. Assignment
creates a name for an object. If you assign the same object to two
names, they both are bound to the same thing. If the object is mutable,
like a list, changes to the object will be seen regardless of which name
you use to refer to it.
 
**
 
I feel a little bit better now that I know that there is a reason for what
my
program did.
 
However, I still don't have any idea how to copy values from one cell in 
an array to the adjacent cell in the same array.
 
I looked  at the reference ,
 
http://www.effbot.org/zone/python-objects.htm
 
that you gave,
 
but did not gleam any hint from it how to copy values from one place in an
array to another place within the same array.
 
It must be possible, for otherwise, you could not sort an array.
 
 
It is quite remarkable that my not knowing that 
 
assignment is not a copy 
 
gave me no difficulties before now.
 
 
 
Kermit  <  [EMAIL PROTECTED]  >
 
 

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


Re: [Tutor] assignment statements in python

2006-06-11 Thread Python
On Sun, 2006-06-11 at 22:14 -0400, Kermit Rose wrote:
>   Message: 1
> Date: Sun, 11 Jun 2006 06:58:39 -0400
> From: Kent Johnson <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] buggy bug in my program
> Cc: tutor@python.org
>  
> Assignment in Python is not a copy, it is a name binding. Assignment
> creates a name for an object. If you assign the same object to two
> names, they both are bound to the same thing. If the object is mutable,
> like a list, changes to the object will be seen regardless of which name
> you use to refer to it.
>  
> **
>  
> I feel a little bit better now that I know that there is a reason for what
> my
> program did.
>  
> However, I still don't have any idea how to copy values from one cell in 
> an array to the adjacent cell in the same array.
>  
> I looked  at the reference ,
>  
> http://www.effbot.org/zone/python-objects.htm
>  
> that you gave,
>  
> but did not gleam any hint from it how to copy values from one place in an
> array to another place within the same array.
>  
> It must be possible, for otherwise, you could not sort an array.
>  
> 
> It is quite remarkable that my not knowing that 
>  
> assignment is not a copy 
>  
> gave me no difficulties before now.
The basic python objects: numbers, strings, and tuples are immutable and
can not be changed (mutated).
a = b = 3
b = 4   # binds b to a different object with value 4
# the object with value 3 is unchanged
print a
3

Container objects such as lists and dictionaries can be changed in
place.
>>> a = b = [1,2,3]
>>> b.append(4) # changes (mutates) b
>>> print a
[1, 2, 3, 4]
>>> b[2] = b[3] # positions 2 and 3 reference the same object
>>> print b
[1, 2, 4, 4]
>>> print a
[1, 2, 4, 4]


>  
> 
> 
> Kermit  <  [EMAIL PROTECTED]  >
>  
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Lloyd Kvam
Venix Corp

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


Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Danny Yoo


> I'm sorry. I think I didn't explain myself well. My problem is not with 
> the database.. The part I'm not sure how to do is connect to the remote 
> computer..

Hi Patricia,

There's some confusion here.  Let's get that out in the open.

It sounds like you have a remote server.  That server provides login shell 
service through ssh, and this login shell service runs on port 22, I 
think.  But if your server is running MySQL, it is very likely that it 
provides network access to that MySQL database through port 3306.

I think you believe that ssh login access is required to access MySQL on 
your remote network server.  But this is not necessarily true: one can 
access MySQL remotely without having a login shell account into the 
machine.  That is, rather than:

 Client > Login through SSH > Execute mysql client

which is three steps, the conventional route here is:

 Client > Connect to networked MySQL using a database driver
  (MySQLdb)

which is more direct.


See:

 MySQLdb: http://sourceforge.net/projects/mysql-python

as well as:

 http://www.devshed.com/c/a/Python/MySQL-Connectivity-With-Python/


However, this does mean that the remote MySQL server has to be set up with 
a separate MySQL username/password account.  That is, MySQL keeps its own 
set of usernames and passwords that can be separate from the shell 
logins.

Also, mysqld --- the software that drives the MySQL server --- has to be 
enabled to work across tcp.  That requirement sounds obvious enough, but 
it is not the default in the MySQL server installs I've seen lately, so 
double check this with your database system administrator.  In short: you 
can not automatically assume that having login access to the machine will 
give you MySQL database access, and visa-versa.

Does this make sense so far?


> I read somewhere that os.popen would work, but I'm not sure if that will 
> do for me

Almost certainly no.

popen is not for external database access.  People have written database 
drivers to solve this problem for you already.  It is perhaps possible to 
bend popen() in such a way to access MySQL, but this will involve an 
amount of work to get right, and there will be a lot of ways of getting it 
wrong.  *grin*


So I'd recommend changing this question from: "How do I get popen() to 
access MySQL across a remote interface?" to a more general: "How do I 
connect to MySQL from Python?"  The link above to MySQLdb will give you 
the software necessary to connect your client to a MySQL server, and the 
link to the Devshed article is a tutorial on how to use it effectively.


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


[Tutor] please remove this address from list: [EMAIL PROTECTED]

2006-06-11 Thread graphic design
not sure how i got on this list. please remove my email address from it.
 
thank you.
 
[EMAIL PROTECTED]

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