ANN: CherryPy 3.0.2

2007-08-13 Thread Christian Wyglendowski
CherryPy 3.0.2 was released last week.  It incorporates a few bug
fixes that were discovered since 3.0.1.

The release can be downloaded at the following URL and is also
available on PyPI:

http://cherrypy.org/wiki/CherryPyDownload

See the list of changes here:

http://cherrypy.org/log/branches/cherrypy-3.0.x?action=stop_on_copyrev=1681stop_rev=1635mode=stop_on_copy

Thanks to everyone who submitted the tickets detailing these issues
and for those who contributed code to fix the problems.

Christian Wyglendowski
CherryPy Team
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Python-URL! - weekly Python news and links (Aug 13)

2007-08-13 Thread Gabriel Genellina
QOTW:  The first time you see twenty tons of machinery move unexpectedly
because you inadvertently changed one bit in memory, you become very 
conservative about your software platform. - Walt Leipold

Making use of the available wrappers for current Tk libraries such as
BWidgets, Tile, Tablelist, TkTreeCtrl, and so on allows you to make UI's
every bit as polished as what comes with wxPython ... - Kevin Walzer


Looking for the best programs written entirely in
Python:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/9fea4deb4c70fef1/

`a==b` vs. `a is b` revisited, with some advice on
when to use one test or another:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4a087153826f1f2b/

Pros and cons of desktop web applications vs. native
GUIs: 

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1f823a9c8a41c8bb/50c2f4bc10621f9a?rnum=1#50c2f4bc10621f9a
started as

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1f823a9c8a41c8bb

When is OK to use __del__?

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b09e02b7c67c8a3b/

Leipzig is the site of the second Python im deutschsprachigen
Raum 2007.  Among the presentations likely to reward both novices
and experienced Pythoneers are ones on Web applications, use of
Python in science, developer tools in Python, and Python for
simulations in aerospace.   
http://www.python-academy.de/workshop/index.html

Somewhat related to previous topic: how to ensure a
generator object is closed in Python 2.4?

http://groups.google.com/group/comp.lang.python/browse_thread/thread/3f789096bded17e7/

Discussing Python threading model, the GIL, Stackless,
and possible future alternatives:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/bbeb8b826af93ae/

Use spaces for space and use tabs for tables: A
Python song, by James Stroud
http://groups.google.com/group/comp.lang.python/msg/9743131cf0c426eb



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish the efforts of Python enthusiats:
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the Planet sites:
http://planetpython.org
http://planet.python.org

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Python411 indexes podcasts ... to help people learn Python ...
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.

Hamburg Pythoneers Monthly Meeting: August, 15

2007-08-13 Thread Bastian Bowe
+ Hamburg Python User Group April Meeting +

I am pleased to announce our next user group meeting:

Wednesday, August 15, 2007 at 7:30pm (NOT 7:00pm!)

Location: DDD Design GmbH, Jarrestrasse 46, 22303 Hamburg.

The topic WSGI - Web Server Gateway Interface is presented by Gerhard
and Bastian.

If you're interested in learning more, please visit our Google Group: 
http://groups.google.com/group/hamburg-pythoneers

Bastian
-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Python 3000 Sprint @ Google

2007-08-13 Thread Guido van Rossum
It's official! The second annual Python Sprint @ Google is happening
again: August 22-25 (Wed-Sat).  We're sprinting at two locations, this
time Google headquarters in Mountain View and the Google office in
Chicago (thanks to Brian Fitzpatrick). We'll connect the two sprints
with full-screen videoconferencing. The event is *free* and includes
Google's *free gourmet food*.

Anyone with a reasonable Python experience is invited to attend. The
primary goal is to work on Python 3000, to polish off the first alpha
release; other ideas are welcome too. Experienced Python core
developers will be available for mentoring. (The goal is not to learn
Python; it is to learn *contributing* to Python.)

For more information and to sign up, please see the wiki page on python.org:
http://wiki.python.org/moin/GoogleSprint

Sign-up via the wiki page is strongly recommended to avoid lines
getting badges. Please read the whole wiki page to make sure you're
prepared.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Ligmail bug?

2007-08-13 Thread Gabriel Genellina
En Sun, 12 Aug 2007 22:14:08 -0300, Ed Leafe [EMAIL PROTECTED] escribi�:

 On Aug 12, 2007, at 7:06 AM, Steve Holden wrote:

 [Please reply via the list when a response is made via the list.

   The default behavior for this list should be to reply to the list,
 as you have pointed out. Yet for some unfathomable reason, the
 keepers of the list have set it up to default to reply to the
 original sender. This is nothing short of stupid, and I cast my vote
 (if I even have one) for changing this default to a more intelligent
 one, if for no other reason than to not have to constantly read
 comments like this chiding someone for acting in a predictable fashion.

Please read this  
URL:http://woozle.org/~neale/papers/reply-to-still-harmful.html

-- 
Gabriel Genellina

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

Re: Querying Graphics Card Name

2007-08-13 Thread Benjamin Goldenberg
On Aug 12, 2:18 pm, Jorgen Grahn [EMAIL PROTECTED]
wrote:
 On Thu, 09 Aug 2007 21:58:54 -, Benjamin Goldenberg [EMAIL PROTECTED] 
 wrote:
  On Aug 9, 3:26 pm, Bjoern Schliessmann usenet-
  [EMAIL PROTECTED] wrote:
  Benjamin Goldenberg wrote:
   I would like to find out the name of the graphics card of the
   machine my program is running on. I have looked into the pyopengl
   module, and using them to query the card, but it seems like there
   ought to be a simpler way to find this out without setting up a
   glcontext. Does anyone have any ideas?

  You could execute glxinfo and look for the renderer string. If
  that's sharp enough for your purpose. Another option is lspci.

  I should have clarified. I would like a cross platform implementation,
  Windows and *nix. It doesn't seem as if glxinfo is available under
  Windows, at least not without installing X11 under cygwin. If
  necessary, I can write the *nix and Windows queries separately.

 Yeah, but ...
 - what if there isn't one?
 - what if there are several?
 - what if there *is* one, but your user is sitting by a remote machine,
   not using the card at all?

 Your method will, no matter how you choose, fail sooner or later,
 so you'd better plan for that.

 What is your reason to do this, by the way?  Remember what Homer
 Simpson said: if something appears to be hard, it is simply not worth
 doing. And I mean that semi-seriously.

These are for some internal automation scripts for the company I work
for. We do development for specific graphics cards, all of which are
OpenGL 2.0 compatible. In order to automate aspects of our building
and testing systems, we need to know which graphics card the software
is being built on. Hopefully, that makes some sense.

-Benjamin

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


Re: Complexity of methods etc

2007-08-13 Thread Paddy
On Aug 13, 1:04 am, Nathan Harmston [EMAIL PROTECTED]
wrote:
 Hi,

 I was wondering if anyone knew of any resources, where I might be able
 to find information about the complexity of certain python functions
 or little tips on how to reduce complexity. I mean like the .join(),
 kind of thing?

 I want to see if there are any improvements I can add to my coding in
 order to reduce  time/space usage/

 Many Thanks in advance

 Nathan

There is this collection:
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
Although I don't think algorithm complexity is given, it is telling
you how to select the most efficient way of doing things in a number
of examples.

- Paddy.

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


Re: Pausing and Unpausing Threads

2007-08-13 Thread Gabriel Genellina
En Sun, 12 Aug 2007 21:45:47 -0300, Aaron J. M. [EMAIL PROTECTED]  
escribi�:

 Uhg, I thought of something I didn't consider before: how to cleanly
 end the Server/DirectedControl(l)er process.

Use the same Queue; put a special kind of Action, or just a None object,  
to tell the thread that there are no more things to process.
 From the main thread, you can join() the others, waiting for them to  
finish.

-- 
Gabriel Genellina

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

Re: Colored text

2007-08-13 Thread Rohan
On Aug 12, 10:01 pm, ianaré [EMAIL PROTECTED] wrote:
 On Aug 12, 10:05 pm, Rohan [EMAIL PROTECTED] wrote:

  Hello,
  Can some one tell me how do I get colored text. Say when I want to
  write something in a text file , how do I get it colored.

 Plain text files don't have color. You could output in html ...

Oh ok what about a csv file, I know its also a text file but I want
the color to be say blue in an excel sheet.

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

Re: Colored text

2007-08-13 Thread Michael Bentley

On Aug 12, 2007, at 7:05 PM, Rohan wrote:
 Can some one tell me how do I get colored text. Say when I want to
 write something in a text file , how do I get it colored.

You can use ANSI escape codes -- http://en.wikipedia.org/wiki/ 
ANSI_escape_code:

colorCodes = [
 \033[0mAll attributes off\033[0m,
 \033[1mBold\033[0m,
 \033[4mUnderline\033[0m,
 \033[5mBlink\033[0m,
 \033[8mHide\033[0m,
 \033[30mBlack\033[0m,
 \033[31mRed\033[0m,
 \033[32mGreen\033[0m,
 \033[33mYellow\033[0m,
 \033[34mBlue\033[0m,
 \033[35mMagenta\033[0m,
 \033[36mCyan\033[0m,
 \033[37mWhite\033[0m,
 \033[40m\033[37mBlack Background\033[0m,
 \033[41mRed Background\033[0m,
 \033[42mGreen Background\033[0m,
 \033[43mYellow Background\033[0m,
 \033[44mBlue Background\033[0m,
 \033[45mMagenta Background\033[0m,
 \033[46mCyan Background\033[0m,
 \033[47mWhite Background\033[0m
]

for i in colorCodes:
 print i

hth,
Michael
---
I would rather use Java than Perl. And I'd rather be eaten by a  
crocodile than use Java. — Trouser


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


Re: decorators - more than just syntactic sugar

2007-08-13 Thread Michele Simionato
On Aug 11, 8:30 pm, Helmut Jarausch [EMAIL PROTECTED] wrote:
 Hi,

 are decorators more than just syntactic sugar in python 2.x and what
 about python 3k ?

Well, I argued may times that syntactic sugar is important (all Turing
complete languages differs by syntactic sugar only) and having or not
having
a given syntactic sugar makes a difference between writing and not
writing
a given program. Having decorators in core Python makes us think
differently.
Have a look at David Mertz article

http://www.ibm.com/developerworks/linux/library/l-cpdecor.html

   Michele Simionato

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


Re: decorators - more than just syntactic sugar

2007-08-13 Thread Kay Schluehr
On Aug 11, 8:30 pm, Helmut Jarausch [EMAIL PROTECTED] wrote:

 How can I find out the predefined decorators?

I dare to say that's not easy. Since decorators are just(?)
syntactical sugar they don't obtain a particular semantics expressed
by distinctive declarative elements. Unlike generators which can be
identified looking for a yield expression a decorator can be
identified syntactically just when it is used. However this might be
sufficient, depending on your intention?

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


Re: Colored text

2007-08-13 Thread ianaré
On Aug 13, 1:50 am, Rohan [EMAIL PROTECTED] wrote:
 On Aug 12, 10:01 pm, ianaré [EMAIL PROTECTED] wrote:

  On Aug 12, 10:05 pm, Rohan [EMAIL PROTECTED] wrote:

   Hello,
   Can some one tell me how do I get colored text. Say when I want to
   write something in a text file , how do I get it colored.

  Plain text files don't have color. You could output in html ...

 Oh ok what about a csv file, I know its also a text file but I want
 the color to be say blue in an excel sheet.

CSV is also pretty much plain text. No support for formatting.

You will need to write xls files. Personaly, I avoid proprietary file
formats like the plague, but this may be what you're looking for:

http://www.answermysearches.com/index.php/generate-an-excel-formatted-file-right-in-python/122/

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

Re: is there anybody using __del__ correctly??

2007-08-13 Thread Michele Simionato
On Aug 12, 9:14 pm, Steven Bethard [EMAIL PROTECTED] wrote:
 Michele Simionato wrote:
  On Aug 10, 7:09 pm, Steven Bethard [EMAIL PROTECTED] wrote:
  There were also a few recipes posted during this discussion that wrap
  weakrefs up a bit nicer so it's easier to use them in place of __del__:

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/519635

  I knew about your recipe and I thought it was clever, *very*
  clever. I have been thinking about it a bit more today and
  here is an alternative, which does not require metaclasses,
  does not require descriptors, and does not require the user to
  declare the attributes she will use in the __finalize__ method.
  Warning: it is no more tested than the test case in your recipe:

  import weakref

  _get = object.__getattribute__
  _set = object.__setattr__
  _del = object.__delattr__

  def getinnerobj(self):
  return _get(self, '*innerobj*')

  class Impostor(object):
  It tries very hard to impersonate the inner object
  def __init__(self, obj):
  _set(self, '*innerobj*', obj)
  def __getattribute__(self, name):
  return getattr(getinnerobj(self), name)
  def __setattr__(self, name, value):
  _set(getinnerobj(self), name, value)
  def __delattr__(self, name):
  _del(getinnerobj(self), name)

  _refset = set()

  class Finalized(object):
  def __new__(cls, *args, **kw):
  self = super(Finalized, cls).__new__(cls, *args, **kw)
  self.__init__(*args, **kw)
  def finalize(ref, refset=_refset):
  refset.remove(ref)
  cls.__finalize__(self)
  fake = Impostor(self)
  _refset.add(weakref.ref(fake, finalize))
  return fake
  def __finalize__(self):
  pass

 The problem here is that __getattribute__ doesn't work for things like
 __getitem__.

Yeah, it is the old issue of special methods being special, i.e.
len(x)
is not exactly x.__len__(). I am not sure if this can be changed in
Py3k,
it is certainly annoying in some (rare) circumstances, as
here.
One workaround is to add all special methods to the Impostor
class:

SPECIALMETHODS = ['__%s__' % name for name in
'''
abs add and call concat contains delitem delslice div eq floordiv ge
getitem
getslice gt iadd iand iconcat idiv ifloordiv ilshift imod imul index
inv invert
ior ipow irepeat irshift isub iter itruediv ixor le len lshift lt mod
mul ne neg
not or pos pow repeat repr rshift setitem setslice str sub truediv
xor
'''.split()]

def add_special_method(cls,
name): def
meth(self,
*args):
return getattr(self, name)
(*args)
meth.__name__ =
name
setattr(cls, name,
meth)
for name in
SPECIALMETHODS:
add_special_method(Impostor,
name)

In this way the Impostor can emulate even the special methods. Here is
an
example:

 class C(object):
...
pass
...
 c=Impostor(C())
 print c
__main__.C object at
0x102a390

Notice that the impostor is calling the __str__ method of C, so it
really
looks like a C object.
Moreover

 c.__class__
class
'__main__.C'

and

 isinstance(c, C)
True

so the Impostor is doing a damn pretty good job of imposture for C
objects.
Of course it does what it can, and it cannot impersonate C objects
completely:
 type(c)
class
'__main__.Impostor'

so code using checks like ``type(c) is C`` would break and the
approach here
cannot be considered more than a hack. Still a cool hack, I would
say ;)

Michele Simionato

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


Re: which IDE is highly recommended in Windows OS

2007-08-13 Thread ychjiang
On 8 13 ,   10 09 , Ge Chunyuan [EMAIL PROTECTED] wrote:
 hi Group:

 I am a new comer for Python, I wonder which IDE is recommended in
 Windows OS.
 Can anyone give some suggestion.

 Thanks indeed
 Ge Chunyuan

javaeclipse  pydev eclipse   

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


Re: Module imports during object instantiation

2007-08-13 Thread Bruno Desthuilliers
Ritesh Raj Sarraf a écrit :
 Hi,
 
 I've been very confused about why this doesn't work. I mean I don't see any
 reason why this has been made not to work.
 
 class Log:
 
 def __init__(self, verbose, lock = None):
 
 if verbose is True:

Don't use an identity test here. There are quite a lot of values that 
eval to either True or False in a boolean context without being the True 
or False objects.

 self.VERBOSE = True
 else: self.VERBOSE = False

Also, this test is rather dumb - in fact you just don't need any test:

   self.VERBOSE = bool(verbose)

 
 if lock is None or lock != 1:
 self.DispLock = False
 else:
 self.DispLock = threading.Lock()
 self.lock = True
 
 if os.name == 'posix':
self.platform = 'posix'
self.color = get_colors()
 
 elif os.name in ['nt', 'dos']:
 self.platform = 'microsoft'
 
 try:
 import SomeModule
 except ImportError:
 self.Set_Flag = None
 
 if self.Set_Flag is not None:
 self.color = SomeModule.get_colors_windows()
 
 else:
 self.platform = None
 self.color = None
 
 When I create an object the import part never gets executed. Is there a
 reason behind it ?

what does print os.name yields ?

 I mean I'd like to keep my class as independent as I want. So that when
 later I need to use it somewhere else, I don't need to know if it depends
 on any modules.
 

Then pass the module to the initializer. Python's modules are objects...

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


Re: Module imports during object instantiation

2007-08-13 Thread Bruno Desthuilliers
Ritesh Raj Sarraf a écrit :
 On Aug 11, 3:17 am, James Stroud [EMAIL PROTECTED] wrote:
 You do realize your import statement will only be called for nt and dos
 systems don't you?

 
 Yes. I would like to load a Windows Python Module (which is, say a
 specific implementation for Windows only) in such a condition where I
 find that the platform is Dos/NT.
 
 Loading it globally doesn't make sense because when from the same
 class an object is created on a non-windows platfom, it would be
 waste. It would either ImportError or else just load the module and
 never use it.
 
 As per my understanding __init__ is executed only once during object
 creation. For such situations (that I've explained above), I think
 __init__() is the correct place to put imports.


Nope.

The initializer will be called *each time* you instanciate the class. 
And nothing prevents client code from calling it explicitelly as many 
times as it wants  - ok, this would be rather strange, but this is still 
technically possible. What I mean that you have no assurance about the 
number of times an initializer will be called.


wrt/ your problem, remember that top-level code is executed when the 
module is loaded (either as a main program or as an imported module). 
The canonical solution to os-specific imports is to handle them at the 
top-level:

if os.name == 'posix:
   from some_posix_module import get_colors
elif os.name in ['nt', 'dos']:
   from some_nt_module import get_windows_color as get_colors
else:
   get_colors = lambda: None # or any other sensible default value...

class SomeClass(object):
   def __init__(self, *args, **kw):
 self.colors = get_colors()
-- 
http://mail.python.org/mailman/listinfo/python-list


Car Air Conditioners

2007-08-13 Thread Lepi Duja
All the informations about car air conditioners can be found on this
website...

http://car-air-conditioning.blogspot.com/

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


Re: which IDE is highly recommended in Windows OS

2007-08-13 Thread Ge Chunyuan
On Aug 13, 10:24 am, _spitFIRE [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Ge Chunyuan wrote:
  hi Group:

  I am a new comer for Python, I wonder which IDE is recommended in
  Windows OS.
  Can anyone give some suggestion.

  Thanks indeed
  Ge Chunyuan

 - - Stani's Python Editor
 (http://www.softpedia.com/get/Programming/Coding-languages-Compilers/S...)
 - - Black Adder (http://www.thekompany.com/products/blackadder/)
 - - Zeus (http://www.zeusedit.com/python.html)
 - - PyScripter (http://mmm-experts.com/Products.aspx?ProductId=4)
 - - ActivePython (http://www.activestate.com/)
 - - IDLE (http://www.python.org/idle/doc/idle2.html)

 and depending on how you define IDEs, you can also decide whether or not to
 include, the following
 - - emacs
 - - vim
 - - scite
 ...

 - --
 _ _ _]{5pitph!r3}[_ _ _
 __
 I'm smart enough to know that I'm dumb.
   - Richard P Feynman
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

 iD8DBQFGv8DSA0th8WKBUJMRAqGcAJ9hhMp3tyS7XmBZT2+fol/A69j4jwCfXNya
 xQTmmDlDF5BAfiWkrSW3TuQ=
 =902n
 -END PGP SIGNATURE-

thanks buddy, I am now using ActivePython, actually it is beyond my
expectation:)

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


verify whether str is still callable in Python 2.5.1

2007-08-13 Thread Ge Chunyuan
hi Group:

Once use ActivePython latest version for Python 2.5.1.
I happened to find function str is not callable, but it is available
for Python 2.5.
Can anybody give some comments about it?
Any response is highly appreciated.



Thanks
Ge Chunyuan

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


Re: verify whether str is still callable in Python 2.5.1

2007-08-13 Thread Peter Otten
Ge Chunyuan wrote:

 Once use ActivePython latest version for Python 2.5.1.
 I happened to find function str is not callable, but it is available
 for Python 2.5.

If it's not callable it's not the str() function, but something else with a
badly chosen variable name.

 callable(str)
True
 str = yadda
 callable(str)
False

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


Re: verify whether str is still callable in Python 2.5.1

2007-08-13 Thread Ge Chunyuan
On Aug 13, 4:48 pm, Peter Otten [EMAIL PROTECTED] wrote:
 Ge Chunyuan wrote:
  Once use ActivePython latest version for Python 2.5.1.
  I happened to find function str is not callable, but it is available
  for Python 2.5.

 If it's not callable it's not the str() function, but something else with a
 badly chosen variable name.

  callable(str)
 True
  str = yadda
  callable(str)

 False

 Peter

oh, please forget my silly question.
you are absolutely right.

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


Re: verify whether str is still callable in Python 2.5.1

2007-08-13 Thread Lawrence Oluyede
Ge Chunyuan [EMAIL PROTECTED] wrote:
 Once use ActivePython latest version for Python 2.5.1.
 I happened to find function str is not callable, but it is available
 for Python 2.5.
 Can anybody give some comments about it?

I don't really understand what your asking. str is a callable, it has
always been AFAIK, since it's a type constructor, like int()

In [1]: callable(str)
Out[1]: True

In [2]: str()
Out[2]: ''


-- 
Lawrence, oluyede.org - neropercaso.it
It is difficult to get a man to understand 
something when his salary depends on not
understanding it - Upton Sinclair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx.ListBox drag and drop

2007-08-13 Thread 7stud
On Aug 12, 11:06 pm, ianaré [EMAIL PROTECTED] wrote:
 Hey all,

 I see plenty of drag and drop examples but they are all for
 wx.ListCtrl. Anyone know of examples or tutorials for wx.ListBox?
 Specifically, I would like to be able to drag a selection from one
 ListBox to another.

 Thanks in advance,

 - ianaré

See if this helps:

-
import wx

class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, List Boxes)
panel = wx.Panel(self, -1)

choices1 = [red, green, blue]
choices2 = [10, 20, 30]

self.lb1 = wx.ListBox(panel, -1, (10, 10),
  (100, 200), choices1, wx.LB_SINGLE)
self.lb1.Bind(wx.EVT_LISTBOX, self.on_select)


lb2 = wx.ListBox(panel, -1, (120, 10),
  (100, 200), choices2, wx.LB_SINGLE)
target = MyTextTarget(lb2)  #MyTextTarget defined below
lb2.SetDropTarget(target)

def on_select(self, event):
selection = self.lb1.GetSelection()

text = self.lb1.GetStringSelection()
text_obj = wx.TextDataObject(text)

source = wx.DropSource(self.lb1)
source.SetData(text_obj)

drop_result = source.DoDragDrop(wx.Drag_DefaultMove)
if drop_result == wx.DragMove:  #the selection was moved-not
copied
self.lb1.Delete(selection)


class MyTextTarget(wx.TextDropTarget):
def __init__(self, target_widget):
wx.TextDropTarget.__init__(self)
self.target_widget = target_widget

self.text_obj = wx.TextDataObject()
self.SetDataObject(self.text_obj)

def OnData(self, x, y, default):  #called automatically on drop
self.GetData()
text = self.text_obj.GetText()

end_of_list = self.target_widget.GetCount()
self.target_widget.InsertItems([text], end_of_list)

return default


app = wx.PySimpleApp(redirect=False)

win = MyFrame()
win.Show()

app.MainLoop()
-

The EVT_LISTBOX appears to be slightly broken on a mac.  It doesn't
fire if you click on a selection that is already selected.

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


Adventure-Engines in Python

2007-08-13 Thread Wildemar Wildenburger
Are there any?

I've set out to make an adventure game and now I'm trying to find a set 
of python-modules to help me do that. I know of the usual non-python 
suspects (AGAST, AGS, Wintermute, ...) and while I they are really good, 
I'd like one that is cross platform.

I've found pyScumm and pyAdv but both don't seem to be ready for use 
yet. So are there any usable engines written in python?

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


Re: retrieving ATOM/FSS feeds

2007-08-13 Thread Lawrence Oluyede
_spitFIRE [EMAIL PROTECTED] wrote:
   I'm using feedparser library to parser ATOM/RSS feeds. However, I don't
 get the entire post! but only summaries! How do I retrieve the entire feed?
 I believe that the parser library should have support for doing that or the
 specification should detail how it can be done? Or should I simply get the
 feed link and do HTML scraping?

If the content producer doesn't provide the full article via RSS/ATOM
there's no way you can get it from there. Search for full content feeds
if any, otherwise get the article URL and feed it to BeautifulSoup to
scrape the content.

-- 
Lawrence, oluyede.org - neropercaso.it
It is difficult to get a man to understand 
something when his salary depends on not
understanding it - Upton Sinclair
-- 
http://mail.python.org/mailman/listinfo/python-list


Eclipse/PyDev question

2007-08-13 Thread king kikapu
Hi,

i am using Eclipse (Platform Runtime binary) with PyDev and i was
wondering if someone can help me with this:

1. I set breakpoints to a .py file and i have told Eclipse to open the
Debug perspective when it sees that some .py file(s) of my project
indeed contains breakpoints. So, i press F9,  Eclipse starts, Debug
perspective opens and i can use the debugger just fine. But when the
app terminates, how can i tell Eclipse to switch automatically to the
PyDev perspective and not remain in the Debug one ?

2. Let's say we have a project that consists of some .py files. I want
to press F9 when the editor displays anyone of these files but make
Eclipse to run the whole project (that has another .py as default)
and not the script that i am currently working on, is that possible ??


Thanks a lot for any help

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


check if var is dict

2007-08-13 Thread Astan Chee
Hi,
I have a variable, I want to check if it is a dictionary or a string.
Is there any better way to do this than I've done. How I did it is by 
doing a .items() and catching a AttributeError that it raises if its not 
a dictionary.
How do i properly do it?
Thanks
Astan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complexity of methods etc

2007-08-13 Thread [EMAIL PROTECTED]
On Aug 13, 1:04 am, Nathan Harmston [EMAIL PROTECTED]
wrote:
 Hi,

 I was wondering if anyone knew of any resources, where I might be able
 to find information about the complexity of certain python functions
 or little tips on how to reduce complexity. I mean like the .join(),
 kind of thing?

 I want to see if there are any improvements I can add to my coding in
 order to reduce  time/space usage/

 Many Thanks in advance

 Nathan

I found the two Python Speed articles useful for demonstrating new
ways to optimise code.  Each is full of little tricks and tips on
efficent ways of doing things.


http://wiki.python.org/moin/PythonSpeed
http://wiki.python.org/moin/PythonSpeed/PerformanceTips

Dan

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


Re: retrieving ATOM/FSS feeds

2007-08-13 Thread _spitFIRE
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lawrence Oluyede wrote:
 If the content producer doesn't provide the full article via RSS/ATOM
 there's no way you can get it from there. Search for full content feeds
 if any, otherwise get the article URL and feed it to BeautifulSoup to
 scrape the content.
 

For the same feed (where the content producer doesn't provide the full
article!) I was able to see the complete post in other RSS aggregators (like
Blam). I wanted to know how they were able to collect the feed!

I knew for sure that you can't do screen scraping separately for each and
every blog and that there has be a standard way or atleast that blogs
maintain a standard template for rendering posts. I mean if each of the site
only offered partial content and the rest had to be scraped from the page,
and the page maintained a non-standard structure which is more likely, then
it would become impossible IMHO for any aggregator to aggregate feeds!

I shall for now try with BeautifulSoup, though I'm still doubtful about it.

- --
_ _ _]{5pitph!r3}[_ _ _
__
“I'm smart enough to know that I'm dumb.”
  - Richard P Feynman
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGwC1SA0th8WKBUJMRAs4eAJ0bLJVzEZls1JtE6e8MUrqdapXGPwCfVO02
yYzezvhJFY1SDHUGxrJdR5M=
=rfLo
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list

negative polar axis

2007-08-13 Thread yadin
hi!
how can i do polar plot in python with negative axes
that is the value of the magnitude is negative

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


Re: Adventure-Engines in Python

2007-08-13 Thread Richard Jones
Wildemar Wildenburger wrote:
 Are there any?

An adventure game was written for one of the PyWeek challenges:

http://www.pyweek.org/e/aerunthar/

You might be able to use that as a starting point.



Richard

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


Re: retrieving ATOM/FSS feeds

2007-08-13 Thread Lawrence Oluyede
_spitFIRE [EMAIL PROTECTED] wrote:
 For the same feed (where the content producer doesn't provide the full
 article!) I was able to see the complete post in other RSS aggregators (like
 Blam). I wanted to know how they were able to collect the feed!

Perhaps in the feed itself there's the link for the full content feed.

-- 
Lawrence, oluyede.org - neropercaso.it
It is difficult to get a man to understand 
something when his salary depends on not
understanding it - Upton Sinclair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: check if var is dict

2007-08-13 Thread Lawrence Oluyede
Astan Chee [EMAIL PROTECTED] wrote:
 I have a variable, I want to check if it is a dictionary or a string.
 Is there any better way to do this than I've done. How I did it is by
 doing a .items() and catching a AttributeError that it raises if its not
 a dictionary.
 How do i properly do it?

One way is:

In [6]: isinstance(d, dict)
Out[6]: True

In [7]: isinstance(ciao, basestring)
Out[7]: True

This way you won't catch custom classes implementing dict or basestring
protocols. In order to do that you can check if it implements the
right methods or treat the object as a dict or a string. It depends on
what you're trying to achieve.

-- 
Lawrence, oluyede.org - neropercaso.it
It is difficult to get a man to understand 
something when his salary depends on not
understanding it - Upton Sinclair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse/PyDev question

2007-08-13 Thread Fabio Zadrozny
On 8/13/07, king kikapu [EMAIL PROTECTED] wrote:

 Hi,

 i am using Eclipse (Platform Runtime binary) with PyDev and i was
 wondering if someone can help me with this:

 1. I set breakpoints to a .py file and i have told Eclipse to open the
 Debug perspective when it sees that some .py file(s) of my project
 indeed contains breakpoints. So, i press F9,  Eclipse starts, Debug
 perspective opens and i can use the debugger just fine. But when the
 app terminates, how can i tell Eclipse to switch automatically to the
 PyDev perspective and not remain in the Debug one ?


There's no currently no automatic' way to do this (but you can use Ctrl+F8
to iterate your perspectives, Ctrl+F7 for your views and Ctrl+F6 for your
editors, so, it should be easy to go to wherever you want in the interface).

2. Let's say we have a project that consists of some .py files. I want
 to press F9 when the editor displays anyone of these files but make
 Eclipse to run the whole project (that has another .py as default)
 and not the script that i am currently working on, is that possible ??


You should do F9 in you current editor and then Ctrl+F11 to re-run the last
run -- so, if you have a main file that you just ran in your project, you
can probably just keep to Ctrl+F11 -- note that this behavior changed with
Eclipse 3.3, but you can restore it: window  preferences   run/debug 
launching  always launch the previously launched application.

Cheers,

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

Re: Module imports during object instantiation

2007-08-13 Thread Steve Holden
Ritesh Raj Sarraf wrote:
 Hi,
 
 I've been very confused about why this doesn't work. I mean I don't see any
 reason why this has been made not to work.
 
 class Log:
 
 def __init__(self, verbose, lock = None):
 
 if verbose is True:
 self.VERBOSE = True
 else: self.VERBOSE = False
 
Better:

self.VERBOSE = verbose

or, if you suspect verbose might pass in a mutable value,

 self.VERBOSE  bool(verbose)

 
 if lock is None or lock != 1:
 self.DispLock = False

do you want to set self.lock here? IF so, a similar improvement could be 
made (though you would still need a test to create the lock object).

 else:
 self.DispLock = threading.Lock()
 self.lock = True
 
 if os.name == 'posix':
self.platform = 'posix'
self.color = get_colors()
 
 elif os.name in ['nt', 'dos']:
 self.platform = 'microsoft'
 
 try:
 import SomeModule
 except ImportError:
 self.Set_Flag = None
 
 if self.Set_Flag is not None:
 self.color = SomeModule.get_colors_windows()
 
 else:
 self.platform = None
 self.color = None
 
 When I create an object the import part never gets executed. Is there a
 reason behind it ?
 I mean I'd like to keep my class as independent as I want. So that when
 later I need to use it somewhere else, I don't need to know if it depends
 on any modules.
 
 Currently, the way I'm left is to globally go and import the module and set
 a flag there.
 
What's leading you to conclude the import isn't being executed? You 
realise, I trust, that the module's code will only be executed on the 
first call to __init__()?

You are right in assuming that __init__() is called once per instance 
created, and it's legitimate to make an import conditional in the way 
you have because of the execute code only once behavior - if the 
module is already in sys.modules then it won't be re-imported, the 
existing one will be used.

Having said all that, I still don't see why you can't just put the 
try/except at the top level of your code and have color be a global. Why 
repeat the attempted import and the computation for each object you 
create? Alternatively, do it at the class level, so it's only executed 
once when the class is declared?

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: check if var is dict

2007-08-13 Thread Bruno Desthuilliers
Astan Chee a écrit :
 Hi,
 I have a variable, I want to check if it is a dictionary or a string.
 Is there any better way to do this than I've done. How I did it is by 
 doing a .items() and catching a AttributeError that it raises if its not 
 a dictionary.
 How do i properly do it?

Checking the presence of one (or more) attributes of the object is so 
far the best thing to do. Now wrt/ *how* to check, using hasattr() or 
getattr() might be better than a try/except block:

def my_func(some_obj):
   if callable(getattr(obj, 'items', None)) \
  and callable(getattr(obj, 'keys', None)):
use_obj_as_a_dict(...)
   else:
   use_obj_as_a_string(...)

Now keep in mind that this may lead to false positives if you don't 
carefully choose the attribute(s) to check the presence of...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Process Control Help

2007-08-13 Thread Cameron Laird
In article [EMAIL PROTECTED],
Azazello  [EMAIL PROTECTED] wrote:
On Jul 31, 12:45 pm, Walt Leipold [EMAIL PROTECTED] wrote:
.
.
.
 It has nothing to do with 'proprietary issues'.  A lot of it has to do
 with the perception of support -- who will support Python and custom
 Python code if my plant shuts down?  Who will train my developers and
 operators?  Who can I sue?  The rest of it is because of the way the
.
.
.
 You *might* save on development time (although I wouldn't bet on it),
 but you'll lose on testing time.  Heck, you'll even lose because you
 have to document your stuff and train people to use it -- what happens
 to your custom system if you get hit by a bus?
.
.
.
 Yes, it's a shame that you have to buy three packages to perform three
 functions, and then buy other 3rd-party packages to tie them together.
 Yes, it's a shame that industrial software is expensive, and
 proprietary, and Windows-only, and generally has a brain-dead scripting
 language (when it has any scriptability at all).  Still, as much as it
 galls me to say it, if your company's primary business isn't writing
 industrial automation software, don't write industrial automation
 software.
.
.
.
 * Unless you're a hobbyist, if you want to do data acquisition or i/o,
 purchase an i/o server for your particular bus/instrumentation from a
 major manufacturer.  You *can* write your own i/o server, especially for
 simple protocols like Modbus, but the commercial versions have been
 tested more exhaustively than you can manage.  Also, the most common
 protocol these days is OPC, which isn't a protocol at all in the
 conventional sense -- it's a set of APIs to a Windows DLL, with the
 wire-level details completely opaque -- so you'd have to buy a library
 for that anyway.

 * Unless you're a hobbyist, if you want an HMI, purchase LabView or
 InTouch or RSView or whatever, and use their tools to draw and
 'configure' your screens.  (Where 'configure' generally means 'program
 in Visual Basic or some other brain-dead language', but we try not to
 say program -- customers and underwriters *hate* custom software.)

 I personally think it's a tragedy that every manufacturer bases its HMI
 on Visual Basic for Applications rather than a better (and free and Open
 Source!) language like Python.  It's also a tragedy that the dominant
 i/o 'protocol' for industrial automation isn't really a protocol, and is
 Windows-only to boot.  It's horrifying that the primary means of
 communication between process control and data acquisition applications
 is via DDE or ActiveX.  And I find it incredible that people and
 companies will pay large sums of money for some of the industrial
 automation products on the market.  But that's the way the industry
 works, and, as frustrating as the commercial offerings are, using them
 will probably be better for you and your company in the long run.
.
.
.
I really appreciate your post Walt. I started this thread last week
and I have to admit that in the subsequent days the 'option' of using
Python for our control solutions is simply not feasible.  Although the
project I wanted to implement was fairly small scale, no 20 ton pieces
or x-ray machinery, the principle of the matter remains the same,
especially as a large corporation.  As an intern returning to school
in the fall, the underlying responsibility for a Python system was my
original concern and discouragement to my employer for persuing this
path.  It became readily apparent that using the crumby software
packaged with our control devices is surely faster in the long run, as
we are not involved in software development.  (The majority of my
coworkers' formal programming experience is in FORTRAN) It has been a
very discouraging few days.  There's so much room for improvement and
yet...  My 4-day conclusion is unless you're already involved in
controls software you must be crazy to join.  Are many young engineers
entering this field?


At an anecdotal level, I'd guess that, no, there are few
young engineers entering this field.

Mr. Leipold's descriptions of the difficulties involved 
in use of Python are accurate, and I particularly support
his advice to use whatever commercial I/O you can find.
I've had success, though, introducing high-level language
programming, and even Linux, as an alternative to vendors'
APIs, Labview, and so on.  I'm not sure how to summarize
what went into this; perhaps the best is to emphasize how
flawed is the software that's typical with vendor APIs.

While there's more to tell about the errors in commercial
networking implementations, the horror of ActiveX, and so
on, right now 

Re: check if var is dict

2007-08-13 Thread Jeff McNeil
You could use 'isinstance' to determine whether or not your object is
an instance of a particular class.

 isinstance({}, dict)
True
 isinstance(, basestring)
True


Note the use of 'basestring', which will catch unicode as well.

-Jeff

On 8/13/07, Astan Chee [EMAIL PROTECTED] wrote:
 Hi,
 I have a variable, I want to check if it is a dictionary or a string.
 Is there any better way to do this than I've done. How I did it is by
 doing a .items() and catching a AttributeError that it raises if its not
 a dictionary.
 How do i properly do it?
 Thanks
 Astan
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Air conditioners for free!??!?!!!

2007-08-13 Thread fritz
http://airconlinks.blogspot.com/

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


Re: Process Control Help

2007-08-13 Thread Cameron Laird
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:


I'm attempting to start some process control using Python.  I've have
.
.
.
Is there an existing forum on this already?
.
.
.
URL: http://www.engcorp.com/acf/RecentChanges 

It's been dormant for a while, but it wouldn't take much to
restore its vitality.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: decorators - more than just syntactic sugar

2007-08-13 Thread BJörn Lindqvist
On 8/11/07, Helmut Jarausch [EMAIL PROTECTED] wrote:
 How can I find out the predefined decorators?

There are two in the standard library, @classmethod for declaring
class methods and @staticmethod for declaring static methods. They are
listed at the built ins page
http://docs.python.org/dev/lib/built-in-funcs.html, unpedagogically
not separated from ordinary functions.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Configuring apache to execute python scripts using mod_python handler

2007-08-13 Thread joe jacob
I configured apache to execute python scripts using mod_python
handler. I followed below mentioned steps to configure apache.

1. In http.conf I added

  Directory D:/softwares/Apache2.2/htdocs
  AddHandler mod_python .py
  PythonHandler mptest
  PythonDebug On
  /Directory

2. Then I added the line LoadModule python_module modules/
mod_python.so to http.conf.

Then I tried execute the python script mentioned below from browser.

from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.write(Hello World!)
return apache.OK

Then I am getting the following error

Traceback (most recent call last):

  File D:\softwares\Python25\Lib\site-packages\mod_python
\importer.py, line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File D:\softwares\Python25\Lib\site-packages\mod_python
\importer.py, line 1202, in _process_target
module = import_module(module_name, path=path)

  File D:\softwares\Python25\Lib\site-packages\mod_python
\importer.py, line 304, in import_module
return __import__(module_name, {}, {}, ['*'])

ImportError: No module named mptest

I am using Apache 2.2.4, python 2.5 and mod_python-3.3.1.win32-py2.5-
Apache2.2.

I am able to execute python scripts by configuring apache to execute
the cgi scripts. But I want to execute it using mod_python as it is
faster compared to cgi mode. Someone please help me on this issue.

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


Re: check if var is dict

2007-08-13 Thread Wildemar Wildenburger
Astan Chee wrote:
 Hi,
 I have a variable, I want to check if it is a dictionary or a string.
 Is there any better way to do this than I've done. How I did it is by 
 doing a .items() and catching a AttributeError that it raises if its not 
 a dictionary.
 How do i properly do it?
   
The way you did, actually :).
Look for It's better to ask for forgiveness than for permission (or 
so) and the term duck typing. That's the way to do it in python.

And just for completeness' sake: You could have also checked for actual 
types via isinstance(your_variable, dict) or type(your_variable) is 
type(dict) or ... But your approach is the recomended one.

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


Re: decorators - more than just syntactic sugar

2007-08-13 Thread Duncan Booth
BJörn Lindqvist [EMAIL PROTECTED] wrote:

 On 8/11/07, Helmut Jarausch [EMAIL PROTECTED] wrote:
 How can I find out the predefined decorators?
 
 There are two in the standard library, @classmethod for declaring
 class methods and @staticmethod for declaring static methods. They are
 listed at the built ins page
 http://docs.python.org/dev/lib/built-in-funcs.html, unpedagogically
 not separated from ordinary functions.
 
 

There are at least two other decorators in the standard library:

 functools.wraps
 contextlib.contextmanager

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


Re: Eclipse/PyDev question

2007-08-13 Thread gatti
On Aug 13, 11:48 am, king kikapu [EMAIL PROTECTED] wrote:
 Hi,

 i am using Eclipse (Platform Runtime binary) with PyDev and i was
 wondering if someone can help me with this:

 1. I set breakpoints to a .py file and i have told Eclipse to open the
 Debug perspective when it sees that some .py file(s) of my project
 indeed contains breakpoints. So, i press F9,  Eclipse starts, Debug
 perspective opens and i can use the debugger just fine. But when the
 app terminates, how can i tell Eclipse to switch automatically to the
 PyDev perspective and not remain in the Debug one ?

You don't, Eclipse keeps the same perspective because for what it
knows you might want to debug some more and it correctly avoids to
decide what is good for you. Switching to the debug perspective when
you issue a debug command is an exception to the normal switching of
perspectives with the respective big buttons and the menu.
If you wish to switch perspective to edit code before debugging again,
putting editors and appropriate accessory views in the debug
perspective might be good enough.

 2. Let's say we have a project that consists of some .py files. I want
 to press F9 when the editor displays anyone of these files but make
 Eclipse to run the whole project (that has another .py as default)
 and not the script that i am currently working on, is that possible ??

Executing the current file is a bad habit, Eclipse remembers a list of
execution/debug configurations that can be selected from a dropdown
list in the toolbar and edited with a dialog box; after you setup
entry points for a project you can use and edit them as needed.
I'm using Eclipse for Java and my entry points include remote
debugging of a GUI application, about 6 JUnit tests, about 3 command
line tools with many complex parameter sets each, and some Ant builds;
it would take about one hour of trial and error to reconstruct the
command lines, classpaths and JVM options. I only run the current file
as a draft for an edited configuration.

Regards,
Lorenzo Gatti

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


Re: decorators - more than just syntactic sugar

2007-08-13 Thread Duncan Booth
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:

 On Sat, 11 Aug 2007 20:30:54 +0200, Helmut Jarausch wrote:
 
 are decorators more than just syntactic sugar in python 2.x and what
 about python 3k ?
 
 They are just syntactic sugar.
 
 @spam
 def ham():
 pass
 
 is the same as
 
 def ham():
 pass
 
 ham = spam(ham)

Decorators are almost just syntactic sugar, but in fact there is a subtle 
difference between the two bits of code you gave: in the second one you 
assign the function to the name ham and then replace it with the result of 
calling spam. With the decorator syntax you only have one assignment to ham 
and when that decorator is called that assignment has not yet happened.

The difference is small, but you can write decorators which depend on it. 
For example, the code I posted in [EMAIL PROTECTED] 
depends on this difference and will not work if you write the calls out 
explicitly instead of using decorators.


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


Re: Configuring apache to execute python scripts using mod_python handler

2007-08-13 Thread [EMAIL PROTECTED]
Hi Joe

You'd probably have better luck posting this to the mod python mailing
list. Did you name your python script mptest.py and did you remember
to restart Apache when you edited the httpd.conf file? If so then I
don't see any reason why it shouldn't work although I've never tried
mod_python under a Windows environment.

Regards

Jeffrey van Aswegen

joe jacob wrote:
 I configured apache to execute python scripts using mod_python
 handler. I followed below mentioned steps to configure apache.

 1. In http.conf I added

   Directory D:/softwares/Apache2.2/htdocs
   AddHandler mod_python .py
   PythonHandler mptest
   PythonDebug On
   /Directory

 2. Then I added the line LoadModule python_module modules/
 mod_python.so to http.conf.

 Then I tried execute the python script mentioned below from browser.

 from mod_python import apache
 def handler(req):
 req.content_type = 'text/plain'
 req.write(Hello World!)
 return apache.OK

 Then I am getting the following error

 Traceback (most recent call last):

   File D:\softwares\Python25\Lib\site-packages\mod_python
 \importer.py, line 1537, in HandlerDispatch
 default=default_handler, arg=req, silent=hlist.silent)

   File D:\softwares\Python25\Lib\site-packages\mod_python
 \importer.py, line 1202, in _process_target
 module = import_module(module_name, path=path)

   File D:\softwares\Python25\Lib\site-packages\mod_python
 \importer.py, line 304, in import_module
 return __import__(module_name, {}, {}, ['*'])

 ImportError: No module named mptest

 I am using Apache 2.2.4, python 2.5 and mod_python-3.3.1.win32-py2.5-
 Apache2.2.

 I am able to execute python scripts by configuring apache to execute
 the cgi scripts. But I want to execute it using mod_python as it is
 faster compared to cgi mode. Someone please help me on this issue.

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


Re: Air conditioners for free!??!?!!!

2007-08-13 Thread Paul Heslop
fritz wrote:
 
 http://goodgrief

-- 
Paul  (We won't die of devotion)  
---   
Stop and Look 
http://www.geocities.com/dreamst8me/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adventure-Engines in Python

2007-08-13 Thread David Boddie
On Mon Aug 13 11:33:14 CEST 2007, Wildemar Wildenburger wrote:

 Are there any?
 
 I've set out to make an adventure game and now I'm trying to find a set 
 of python-modules to help me do that. I know of the usual non-python 
 suspects (AGAST, AGS, Wintermute, ...) and while I they are really good, 
 I'd like one that is cross platform.
 
 I've found pyScumm and pyAdv but both don't seem to be ready for use 
 yet. So are there any usable engines written in python?

It's been a while since I looked at anything like this, but I seem to
remember two Python powered engines: PAWS and PUB.

  http://py-universe.sourceforge.net/
  http://members.nuvox.net/~zt.wolf/PAWS.htm

If you want to write adventures with more graphics and less text, you could
do worse than looking at existing projects and solutions written with Pygame:

  http://www.pygame.org/

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


Python-URL! - weekly Python news and links (Aug 13)

2007-08-13 Thread Gabriel Genellina
QOTW:  The first time you see twenty tons of machinery move unexpectedly
because you inadvertently changed one bit in memory, you become very 
conservative about your software platform. - Walt Leipold

Making use of the available wrappers for current Tk libraries such as
BWidgets, Tile, Tablelist, TkTreeCtrl, and so on allows you to make UI's
every bit as polished as what comes with wxPython ... - Kevin Walzer


Looking for the best programs written entirely in
Python:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/9fea4deb4c70fef1/

`a==b` vs. `a is b` revisited, with some advice on
when to use one test or another:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4a087153826f1f2b/

Pros and cons of desktop web applications vs. native
GUIs: 

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1f823a9c8a41c8bb/50c2f4bc10621f9a?rnum=1#50c2f4bc10621f9a
started as

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1f823a9c8a41c8bb

When is OK to use __del__?

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b09e02b7c67c8a3b/

Leipzig is the site of the second Python im deutschsprachigen
Raum 2007.  Among the presentations likely to reward both novices
and experienced Pythoneers are ones on Web applications, use of
Python in science, developer tools in Python, and Python for
simulations in aerospace.   
http://www.python-academy.de/workshop/index.html

Somewhat related to previous topic: how to ensure a
generator object is closed in Python 2.4?

http://groups.google.com/group/comp.lang.python/browse_thread/thread/3f789096bded17e7/

Discussing Python threading model, the GIL, Stackless,
and possible future alternatives:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/bbeb8b826af93ae/

Use spaces for space and use tabs for tables: A
Python song, by James Stroud
http://groups.google.com/group/comp.lang.python/msg/9743131cf0c426eb



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish the efforts of Python enthusiats:
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the Planet sites:
http://planetpython.org
http://planet.python.org

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Python411 indexes podcasts ... to help people learn Python ...
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.

Re: Eclipse/PyDev question

2007-08-13 Thread king kikapu
On Aug 13, 1:44 pm, [EMAIL PROTECTED] wrote:
 On Aug 13, 11:48 am, king kikapu [EMAIL PROTECTED] wrote:

  Hi,

  i am using Eclipse (Platform Runtime binary) with PyDev and i was
  wondering if someone can help me with this:

  1. I set breakpoints to a .py file and i have told Eclipse to open the
  Debug perspective when it sees that some .py file(s) of my project
  indeed contains breakpoints. So, i press F9,  Eclipse starts, Debug
  perspective opens and i can use the debugger just fine. But when the
  app terminates, how can i tell Eclipse to switch automatically to the
  PyDev perspective and not remain in the Debug one ?

 You don't, Eclipse keeps the same perspective because for what it
 knows you might want to debug some more and it correctly avoids to
 decide what is good for you. Switching to the debug perspective when
 you issue a debug command is an exception to the normal switching of
 perspectives with the respective big buttons and the menu.
 If you wish to switch perspective to edit code before debugging again,
 putting editors and appropriate accessory views in the debug
 perspective might be good enough.

  2. Let's say we have a project that consists of some .py files. I want
  to press F9 when the editor displays anyone of these files but make
  Eclipse to run the whole project (that has another .py as default)
  and not the script that i am currently working on, is that possible ??

 Executing the current file is a bad habit, Eclipse remembers a list of
 execution/debug configurations that can be selected from a dropdown
 list in the toolbar and edited with a dialog box; after you setup
 entry points for a project you can use and edit them as needed.
 I'm using Eclipse for Java and my entry points include remote
 debugging of a GUI application, about 6 JUnit tests, about 3 command
 line tools with many complex parameter sets each, and some Ant builds;
 it would take about one hour of trial and error to reconstruct the
 command lines, classpaths and JVM options. I only run the current file
 as a draft for an edited configuration.

 Regards,
 Lorenzo Gatti

Hey Lorenzo,

thanks for the help!

I understood that with the Debug perspective. Ok, i will, as
currently, have to swtick manually to PyDev.

But i cannot figgre out how i can tell Eclipse to run the whole
Project and not the currently active script that i work on...

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


Re: Fatest standard way to sum bytes (and their squares)?

2007-08-13 Thread Hrvoje Niksic
Erik Max Francis [EMAIL PROTECTED] writes:

 Hrvoje Niksic wrote:

 For ordinalSum, using imap is almost twice as fast:
 $ python -m timeit -s 'data=[chr(x) for x in xrange(256)]'
 'sum(ord(x) for x in data)'
 1 loops, best of 3: 92.4 usec per loop
 $ python -m timeit -s 'data=[chr(x) for x in xrange(256)]; from itertools 
 import imap' 'sum(imap(ord, data))'
 1 loops, best of 3: 55.4 usec per loop

 You're using data which is a list of chars (strings), rather than a
 string itself, which is what the format is in.  The imap
 optimization doesn't appear to work quite as dramatically well for
 me with strings instead of lists, but it certainly is an
 improvement.

I wouldn't expect to see any difference in strings and lists.  In this
simple test I get approximately the same ~1.7x speedup:

$ python -m timeit 'sum(ord(x) for x in abcdefghijklmnopqrstuvwxyz)'
10 loops, best of 3: 12.7 usec per loop
$ python -m timeit -s 'from itertools import imap' 'sum(imap(ord, 
abcdefghijklmnopqrstuvwxyz))'
10 loops, best of 3: 7.42 usec per loop
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extending logging module

2007-08-13 Thread Vinay Sajip
On Aug 9, 9:08 pm, jay [EMAIL PROTECTED] wrote:
 It actually worked, but this is not the way I would like to handle the
 problem.  I would prefer to extend the classes instead.  However, I'm
 not too familiar with that, and I had to change things in so many
 places, I'm wondering if its even possible?  I don't like changing the
 standard libraries, what happens if I have to upgrade python?  My
 changes get overwritten.

 Can anyone offer some help or suggestions?  Thanks


Where's the difficulty in extending the SyslogHandler class? Simply
override the methods you need to provide the behaviour you want, then
use your handler instead of the standard SyslogHandler. I'm travelling
at the moment and cannot post a working example, but it should be easy
enough to do. It's just the same as extending any other Python class -
but remember to call the base class's __init__ from your own __init__,
if you provide one.

Best regards,

Vinay Sajip

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


Re: Adventure-Engines in Python

2007-08-13 Thread Tommy Nordgren

On 13 aug 2007, at 11.33, Wildemar Wildenburger wrote:

 Are there any?

 I've set out to make an adventure game and now I'm trying to find a  
 set
 of python-modules to help me do that. I know of the usual non-python
 suspects (AGAST, AGS, Wintermute, ...) and while I they are really  
 good,
 I'd like one that is cross platform.

 I've found pyScumm and pyAdv but both don't seem to be ready for use
 yet. So are there any usable engines written in python?

 /W
 -- 
 http://mail.python.org/mailman/listinfo/python-list
I don't know of any adventure engines in Python,
bet there is an open-source language and class library for text  
adventures called TADS
(www.tads.org) The syntax is similar to C++ and Java.
Tads have been ported to ALL major platforms
-
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
[EMAIL PROTECTED]



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


Re: Adventure-Engines in Python

2007-08-13 Thread Neil Cerutti
On 2007-08-13, Richard Jones [EMAIL PROTECTED] wrote:
 Wildemar Wildenburger wrote:
 Are there any?

 An adventure game was written for one of the PyWeek challenges:

 http://www.pyweek.org/e/aerunthar/

 You might be able to use that as a starting point.

Here's an abondoned (since Python 2.2), but basically complete
system:

  http://members.nuvox.net/~zt.wolf/PAWS.htm

For a taste of what it looked like, see the PAWS section of Roger
Firth's IF system comparison page, _Cloak of Darkness_. 

http://www.firthworks.com/roger/cloak/
http://www.firthworks.com/roger/cloak/paws/index.html

This contains a P.A.W.S version of the very simple example game.
The author of the example is somewhat suspect, however.

As far as I know, no full game was ever written in PAWS. Once you
try it, you'll possibly see why no interactive fiction system
distributed as a library for a general-purpose language has ever
caught on. Every system that's enjoyed even moderate success has
been a language+library implementation.

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


Re: Colored text

2007-08-13 Thread Neil Cerutti
On 2007-08-13, Michael Bentley [EMAIL PROTECTED] wrote:

 On Aug 12, 2007, at 7:05 PM, Rohan wrote:
 Can some one tell me how do I get colored text. Say when I want to
 write something in a text file , how do I get it colored.

 You can use ANSI escape codes -- http://en.wikipedia.org/wiki/ 
 ANSI_escape_code:

Unfortunately, most versions of Windows of the last 7 years
(2000, XP, probably Vista) don't support ANSI escape codes well
enough to work with Python.

-- 
Neil Cerutti
We have to play hard for the full 40 minutes. 48? Oh, that's right. --Mikki
Moore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: retrieving ATOM/FSS feeds

2007-08-13 Thread Diez B. Roggisch
_spitFIRE wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Lawrence Oluyede wrote:
 If the content producer doesn't provide the full article via RSS/ATOM
 there's no way you can get it from there. Search for full content feeds
 if any, otherwise get the article URL and feed it to BeautifulSoup to
 scrape the content.
 
 
 For the same feed (where the content producer doesn't provide the full
 article!) I was able to see the complete post in other RSS aggregators
 (like Blam). I wanted to know how they were able to collect the feed!

Either it is referred to in the data - or it might be that they do have
affiliate-deals with certain partners.

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


Re: Eclipse/PyDev question

2007-08-13 Thread king kikapu
Ah, i forgot another one:

as any project evolves, you need to organize it in directories. So, i
have a project named Dev and Eclipse has provided me (in Navigator)
with Dev and Src. Inside Src i put my .py files. Let's say that i
want to create a directory there (will i make it in Src or in Dev)
to put other .py files. I tried adding a Folder, i also tried to add
a Pydev Source Folder, either way i cannot refer to these files from
a .py located in Src directory with the usual from folderA
import...It does not understand the folder structure and i am pretty
sure i am missing something obvious here...

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


Re: Something in the function tutorial confused me.

2007-08-13 Thread Neil Cerutti
On 2007-08-12, Alex Martelli [EMAIL PROTECTED] wrote:
 Neil Cerutti [EMAIL PROTECTED] wrote:
...
 OK, I've thought about this some more and I think the source
 of my confusion was I thought assignment in Python meant
 binding a name to something, not mutating an object. But in
 the case of augmented assignment, assignment no longer means
 that?

 Plain assignment *to a plain name* does mean binding a name
 (the LHS) to something (the RHS).

 Other assignments (ones that are not plain assignments to
 names) may have different meanings.  For example:

 class act(object):
 ...   def __init__(self, c): self._c = c
 ...   def getC(self): return self._c
 ...   def setC(self, *ignore): self._c += 1
 ...   c = property(getC, setC)
 ...   
 x = act(0)
 x.c
 0
 x.c = 23
 x.c
 1

 Here's an example where a plain assignment (to an attribute of x, not to
 a plain name) obviously DOESN'T mean binding a name to something: the
 something (the RHS) is completely ignored, so the plain assignment is
 mutating an object (x) and not binding any name to anything.

That's enlightening. I hadn't considered the implications of
generalizing assignment to names with assignment to qualified
names.

 Plain assignments to items and slices can also often be best
 seen as mutating an object (the one being indexed or sliced
 on the LHS) rather than binding a name.  For example:

 l=list('ciao')
 l[1:3]='app'
 l
 ['c', 'a', 'p', 'p', 'o']

That example makes me feel ashamed for not thinking of it, since
I use the slicing assignment all the time and it's obviously
not a binding construct.

 If I was teaching Python and came upon this example, I would
 definitely not try to weaselword the explanation of what's
 going on in terms of binding a name (or several ``names'',
 including ``rebinding a new ``name'' l[4] to the 'o' that was
 previously ``bound'' to l[3], etc:-): it's just orders of
 magnitudes simpler to explain this as mutating an object,
 namely the list 

 I take almost 3 pages in Python in a Nutshell (47 to 49 in
 the second edition) to summarily explain every kind assignment
 -- and that's in a work in which I've tried (successfully, I
 believe from reviews) to be very, *VERY* concise;-).

 Summarizing that summary;-), a plain assignment to an identifier binds
 that name; a plain assignment to an attribute reference x.y asks object
 x (x can be any expression) to bind its attribute named 'y'; a plain
 assignment to an indexing x[y] (x and y are arbitrary expressions) asks
 object x to bind its item indicated by the value of y); a plain
 assignment to a slicing is equivalent to the plain assignment to the
 indexing with an index of slice(start, stop, stride) [[slice is a Python
 builtin type]].

 Plain assignment to an identifier just happens; all other cases of
 plain assignment are requests to an object to bind one or more of its
 attributes or items (i.e., requests for specific mutations of an object)
 -- as for, say any method call (which might also be a request for some
 kind of mutation), the object will do whatever it pleases with the
 request (including, perhaps, refusing it, by raising an exception).

 Then we get into unpacking assignments and augmented
 assignments, but I don't really want to write two more pages
 worth of summary...;-).

Thanks very much for taking the time to help clear up my
erroneous model of assignment in Python. I'd taken a conceptual
shortcut that's not justified.

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


Drawing a graph

2007-08-13 Thread Ghirai
Hello list,

I need to draw a graph, 2 axes, 2D, nothing fancy.
One of the axes is time, the other one is a series of integers.

I don't care much about the output format.

Are there any specialized libraries for this, or should i use PIL?

Thanks.

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


strftime in python 2.2

2007-08-13 Thread Flyzone
I'm trying to make work this code in python 2.2.3:

check=datetime.datetime.today().strftime(%H%M)

but datetime is not supported in that version but just in the later.
I can't upgrade python, too many dependencies in a critical system.
How can i convert that string to have the same result?

Hope someone can help me,
Thanks in advance

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


Re: check if var is dict

2007-08-13 Thread Bruno Desthuilliers
Jeff McNeil a écrit :
(top-post corrected)
 On 8/13/07, Astan Chee [EMAIL PROTECTED] wrote:
 Hi,
 I have a variable, I want to check if it is a dictionary or a string.
 Is there any better way to do this than I've done. How I did it is by
 doing a .items() and catching a AttributeError that it raises if its not
 a dictionary.
 How do i properly do it?
 Thanks

  You could use 'isinstance' to determine whether or not your object is
  an instance of a particular class.
 
  isinstance({}, dict)
  True
  isinstance(, basestring)
  True
 
  Note the use of 'basestring', which will catch unicode as well.
 
The problem is that it will prevent passing some perfectly valid objects 
(in this case, mostly dict-like objects, and there are quite a lot of 
dict-like objects in existing Python code).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: negative polar axis

2007-08-13 Thread Steve Holden
yadin wrote:
 hi!
 how can i do polar plot in python with negative axes
 that is the value of the magnitude is negative
 
Surely a negative magnitude doesn't make sense in polar coordinates, 
since the magnitude is supposed to represent the distance from the center.

About the best interpretation I can think of is to add 180 degrees to 
the angle and reverse the sign of the magnitude, but this would be a 
hack. Where are those coordinates coming from?

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Pausing and Unpausing Threads

2007-08-13 Thread Aaron J. M.
On Aug 13, 2:31 am, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 Use the same Queue; put a special kind of Action, or just a None object,
 to tell the thread that there are no more things to process.
  From the main thread, you can join() the others, waiting for them to
 finish.

Ah, thank you very much. :)

- Aaron J. M.

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


Getting started with JPype

2007-08-13 Thread porter
Hi,

For nefarious javaesque reasons I've been trying to get started with
jpype (http://jpype.sourceforge.net). This looks like a potentially
useful tool for integrating java classes into C-python, but
frustratingly I've run into immediate problems. The documentation on
the project really doesn't deal with 'the basics' and I believe it is
this that I am running foul of: I have read much on the web, and I
suspect that this is a classpath issue, but I can't see what I'm doing
wrong.

And I'm confident that the path I specify is ok

The error I get is

Package myclass.HelloWorld is not Callable

but I suspect that this is, infact, telling me that the class
HelloWorld could not be found.

If so - why not? - Note that using java

Here's my python code snippet

from jpype import *

startJVM(getDefaultJVMPath(), -ea, -Djava.class.path=D:/tmp/jpype-
reli/test/dist/test.jar'' )

package = JPackage(myclass)
x = package.HelloWorld()
x.do_a_message()

shutdownJVM()

I have a java class called HelloWorld in package myclass which
resides in test.jar. The source is below:

package myclasses;

public class HelloWorld
{

/** Creates a new instance of HelloWorld */
public HelloWorld()
{
}

public void message()
{
System.out.println(Hello, World);
}

public static void do_a_message()
{
System.out.println(Static Hello, World);
}
}

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


Re: Drawing a graph

2007-08-13 Thread Helmut Jarausch
Ghirai wrote:
 Hello list,
 
 I need to draw a graph, 2 axes, 2D, nothing fancy.
 One of the axes is time, the other one is a series of integers.
 
 I don't care much about the output format.
 
 Are there any specialized libraries for this, or should i use PIL?
 

What about Gnuplot.py
http://gnuplot-py.sourceforge.net/


-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting started with JPype

2007-08-13 Thread porter
Gah - I hate it when that happens: Just after posting I figured out my
silly mistake: my package is called myclasses and I was referencing
'myclass'

apologies for wasting your time




 Hi,

 For nefarious javaesque reasons I've been trying to get started with
 jpype (http://jpype.sourceforge.net). This looks like a potentially
 useful tool for integrating java classes into C-python, but
 frustratingly I've run into immediate problems. The documentation on
 the project really doesn't deal with 'the basics' and I believe it is
 this that I am running foul of: I have read much on the web, and I
 suspect that this is a classpath issue, but I can't see what I'm doing
 wrong.

 And I'm confident that the path I specify is ok

 The error I get is

 Package myclass.HelloWorld is not Callable

 but I suspect that this is, infact, telling me that the class
 HelloWorld could not be found.

 If so - why not? - Note that using java

 Here's my python code snippet

 from jpype import *

 startJVM(getDefaultJVMPath(), -ea, -Djava.class.path=D:/tmp/jpype-
 reli/test/dist/test.jar'' )

 package = JPackage(myclass)
 x = package.HelloWorld()
 x.do_a_message()

 shutdownJVM()

 I have a java class called HelloWorld in package myclass which
 resides in test.jar. The source is below:

 package myclasses;

 public class HelloWorld
 {

 /** Creates a new instance of HelloWorld */
 public HelloWorld()
 {
 }

 public void message()
 {
 System.out.println(Hello, World);
 }

 public static void do_a_message()
 {
 System.out.println(Static Hello, World);
 }

 }


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


Re: Drawing a graph

2007-08-13 Thread Larry Bates
Ghirai wrote:
 Hello list,
 
 I need to draw a graph, 2 axes, 2D, nothing fancy.
 One of the axes is time, the other one is a series of integers.
 
 I don't care much about the output format.
 
 Are there any specialized libraries for this, or should i use PIL?
 
 Thanks.
 
ReportLab graphics works for me.

www.reportlab.org

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


Re: Binary, Hex, and Decimal string conversions

2007-08-13 Thread Robert Dailey
Just curious Dick, why are you making your own to_base method? Doesn't the
source I provided in my earlier email give you all that you need? I was
hoping my source might be useful to a few people, even though it's pretty
trivial code.

On 8/12/07, Dick Moores [EMAIL PROTECTED] wrote:

 At 07:04 PM 8/12/2007, Michael Bentley wrote:

 On Aug 12, 2007, at 6:28 PM, Dick Moores wrote:
 
 n = 12
 base = 36
 print to_base(n, base)
 ==
 This seems to work fine for n = base, but not for n  base. For
 example, the code shown returns c. Is my indentation wrong, or
 the code? It seems to me that the code should work for the general
 case, not just for n = base.
 
 Isn't 'c' the correct answer?

 Yes, of course. Stupid of me.

 Dick


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

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

Re: Database intensive application

2007-08-13 Thread Erik Jones

On Aug 12, 2007, at 7:44 AM, Viewer T. wrote:

  and Yes, Python
 has awesome database support and can satisfy almost all database  
 needs.

Wow.  Nobody ever told me Python was *that* kind of language :)

Erik Jones

Software Developer | Emma®
[EMAIL PROTECTED]
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate  market in style.
Visit us online at http://www.myemma.com


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


Re: Something in the function tutorial confused me.

2007-08-13 Thread Alex Martelli
Neil Cerutti [EMAIL PROTECTED] wrote:
   ...
  Then we get into unpacking assignments and augmented
  assignments, but I don't really want to write two more pages
  worth of summary...;-).
 
 Thanks very much for taking the time to help clear up my
 erroneous model of assignment in Python. I'd taken a conceptual
 shortcut that's not justified.

You're very welcome, it's always a pleasure to help!


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


Help with optimisation

2007-08-13 Thread special_dragonfly
Hello,
I know this might be a little cheeky, and if it is, please say, but I need a 
little hand optimising some code. For the simple reason that this is 
'company' code and I have no idea what I'm allowed to release and not as the 
case may be I've changed anything that could give an indication of the 
company - if that makes any sense...

for the code below:
text_buffer is a single record from an XML stream. I can't read in the 
entire XML at once because it isn't all available straight away, so I 
capture line by line, and when a full message is available I use parseString 
under the minidom API.
The SQL version is SQLite. It was recommended to me, and is adequate for the 
uses I put it to.
The function doesn't return anything, but it's called often enough and 
depending on the optimisation I'll be able to use the same style in other 
areas of the program.

previous code:
def CreatePerson(text_buffer):
dom=xml.dom.minidom.parseString(text_buffer)
reflist = dom.getElementsByTagName('Country')
Country = reflist[0].firstChild.nodeValue
reflist = dom.getElementsByTagName('Age')
Age = reflist[0].firstChild.nodeValue
reflist = dom.getElementsByTagName('Surname')
Surname = reflist[0].firstChild.nodeValue
reflist = dom.getElementsByTagName('Forename')
Forename = reflist[0].firstChild.nodeValue
cursor.execute('INSERT INTO Person VALUES(?,?,?)', (Forename + - + 
Surname, Age, Country))
connection.commit()

I've changed it now to this:
def CreatePerson(text_buffer):
dom=xml.dom.minidom.parseString(text_buffer)
elements=['Country','Age','Surname','Forename']
Values=[]
for element in elements:
reflist=dom.getElementsByTagName(element)
Values.append(reflist[0].firstChild.nodeValue)
# I can get away with the above because I know the structure of the 
XML
cursor.execute('INSERT INTO Person 
VALUES(?,?,?)',(Forename+-+Surname,Age,Country))
connection.commit()

They both seem ugly IMO (read: longer than intuitively necessary), and so I 
was wondering whether there was any way to combine Forename and Surname 
together within the Values list (think merge cells with the '-' in between) 
so I could use the unary(?) operator within the SQL?

I suppose if this is a cheeky request then I won't get any replies.
Thank you for any help
Dominic



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


Re: Car Air Conditioners

2007-08-13 Thread codey45
On Aug 13, 1:18 am, Lepi Duja [EMAIL PROTECTED] wrote:
 All the informations about car air conditioners can be found on this
 website...

 http://car-air-conditioning.blogspot.com/


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


Dictionary viewer and editor

2007-08-13 Thread Ariel Balter
http://mail.python.org/pipermail/python-list/2001-August/100288.html

Did you ever finish writing this?

-- 
00

Ariel Balter

Swain Hall West 025
Department of Physics
Indiana University, Bloomington
737 E Third Street, 47404

[EMAIL PROTECTED]

Office: (812) 855-2441
Home: (812) 332-2721

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


Re: Adventure-Engines in Python

2007-08-13 Thread Wildemar Wildenburger
Wildemar Wildenburger wrote:
 I've set out to make an adventure game and now I'm trying to find a set 
 of python-modules to help me do that. I know of the usual non-python 
 suspects (AGAST, AGS, Wintermute, ...) and while I they are really good, 
 I'd like one that is cross platform.
   
OK, thanks. I should, of course, have been more specific. By saying 
adventure I mean the graphical variant (say, Monkey Island or Broken 
Sword), preferably but not necessarily in 2D.

I've also found vidaG, but it seems dead as well. I'll keep looking but 
if you know something, please let me know.


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


Re: Help with optimisation

2007-08-13 Thread Alex Martelli
special_dragonfly [EMAIL PROTECTED] wrote:
   ...
 dom=xml.dom.minidom.parseString(text_buffer)

If you need to optimize code that parses XML, use ElementTree (some
other parsers are also fast, but minidom ISN'T).


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


Re: Mixing Python and C threads

2007-08-13 Thread Stéphane Larouche
Aahz aahz at pythoncraft.com writes:

 
 In article mailman.430.1183825935.22759.python-list at python.org,
 =?utf-8?b?U3TDqXBoYW5l?= Larouche  stephane.larouche at polymtl.ca wrote:
 Aahz aahz at pythoncraft.com writes:
 
  Can you reproduce your problem with stub code that only creates threads?
  If yes, that indicates that you're messing with a thread structure
  somewhere.  Note that because you're using gcc, it's possible there's a
  thread bug on Windows with your tool chain.  You might want to check for
  bug reports.
 
 Here's the simplest piece of code I could think of to reproduce the problem:
 
 Good work.  This is about as far as my expertise can take you; if nobody
 responds, you might try the new C/API mailing list (capi-sig).

If anybody followed this thread, you'll be pleased to know that the mingw gcc
4.2.1 technology preview release available from the official mingw website and
Python threads interact perfectly well together. You also have to pass the
-mthread option to the linker.

Sincerely,

Stéphane


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

Re: strftime in python 2.2

2007-08-13 Thread Martin Blume
Flyzoneschrieb
 I'm trying to make work this code in python 2.2.3:
 
 check=datetime.datetime.today().strftime(%H%M)
 
 but datetime is not supported in that version but 
 just in the later. I can't upgrade python, too many 
 dependencies in a critical system.
 How can i convert that string to have the same result?
 

import time
time.strftime(%H%M)

HTH
Martin


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


Re: Fatest standard way to sum bytes (and their squares)?

2007-08-13 Thread Alexander Schmolck
Erik Max Francis [EMAIL PROTECTED] writes:

 Alexander Schmolck wrote:

 Is this any faster?

  ordSum, orsSumSq = (lambda c:c.real,c.imag)(sum(complex(ord(x),ord(x)1)
 for x in data))

 That's pretty clever, but I neglected to mention that I need to accumulate the
 sums as ints/longs to avoid losing precision, so converting to floating point
 isn't an optional.

I think you can safely use this trick (provided it really makes things faster)
provided you sum blocks no larger than 2**(53-8) bytes; if your files are
really that big you'd certainly want to split summing into several blocks
anyway, because otherwise you'll be doing *lots* of extra bignum arithmetic
instead of int32/int64 addition (I'd assume this will slow things noticably
down even in python). Another trick you could try, again using table-lookup:
work on words (i.e. 2bytes) instead of single bytes again using a table (from
word-(byte-sum,sq-byte-sum) tuples) ; this will half the function calls and
the table size of is hopefully still small enough to not to ruin your
cache-hit rate (you might want to try array).

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


Re: Dictionary viewer and editor

2007-08-13 Thread Paddy
On Aug 13, 7:09 pm, Ariel Balter [EMAIL PROTECTED] wrote:
 http://mail.python.org/pipermail/python-list/2001-August/100288.html

 Did you ever finish writing this?

 --
 00

 Ariel Balter

 Swain Hall West 025
 Department of Physics
 Indiana University, Bloomington
 737 E Third Street, 47404

 [EMAIL PROTECTED]

 Office: (812) 855-2441
 Home: (812) 332-2721

There is this (untried): http://home.gna.org/oomadness/en/editobj/index.html

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


Re: Drawing a graph

2007-08-13 Thread markacy
On 12 Sie, 21:09, Ghirai [EMAIL PROTECTED] wrote:
 Hello list,

 I need to draw a graph, 2 axes, 2D, nothing fancy.
 One of the axes is time, the other one is a series of integers.

 I don't care much about the output format.

 Are there any specialized libraries for this, or should i use PIL?

 Thanks.

 --
 Regards,
 Ghirai.

Matplotlib (http://matplotlib.sourceforge.net/)

Cheers,
Marek

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


►ENJOY free satellite tv on your pc◄

2007-08-13 Thread Lisa Jones
The New Way To Enjoy Satellite TV on your PC!

• Watch all your favorite shows on your Computer from anywhere in the
World!
• Save 1000's of $$$ over many years on cable and satellite bills
• Plus Get FREE Unlimited Downloads Movies, MP3s Music, etc !!!
• INSTANT DOWNLOAD

For More Details: http://tvonpc.freeweb7.com

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

Re: ANN: Compyler 0.1

2007-08-13 Thread olsongt
 Grant Olson wrote:
  Compyler is a pre-alpha x86 native code compiler.

 In what ways is this similar or different to Shed 
 Skin?http://mark.dufour.googlepages.com/

 --Irmen

I've never actually downloaded shedskin, but my understanding is that
it:

  + does type inference for speed, but means you're working with a
subset of python.

  + Generates C++ so you need an intermediate compiler (probably only
an issue on windows)

  + Generates code via the AST.

OTOH, compyler:

  + has the exact same semantics as compiler code.  I was more
concerned with this than performance payoffs.

  + generates .COFF files that are ready for linking.

  + Skips syntax tree processing and just assumes the default bytecode
is a good enough starting point.

I was going to say you couldn't make a .pyd in ShedSkin, but it looks
like you can do that too.

-Grant


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


Re: ANN: Compyler 0.1

2007-08-13 Thread olsongt

   + has the exact same semantics as compiler code.  I was more


This should read exact same semantics as python code

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


Re: Eclipse/PyDev question

2007-08-13 Thread Fabio Zadrozny
On 8/13/07, king kikapu [EMAIL PROTECTED] wrote:

 Ah, i forgot another one:

 as any project evolves, you need to organize it in directories. So, i
 have a project named Dev and Eclipse has provided me (in Navigator)
 with Dev and Src. Inside Src i put my .py files. Let's say that i
 want to create a directory there (will i make it in Src or in Dev)
 to put other .py files. I tried adding a Folder, i also tried to add
 a Pydev Source Folder, either way i cannot refer to these files from
 a .py located in Src directory with the usual from folderA
 import...It does not understand the folder structure and i am pretty
 sure i am missing something obvious here...


You have to set as source folders the exact same folders you'd usually put
into your pythonpath (that's one level before the module you're going to
import). Details on how to do that can be found at:
http://fabioz.com/pydev/manual_101_root.html

Cheers,

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

Re: Help with optimisation

2007-08-13 Thread Bruno Desthuilliers
special_dragonfly a écrit :
 Hello,
(snip)
 The function doesn't return anything, but it's called often enough and 
 depending on the optimisation I'll be able to use the same style in other 
 areas of the program.
 
 previous code:
 def CreatePerson(text_buffer):
 dom=xml.dom.minidom.parseString(text_buffer)
 reflist = dom.getElementsByTagName('Country')
 Country = reflist[0].firstChild.nodeValue
 reflist = dom.getElementsByTagName('Age')
 Age = reflist[0].firstChild.nodeValue
 reflist = dom.getElementsByTagName('Surname')
 Surname = reflist[0].firstChild.nodeValue
 reflist = dom.getElementsByTagName('Forename')
 Forename = reflist[0].firstChild.nodeValue
 cursor.execute('INSERT INTO Person VALUES(?,?,?)', (Forename + - + 
 Surname, Age, Country))
 connection.commit()
 
 I've changed it now to this:
 def CreatePerson(text_buffer):
 dom=xml.dom.minidom.parseString(text_buffer)
 elements=['Country','Age','Surname','Forename']
 Values=[]
 for element in elements:
 reflist=dom.getElementsByTagName(element)
 Values.append(reflist[0].firstChild.nodeValue)
 # I can get away with the above because I know the structure of the 
 XML
 cursor.execute('INSERT INTO Person 
 VALUES(?,?,?)',(Forename+-+Surname,Age,Country))
 connection.commit()

A common python optimisation trick is to stote local references to save 
on attribute lookup time, ie:

# local ref to parseString
import dom
dom_parseString=xml.dom.minidom.parseString

def CreatePerson(text_buffer):
 dom = dom_parseString(text_buffer)
 elements=['Country','Age','Surname','Forename']
 values=[]
 getElementByTagName = dom.getElementsByTagName
 for element in elements:
 reflist = getElementsByTagName(element)
 values.append(reflist[0].firstChild.nodeValue)


But as Alex already pointed out, you'd be better using (c)ElementTree.

 They both seem ugly IMO (read: longer than intuitively necessary),

I'd say this is a common problem with XML :-/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there anybody using __del__ correctly??

2007-08-13 Thread Steven Bethard
Michele Simionato wrote:
 SPECIALMETHODS = ['__%s__' % name for name in
 '''
 abs add and call concat contains delitem delslice div eq floordiv ge
 getitem
 getslice gt iadd iand iconcat idiv ifloordiv ilshift imod imul index
 inv invert
 ior ipow irepeat irshift isub iter itruediv ixor le len lshift lt mod
 mul ne neg
 not or pos pow repeat repr rshift setitem setslice str sub truediv
 xor
 '''.split()]
 
 def add_special_method(cls, name):
 def meth(self, *args):
 return getattr(self, name)(*args)
 meth.__name__ = name
 setattr(cls, name, meth)
 for name in SPECIALMETHODS:
 add_special_method(Impostor, name)
 
 In this way the Impostor can emulate even the special methods. Here is
 an example:
 
 class C(object):
 ...
 pass
 ...
 c=Impostor(C())
 print c
 __main__.C object at 0x102a390
 
 Notice that the impostor is calling the __str__ method of C, so it
 really looks like a C object. Moreover
 
 c.__class__
 class '__main__.C'
 
 and
 
 isinstance(c, C)
 True
 
 so the Impostor is doing a damn pretty good job of imposture for C
 objects. Of course it does what it can, and it cannot impersonate C
 objects completely:

 type(c)
 class '__main__.Impostor'
 
 so code using checks like ``type(c) is C`` would break and the
 approach here cannot be considered more than a hack.

That's fun. =)

I don't really think it's too much of a hack either. ``type(c) is C`` is 
expected to fail for proxy classes, which is why everyone keeps getting 
told to use ``isinstance(c, C)`` instead.  In Py3K, when ``isinstance`` 
becomes overloadable, it's going to be even more of a mistake to write 
``type(c) is C``.

That said, I doubt I'd want to slow down all attribute access on my 
class just to do some cleanup, when it's probably better to just tell 
everyone to use a ``with`` block. ;-)

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


Re: Drawing a graph

2007-08-13 Thread Kurt Smith
On 8/12/07, Ghirai [EMAIL PROTECTED] wrote:
 Hello list,

 I need to draw a graph, 2 axes, 2D, nothing fancy.
 One of the axes is time, the other one is a series of integers.

 I don't care much about the output format.

 Are there any specialized libraries for this, or should i use PIL?

 Thanks.

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


Checkout matplotlib: http://matplotlib.sourceforge.net/

Powerful (esp. with IPython), clean implementation, very nice output,
IMHO.  It does depend on some other things; primarily numpy and some
sort of backend for displaying figures (usually can use a default
backend -- e.g. Tkinter).  Otherwise you can plot directly to file.
May not be what you're looking for if you want something quick.

HTH,

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


Re: Configuring apache to execute python scripts using mod_python handler

2007-08-13 Thread 7stud
On Aug 13, 5:16 am, joe jacob [EMAIL PROTECTED] wrote:
 I configured apache to execute python scripts using mod_python
 handler. I followed below mentioned steps to configure apache.

 1. In http.conf I added

   Directory D:/softwares/Apache2.2/htdocs
   AddHandler mod_python .py
   PythonHandler mptest
   PythonDebug On
   /Directory

 2. Then I added the line LoadModule python_module modules/
 mod_python.so to http.conf.

 Then I tried execute the python script mentioned below from browser.

 from mod_python import apache
 def handler(req):
 req.content_type = 'text/plain'
 req.write(Hello World!)
 return apache.OK

 Then I am getting the following error

 Traceback (most recent call last):

   File D:\softwares\Python25\Lib\site-packages\mod_python
 \importer.py, line 1537, in HandlerDispatch
 default=default_handler, arg=req, silent=hlist.silent)

   File D:\softwares\Python25\Lib\site-packages\mod_python
 \importer.py, line 1202, in _process_target
 module = import_module(module_name, path=path)

   File D:\softwares\Python25\Lib\site-packages\mod_python
 \importer.py, line 304, in import_module
 return __import__(module_name, {}, {}, ['*'])

 ImportError: No module named mptest

 I am using Apache 2.2.4, python 2.5 and mod_python-3.3.1.win32-py2.5-
 Apache2.2.

 I am able to execute python scripts by configuring apache to execute
 the cgi scripts. But I want to execute it using mod_python as it is
 faster compared to cgi mode. Someone please help me on this issue.

1) In the mod_python tutorial it says:

---
2.4 Testing

...
...

2. Add the following Apache directives, which can appear in either the
main server configuration file, or .htaccess. If you are going to be
using the .htaccess file, you will not need the Directory tag below
(the directory then becomes the one in which the .htaccess file is
located), ***and you will need to make sure the AllowOverride
directive applicable to this directory has at least FileInfo
specified. (The default is None, which will not work.)

Directory /some/directory/htdocs/test
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
/Directory


Note the last sentence in the directions above.  I explain what is
needed for that part at the link in (2) below.  Also note the
directory listed in the opening Directory tag:

/some/directory/htdocs/test

That specifies a sub directory of htdocs.  That's because the htdocs
directory has its own Directory tag in httpd.conf, which specifies
the things you can to with it.  If you look around in httpd.conf, you
will see the Directory tag that applies to htdocs.  Mine looks like
this:

Directory /Library/Apache2/htdocs
...
...
Directory

The mod_python Testing tutorial wants you to create your own sub
directory in htdocs, so that you can specify your own rules for that
directory.  You're probably getting errors because you have two
Directory tags in your httpd.conf file for the htdocs directory, and
the second tag is overwriting the first one.


2) You can see the latter part of this thread for what I did to get
mptest.py to work:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/3ccaf303b8b4fd31/ea2645ec03370fb2?lnk=gstq=mod_pythonrnum=1#ea2645ec03370fb2


3) I put any Directory tags I added to httpd.conf below the first
Directory tag in http.conf, which is this one:

Directory /Library/Apache2/htdocs

so that the ones lower down in the file will override the previous
tags if there is a conflict.

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


Re: which IDE is highly recommended in Windows OS

2007-08-13 Thread James Matthews
www.wingide.com

On 8/13/07, Ge Chunyuan [EMAIL PROTECTED] wrote:

 On Aug 13, 10:24 am, _spitFIRE [EMAIL PROTECTED] wrote:
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  Ge Chunyuan wrote:
   hi Group:
 
   I am a new comer for Python, I wonder which IDE is recommended in
   Windows OS.
   Can anyone give some suggestion.
 
   Thanks indeed
   Ge Chunyuan
 
  - - Stani's Python Editor
  (
 http://www.softpedia.com/get/Programming/Coding-languages-Compilers/S...)
  - - Black Adder (http://www.thekompany.com/products/blackadder/)
  - - Zeus (http://www.zeusedit.com/python.html)
  - - PyScripter (http://mmm-experts.com/Products.aspx?ProductId=4)
  - - ActivePython (http://www.activestate.com/)
  - - IDLE (http://www.python.org/idle/doc/idle2.html)
 
  and depending on how you define IDEs, you can also decide whether or not
 to
  include, the following
  - - emacs
  - - vim
  - - scite
  ...
 
  - --
  _ _ _]{5pitph!r3}[_ _ _
  __
  I'm smart enough to know that I'm dumb.
- Richard P Feynman
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.6 (GNU/Linux)
  Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
 
  iD8DBQFGv8DSA0th8WKBUJMRAqGcAJ9hhMp3tyS7XmBZT2+fol/A69j4jwCfXNya
  xQTmmDlDF5BAfiWkrSW3TuQ=
  =902n
  -END PGP SIGNATURE-

 thanks buddy, I am now using ActivePython, actually it is beyond my
 expectation:)

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




-- 
http://www.goldwatches.com/
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Assignments and Variable Substitution

2007-08-13 Thread brad
I'd like to do something like this:

var = '123'
%s = [], %var

So that, in the end, var is '123' and an empty list is named '123' as 
well. The list assignments are created during a loop.

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


Re: Assignments and Variable Substitution

2007-08-13 Thread srage
On Aug 13, 1:00 pm, brad [EMAIL PROTECTED] wrote:
 I'd like to do something like this:

 var = '123'
 %s = [], %var

 So that, in the end, var is '123' and an empty list is named '123' as
 well. The list assignments are created during a loop.

 Thanks,
 Brad

You probably want to use a dictionary to store your lists... code
like:

variableDict = {}
variableDict[var] = ['value1', 'value2', 'value3']

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


Re: is there anybody using __del__ correctly??

2007-08-13 Thread Michele Simionato
On Aug 13, 6:26 pm, Steven Bethard [EMAIL PROTECTED] wrote:
 I doubt I'd want to slow down all attribute access on my
 class just to do some cleanup, when it's probably better to just tell
 everyone to use a ``with`` block. ;-)

Amen. The point is that finding an easy upgrade path for current code
using __del__ does not look easy at all. Maybe we should be bold,
remove __del__ in Py3K, say to everybody to use 'with', and force
people to rewrite their code, ignoring the complaints from the
big frameworks guys (anyway, they are already complaining ;)


 Michele Simionato

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


C++ Binding with Threads

2007-08-13 Thread Pablo Yabo
Hello,

I want to embed Python in an application and use an API of the application
from Python.
The application uses a library that creates several threads and I the users
of the application will write Python scripts handling this events.

The problem is that I having problems with threads. I saw that I have to
PyEval_InitThreads and then PyThreadState_New and PyThreadState_Swap from
the new thread but this way to solve the problem doesn't work for me because
I need to let 2 or more threads run at the SAME time.
The interpreter lock doesn't let them run at the same time so I'm looking
for another solution. I saw Py_NewInterpreter and I tried to use it but it
doesn't work if I don't keep the lock.

Can anyone help me to solve this issue or tell me 'Forget it!'?


Thanks on advance,
Pablo Yabo
-- 
http://mail.python.org/mailman/listinfo/python-list

C++ Binding with Threads

2007-08-13 Thread Pablo Yabo
Hello,

I want to embed Python in an application and use an API of the application
from Python.
The application uses a library that creates several threads and I the users
of the application will write Python scripts handling this events.

The problem is that I having problems with threads. I saw that I have to
PyEval_InitThreads and then PyThreadState_New and PyThreadState_Swap from
the new thread but this way to solve the problem doesn't work for me because
I need to let 2 or more threads run at the SAME time.
The interpreter lock doesn't let them run at the same time so I'm looking
for another solution. I saw Py_NewInterpreter and I tried to use it but it
doesn't work if I don't keep the lock.

Can anyone help me to solve this issue or tell me 'Forget it!'?


Thanks on advance,
Pablo Yabo
--
http://www.nektra.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Python in Chinese

2007-08-13 Thread Paul McGuire
Back in May, there was quite an extensive discussion of whether or not
Python should support Unicode identifiers (with the final result being
that this would be supported in Python 3).  In my periodic googling
for pyparsing users, I stumbled upon Zhpy, a preprocessor that renders
on the fly Chinese Python keywords and indentifiers written using
traditional Chinese characters into ASCII counterparts, and then
executes the resulting script.  I was very intrigued at the idea, and
I thought back to Martin v. Löwis's PEP.  The Zhpy approach will work
with current versions of Python (going back to 2.3, since pyparsing
requires that version).

You can view examples at the pyparsing Who's Using Pyparsing wiki
page - http://pyparsing.wikispaces.com/WhosUsingPyparsing#Zhpy.

Given the breadth of response to Martin v. Löwis's post, I'm curious
as to what the reaction might be to something like Zhpy.

-- Paul

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


Re: decorators - more than just syntactic sugar

2007-08-13 Thread Alexander Schmolck
Michele Simionato [EMAIL PROTECTED] writes:

 On Aug 11, 8:30 pm, Helmut Jarausch [EMAIL PROTECTED] wrote:
 Hi,

 are decorators more than just syntactic sugar in python 2.x and what
 about python 3k ?

 Well, I argued may times that syntactic sugar is important (all Turing
 complete languages differs by syntactic sugar only)

Although I agree that mere syntactic sugar matters, I think you're
overstating the point. I would argue that most people would understand
syntactic sugar as equivalent to a (very) localized program transformation.
Things like first class continuations clearly aren't syntactic sugar in that
sense.



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


Re: Fatest standard way to sum bytes (and their squares)?

2007-08-13 Thread Alexander Schmolck

Alexander Schmolck [EMAIL PROTECTED] writes:

 Erik Max Francis [EMAIL PROTECTED] writes:

 Alexander Schmolck wrote:

 Is this any faster?

  ordSum, orsSumSq = (lambda c:c.real,c.imag)(sum(complex(ord(x),ord(x)1)
 for x in data))

 That's pretty clever, but I neglected to mention that I need to accumulate 
 the
 sums as ints/longs to avoid losing precision, so converting to floating point
 isn't an optional.

 I think you can safely use this trick (provided it really makes things faster)
 provided you sum blocks no larger than 2**(53-8) bytes; 

Forgot about the squares; make this 2**(53-16); still pretty big.

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


Re: Python in Chinese

2007-08-13 Thread Martin v. Löwis
Paul McGuire schrieb:
 Back in May, there was quite an extensive discussion of whether or not
 Python should support Unicode identifiers (with the final result being
 that this would be supported in Python 3).  In my periodic googling
 for pyparsing users, I stumbled upon Zhpy, a preprocessor that renders
 on the fly Chinese Python keywords and indentifiers written using
 traditional Chinese characters into ASCII counterparts, and then
 executes the resulting script.  

Interesting!

Notice what they do to the identifiers - when translating to English,
the just number them. I wonder what this will do to backtraces,
cross-module imports, and such...

With Python 3, they can restrict themselves to just translating
keywords, and leave all identifiers in place.

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


  1   2   >