Re: How do I get the URL of the active tab in Firefox/IE/Chrome?

2010-11-28 Thread Tim Harig
On 2010-11-29, Michel Claveau - MVP  
wrote:
> Hello!
>
>> The "InternetExplorer.Application" automation object doesn't contain 
>> any way to manipulate tabs directly
>
> False. Try this example:
>   import win32com.client
>   for instance in 
> win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'):
>   print instance,"  URL :",instance.LocationURL

A Shell collection object != a InternetExplorer.Application object.
The problem with using a ShellWindows object is that you could easily
connect to the wrong instance, especially since the OP doesn't know the
LocationURL of the instance that he is looking for.  That is why I asked
for clarification.  Once we know what the OP is trying to do, we can
make sure that he has a reliable method to connect to the proper instance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Urgent requirement for Php Developer

2010-11-28 Thread Priyanka Kalpande
Urgent requirment for Python programmer. For the further details
contact us on 9930698901 or eMail your resumes to hr.mana...@pfhit.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Next Melbourne PUG meeting Monday 6th of December

2010-11-28 Thread Ben Finney
Richard Jones  writes:

> The Melbourne Python Users Group will be meeting 6PM next Monday, the
> 6th of December at RMIT University.
>
> For details see http://bit.ly/mpug.

Or for those who prefer their URLs to avoid unnecessary points of
failure, that's http://wiki.python.org/moin/MelbournePUG>.

Hope to see you there!

-- 
 \   “Killing the creator was the traditional method of patent |
  `\protection” —Terry Pratchett, _Small Gods_ |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help required with Tranformation of coordinate system

2010-11-28 Thread BansalMaddy
On Nov 29, 2:03 am, Terry Reedy  wrote:
> On 11/28/2010 6:36 PM, BansalMaddy wrote:
>
> > hi all!
> > i need a help in python! i am struggling to implement this since last
> > 2/3 days. suppose i have a 2D plot (say y=x**2).
> > now on the same plot i want to transform my origin of coordinate
> > system to a point (x',y' on this curve and again create a new plot
> > with origin at x',y')
> > can somebody help me how can i offset my cordinate system ...
>
> Plot y-y' == (x-x')**2 - y' against x-x'.
>
> --
> Terry Jan Reedy

Thanks for the reply, but i was looking for some built in function to
offset coordinate system, because my problem is not very simple as i
mentioned in my query, actually i need to plot some kind of closed
loops.
e..g
1. curve will be y=f(x) then i have to search for a point on y=f(x)
curve and i have to plot another function y'=f(x'), where x' and y'
are (-2x) and (-2y) repectively.
2. then again i hve to search for a pont on y'=f(x') and do some third
kind of operations, on that.
in that case if can shift my coordinate system to desired location on
curve the computation becomes simpler.

THanks again, hope i made myself clear :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I get the URL of the active tab in Firefox/IE/Chrome?

2010-11-28 Thread Michel Claveau - MVP
Hello!

> The "InternetExplorer.Application" automation object doesn't contain 
> any way to manipulate tabs directly

False. Try this example:
  import win32com.client
  for instance in 
win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'):
  print instance,"  URL :",instance.LocationURL

@-salutations
-- 
Michel Claveau 


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


Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-28 Thread Raymond Hettinger
On Nov 28, 4:36 am, coldpizza  wrote:
> Did you try google code search? It is *not* the same as google code
> hosting.
> The site ishttp://www.google.com/codesearchand you can select Python
> in the 'language' dropdown.

Yes, I use Google's code search frequently and did try it for super().
However, you still need to drill into many of the hits manually,
because it is difficult to disambiguate a single inheritance use
of super() (which is very common) from a design with cooperative
multiple inheritance.  You have to read a lot of code and can still
come
up empty handed.


Raymond

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


How do you find out what's happening in a process?

2010-11-28 Thread Leo Jay
Hi all,

I'd like to know how do you guys find out what's happening in your
code if the process seems not work.
In java, I will use jstack  to check stacks of threads and lock status.
But I don't know how to do it in python.

-- 
Best Regards,
Leo Jay
-- 
http://mail.python.org/mailman/listinfo/python-list


How do I get the URL of the active tab in Firefox/IE/Chrome?

2010-11-28 Thread He Jibo
Hi,
I am writing a small program, which needs to get the URL of the active
tab in either of firefox, internet exploerer or chrome.
My need is similar as the one posted at,
http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox-ie-chrome

I did a lot of Googling, and get the following code. The following
code can get the url of the first tab in internet explorer. My
question is, how can I get the url of the current active tab? Thanks.

'''
http://efreedom.com/Question/1-2555905/Get-Internet-Explorer-Address-Bar-Python
http://blogs.msdn.com/b/oldnewthing/archive/2005/07/05/435657.aspx
http://mail.python.org/pipermail/python-win32/2004-June/002040.html
http://code.activestate.com/recipes/302324-browser-automation-tool-py-class-file/
'''
from win32com.client import Dispatch
import win32api, win32con,win32gui


SHELL = Dispatch("Shell.Application")

def get_ie(shell):
for win in shell.Windows():
#print win
if win.Name == "Windows Internet Explorer":
return win
return None

def main():
ie = get_ie(SHELL)
if ie:
print ie.LocationURL
print ie.LocationName
print ie.ReadyState
print ie
print ie.Document.title
print ie.Document.location
print ie.Document.forms

#title = win32gui.GetWindowText(ie)
#print title

else:
print "no ie window"

if __name__ == '__main__':
main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Next Melbourne PUG meeting Monday 6th of December

2010-11-28 Thread Richard Jones
Hi all,

The Melbourne Python Users Group will be meeting 6PM next Monday,
the 6th of December at RMIT University.

For details see http://bit.ly/mpug.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLite date fields

2010-11-28 Thread Tim Roberts
Duncan Booth  wrote:

>Tim Roberts  wrote:
>
>>>However, when it comes to writing-back data to the table, SQLite is
>>>very forgiving and is quite happy to store '25/06/2003' in a date
>>>field, 
>> 
>> SQLite is essentially typeless.  ALL fields are stored as strings,
>> with no interpretation.  You can store whatever you want in any
>> column.  The column types are basically there to remind YOU how to
>> handle the data. 
>
>Not all fields are stored as strings; they may also be stored as 
>integer, floating point values or binary data.

Sorry.  Up through SQLite version 2, ALL fields were stored as strings,
even if you typed them as integers or floats.  I see that has changed in
v3.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: ActivePython 2.6.6.17 is now available

2010-11-28 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.6.6.17, a complete, 
ready-to-install binary distribution of Python 2.6.

http://www.activestate.com/activepython/downloads

What's New in ActivePython-2.6.6.17
===

*Release date: 19-Nov-2010*

New Features & Upgrades
---

- Security upgrade to openssl-0.9.8p
- Upgrade to PyPM 1.2.5; noteworthy changes:

  - New command 'pypm log' to view log entries for last operation
  - depgraph bug fixes (Bug #88664, #88825)
  - Fix: ignore empty lines in requirements.txt
  - Ignore comments (starting with #) in the requirements file

What's New in ActivePythonEE-2.6.6.16
=

*Release date: 05-Nov-2010*

New Features & Upgrades
---

- Upgrade to PyPM 1.2.3; noteworthy changes:

  - Faster startup (performance) especially on Windows.
  - Rewrite of an improved dependency algorithm (#88038)
  - install/uninstall now accepts the --nodeps option
  - 'pypm install ' to directly download and install a .pypm file
  - 'pypm show' shows other installed packages depending on the shown package
  - 'pypm show' accepts --rdepends to show the list of dependents
  - 'pypm show' shows extra dependencies (for use in the 'install' cmd)
  - 'pypm show' lists all available versions in the repository
  - 'pypm freeze' to dump installed packages as requirements (like 'pip freeze')
  - Support for pip-stye requirements file ('pypm install -r requirements.txt')
  - Bug #87764: 'pypm upgrade' will not error out for missing packages
  - Bug #87902: fix infinite loops with cyclic package dependencies (eg: plone)
  - Bug #88370: Handle file-overwrite conflicts (implement --force)

- Upgraded the following packages:

  - Distribute-0.6.14
  - pip-0.8.1
  - SQLAlchemy-0.6.5
  - virtualenv-1.5.1


What is ActivePython?
=

ActivePython is ActiveState's binary distribution of Python. Builds for 
Windows, Mac OS X, Linux are made freely available. Solaris, HP-UX and AIX 
builds, and access to older versions are available in ActivePython Business, 
Enterprise and OEM editions:

http://www.activestate.com/python

ActivePython includes the Python core and the many core extensions: zlib and 
bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3) 
database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for 
Tkinter, ElementTree for XML processing, ctypes (on supported platforms) for 
low-level library access, and others. The Windows distribution ships with 
PyWin32 -- a suite of Windows tools developed by Mark Hammond, including 
bindings to the Win32 API and Windows COM.

ActivePython 2.6, 2.7 and 3.1 also include a binary package manager for Python 
(PyPM) that can be used to install packages much easily. For example:

  C:\>pypm install mysql-python
  [...]

  C:\>python
  >>> import MySQLdb
  >>>

See this page for full details:

http://docs.activestate.com/activepython/2.6/whatsincluded.html

As well, ActivePython ships with a wealth of documentation for both new and 
experienced Python programmers. In addition to the core Python docs, 
ActivePython includes the "What's New in Python" series, "Dive into Python", 
the Python FAQs & HOWTOs, and the Python Enhancement Proposals (PEPs).

An online version of the docs can be found here:

http://docs.activestate.com/activepython/2.6/

We would welcome any and all feedback to:

activepython-feedb...@activestate.com

Please file bugs against ActivePython at:

http://bugs.activestate.com/enter_bug.cgi?product=ActivePython

Supported Platforms
===

ActivePython is available for the following platforms:

- Windows/x86   (32-bit)
- Windows/x64   (64-bit) (aka "AMD64")
- Mac OS X  (32-bit and 64-bit; 10.5+)
- Linux/x86 (32-bit)
- Linux/x86_64  (64-bit) (aka "AMD64")

- Solaris/SPARC (32-bit and 64-bit) (Business, Enterprise or OEM edition only)
- Solaris/x86   (32-bit)(Business, Enterprise or OEM edition only)
- HP-UX/PA-RISC (32-bit)(Business, Enterprise or OEM edition only)
- HP-UX/IA-64   (32-bit and 64-bit) (Enterprise or OEM edition only)
- AIX/PowerPC   (32-bit and 64-bit) (Business, Enterprise or OEM edition only)

More information about the Business Edition can be found here:

http://www.activestate.com/business-edition

Custom builds are available in the Enterprise Edition:

http://www.activestate.com/enterprise-edition

Thanks, and enjoy!

The Python Team

--
Sridhar Ratnakumar
Python Developer
ActiveState, The Dynamic Language Experts

sridh...@activestate.com
http://www.activestate.com

Get insights on Open Source and Dynamic Languages at 
www.activestate.com/blog

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


Re: Help required with Tranformation of coordinate system

2010-11-28 Thread Terry Reedy

On 11/28/2010 6:36 PM, BansalMaddy wrote:

hi all!
i need a help in python! i am struggling to implement this since last
2/3 days. suppose i have a 2D plot (say y=x**2).
now on the same plot i want to transform my origin of coordinate
system to a point (x',y' on this curve and again create a new plot
with origin at x',y')
can somebody help me how can i offset my cordinate system ...


Plot y-y' == (x-x')**2 - y' against x-x'.


--
Terry Jan Reedy

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


Re: list of regex special characters

2010-11-28 Thread Ben Finney
Tim Chase  writes:

> On 11/28/2010 05:58 PM, goldtech wrote:
> > I am looking for a list of special character in python regular
> > expressions that need to be escaped if you want their literal
> > meaning.
>
> Trust the re module to tell you:
>
>  >>> import re
>  >>> chars = [chr(i) for i in range(0,256)]
>  >>> escaped = [c for c in chars if re.escape(c) != c]

Note that, according to its docstring, ‘re.escape’ doesn't distinguish
characters that *need to be* escaped for their literal meaning; it
simply escapes any non-alphanumeric character.

>  >>> can_use_unescaped = [c for c in chars if re.escape(c) == c]

Right. There are three classes of character for this purpose:

* those that have a literal meaning *only if* escaped
* those that have literal meaning whether or not they are escaped
* those that have a literal meaning *only if not* escaped

The ‘re.escape’ function, according to its docstring, simply says any
non-alphanumerics can safely be said to exist in one of the first two
classes, and both are safe to escape without bothering to distinguish
between them.

The OP was asking for the first class specifically, but I question
whether that's actually needed for the purpose.

-- 
 \   “The cost of education is trivial compared to the cost of |
  `\ ignorance.” —Thomas Jefferson |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list of regex special characters

2010-11-28 Thread Tim Chase

On 11/28/2010 05:58 PM, goldtech wrote:

I am looking for a list of special character in python regular
expressions that need to be escaped if you want their literal meaning.

I searched and can not find the list. Any help appreciated.


Trust the re module to tell you:

 >>> import re
 >>> chars = [chr(i) for i in range(0,256)]
 >>> escaped = [c for c in chars if re.escape(c) != c]
 >>> print len(escaped)
 194
 >>> print escaped
 [...]
 >>> can_use_unescaped = [c for c in chars if re.escape(c) == c]

(adjust "chars" accordingly if you want to check unicode 
characters too).


-tkc



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


Re: list of regex special characters

2010-11-28 Thread Ben Finney
goldtech  writes:

> I am looking for a list of special character in python regular
> expressions that need to be escaped if you want their literal meaning.

You can avoid caring about that by using ‘re.escape’, which escapes any
characters in its input character that are not alphanumeric.

> I searched and can not find the list. Any help appreciated.

>>> import re
>>> help(re)
…
DESCRIPTION
…
The special characters are: …

-- 
 \ “I got some new underwear the other day. Well, new to me.” —Emo |
  `\   Philips |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


list of regex special characters

2010-11-28 Thread goldtech
I am looking for a list of special character in python regular
expressions that need to be escaped if you want their literal meaning.

I searched and can not find the list. Any help appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Help required with Tranformation of coordinate system

2010-11-28 Thread BansalMaddy
hi all!
i need a help in python! i am struggling to implement this since last
2/3 days. suppose i have a 2D plot (say y=x**2).
now on the same plot i want to transform my origin of coordinate
system to a point (x',y' on this curve and again create a new plot
with origin at x',y')
can somebody help me how can i offset my cordinate system ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparing floats

2010-11-28 Thread Nobody
On Sat, 27 Nov 2010 18:23:48 -0500, Terry Reedy wrote:

>> Therefore, to implement this multiplication operation I need to have a
>> way to verify that the float tuples C and D are "equal".
> 
> I might try the average relative difference:
> sum(abs((i-j)/(i+j)) for i,j in zip(C,D))/n # assuming lengths constant

The division is unstable if i and j are close to zero.

For scalars, I'd use:

abs(i-j) <= epsilon * (1 + abs(i+j))

This amounts to a relative error check for large values and an absolute
error check for values close to zero.

For a vector, I'd check that the above holds for all pairs.

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


Re: Using property() to extend Tkinter classes but Tkinter classes are old-style classes?

2010-11-28 Thread Terry Reedy

On 11/28/2010 3:47 PM, pyt...@bdurham.com wrote:

I had planned on subclassing Tkinter.Toplevel() using property() to wrap
access to properties like a window's title.
After much head scratching and a peek at the Tkinter.py source, I
realized that all Tkinter classes are old-style classes (even under
Python 2.7).
1. Is there a technical reason why Tkinter classes are still old-style
classes?


To not break old code. Being able to break code by upgrading all classes 
in the stdlib was one of the reasons for 3.x.


--
Terry Jan Reedy

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


Re: remote control firefox with python

2010-11-28 Thread News123
On 11/28/2010 06:19 PM, Tim Harig wrote:
> On 2010-11-28, News123  wrote:
>> Thanks in advance for any pointers ideas.
> 
> google XPCOM
thanks a lot
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Standard module implementation

2010-11-28 Thread Chris Rebert
On Sun, Nov 28, 2010 at 6:08 AM, candide  wrote:
> I was wondering if all the standard module are implemented in C. For
> instance, I can't find a C implementation for the minidom xml parser under
> Python 2.6.

As was already said, no; a significant portion if not the majority of
the std lib is written in pure Python, not C.

You can usually determine how a module is implemented by looking at
the file extension of the module's __file__ attribute. For example:
$ python
Python 2.6.6 (r266:84292, Oct 12 2010, 14:31:05)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle # obviously in C
>>> cPickle.__file__
'/sw/lib/python2.6/lib-dynload/cPickle.so'
>>> import pickle # pure Python version
>>> pickle.__file__
'/sw/lib/python2.6/pickle.pyc'

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Using property() to extend Tkinter classes but Tkinter classes are old-style classes?

2010-11-28 Thread python
I had planned on subclassing Tkinter.Toplevel() using property()
to wrap access to properties like a window's title.

After much head scratching and a peek at the Tkinter.py source, I
realized that all Tkinter classes are old-style classes (even
under Python 2.7).

1. Is there a technical reason why Tkinter classes are still
old-style classes?

2. Is there a technique I can use to get property() to work with
old-style classes? Or, must I use composition and wrap a
reference to a Tkinter.Toplevel() window in a new style class?

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


Re: How do I get the URL of the active tab in Firefox/IE/Chrome?

2010-11-28 Thread Tim Harig
On 2010-11-28, He Jibo  wrote:
> I did a lot of Googling, and get the following code. The following
> code can get the url of the first tab in internet explorer. My
> question is, how can I get the url of the current active tab? Thanks.

It would be beneficial to know what your ultimate goal is.  The
"InternetExplorer.Application" automation object doesn't contain any way to
manipulate tabs directly; but, there are likely less direct methods of
achieving whatever you are trying to accomplish if you let us know what
that is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-28 Thread André Malo
* Steve Holden wrote:

> Even inheritance itself isn't as useful as it at first
> appears, and composition turns out in practice to be much more useful.
> That goes double for multiple inheritance.

Amen.

nd
-- 
my @japh = (sub{q~Just~},sub{q~Another~},sub{q~Perl~},sub{q~Hacker~});
my $japh = q[sub japh { }]; print join   #
 [ $japh =~ /{(.)}/] -> [0] => map $_ -> ()  #André Malo #
=> @japh;# http://www.perlig.de/ #
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Subprocesses and Ctrl-C handling on windows

2010-11-28 Thread Perry Johnson
On 2010-11-28, Perry Johnson wrote:

> I have a python script which spawns a subprocess that takes a few
> seconds to complete. If I hit Ctrl-C while the subprocess is
> executing, sometimes the python script and the subprocess end silently
> and I get back to the shell prompt and sometimes I get the
> KeyboardInterrupt exception. Is there any kind of method underneath
> this seemingly random behavior?

False alarm, please disregard the quoted post.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.1.3

2010-11-28 Thread Roy Smith
In article 
<53c154fa-e957-4266-ad12-eaf8c2ef3...@35g2000prt.googlegroups.com>,
 Gnarlodious  wrote:

> Well I don't know what a readline is, but I upgraded from 3.1.1 and it
> was working fine.
> 
> I might also add that the downarrow is also broken: ^[[B
> 
> -- Gnarlie

Readline is the (very cool) library which handles all the interactive 
line editing, including the up and down arrows.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TDD in python

2010-11-28 Thread Terry Reedy

On 11/28/2010 5:58 AM, Rustom Mody wrote:

Does anyone know of something like this for python?

http://www.vimeo.com/13240481


"This is the first in a series of videos demonstrating TDD in C++ using 
the Eclipse CDT and CppUTest"


TDD = Test-Driven Development is a development philosophy applicable to 
any language. It is not all that different from Hypothesis-Driven 
Science (HDS) (I just made that connection!)


I suspect CppUTest is derived from Java JUnit (or whatever), as is 
Python's unittest. Python also has doctest and other public and private 
test frameworks and function.


--
Terry Jan Reedy

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


Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-28 Thread Kirill Simonov

Hi Raymond,

We've been using cooperative inheritance to implement stacked utilities 
such as WSGI middleware or connecting to a database.


An example of a WSGI middleware stack:

# Declare the interface and provide the default implementation.
class WSGI(Utility):
def __call__(self, environ, start_response):
# The main WSGI application is implemented here.
start_response("200 OK", [('Content-Type', 'text/plain')])
return ["Hello World!"]

# GZip middleware (may be defined in a different module or a plugin)
class GZIP(WSGI):
# To indicate relative position in the middleware stack
weights(100)
def __call__(self, environ, start_response):
# Call the next middleware in the stack to generate data.
# Also, need to wrap start_response here...
generator = super(GZIP, self).__call__(environ, start_response)
# Pack the output...

# Error handling middleware (defined in a different module or a plugin)
class LogErrors(WSGI):
weights(1000)
def __call__(self, environ, start_response):
# Call the next middleware in the stack, catch any errors.
try:
generator = super(LogErrors, self).__call__(environ,
 start_response)
except:
# Log errors...

# Now glue them all together
def wsgi(environ, start_response):
wsgi = WSGI() # !!!
return wsgi(environ, start_response)

The trick here is that the constructor of `WSGI` (actually, 
`Utility.__new__()`) is overridden.  Instead of producing a new instance 
of `WSGI` , it does the following:

- use `__subclasses__()` to find all components of the utility;
- order the components by their weights;
- create a new class: `type(name, list_of_components, {})`;
- return an instance of the class.

Here is another example, database connection.

# The interface, no default implementation.
class Connect(Utility):
def __init__(self, host, port, user, password, database):
self.host = host
self.port = port
self.user = user
self.password = password
self.database = database
def __call__(self):
raise NotImplementedError()

# Public API
def connect(host, port, user, password, database):
# Same trick here.
connect = Connect(host, port, user, password, database)
return connect()

# PostgreSQL implementation (defined in a plugin)
import psycopg2
class PGSQLConnect(Connect):
def __call__(self):
return psycopg2.connect(...)

# Connection pooling (defined in a plugin)
class Pooling(Connect):
weights(100)
def __call__(self):
# Check if we could reuse an existing connection
# ...
# If no free connections available
connection = super(Pooling, self).__call__()
# Save it somewhere and return it...

Note that utility instances are short-lived so any persistent state must 
be kept elsewhere.



We also use the same pattern to implement Cecil/Diesel-style 
multimethods and general predicate dispatch, but that's probably outside 
the scope of your question.


A public version of the code lives here:
https://bitbucket.org/prometheus/htsql
Unfortunately it doesn't exactly match my examples above: connection 
pooling and most of the wsgi middleware are still to be ported, 
`weights()` is missing, etc.



Hope it helps.

Thanks,
Kirill

On 11/24/2010 03:08 PM, Raymond Hettinger wrote:

I'm writing-up more guidance on how to use super() and would like to
point at some real-world Python examples of cooperative multiple
inheritance.

Google searches take me to old papers for C++ and Eiffel, but that
don't seem to be relevant to most Python programmers (i.e. a
WalkingMenu example where a submenu is both a Entry in a Menu and a
Menu itself).  Another published example is in a graphic library where
some widgets inherit GraphicalFeature methods such as location, size
and NestingGroupingFeatures such as finding parents, siblings, and
children.  I don't find either of those examples compelling because
there is no particular reason that they would have to have overlapping
method names.

So far, the only situation I can find where method names necessarily
overlap is for the basics like __init__(), close(), flush(), and
save() where multiple parents need to have their own initialization
and finalization.

If you guys know of good examples, I would appreciate a link or a
recap.

Thanks,


Raymond


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


Getting current time zone in Python in tzinfo format not implemented

2010-11-28 Thread John Nagle

   Getting the local time zone in Python is rather difficult.

As of 2008, two articles indicate that the current mechanisms
totally suck:

"Python and time zones part 2: The beast returns!":
http://regebro.wordpress.com/2008/05/10/python-and-time-zones-part-2-the-beast-returns/

"Time zones in Python – welcome to hell":
http://blog.mfabrik.com/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/

(Despite that article, there is a straightforward way to get that
information in Windows: "GetDynamicTimeZoneInformation".)

Did something useful ever get done about that?  This
ought to be in the "time" module for each platform.

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


nike jordan shoes coach, chane bag COOGI

2010-11-28 Thread dgf dg

=== http://www.stefsclothes.net ===


Handbags(Coach lv fendi d&g) $35
Tshirts (Polo ,ed hardy,lacoste) $16
Jean(True Religion,ed hardy,coogi) $30
Sunglasses(Oakey,coach,gucci,Armaini) $16
New era cap $15
Bikini (Ed hardy,polo) $25


 http://www.stefsclothes.net 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remote control firefox with python

2010-11-28 Thread Tim Harig
On 2010-11-28, News123  wrote:
> Thanks in advance for any pointers ideas.

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


Re: Python 3.1.3

2010-11-28 Thread Ned Deily
In article ,
 Roy Smith  wrote:
> I'm seeing the same behavior on a build I did of
> 
> Python 3.2a4+ (py3k:86538, Nov 19 2010, 20:52:31)
> 
> last week, also on 10.6.5.  From the configure output, it looks like it 
> found readline:
> 
> py3k$ grep -i readline config.status 
> D["HAVE_LIBREADLINE"]=" 1"
> 
> but it's not acting like it.  The Python 2.6.1 which came with the 
> system works properly.

As noted, Python 3.2 on OS X should link to the OS X copy of the BSD 
editline (libedit).  You may have to adjust your PYTHONSTARTUP script to 
use the different commands.  Here's a snippet from mine:

try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")

http://docs.python.org/py3k/library/readline.html
Also, see: man 5 editrc

BTW, python.org 3.2a4 installers for OS X are now available so you might 
not need to build your own:

http://www.python.org/download/releases/3.2/

-- 
 Ned Deily,
 n...@acm.org

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


Re: Python 3.1.3

2010-11-28 Thread Ned Deily
In article 
<2b22dfa0-41d5-4047-8cfe-7a18e00e3...@o23g2000prh.googlegroups.com>,
 Gnarlodious  wrote:
> Ah yes, sorry.
> This is Mac OSX 10.6.5, I did it build from the file at
> http://www.python.org/ftp/python/3.1.3/Python-3.1.3.tgz

For Python 3.1 on OS X, you'll need to supply a version of the GNU 
readline library, which is not supplied by Apple in OS X, during the 
build.  Python 2.7 and 3.2 are able to make use of the BSD editline 
libedit which does comes with OS X.

-- 
 Ned Deily,
 n...@acm.org

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


Re: Python 3.1.3

2010-11-28 Thread Gnarlodious
Well I don't know what a readline is, but I upgraded from 3.1.1 and it
was working fine.

I might also add that the downarrow is also broken: ^[[B

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


Re: Python 3.1.3

2010-11-28 Thread Roy Smith
In article 
<2b22dfa0-41d5-4047-8cfe-7a18e00e3...@o23g2000prh.googlegroups.com>,
 Gnarlodious  wrote:

> Ah yes, sorry.
> This is Mac OSX 10.6.5, I did it build from the file at
> http://www.python.org/ftp/python/3.1.3/Python-3.1.3.tgz
> 
> -- Gnarlie

I'm seeing the same behavior on a build I did of

Python 3.2a4+ (py3k:86538, Nov 19 2010, 20:52:31)

last week, also on 10.6.5.  From the configure output, it looks like it 
found readline:

py3k$ grep -i readline config.status 
D["HAVE_LIBREADLINE"]=" 1"

but it's not acting like it.  The Python 2.6.1 which came with the 
system works properly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.1.3

2010-11-28 Thread Gnarlodious
Ah yes, sorry.
This is Mac OSX 10.6.5, I did it build from the file at
http://www.python.org/ftp/python/3.1.3/Python-3.1.3.tgz

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


Re: Python 3.1.3

2010-11-28 Thread Stefan Behnel

Gnarlodious, 28.11.2010 16:35:

Don't know why, but in Terminal the uparrow now gives me:

^[[A

which means I no longer have history scrolling.


You seem to be mailing from a Mac, is that the system you're having this 
problem with? Did you build Python yourself or use a provided binary? (and, 
if the latter, from where?)


Stefan

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


send free sms to any mobile in the world

2010-11-28 Thread mohammed_a_o
send free sms to any mobile in the world



http://www.phpforweb.com/askany/sms.php?sms
-- 
http://mail.python.org/mailman/listinfo/python-list


Subprocesses and Ctrl-C handling on windows

2010-11-28 Thread Perry Johnson
I have a python script which spawns a subprocess that takes a few
seconds to complete. If I hit Ctrl-C while the subprocess is
executing, sometimes the python script and the subprocess end silently
and I get back to the shell prompt and sometimes I get the
KeyboardInterrupt exception. Is there any kind of method underneath
this seemingly random behavior?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.1.3

2010-11-28 Thread Gnarlodious
Don't know why, but in Terminal the uparrow now gives me:

^[[A

which means I no longer have history scrolling.

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


remote control firefox with python

2010-11-28 Thread News123
Hi,


I wondered whether there is a simpe way to
'remote' control fire fox with python.


With remote controlling I mean:
- enter a url in the title bar and click on it
- create a new tab
- enter another url click on it
- save the html document of this page
- Probably the most difficult one: emulate a click or 'right click' on a
certain button or link of the current page.
- other interesting things would be to be able to enter the master
password from a script
- to enable disable proxy settings while running.

The reason why I want to stay within Firefox and not use any other
'mechanize' frame work is, that the pages I want to automate might
contain a lot of javascript for the construction of the actual page.


Thanks in advance for any pointers ideas.
-- 
http://mail.python.org/mailman/listinfo/python-list


How do I get the URL of the active tab in Firefox/IE/Chrome?

2010-11-28 Thread He Jibo
Hi,
I am writing a small program, which needs to get the URL of the active
tab in either of firefox, internet exploerer or chrome.
My need is similar as the one posted at, http://stackoverflow.com/questions/3631
... -ie-chrome

I did a lot of Googling, and get the following code. The following
code can get the url of the first tab in internet explorer. My
question is, how can I get the url of the current active tab? Thanks.

'''
http://efreedom.com/Question/1-2555905/ ... Bar-Python
http://blogs.msdn.com/b/oldnewthing/arc ... 35657.aspx
http://mail.python.org/pipermail/python ... 02040.html
http://code.activestate.com/recipes/302 ... lass-file/
'''
from win32com.client import Dispatch
import win32api, win32con,win32gui


SHELL = Dispatch("Shell.Application")

def get_ie(shell):
for win in shell.Windows():
# print win
if win.Name == "Windows Internet Explorer":
return win
return None

def main():
ie = get_ie(SHELL)
if ie:
print ie.LocationURL
print ie.LocationName
print ie.ReadyState
print ie
print ie.Document.title
print ie.Document.location
print ie.Document.forms

# title = win32gui.GetWindowText(ie)
# print title

else:
print "no ie window"

if __name__ == '__main__':
main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: google group api with python

2010-11-28 Thread News123
On 11/27/2010 11:51 PM, macroasm wrote:
> hi. i want google group with send python. how do user api.

Hi macroasm,


You will probably increase tha amount of replies if you elaborate on
your question.

I personally do not really understand  what you exactly asked for.




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


Re: TDD in python

2010-11-28 Thread Stefan Behnel

Rustom Mody, 28.11.2010 11:58:

Does anyone know of something like this for python?

http://www.vimeo.com/13240481


The page seems to require a recent version of the Flash player. Could you 
describe what exactly you are looking for?


Stefan

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


Re: Standard module implementation

2010-11-28 Thread Benjamin Kaplan
On Sun, Nov 28, 2010 at 9:08 AM, candide  wrote:
> I was wondering if all the standard module are implemented in C. For
> instance, I can't find a C implementation for the minidom xml parser under
> Python 2.6.
> --

No they aren't. A good chunk of the standard library is implemented in
Python. Which is nice because Python the language isn't only
implemented in C (CPython, the main implementation). It's also
implemented in Java (Jython), C# (IronPython), and even in a
restricted subset of Python itself (PyPy).
-- 
http://mail.python.org/mailman/listinfo/python-list


Standard module implementation

2010-11-28 Thread candide
I was wondering if all the standard module are implemented in C. For 
instance, I can't find a C implementation for the minidom xml parser 
under Python 2.6.

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


Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-28 Thread Mark Wooding
Steve Holden  writes:

> It isn't. Even inheritance itself isn't as useful as it at first
> appears, and composition turns out in practice to be much more useful.
> That goes double for multiple inheritance.

Composition /with a convenient notation for delegation/ works fairly
well.  Indeed, this can be seen as the basis of Self.  But downwards
delegation -- where a superclass leaves part of its behaviour
unspecified and requires (concrete) subclasses to fill in the resulting
blanks -- is hard to express like this without some kind of means of
identifying the original recipient of the delegated message.  Once
you've done that, there isn't much of a difference between a superclass
and a component with implicit delegation.

-- [mdw]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-28 Thread coldpizza
On Nov 24, 11:08 pm, Raymond Hettinger  wrote:
> I'm writing-up more guidance on how to use super() and would like to
> point at some real-world Python examples of cooperative multiple
> inheritance.
>
> Google searches take me to old papers for C++ and Eiffel, but that
> don't seem to be relevant to most Python programmers (i.e. a
> WalkingMenu example where a submenu is both a Entry in a Menu and a
> Menu itself).  Another published example is in a graphic library where
> some widgets inherit GraphicalFeature methods such as location, size
> and NestingGroupingFeatures such as finding parents, siblings, and
> children.  I don't find either of those examples compelling because
> there is no particular reason that they would have to have overlapping
> method names.
>
> So far, the only situation I can find where method names necessarily
> overlap is for the basics like __init__(), close(), flush(), and
> save() where multiple parents need to have their own initialization
> and finalization.
>
> If you guys know of good examples, I would appreciate a link or a
> recap.
>
> Thanks,
>
> Raymond

Did you try google code search? It is *not* the same as google code
hosting.
The site is http://www.google.com/codesearch and you can select Python
in the 'language' dropdown.
-- 
http://mail.python.org/mailman/listinfo/python-list


TDD in python

2010-11-28 Thread Rustom Mody
Does anyone know of something like this for python?

http://www.vimeo.com/13240481
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Kind of plugin system

2010-11-28 Thread Gaëtan Podevijn
Hello,

Thank you both, I'll look at this in more depth !

Regards,
Gaëtan

2010/11/27 Marc-Andre Belzile 

> I guess you could just define an entry-point in your source provider files
> that would return a specific instance of an InformationProvider class. This
> entry-point would be called by your main app (maybe at startup time or
> during an update phase).
>
> There are plenty of articles on the web about python plugins that could
> help you out, such as this one:
>
>  http://wehart.blogspot.com/2009/01/python-plugin-frameworks.html
>
> -mab
>
>
>
> From: python-list-bounces+marc-andre.belzile=autodesk@python.org[mailto:
> python-list-bounces+marc-andre.belzile
> =autodesk@python.org] On Behalf Of Gaëtan Podevijn
> Sent: Friday, November 26, 2010 12:46 PM
> To: python-list@python.org
> Subject: Kind of plugin system
>
> Hello,
>
> Here is my problem.
>
> I need to get some informations from files stored on my filesystem, Flickr
> and Picasa. So the idea is to create a class (for instance,
> "InformationsProvider") that provides common methods for those three
> sources, then, for each source, I create a class that inherits from
> "InformationsProvider" such as "InformationsLocalProvider",
> "InformationsFlickrProvider" and "InformationPicasaProvider". It is clearly
> needed because the method to get the informations is totally different for
> each source (the connection with flickr or picasa for exemple).
>
> However, I'd like, in the future, to be able to add new source and thus,
> just add a new class that implements the methods from Provider. The thing
> is, I'd like to add only one class, and that the rest of the application is
> able to use that class without really knowing how many class there are.
>
> I'd have something like :
> for each provider that exists: get the informations file
>
> and if I add a new .py that implements a new provider (say Delicious of
> GMail), the code above takes account of the new class. It must be "dynamic".
>
> Could you help me with that ? I hope I was clear enough.
>
> Thanks a lot,
>
> Gaëtan
>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparing floats

2010-11-28 Thread Peter Otten
kj wrote:

> I understand that, in Python 2.7 and 3.x >= 3.1, when the interactive
> shell displays a float it shows "the shortest decimal fraction that
> rounds correctly back to the true binary value".  Is there a way
> to access this rounding functionality from code that must be able
> to run under version 2.6? (The idea would be to implement float
> comparison as a comparison of the rounded versions of floats.)

Doesn't float(str(x)) == x for all x imply that str(x) == str(y) if and only 
if x == y? If so, what would be the benefit of converting to string at all?

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