Re: Inheritance confusion

2008-04-19 Thread Kay Schluehr
On 19 Apr., 08:37, Hook <[EMAIL PROTECTED]> wrote:

> Traceback (most recent call last):
>   File "./3.py", line 20, in 
> Obj.Connect ('Database')
>   File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect
> self.TRACE ("DB::Connect (" + database + "," + mode)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE
> self.DailyLog (msg)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in
> DailyLog
> dt  = self.Date (time ())
> TypeError: 'module' object is not callable
>
> Googling the "TypeError" message suggests that I've got a module and
> class with the same name, but I can't see that I have.

The error message just says that you have called a module which is
time in this case.

Just replace the call to time by time.time() and it shall work.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance confusion

2008-04-19 Thread Peter Otten
Hook wrote:

> When I run the script I get this:
> 
> Traceback (most recent call last):
>   File "./3.py", line 20, in 
> Obj.Connect ('Database')
>   File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect
> self.TRACE ("DB::Connect (" + database + "," + mode)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE
> self.DailyLog (msg)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in
> DailyLog
> dt  = self.Date (time ())
> TypeError: 'module' object is not callable
> 
> 
> Googling the "TypeError" message suggests that I've got a module and
> class with the same name, but I can't see that I have.
> 
> Can someone point me in the right direction please?

Read the traceback ;) Here's a hint:

>>> import time
>>> time()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'module' object is not callable
>>> time.time()
1208588011.7017989

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance confusion

2008-04-19 Thread 7stud
On Apr 19, 12:37 am, Hook <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm having a problem with multiple inheritance - it's clearly something
> I've missed, but the web pages and books that I've consulted aren't
> helping, so I'll throw myself on the mercy and collective wisdom of
> Usenet!
>
> I've got 4 files (what I'll show has the active content removed for
> brevity):
>
> Errors_m.py
> ~~~
> class Errors (object) :
>     def __init__ (self, params) :
>         pass
>
>     def Error (self, string) :
>         return 100
>
> DT_m.py
> ~~~
> class DT (object) :
>     def __init__ (self, params) :
>                 pass
>
>     def Date (self, epoch, pattern = 'd mmm ') :
>         dt = datetime.datetime.fromtimestamp (epoch)
>
> Hook_m.py
> ~
> from DT_m import DT
> from Error_m import Errors
>
> class Hook (Errors, DT) :
>     def __init__ (self, params) :
>         DT.__init__ (self, params)
>         Errors.__init__ (self, params)
>
> DB_m.py
> ~~~
> from Hook_m import Hook
>
> class DB (Hook) :
>     def __init__ (self, params) :
>         Hook.__init__ (self, params)
>
> And a test script:
>
> #!/usr/bin/python
>
> import os
> import re
> import string
> import sys
>
> from DB_m import DB
>
> Dict = dict ()
> Dict ['logdir'] = '/tmp/log'
> Dict ['diag']   = 1
>
> Obj = DB (Dict)
> print dir (Obj)
> Obj.Connect ('Database')
>
> When I run the script I get this:
>
> Traceback (most recent call last):
>   File "./3.py", line 20, in 
>     Obj.Connect ('Database')
>   File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect
>     self.TRACE ("DB::Connect (" + database + "," + mode)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE
>     self.DailyLog (msg)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in
> DailyLog
>     dt          = self.Date (time ())
> TypeError: 'module' object is not callable
>
> Googling the "TypeError" message suggests that I've got a module and
> class with the same name, but I can't see that I have.
>
> Can someone point me in the right direction please?
>
> If you need to see all the source, can do, but it's certainly too much
> for an intro message!
>
> Thanks,
>
> Hook


import time

time()

--output:--
Traceback (most recent call last):
  File "test1.py", line 3, in ?
time()
TypeError: 'module' object is not callable


Did you do that somewhere?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance confusion

2008-04-19 Thread Mark Shroyer
In article <[EMAIL PROTECTED]>,
 Hook <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I'm having a problem with multiple inheritance - it's clearly something 
> I've missed, but the web pages and books that I've consulted aren't 
> helping, so I'll throw myself on the mercy and collective wisdom of 
> Usenet!
> 
> I've got 4 files (what I'll show has the active content removed for 
> brevity):
> 
> Errors_m.py
> ~~~
> class Errors (object) :
> def __init__ (self, params) :
> pass
> 
> def Error (self, string) :
> return 100
> 
> DT_m.py
> ~~~
> class DT (object) :
> def __init__ (self, params) :
>   pass
> 
> def Date (self, epoch, pattern = 'd mmm ') :
> dt = datetime.datetime.fromtimestamp (epoch)
> 
> Hook_m.py
> ~
> from DT_m import DT
> from Error_m import Errors
> 
> class Hook (Errors, DT) :
> def __init__ (self, params) :
> DT.__init__ (self, params)
> Errors.__init__ (self, params)
> 
> DB_m.py
> ~~~
> from Hook_m import Hook
> 
> class DB (Hook) :
> def __init__ (self, params) :
> Hook.__init__ (self, params)
> 
> 
> And a test script:
> 
> #!/usr/bin/python
> 
> import os
> import re
> import string
> import sys
> 
> from DB_m import DB
> 
> Dict = dict ()
> Dict ['logdir'] = '/tmp/log'
> Dict ['diag']   = 1
> 
> Obj = DB (Dict)
> print dir (Obj)
> Obj.Connect ('Database')
> 
> 
> When I run the script I get this:
> 
> Traceback (most recent call last):
>   File "./3.py", line 20, in 
> Obj.Connect ('Database')
>   File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect
> self.TRACE ("DB::Connect (" + database + "," + mode)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE
> self.DailyLog (msg)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in 
> DailyLog
> dt  = self.Date (time ())
> TypeError: 'module' object is not callable
> 
> 
> Googling the "TypeError" message suggests that I've got a module and 
> class with the same name, but I can't see that I have.

For what it's worth, modules actually *are* allowed to contain a class 
of the same name: for example, datetime.datetime.

Anyway, what this error message is actually trying to tell you is that 
you are attempting to call a module as a function somewhere -- and in 
this particular case, I think it's referring to the time module.  Are 
you sure that line 98 in Hook_m.py should not instead be:

dt = self.Date(time.time())

The time module contains a function, time(), which returns the current 
Unix time (another example of a module containing an object of the same 
name, incidentally); but you'll need to call this function as 
"time.time()" unless you have prefaced your code with

from time import time

or

from time import *

Otherwise, the token "time" refers to the time module, which is not 
callable, and not the desired function therein.

-- 
Mark Shroyer, http://markshroyer.com/contact/

   Due to extreme spam, I block all articles originating from Google
 Groups.  If you want your postings to be seen by more readers you will
  need to find a different means of posting on Usenet.
   http://improve-usenet.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance confusion

2008-04-19 Thread Ben Finney
Hook <[EMAIL PROTECTED]> writes:

> I'm having a problem with multiple inheritance

You aren't alone. Multiple inheritance (MI) is difficult to implement,
and once implemented, usually difficult to understand and sometimes
counterintuitive.

I recommend you read and absorb the article "The Truth about super"
http://www.phyast.pitt.edu/~micheles/python/super.html> to
understand more about MI in Python.


However, there are more fundamental issues:

> I've got 4 files

That should be irrelevant to MI problems. Please refine your example
so that it's in one module, and still exhibits the problem.

> When I run the script I get this:
> 
> Traceback (most recent call last):
>   File "./3.py", line 20, in 
> Obj.Connect ('Database')
>   File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect
> self.TRACE ("DB::Connect (" + database + "," + mode)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE
> self.DailyLog (msg)
>   File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in 
> DailyLog
> dt  = self.Date (time ())
> TypeError: 'module' object is not callable

No, you don't. That might be what you get from *your* code, but it's
not produced by the code you *posted*. (I know this if only because
none of your modules have a line 98 on which to raise an exception.)

So, since we don't have the code that generates that traceback, that
traceback isn't useful to us for diagnosing the problem.

> If you need to see all the source, can do, but it's certainly too
> much for an intro message!

Indeed. Instead, re-work your code (based on a copy) until it's as
simple as it can be, and *still* shows the problems when you execute
it. Then, if you still don't know why the traceback occurs, feel free
to post that minimal example with the corresponding traceback.

-- 
 \  "Jury: A group of 12 people, who, having lied to the judge |
  `\   about their health, hearing, and business engagements, have |
_o__)failed to fool him."  -- Henry L. Mencken |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


www.tradertrade.com(accept paypal).buy sell nike shox R4sneaker trainer sports shoes.nike jordan airforce one shoes nike airmax shox shoes gucci prada timberland shoes

2008-04-19 Thread tradertrade13
We  (www.tradertrade.com)  china wholesale and retail new Nike
Sneakers,Air Jordan Sneakers,air force ones 1s,Nike Dunks SB,Bape Sta
from nike outlets and factory stores,also Nike wholesale - Jordan
Shoes we supply nike sneakers jordan sneaker air force 1s ...
Featuring unique gift ideas for birthdays,weddings, anniversaries &
holidays.Nike Air Max LTD-Nike Air Max Ltd Shoes, Nike Air Max Ltd
Trainers. ... We   (www.tradertrade.com)  also sale and wholesale
nike shoes other styles:nike air max - nike air max Nike Air Max -
Nike Air Max TN Plus,TN BURBERRY,Gucci,TN L.V.. NIKE TN REQUINS
CHAUSSURES,neuves hommes Nike TN requins Chaussures:Nike Air Max TN
Plus men's,Nike Shox - Mens,Womens Nike Shox basketball shoes
wholesale from chinaNike Shox TL NZ R4 R5 Turbo Monster Nike shoes
wholesale,Puma - Puma Shoes.Nike shoes wholesale:Puma Shoes men's
women's trainers at globnikesneakers dot com Puma Shoes cheap
discount
shoes nike wholesale and sale to nike shop and nike We sell Nike Air
Max shoes,nike air max trainers for running and training- Nike Air
Max 360 95 97 2003 Tn Plus Nike shoes wholesale,air max2 cb 94,air
max2 cb,air ...Nike Wholesale,Nike Sneaker,jordan Sneaker, Air Force
one 1s, Dunk Dunks Jordan Jordans Air Max Shox
Rift...Timberland.Timberland boots,Timberland shoes,Prada
wholesale,Prada sale,Prada shop,Prada store.we wholesale and sale
cheap discount Timberland men's women's,We Wholesale  Cheap Jordan
Shoes,Michael Jordan Shoes,Nike Jordan Basketball shoes,Nike Air
Jordan.Timberland-Timberland Boots.Nike shoes wholesale:Timberland
Boots men's women's  trainers sneakers basketball shoes running
shoes.Timberland Boots cheap discount  Nike Air Max 90-Nike Air Max
90
Shoes,Nike Air Max 90 trainers. at globnikesneaker dot com nike shoes
Nike Air Max ->  Nike Air Max 90 (Note Mens model size 41 42 43 44 45
46.Nike shoes buy, nike shoes wholesale, buy nike shoes from china
nike shoes wholesale ... (www.tradertrade.com) Nike Running
shoes,nike shox and nike air max Running shoes, nike shox tl nz r4
turbo monster  running shoes,nike air max tn,Puma - Puma Speed Cat.
Nike shoes wholesale:Puma Speed Cat men's women's trainers sneakers
basketball shoes running shoes,Nike Air Max 2003-Nike Air  Max 2003
Trainers,Nike Air Max 2003 Shoes. ... Nike Air Max 2003 cheap
discount
shoes nike  wholesale and sale to nike shop and nike store.Nike Air
Max - Nike Air Max 2004 trainers. Nike  shoes wholesale:Nike Air
Max ... Nike Air Max 2003 cheap discount shoes nike wholesale and
sale
to nike shop and nike factory.Nike Air Jordan 3,nike jordan 3 retro
shoes,nike air jordan 3 retro sneakers,Nike air jordan 3 shoes
wholesale:Nike Air Jordan 3 men's women's trainers  sneakers,Nike
Shox-
Nike Shox TL NZ R4 R5 Turbo Monster Nike shoes wholesale.We wholesale
nike shoes: Nike Shox TL,Nike Shox NZ,Nike Shox R4,Nike Shox R5,Nike
Shox Nike Air Dunk- Nike Air Dunk High.Nike shoes wholesale:Nike Air
Dunk High men's women's trainers sneakers basketball shoes running
shoes.Nike Air Max 97, Nike Womens Air Max 97 trainers, nike mens air
max 97 trainers,nike air max 97 running shoes sell cheap with
discount,Nike Air Force 1-Nike ... Nike Air force 1 High cheap
discount shoes nike wholesale at globnikesneakers dot com We also
sale
and wholesale nike shoes other styles:nike air we sell cheap Nike Air
Max 95 shoes and trainers for womens,mens and for
running,trainning,tennis with all black color,pink color,red,
blue..with discount,Nike air jordan shoes for wholesale,We wholesale
and sale nike air jordan  Basketball shoes,buy quality of nike air
jordan running shoes trainers sneakers for our ...Nike cheap shoes,we
sale nike shoes in cheap price,buy cheap nike shoes Adidas. Adidas
shoes,Adidas wholesale,Adidas shop,Adidas store,Adidas
goodyear,Adidas
TMAC,Adidas wholesale and sale cheap discount Adidas.Nike Dunk - Nike
Air Dunk. Nike Dunk Air Dunk Low Mid High Nike shoes wholesale.We
wholesale Nike Dunk Air Dunk Men's Women's shoes wholesale at cheap
discount price,Nike Air Rift-Nike Rift Air Rift Nike shoes
wholesale.We wholesale nike shoes;Nike Rift shoes, Nike Air Rift
shoes.Puma-Puma Joggers.Nike shoes wholesale:Puma Joggers men's
women's trainers... (www.tradertrade.com) Puma Joggers cheap
discount shoes nike wholesale and sale to nike shop and nike Adidas -
Adidas Shoes. Nike shoes wholesale: Adidas Shoes men's women's
trainers ... Adidas Shoes cheap discount shoes nike wholesale and
sale
to nike shop and nike Shoes. Nike Air Max. Nike Air Max TN Plus. Nike
Air Max 90. Nike Air Max 91. Nike Air Max 95 ... Nike Air force 1
Low.
Nike Air force 1 High. Nike Air Jordan Nike Air Max  Nike Air Max 360
95 97 2003 Tn Plus ... Nike Air Max 360, Nike Air Max 95, Nike Air
Max
97, Nike Air Max 2003, ... (www.tradertrade.com)Nike Air Jordan
2,Nike Jordan 2 Retro Shoes Nike Air Jordan 2 shoes wholesale: Nike
Air Jordan 2 men's women's trainers sneakers sketball shoes running
shoes at globnikesneakers dot com .Nike Air Max - Nike Air Max 2005,
Nike

Re: How to print a unicode string?

2008-04-19 Thread Martin v. Löwis
> Is it possible to change an
> environment variable, so that Python uses this coding automatically?

No.

> Or pass a command-line argument when Emacs python-mode invokes the
> Python interpreter?

No.

> Or execute this line of Python in a startup script
> which is invoked whenever a new Python session is started?

Yes, you can add the code I suggested to sitecustomize.py.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter, getting canvas-object, how?

2008-04-19 Thread Rafał Wysocki
[EMAIL PROTECTED] napisał(a):
> so i load a gif onto a canvas and when i click the canvs i want to get
> the color of the pixel that is clicked.
> so i need to ge the object im clicking.
> i was told in another thread to use find_withtag or find_closest but
> it is not working, maybe im using the
> method on the wrong object.
> how do i do this?
> and how do i then get specifics about that object, ie the pixel-color?
>
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
> return self.func(*args)
>   File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments
> \mapgetobject.py", line 17, in callback
> undermouse=find_closest(master.CURRENT)
> NameError: global name 'find_closest' is not defined
>
> from Tkinter import *
>
> master = Tk()
>
> w = Canvas(master, width=400, height=625)
> w.pack(expand = YES, fill = BOTH)
>
> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of-
> sweden.gif')
> w.create_image(30, 30, image = mapq, anchor = NW)
>
> def key(event):
> print "pressed", repr(event.char)
>
> def callback(event):
> clobj=event.widget
> ##undermouse=find_withtag(master.CURRENT)
> undermouse=find_closest(master.CURRENT)
> print repr(undermouse)
>
> w.bind("", key)
> w.bind("", callback)
> w.pack()
>
> mainloop()

from Tkinter import *

master = Tk()

w = Canvas(master, width=400, height=625)
w.pack(expand = YES, fill = BOTH)

mapq = PhotoImage(file = 'img.gif')
_id = w.create_image(0, 0, image = mapq, anchor = NW)

objects = {} # map id to object
objects[_id] = mapq

def key(event):
print "pressed", repr(event.char)

def callback(event):
x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a
window x,y coordinates to a canvas coordinate
_id = w.find_closest(x,y)[0] # Returns tuple containing the object
id
obj = objects[_id]   # Finds object with given id
print 'color: %s' % obj.get(int(x), int(y))

w.bind("", key)
w.bind("", callback)
w.pack()

mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python setup.py install on Vista?

2008-04-19 Thread Steve Holden
Patrick Mullen wrote:
> On Fri, Apr 18, 2008 at 4:29 PM, globalrev <[EMAIL PROTECTED]> wrote:
>> type "python setup.py install"
>>
>>  that is used in most "addons" for python.
>>
>>  well using windows vista, where the h*** am i supposed to type this?
>>
>>  if it is not doable in windows, what do i have to do instead? just
>>  clicking the setup.py-file never works.
>>  --
>>  http://mail.python.org/mailman/listinfo/python-list
>>
> 
> There are many problems with this on Vista.  First, you need a command
> prompt.  You can go to "start menu->all programs->accessories->command
> prompt" for this.  But to install things in vista, you will likely
> need to be an administrator, and windows won't automatically ask for
> permission when typing "python setup.py install."  So instead of
> clicking on command prompt, right click it, and choose "run as
> administrator".  A faster way is to type "cmd" in the start menu
> search area, and wait for "cmd.exe" to come up.  Run that as
> administrator.

A quicker way to get an adminstrator command tool is to bring up the run 
dialog with Windows-R, enter "cmd" then hit CTRL/SHIFT/Enter.
> 
> Once you have a command prompt, you can "cd" into the directory where
> you want to install the extension.  Then, "c:\python25\python setup.py
> install" should work.  If you are using 2.4 or 3.0, it would be
> "c:\python24\python" or "c:\python30\python" etc.  If you installed
> python somewhere other than the default folder, then you will need to
> enter that path.
> 
> To make this process easier, when I want to install an extension, I
> usually create a .bat file in the extension folder.  Right click in
> the folder and choose new->text file.  Rename the file to
> "install.bat".  Right click the file and go to edit.  Enter
> "c:\python25\python setup.py install" into the file and save.  Then
> right click and choose run as administrator, and it should install.
> You might add a "pause" line in the bat file as well, so that if it
> has a problem installing, it will stay open so you can see the output.
> 
> Your best solution is to uninstall vista and use linux :)

You're right, Vista's a pain.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py3k concerns. An example

2008-04-19 Thread Carl Banks
On Apr 18, 11:58 am, Aaron Watters <[EMAIL PROTECTED]> wrote:
> Why is the migration to py3k a concern?
> For example I have libraries which use string%dictionary
> substitution where the dictionary is actually an object
> which emulates a dictionary.  The __getitem__ for
> the object can be very expensive and is only called when
> needed by the string substitution.
>
> In py3k string%dictionary is going away.  Why?
> I have no idea.
>
> The replacement is a string.format(...) method
> which supports dictionary calling.
> string.format(**dictionary)
> But dictionary
> calling doesn't support dictionary emulation.
> So in the example below the substitution works
> but the call fails.
>
> === code
>
> class fdict(dict):
> def __getitem__(self, item):
> return "got("+item+")"
>
> def fn(**d):
> print d["boogie"]
>
> if __name__=="__main__":
> fd = fdict()
> print "attempting string substitution with fake dictionary"
> print
> print "hello there %(boogie)s" % fd # <-- works
> print
> print "now attempting function call with fake dictionary"
> print
> fn(**fd) # <-- fails
>
> === output
>
> % python2.6 dtest.py
> attempting string substitution with fake dictionary
>
> hello there got(boogie)
>
> now attempting function call with fake dictionary
>
> Traceback (most recent call last):
>   File "dtest.py", line 17, in 
> fn(**fd)
>   File "dtest.py", line 7, in fn
> print d["boogie"]
> KeyError: 'boogie'
>
>  end of output
>
> Consequently there is no simple way to translate
> my code, I think.  I suspect you will find this kind of subtle
> issue in many places.  Or worse, you won't find it
> until after your program has been installed
> in production.
>
> It's a damn shame because
> if string%dict was just left in it wouldn't be an issue.
>
> Also, if making f(**d) support dict emulation
> has any negative  performance implications
> then I don't want it please.
>
> sigh.  -- Aaron Watters


If you don't like Python 3, DON'T USE IT.

It's been stated repeatedly that 2.x and 3.x are going to be supported
in parallel for years.

Refusing to use 3, thus casting your brain-share vote against it, is
far more likely to have an effect than you coming here and making
everyone's life miserable with your pitiful whining.


Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Workshop

2008-04-19 Thread m.moghimi
On Apr 14, 9:53 pm, "m.moghimi" <[EMAIL PROTECTED]> wrote:
> On Apr 14, 5:15 pm, "Twayne" <[EMAIL PROTECTED]> wrote:
>
>
>
> > > Hi,
>
> > > We are to hold a workshop about python (introduction). It will be two
> > > one hour and half sessions.
> > > I wanted to know which subjects do you suggest to be presented and is
> > > there a good presentation file (powerpoint or ...) about this on the
> > > net.
> > > We thought that it may be good that first session covers the
> > > introduction, zen of python, python coding syntax and the second
> > > session will be about application, libraries or so.
> > > I really appreciate if you tell me your ideas?
>
> > Depends; what's the experiene level of the audience?  "Introductory" is
> > a pretty vague concept; introductory to what audience?
>
> > --
> > --
> > Regards,
>
> > Twayne
>
> > Open Office isn't just for wimps anymore;
> > OOo is a GREAT MS Office replacementwww.openoffice.org
>
> The audiences are computer engineering students who know programming
> in c++ and some of them know java.

any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 adoption

2008-04-19 Thread Carl Banks
On Apr 18, 2:08 pm, Joseph Turian <[EMAIL PROTECTED]> wrote:
> How widely adopted is python 2.5?
>
> We are doing some development, and have a choice to make:
> a) Use all the 2.5 features we want.
> b) Maintain backwards compatability with 2.4.
>
> So I guess the question is, does anyone have a sense of what percent
> of python users don't have 2.5?


One possible barometer for the situation is what's the oldest version
of Python to have been supported in the most bug-fix releases?

...In which case you need to maintain backwards compatibility with
2.3.

(I bring this up to illustrate that if there are people clamoring for
a 2.3 updates, there are probably quite a few supporting 2.4 as well.)


Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 adoption

2008-04-19 Thread Graham Breed
On Apr 19, 3:16 am, Joseph Turian <[EMAIL PROTECTED]> wrote:
> Basically, we're planning on releasing it as open-source, and don't
> want to alienate a large percentage of potential users.

How about Java users?  Jython was recently at 2.2 (still is for all I
know).  I'm pleased they've got that far because I like to know that
my code can run under Java and I like generators.

My web host uses 1.5.2.  That is painful.

If you're assuming your potential users already have 2.4 then the
chances are they'll have upgraded to 2.5 by the time you've finished
anyway.


  Graham
-- 
http://mail.python.org/mailman/listinfo/python-list


Mondaine Women's Railway watch #A669.30305.11SBC - Replica Watch Fake

2008-04-19 Thread watches0802
Mondaine Women's Railway watch #A669.30305.11SBC - Replica Watch Fake

Mondaine Women's Railway watch #A669.30305.11SBC Link :
http://www.watchesprice.net/Replica-Mondaine-10291.html
Replica Watches Home : http://www.watchesprice.net/
Replica Mondaine Brands : http://www.watchesprice.net/Mondaine-Replica.html

Replica Mondaine Women's Railway watch #A669.30305.11SBC --- one of
best selling replica watches, it is crafted in high quality, please
click image 'buy now' to buy this chic but inexpensive replica to save
you a lot of money .

Mondaine Women's Railway watch A669.30305.11SBC Description:


Swiss quartz movement, Casual watch, Black hands and hour markers,
Black indices, Analog date display, Polished stainless steel silver-
tone bezel, case, crown and caseback, 30 meters/100 feet water
resistant

Mondaine Women's Railway watch A669.30305.11SBC Details:



Brand: Mondaine
Model: A669.30305.11SBC
Dimensions: .7 pounds

Dial color: Polished stainless steel silver-tone case, White
Water-resistant to 30 meters




Thank you for choosing www.watchesprice.net as your reliable dealer of
quality waches including Mondaine Women's Railway watch
#A669.30305.11SBC . we guarantee every watch you receive will be exact
watch you ordered. Each watch sold enjoy one year Warranty for free
repair. Every order from aaa-replica-watches is shipped via EMS, the
customer is responsible for the shipping fee on the first order, but
since the second watch you buy from our site, the shipping cost is
free. Please note that If the total amount of payment is over
$600(USD), the customer is required to contact our customer service
before sending the money in case failed payment. If you have any other
questions please check our other pages or feel free to email us by
[EMAIL PROTECTED] Cheapest Mondaine Women's Railway watch
#A669.30305.11SBC


The Same Mondaine Series :

Mondaine - A669303SBB (Size: women) :
http://www.watchesprice.net/Replica-Mondaine-10292.html

Mondaine A6873030814sbb Line Extension Unisex Watch :
http://www.watchesprice.net/Replica-Mondaine-10293.html

Mondaine - A6903030814SBB (Size: men) :
http://www.watchesprice.net/Replica-Mondaine-10294.html

Mondaine A6873030811sbb Line Extension Unisex Watch :
http://www.watchesprice.net/Replica-Mondaine-10295.html

Mondaine A6663032214sbb Line Extension Unisex Watch :
http://www.watchesprice.net/Replica-Mondaine-10296.html

Mondaine Men's Railways watch #A669.30308.64SBB :
http://www.watchesprice.net/Replica-Mondaine-10297.html

Mondaine Men's Railway watch #A660.30303.14SBB :
http://www.watchesprice.net/Replica-Mondaine-10298.html

Mondaine Men's Watches Specials A658.30300.11GEB - 5 :
http://www.watchesprice.net/Replica-Mondaine-10299.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch - Replica Watch Fake

2008-04-19 Thread watches0802
Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Bezel Women's Watch - Replica Watch Fake

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Bezel Women's Watch Link : 
http://www.watchesprice.net/Replica-Bulova-2208.html
Replica Watches Home : http://www.watchesprice.net/
Replica Bulova Brands : http://www.watchesprice.net/Bulova-Replica.html

Replica Bulova Watches, Bulova Ladies' Sport Marine Star Mother of
Pearl Dial Diamond Bezel Women's Watch --- one of best selling replica
watches, it is crafted in high quality, please click image 'buy now'
to buy this chic but inexpensive replica to save you a lot of money .

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Bezel Women's Watch Description:

no
Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Bezel Women's Watch Details:



Brand: Bulova
Band material: stainless-steel
Bezel material: stainless-steel
Case material: stainless-steel
Clasp type: deployment-buckle
Dial color: mother-of-pearl
Dial window material: anti-reflective-sapphire
Movement type: Quartz
Water-resistant to 330 feet




Thank you for choosing www.watchesprice.net as your reliable dealer of
quality waches including Bulova Watches, Bulova Ladies' Sport Marine
Star Mother of Pearl Dial Diamond Bezel Women's Watch . we guarantee
every watch you receive will be exact watch you ordered. Each watch
sold enjoy one year Warranty for free repair. Every order from aaa-
replica-watches is shipped via EMS, the customer is responsible for
the shipping fee on the first order, but since the second watch you
buy from our site, the shipping cost is free. Please note that If the
total amount of payment is over $600(USD), the customer is required to
contact our customer service before sending the money in case failed
payment. If you have any other questions please check our other pages
or feel free to email us by [EMAIL PROTECTED] Cheapest Bulova
Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond
Bezel Women's Watch


The Same Bulova Series :

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2209.html

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2210.html

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Markers Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2211.html

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Markers Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2212.html

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Markers Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2213.html

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Markers Rotating Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2214.html

Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial
Diamond Markers Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2215.html

Bulova Watches, Bulova Ladies' Sport Marine Star Silver, Pink and Blue
Interchangebale Bezel 35 Diamonds Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2216.html

Bulova Watches, Bulova Ladies' Sport Marine Star Two Tone Steel and
Gold Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2217.html

Bulova Watches, Bulova Ladies' Sport Marine Star Two Tone Steel and
Rose Gold Diamond Bezel Mother of Pearl Dial Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2218.html

Bulova Watches, Bulova Latest Edition in Stainless Steel or Two Tone
with or without Diamond Bezel Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2219.html

Bulova Watches- Bulova Ladies' Bracelet Two Tone Steel and Gold
Women's Watch :
http://www.watchesprice.net/Replica-Bulova-2220.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeNone field detection

2008-04-19 Thread Joe Blow
On Wed, 16 Apr 2008 21:13:18 -0400, Steve Holden wrote:
> 
> Since there is only one instance of TypeNone (the value we reference as 
> None) the easiest test is
> 
>if x is None:
> 

Thanks... the "if x is None:" statement is exactly what I was looking for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 adoption

2008-04-19 Thread Donald 'Paddy' McCarthy
Joseph Turian wrote:
> Basically, we're planning on releasing it as open-source, and don't
> want to alienate a large percentage of potential users.
Then develop for 2.5 with an eye on what is to come this year in 2.6 with 
regard to already planned 
deprecations.

- Paddy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 adoption

2008-04-19 Thread castironpi
On Apr 18, 2:16 pm, Joseph Turian <[EMAIL PROTECTED]> wrote:
> Basically, we're planning on releasing it as open-source, and don't
> want to alienate a large percentage of potential users.

99% is a big percent.  My 1% doesn't like something.
-- 
http://mail.python.org/mailman/listinfo/python-list


winreg module, need help to understand why i'm getting exception

2008-04-19 Thread hellt
HI all, i found winreg module from 
http://www.rutherfurd.net/python/winreg/index.html
very useful and simple, instead _winreg.

But i have a problem with this module, in its iterable part.

look at the following code

key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum")
for i in key.values:
print i.value

and that is the exception

Traceback (most recent call last):
 File "D:\.Projects\python\temp.py", line 21, in 
   for i in key.values:
 File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next
   return self.values[self.index - 1]
 File "C:\Python25\Lib\site-packages\winreg.py", line 289, in
__getitem__
   name = _winreg.EnumValue(self.hkey, key)[0]
WindowsError: [Error 259] No more data is available


so there is some problem with iterate, i think
i am still a beginner, so i cant understand why this appears, and what
should i fix.

if anyone have some time to look closer to this module, i will
appreciate this very much.

thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


eggy IDE

2008-04-19 Thread mark
Hello,

I have written an open source IDE in python and Qt, called eggy. Eggy 
supports several languages, including python, ruby, C, C++, java, perl 
and others. Eggy also supports group projects over the lan or internet - 
with live changes, lets you compile and run your code, supports 
templates and lets you write your own plugins very easily. You also have 
syntax highlighting, autocompletion, an integrated bash shell and the 
option of chatting with group partners. You can read more about it here:

http://eggy.student.utwente.nl";>http://eggy.student.utwente.nl

it free and open source (GPL).

Regards,

Mark

PS: if anyone is interested in helping out with the project, feel free 
to write and submit a plugin (in python), its really easy and some ideas 
are posted on the website.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print a unicode string?

2008-04-19 Thread M.-A. Lemburg
On 2008-04-19 03:09, [EMAIL PROTECTED] wrote:
> Another poster pointed me to
>>> sys.stdout = codecs.getwriter("UTF-8")(sys.stdout)
> and this works great. All I want now is some reassurance that this is
> the most appropriate way for me to achieve what I want (e.g. least
> likely to break with future versions of Python, most in keeping with
> the design of Python, easiest for me to maintain, etc.).

While the above works nicely for Unicode objects you write
to sys.stdout, you are going to have problems with non-ASCII
8-bit strings, e.g. binary data.

Python will have to convert these to Unicode before applying
the UTF-8 codec and uses the default encoding for this, which
is ASCII.

You could wrap sys.stdout using a codecs.EncodedFile() which provides
transparent recoding, but then you have problems with Unicode objects,
since the recoder assumes that it has to work with strings on input
(to e.g. the .write() method).

There's no ideal solution - it really depends a lot on what
your application does and how it uses strings and Unicode.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 19 2008)
 >>> Python/Zope Consulting and Support ...http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: winreg module, need help to understand why i'm getting exception

2008-04-19 Thread s0suk3
On Apr 19, 6:20 am, hellt <[EMAIL PROTECTED]> wrote:
> HI all, i found winreg module 
> fromhttp://www.rutherfurd.net/python/winreg/index.html
> very useful and simple, instead _winreg.
>
> But i have a problem with this module, in its iterable part.
>
> look at the following code
>
> key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum")
> for i in key.values:
> print i.value
>
> and that is the exception
>
> Traceback (most recent call last):
>  File "D:\.Projects\python\temp.py", line 21, in 
>for i in key.values:
>  File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next
>return self.values[self.index - 1]
>  File "C:\Python25\Lib\site-packages\winreg.py", line 289, in
> __getitem__
>name = _winreg.EnumValue(self.hkey, key)[0]
> WindowsError: [Error 259] No more data is available
>
> so there is some problem with iterate, i think
> i am still a beginner, so i cant understand why this appears, and what
> should i fix.
>
> if anyone have some time to look closer to this module, i will
> appreciate this very much.

The problem is not in your code, but in the module. The EnumValue()
and EnumKey() functions in the _winreg module raise WindowsError when
there are no more keys or values to retrieve. So, go inside the module
and modify that line to something like:

# There should be a for or a while loop around here
try:
name = _winreg.EnumValue(key, index)
except EnvironmentError:
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: winreg module, need help to understand why i'm getting exception

2008-04-19 Thread s0suk3
Sorry, the above post is not complete. This is the rest:

# There should be a for or a while loop around here
try:
name = _winreg.EnumValue(key, index)
except EnvironmentError:
# It raises WindowsError, but the _winreg documentation
# recommends catching EnvironmentError
break
else:
# do something with 'name'
...

Anyway, I'd recommend using _winreg instead of the module you're
using, since it clearly has errors, and it's not on the standard
library.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance confusion

2008-04-19 Thread Hook
Thanks to everyone who replied. Kay and Mark put me on the right track 
immediately. Ben is quite right - the fragment that I posted couldn't 
have given that error, but I didn't want to post the whole thing - 
perhaps wrongly, I thought it wouldn't help clarify what I thought the 
problem was. And that was the real issue - I had managed to convince 
myself that I had a naming problem in one of my own modules somewhere.

If anyone is interested in the background, I'm a long time Perl 
programmer trying to learn Python by converting a small set of standard, 
locally developed Perl libraries. It's an edifying experience, and I can 
understand why some colleagues like Python so much.

Again, thanks for the help, it's appreciated.

Hook
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 adoption

2008-04-19 Thread Ray Cote
At 12:16 PM -0700 4/18/08, Joseph Turian wrote:
>Basically, we're planning on releasing it as open-source, and don't
>want to alienate a large percentage of potential users.
>--
>http://mail.python.org/mailman/listinfo/python-list

A few seconds after reading this, I read the announcement for pyspread.
Requirements? Python 2.5.

You might want to talk with the pyspread folks regarding their 
decision to require 2.5.
http://pyspread.sourceforge.net

--Ray

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Metaprogramming Example

2008-04-19 Thread andrew cooke
On Apr 18, 4:48 am, Bruno Desthuilliers  wrote:
[...]
> Practically, this means that (amongst other niceties) :
> - you can define functions outside classes and use them as instance or
> class methods
> - you can add/replaces methods dynamically on a per-class or
> per-instance basis
> - you can access the function object of a method and use it as a function
> - you can define your own callable types, that - if you implement the
> appropriate support for the descriptor protocol - will be usable as
> methods too

ok, that's convincing (i had thought the majority of these were
already
possible, albeit with some kind of hard-coded "magic" behind the
scenes).

[...]
> > by referring to the titanic
> > i didn't mean that python was a disaster, rather that the "iceberg" is
> > still there (i am not 100% sure what the iceberg is, but it's
> > something
> > to do with making namespaces explicit in some places and not others).
>
> I guess you're thinking of the self argument, declared in the function's
> signature but not "explicitly passed" when calling the method ?

not really.  more to do with when namespaces (i am not sure i have the
right term - the dictionary that provides the mapping from name to
object)
are explicit or implicit.  for example, python has closures (implicit
lookup) and "self" (explicit lookup).

but as i said, i don't have a clear argument - something just feels
"odd".
at the same time, i know that language design is a practical business
and so this is probably not important.

finally, thank you for pointing me to sql alchemy (i think it was
you?).
it really is excellent.

andrew
-- 
http://mail.python.org/mailman/listinfo/python-list


Kill an OS process from script (perhaps unix specific)

2008-04-19 Thread chengiz
Hi,
I'm trying to run a process from a python script. I need the exit
status of that process but do not care about its output, so until now
was using os.system(). But it turned out that the process often went
into an infinite loop, so I wrote a SIGALRM handler. Unfortunately the
code I came up with is quite kludgy:

import subprocess
...
try:
  p = subprocess.Popen(..., shell = True)
  pid = p.pid
  os.waitpid(pid...)
  ...
except ...: # Thrown by alarm signal handler
  os.kill(pid + 1)  # "Real" pid = shell pid + 1
  ...

The os.kill is very hacky and unsafe so I was looking for better
ideas. Any help will be greatly appreciated. Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Metaprogramming Example

2008-04-19 Thread Kay Schluehr
On 17 Apr., 14:25, andrew cooke <[EMAIL PROTECTED]> wrote:

> PS Is there anywhere that explains why Decorators (in the context of
> functions/methods) are so good?

We had kind of an inverse discussion a while ago when someone asked
about the fate of aspect oriented programming (AOP) in Python. My
answer was that technically "aspect weaving" using code generators is
dead in application programming [1] and decorators are handy,
lightweight, local and controllable while serving very similar
purposes.

[1] There are occasions where source code weaving might still has its
place. Profiling for example or code coverage. Just examine this
interesting blog article:

http://nedbatchelder.com/blog/200804/wicked_hack_python_bytecode_tracing.html

and the subsequent discussion.
-- 
http://mail.python.org/mailman/listinfo/python-list


socket.AF_INET

2008-04-19 Thread Matt Herzog
Hi All.

I'm trying to write a script that will send me an email message when my IP 
address changes on a specific NIC. On Linux, the script works. On FreeBSD, it 
fails with: 

Traceback (most recent call last):
File "./pyifcheck.py", line 22, in 
if get_ip_address('xl0') == IPADDY:
File "./pyifcheck.py", line 18, in get_ip_address
struct.pack('256s', ifname[:15]) )[20:24])
IOError: [Errno 25] Inappropriate ioctl for device

The script is below.
###
SENDMAIL = "/usr/sbin/sendmail"
IPADDY = "85.126.250.328"
#IFCONFIG = "/sbin/ifconfig
import os
import smtplib
import socket
import fcntl
import struct

def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915,  # SIOCGIFADDR
struct.pack('256s', ifname[:15]) )[20:24])

#get_ip_address('xl0')

if get_ip_address('xl0') == IPADDY:
print "nevermind"

else:   

p = os.popen("%s -t" % SENDMAIL, "w")
p.write("To: [EMAIL PROTECTED]")
p.write("Subject: YOUR IP ADDRESS HAS CHANGED\n")
p.write("\n") # blank line separating headers from body
p.write("Your IP addy has changed to $getipaddy\n")
p.write("some more text\n")
sts = p.close()
if sts != 0:

print "Sendmail exit status", sts


##

Thanks for any suggestions.

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too 
dark to read."   
--  Groucho Marx

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is file open in system ? - other than lsof

2008-04-19 Thread paul
bvidinli schrieb:
> is there a way to find out if file open in system ? -
> please write if you know a way  other than lsof. because lsof if slow for me.
> i need a faster way.
> i deal with thousands of files... so, i need a faster / python way for this.
> thanks.
I think you can do this with inotify. It's an event based notification 
mechanism for linux kernel 2.6.13 and up. It has python bindings 
available (google for pyinotify).
You will receive events like IN_OPEN,IN_CLOSE,etc. and keep track of 
opened files this way.

hth
  Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why function got dictionary

2008-04-19 Thread Christian Heimes
[EMAIL PROTECTED] schrieb:
> A: everything (or almost) in Python is an object. Including functions,
> classes, modules etc.

Everything you can access from or through Python code must be an object.
Every object has at least a type and a reference count.

Christian

-- 
http://mail.python.org/mailman/listinfo/python-list


urlretrieve can't send headers

2008-04-19 Thread triplezone3
Hello. I'm using urllib.urlretrieve to download files,
because it provides a handy hook function.
Unfortunately, it won't let me send headers, which
could be quite useful. Is there any way I could do
this?



  __
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Metaprogramming Example

2008-04-19 Thread [EMAIL PROTECTED]
On 19 avr, 16:34, andrew cooke <[EMAIL PROTECTED]> wrote:
> On Apr 18, 4:48 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>
> [...]
>
> > Practically, this means that (amongst other niceties) :
> > - you can define functions outside classes and use them as instance or
> > class methods
> > - you can add/replaces methods dynamically on a per-class or
> > per-instance basis
> > - you can access the function object of a method and use it as a function
> > - you can define your own callable types, that - if you implement the
> > appropriate support for the descriptor protocol - will be usable as
> > methods too
>
> ok, that's convincing (i had thought the majority of these were
> already
> possible, albeit with some kind of hard-coded "magic" behind the
> scenes).

Yep, the whole point is that it's not that hard-coded anymore. Python
exposes most of it's inner mechanisms, so that you can taylor quite a
lot of things to your needs. This is quite useful for writing clean
frameworks needing very few boilerplate in the user code.

> [...]
>
> > > by referring to the titanic
> > > i didn't mean that python was a disaster, rather that the "iceberg" is
> > > still there (i am not 100% sure what the iceberg is, but it's
> > > something
> > > to do with making namespaces explicit in some places and not others).
>
> > I guess you're thinking of the self argument, declared in the function's
> > signature but not "explicitly passed" when calling the method ?
>
> not really.  more to do with when namespaces (i am not sure i have the
> right term - the dictionary that provides the mapping from name to
> object)
> are explicit or implicit.  for example, python has closures (implicit
> lookup) and "self" (explicit lookup).
>
> but as i said, i don't have a clear argument - something just feels
> "odd".
> at the same time, i know that language design is a practical business
> and so this is probably not important.

The fact is that everything you do with closures can be done with
objects. OTHO, there are quite a lot of cases where defining a
specific class would be just way too heavy, and a closure is much more
lightweight. So yes, it's a matter of "practicality beats purity".
While trying to remain as clean as possible, Python is definitively a
practical language.

> finally, thank you for pointing me to sql alchemy (i think it was
> you?).

Seems so.

> it really is excellent.

Indeed !-)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urlretrieve can't send headers

2008-04-19 Thread Diez B. Roggisch
triplezone3 schrieb:
> Hello. I'm using urllib.urlretrieve to download files,
> because it provides a handy hook function.
> Unfortunately, it won't let me send headers, which
> could be quite useful. Is there any way I could do
> this?

I suggest you look into urllib2. It allows you to explicitly create an 
request-object that you can stuff with headers and parameters and what 
you like.

diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why function got dictionary

2008-04-19 Thread sturlamolden
On Apr 17, 4:06 pm, AlFire <[EMAIL PROTECTED]> wrote:

> Q: why function got dictionary? What it is used for?

As previously mentioned, a function has a __dict__ like (most) other
objects.

You can e.g. use it to create static variables:

int foobar()
{
   static int i = 0;
   return i++;
}

is roughly equivalent to:

def foobar():
   foobar.i += 1
   return foobar.i
foobar.i = 0







-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Kill an OS process from script (perhaps unix specific)

2008-04-19 Thread Douglas Wells
In article <[EMAIL PROTECTED]>,
  [EMAIL PROTECTED] writes:
> Hi,
> I'm trying to run a process from a python script. I need the exit
> status of that process but do not care about its output, so until now
> was using os.system(). But it turned out that the process often went
> into an infinite loop, so I wrote a SIGALRM handler. Unfortunately the
> code I came up with is quite kludgy:
> 
> import subprocess
> ...
> try:
>   p = subprocess.Popen(..., shell = True)
>   pid = p.pid
>   os.waitpid(pid...)
>   ...
> except ...: # Thrown by alarm signal handler
>   os.kill(pid + 1)  # "Real" pid = shell pid + 1
>   ...
> 
> The os.kill is very hacky and unsafe so I was looking for better
> ideas. Any help will be greatly appreciated. Thanks!

Assuming that the problem is really an infinite loop (and not just
an arbitrary delay), you could use the simple construct:

 import os
 code = os.system ("ulimit -t  ; ...")

That's not guaranteed to work on all POSIX systems, but it should
work with at least ash, bash, and ksh.  And it would would be
"limit cputime  ; ..." if you somehow got hooked up with a
C shell.

 - dmw

-- 
.   Douglas Wells .  Connection Technologies  .
.   Internet:  -sp9804- -at - contek.com- .
-- 
http://mail.python.org/mailman/listinfo/python-list


Issue with inspect module

2008-04-19 Thread ilanschnell
Hi,
I have this trivial program:

import inspect
class A:
def __init__(self, a):
self.a = a
def __str__(self):
return 'A(%s)' % self.a
a = A(8)
print a

the output is:
A(8)
A(8)

Why does the inspect module cause the output
to be printed twice?

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urlretrieve can't send headers

2008-04-19 Thread triplezone3
I have looked in to urllib2, and I can't find a
function which would allow me to get the progress of
the download as it happens, bit by bit, like
urlretrieve does, at least not easily.
urllib.urlretrieve's returnhook is just handy.
I have another question concerning urlretrieve, is
there a way I can force it to stop downloading
half-way, say after the user clicked cancel? Thanks in
advance.

--- "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

> triplezone3 schrieb:
> > Hello. I'm using urllib.urlretrieve to download
> files,
> > because it provides a handy hook function.
> > Unfortunately, it won't let me send headers, which
> > could be quite useful. Is there any way I could do
> > this?
> 
> I suggest you look into urllib2. It allows you to
> explicitly create an 
> request-object that you can stuff with headers and
> parameters and what 
> you like.
> 
> diez
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 



  ___ 
Yahoo! For Good helps you make a difference  

http://uk.promotions.yahoo.com/forgood/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database vs Data Structure?

2008-04-19 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
> On Apr 18, 12:23 am, I V <[EMAIL PROTECTED]> wrote:
>> On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote:
>>> use some sort of data-structure (maybe
>>> nested dictionaries or a custom class) and store the pickled
>>> data-structure in a single row in the database (then unpickle the data
>>> and query in memory).
>> Why would you want to do this? I don't see what you would hope to gain by
>> doing this, over just using a database.
> 
> Are databases truly another language from Python, fundamentally?

Yes.  A fair amount of study went into them.  Databases are about
information that survives the over an extended period of time (months
or years, not hours).

Classic qualities for a database that don't normally apply to Python
(all properties of a "transaction" -- bundled set of changes):
 * Atomicity:
A transaction either is fully applied or not applied at all.
 * Consistency:
Transactions applied to a database with invariants preserve
those invariants (things like balance sheets totals).
 * Isolation:
Each transactions happens as if it were happening at its own
moment in time -- tou don't worry about other transactions
interleaved with your transaction.
 * Durability:
Once a transaction actually makes it into the database, it stays
there and doesn't magically fail a long time later.

-Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with inspect module

2008-04-19 Thread Cristina Yenyxe González García
2008/4/19, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> Hi,

Hello,

>  I have this trivial program:
>
>  import inspect
>  class A:
> def __init__(self, a):
> self.a = a
> def __str__(self):
> return 'A(%s)' % self.a
>  a = A(8)
>  print a
>
>  the output is:
>  A(8)
>  A(8)
>
>  Why does the inspect module cause the output
>  to be printed twice?
>

I have just run it on the CPython interpreter and it works well. Have
you tried it without the 'import inspect' line and checked there is no
problem?

Or maybe are you using another interpreter?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why function got dictionary

2008-04-19 Thread [EMAIL PROTECTED]
On 19 avr, 19:39, sturlamolden <[EMAIL PROTECTED]> wrote:
> On Apr 17, 4:06 pm, AlFire <[EMAIL PROTECTED]> wrote:
>
> > Q: why function got dictionary? What it is used for?
>
> As previously mentioned, a function has a __dict__ like (most) other
> objects.
>
> You can e.g. use it to create static variables:
>
> int foobar()
> {
>static int i = 0;
>return i++;
>
> }
>
> is roughly equivalent to:
>
> def foobar():
>foobar.i += 1
>return foobar.i
> foobar.i = 0

barfoo = foobar
foobar = lambda x : x

And boom.

'static' variables are better implemented using either closures,
mutable default arguments or custom callable types.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with inspect module

2008-04-19 Thread Karl-Heinz Ruskowski
> Why does the inspect module cause the output
> to be printed twice?

I also tested it, no problem here either. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with inspect module

2008-04-19 Thread ilanschnell
On Apr 19, 1:41 pm, Karl-Heinz Ruskowski <[EMAIL PROTECTED]>
wrote:
> > Why does the inspect module cause the output
> > to be printed twice?
>
> I also tested it, no problem here either.

I realized what the problem was.
I called the file inspect.py, stupid me.

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


random.random(), random not defined!?

2008-04-19 Thread globalrev
do i need to import something to use random?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why function got dictionary

2008-04-19 Thread sturlamolden
On Apr 19, 8:33 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> barfoo = foobar
> foobar = lambda x : x
>
> And boom.

That's why I used the qualifier 'roughly equivalent' and not simply
'equivalent'.


-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] DoIt 0.1.0 Released (build tool)

2008-04-19 Thread Eduardo Schettino
DoIt - A task execution tool (build-tool)
=

This is the first public release of DoIt

Website: http://python-doit.sourceforge.net/
Release: DoIt 0.1.0
License: MIT

About
-

DoIt is a build tool that focus not only on making/building things but on
executing any kind of tasks in an efficient way. Designed to be easy to use
and "get out of your way".

DoIt like most build tools is used to execute tasks defined in a
configuration file. Configuration files are python modules. The tasks can be
python functions (or any callable) or an external shell script. DoIt
automatically keeps track of declared dependencies executing only tasks that
needs to be update (based on which dependencies have changed).

In DoIt, unlike most(all?) build-tools, a task doesn't need to define a target
file to use the execute only if not up-to-date feature. This make DoIt
specially suitable for running test suites.

DoIt can be used to perform any task or build anything, though it doesn't
support automatic dependency discovery for any language.

Cheers,
  Eduardo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random.random(), random not defined!?

2008-04-19 Thread Eduardo Schettino
On Sun, Apr 20, 2008 at 12:58 AM, globalrev <[EMAIL PROTECTED]> wrote:
> do i need to import something to use random?
>  --

you need to import random :)

Python 2.5.1 (r251:54863, Mar  7 2008, 03:39:23)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> random.random()
0.76018998919085967
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter, getting canvas-object, how?

2008-04-19 Thread globalrev
On 19 Apr, 10:15, Rafał Wysocki <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] napisa³(a):
>
>
>
> > so i load a gif onto a canvas and when i click the canvs i want to get
> > the color of the pixel that is clicked.
> > so i need to ge the object im clicking.
> > i was told in another thread to use find_withtag or find_closest but
> > it is not working, maybe im using the
> > method on the wrong object.
> > how do i do this?
> > and how do i then get specifics about that object, ie the pixel-color?
>
> > Exception in Tkinter callback
> > Traceback (most recent call last):
> >   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
> > return self.func(*args)
> >   File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments
> > \mapgetobject.py", line 17, in callback
> > undermouse=find_closest(master.CURRENT)
> > NameError: global name 'find_closest' is not defined
>
> > from Tkinter import *
>
> > master = Tk()
>
> > w = Canvas(master, width=400, height=625)
> > w.pack(expand = YES, fill = BOTH)
>
> > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of-
> > sweden.gif')
> > w.create_image(30, 30, image = mapq, anchor = NW)
>
> > def key(event):
> > print "pressed", repr(event.char)
>
> > def callback(event):
> > clobj=event.widget
> > ##undermouse=find_withtag(master.CURRENT)
> > undermouse=find_closest(master.CURRENT)
> > print repr(undermouse)
>
> > w.bind("", key)
> > w.bind("", callback)
> > w.pack()
>
> > mainloop()
>
> from Tkinter import *
>
> master = Tk()
>
> w = Canvas(master, width=400, height=625)
> w.pack(expand = YES, fill = BOTH)
>
> mapq = PhotoImage(file = 'img.gif')
> _id = w.create_image(0, 0, image = mapq, anchor = NW)
>
> objects = {} # map id to object
> objects[_id] = mapq
>
> def key(event):
> print "pressed", repr(event.char)
>
> def callback(event):
> x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a
> window x,y coordinates to a canvas coordinate
> _id = w.find_closest(x,y)[0] # Returns tuple containing the object
> id
> obj = objects[_id]   # Finds object with given id
> print 'color: %s' % obj.get(int(x), int(y))
>
> w.bind("", key)
> w.bind("", callback)
> w.pack()
>
> mainloop()

ty very much. however i dont get the %s really. is % a symbol and then
replaced by obj.get-values?
anyway when clicked i get 3values, but there is intx and inty only.
where does the 3rd value come from and how do i refer to it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Frame work for simple physics web applications

2008-04-19 Thread Rick Muller
I'd like to use my webserver to distribute some simple python physics
apps. Ideally, I'd like to use some simple form to input a few pieces
of data, call a python program, and return some image from a plot or
some other rendering. This is easy to do using CGI, but I was
wondering whether anyone on the list could recommend that would look a
little more polished and professional.

Let's say I want to input a wave vector k, and then input a plot of
sin(k*x). I would like to have a simple form input for k, and then
display an image of the plot. What I'm doing is a little more varied
than this, but the common thread is that in each application I need to
input several pieces of data and then display some image. I can
probably think of 20 different applications right off the bat that I'd
like to deploy.

The idea behind this is to put together some simple toy models for
quantum computing qubits that my experimental collaborators can play
with without having to install Python, NumPy, and MatPlotLib
themselves. (I understand, of course, that such an installation might
be "good for them", but I'd rather not fight that battle just now.)

I could, of course, write a Jython applet for this, but this would
require my re-learning how to use the Java API, and it has been a few
years for me.

Do any of the AJAX frameworks for Python compare in simplicity to
writing a simple CGI script? I've been impressed with web.py, since it
seems pretty easy to use, but I would go to the trouble of learning
one of the bigger frameworks if they would provide a more elegant
solution.

My web skillz are obviously several years out of date, so I'd like
some guidance on the best way to update them.

Thanks in advance,

Rick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: pyspread 0.0.1

2008-04-19 Thread Martin Manns
On Fri, 18 Apr 2008 04:46:38 +0200
Martin Manns <[EMAIL PROTECTED]> wrote:

> pyspread 0.0.1 is now available at:
> http://pyspread.sourceforge.net

Hi,

I updated to version 0.0.2 that fixes the tarballs and zip files.
Any information about the package working on different platforms is
appreciated.

I got it working on Gentoo and on Debian (python 2.4).


Best Regards

Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I just killed GIL!!!

2008-04-19 Thread [EMAIL PROTECTED]
On Apr 18, 9:29 pm, sturlamolden <[EMAIL PROTECTED]> wrote:
> On 18 Apr, 21:28, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx
> > results in a fork-style copy-on-write duplicate of the current process.
>
> I know about NtCreateProcess and ZwCreateProcess, but they just create
> an empty process - no context, no thread(s), no DLLs loaded, etc.
> There is even an example code of how to implement fork() with
> ZwCreateProcess in Nebbet's book on NT kernel internals, but
> apparently it doesn't work quite well.

It works fine for a copy-on-write process creation.  It doesn't work
100% compatibly to fork.  Nebbet is the best reference out there on
the method.

FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL
SectionHandle method and was POSIX certified, so it's certainly
possible.

> Searching with Google, I find several claims that there is a
> "CreateProcessEx"

Yeah my bad, I meant zwCreateProcess.  It's been almost a decade now
since I used it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] DoIt 0.1.0 Released (build tool)

2008-04-19 Thread John Machin
Eduardo Schettino wrote:
> DoIt - A task execution tool (build-tool)
> =
> 
> This is the first public release of DoIt
> 
> Website: http://python-doit.sourceforge.net/
> Release: DoIt 0.1.0
> License: MIT
> 
> About
> -
> 
> DoIt is a build tool that focus not only on making/building things but on
> executing any kind of tasks in an efficient way. Designed to be easy to use
> and "get out of your way".

You may like to consider the possibility of confusion caused by the 
similarity of some characters in some fonts (DoIt, Do1t, Dolt) ... 
google("dictionary dolt") :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random.random(), random not defined!?

2008-04-19 Thread John Machin
globalrev wrote:
> do i need to import something to use random?

No, you need to import random
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter, getting canvas-object, how?

2008-04-19 Thread globalrev
On 19 Apr, 21:43, globalrev <[EMAIL PROTECTED]> wrote:
> On 19 Apr, 10:15, Rafaù Wysocki <[EMAIL PROTECTED]> wrote:
>
>
>
> > [EMAIL PROTECTED] napisa³(a):
>
> > > so i load a gif onto a canvas and when i click the canvs i want to get
> > > the color of the pixel that is clicked.
> > > so i need to ge the object im clicking.
> > > i was told in another thread to use find_withtag or find_closest but
> > > it is not working, maybe im using the
> > > method on the wrong object.
> > > how do i do this?
> > > and how do i then get specifics about that object, ie the pixel-color?
>
> > > Exception in Tkinter callback
> > > Traceback (most recent call last):
> > >   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
> > > return self.func(*args)
> > >   File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments
> > > \mapgetobject.py", line 17, in callback
> > > undermouse=find_closest(master.CURRENT)
> > > NameError: global name 'find_closest' is not defined
>
> > > from Tkinter import *
>
> > > master = Tk()
>
> > > w = Canvas(master, width=400, height=625)
> > > w.pack(expand = YES, fill = BOTH)
>
> > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of-
> > > sweden.gif')
> > > w.create_image(30, 30, image = mapq, anchor = NW)
>
> > > def key(event):
> > > print "pressed", repr(event.char)
>
> > > def callback(event):
> > > clobj=event.widget
> > > ##undermouse=find_withtag(master.CURRENT)
> > > undermouse=find_closest(master.CURRENT)
> > > print repr(undermouse)
>
> > > w.bind("", key)
> > > w.bind("", callback)
> > > w.pack()
>
> > > mainloop()
>
> > from Tkinter import *
>
> > master = Tk()
>
> > w = Canvas(master, width=400, height=625)
> > w.pack(expand = YES, fill = BOTH)
>
> > mapq = PhotoImage(file = 'img.gif')
> > _id = w.create_image(0, 0, image = mapq, anchor = NW)
>
> > objects = {} # map id to object
> > objects[_id] = mapq
>
> > def key(event):
> > print "pressed", repr(event.char)
>
> > def callback(event):
> > x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a
> > window x,y coordinates to a canvas coordinate
> > _id = w.find_closest(x,y)[0] # Returns tuple containing the object
> > id
> > obj = objects[_id]   # Finds object with given id
> > print 'color: %s' % obj.get(int(x), int(y))
>
> > w.bind("", key)
> > w.bind("", callback)
> > w.pack()
>
> > mainloop()
>
> ty very much. however i dont get the %s really. is % a symbol and then
> replaced by obj.get-values?
> anyway when clicked i get 3values, but there is intx and inty only.
> where does the 3rd value come from and how do i refer to it?

nevermind i get it now
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frame work for simple physics web applications

2008-04-19 Thread globalrev
On 19 Apr, 21:55, Rick Muller <[EMAIL PROTECTED]> wrote:
> I'd like to use my webserver to distribute some simple python physics
> apps. Ideally, I'd like to use some simple form to input a few pieces
> of data, call a python program, and return some image from a plot or
> some other rendering. This is easy to do using CGI, but I was
> wondering whether anyone on the list could recommend that would look a
> little more polished and professional.
>
> Let's say I want to input a wave vector k, and then input a plot of
> sin(k*x). I would like to have a simple form input for k, and then
> display an image of the plot. What I'm doing is a little more varied
> than this, but the common thread is that in each application I need to
> input several pieces of data and then display some image. I can
> probably think of 20 different applications right off the bat that I'd
> like to deploy.
>
> The idea behind this is to put together some simple toy models for
> quantum computing qubits that my experimental collaborators can play
> with without having to install Python, NumPy, and MatPlotLib
> themselves. (I understand, of course, that such an installation might
> be "good for them", but I'd rather not fight that battle just now.)
>
> I could, of course, write a Jython applet for this, but this would
> require my re-learning how to use the Java API, and it has been a few
> years for me.
>
> Do any of the AJAX frameworks for Python compare in simplicity to
> writing a simple CGI script? I've been impressed with web.py, since it
> seems pretty easy to use, but I would go to the trouble of learning
> one of the bigger frameworks if they would provide a more elegant
> solution.
>
> My web skillz are obviously several years out of date, so I'd like
> some guidance on the best way to update them.
>
> Thanks in advance,
>
> Rick

www.vpython.org might be what you are looking for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database vs Data Structure?

2008-04-19 Thread castironpi
On Apr 19, 1:27 pm, Scott David Daniels <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Apr 18, 12:23 am, I V <[EMAIL PROTECTED]> wrote:
> >> On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote:
> >>> use some sort of data-structure (maybe
> >>> nested dictionaries or a custom class) and store the pickled
> >>> data-structure in a single row in the database (then unpickle the data
> >>> and query in memory).
> >> Why would you want to do this? I don't see what you would hope to gain by
> >> doing this, over just using a database.
>
> > Are databases truly another language from Python, fundamentally?
>
> Yes.  A fair amount of study went into them.  Databases are about
> information that survives the over an extended period of time (months
> or years, not hours).
>
> Classic qualities for a database that don't normally apply to Python
> (all properties of a "transaction" -- bundled set of changes):
>      * Atomicity:
>         A transaction either is fully applied or not applied at all.
>      * Consistency:
>         Transactions applied to a database with invariants preserve
>         those invariants (things like balance sheets totals).
>      * Isolation:
>         Each transactions happens as if it were happening at its own
>         moment in time -- tou don't worry about other transactions
>         interleaved with your transaction.
>      * Durability:
>         Once a transaction actually makes it into the database, it stays
>         there and doesn't magically fail a long time later.
>
> -Scott David Daniels
> [EMAIL PROTECTED]

Scott,

Classical qualities for Python that don't normally apply to a database
are:
   * Encapsulation
   * Modularity

(Besides for social factors,) I make case that database language is
always better to start learning than program language.  They have no
properties of databases.

Hold that databases are slightly less sophisticated than language, and
you hold rates at which data comes from the universe.  Note,
information isn't terribly well quantified, but is empirical.  Note,
matter comes from the universe too, but information goes to heads and
we care.

I hold it's proper to distinguish, though: you're doing the usual
things to data from the real world, but it seems like things I want to
do to computer screen are hard to do to a computer screen.  I'm
sensitive to money (want>0); why doesn't it want to do computers?  I'd
rather just animate plastics.  Hook some up to it.  Build roads and
surfboards.  (No snowboards; it's water; or it's way below it.)  Plus
get a bunch from the A.C. lines.

Data always come from the universe, i.e. from matter.  Just another
way to make money with it.  Everyone can make money, what's the
problem with SQL?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frame work for simple physics web applications

2008-04-19 Thread Rick Muller
On Apr 19, 2:44 pm, globalrev <[EMAIL PROTECTED]> wrote:

>
> www.vpython.orgmight be what you are looking for.

Except, if I'm not mistaken, vpython isn't a web framework. It would
work if I wanted to write some python scripts and have other people
run them, but I want to run everything through a web page, so I don't
have to worry about installing python on everyone's computer and
distributing updates of all of my scripts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] DoIt 0.1.0 Released (build tool)

2008-04-19 Thread Eduardo Schettino
On Sun, Apr 20, 2008 at 2:04 AM, John Machin <[EMAIL PROTECTED]> wrote:
>  You may like to consider the possibility of confusion caused by the
>  similarity of some characters in some fonts (DoIt, Do1t, Dolt) ...
>  google("dictionary dolt") :-)
>  --
>  http://mail.python.org/mailman/listinfo/python-list
>

hehehehe. i feel like a DOLT

I never realized that it is confusing. I also didnt know this word
"dolt" before.
 i wont use capital letters anymore.
thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


manipulating class attributes from a decorator while the class is being defined

2008-04-19 Thread Wilbert Berendsen
Hi, is it possible to manipulate class attributes from within a decorator 
while the class is being defined?

I want to register methods with some additional values in a class attribute. 
But I can't get a decorator to change a class attribute while the class is 
still being defined. Something like:

class Parser(object):
  
  regexps = []
  def reg(regexp):
def deco(func):
  regexps.append((regexp, func))
  return func
return deco
  
  @reg(r'".*"')
  def quoted_string(self):
pass

How can I reach the class attribute `regexps' from within a decorator?

Thanks for any help,
Wilbert Berendsen

-- 
http://www.wilbertberendsen.nl/
"You must be the change you wish to see in the world."
-- Mahatma Gandhi
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham new haircut

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham biography

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham quotes

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham background

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


rock and republic victoria beckham

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham news

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham gallery

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham 2007

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


photos of victoria beckham

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


david & victoria beckham

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


david beckham and victoria beckham

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


how tall is victoria beckham

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham lyrics

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


victoria beckham boobs

2008-04-19 Thread billingspanshism
Just few link on some Movies


Movies: http://victoria-beckham.12w.net


F
R
E
E


C
E
L
E
B
R
I
T
Y


M
O
V
I
E
S
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2's complement conversion. Is this right?

2008-04-19 Thread Bob Greschke
On 2008-04-18 23:35:12 -0600, Ivan Illarionov <[EMAIL PROTECTED]> said:

> On Sat, 19 Apr 2008 04:45:54 +, Ivan Illarionov wrote:
> 
>> On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote:
>> 
>>> On 2008-04-18, Bob Greschke <[EMAIL PROTECTED]> wrote:
>>> 
 However, in playing around with your suggestion and Grant's code I've
 found that the struct stuff is WAY slower than doing something like
 this
 
 Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if
 Value
> = 0x80:
 Value -= 0x100
 
 This is almost twice as fast just sitting here grinding through a few
 hundred thousand conversions (like 3sec vs. ~5secs just counting on my
 fingers - on an old Sun...it's a bit slow).  Replacing *65536 with
 <<16 and *256 with <<8 might even be a little faster, but it's too
 close to call without really profiling it.
>>> 
>>> I didn't know speed was important.  This might be a little faster
>>> (depending on hardware):
>>> 
>>> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2])
>>> 
>>> It also makes the intention a bit more obvious (at least to me).
>>> 
>>> A decent C compiler will recognize that <<16 and <<8 are special and
>>> just move bytes around rather than actually doing shifts.  I doubt the
>>> Python compiler does optimizations like that, but shifts are still
>>> usually faster than multiplies (though, again, a good compiler will
>>> recognize that multiplying by 65536 is the same as shifting by 16 and
>>> just move bytes around).
>> 
>> So why not put it in C extension?
>> 
>> It's easier than most people think:
>> 
>> 
>> from3bytes.c
>> 
>> #include 
>> 
>> PyObject*
>> from3bytes(PyObject* self, PyObject* args) {
>> const char * s;
>> int len;
>> if (!PyArg_ParseTuple(args, "s#", &s, &len))
>> return NULL;
>> long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x80)
>> n -= 0x100;
>> return PyInt_FromLong(n);
>> }
>> 
>> static PyMethodDef functions[] = {
>> {"from3bytes",(PyCFunction)from3bytes, METH_VARARGS}, {NULL,
>> NULL, 0, NULL},
>> };
>> 
>> 
>> DL_EXPORT(void)
>> init_from3bytes(void)
>> {
>> Py_InitModule("_from3bytes", functions);
>> }
>> 
>> buildme.py
>> ==
>> import os
>> import sys
>> from distutils.core import Extension, setup
>> 
>> os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv =
>> [sys.argv[0], 'build_ext', '-i'] setup(ext_modules =
>> [Extension('_from3bytes', ['from3bytes.c'])]) 
>> 
>> 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes
>> import from3bytes' will import C-optimized function
>> 
>> Hope this helps.
> 
> Sorry,
> the right code should be:
> 
> PyObject* from3bytes(PyObject* self, PyObject* args)
> {
> const char * s;
> int len;
> if (!PyArg_ParseTuple(args, "s#", &s, &len))
> return NULL;
> long n = unsigned char)s[0])<<16) | (((unsigned char)s[1])<<8) |
> ((unsigned char)s[2]));
> if (n >= 0x80)
> n -= 0x100;
> return PyInt_FromLong(n);
> }

No thanks.  Being able to alter and install these programs on whatever 
computer they are installed on is more important than speed.  I went 
down the C-extension path years ago and it turned into a big mess.  
Everything has to run on Sun's, Mac's, Linux and Windows without any 
major hassels if they have to be changed.  I can't reley on everything 
the program needs to be rebuilt being installed beyond Python and 
Tkinter (and pySerial and PIL for a couple of programs), which they 
need to run.  So no compiling and everything is in one file, in case a 
new version has to be upgraded by a user by emailing it to them while 
they're sitting on some mountain in Tibet.  Just unzip, stick the .py 
somewhere logical, (usually) double-click, and they are off and running.

Bob


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: manipulating class attributes from a decorator while the class is being defined

2008-04-19 Thread Christian Heimes
Wilbert Berendsen schrieb:
> Hi, is it possible to manipulate class attributes from within a decorator 
> while the class is being defined?
> 
> I want to register methods with some additional values in a class attribute. 
> But I can't get a decorator to change a class attribute while the class is 
> still being defined. Something like:
> 
> class Parser(object):
>   
>   regexps = []
>   def reg(regexp):
> def deco(func):
>   regexps.append((regexp, func))
>   return func
> return deco
>   
>   @reg(r'".*"')
>   def quoted_string(self):
> pass
> 
> How can I reach the class attribute `regexps' from within a decorator?

It's really tricky . The class object doesn't exists yet. It's created
after all functions are parsed and created. You have can walk up the
stack frames but it's ugly.

Christian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: manipulating class attributes from a decorator while the class is being defined

2008-04-19 Thread Karl-Heinz Ruskowski
> How can I reach the class attribute `regexps' from within a decorator?
Now, the first way that comes to my mind is simply overloading the class and 
set your regexps variable in your new class. 

The other way is to create an object and set it more manually (obj.regexps = 
['.*']). Which for me is an ugly this to do because the first way is far more 
elegant :) 

-- 
GPG key: 0x04B3BB96


pgpqg8hSnWlWX.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: 2's complement conversion. Is this right?

2008-04-19 Thread Bob Greschke
On 2008-04-18 21:33:34 -0600, Grant Edwards <[EMAIL PROTECTED]> said:

> On 2008-04-18, Bob Greschke <[EMAIL PROTECTED]> wrote:
> 
>> I'm on a Solaris 8 with Python 2.3.4 and when crunching
>> through, literally, millions and millions of samples of
>> seismic data fingers point out the difference nicely. :) I'll
>> look into this more on some of our bigger better faster
>> machines (there is no -m option for timeit on the Sun :).  The
>> Sun is just what I develop on.  If stuff runs fast enough to
>> keep me awake on there over an ssh'ed X11 connection it should run even 
>> better on the real field equipment (Macs,
>> Linuxes, WinXPs).
> 
> If time is an issue, I might write a C program to convert the
> files from 24-bit numbers to 32-bit numbers.  Then you can use
> numpy to load huge arrays of them in a single whack.

Yes you could. :)  But this is all in real time (as in 'gotta have it 
right now' real time).  Plus we're dealing with 100's of files 
(instruments) at a time.  It'll be 1000's of instruments this summer up 
in Canada.

Here's the program having happily crunched away at nearly twice the 
speed it was the day before yesterday.

www.greschke.com/unlinked/files/pocus.png

The white dots come from the 3-byte integers and make up the green line 
which makes up one 'logical' chunk (in this case they recorded for 
60mins at a time) of a whole data file with one file per instrument.  
Generally we just take a quick look at the green lines to make sure the 
instruments were working, and pull out the bad ones so they don't get 
used again until they've been looked at.  Zooming in to the level where 
you can see the individual samples is used to (more) accurately 
determine the time when an [intentional] explosion was set off.  You 
use instruments placed near the shot holes for that.  Simple. :)

Bob



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2's complement conversion. Is this right?

2008-04-19 Thread Bob Greschke
> 
> 
> www.greschke.com/unlinked/files/pocus.png
> 
> 
> Darnit.

www.greschke.com/unlinked/images/pocus.png

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frame work for simple physics web applications

2008-04-19 Thread Stef Mientki
Rick Muller wrote:
> On Apr 19, 2:44 pm, globalrev <[EMAIL PROTECTED]> wrote:
>
>   
>> www.vpython.orgmight be what you are looking for.
>> 
>
> Except, if I'm not mistaken, vpython isn't a web framework. It would
> work if I wanted to write some python scripts and have other people
> run them, but I want to run everything through a web page, so I don't
> have to worry about installing python on everyone's computer
So what should the students use when they want to explore quantum 
computing outside the scope you're offering ?
C++, MatLab, LabView perhaps, this looks to me like an unique 
opportunity to promote Python.
>  and
> distributing updates of all of my scripts.
>   
I'm not familiar with this, but isn't it possible to run scripts from a 
website locally ?

cheers,
Stef


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for Series 40 Nokia?

2008-04-19 Thread Dotan Cohen
On 18/04/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Apr 18, 8:46 am, "Dotan Cohen" <[EMAIL PROTECTED]> wrote:
>  > I had once heard something about python running on a Series 40 Nokia,
>  > but I am unable to google anything concrete. Might it have been
>  > Jython? Is there a known implementation of Python for the series 40
>  > (which is not Symbian, by the way)? Will Jython work in such an
>  > environment?
>  >
>  > Thanks in advance.
>
> there is a comment here of using jython on a nokia S40
>  Nokia 7210 SDK for Nokia Series 40 platform.
>  http://bookshelf.sourceforge.net/en/src-build.html
>
>  So i think i will work.
>
>  I am using a S60 and works well, I have a GPS program in Python,
>  Editors, Ogg player, and other assorted items.
>
>  I myself purchased the Nokia N70 purely because of the Python ability
>  it had..

Thanks. I have tried to avoid Symbian phones as they are slow and
irresponsive to input in my experience. That said, I loved my N-Gage
and irresponsiveness really was my only complaint with the device.
Perhaps if the newer models are more responsive, then I will switch so
that I can run Python on it. Thanks.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

www.crazysupplier.com cheap nike shoes nike air jordans Manufacturer, Buyer, Supplier ...

2008-04-19 Thread ceo . ch2008
China wholesaler of cheap air jordan shoes,wholesale
jordans,wholesale
jordans from china,wholesale nike jordans (www.crazysupplier.com)
Buy new jordan 23 shoes, air jordan 23 shoes,jordan xx3,nike jordan
xxiii,new air jordan 23 shoes,AJ23,jordan 23 (www.crazysupplier.com)
cheap Air jordan xxiii,Jordan 23,cheap wholesale jordan 23,cheap buy
air jordan 23,cheap air jordan XX3,XXIII from china
(www.crazysupplier.com)
cheap wholesale jordans,china wholesalers,Jordans cheap wholesale
price,buy cheap jordans,air jordan suppliers from china
(www.crazysupplier.com)
AJ XXIII,aj23,aj xx3,Nike jordan 23,air jordan xx3,Air jordan
xxiii,air jordan 23,new jordan xxiii,cheap jordan xx3,buy from china
(www.crazysupplier.com)
Jordan shoes xxiii,air jordan shoes 23,new jordan 23,xx3,new jordan
23 shoes,Nike Air jordan 23,xx3 jordan,xx3 shoes,nike jordan xxiii
(www.crazysupplier.com)
Nike air jordan force 23,ajf23,air jordan 23 fusions,nike jordan 23
fusions,AJF xx3, Jordan XX3 fusions,air force jordan 23 xx3,xxiii
fusions,nike air jordan fusions xxiii
Mixed jordans,air jordan mix,air jordan 3 force one,ajf3,jordan 3
fusions,Air force one jordan iii fusions,Nike air jordan 3 iii X air
force one fusions, air force jordan 3 iii fusions, air jordan 4 v
fusions, AJF4,air force one jordan v 4,nike AJF4 fusions
(www.crazysupplier.com)
Nike Jordan countdown pack 10/13,Nike Jordan Countdown Pack
(14/9),Nike Air Jordan Collezione (Countdown Pack 10 / 13)

Wholesale Air Jordan 12 Fusions (www.crazysupplier.com)
china wholesaler Air Jordan 5 x AF1 Fusions Black/Red Sneaker
(www.crazysupplier.com)
wholesale Air Jordan Force 12 Fusions (www.crazysupplier.com)
Air Jordan V x Air Force 1 Fusion,air force 1 jordans
(www.crazysupplier.com)
Nike Air Jordan Force XII Fusion (www.crazysupplier.com)
Air Jordan XII x AF1 Fusion (www.crazysupplier.com)
AIR FORCE 1 AIR JORDAN V fusion (www.crazysupplier.com)
Nike Air Jordan XII Fusions (www.crazysupplier.com)
Nike Air Jordan IV Fusions,Air jordan 4 plus air force 1
(www.myshoesdepot.com)
Nike AF1 Air Jordan Fusions wholesale (www.crazysupplier.com)
Nike Air Jordan Fusions XII Mid (www.crazysupplier.com)
Men's Nike Air Jordan Fusion XII Mid (www.crazysupplier.com)
Air Jordan "Fusions": AJ XII x Air Force 1
(www.crazysupplier.com)
Sell Air Jordan 12 fusion sneakers (www.crazysupplier.com)
Air Jordan 5 (V) x Air Force 1 (One) - Fusion
(www.crazysupplier.com)
air jordan 12 air force one 1 fusion (www.crazysupplier.com)
Air Jordan fusion XII (www.crazysupplier.com)
Nike fusion shoes,air jordan 4 fusion,AJF4 fusions,Jordan 4 plus af1
fusion,nike jordan fusion
Wholesale Air jordan 4 x air force 1 fusions
(www.crazysupplier.com)
Wholesale cheap jordans and air force ones site at
(www.crazysupplier.com)
wholesale Air Jordan 12 Fusion,air jordan 5 x air force 1 Fusion
(www.crazysupplier.com)
(www.crazysupplier.com) Wholesale New Air Jordan 12 Fusion,Air
Jordan 12 X Air Force 1 Wholesale New Air Jordan 12 Fusion,Air Jordan
12 X Air Force 1
cheap Air Jordan 5 x Air Force one Fusion
(www.crazysupplier.com)
discount Air Jordan 5 and Air Force one Fusion
(www.crazysupplier.com)
Air Jordan 12 x Air Force One china online store
(www.crazysupplier.com)
(www.crazysupplier.com) Air Jordan V x Air Force 1 Fusion
Air Jordan 12 x Air Force Ones Fusion (www.crazysupplier.com)
Nike AF1 x Air Jordan 5.
Nike Air Force Ones Shoes & Air Jordan 5.
wholesale Air Jordan 5 (V) x Air Force 1 Fusion
(www.crazysupplier.com)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random.random(), random not defined!?

2008-04-19 Thread Mensanator
On Apr 19, 3:36�pm, John Machin <[EMAIL PROTECTED]> wrote:
> globalrev wrote:
> > do i need to import something to use random?
>
> No, you need to import random

But you could alsways import it as something.

>>> import random as something
>>> something.random()
0.45811606256668347
-- 
http://mail.python.org/mailman/listinfo/python-list

Bigger projects, including files?

2008-04-19 Thread globalrev
if i have a larger project and want to divide my program into several
files, how do i include these files in the mainprogram?

using import someprojectfile doesnt work because import is for site-
packages right and i dont want to put all my files
in that folder.

so how do i do it?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bigger projects, including files?

2008-04-19 Thread Martin P. Hellwig
globalrev wrote:
> if i have a larger project and want to divide my program into several
> files, how do i include these files in the mainprogram?
> 
> using import someprojectfile doesnt work because import is for site-
> packages right and i dont want to put all my files
> in that folder.
> 
> so how do i do it?
> 
You can always add the path where the other files are to sys.path
I've posted a while ago something that sort of does that for 
inter-package reference if the root is not in the sys.path
http://groups.google.com/group/comp.lang.python/browse_thread/thread/0e29ab20b4d4bc97
hth
-- 
mph
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bigger projects, including files?

2008-04-19 Thread globalrev
On 20 Apr, 02:04, "Martin P. Hellwig" <[EMAIL PROTECTED]> wrote:
> globalrev wrote:
> > if i have a larger project and want to divide my program into several
> > files, how do i include these files in the mainprogram?
>
> > using import someprojectfile doesnt work because import is for site-
> > packages right and i dont want to put all my files
> > in that folder.
>
> > so how do i do it?
>
> You can always add the path where the other files are to sys.path
> I've posted a while ago something that sort of does that for
> inter-package reference if the root is not in the 
> sys.pathhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/...
> hth
> --
> mph

thanks. i saw now myself that import works if it is in the same folder
as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2's complement conversion. Is this right?

2008-04-19 Thread George Sakkis
On Apr 18, 9:36 pm, Ross Ridge <[EMAIL PROTECTED]>
wrote:
> Ross Ridge <[EMAIL PROTECTED]> said:
>
> > If you have Python 2.5, here's a faster version:
>
> >    from struct import *
> >    unpack_i32be = Struct(">l").unpack
>
> >    def from3Bytes_ross2(s):
> >        return unpack_i32be(s + "\0")[0] >> 8
>
> Bob Greschke  <[EMAIL PROTECTED]> wrote:
>
> > That's not even intelligible.  I wanna go back to COBOL. :)
>
> It's the same as the previous version except that it "precompiles"
> the struct.unpack() format string.  It works similar to the way Python
> handles regular expressions.

I didn't know about the Struct class; pretty neat. It's amazing that
this version without Psyco is as fast Bob's version with Psyco! Adding
Psyco to it though makes it *slower*, not faster. So here's how I'd
write it (if I wanted or had to stay in pure Python):

try: import psyco
except ImportError:
from struct import Struct
unpack_i32be = Struct(">l").unpack
def from3Bytes(s):
return unpack_i32be(s + "\0")[0] >> 8
else:
def from3Bytes(s):
Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2])
if Value >= 0x80:
Value -= 0x100
return Value
psyco.bind(from3Bytes)


HTH,
George
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I just killed GIL!!!

2008-04-19 Thread sturlamolden
On Apr 19, 10:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:

> FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL
> SectionHandle method and was POSIX certified, so it's certainly
> possible.

Windows Vista Ultimate comes with Interix integrated, renamed
'Subsystem for Unix based Applications' or SUA for short. Interix is
even UNIX certified when a C compiler is installed. Windows also has a
OS/2 subsystem which has a COW fork. Yes it is possible. One may
wonder why the Win32 subsystem don't have this feature. Perhaps fork()
is unfriendly to threads, like fork on Linux used to be (or is?)
pthread unfriendly. Or perhaps M$ (MegaDollar) just did this to be
mean. I don't know. I see the lack of fork() in Win32 as one of the
major shortcomings of Windows.

Anyhow, I just downloaded the WDK which supersedes the DDK. The
examples in Nebbet's book do not build anymore, as there are invalid C
in the WDK header files. :-(







-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frame work for simple physics web applications

2008-04-19 Thread Brian Blais

On Apr 19, 2008, at Apr 19:3:55 PM, Rick Muller wrote:

Do any of the AJAX frameworks for Python compare in simplicity to
writing a simple CGI script? I've been impressed with web.py, since it
seems pretty easy to use, but I would go to the trouble of learning
one of the bigger frameworks if they would provide a more elegant
solution.



I'd highly recommend web.py.  You can even run it as a cgi script, if  
you want, but it has its own webserver.  For larger scale stuff, they  
give directions for running it behind apache or lighttpd.  It's very  
easy and flexible.


are you using matplotlib for the plots?


bb

--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais



-- 
http://mail.python.org/mailman/listinfo/python-list

Any reliable obfurscator for Python 2.5

2008-04-19 Thread Banibrata Dutta
Hi,

Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator
for Python 2.5 code.

-- 
regards,
Banibrata
http://www.linkedin.com/in/bdutta
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: User-defined Exceptions: is self.args OK?

2008-04-19 Thread Gabriel Genellina
En Thu, 17 Apr 2008 19:11:36 -0300, Petr Jakeš <[EMAIL PROTECTED]>  
escribió:

> I am trying to dig through User-defined Exceptions.  chapter 8.5 in
> http://docs.python.org/tut/node10.html
>
>
> I would like to know, if is it OK to add following line to the __init__
> method of the TransitionError class?
>
> self.args = (self.previous, self.next, self.message)

Not necesarily, but you should call the base __init__, perhaps with a  
suitable message.

Most of the time, a meaningful error message is all what I want, so I  
write:

class FooError(Exception): pass

(perhaps inheriting from ValueError or TypeError or any other more  
meaningful base error).
Then, when something wrong is detected:

 if :
 raise FooError, "some %s message" % foo

In your case, you appear to require more info stored in the exception. Try  
this (based on your code):

class TransitionError(Error): # I assume Error inherits from Exception?
 def __init__(self, previous, next, message):
 self.previous = previous
 self.next = next
 Error.__init__(self, previous, next, message)
 # perhaps: Error.__init__(self, message)
 # if message already contain references to
 # previous and next

raise TransitionError, (1, 2, "oops")

Traceback (most recent call last):
   File "", line 1, in 
__main__.TransitionError: (1, 2, 'oops')

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2's complement conversion. Is this right?

2008-04-19 Thread Ross Ridge
Ross Ridge <[EMAIL PROTECTED]> wrote:
> It's the same as the previous version except that it "precompiles"
> the struct.unpack() format string. =A0It works similar to the way Python
> handles regular expressions.

George Sakkis  <[EMAIL PROTECTED]> wrote:
>I didn't know about the Struct class; pretty neat. It's amazing that
>this version without Psyco is as fast Bob's version with Psyco!

Unfortunately, it doesn't seem to documented in the Python 2.5 manual.
The speed improvement mainly comes from avoiding the Python code in the
struct module that wraps the Struct class.  The struct module caches
already compiled format strings, but looking format strings in the cache
ends taking a fair chunk of time in my original example.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RotatingFileHandler - ShouldRollover error

2008-04-19 Thread Gabriel Genellina
En Wed, 16 Apr 2008 10:50:44 -0300, <[EMAIL PROTECTED]> escribió:

> I am using the RotatingFileHandler logger with Python 2.5 on Windows and  
> I am getting an error on the rollover.  When the log file gets close to  
> the size where it needs to rollover, I start getting the following error  
> for every log message.  Does anyone have a solution to this problem?
>
> Traceback (most recent call last):
>   File "C:\Python25\Lib\logging\handlers.py", line 73, in emit
> if self.shouldRollover(record):
>   File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover
> self.stream.seek(0, 2)  #due to non-posix-compliant Windows feature
> ValueError: I/O operation on closed file

There are some fixes in svn - you may try using the current sources from  
http://svn.python.org/projects/python/trunk/

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2's complement conversion. Is this right?

2008-04-19 Thread John Machin
Ross Ridge wrote:
> Ross Ridge <[EMAIL PROTECTED]> wrote:
>> It's the same as the previous version except that it "precompiles"
>> the struct.unpack() format string. =A0It works similar to the way Python
>> handles regular expressions.
> 
> George Sakkis  <[EMAIL PROTECTED]> wrote:
>> I didn't know about the Struct class; pretty neat. It's amazing that
>> this version without Psyco is as fast Bob's version with Psyco!
> 
> Unfortunately, it doesn't seem to documented in the Python 2.5 manual.

It seems to me that it's documented:

http://docs.python.org/lib/struct-objects.html

The struct module doc page 
(http://docs.python.org/lib/module-struct.html) provides links but no 
explicit mention of the Struct class in its text.

-- 
http://mail.python.org/mailman/listinfo/python-list


Checking if a text file is blank

2008-04-19 Thread elnoire
Greetings!

I've just started learning python, so this is probably one of those
obvious questions newbies ask.

Is there any way in python to check if a text file is blank?

What I've tried to do so far is:

f = file("friends.txt", "w")
if f.read() is True:
"""do stuff"""
else:
"""do other stuff"""
f.close()

What I *mean* to do in the second line is to check if the text file is
not-blank. But apparently that's not the way to do it.

Could someone set me straight please?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: manipulating class attributes from a decorator while the class is being defined

2008-04-19 Thread Arnaud Delobelle
On Apr 19, 10:19 pm, Wilbert Berendsen <[EMAIL PROTECTED]> wrote:
> Hi, is it possible to manipulate class attributes from within a decorator
> while the class is being defined?
>
> I want to register methods with some additional values in a class attribute.
> But I can't get a decorator to change a class attribute while the class is
> still being defined. Something like:
>
> class Parser(object):
>
>   regexps = []
>   def reg(regexp):
>     def deco(func):
>       regexps.append((regexp, func))
>       return func
>     return deco
>
>   @reg(r'".*"')
>   def quoted_string(self):
>     pass
>
> How can I reach the class attribute `regexps' from within a decorator?

In this particular example, it is enought to change the line

   def reg(regexp):

to:

   def reg(regexp, regexps=regexps):

So that 'regexps' inside reg() will point to the same object as
'regexps' outside reg().

Of course it wouldn't work well with inheritance, but it seems to me
that you don't want to subclass 'Parser' anyway.  If you did, you
could instead have something like this:

class Ruleset(list):

def add(self, regexp):
def decorator(func):
self.append((regexp, func))
return func
return decorator


class Parser(object):

rules = Ruleset()

@rules.add(r'".*"')
def quoted_string(self):
   pass


Or, yet another solution is to change the metaclass of 'Parser' so
that it populates the class's rules by scanning its attributes.

HTH

--
Arnaud

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Checking if a text file is blank

2008-04-19 Thread David
>
>  Is there any way in python to check if a text file is blank?
>
>  What I've tried to do so far is:
>
> f = file("friends.txt", "w")
> if f.read() is True:
> """do stuff"""
> else:
> """do other stuff"""
> f.close()
>
>  What I *mean* to do in the second line is to check if the text file is
>  not-blank. But apparently that's not the way to do it.
>
>  Could someone set me straight please?

You're opening your file in write mode, so it gets truncated. Add "+"
to your open mode (r+ or w+) if you want to read and write.

Here is the file docstring:

file(name[, mode[, buffering]]) -> file object

Open a file.  The mode can be 'r', 'w' or 'a' for reading (default),
writing or appending.  The file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing.  Add a 'b' to the mode for binary files.
Add a '+' to the mode to allow simultaneous reading and writing.
If the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size.
Add a 'U' to mode to open the file for input with universal newline
support.  Any line ending in the input file will be seen as a '\n'
in Python.  Also, a file so opened gains the attribute 'newlines';
the value for this attribute is one of None (no newline read yet),
'\r', '\n', '\r\n' or a tuple containing all the newline types seen.

'U' cannot be combined with 'w' or '+' mode.

Note:  open() is an alias for file().

Also, comparison of a value with True is redundant in an if statement.
Rather use 'if f.read():'

David.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Checking if a text file is blank

2008-04-19 Thread Dan Bishop
On Apr 20, 1:04 am, [EMAIL PROTECTED] wrote:
> Greetings!
>
> I've just started learning python, so this is probably one of those
> obvious questions newbies ask.
>
> Is there any way in python to check if a text file is blank?
>
> What I've tried to do so far is:
>
> f = file("friends.txt", "w")
> if f.read() is True:
> """do stuff"""
> else:
> """do other stuff"""
> f.close()
>
> What I *mean* to do in the second line is to check if the text file is
> not-blank. But apparently that's not the way to do it.
>
> Could someone set me straight please?

The flaw in your code is that "f.read() is True" doesn't do what you
think it does.

(1) The "is" operator is a test for object IDENTITY.  Two objects can
be equal but distinct

>>> list1 = list2 = [1, 2, 3]
>>> list1 is list2
True
>>> list1[-1] = 4
>>> list2
[1, 2, 4]

>>> list1 = [1, 2, 3]
>>> list2 = [1, 2, 3]
>>> list1 is list2
False
>>> list1[-1] = 4
>>> list2
[1, 2, 3]

(2) Even if you used "f.read() == True", it still wouldn't work in
Python.  Values can be true or false (in the context of an if or while
statement) without being equal to True or False.

Values that are equal to True:
True, 1, 1.0, (1+0j), decimal.Decimal(1)

Values that are true but not equal to True:
"spam", "1", (1,), [1], set([1]), {1: 2}, etc.

Values that are equal to False:
False, 0, 0.0, 0j, decimal.Decimal(0)

Values that are false but not equal to False:
"", (), [], set()

And even if you are sure that you're only dealing with values of 0 or
1, it's unnecessary to write "if x == True:".  It's redundant, just
like "if (x == True) == True:" or "if ((x == True) == True) ==
True:".  Just write "if x:".  Or, in this specific case, "if
f.read():".

(3) While not affecting your program's correctness, it's rather
inefficient to read a gigabytes-long file into memory just to check
whether it's empty.  Read just the first line or the first character.
Or use os.stat .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Checking if a text file is blank

2008-04-19 Thread Andrew Lee
[EMAIL PROTECTED] wrote:
> Greetings!
> 
> I've just started learning python, so this is probably one of those
> obvious questions newbies ask.
> 
> Is there any way in python to check if a text file is blank?
> 
> What I've tried to do so far is:
> 
> f = file("friends.txt", "w")
>   if f.read() is True:
>   """do stuff"""
>   else:
>   """do other stuff"""
>   f.close()
> 
> What I *mean* to do in the second line is to check if the text file is
> not-blank. But apparently that's not the way to do it.
> 
> Could someone set me straight please?


Along with the other posts ... consider using the lstat command to get 
information about the file.


import os
print os.lstat("friends.txt")[6]


gives the size in bytes of friends.txt or throws an OSError if 
friends.txt does not exist.

lstat is portable, it defaults to stat on Windows.
-- 
http://mail.python.org/mailman/listinfo/python-list