Re: [Tutor] Graphics with Python: wxPython vs. tkinter vs., PyCairo vs. PyX vs...

2007-01-18 Thread Paulino
There is also PyQt4 which is my favorite. I'm a beginner in programming I tryed first PyQt and I gave up because it seemed so complicated. Then I've played a litle with tkinter which I think is very poor. I moved to wxpython which as a learning curve similar to that of tkinter, but a wider set

[Tutor] Division doesn't work

2007-01-18 Thread Johan Geldenhuys
Hi all, In my script I want to convert 14105 bytes to kilobytes and and this is what I do: >>> s = 14105 >>> print '%0.2f' % (s/1024) 13.00 This not correct and I don't know why. The answer is 13.77. Any pointers please that would help my in the right direction? Thanks Johan -- No vi

Re: [Tutor] Division doesn't work

2007-01-18 Thread Geoframer
You assign s as an integer... it should be a float to get the right result... So either define s as s = 14105.0 or as s = float(14105) it'll then result in the right answer : In [17]: s=14105.0 In [18]: s/1024 Out[18]: 13.7744140625 In [19]: s = float(14105) In [20]: s/1024 Out[20]: 13.7744

Re: [Tutor] Division doesn't work

2007-01-18 Thread Geoframer
Or actually an even easier way is to just to divide bij a float and the end result will also be a float. So in your case divide bij 1024.0 ;-) In [21]: s=14105 In [22]: s/1024.0 Out[22]: 13.7744140625 HTH - Geofram On 1/18/07, Geoframer <[EMAIL PROTECTED]> wrote: You assign s as an intege

Re: [Tutor] Division doesn't work

2007-01-18 Thread Johan Geldenhuys
Thanks at lot. Something as simple as that... J _ From: Geoframer [mailto:[EMAIL PROTECTED] Sent: 18 January 2007 02:10 PM To: Johan Geldenhuys Cc: tutor@python.org Subject: Re: [Tutor] Division doesn't work You assign s as an integer... it should be a float to get the right result.

[Tutor] Redirect from a CGI script

2007-01-18 Thread Paulino
How can i redirect to another URL from a python CGI script. Is's suposed to be as simply as: print "Location : http://newurl " It's not working. this simple code does't work - 'print "Content-Type:text/html\n\n" 'print "Location : /cgi-bin/ecodiv.pyw " 'print I use CGIHTTPServer, the server sc

Re: [Tutor] Redirect from a CGI script

2007-01-18 Thread Andre Engels
2007/1/18, Paulino <[EMAIL PROTECTED]>: How can i redirect to another URL from a python CGI script. Is's suposed to be as simply as: print "Location : http://newurl " It's not working. this simple code does't work - 'print "Content-Type:text/html\n\n" 'print "Location : /cgi-bin/ecodiv.pyw "

Re: [Tutor] Division doesn't work

2007-01-18 Thread Kent Johnson
Johan Geldenhuys wrote: > Hi all, > > In my script I want to convert 14105 bytes to kilobytes and and this is > what I do: > >> >> s = 14105 >> >> print '%0.2f' % (s/1024) > 13.00 > > This not correct and I don't know why. The answer is 13.77. > > Any pointers please that would help my in

Re: [Tutor] Redirect from a CGI script

2007-01-18 Thread Kent Johnson
Paulino wrote: > How can i redirect to another URL from a python CGI script. > > Is's suposed to be as simply as: > > print "Location : http://newurl " > It's not working. > > this simple code does't work - > 'print "Content-Type:text/html\n\n" Try it without the two extra newlines. A blank li

Re: [Tutor] Division doesn't work

2007-01-18 Thread Zara
On Thu, 18 Jan 2007 13:09:48 +0100, Geoframer <[EMAIL PROTECTED]> wrote: >You assign s as an integer... it should be a float to get the right >result... <...> Yes, that is the wordt defect of Python: its inability to read programmer mind and detect the rteal programmer intentions. Zara __

Re: [Tutor] Division doesn't work

2007-01-18 Thread Danny Yoo
On Thu, 18 Jan 2007, Johan Geldenhuys wrote: > Thanks at lot. Something as simple as that... No, don't feel bad about it: integer division is a bad "gotcha!" in Python. Integer division is known to be suprising, and it'll eventually be replaced by true division in Python 3: http://www.

Re: [Tutor] Beginners

2007-01-18 Thread wesley chun
> I dont have any programming background, i know only c language. you say you don't have any programming experience but that you know C... i'm not sure what you mean by that. how many years have you been using C? ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Perfect Python web stack?

2007-01-18 Thread Hugo González Monteverde
Hi, Check the thread in the archive. This has been discussed recently. I have been exploring Django, and since I don't want to go into SQL now, I like it. It generates DB code from your model and you don't have to do SQL. It helps to do your app FAST! But that's just my opinion. Hugo OkaMt

[Tutor] Correct Way to Start a Python Program Under Linux

2007-01-18 Thread pytutor . 20 . 247ob
Hi, Please help I'm at my wits end... My program comprises of 2 modules and runs a gui written in pygtk2, I have at the beginning of each: #!/bin/env python I made it executable (chmod a+x) I can run them from a terminal window like $ /path/to/file.py this works fine and dandy no probs at all

[Tutor] Variables of Variables

2007-01-18 Thread Tino Dai
Hi Everybody, Is there a way to do variables of variables in python. For example in perl: $foo = 'bar' $$foo = '5' and $bar will have a value of 5. I have been search high and low for a simple way to do this in python? -Thanks, Tino ___ Tutor mai

Re: [Tutor] Variables of Variables

2007-01-18 Thread John Fouhy
On 19/01/07, Tino Dai <[EMAIL PROTECTED]> wrote: > Hi Everybody, > > Is there a way to do variables of variables in python. For example in > perl: > > $foo = 'bar' > $$foo = '5' > > and $bar will have a value of 5. I have been search high and low for a > simple way to do this in python? In th

Re: [Tutor] Variables of Variables

2007-01-18 Thread Danny Yoo
> Rather than storing your data as variables, you could store it in a > dictionary. Then you can dynamically access data however you like.. Suggesting a dictionary here is right. The technique in the original poster's question is deprecated and widely known to be a Bad Idea in Perl. See Mark

Re: [Tutor] Perfect Python web stack?

2007-01-18 Thread Alan Gauld
"OkaMthembo" <[EMAIL PROTECTED]> wrote > Please help me to decide. I might have asked some > of you before, so please bear with me. > > I want to build a database driven python web app > and i need to decide, so please vote on the best > components "Best" will depend on many things. For the data

Re: [Tutor] Perfect Python web stack?

2007-01-18 Thread Alan Gauld
"Dave Kuhlman" <[EMAIL PROTECTED]> wrote > I'm currently learning Pylons. The tutorials for Pylons discuss > two object-relational mappers for Python: SQLObject and SQLAlchemy. > If you want to view your database from a higher, more abstract > level, you might want to look at them, too. FWIW.

Re: [Tutor] Telepathic Python (was: Division doesn't work)

2007-01-18 Thread Carroll, Barry
> -Original Message- > Date: Thu, 18 Jan 2007 14:16:07 +0100 > From: Zara <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Division doesn't work > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=us-ascii > > On Thu, 18 Jan 2007 13:09:48 +0100, Geoframer

Re: [Tutor] What is a mixin class?

2007-01-18 Thread Alan Gauld
"Don Taylor" <[EMAIL PROTECTED]> wrote >I have a vague idea what a mixin class is, I would like to get a >better > handle on it. The mixin style of OOP comes from the old (1970's vintage) Flavors version of Lisp. In Flavors the metaphor was to start with the Vanilla flavor and mix-in other flav

Re: [Tutor] Correct Way to Start a Python Program Under Linux

2007-01-18 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > I can run them from a terminal window like > > $ /path/to/file.py > > this works fine and dandy no probs at all but ultimately I want to > share this program and I want people to launch the program directly > from a menu and not a shell. That should be straightforward