Re: Identify the Color of an Image

2010-07-15 Thread Monyl
On Jul 14, 9:01 pm, John Nagle  wrote:
> On 7/14/2010 5:37 AM, Monyl wrote:
>
> > Hi,
>
> > 1. How can I find thecolorof  animagepresent the webpage?
>
> > 2. How to identify the font type of the selected text present in the
> > content of the web page
>
> > It would be much helpfull, if anyone responds to it ASAP
>
> > Thanks
> > Mohmyda
>
>      "Selected text"?  Selected how?  "Selected" implies some form
> of user interface, like a browser.  If you're doing something in
> a browser, look into Firefox and Greasemonkey.
>
>                                 John Nagle

I will be using a automation tool called Sikuli and select the text or
an Image.

My Requirement
---

I will capture the image manually and scriptify using Sikuli. To find
the captured image in the web page. Once it finds the image I need to
collect the information of the image like,

Co-ordinates of the image, height and width, color and pixel rate of
the image.

If I want to search a particular text in a webpage. I need to find the
font name, type, color and size of the text.

Note :- We can open the web page in any browser. but I should be able
to capture the attributes of the image/Text displayed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Identify the Color of an Image

2010-07-15 Thread Monyl
On Jul 14, 8:51 pm, Gary Herron  wrote:
> On 07/14/2010 05:37 AM, Monyl wrote:
>
> > Hi,
>
> > 1. How can I find thecolorof  animagepresent the webpage?
>
> > 2. How to identify the font type of the selected text present in the
> > content of the web page
>
> > It would be much helpfull, if anyone responds to it ASAP
>
> > Thanks
> > Mohmyda
>
> Please be clearer about what you want.
>
> 1. Animagedoes not "have" acolor, although each pixel in animage
> does have acolor.
>
> 2.  Text in a web page does not (necessarily)  have a font, although the
> display engine will use a font of its choice to render text.  And my
> browser will probably use a different font than yours.

Hi Gary Herron,

1.If I am going to click on a particular image. I will have click
using the co-ordinates of an Image. Can we find the color of the pixel
which lies in that particular co-ordinate where I click.

2.I just want to retrive the attributes of the text as it appears on
the browser. Can I get the font value depending on the browsers.

Hope you understand my problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: floatref

2010-07-15 Thread John Nagle

On 7/14/2010 12:56 AM, Roald de Vries wrote:

I know, I just wondered if there is a *standard* solution.


   Yes, there is.

class floatref(object) :
   def __init__(self, initialval) :
   self.__dict__["_val"] = initialval
   def __getattr__(self, attrname) :
   if attrname == 'val' :
   return(self._val)
   else :
   raise AttributeError(attrname)
   def __setattr__(self, attrname, val) :
   if attrname == 'val' :
   self.__dict__["_val"] = val
   else :
   raise AttributeError(attrname)


x = floatref(1.0)
y = x

print(x.val)
x.val = 10.0
print(x.val)
print(y.val)


Are you happy now?

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


Is python suitable for my needs?

2010-07-15 Thread Simon SSt

Hi,

Never too late to discover a new language :-)

I hope anybody could help me answering my questions. I'm a technical 
consultant for a software editor. Our software is running on the UNIX 
(solaris 10 / AIX 5L), Sybase 15.x / Oracle 10G , Weblogic Server 9.x 
and 10.x.


I'd like to know if Python is suitable for helping me:
Monitoring the UNIX box?
Get some metrics from Sybase and Oracle?
Get JMX metrics from Weblogic Server (Weblogic Server is provided with a 
scripting tool based on Jython)


Thanks for your hints.

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


whitespace in a word doc

2010-07-15 Thread Bruce
I'm trying to create a word doc using win32com. I don't get the same
whitespace as when printing the same stuff in the dos window. At the
terminal I manage to line up the second column like

apples  5
pears7

I do this by adding whitespace characters to the strings in the first
column so that their length is equal to that of the longest string in
the first column.

I print the excact same string to word. but in the word doc somehting
happens that messes things up like this :

apples5
pears   7

Needless to say, this is extremely frustrating. But why does it
happen, and how can I align the column in word?
-- 
http://mail.python.org/mailman/listinfo/python-list


insufficient memory problem in running .exe file in ipython

2010-07-15 Thread youngung
Hello!

I came across a problem in running a .exe file through ipython.
"""  os.system(' ~.exe')"""  was used.
The error message popped up says

Memory error: insufficient physical memory available

What should I try further?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: whitespace in a word doc

2010-07-15 Thread Tim Golden

On 15/07/2010 08:45, Bruce wrote:

I'm trying to create a word doc using win32com. I don't get the same
whitespace as when printing the same stuff in the dos window. At the
terminal I manage to line up the second column like

apples  5
pears7

I do this by adding whitespace characters to the strings in the first
column so that their length is equal to that of the longest string in
the first column.

I print the excact same string to word. but in the word doc somehting
happens that messes things up like this :

apples5
pears   7

Needless to say, this is extremely frustrating. But why does it
happen, and how can I align the column in word?


Couple of things which will help us to help you:

1) Consider what's going on *without* Python: if you take the exact
same text and spaces and type it into a Word document, does the same
thing happen? If so, then there is something of a gap in your understanding
of how Word arranges spaces, especially with proportional fonts.

2) If the text looks fine when you type it in but dodgy when programmed
in from Python, post the code here. If there's an issue with the way
your code is doing what its' doing, we need to see the code to work
that out. (Usually).

If you want things to line up in columns in Word, you probably want to
do one of two things (possibly both): use a fixed-width font, eg Courier 
New;

use Word tables. If you go the latter route, it can sometimes be easier to
generate the equivalent HTML and then ask Word to open it directly. Depends.


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


Re: Is python suitable for my needs?

2010-07-15 Thread Nitin Pawar
Python will absolutely will suit for monitoring. I use it on tomcat, mysql ,
apache and linux as well as freebsd

Thanks,
Nitin

On Thu, Jul 15, 2010 at 1:06 PM, Simon SSt  wrote:

> Hi,
>
> Never too late to discover a new language :-)
>
> I hope anybody could help me answering my questions. I'm a technical
> consultant for a software editor. Our software is running on the UNIX
> (solaris 10 / AIX 5L), Sybase 15.x / Oracle 10G , Weblogic Server 9.x and
> 10.x.
>
> I'd like to know if Python is suitable for helping me:
> Monitoring the UNIX box?
> Get some metrics from Sybase and Oracle?
> Get JMX metrics from Weblogic Server (Weblogic Server is provided with a
> scripting tool based on Jython)
>
> Thanks for your hints.
>
> Simon
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: whitespace in a word doc

2010-07-15 Thread Bruce
On Jul 15, 9:59 am, Tim Golden  wrote:
> On 15/07/2010 08:45, Bruce wrote:
>
>
>
>
>
> > I'm trying to create a word doc using win32com. I don't get the same
> > whitespace as when printing the same stuff in the dos window. At the
> > terminal I manage to line up the second column like
>
> > apples          5
> > pears            7
>
> > I do this by adding whitespace characters to the strings in the first
> > column so that their length is equal to that of the longest string in
> > the first column.
>
> > I print the excact same string to word. but in the word doc somehting
> > happens that messes things up like this :
>
> > apples                        5
> > pears               7
>
> > Needless to say, this is extremely frustrating. But why does it
> > happen, and how can I align the column in word?
>
> Couple of things which will help us to help you:
>
> 1) Consider what's going on *without* Python: if you take the exact
> same text and spaces and type it into a Word document, does the same
> thing happen?

Yes. Now using courier new. Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Balenciaga Envelop Clutch 084357L_CF

2010-07-15 Thread swiss luxury watches
Balenciaga Envelop Clutch 084357L_CF
http://www.bagstag.com/Balenciaga-Envelop-Clutch-084357L_CF.html

Balenciaga Envelop Clutch Information :
Brand :   Balenciaga ( http://www.bagstag.com/Balenciaga.html
)
Code :   084357L_CF

Balenciaga Envelop ClutchPure chevre (goatskin) with matching
leather trimmingsA central zip pocket on flapLeather coated
studs on front and corners.Two compartmentsAttached mirror
Llower buckle accentBlack cloth interior  Each Balenciaga Envelop
Clutch  replica comes with a Balenciaga   dust bag, Balenciaga
authenticity card and a Balenciaga care booklet. Size: 12" x 7"

General Attributes
Style: Clutches & Pouches
Color: Tan
Gender: Women
-- 
http://mail.python.org/mailman/listinfo/python-list


VoIP

2010-07-15 Thread M Eid
Dears,
 My blog about Voice over Internet protocol networks..Let's
improve our general knowledg

 
http://voib-net.blogspot.com/


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


Re: python ldap recursive

2010-07-15 Thread Michael Ströder
tekion wrote:
> I know perl Net::LDAP could do a recursive search call to LDAP.

I don't know perl's Net::LDAP and therefore I'm not sure what you mean with
"recursive search call". Personally I'd associate that with recursively
processing LDAP tree structure.

> What I am running into with Python LDAP on the search call is that I would 
> l have to wait for the search to complete to get the result.  Where as with
> Perl recursive search call,  I would get the result (not the completed
> result) back while the search is still running.

In case you're using http://www.python-ldap.org you're probably looking for
the asynchronous search methods:

http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.search

See general note:

http://www.python-ldap.org/doc/html/ldap.html#sending-ldap-requests

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python portable/Can I install it on an USB Stick?

2010-07-15 Thread Marek Kubica
On 14 Jul 2010 19:28:58 GMT
tommyb...@hotmail.com (Thomas Tundor) wrote:

> Is Python portable?

Yes.

> Can I install it on an USB Stick?

Yes.

> Or is Python installing (at least on WinXP) services or register some
> DLLs or write something into Registry?

Well, the installer is writing something into the registry, although it
is not neccessary to run Python.

regards,
Marek
-- 
http://mail.python.org/mailman/listinfo/python-list


need help: Is there is a way to get someone's calendar from mail exchange server with python

2010-07-15 Thread aimeixu

Hi guys,
I really need help to figure out a way to get someone's calendar from 
mail exchange server with python. I have no idea about how to make it 
.Or could some nice guys give me some hint?Thank a lot .

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


Re: floatref

2010-07-15 Thread Tino Wildenhain

Hi John,

Am 15.07.2010 09:14, schrieb John Nagle:

On 7/14/2010 12:56 AM, Roald de Vries wrote:

I know, I just wondered if there is a *standard* solution.


Yes, there is.

class floatref(object) :
def __init__(self, initialval) :
self.__dict__["_val"] = initialval
def __getattr__(self, attrname) :
if attrname == 'val' :
return(self._val)
else :
raise AttributeError(attrname)
def __setattr__(self, attrname, val) :
if attrname == 'val' :
self.__dict__["_val"] = val
else :
raise AttributeError(attrname)


Uhm. How would that be different to:

class floatref(object):
def __init__(self,val):
self.val=val


?



x = floatref(1.0)
y = x

print(x.val)
x.val = 10.0
print(x.val)
print(y.val)



Regards
Tino

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


Re: need help: Is there is a way to get someone's calendar from mail exchange server with python

2010-07-15 Thread Tim Golden

On 15/07/2010 10:38, aimeixu wrote:

Hi guys,
I really need help to figure out a way to get someone's calendar from
mail exchange server with python. I have no idea about how to make it
.Or could some nice guys give me some hint?Thank a lot .


There's an IMAP-based recipe here:

  http://sites.google.com/site/mattpoepping/gcalpython

and an IronPython one here:

  http://exchange2ical.codeplex.com/

and an ADO one here:

  http://www.codeproject.com/KB/dotnet/Dot_Net_2005.aspx

and a CDO one here (search for "Open another users calendar folder"):

  http://www.cdolive.com/cdo5p2.htm

The last two aren't directly Python examples but are easily
translated via win32com.client.

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


python3: help with pickle

2010-07-15 Thread Alan
Hi there,

This is more an exercise to myself to understand python3. I took a code I
wrote (acpype) and I am trying to make it compatible with either python 3 or
2.

I am trying to make a pickle file compatible with either python 3 and 2 as I
believe it should be possible.

I've looked at http://docs.python.org/py3k/library/pickle.html but still,
when I create a pickle file for an object with python 2.7 and then I try to
load it in python3, I got this:

Python 3.1.2 (r312:79147, Jul  7 2010, 10:55:24)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from acpype import * # this acpype package contains needed class ACTopol
>>> import pickle
>>> o = pickle.load(open('AAA.acpype/AAA.pkl','rb'))
Traceback (most recent call last):
  File "", line 1, in 
  File "/sw/lib/python3.1/pickle.py", line 1365, in load
encoding=encoding, errors=errors).load()
TypeError: ('__init__() takes at least 2 positional arguments (1 given)',
, ())
>>>

Now trying the contrary, pickle file is created with python3, I got this
when trying to load it with python 2.7:

Python 2.7 (r27:82500, Jul  7 2010, 10:48:15)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from acpype import *
>>> import pickle
>>> o = pickle.load(open('AAA.pkl','rb'))
Traceback (most recent call last):
  File "", line 1, in 
  File "/sw/lib/python2.7/pickle.py", line 1378, in load
return Unpickler(file).load()
  File "/sw/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
  File "/sw/lib/python2.7/pickle.py", line 1083, in load_newobj
obj = cls.__new__(cls, *args)
AttributeError: class ACTopol has no attribute '__new__'

Apart that, everything else seems to work. Just one note more: when loading
the pickle file 2.7 in python 2.7, type(o) is , while
pickle 3 in python 3, type(o) is 

Many thanks in advance,

Alan

-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need help: Is there is a way to get someone's calendar from mail exchange server with python

2010-07-15 Thread Ulrich Eckhardt
aimeixu wrote:
> I really need help to figure out a way to get someone's calendar from
> mail exchange server with python.

You can implement any network protocol with Python, see e.g. the struct
library. However, it would be easier to use an existing protocol
implementation. When you say "mail exchange server", what exactly does that
mean? I guess you actually mean an Exchange mail which is a product of
Microsoft. For that, there is a free implementation of the server-side
protocol (openexchange, IIRC). OTOH, you may be able to use the win32 MAPI
(message API), but I'm not sure what this can do and if there are Python
bindings for it.

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


[ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-15 Thread Paul


I'm pleased to announce the release of inflect.py v0.1.8, a module that 
correctly generates:

* the plural of singular nouns and verbs
* the singular of plural nouns
* ordinals
* indefinite articles
* present participles
* and converts numbers to words

Examples:

>>> import inflect
>>> p = inflect.engine()
>>> p.pl('cat')
'cats'
>>> p.pl('sheep')
'sheep'
>>> p.pl('bacterium')
'bacteria'

plural of singular verbs: it walks -> they walk
>>> p.pl('walks')
'walk'

singular of plural nouns:
>>> p.sinoun('bacteria')
'bacterium'
>>> p.sinoun('knives')
'knife'

ordinals:
>>> p.ordinal(31)
'31st'
>>> p.ordinal('twenty-five')
'twenty-fifth'

indefinite articles:
>>> p.a('horse')
'a horse'
>>> p.a('ant')
'an ant'
>>> p.a('hour')
'an hour'

present participles:
>>> p.prespart('drinks')

'drinking'


>>> p.prespart('runs')
'running'
>>> p.prespart('flies')
'flying'

numbers to words:
>>> p.numwords(1234567)
'one million, two hundred and thirty-four thousand, five hundred and 
sixty-seven'


Installation: "pip install inflect" or "easy_install inflect"
PyPi: http://pypi.python.org/pypi/inflect
Bug Tracker: http://github.com/pwdyson/inflect.py/issues
Source Code: http://github.com/pwdyson/inflect.py


Cheers,
Paul Dyson




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


Re: python3: help with pickle

2010-07-15 Thread Chris Rebert
On Thu, Jul 15, 2010 at 3:34 AM, Alan  wrote:
> Hi there,
> This is more an exercise to myself to understand python3. I took a code I
> wrote (acpype) and I am trying to make it compatible with either python 3 or
> 2.
> I am trying to make a pickle file compatible with either python 3 and 2 as I
> believe it should be possible.
> I've looked at http://docs.python.org/py3k/library/pickle.html but still,
> when I create a pickle file for an object with python 2.7 and then I try to
> load it in python3, I got this:
> Python 3.1.2 (r312:79147, Jul  7 2010, 10:55:24)
> [GCC 4.2.1 (Apple Inc. build 5659)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
 from acpype import * # this acpype package contains needed class ACTopol
 import pickle
 o = pickle.load(open('AAA.acpype/AAA.pkl','rb'))
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/sw/lib/python3.1/pickle.py", line 1365, in load
>     encoding=encoding, errors=errors).load()
> TypeError: ('__init__() takes at least 2 positional arguments (1 given)',
> , ())

> Now trying the contrary, pickle file is created with python3, I got this
> when trying to load it with python 2.7:
> Python 2.7 (r27:82500, Jul  7 2010, 10:48:15)
> [GCC 4.2.1 (Apple Inc. build 5659)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
 from acpype import *
 import pickle
 o = pickle.load(open('AAA.pkl','rb'))
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/sw/lib/python2.7/pickle.py", line 1378, in load
>     return Unpickler(file).load()
>   File "/sw/lib/python2.7/pickle.py", line 858, in load
>     dispatch[key](self)
>   File "/sw/lib/python2.7/pickle.py", line 1083, in load_newobj
>     obj = cls.__new__(cls, *args)
> AttributeError: class ACTopol has no attribute '__new__'
> Apart that, everything else seems to work. Just one note more: when loading
> the pickle file 2.7 in python 2.7, type(o) is , while
> pickle 3 in python 3, type(o) is 

Your AbstractTopol class needs to inherit from class `object` so that
it (and its descendant ACTopol) become new-style classes. Old-style
classes don't exist in Python 3, and I think this is at least partly
the cause of your problem.

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


Extending objects by a method?

2010-07-15 Thread Karsten Wutzke
Hello,

I'm new to Python so beware.

I have a hierarchical object structure which I iterate over (the
elements/classes of interest). I would like to apply the Visitor
pattern onto this object structure, so I must add an "accept" method
to every object (I'm interesting in) for the Visitor pattern to work.

Is there any Python-inbuilt way to dynamically add a method or do I
have to wrap each iterated object into a Decorator supplying the
accept method? The latter would mean having to rebuild the (part)
hierarchy with the Decorator objects before running the Visitor, which
I'd like to avoid.

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


Re: Extending objects by a method?

2010-07-15 Thread Karsten Wutzke
Small correction: I probably have to add a method to a class, so that
every object instantiated not by me has the desired functionality.

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


Re: insufficient memory problem in running .exe file in ipython

2010-07-15 Thread Steven D'Aprano
On Thu, 15 Jul 2010 00:54:19 -0700, youngung wrote:

> Hello!
> 
> I came across a problem in running a .exe file through ipython. """ 
> os.system(' ~.exe')"""  was used. The error message popped up says
> 
> Memory error: insufficient physical memory available
> 
> What should I try further?

More memory?


What's your operating system, how much memory do you have, how much 
memory does ' ~.exe' (that's a weird name) need? Is your operating system 
set to limit the amount of memory each process is given? 

What happens if you don't use ipython but call os.system(' ~.exe') from 
the normal Python prompt?


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


Re: Is python suitable for my needs?

2010-07-15 Thread Steven D'Aprano
On Thu, 15 Jul 2010 09:36:25 +0200, Simon SSt wrote:

> Hi,
> 
> Never too late to discover a new language :-)
> 
> I hope anybody could help me answering my questions. I'm a technical
> consultant for a software editor. Our software is running on the UNIX
> (solaris 10 / AIX 5L), Sybase 15.x / Oracle 10G , Weblogic Server 9.x
> and 10.x.
> 
> I'd like to know if Python is suitable for helping me: Monitoring the
> UNIX box?

You're probably better off using existing tools like Nagios and Munin 
rather than trying to reinvent the wheel. But yes, Python is a fine 
language for tasks like that. Server monitoring is an awfully big wheel 
to reinvent though; you should have a good reason for not using an 
existing, well-tested and supported product.


> Get some metrics from Sybase and Oracle? 

Google blocked where you are?

http://www.oracle.com/technology/pub/articles/prez-python-queries.html
http://wiki.oracle.com/page/Python

If you've got specific questions that you couldn't answer by googling, 
you should say so.



> Get JMX metrics from Weblogic
> Server (Weblogic Server is provided with a scripting tool based on
> Jython)

That's a pretty good hint. Are you aware that Jython is Python 
implemented in Java instead of C? In other words, Jython *is* Python.


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


empty set and empty dict for Python 3

2010-07-15 Thread Yingjie Lan
Hi there,

Maybe somebody already suggested this:

How about "{:}" for the empty dict, 
so that "{}" can denote the empty set?


Yingjie


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


Re: empty set and empty dict for Python 3

2010-07-15 Thread Tim Golden

On 15/07/2010 13:30, Yingjie Lan wrote:

Hi there,

Maybe somebody already suggested this:

How about "{:}" for the empty dict,
so that "{}" can denote the empty set?


Well one thing is that {} has denoted the empty dict
for many many releases of Python so a *lot* of code
would break if you suddenly switched...

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


Re: empty set and empty dict for Python 3

2010-07-15 Thread Peter Otten
Yingjie Lan wrote:

> Maybe somebody already suggested this:
> 
> How about "{:}" for the empty dict,
> so that "{}" can denote the empty set?

http://mail.python.org/pipermail/python-3000/2007-April/006620.html
-- 
http://mail.python.org/mailman/listinfo/python-list


how to install all python plugins

2010-07-15 Thread Ranjith Kumar
Hi!
   I`m using ubuntu 10.04 I want to install all the python plugins at once
or the python plugins list.
thank you in advance

-- 
Cheers
Ranjith,

http://ranjith10z.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple Hack To Get $2000 To Your PayPal Account

2010-07-15 Thread free money
Simple Hack To Get $2000 To Your PayPal  Account At  http://easyhappydays.tk

Due to high security risks, i have hidden the PayPal Form link in an
image.  in that website On Top Side Above search box , click on image
and enter your  PayPal  id And Your name.  please don,t tell to any
One.
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple Hack To Get $2000 To Your PayPal Account

2010-07-15 Thread free money
Simple Hack To Get $2000 To Your PayPal  Account At  http://easyhappydays.tk

Due to high security risks, i have hidden the PayPal Form link in an
image.  in that website On Top Side Above search box , click on image
and enter your  PayPal  id And Your name.  please don,t tell to any
One.
-- 
http://mail.python.org/mailman/listinfo/python-list


python3: signal.signal/singal.alarm

2010-07-15 Thread Alan
Hi there,

I have this, say timeTol = 5 (5 seconds) and 'cmd' takes minutes to execute
:

import subprocess as sub

...

p = sub.Popen(cmd, shell=True, stderr = sub.STDOUT, stdout =
sub.PIPE)

pid = p.pid

signal.signal(signal.SIGALRM, signal_handler)

signal.alarm(timeTol)

And it works on python 2.x.

However, on python 3.x, the signal_handler is only called when 'p =
sub.Popen...' has finished (after minutes) and signal.alarm appears to not
be called at 5 sec. Can someone please explain me this behaviour and how to
solve this?

Many thanks in advance,

Alan
-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extending objects by a method?

2010-07-15 Thread Tim Chase

On 07/15/2010 06:45 AM, Karsten Wutzke wrote:

Small correction: I probably have to add a method to a class, so that
every object instantiated not by me has the desired functionality.


You mean like:

>>> class Foo:
... def __init__(self, greeting):
... self.greeting = greeting
...
>>> f = Foo("Hello")
>>> def greet(self, other):
... print "%s, %s" % (self.greeting, other)
...
>>> Foo.greet = greet
>>> f.greet("world")
Hello, world


-tkc



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


Re: whitespace in a word doc

2010-07-15 Thread Grant Edwards
On 2010-07-15, Bruce  wrote:

> I'm trying to create a word doc using win32com.

Unfortunately the phrase "word doc" is meaningless.

Exactly what format file are you trying to generate?  For example: Word97 "doc" 
or the
new "docx" format?

> I don't get the same whitespace as when printing the same stuff in
> the dos window. At the terminal I manage to line up the second column
> like
>
> apples  5
> pears7
>
> I do this by adding whitespace characters to the strings in the first
> column so that their length is equal to that of the longest string in
> the first column.

Are you just generating an ASCII text file and then opening it in
word?

> I print the excact same string to word. but in the word doc somehting
> happens that messes things up like this :
>
> apples5
> pears   7
>
> Needless to say, this is extremely frustrating. But why does it
> happen, and how can I align the column in word?

Why?  Because word is using a viable-spaced font and the "dos window"
uses a fixed-width font.

If you want any control over the appearance of the document, you'll
have to either force word to open the file in a fixed-width font, or
you'll have to generate a file that contains formatting information.
What you appear to want is a table.

Generating RTF has worked well for me in the past:

 http://code.google.com/p/pyrtf-ng/
 http://pyrtf.sourceforge.net/

An enahanced version of pyRTF that supports EMF graphics and scaling
of graphics is available here:

  http://www.panix.com/~grante/files/python/PyRTF-0.46.tar.gz

If you want to generate graphics, this might be worth a look

  http://pyemf.sourceforge.net/ 
  
You might also be able to generate HTML and then open that file using
Word.


-- 
Grant Edwards   grant.b.edwardsYow! The Osmonds!  You are
  at   all Osmonds!!  Throwing up
  gmail.comon a freeway at dawn!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python suitable for my needs?

2010-07-15 Thread Simon SSt

Le 15/07/2010 14:26, Steven D'Aprano a écrit :

On Thu, 15 Jul 2010 09:36:25 +0200, Simon SSt wrote:


Hi,

Never too late to discover a new language :-)

I hope anybody could help me answering my questions. I'm a technical
consultant for a software editor. Our software is running on the UNIX
(solaris 10 / AIX 5L), Sybase 15.x / Oracle 10G , Weblogic Server 9.x
and 10.x.

I'd like to know if Python is suitable for helping me: Monitoring the
UNIX box?


You're probably better off using existing tools like Nagios and Munin
rather than trying to reinvent the wheel. But yes, Python is a fine
language for tasks like that. Server monitoring is an awfully big wheel
to reinvent though; you should have a good reason for not using an
existing, well-tested and supported product.



Get some metrics from Sybase and Oracle?


Google blocked where you are?

http://www.oracle.com/technology/pub/articles/prez-python-queries.html
http://wiki.oracle.com/page/Python

If you've got specific questions that you couldn't answer by googling,
you should say so.




Get JMX metrics from Weblogic
Server (Weblogic Server is provided with a scripting tool based on
Jython)


That's a pretty good hint. Are you aware that Jython is Python
implemented in Java instead of C? In other words, Jython *is* Python.


Regarding the System monitoring, I agree there are plenty of excellent 
solution and I shouldn't reinventing the wheel. I just want a script 
that will give me some info regarding the system state that I can use at 
any client site...but this monitoring part isn't my priority.


Regarding the DB, thanks for your link I'll look at them thoroughly.

And finally for JMX, yes I know about Jython so I'll investigate it.

Thanks

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


Python source checkout problem

2010-07-15 Thread Andrew Lucas
I am trying to check-out the python source using subversion.  The
documentation says that

"svn co http://svn.python.org/projects/python/trunk";

should do the trick.

When I do this I get the following response:

"svn: REPORT of '/projects/!svn/vcc/default': 200 OK (http://
svn.python.org)"

There is now a hidden .svn folder in my directory, but I can't find
any source anywhere, all subdirectories are empty.

When I try to update via

"svn update"

I get the following response.

"svn: Server sent unexpected return value (307 Proxy Redirect) in
response to OPTIONS request for 'http://svn.python.org/projects/python/
trunk' "

Any ideas what I am doing wrong?

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


Question about Python upgrade on linux

2010-07-15 Thread guandalino
Hi, suppose I have python 2.6.4 installed from source and I want to
upgrade to 2.6.5. Python standard library is automatically upgraded at
2.6.5 as well, while 3rd party pure Python and extension modules in
site-packages don't. Is it safe to keep the old site-packages or is it
suggested to reinstall modules and/or recompile extensions using the
new Python?

And to upgrade from 2.6 to 2.7?

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


Re: Python source checkout problem

2010-07-15 Thread Terry Reedy

On 7/15/2010 11:23 AM, Andrew Lucas wrote:

I am trying to check-out the python source using subversion.  The
documentation says that


Which doc? It probably needs to be changed.


"svn co http://svn.python.org/projects/python/trunk";


I believe 'trunk' is frozen as of the 2.7 release.
I suspect you want the releasexy-maint branch for some value of x and y 
or py3k for what is now the main developmemt branch. (3.2a)


As to the errors: I am currently browsing the svn view ok. I would try 
again to make sure it was not a temporary glitch.


--
Terry Jan Reedy

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


Re: Python source checkout problem

2010-07-15 Thread Mike Nerone
On 07/15/2010 10:23 AM, Andrew Lucas wrote:
> "svn co http://svn.python.org/projects/python/trunk";
>
> ...
>
> "svn: Server sent unexpected return value (307 Proxy Redirect) in
> response to OPTIONS request for 'http://svn.python.org/projects/python/
> trunk' "
>   
Assuming trunk is what you actually want, I would guess that your
environment has a proxy server that's not compatible with subversion
getting in your way. Ask your network admins if you're at a business
location.

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


Re: how to install all python plugins

2010-07-15 Thread Daniel Fetchinson
> I`m using ubuntu 10.04 I want to install all the python plugins at once
> or the python plugins list.
> thank you in advance

What is a python plugin?

If you mean all published packages on the python website, then you
probably don't really want to install all of them, only those that you
need.

If you mean all python packages that are available through the package
manager of ubuntu, then you'll need to search the entire list of
available packages using ubuntu's package manager, pick out the ones
that have 'python' in their names (presumably, this is how it works on
fedora) and install them using the above mentioned package manager
software. If you don't know how to use it, please see

https://help.ubuntu.com/community/SynapticHowto
https://help.ubuntu.com/community/InstallingSoftware

HTH,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-15 Thread Daniel Fetchinson
> I'm pleased to announce the release of inflect.py v0.1.8, a module that
> correctly generates:
>
> * the plural of singular nouns and verbs
> * the singular of plural nouns
> * ordinals
> * indefinite articles
> * present participles
> * and converts numbers to words

Wow!

Tons of kudos, this must have been hell of a work to put together with
all the irregular nouns/verbs/etc, and I really needed something like
this for a long time.

Thanks a lot,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-15 Thread Thomas Jollans
On 07/15/2010 01:00 PM, Paul wrote:
> 
> 
> I'm pleased to announce the release of inflect.py v0.1.8, a module that
> correctly generates:
> 
> * the plural of singular nouns and verbs
> * the singular of plural nouns
> * ordinals
> * indefinite articles
> * present participles
> * and converts numbers to words

Which languages does it support? If the answer is what I expect it is,
did you design the module with multilingualism in mind?

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


Re: ctypes' c_longdouble: underflow error (bug?)

2010-07-15 Thread kj
In  Thomas Jollans 
 writes:

>http://docs.python.org/library/ctypes.html#fundamental-data-types

>c_longdouble maps to float

Thanks for pointing this out!
~K
(Does it make *any difference at all* to use c_longdouble instead
of c_double?  If not, I wonder what's the point of having c_longdouble
at all.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Q for Emacs users: code-folding (hideshow)

2010-07-15 Thread kj


This is a question _for Emacs users_ (the rest of you, go away :)  ).

How do you do Python code-folding in Emacs?

Thanks!

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


Cannot send email

2010-07-15 Thread G F
A while back I was working for a company and set up a little python script to 
send out maintenance emails for some equipment we had set up in the field. The 
script collected information about the equipment composed an email and sent it 
out to interested persons. Then I left the company and they changed their ISP 
and got a new IP address. Now the emails are not getting through. The email 
server is the same as before but it is not working. Below is the error messaage 
that is reported by the script.

Does anyone have any ideas where the trouble is and what can be done about it? 
The little bit about:
"reply: retcode (557); Msg: This mail server does not accept mail addressed to 
aninterestedper...@yahoo.com" 
seems to be telling but I do not know why the server would respond this way.



Thank you.



>>> s = smtplib.SMTP(emailHost)
>>> s.set_debuglevel(1)
>>> s.sendmail(emailAddress, sendTo, testTxt)
send: 'ehlo [127.0.1.1]\r\n'
reply: '250-AUTH LOGIN PLAIN\r\n'
reply: '250-AUTH LOGIN\r\n'
reply: '250-AUTH=LOGIN\r\n'
reply: '250-8BITMIME\r\n'
reply: '250-SIZE 4096\r\n'
reply: '250 HELP\r\n'
reply: retcode (250); Msg: AUTH LOGIN PLAIN
AUTH LOGIN
AUTH=LOGIN
8BITMIME
SIZE 4096
HELP
send: 'mail FROM: size=10\r\n'
reply: '250  Address Okay\r\n'
reply: retcode (250); Msg: Address Okay
send: 'rcpt TO:\r\n'
reply: '557 This mail server does not accept mail addressed to 
gscotflem...@yahoo.com\r\n'
reply: retcode (557); Msg: This mail server does not accept mail addressed to 
aninterestedper...@yahoo.com

send: 'rset\r\n'
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/smtplib.py", line 708, in sendmail
    self.rset()
  File "/usr/lib/python2.6/smtplib.py", line 438, in rset
    return self.docmd("rset")
  File "/usr/lib/python2.6/smtplib.py", line 363, in docmd
    return self.getreply()
  File "/usr/lib/python2.6/smtplib.py", line 340, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
>>> 



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


Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-15 Thread Stefan Behnel

Thomas Jollans, 15.07.2010 18:41:

On 07/15/2010 01:00 PM, Paul wrote:

I'm pleased to announce the release of inflect.py v0.1.8, a module that
correctly generates:

* the plural of singular nouns and verbs
* the singular of plural nouns
* ordinals
* indefinite articles
* present participles
* and converts numbers to words


Which languages does it support? If the answer is what I expect it is,


It is. Most of the time, when people forget to say what they are talking 
about, assuming that they are either US-Americans or Windows users will hit 
the nail on the head.


Still, a pretty nice tool, I'd say.



did you design the module with multilingualism in mind?


Just look at the code, it consists almost exclusively of long lists of 
words. Multilingualism clearly wasn't a design goal.


Stefan

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


Re: ctypes' c_longdouble: underflow error (bug?)

2010-07-15 Thread Thomas Jollans
On 07/15/2010 06:41 PM, kj wrote:
> In  Thomas Jollans 
>  writes:
> 
>> http://docs.python.org/library/ctypes.html#fundamental-data-types
> 
>> c_longdouble maps to float
> 
> Thanks for pointing this out!
> ~K
> (Does it make *any difference at all* to use c_longdouble instead
> of c_double?  If not, I wonder what's the point of having c_longdouble
> at all.)

they're still different types (in C).

on my machine, a double is 64 bits wide, while a long double is 128 bits
wide. This means that a function that expects a long double argument
will expect 16 bytes, but ctypes will only pass 8 bytes if you tell it
to pass double. The same applies to return values.

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


Re: Cannot send email

2010-07-15 Thread D'Arcy J.M. Cain
On Thu, 15 Jul 2010 09:50:57 -0700 (PDT)
G F  wrote:
> Does anyone have any ideas where the trouble is and what can be done
> about it? The little bit about:
> "reply: retcode (557); Msg: This mail server does not accept mail
> addressed to aninterestedper...@yahoo.com" 
> seems to be telling but I do not know why the server would respond this way.

This is really not a Python question but I think that you will find
that the issue is that the server needs to know about the new IP
address.  The error looks like an anti-relay thing.

Contact the mail server admin or ask on a list dedicated to
administrating email.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

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


Re: Question about Python upgrade on linux

2010-07-15 Thread Jeff McNeil
On Jul 15, 11:54 am, guandalino  wrote:
> Hi, suppose I have python 2.6.4 installed from source and I want to
> upgrade to 2.6.5. Python standard library is automatically upgraded at
> 2.6.5 as well, while 3rd party pure Python and extension modules in
> site-packages don't. Is it safe to keep the old site-packages or is it
> suggested to reinstall modules and/or recompile extensions using the
> new Python?
>
> And to upgrade from 2.6 to 2.7?
>
> Thanks,
> best regards.

Going from 2.6.4 to 2.6.5 ought to be fine (consider the /usr/lib/
python2.x/ naming, and not /usr/lib/python2.x.y naming).When Going
from 2.6 to 2.7, you're better off reinstalling your extensions.

Thanks,

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


Re: Code generator and visitor pattern

2010-07-15 Thread Thomas Jollans
On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
> Hello,
> 
> this is obviously a Python OO question:
> 
> Since Python isn't stringly typed,

I expect this is an innocent typo, and you mean strictly.

> single-dispatch isn't available per se. So is the "double-dispatch" Visitor 
> pattern,

Wait, what?
First of all, python is strictly typed in that every object has exactly
one type, which is different from other types. So you can't do "1"+2, as
you can in some other languages.

Anyway, this is interesting: Tell me more about how Python's dynamic
nature makes it impossible to do whatever you're trying to do. I'm
baffled. What are you trying to do, anyway?

> which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?

WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
your train of thought, apparently: Now, the thing that code generators
probably share is that they write code to files. It depends on what I'm
trying to do of course, but I expect there's a good chance that if I
wrote a code generator in Python, it wouldn't be particularly
object-oriented at all.

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


Re: Code generator and visitor pattern

2010-07-15 Thread Christian Heimes
> Since Python isn't stringly typed, single-dispatch isn't available per
> se. So is the "double-dispatch" Visitor pattern, which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?

Do you mean strongly typed langauge?

You are wrong, Python is a strongly typed language. Perhaps you are
confusing strong/weak with dynamic/static? These attributes are
orthogonal to each other. Python is a strongly and dynamicly typed language.

The visitor pattern is required for double dispatching in *some* OO
language like C++, to work around issues with inheritance and function
overloading. Python's OO works differently.

Christian

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


Re: Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
On 15 Jul., 20:28, Thomas Jollans  wrote:
> On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
>
> > Hello,
>
> > this is obviously a Python OO question:
>
> > Since Python isn't stringly typed,
>
> I expect this is an innocent typo, and you mean strictly.
>
> > single-dispatch isn't available per se. So is the "double-dispatch" Visitor 
> > pattern,
>

Yes, typo, I meant strictly.

> Wait, what?
> First of all, python is strictly typed in that every object has exactly
> one type, which is different from other types. So you can't do "1"+2, as
> you can in some other languages.
>
> Anyway, this is interesting: Tell me more about how Python's dynamic
> nature makes it impossible to do whatever you're trying to do. I'm
> baffled. What are you trying to do, anyway?
>
> > which is usually used
> > in OO systems to implement code generators. So, what is the de facto
> > method in Python to handle source code generation?
>
> WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
> your train of thought, apparently: Now, the thing that code generators
> probably share is that they write code to files. It depends on what I'm
> trying to do of course, but I expect there's a good chance that if I
> wrote a code generator in Python, it wouldn't be particularly
> object-oriented at all.

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in. I did some reading and it turned out that Python
can't do it without some tricks (function decorators and 3rd party
code). For what I'm doing, I can't, or rather don't want to rely on
3rd party code (that has reasons). Thus, the visitor OO pattern must
be replaced by some other way.

As I expected, you already hinted a non-OO solution. Which is now that
*I* am wondering what that would look like...

Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.

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


Re: how to install all python plugins

2010-07-15 Thread Johan Grönqvist

2010-07-15 18:18, Daniel Fetchinson skrev:


If you mean all python packages that are available through the package
manager of ubuntu, then you'll need to search the entire list of
available packages using ubuntu's package manager, pick out the ones
that have 'python' in their names (presumably, this is how it works on
fedora) and install them using the above mentioned package manager
software.


To install all packages whose names start with "python-" in ubuntu:

"apt-get install python-*" (as root, or prepended with sudo)



/ johan

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


Re: Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
>
> Yes, typo, I meant strictly.
>

Damn, I mean strongly. At least not for identifying which methods to
call depending on the type/s.

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


Re: Code generator and visitor pattern

2010-07-15 Thread Thomas Jollans
On 07/15/2010 08:45 PM, Karsten Wutzke wrote:
> On 15 Jul., 20:28, Thomas Jollans  wrote:
>> On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
>>
>>> Hello,
>>
>>> this is obviously a Python OO question:
>>
>>> Since Python isn't stringly typed,
>>
>> I expect this is an innocent typo, and you mean strictly.
>>
>>> single-dispatch isn't available per se. So is the "double-dispatch" Visitor 
>>> pattern,
>>
> 
> Yes, typo, I meant strictly.
> 
>> Wait, what?
>> First of all, python is strictly typed in that every object has exactly
>> one type, which is different from other types. So you can't do "1"+2, as
>> you can in some other languages.
>>
>> Anyway, this is interesting: Tell me more about how Python's dynamic
>> nature makes it impossible to do whatever you're trying to do. I'm
>> baffled. What are you trying to do, anyway?
>>
>>> which is usually used
>>> in OO systems to implement code generators. So, what is the de facto
>>> method in Python to handle source code generation?
>>
>> WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
>> your train of thought, apparently: Now, the thing that code generators
>> probably share is that they write code to files. It depends on what I'm
>> trying to do of course, but I expect there's a good chance that if I
>> wrote a code generator in Python, it wouldn't be particularly
>> object-oriented at all.
> 
> Well, I'm most experienced in OO, so writing OO in Python seems like
> the way to start with Python. The visitor pattern uses single-
> dispatch, that is, it determines which method to call be the type of
> object passed in. I did some reading and it turned out that Python
> can't do it without some tricks (function decorators and 3rd party
> code).

Well, yes: the name of a function or method refers to a single callable
object and piece of code. if you care about the type of the argument,
you must say so explicitly:

class A:
def dothing(self, obj):
if isinstance(obj, str):
self.dostringthing(obj)
elif isinstance(obj, (int,float)):
self.donumberthing(obj)
else:
self.dogenericthing(obj)

# ...

while python doesn't have C++-style function overloading, its
alternative also doesn't have the limitations that come with it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

Karsten Wutzke, 15.07.2010 20:45:

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in.


Well, then do that. Put the types into a dict and map them to the functions 
to call, then call the function through the dict. That's a pretty common 
way to do dispatching.




Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.


You speak in riddles, but my guess is that your problem is that you don't 
want to dispatch mechanism to match only exact types but also subtypes. No 
problem, just build your dict incrementally and add new types as they come 
in. See this file for an example:


http://hg.cython.org/cython-devel/file/tip/Cython/Compiler/Visitor.py

Stefan

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


Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-15 Thread John Nagle

   I had a similar problem back in 2007.  See

http://bytes.com/topic/python/answers/613336-more-m2crypto-build-problems

Also see

http://bytes.com/topic/python/answers/711381-m2crypto-0-18-new-version-same-old-build-bugs

   There have been problems with SWIG. There have been problems with
how OpenSSL was built (with or without elliptic curve crypto support).
And there were some issues with building on 64-bit hardware running
32-bit operating systems, because the build script was checking
the wrong system configuration parameter.

   Not sure what problem you're having with Mac OS X.  From the
errors, though, I suspect that not all the components involved
are consistent with 32/64 bit width.

John Nagle

On 7/14/2010 10:05 PM, Adam Mercer wrote:

Anyone have any ideas about this?

Cheers

Adam

On Tue, Jul 13, 2010 at 16:18, Adam Mercer  wrote:

Hi

I'm trying to build M2Crypto on Mac OS X 10.6.4 against python2.5
(python2.6 fails in the same way), with SWIG 2.0.0 and OpenSSL 1.0.0a
and it is failing with the following:

105 :info:build swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
106 :info:build swig -python
-I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
-I/opt/local/include -includeall -o SWIG/_m2crypto_wrap.c
SWIG/_m2crypto.i
107 :info:build SWIG/_bio.i:64: Warning 454: Setting a
pointer/reference variable may leak memory.
108 :info:build SWIG/_rand.i:19: Warning 454: Setting a
pointer/reference variable may leak memory.
109 :info:build SWIG/_evp.i:156: Warning 454: Setting a
pointer/reference variable may leak memory.
110 :info:build SWIG/_dh.i:36: Warning 454: Setting a
pointer/reference variable may leak memory.
111 :info:build SWIG/_rsa.i:43: Warning 454: Setting a
pointer/reference variable may leak memory.
112 :info:build SWIG/_dsa.i:31: Warning 454: Setting a
pointer/reference variable may leak memory.
113 :info:build SWIG/_ssl.i:207: Warning 454: Setting a
pointer/reference variable may leak memory.
114 :info:build SWIG/_x509.i:313: Warning 454: Setting a
pointer/reference variable may leak memory.
115 :info:build SWIG/_pkcs7.i:42: Warning 454: Setting a
pointer/reference variable may leak memory.
116 :info:build SWIG/_pkcs7.i:42: Warning 454: Setting a
pointer/reference variable may leak memory.
117 :info:build SWIG/_util.i:9: Warning 454: Setting a
pointer/reference variable may leak memory.
118 :info:build SWIG/_ec.i:111: Warning 454: Setting a
pointer/reference variable may leak memory.
119 :info:build SWIG/_engine.i:162: Warning 454: Setting a
pointer/reference variable may leak memory.
120 :info:build creating build/temp.macosx-10.6-x86_64-2.5
121 :info:build creating build/temp.macosx-10.6-x86_64-2.5/SWIG
122 :info:build /usr/bin/gcc-4.2 -fno-strict-aliasing -mno-fused-madd
-fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
-I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
-I/opt/local/include
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py25-m2crypto/work/M2Crypto-0.20.2/SWIG
-c SWIG/_m2crypto_wrap.c -o
build/temp.macosx-10.6-x86_64-2.5/SWIG/_m2crypto_wrap.o -DTHREADING
123 :info:build SWIG/_m2crypto_wrap.c: In function 'rand_pseudo_bytes':
124 :info:build SWIG/_m2crypto_wrap.c:3899: warning: pointer targets
in passing argument 1 of 'PyString_FromStringAndSize' differ in
signedness
125 :info:build SWIG/_m2crypto_wrap.c: In function 'pkcs5_pbkdf2_hmac_sha1':
126 :info:build SWIG/_m2crypto_wrap.c:3973: warning: pointer targets
in passing argument 1 of 'PyString_FromStringAndSize' differ in
signedness
127 :info:build SWIG/_m2crypto_wrap.c: In function 'bytes_to_key':
128 :info:build SWIG/_m2crypto_wrap.c:4132: warning: pointer targets
in passing argument 1 of 'PyString_FromStringAndSize' differ in
signedness
129 :info:build SWIG/_m2crypto_wrap.c: In function 'sign_final':
130 :info:build SWIG/_m2crypto_wrap.c:4228: warning: pointer targets
in passing argument 1 of 'PyString_FromStringAndSize' differ in
signedness
131 :info:build SWIG/_m2crypto_wrap.c: In function 'pkey_as_der':
132 :info:build SWIG/_m2crypto_wrap.c:4300: warning: pointer targets
in passing argument 1 of 'PyString_FromStringAndSize' differ in
signedness
133 :info:build SWIG/_m2crypto_wrap.c: In function 'pkey_get_modulus':
134 :info:build SWIG/_m2crypto_wrap.c:4333: warning: value computed is not 
used
135 :info:build SWIG/_m2crypto_wrap.c:4358: warning: value computed is not 
used
136 :info:build SWIG/_m2crypto_wrap.c: In function 'AES_crypt':
137 :info:build SWIG/_m2crypto_wrap.c:: warning: pointer targets
in passing argument 1 of 'PyString_FromStringAndSize' differ in
signedness
138 :info:build SWIG/_m2crypto_wrap.c: At top level:
139 :info:build SWIG/_m2crypto_wrap.c:5846: error: expected '='

Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

Karsten Wutzke, 15.07.2010 21:00:

Yes, typo, I meant strictly.


Damn, I mean strongly. At least not for identifying which methods to
call depending on the type/s.


I think you meant "statically typed".

http://c2.com/cgi-bin/wiki?StronglyTyped
http://www.c2.com/cgi/wiki?StaticTyping

Stefan

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


Re: Code generator and visitor pattern

2010-07-15 Thread MRAB

Stefan Behnel wrote:

Karsten Wutzke, 15.07.2010 20:45:

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in.


Well, then do that. Put the types into a dict and map them to the 
functions to call, then call the function through the dict. That's a 
pretty common way to do dispatching.




Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.


You speak in riddles, but my guess is that your problem is that you 
don't want to dispatch mechanism to match only exact types but also 
subtypes. No problem, just build your dict incrementally and add new 
types as they come in. See this file for an example:


http://hg.cython.org/cython-devel/file/tip/Cython/Compiler/Visitor.py


Another variation: the dispatch table starts with entries for certain
types then it adds subtypes on demand:

def visit(self, obj):
try:
handler = self.dispatch_table[type(obj)]
except KeyError:
for disp_type, disp_func in self.dispatch_table.items():
if isinstance(obj, disp_type):
self.dispatch_table[type(obj)] = disp_func
handler = disp_func
else:
raise RuntimeError("Visitor does not accept object: %s" 
% obj)

   return handler(obj)
--
http://mail.python.org/mailman/listinfo/python-list


Best Pythonic Approach to Annotation/Metadata?

2010-07-15 Thread Sparky
Hello Python community!

I am building a JSON-RPC web application that uses quite a few models.
I would like to return JSON encoded object information and I need a
system to indicate which properties should be returned when the object
is translated to a JSON encoded string. Unfortunately, this
application runs on top of Google's App Engine and, thus, private
attributes are not an option. Also, a preliminary search leads me to
believe that there are no real established ways to annotate variables.
Ideally I want to do something like:

def to_JSON(self):
returnDict = {}
for member in filter(someMethod, inspect.getmembers(self)):
returnDict[member[0]] = member[1]
return json.dumps(returnDict)

I recognize that two solutions would be to 1) include a prefix like
"public_" before variable names or 2) have a list/tuple of attributes
that should be transmitted, simply using the "in" operator. However,
both these options seem like a pretty ungraceful way to do it. Does
anyone else have an idea? Are there any established methods to apply
metadata / annotations to variables in Python or do you believe one of
the above is a good "pythonic" way to solve this problem? I am using
2.6.

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


Re: Code generator and visitor pattern

2010-07-15 Thread Matt McCredie
Karsten Wutzke  web.de> writes:

> So, what is the de facto method in Python to handle source code generation?


Take a look at the NodeVisitor class in the ast module in python 2.6+. 
The visitor pattern is implemented in the python standard library.

Matt

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


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

MRAB, 15.07.2010 21:33:

Stefan Behnel wrote:

Karsten Wutzke, 15.07.2010 20:45:

Well, I'm most experienced in OO, so writing OO in Python seems like
the way to start with Python. The visitor pattern uses single-
dispatch, that is, it determines which method to call be the type of
object passed in.


Well, then do that. Put the types into a dict and map them to the
functions to call, then call the function through the dict. That's a
pretty common way to do dispatching.



Note, that I have an hierarchical object structure which I want to
iterate over, so using OO looked natural to me. If there's a better
approach, I'm all ears.


You speak in riddles, but my guess is that your problem is that you
don't want to dispatch mechanism to match only exact types but also
subtypes. No problem, just build your dict incrementally and add new
types as they come in. See this file for an example:

http://hg.cython.org/cython-devel/file/tip/Cython/Compiler/Visitor.py


Another variation: the dispatch table starts with entries for certain
types then it adds subtypes on demand:

def visit(self, obj):
try:
handler = self.dispatch_table[type(obj)]
except KeyError:
for disp_type, disp_func in self.dispatch_table.items():
if isinstance(obj, disp_type):
self.dispatch_table[type(obj)] = disp_func
handler = disp_func
else:
raise RuntimeError("Visitor does not accept object: %s" % obj)
return handler(obj)


Well, yes, that's basically what the code behind the above link does, 
except that it follows the type hierarchy correctly to find the closest match.


Stefan

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


Python script to start, restart and stop the apache server

2010-07-15 Thread Ranjith Kumar
Hi,
   I planned to write a python script to starts the apache server and when
the HTTPD goes down/drop it should auto restart and when user chooses stop
it should stop the apache server.
Here the start and stop should be user set but the restart when the server
goes down.

Similar to this program,
This is shell script,

#!/bin/bash
# Apache Process Monitor
# Restart Apache Web Server When It Goes Down
# -
# Copyright (c) 2003 nixCraft project 
# This script is licensed under GNU GPL version 2.0 or above
# -
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -
# RHEL / CentOS / Fedora Linux restart command
RESTART="/sbin/service httpd restart"

# uncomment if you are using Debian / Ubuntu Linux
#RESTART="/etc/init.d/apache2 restart"

#path to pgrep command
PGREP="/usr/bin/pgrep"

# Httpd daemon name,
# Under RHEL/CentOS/Fedora it is httpd
# Under Debian 4.x it is apache2
HTTPD="httpd"

# find httpd pid
$PGREP ${HTTPD}

if [ $? -ne 0 ] # if apache not running
then
 # restart apache
 $RESTART
fi

Johan Grönqvist and Daniel Fetchinson thanks for your reply.


-- 
Cheers
Ranjith,

http://ranjith10z.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Pythonic Approach to Annotation/Metadata?

2010-07-15 Thread John Krukoff
On Thu, 2010-07-15 at 12:37 -0700, Sparky wrote:

> the above is a good "pythonic" way to solve this problem? I am using
> 2.6.

Hopefully a helpful correction, but if you're running on google app
engine, you're using python 2.5 on the google side irrespective of what
you're running for development.

-- 
John Krukoff 
Land Title Guarantee Company

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


Re: Q for Emacs users: code-folding (hideshow)

2010-07-15 Thread Peter
On Jul 16, 2:45 am, kj  wrote:
> This is a question _for Emacs users_ (the rest of you, go away :)  ).
>
> How do you do Python code-folding in Emacs?
>
> Thanks!
>
> ~K

I don't - when I first looked at folding-mode (I assume this is what
you are referring too?) I couldn't be bothered putting the {{{ }}}
strings into the code comments - maybe somebody else has had better
success with it? But I just couldn't be bothered. Although if you use
a template generating system such as ELSE, you could probably work it
into the code templates and have them generated automatically. I must
admit that I started to modify my code templates once upon a time to
provide this but lost interest part way through and just put up with
splitting the window and "hiding" the intervening code that way.

Personally I think something like "folding" would be better worked
into the major mode and performed on a syntactic scan basis i.e. the
elisp must understand where the code blocks begin and end and make
folding decisions based on where point is located in relation to
surround code blocks.

Actually, it might be possible now that pymacs is available (well, I
say "now" - even though pymacs has been available for quite some time,
I looked at folding mode even earlier!) i.e. call a Python helper
program that would provide the syntactic scanning of the buffer
contents and return appropriate markers into the buffer for the
folding mode code to work with. One day when I have run out of other
(programming) things to do I might investigate this :-)

Anybody else now of any better ideas or whatever? Now that I think
about it, I wouldn't mind using folding mode if I could make it
"easier" to use myself! :-)

Peter



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


[OFF TOPIC] How to Learn Lambda Calculus: A Guide

2010-07-15 Thread Nonpython
1: Try to learn lambda calculus
2: Fail to learn lambda calculus
3: Sit in corner rocking
4: Consider suicide.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Learn Lambda Calculus: A Guide

2010-07-15 Thread Peter
On Jul 16, 6:40 am, Nonpython  wrote:
> 1: Try to learn lambda calculus
> 2: Fail to learn lambda calculus
> 3: Sit in corner rocking
> 4: Consider suicide.

You forgot:

5: (quietly) drooling

But then that might be part of the advanced course? I really can't
remember, my PHD in 'lambda calculus' was done so long ago now...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Ian Hobson

On 15/07/2010 18:58, Karsten Wutzke wrote:

Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

Karsten
   

I'm baffled. Not by what you mean by stringly, but

What feature of Python stops you writing the three parts of the visitor 
pattern:


IIRC you need:

A tree walker that creates the visitor and walks the tree calling
node.visitFrom(visitor)
on each one in the required order.

The  visitfrom(aVisitor) routines in each node type that calls
aVisitor.visitedMyNodeType(self)
where MyNodeType is, naturally different for each node type!

All the
   def visitedNodeType(aNode):  routines in visitor to generate the code.

Simples! No? :)

Ian




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


Re: Code generator and visitor pattern

2010-07-15 Thread Ian Hobson

On 15/07/2010 18:58, Karsten Wutzke wrote:

Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

Karsten
   

I'm baffled. Not by what you mean by stringly, but

What feature of Python stops you writing the three parts of the visitor 
pattern:


IIRC you need:

A tree walker that creates the visitor and walks the tree calling
node.visitFrom(visitor)
on each one in the required order.

The  visitfrom(aVisitor) routines in each node type that calls
aVisitor.visitedMyNodeType(self)
where MyNodeType is, naturally different for each node type!

All the
   def visitedNodeType(aNode):  routines in visitor to generate the code.

Simples! No? :)

Ian




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


Possible to include \n chars in doctest code samples or output?

2010-07-15 Thread python
I'm working with some Python 2.6 code that is using the doctest
module for unittests.

I tried adding tests whose code and results required newlines
(\n). Apparently newlines in string constants breaks the doctest
code.

Any workarounds other than using another char for newlines and
wrapping all my strings with .replace( someChar, chr(10) )?

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


Re: Possible to include \n chars in doctest code samples or output?

2010-07-15 Thread Thomas Jollans
On 07/15/2010 11:14 PM, pyt...@bdurham.com wrote:
> I'm working with some Python 2.6 code that is using the doctest module
> for unittests.
>  
> I tried adding tests whose code and results required newlines (\n).
> Apparently newlines in string constants breaks the doctest code.
>  
> Any workarounds other than using another char for newlines and wrapping
> all my strings with .replace( someChar, chr(10) )?

Recall that doctest doesn't parse the code, it extracts the docstrings.
And docstrings are just strings, and are parsed like strings.

Remember that the two following strings are identical:

"""a
b"""

"""a\nb"""

As are these two:

r"\n"
"\\n"

Anyway, you need to escape the backslash if you want backslash-n to be
in your docstring. Otherwise you'll get a newline like any other
newline, not a character sequence doctest can eval() to a newline while
processing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-15 Thread Adam Mercer
On Thu, Jul 15, 2010 at 14:10, John Nagle  wrote:
>   I had a similar problem back in 2007.  See
>
> http://bytes.com/topic/python/answers/613336-more-m2crypto-build-problems
>
> Also see
>
> http://bytes.com/topic/python/answers/711381-m2crypto-0-18-new-version-same-old-build-bugs
>
>   There have been problems with SWIG. There have been problems with
> how OpenSSL was built (with or without elliptic curve crypto support).
> And there were some issues with building on 64-bit hardware running
> 32-bit operating systems, because the build script was checking
> the wrong system configuration parameter.
>
>   Not sure what problem you're having with Mac OS X.  From the
> errors, though, I suspect that not all the components involved
> are consistent with 32/64 bit width.

Thanks, I'm sure everything is consistent with the architecture, i.e.
everything is 64 bit. The last time I build M2Crypto on this box was
against SWIG-1.3.x and OpenSSL-0.9.8? So one of these (or both) has
broken something... Looks like I'll have to revert each one at a
time...

Cheers

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


About problems that I have with learning wxPython in Macintosh

2010-07-15 Thread ata.jaf
Hi,
I'm newbie to wxPython and need it to develop my little app.
But from start I have problems with tutorials. Because all of them are
compatible with Windows but not so much with Mac.
For example in this code:


import wx

class MainWindow(wx.Frame) :
 def __init__(self, parent, title) :
   wx.Frame.__init__(self, parent, title=title, size=(200, 100))
   self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
   self.CreateStatusBar()

   filemenu = wx.Menu()

   filemenu.Append(wx.ID_ABOUT, '&About', ' Information about this
program.')
   filemenu.AppendSeparator()
   filemenu.Append(wx.ID_EXIT, 'E&xit', ' Terminate the program')

   menuBar = wx.MenuBar()
   menuBar.Append(filemenu, '&File')
   self.SetMenuBar(menuBar)
   self.Show(True)

app = wx.App(False)
frame = MainWindow(None, 'Sample editor')
app.MainLoop()



The menus doesn't appear in the product.
Can anyone help me to find a tutorial that is for using wxPython on a
Mac?
Thanks
Ata
-- 
http://mail.python.org/mailman/listinfo/python-list


How to Learn Lambda Calculus: A Guide

2010-07-15 Thread geremy condra
On Thu, Jul 15, 2010 at 1:53 PM, Peter  wrote:
> On Jul 16, 6:40 am, Nonpython  wrote:
>> 1: Try to learn lambda calculus
>> 2: Fail to learn lambda calculus
>> 3: Sit in corner rocking
>> 4: Consider suicide.
>
> You forgot:
>
> 5: (quietly) drooling
>
> But then that might be part of the advanced course? I really can't
> remember, my PHD in 'lambda calculus' was done so long ago now...

No PhD required (if one ever is, besides for jobification purposes).

Simple (somewhat shallow) introduction:
http://eflorenzano.com/blog/post/lambda-calculus/

A construction of the Church numerals: http://www.stephendiehl.com/?p=66

Not so hard, really.

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


Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-15 Thread geremy condra
On Thu, Jul 15, 2010 at 3:03 PM, Adam Mercer  wrote:
> On Thu, Jul 15, 2010 at 14:10, John Nagle  wrote:
>>   I had a similar problem back in 2007.  See
>>
>> http://bytes.com/topic/python/answers/613336-more-m2crypto-build-problems
>>
>> Also see
>>
>> http://bytes.com/topic/python/answers/711381-m2crypto-0-18-new-version-same-old-build-bugs
>>
>>   There have been problems with SWIG. There have been problems with
>> how OpenSSL was built (with or without elliptic curve crypto support).
>> And there were some issues with building on 64-bit hardware running
>> 32-bit operating systems, because the build script was checking
>> the wrong system configuration parameter.
>>
>>   Not sure what problem you're having with Mac OS X.  From the
>> errors, though, I suspect that not all the components involved
>> are consistent with 32/64 bit width.
>
> Thanks, I'm sure everything is consistent with the architecture, i.e.
> everything is 64 bit. The last time I build M2Crypto on this box was
> against SWIG-1.3.x and OpenSSL-0.9.8? So one of these (or both) has
> broken something... Looks like I'll have to revert each one at a
> time...
>
> Cheers
>
> Adam

The move to 1.0 was a PITA for me, although I appreciate the improved
EVP_PKEY support it will probably break a chunk of code.

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


File transfer on network

2010-07-15 Thread mukesh tiwari
Hello all
Currently i am trying to develop a client and server in python. Client
takes screenshot in every 20 seconds and send it to server. Server
store the received file in folder. Here is code for Client

import sys
import socket
import gtk.gdk
import time
if __name__ == "__main__":
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
host,port="localhost",50007
s.connect((host,port))
while 1:
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = 
pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
if (pb != None):
   pb.save('/home/tmp_1/screenshot.png',"png")
f=open('/home//tmp_1/screenshot.png','rb')
while 1:
blk=f.read(2048)
if not blk:break
s.send(blk)
f.close()
print 'file transfer done';
time.sleep(20)

s.close()


Server Code
import sys
import socket
import time
if __name__ == "__main__":

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host,port="",50007
s.bind((host,port))
s.listen(1)
conn,add=s.accept()
i=0
while 1:
f=open('/home/tmp_2/copyscreenshot_'+str(i)+'.png','wb')
while 1:
data=conn.recv(2048)
if not data:break
f.write(data)

f.close()
print 'file received'
time.sleep(20)
i+=1;
#print ' file received '

conn.close()


My problem is that server is copying only first image
copyscreenshot_0.png while my client continuously taking screen shot.
Kindly tell me what is wrong with my server code.

Thank you
Mukesh Tiwari







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































import sys
import socket
import gtk.gdk
import time
if __name__ == "__main__":
s=socket.socket(socket

Re: Best Pythonic Approach to Annotation/Metadata?

2010-07-15 Thread Sparky
On Jul 15, 2:26 pm, John Krukoff  wrote:
> On Thu, 2010-07-15 at 12:37 -0700, Sparky wrote:
>
> 
>
> > the above is a good "pythonic" way to solve this problem? I am using
> > 2.6.
>
> Hopefully a helpful correction, but if you're running on google app
> engine, you're using python 2.5 on the google side irrespective of what
> you're running for development.
>
> --
> John Krukoff 
> Land Title Guarantee Company

Sorry about that and thanks for pointing out my mistake there.

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


Re: File transfer on network

2010-07-15 Thread mukesh tiwari
Kindly see this post as above post contains some garbage code in end.
Sorry for that.

Hello all
Currently i am trying to develop a client and server in python.
Client
takes screenshot in every 20 seconds and send it to server. Server
store the received file in folder. Here is code for Client
import sys
import socket
import gtk.gdk
import time
if __name__ == "__main__":
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
host,port="localhost",50007
s.connect((host,port))
while 1:
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,
8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),
0,0,0,0,sz[0],sz[1])
if (pb != None):
   pb.save('/home/tmp_1/screenshot.png',"png")
f=open('/home//tmp_1/screenshot.png','rb')
while 1:
blk=f.read(2048)
if not blk:break
s.send(blk)
f.close()
print 'file transfer done';
time.sleep(20)
s.close()
Server Code
import sys
import socket
import time
if __name__ == "__main__":
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host,port="",50007
s.bind((host,port))
s.listen(1)
conn,add=s.accept()
i=0
while 1:
f=open('/home/tmp_2/copyscreenshot_'+str(i)
+'.png','wb')
while 1:
data=conn.recv(2048)
if not data:break
f.write(data)
f.close()
print 'file received'
time.sleep(20)
i+=1;
#print ' file received '
conn.close()
My problem is that server is copying only first image
copyscreenshot_0.png while my client continuously taking screen shot.
Kindly tell me what is wrong with my server code.
Thank you
Mukesh Tiwari
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multitask http server (single-process multi-connection HTTP server)

2010-07-15 Thread lkcl
On Jul 13, 12:00 pm, Luke Kenneth Casson Leighton
 wrote:

> but... not being funny or anything, but basically i'm done already 
> :)multitaskhttpdworks, it doesn't need stackless, i completed a JSONRPC
> service last night, i'll add POST of multi-part forms today, and i
> have everything that [GNUmed] will need.

 ok instead of adding this to httpd.py i created an HTTP proxy out of
multitaskhttpd.  i also cobbled together an example JSONRPC Server
which is highly likely to be used in gnumed, now.  this modified
version of SimpleJSONRPCServer.py i had to rip bits of
BaseHTTPServer.py and add in Connection Keep-Alives on every
response.  so, send_error needed modding/replacing, as did send_head,
list_directory and so on, all with a view to making sure that the HTTP
proxy is "happy".

 the reason why the proxy works is because the incoming HTTP
connection results in an HTTP/1.1 proxy connection with Connection:
Keep-Alive set.  so, even if the user's browser drops the connection,
the proxy permanently keeps open the connection to the upstream HTTP
server.  in the case of the standard SimpleHTTPServer.py and so on
that results in the handle_request() loop basically serving that same
user _forever_.  well... it would, if it wasn't for the fact that the
standard version of send_error() in BaseHTTPServer.py does
"Connection: Close", hence the reason why i had to replace it.

 so, yeah - now you can do truly dreadful things like... create a
massive in-memory data structure and never have to serialise it
because the back-end process will _still_ be around pretty much
forever... and you can keep doing that until the server runs out of
memory.  hurrah!

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


Re: File transfer on network

2010-07-15 Thread MRAB

mukesh tiwari wrote:

Hello all
Currently i am trying to develop a client and server in python. Client
takes screenshot in every 20 seconds and send it to server. Server
store the received file in folder. Here is code for Client

import sys
import socket
import gtk.gdk
import time
if __name__ == "__main__":
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
host,port="localhost",50007
s.connect((host,port))
while 1:
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = 
pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
if (pb != None):
   pb.save('/home/tmp_1/screenshot.png',"png")
f=open('/home//tmp_1/screenshot.png','rb')
while 1:
blk=f.read(2048)
if not blk:break
s.send(blk)
f.close()
print 'file transfer done';
time.sleep(20)

s.close()


Server Code
import sys
import socket
import time
if __name__ == "__main__":

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host,port="",50007
s.bind((host,port))
s.listen(1)
  conn,add=s.accept()
i=0
while 1:
f=open('/home/tmp_2/copyscreenshot_'+str(i)+'.png','wb')
while 1:
data=conn.recv(2048)
if not data:break
f.write(data)

f.close()
print 'file received'
time.sleep(20)
i+=1;
#print ' file received '

conn.close()


My problem is that server is copying only first image
copyscreenshot_0.png while my client continuously taking screen shot.
Kindly tell me what is wrong with my server code.


The .recv will return an empty string only when the connection is closed
by the client, but the client keeps the connection open.

You could either open and close a connection for each image, or have the
client tell the server how many bytes it's going to send, followed by
the bytes (my preference would be to send the size as a string ending
with, say, a newline).

Another point: the .send method doesn't guarantee that it'll send all
the bytes (it'll return the number of bytes that it has actually sent);
use the .sendall method instead.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Carl Banks
On Jul 15, 11:45 am, Karsten Wutzke  wrote:
> On 15 Jul., 20:28, Thomas Jollans  wrote:
>
> > On 07/15/2010 07:58 PM, Karsten Wutzke wrote:
>
> > > Hello,
>
> > > this is obviously a Python OO question:
>
> > > Since Python isn't stringly typed,
>
> > I expect this is an innocent typo, and you mean strictly.
>
> > > single-dispatch isn't available per se. So is the "double-dispatch" 
> > > Visitor pattern,
>
> Yes, typo, I meant strictly.
>
>
>
>
>
> > Wait, what?
> > First of all, python is strictly typed in that every object has exactly
> > one type, which is different from other types. So you can't do "1"+2, as
> > you can in some other languages.
>
> > Anyway, this is interesting: Tell me more about how Python's dynamic
> > nature makes it impossible to do whatever you're trying to do. I'm
> > baffled. What are you trying to do, anyway?
>
> > > which is usually used
> > > in OO systems to implement code generators. So, what is the de facto
> > > method in Python to handle source code generation?
>
> > WHOA! Now if that isn't a Gedankensprung. Also, I'm still very far from
> > your train of thought, apparently: Now, the thing that code generators
> > probably share is that they write code to files. It depends on what I'm
> > trying to do of course, but I expect there's a good chance that if I
> > wrote a code generator in Python, it wouldn't be particularly
> > object-oriented at all.
>
> Well, I'm most experienced in OO, so writing OO in Python seems like
> the way to start with Python. The visitor pattern uses single-
> dispatch, that is, it determines which method to call be the type of
> object passed in. I did some reading and it turned out that Python
> can't do it without some tricks (function decorators and 3rd party
> code). For what I'm doing, I can't, or rather don't want to rely on
> 3rd party code (that has reasons). Thus, the visitor OO pattern must
> be replaced by some other way.

Oh brother.

Around these parts, we consider the main use of most Design Patterns
to be to work around limitations of other languages.  Visitor Pattern
is probably the worst example of it.

In Python it's completely unnecessary (at least in its boilerplate-
heavy incarnation as used in C++), and the fact that Python isn't
strongly typed, as you put it, is exactly the reason why.

Say you have a bunch of unrelated types that define a calculate
method, you have a variable x that could be any of these types.
Here's how you would do that in Python:

x.calculate()

Bam, that's it.  Visitor Pattern in Python.  You don't have to create
a bunch of homemade dispatching boilerplate like you do in C++.


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


[ANNC] pynguin-0.9 (python turtle graphics application)

2010-07-15 Thread Lee Harr

Pynguin is a python-based turtle graphics application.
    It combines an editor, interactive interpreter, and
    graphics display area.

It is meant to be an easy environment for introducing
    some programming concepts to beginning programmers.


http://pynguin.googlecode.com/


This release has focused on improvements to usabilty and
    user-friendliness, with much input and many reports
    from actual users. Thanks Alec! There is a huge list
    of bug fixes and new features.


Pynguin is tested with Python 2.6.5 and PyQt 4.7.2 and
    will use Pygments syntax highlighting if available.

Pynguin is released under GPLv3.


Changes in pynguin-0.9:
    Pynguin API
    - added pythonic accessors for .x .y and .heading
    - added methods for getting heading: xyh() and h()
    - added promote() method to change which pynguin is primary
    - added remove() to get rid of unneeded pynguins
    - also enables removing pynguin, but keeping its drawing
    - added reap() method to remove all other pynguins and
    take charge of all their drawings at once
    - made turnto() instant, like goto()
    - plain reset() now only affects single pynguin
    - restores as much as possible to initial state
    - use reset(True) or reset(full=True) for complete reset
    - square() is now built in
    - added avatar() to access setImageid() more reliably
    - changed onclick() API slightly
    - updated onclick examples and added new examples

    Canvas
    - added ability to zoom and pan the canvas
    - added ability to track pynguin if it draws off the screen
    - pynguins can now be dragged in to position
    - now passes mouse clicks to all pynguins

    Integrated Editor
    - fixed problem with editor undo entries being lost
    - better recognition of when document has actually been modified
    - automatically strips prompts when pasting to code editor
    - allow changing font size and word wrapping in editor
    - fixed tabifying/untabifying selection in editor

    Integrated Console
    - fixed copying from console area (shortcut and context menu)
    - KeyboardInterrupt is now quiet by default
    - fixed tab/backtab in console area
    - added keyboard shortcuts for scrolling in console
    - added ctrl-d shortcut for exiting when typing in console

    General
    - added periodic automatic saving
    - better control-c handling
    - code that never uses Pynguin methods can now be stopped
    - limits print rate to keep console responsive
    - fixed prompt alignment after ctrl-c on non-function code
    - made .png default export and improved error message on failure
    - now allows unicode in code area and console
    - added command line switch to enable debugging
    - added Save As, New, and Open shortcuts

  
_
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: About problems that I have with learning wxPython in Macintosh

2010-07-15 Thread Benjamin Kaplan
On Thu, Jul 15, 2010 at 3:04 PM, ata.jaf  wrote:

> Hi,
> I'm newbie to wxPython and need it to develop my little app.
> But from start I have problems with tutorials. Because all of them are
> compatible with Windows but not so much with Mac.
> For example in this code:
>
>
> import wx
>
> class MainWindow(wx.Frame) :
>  def __init__(self, parent, title) :
>   wx.Frame.__init__(self, parent, title=title, size=(200, 100))
>   self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
>   self.CreateStatusBar()
>
>   filemenu = wx.Menu()
>
>   filemenu.Append(wx.ID_ABOUT, '&About', ' Information about this
> program.')
>   filemenu.AppendSeparator()
>   filemenu.Append(wx.ID_EXIT, 'E&xit', ' Terminate the program')
>
>   menuBar = wx.MenuBar()
>   menuBar.Append(filemenu, '&File')
>   self.SetMenuBar(menuBar)
>   self.Show(True)
>
> app = wx.App(False)
> frame = MainWindow(None, 'Sample editor')
> app.MainLoop()
>
>
>
> The menus doesn't appear in the product.
> Can anyone help me to find a tutorial that is for using wxPython on a
> Mac?
> Thanks
> Ata
> --
>


Did you look on the menubar? wxPython uses native components (Cocoa in the
case of OS X) so the menu should appear in the menu bar and not in the
application window. wx will automatically move some of the items in the menu
to the appropriate location (About, Preferences, and Quit are all in the
Application menu for instance and not the file menu)

The wxPython Wiki has a page about Mac-specific issues :
http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X

Also, you'll get better answer for questions like this (which are
wx-specific and not Python-specific) on the wxPython list:
http://groups.google.com/group/wxpython-users
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Errno 9] Bad file descriptor

2010-07-15 Thread joblack
> Where does the error occur? If Cameron is right, it occurs somewhere
> completely different, when serializer.dump() is already long done, when
> some unsuspecting fool tries to do something with serializer.outf (such
> as closing it)
I have found it but still I don't get it.

Dump looks like this:

...

File "C: ... ineptpdf8.4.20.pyw", line 1266, in initialize return
self.initialize_fopn(docid, param)
File "C: ... ineptpdf8.4.20.pyw", line 1411, in initialize_fopn print
buildurl

IOError: [Errno 9] Bad file descriptor

Two strange things:

1st: in the buildurl is only the url (as a string) to open (something
like http://www.serverblaba.com/asdfasdf?wdfasdf=4&awfwf=34 ...)
2nd: it works if I start in in IDLE, it doesn't work if I double klick
on the .pyw file.

How can printing out a string throw a IOError exception? I'm quite
puzzled.
-- 
http://mail.python.org/mailman/listinfo/python-list


Fairy scenes

2010-07-15 Thread nais-saudi
Fairy scenes


The sections that cried and asked YouTube viewers translation:

http://www.youtube.com/v/IFq9cjtrWlQ&rel=0

http://www.youtube.com/v/y2BN73Q-AJw&rel=0

http://www.youtube.com/v/nNFMvznJ-4c&rel=0

http://www.youtube.com/v/qVB9HNQ-w2I&rel=0

http://www.youtube.com/v/RWfR9z91j8I&rel=0


http://www.todayislam.com/yusuf.htm
http://islamtomorrow.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Errno 9] Bad file descriptor

2010-07-15 Thread MRAB

joblack wrote:

Where does the error occur? If Cameron is right, it occurs somewhere
completely different, when serializer.dump() is already long done, when
some unsuspecting fool tries to do something with serializer.outf (such
as closing it)

I have found it but still I don't get it.

Dump looks like this:

...

File "C: ... ineptpdf8.4.20.pyw", line 1266, in initialize return
self.initialize_fopn(docid, param)
File "C: ... ineptpdf8.4.20.pyw", line 1411, in initialize_fopn print
buildurl

IOError: [Errno 9] Bad file descriptor

Two strange things:

1st: in the buildurl is only the url (as a string) to open (something
like http://www.serverblaba.com/asdfasdf?wdfasdf=4&awfwf=34 ...)
2nd: it works if I start in in IDLE, it doesn't work if I double klick
on the .pyw file.

How can printing out a string throw a IOError exception? I'm quite
puzzled.


The extension .pyw says to run the script without opening a console
window. If there's no console, the script can't print to it. Result?
IOError exception.
--
http://mail.python.org/mailman/listinfo/python-list


__getattribute__ hook and len() problem

2010-07-15 Thread ernest
Hi!

I have this class that overrides the __getattribute__ method,
so that it returns the attributes of str(self) instead of the
attributes of self.

class Part(object):
def __init__(self):
self.content = []
def __str__(self):
return str.join('\n', self.content)
def __getattribute__(self, name):
if name in ['content', 'write', '__str__']:
return object.__getattribute__(self, name)
else:
return str(self).__getattribute__(name)
def write(self, data):
self.content.append(data)

Then I do:

In [50]: p = Part()

In [51]: p.write('foo')

In [52]: p.upper()
Out[56]: 'FOO'

This is okay, works as expected.

However, len(p) fails:

TypeError: object of type 'Part' has no len()

And yet, p.__len__() returns 3. I though len(object) simply
called object.__len__.

Can somebody shed some light on this??

Many thanks in advance.

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


Toronto PyCamp 2010

2010-07-15 Thread Chris Calloway
The University of Toronto Department of Physics brings PyCamp to Toronto 
on Monday, August 30 through Friday, September 3, 2010.


Register today at http://trizpug.org/boot-camp/torpy10/

For beginners, this ultra-low-cost Python Boot Camp makes you productive 
so you can get your work done quickly. PyCamp emphasizes the features 
which make Python a simpler and more efficient language. Following along 
with example Python PushUps™ speeds your learning process in a modern 
high-tech classroom. Become a self-sufficient Python developer in just 
five days at PyCamp! Conducted on the campus of the University of 
Toronto, PyCamp comes with your own single OS/single developer copy of 
Wing Professional Python IDE.


--
Sincerely,

Chris Calloway
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599
--
http://mail.python.org/mailman/listinfo/python-list


Re: __getattribute__ hook and len() problem

2010-07-15 Thread Chris Rebert
On Thu, Jul 15, 2010 at 5:42 PM, ernest  wrote:
> Hi!
>
> I have this class that overrides the __getattribute__ method,
> so that it returns the attributes of str(self) instead of the
> attributes of self.
>
> class Part(object):
>    def __init__(self):
>        self.content = []
>    def __str__(self):
>        return str.join('\n', self.content)
>    def __getattribute__(self, name):
>        if name in ['content', 'write', '__str__']:
>            return object.__getattribute__(self, name)
>        else:
>            return str(self).__getattribute__(name)
>    def write(self, data):
>        self.content.append(data)
>
> Then I do:
>
> In [50]: p = Part()
>
> In [51]: p.write('foo')
>

> However, len(p) fails:
>
> TypeError: object of type 'Part' has no len()
>
> And yet, p.__len__() returns 3. I though len(object) simply
> called object.__len__.
>
> Can somebody shed some light on this??

Quoth 
http://docs.python.org/reference/datamodel.html#more-attribute-access-for-new-style-classes
:
"""
3.4.2.1. More attribute access for new-style classes

object.__getattribute__(self, name)

***Note: This method may still be bypassed when looking up special
methods as the result of implicit invocation via language syntax or
built-in functions. See Special method lookup for new-style classes
(http://docs.python.org/reference/datamodel.html#new-style-special-lookup
).***
""" (emphasis mine)

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


Re: __getattribute__ hook and len() problem

2010-07-15 Thread Christian Heimes
> And yet, p.__len__() returns 3. I though len(object) simply
> called object.__len__.

Not exactly, all __magic__ methods of new style classes are called like
getattr(type(obj), "__len__")(obj). As a result magic methods are never
looked up on the object, including hooks like __getattr_() and
__getattribute__().

Christian

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


Re: Naming Conventions, Where's the Convention Waldo?

2010-07-15 Thread Aahz
In article <4c3a8087$0$28662$c3e8...@news.astraweb.com>,
Steven D'Aprano   wrote:
>
>For some reason, when I answer the phone and say "Hello, Steven 
>speaking?" I often get called Peter.

That's the Peter Principle in action.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Normal is what cuts off your sixth finger and your tail..."  --Siobhan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __getattribute__ hook and len() problem

2010-07-15 Thread ernest
Thanks Chris & Christian.
Mistery solved :)

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


Re: C interpreter in Lisp/scheme/python

2010-07-15 Thread Seebs
On 2010-07-15, bolega  wrote:
> This makes some sense. He replied on the newsgroup in a lengthy post
> that there are sufficient resources out there giving hint that no one
> need help me out. Then I was called "lazy" in one email and tersely
> given JUST the last name of an author who has many books each many
> 100s pages, when I asked for a relevant book, as if i am a scholar in
> the field, although he did spend lots of words on irrelevant and
> unbeneficial things which diminished my enthusiasm.

If you found those "irrelevant and unbeneficial", then while I agree that he
may have been wasting his time, he would have been wasting it even worse
trying to walk you through the technical material when you're clearly
not currently at a stage where you are ready to learn anyway.

> Now, I find out
> from you that he has/had a business concern or interest in a company
> that is writing/wrote lisp interpreter in C. Correct me if I am making
> an error. I dont want to think deprecatingly of any good soul but this
> is what i experienced.

If you are trying to imply that he was acting in some unethical way, you have
further cemented the notion that trying to talk to you is a waste of anyone's
time.  *plonk*

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie: Python 3 and MySQL???

2010-07-15 Thread fuglyducky
I am brand new Python and need to connect to a MySQL DB. The books I
have been using are all Python 3 so I'd like to stick with what I
know. Does anyone know if there is a library out there for connecting
to MySQL with Python 3? If not, does anyone have any info on when
MySQLdb may be ported?

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


Re: Fascinating interview by Richard Stallman on Russia TV

2010-07-15 Thread gavino
On Jul 7, 1:56 pm, bolega  wrote:
> "Democracy is sick in the US, government monitors your 
> Internet"http://www.youtube.com/watch?v=2BfCJq_zIdk&feature=fvsr
>
> Enjoy .

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


Re: Splitting numeric litterals

2010-07-15 Thread Lawrence D'Oliveiro
In message , MRAB wrote:

> Normally it's only string literals that could be so long that you might
> want to split them over several lines. It is somewhat unusual to have a
> _numeric_ literal that's very very long!

Seems a peculiar assumption to make in a language that allows integers of 
arbitrary length, does it not?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel

Carl Banks, 16.07.2010 01:14:

Around these parts, we consider the main use of most Design Patterns
to be to work around limitations of other languages.  Visitor Pattern
is probably the worst example of it.

In Python it's completely unnecessary (at least in its boilerplate-
heavy incarnation as used in C++), and the fact that Python isn't
strongly typed, as you put it, is exactly the reason why.

Say you have a bunch of unrelated types that define a calculate
method, you have a variable x that could be any of these types.
Here's how you would do that in Python:

 x.calculate()

Bam, that's it.  Visitor Pattern in Python.  You don't have to create
a bunch of homemade dispatching boilerplate like you do in C++.


Well, you can do that in every OO language. It's not what the visitor 
pattern is there for, though.


The code I referenced is from the Cython compiler, and we use it to "do 
stuff" with the AST. The visitor pattern is actually a pretty common way to 
bind code in a single place that does a certain thing to different parts of 
a data structure. Without it, if you kept that code *inside* of the data 
structure, you'd have to spill the type specific parts all over your code.


Stefan

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


Re: Code generator and visitor pattern

2010-07-15 Thread Paul Rubin
Karsten Wutzke  writes:
> Since Python isn't stringly typed, single-dispatch isn't available per
> se. So is the "double-dispatch" Visitor pattern, which is usually used
> in OO systems to implement code generators. So, what is the de facto
> method in Python to handle source code generation?

A minute of web surfing found this:

http://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Python 3 and MySQL???

2010-07-15 Thread Rami Chowdhury

On Jul 15, 2010, at 19:53 , fuglyducky wrote:

> I am brand new Python and need to connect to a MySQL DB. The books I
> have been using are all Python 3 so I'd like to stick with what I
> know. Does anyone know if there is a library out there for connecting
> to MySQL with Python 3?

I believe OurSQL supports Python 3.x -- http://packages.python.org/oursql/

HTH,
Rami

-
Rami Chowdhury
"Never assume malice when stupidity will suffice." -- Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)

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


IDLE won't start on Mac OSX

2010-07-15 Thread Dylan Gleason
Hello, 

My name is Dylan. I am new to this list and am just getting started with Python 
and programming in general (although I have some experience with general UNIX 
wankery).

I am trying to fire up Python ver. 2.7 with IDLE (I am using Mac OSX 10.6.3), 
but it will not start, citing the following error message:

>>> IDLE's subprocess didn't make connection. Either IDLE can't start 
>>> subprocess or 
>>>personal firewall software is blocking the connection.

I tried disabling my firewall and restarting but unfortunately I still get the 
same message.

I executed Python via the command line and it seemed to work just fine. Can 
someone help me??

Thanks,
Dylan


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


  1   2   >