Re: subprocess.Popen(..., cwd=...) and Makefile $(PWD) don't play nice

2008-10-07 Thread Thomas Bellman
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:

> En Mon, 06 Oct 2008 13:09:26 -0300, Miki <[EMAIL PROTECTED]> escribió:

>> Can anybody explain why Makefile $(PWD) does show the right directory
>> when running under subprocess.Popen(..., cwd=...)
>>
>> For example:
>> [18:07] tmp $cat /tmp/p/Makefile
>> all:
>> @echo $(PWD)
>> [18:07] tmp $cat t
>> #!/usr/bin/env python
>>
>> from subprocess import Popen
>> Popen(["make"], cwd="/tmp/p")
>>
>> [18:07] tmp $./t
>> /tmp
>>
>> The output of the "make" command should have been "/tmp/p" and not "/
>> tmp"

> I've tried the equivalent version on Windows and it worked fine.
> And I can't see how make could find the Makefile at /tmp/p if the current
> directory were another one... (?)

The problem is, he is not printing the name of the current working
directory; he is printing the value of the variable $PWD.  That is
likely set from the environment by the shell he started the Python
program from, but Python does *not* update to reflect changes to
the working directory.

Use '@pwd' instead of '@echo $(PWD)'.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"Beware of bugs in the above code; I have!  bellman @ lysator.liu.se
 only proved it correct, not tried it."  !  Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Array of dict or lists or ....?

2008-10-07 Thread Gabriel Genellina
En Mon, 06 Oct 2008 22:52:29 -0300, Tim Chase  
<[EMAIL PROTECTED]> escribió:



   __repr__ = __str__


[EMAIL PROTECTED] wrote]

 I don't know if that's a good practice.


I've seen it in a couple places, and it's pretty explicit what it's  
doing.


__repr__ is used as a fallback for __str__, so just defining __repr__ (and  
leaving out __str__) is enough.


--
Gabriel Genellina

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


Python 2.5.3: call for patches

2008-10-07 Thread Martin v. Löwis
Within a few weeks, we will release Python 2.5.3. This will be the last
bug fix release of Python 2.5, afterwards, future releases of 2.5 will
only include security fixes, and no binaries (for Windows or OSX) will
be provided anymore (from python.org).

In principle, the release will include all changes that are already on
the release25-maint branch in subversion [1]. If you think that specific
changes should be considered, please create an issue in the bug tracker
[2], and label it with the 2.5.3 version. Backports of changes that
are already released in Python 2.6 but may apply to 2.5 are of
particular interest.

Regards,
Martin

[1] http://svn.python.org/projects/python/branches/release25-maint/
[2] http://bugs.python.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: type-checking support in Python?

2008-10-07 Thread Lorenzo Gatti
On 7 Ott, 08:36, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message <[EMAIL PROTECTED]>, Gabriel
>
> Genellina wrote:
> > As an example, in the oil industry here in my country there is a mix of
> > measurement units in common usage. Depth is measured in meters, but pump
> > stroke in inches; loads in lbs but pressures in kg/cm².
>
> Isn't the right way to handle that to attach dimensions to each number?

Can you afford to avoid floats and ints? Attaching suffixes is the
best one can do with the builtin types.
In C++ one can check dimensions at compile time (http://www.boost.org/
doc/libs/1_36_0/doc/html/boost_units.html) with a modest increase of
cumbersomeness, but Python would need very heavyweight classes
containing a value and its dimension and a replacement of all needed
functions and operations.

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


Re: type-checking support in Python?

2008-10-07 Thread Gabriel Genellina
En Tue, 07 Oct 2008 03:36:12 -0300, Lawrence D'Oliveiro  
<[EMAIL PROTECTED]> escribió:



In message <[EMAIL PROTECTED]>, Gabriel
Genellina wrote:


As an example, in the oil industry here in my country there is a mix of
measurement units in common usage. Depth is measured in meters, but pump
stroke in inches; loads in lbs but pressures in kg/cm².


Isn't the right way to handle that to attach dimensions to each number?


Maybe, but I prefer the values to be plain float objects. In my case it's  
not that units are dynamic themselves: "this" file format has depth in  
feet, "that" one uses meters, but that's known from start. I think I'd  
attach units to values if they were dynamic and I had to reproduce the  
original format exactly, but hasn't happened yet (fortunately).


--
Gabriel Genellina

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


export opengl context to pdf

2008-10-07 Thread Vaibhav . bhawsar
Hi,
Does anyone know of a package that will allow me to output an opengl
context as a PDF (or postscript)?
I am using pyglet to render something on screen that i want to save as PDF.

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


Re: Array of dict or lists or ....?

2008-10-07 Thread Hrvoje Niksic
Tim Chase <[EMAIL PROTECTED]> writes:

>>>__repr__ = __str__
>>
>> I don't know if that's a good practice.
>
> I've seen it in a couple places, and it's pretty explicit what it's
> doing.

But what's the point?  Simply define __repr__, and both repr and str
will pick it up.
--
http://mail.python.org/mailman/listinfo/python-list


managing releases of web applications: is svn checkout the best way?

2008-10-07 Thread Ksenia
Hi,

For website development, I am using SVN repository to commit the code
from my development computer, and on the production server use svn
checkout to update the code to the latest version.
Is this the most common approach people using? Or is there maybe a
better way to manage "live" releases, like creating an egg for each
release? Assuming the code is closed-source and should be kept secure.

Just wondering how you people deal with that.
Thanks
Ksenia
--
http://mail.python.org/mailman/listinfo/python-list


Python pre-release announcements (was: Python 2.5.3: call for patches)

2008-10-07 Thread Ben Finney
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:

> Within a few weeks, we will release Python 2.5.3.

I'm glad to see this. Thank you to all involved in the ongoing work of
coordinating Python releases.

Can I request, in the interest of reducing confusion, that any
announcements of pre-release versions of 2.5.3 (or any other Python
release) be announced *without* saying “RELEASED: A not-really-release
version of Python”.

It's very confusing to see a progression of announcements with subject
fields like:

RELEASED: Python 2.8.not-ready-yet
RELEASED: Python 2.8.alpha-1
RELEASED: Python 2.8.beta-1
RELEASED: Python 2.8.beta-2
RELEASED: Python 2.8 release candidate 1
RELEASED: Python 2.8 release candidate 2
RELEASED: Python 2.8 final

The word “RELEASED” is a strong indicator that a new version of
Python (in this case) is *released*, not merely available in a
pre-release form. The only one that qualifies in the above list is the
last one where Python 2.8 is *actually* released. Otherwise, the word
becomes overburdened with too many meanings and doesn't indicate
anything strongly.

It would be much less confusing if the word “release” in such
announcements was reserved for the release *of that version* (in this
case, 2.8), and not for the availability of some pre-release. Perhaps
simply using the word “ANNOUNCED” or abbreviated “ANN”:

[ANN] Python 2.8.not-ready-yet
[ANN] Python 2.8.alpha-1
[ANN] Python 2.8.beta-1
[ANN] Python 2.8.beta-2
[ANN] Python 2.8 release candidate 1
[ANN] Python 2.8 release candidate 2
[ANN] Python 2.8 final

That, to me at least, communicates what's actually happening far
better and leads to less confusion about what the state of release is.


I recall making this point some while ago to positive effect (thank
you!), but it seems to have been ignored in the recent progression of
announcements for Python 2.6. I didn't want to complain at that point,
with such a good job being done otherwise by the Python 2.6 release
team.

Is there some policy document or release management guide that could
be updated for release teams to follow on this without needing to have
this discussion every time?

-- 
 \“I used to work in a fire hydrant factory. You couldn't park |
  `\  anywhere near the place.” —Steven Wright |
_o__)  |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dict Comprehension ?

2008-10-07 Thread Ernst-Ludwig Brust
<[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
>
> Instead of creating the list (array) dif, you can create a lazy
> iterator. Then you can fed it to a set.

Thangs,
this idea is not only less storage-consuming but even faster
than the "List-Version".
But, i used the idea of pruebauno,
as this is faster.

Ernst-Ludwig Brust 


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


Re: Dict Comprehension ?

2008-10-07 Thread Ernst-Ludwig Brust
"Ben Finney" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
> "Ernst-Ludwig Brust" <[EMAIL PROTECTED]> writes:
>
> So, generator expressions can be a powerful way to clarify the purpose
> of a section of code. They can be over-used, though: don't use them
> unless they actually *do* clarify the code; sometimes an explicit
> looping construct is clearer.

Thangs,
my opinion was, that "one-statement-constructions" are
much faster then f.e. explicit loops.
But,
now i know, with Python, this is not allways true.

Ernst-Ludwig Brust 


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


Re: Dict Comprehension ?

2008-10-07 Thread Ernst-Ludwig Brust
<[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
>
> from collections import defaultdict
> da=defaultdict(int)
> for x in [10]:
>for y in [11]:
>da[abs(x-y)]+=1

Thangs,
collections are a real good idea.
I will use this version.

Ernsst-Ludwwig Brust


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


Re: HARD REAL TIME PYTHON

2008-10-07 Thread bieffe62
On 7 Ott, 01:25, "Blubaugh, David A." <[EMAIL PROTECTED]> wrote:
> To All,
>
> I have done some additional research into the possibility of utilizing
> Python for hard real time development.  I have seen on various websites
> where this has been discussed before on the internet.  However, I was
> wondering as to how successful anyone has truly been in developing a
> program project either in windows or in Linux that was or extremely
> close to real time constraints? For example is it possible to develop a
> python program that can address an interrupt or execute an operation
> within 70 Hz or less?? Are there any additional considerations that I
> should investigate first regarding this matter??
>
> Thanks,
>
> David Blubaugh
>
> This e-mail transmission contains information that is confidential and may be
> privileged. It is intended only for the addressee(s) named above. If you 
> receive
> this e-mail in error, please do not read, copy or disseminate it in any 
> manner.
> If you are not the intended recipient, any disclosure, copying, distribution 
> or
> use of the contents of this information is prohibited. Please reply to the
> message immediately by informing the sender that the message was misdirected.
> After replying, please erase it from your computer system. Your assistance in
> correcting this error is appreciated.

AFAIK, the requirement for hard real time, is that response time have
to be predictable, rather than
generally 'fast'.
Very high level languages like python use many features which are by
their nature unpredictable or
difficult to predict in their response times: to name a pair, garbage
collection and hash table lookups.
Usually real time programmers tend not to use these features even when
they program with lower level
languages such as C, ot at least to use them only during
initialization, when being predictable is less
important.

So no, I would not use python for hard real time ...
Said that, I have to say that once used python to simulate  the
protocol of a device which my code (in ADA) had to interface. Typical
response times in this protocol was about 10ms, and my small python
simulator usually managed to respond in that time, although sometime
it delayed its response causing the response timeout in my code to
expire ...


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


Re: Builing Python 2.6 on AIX 5.2

2008-10-07 Thread brasse
On Oct 6, 5:03 pm, "Jesse Noller" <[EMAIL PROTECTED]> wrote:
> Looks like AIX is missing sem_timedwait - see:http://bugs.python.org/issue3876
>
> Please add your error to the bug report just so I can track it.
>
> -jesse
>

OK, I have now added my information to the bug tracker.

I would be quite happy if I could build Python on AIX without the
multiprocessing module. Is there some way I can skip some selected
modules when building Python. I tried with ./configure --without-
multiprocessing, but that didn't work.

:.:: mattias


> On Mon, Oct 6, 2008 at 4:16 AM, brasse <[EMAIL PROTECTED]> wrote:
> > Hello!
>
> > I am having some trouble building Python 2.6 on AIX. The steps I have
> > taken are:
>
> > export PATH=/usr/bin/:/usr/vacpp/bin/
> > ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6
> > make
>
> > This is the error message I'm seeing:
> > ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/
> > temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/_multiprocessing/
> > multiprocessing.o build/temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/
> > _multiprocessing/socket_connection.o build/temp.aix-5.2-2.6/home/mabr/
> > Python-2.6/Modules/_multiprocessing/semaphore.o -L/usr/local/lib -o
> > build/lib.aix-5.2-2.6/_multiprocessing.so
> > ld: 0711-317 ERROR: Undefined symbol: .sem_timedwait
> > ld: 0711-317 ERROR: Undefined symbol: .CMSG_SPACE
> > ld: 0711-317 ERROR: Undefined symbol: .CMSG_LEN
> > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> > information.
> > *** WARNING: renaming "_multiprocessing" since importing it failed: No
> > such file or directory
> > error: No such file or directory
> > make: The error code from the last command is 1.
>
> > Have someone on this list had similar problems? Am I missing some
> > libraries? The configure script runs without errors, I would have
> > expected some kind of error there if I was missing something.
>
> > Regards,
> > Mattias
> > --
> >http://mail.python.org/mailman/listinfo/python-list

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


Re: how to start thread by group?

2008-10-07 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Gabriel
Genellina wrote:

> Usually it's more efficient to create all the MAX_THREADS at once, and
> continuously feed them with tasks to be done.

Given that the bottleneck is most likely to be the internet connection, I'd
say the "premature optimization is the root of all evil" adage applies
here.
--
http://mail.python.org/mailman/listinfo/python-list


Re: managing releases of web applications: is svn checkout the best way?

2008-10-07 Thread Michele Simionato
On Oct 7, 9:55 am, Ksenia <[EMAIL PROTECTED]> wrote:
> Hi,
>
> For website development, I am using SVN repository to commit the code
> from my development computer, and on the production server use svn
> checkout to update the code to the latest version.
> Is this the most common approach people using? Or is there maybe a
> better way to manage "live" releases, like creating an egg for each
> release? Assuming the code is closed-source and should be kept secure.
>
> Just wondering how you people deal with that.
> Thanks
> Ksenia

We make a tag for each new release and then a SVN export. This works
for pure Python code.
We also have dependencies for C++ libraries, which change less often.
For them,
we make eggs.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is PyFIT dead and abandoned?

2008-10-07 Thread Fuzzyman
On Oct 7, 1:34 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> "James Mills" <[EMAIL PROTECTED]> writes:
> > On Tue, Oct 7, 2008 at 5:18 AM,  <[EMAIL PROTECTED]> wrote:
> > > Has PyFIT been completely abandoned? Is there a better alternative or
> > > other resources to help me integrate fitnesse and python?
>
> > I for one am not interested in this kind of framework for testing -
> > and yet I come from a strict Software Engineering background where
> > this kind of User Acceptance and Requirements-based testing is
> > taught.
>
> How, then, do you automate functional testing of the full system?
>
> > I think you'll find most developers prefer to use unit test
> > frameworks and python has a great one built-in to the standard
> > library. In 99.9% of use cases, writing unit tests and well
> > documented and well designed, re-usable units of code is far better
> > than what any Requirements and Interactive testing framework could
> > ever offer.
>
> I completely disagree. Unit tests are essential for testing code
> *units*; e.g. functions and classes and attributes (oh my).They're a
> poor fit for testing the behaviour of the overall system: for that, a
> functional test suite is needed, and PyFIT seems to be a good .
>
> Automated unit tests and automated functional tests are complementary,
> and do not replace one another. Both are needed to have confidence in
> the code.

At Resolver Systems we have built our own functional test framework on
top of unittest. It automates the applications but uses the usual
'assert*' methods and patterns to make assertions about the
application state.

Michael


>
> --
>  \     “Injustice is relatively easy to bear; what stings is justice.” |
>   `\                                                 —Henry L. Mencken |
> _o__)                                                                  |
> Ben Finney

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


Re: equivalent of py2exe in other os

2008-10-07 Thread Pierre-Alain Dorange
<[EMAIL PROTECTED]> wrote:

> For Linux I know of (but never used myself) PyInstaller :
> http://pyinstaller.python-hosting.com/
> They seem to have a in-development version for OS/X too, so maybe you
> could give it a try ...

py2app for Mac works fine.

-- 
Pierre-Alain Dorange

Ce message est sous licence Creative Commons "by-nc-sa-2.0"

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


SMTPlib inside function, extra tab

2008-10-07 Thread Hunter
I am writing a script that needs to send some emails.  And I've used
smtplib in the past and it is pretty easy.  But I thought, gee it
would be easier if I could just call it as a function, passing the
from, to, subject, and message text.  So I wrote it up as a function
and it sort of works, but I get a weird error.  When it runs it
inserts a "\t" tab character before each item during the send portion
(which I can see when I turn on debug).  The end result is that I
don't get any body or subject in my emails.  It works fine when I copy
the inside of the function and run it directly.  It isn't a
dealbreaker, I can certainly just call it direct, but from a learning
Python perspective I'm wondering if anyone knows what exactly is
happening.I'm more interested in the why this is happening than a
solution (though that would be great too).  Oh and if you could
explain it to me, with no CS background, that would be even better.

I am working on Windows Vista with Python 2.5.2 (activestate).

Thanks --Joshua

Snip of script (more or less a copy/paste from effbot):
fromaddress = '[EMAIL PROTECTED]'
tolist = ['[EMAIL PROTECTED]','[EMAIL PROTECTED]']
msgsubj = "Hello!"
messagebody = "This message was sent with Python's smtplib."


def send_mail(fromaddress,tolist,msgsubj,messagebody):
import smtplib
SERVER = "mymailserver.mydomain.com"
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (fromaddress, ", ".join(tolist),msgsubj, messagebody)
print message
server = smtplib.SMTP(SERVER)
server.set_debuglevel(1)
server.sendmail(fromaddress, tolist, message)
server.quit()

send_mail(fromaddress, tolist, msgsubj, messagebody)

Output when called from function:
send: 'ehlo twaus-mycomputer.mydomain.local\r\n'
reply: '250-mymailserver.mydomain.com Hello [10.10.10.119]\r\n'
reply: '250-TURN\r\n'
reply: '250-SIZE\r\n'
reply: '250-ETRN\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-DSN\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-8bitmime\r\n'
reply: '250-BINARYMIME\r\n'
reply: '250-CHUNKING\r\n'
reply: '250-VRFY\r\n'
reply: '250-X-EXPS GSSAPI NTLM LOGIN\r\n'
reply: '250-X-EXPS=LOGIN\r\n'
reply: '250-AUTH GSSAPI NTLM LOGIN\r\n'
reply: '250-AUTH=LOGIN\r\n'
reply: '250-X-LINK2STATE\r\n'
reply: '250-XEXCH50\r\n'
reply: '250 OK\r\n'
reply: retcode (250); Msg: mymailserver.mydomain.com Hello
[10.10.10.119]

TURN
SIZE
ETRN
PIPELINING
DSN
ENHANCEDSTATUSCODES
8bitmime
BINARYMIME
CHUNKING
VRFY
X-EXPS GSSAPI NTLM LOGIN
X-EXPS=LOGIN
AUTH GSSAPI NTLM LOGIN
AUTH=LOGIN
X-LINK2STATE
XEXCH50
OK
send: 'mail FROM:<[EMAIL PROTECTED]> size=159\r\n'
reply: '250 2.1.0 [EMAIL PROTECTED] OK\r\n'
reply: retcode (250); Msg: 2.1.0 [EMAIL PROTECTED] OK
send: 'rcpt TO:<[EMAIL PROTECTED]>\r\n'
reply: '250 2.1.5 [EMAIL PROTECTED] \r\n'
reply: retcode (250); Msg: 2.1.5 [EMAIL PROTECTED]
send: 'rcpt TO:<[EMAIL PROTECTED]>\r\n'
reply: '250 2.1.5 [EMAIL PROTECTED] \r\n'
reply: retcode (250); Msg: 2.1.5 [EMAIL PROTECTED]
send: 'data\r\n'
reply: '354 Start mail input; end with .\r\n'
reply: retcode (354); Msg: Start mail input; end with .
data: (354, 'Start mail input; end with .')
send: "\tFrom: [EMAIL PROTECTED]: [EMAIL PROTECTED], j
[EMAIL PROTECTED]: Hello!\r\n\tThis message was sent
with
Python's smtplib.\r\n\t\r\n.\r\n"
reply: '250 2.6.0
<[EMAIL PROTECTED]>
 Queued mail for delivery\r\n'
reply: retcode (250); Msg: 2.6.0
<[EMAIL PROTECTED]
mydomain.com> Queued mail for delivery
data: (250, '2.6.0
<[EMAIL PROTECTED]
> Queued mail for delivery')
send: 'quit\r\n'
reply: '221 2.0.0 mymailserver.mydomain.com Service closing
transmission
channel\r\n'
reply: retcode (221); Msg: 2.0.0 mymailserver.mydomain.com Service
closin
g transmission channel
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Hello!
This message was sent with Python's smtplib.

Output if you just run the internal part of the function directly:
send: 'ehlo twaus-mycomputer.mydomain.local\r\n'
reply: '250-mymailserver.mydomain.com Hello [10.10.10.119]\r\n'
reply: '250-TURN\r\n'
reply: '250-SIZE\r\n'
reply: '250-ETRN\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-DSN\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-8bitmime\r\n'
reply: '250-BINARYMIME\r\n'
reply: '250-CHUNKING\r\n'
reply: '250-VRFY\r\n'
reply: '250-X-EXPS GSSAPI NTLM LOGIN\r\n'
reply: '250-X-EXPS=LOGIN\r\n'
reply: '250-AUTH GSSAPI NTLM LOGIN\r\n'
reply: '250-AUTH=LOGIN\r\n'
reply: '250-X-LINK2STATE\r\n'
reply: '250-XEXCH50\r\n'
reply: '250 OK\r\n'
reply: retcode (250); Msg: mymailserver.mydomain.com Hello
[10.10.10.119]

TURN
SIZE
ETRN
PIPELINING
DSN
ENHANCEDSTATUSCODES
8bitmime
BINARYMIME
CHUNKING
VRFY
X-EXPS GSSAPI NTLM LOGIN
X-EXPS=LOGIN
AUTH GSSAPI NTLM LOGIN
AUTH=LOGIN
X-LINK2STATE
XEXCH50
OK
send: 'mail FROM:<[EMAIL PROTECTED]> size=154\r\n'
reply: '250 2.1.0 [EMAIL PROTECTED] OK\r\n'
reply: retcode (250); Msg: 2.1.0 [EMAIL PROTECTED] OK
send: 'rcpt TO:<[EMAIL PROTECTED]>\r\n'
reply: '250

automatically insert text in ms-word properties

2008-10-07 Thread gita ziabari
All,

I wanna use python to automatically insert text in ms-word properties.
Anyone could help me?

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


Re: SMTPlib inside function, extra tab

2008-10-07 Thread Tino Wildenhain

Hunter wrote:

I am writing a script that needs to send some emails.  And I've used
smtplib in the past and it is pretty easy.  But I thought, gee it
would be easier if I could just call it as a function, passing the
from, to, subject, and message text.  So I wrote it up as a function
and it sort of works, but I get a weird error.  When it runs it
inserts a "\t" tab character before each item during the send portion
(which I can see when I turn on debug).  The end result is that I
don't get any body or subject in my emails.  It works fine when I copy
the inside of the function and run it directly.  It isn't a
dealbreaker, I can certainly just call it direct, but from a learning
Python perspective I'm wondering if anyone knows what exactly is
happening.I'm more interested in the why this is happening than a
solution (though that would be great too).  Oh and if you could
explain it to me, with no CS background, that would be even better.

I am working on Windows Vista with Python 2.5.2 (activestate).

Thanks --Joshua

Snip of script (more or less a copy/paste from effbot):
fromaddress = '[EMAIL PROTECTED]'
tolist = ['[EMAIL PROTECTED]','[EMAIL PROTECTED]']
msgsubj = "Hello!"
messagebody = "This message was sent with Python's smtplib."


def send_mail(fromaddress,tolist,msgsubj,messagebody):
import smtplib
SERVER = "mymailserver.mydomain.com"
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (fromaddress, ", ".join(tolist),msgsubj, messagebody)

  ^
The tabs are exactly here.

best is to use the mail package to generate mime compliant
emails and use simple templates - which could in the
easiest form just module level constants like:

stdform="""
Hello %(greeting)s,

this automated email is about %(subject)s ... """

and so on and then you use it with

stdform % dict(greeting='Mr Ed',subject='writing emails')

...

HTH
Tino


smime.p7s
Description: S/MIME Cryptographic Signature
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pure Python interface to MySQL?

2008-10-07 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 "James Mills" <[EMAIL PROTECTED]> wrote:

> You could for example use an alternative database:
>  * buzhug
>  * ZODB
>  * Durus
>  * Or any of: pickle, shelve, XML, or flat file.

Unfortunately, I don't own the database, just the clients that have to 
insert records into it :-(
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pure Python interface to MySQL?

2008-10-07 Thread Gerhard Häring

Gerhard Häring wrote:

James Mills wrote:

On Tue, Oct 7, 2008 at 9:15 AM, Roy Smith <[EMAIL PROTECTED]> wrote:
Does there exist a pure Python version of a MySQL module?  I've got a 
data
logging application that needs to run on a whole bunch of OSs, 
ranging from

Windows to a dozen different unix flavors on all sorts of hardware.

Portability is much more important than performance for this 
application.
We're only inserting a few hundred records a day from each system, 
but the

ability to quickly deploy to anywhere I've already got Python running is
key.


My solution (tm):

You could implement a proxy server/client
sub-system [...]


Or instead of reinventing the wheel, you could use SQLRelay 
(http://sqlrelay.sourceforge.net/), which has a pure-Python DB-API module.


Unfortunately, the Python interface for SQLRelay seems to include parts 
written in C. What a pity.


-- Gerhard

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


Acer Laptops 4520NWXMi Athlon LX.AHS0C.032

2008-10-07 Thread Online Shopping
Buy low price Acer Acer Laptops 4520NWXMi Athlon LX.AHS0C.032 - buy
best Acer Aspire Laptops 4520NWXMi Athlon LX.AHS0C.032 online at
lowest price at homeshop18 laptops shop. For more information visit:
http://www.homeshop18.com/shop/u/y/p-Computers-Q-and-Q-Peripherals-S-Laptops-S-Acer-Q-Aspire-Q-4520NWXMi-Q-Athlon-Q-LX.AHS0C.032-Q-Notebook/Home_Online-pI_20266-clI_2-cI_920-pCI_909-

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


Re: ABCs -> infix syntax for isinstance() ?

2008-10-07 Thread Boris Borcic

Bruno Desthuilliers wrote:


Boris Borcic a écrit :


Given the ABC innovation, maybe an infix syntax for isinstance() would
be good.
Possibilities :
- stealing "is" away from object identity. As a motivation, true use
cases for testing object identity are rare;



"x is None" is a *very* common test. (...)
Testing a class identity often happens when writing metaclasses



This kind-of-talks for Terry's proposition : adding a __contains__ to
type,



I said "type identity testing", not isinstance() or issubclass() testing.


Yes, but in the thread's context [of choosing between "is" and "in" as infix 
syntax for isinstance()] you were in effect raising as an objection to the first 
choice that it meant conflict with this use case [of "type identity testing" 
which is "common when writing metaclasses"].


This implied "writing metaclasses" as a background experience to decide the 
issue, what in turn implied a preference for the second solution ("x in Number") 
on *two* counts.


First because it was a proposed alternative to what you were objecting to, and
Second because "x in Number" has this most simple "metaclassy" solution.

(...)


And anyway, I don't see how any of the above address the point that your 
premise that "true identity testing is rare" is just wrong...




I wrote "true use cases for identity testing are rare", it was more of an 
auxiliary assertion that a premise, and nothing you objected really disproved it 
(for an adequate definition of "true use case").


* writing metaclasses is rare, and so is testing class identity in its context.

* "x is None" is arguably not a "true use case", in the sense that it is a case 
of testing identity against a constant that


- doesn't compare equal to anything else
- is the single instance of a singleton class

so that there exists both an equality test and an isinstance() test that are 
equivalents to the identity test.


Cheers, BB






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


Re: Array of dict or lists or ....?

2008-10-07 Thread Pat

Dennis Lee Bieber wrote:

On Mon, 06 Oct 2008 19:45:07 -0400, Pat <[EMAIL PROTECTED]> declaimed the
following in comp.lang.python:

I can't figure out how to set up a Python data structure to read in data 
that looks something like this (albeit somewhat simplified and contrived):



States
Counties
  Schools
Classes
   Max Allowed Students
   Current enrolled Students

Nebraska, Wabash, Newville, Math, 20, 0
Nebraska, Wabash, Newville, Gym, 400, 0
Nebraska, Tingo,  Newfille, Gym, 400, 0
Ohio, Dinger, OldSchool, English, 10, 0







The structure looks more suited to a database -- maybe SQLite since
the interface is supplied with the newer versions of Python (and
available for older versions).


I don't understand why I need a database when it should just be a matter 
of defining the data structure.  I used a fictional example to make it 
easier to (hopefully) convey how the data is laid out.


One of the routines in the actual program checks a few thousand 
computers to verify that certain processes are running.  I didn't want 
to complicate my original question by going through all of the gory 
details (multiple userids running many processes with some of the 
processes having the same name).  To save time, I fork a process for 
each computer that I'm checking.  It seems to me that banging away at a 
database would greatly slow down the program and make the program more 
complicated.


The Perl routine works fine and I'd like to emulate that behavior but 
since I've just starting learning Python I don't know the syntax for 
designing the data structure.  I would really appreciate it if someone 
could point me in the right direction.

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


Re: execute a function before and after any method of a parent class

2008-10-07 Thread Michele Simionato
On Oct 3, 9:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:

> Ok, but then you have to explicitely decorate every method. To avoid this,  
> you may use a metaclass; this article by Michael Foord explains 
> how:http://www.voidspace.org.uk/python/articles/metaclasses.shtml#a-metho...

Since Python 2.6 is out, I would recommend using a class decorator for
this task.
The class decorator is not inherited, so in order to decorate methods
in subclasses
one has to repeat it, which I see as a feature (explicit is better
than implicit).
Otherwise the readers of your classes will not have any visual clue
that something
magic is going on; moreover, you will lower the risk of decorating
methods
that should not be decorated (I mean, in case of accidents).

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


several version of eggs

2008-10-07 Thread Sed
Hello,

I thought that with eggs, I will be able to choose at run time, which
version of an egg I would like to use.

But after some tests with dummy eggs, I've tried to make it work with
SQLAlchemy for example, with no success at all.

So does some one know if such feature is available with eggs ??

-- the example ---

easy_install 'SQLAlchemy==0.4.4'
...
easy_install 'SQLAlchemy==0.4.6'
...

python
import pkg_resources
>>> pkg_resources.require("SQLAlchemy==0.4.6")
[SQLAlchemy 0.4.6 (/home/system/briner/py-lib/SQLAlchemy-0.4.6-
py2.5.egg)]
>>> pkg_resources.require("SQLAlchemy==0.4.4")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
in require
needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (SQLAlchemy 0.4.6 (/home/system/briner/
py-lib/SQLAlchemy-0.4.6-py2.5.egg),
Requirement.parse('SQLAlchemy==0.4.4'))

Ctrl+D

easy_install 'SQLAlchemy==0.4.4'
...
python
>>> import pkg_resources
>>> pkg_resources.require("SQLAlchemy==0.4.4")
[SQLAlchemy 0.4.4 (/home/system/briner/py-lib/SQLAlchemy-0.4.4-
py2.5.egg)]
>>> pkg_resources.require("SQLAlchemy==0.4.6")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
in require
needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (SQLAlchemy 0.4.4 (/home/system/briner/
py-lib/SQLAlchemy-0.4.4-py2.5.egg),
Requirement.parse('SQLAlchemy==0.4.6'))

---
so it feels that the only package I can call is the latest one
installed !!!

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


Re: Getting namespaces right when parsing/executing Python ASTs

2008-10-07 Thread Orestis Markou
Have you tried passing in empty dicts for globals and locals? I think
that the defaults will be the *current* globals and locals, and then
of course your namespace is broken...

On Tue, Oct 7, 2008 at 1:26 PM, Gordon Fraser <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to parse Python code to an AST, apply some changes to the AST
> and then compile and run the AST, but I'm running into problems when
> trying to evaluate/execute the resulting code object. It seems that the
> global namespace differs depending on where I call parse and eval/exec.
>
> The following code parses a file, compiles and then evaluates the AST.
> If I call Python directly on this code, then it works:
>
>import sys, parser
>ast = parser.suite(open(sys.argv[1]).read())
>code = ast.compile()
>exec(code)
>
> ...and it also works this way with Python2.6:
>
>ast = compile(open(sys.argv[1]).read(), "",
> 'exec',_ast.PyCF_ONLY_AST)
>code = compile(ast, "exec(code)
>
> However, if I include that snippet in a different scope (some function
> or class), then the namespace that the code object will have differs -
> it seems the symbols defined in the AST are not included when executing
> the code. For example:
>
>import sys,parser
>
>def main():
>ast = parser.suite(open(sys.argv[1]).read())
>code = ast.compile()
>exec(code)
>
>if __name__ == "__main__":
>  main()
>
> In particular this is a problem if I'm parsing a module with several
> functions - none of these functions actually ends up in the scope of the
> code object (same behavior with Python2.6 and the PyCF_ONLY_AST
> version).
>
> The function "exec" takes parameters for globals and locals, but I have
> no idea where to get these dictionaries from the "parser" module. My
> guess is that I am misunderstanding something about how Python treats
> namespaces. Can anyone help me here?
>
> Thanks,
> Gordon
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
[EMAIL PROTECTED]
http://orestis.gr
--
http://mail.python.org/mailman/listinfo/python-list


Re: several version of eggs

2008-10-07 Thread Diez B. Roggisch
Sed wrote:

> Hello,
> 
> I thought that with eggs, I will be able to choose at run time, which
> version of an egg I would like to use.
> 
> But after some tests with dummy eggs, I've tried to make it work with
> SQLAlchemy for example, with no success at all.
> 
> So does some one know if such feature is available with eggs ??
> 
> -- the example ---
> 
> easy_install 'SQLAlchemy==0.4.4'
> ...
> easy_install 'SQLAlchemy==0.4.6'
> ...
> 
> python
> import pkg_resources
 pkg_resources.require("SQLAlchemy==0.4.6")
> [SQLAlchemy 0.4.6 (/home/system/briner/py-lib/SQLAlchemy-0.4.6-
> py2.5.egg)]
 pkg_resources.require("SQLAlchemy==0.4.4")
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
> in require
> needed = self.resolve(parse_requirements(requirements))
>   File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
> in resolve
> raise VersionConflict(dist,req) # XXX put more info here
> pkg_resources.VersionConflict: (SQLAlchemy 0.4.6 (/home/system/briner/
> py-lib/SQLAlchemy-0.4.6-py2.5.egg),
> Requirement.parse('SQLAlchemy==0.4.4'))
> 
> Ctrl+D
> 
> easy_install 'SQLAlchemy==0.4.4'
> ...
> python
 import pkg_resources
 pkg_resources.require("SQLAlchemy==0.4.4")
> [SQLAlchemy 0.4.4 (/home/system/briner/py-lib/SQLAlchemy-0.4.4-
> py2.5.egg)]
 pkg_resources.require("SQLAlchemy==0.4.6")
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
> in require
> needed = self.resolve(parse_requirements(requirements))
>   File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
> in resolve
> raise VersionConflict(dist,req) # XXX put more info here
> pkg_resources.VersionConflict: (SQLAlchemy 0.4.4 (/home/system/briner/
> py-lib/SQLAlchemy-0.4.4-py2.5.egg),
> Requirement.parse('SQLAlchemy==0.4.6'))
> 
> ---
> so it feels that the only package I can call is the latest one
> installed !!!

you need to easy_install with -m/--multi-version. All of your packages.

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


Re: equivalent of py2exe in other os

2008-10-07 Thread Benjamin Kaplan
On Tue, Oct 7, 2008 at 6:43 AM, Almar Klein <[EMAIL PROTECTED]> wrote:

> Hi,
> I was going to say "try google", but it seems quite hard to find indeed.
> Use "freeze" for linux and "py2app" for osx.
>
> I know of a program called gui2exe which is a gui which uses the three
> to compile executables of your os of choise (but I think only py2exe was
> implemented thus far).
>
> Almar
>

Actually, Andrea Gavana (gui2exe's creator) has been working on adding
support for the other executable builders. You can get the current working
version from here:
http:/code.google.com/p/gui2exe



>
> 2008/10/7 Astan Chee <[EMAIL PROTECTED]>
>
> Hi,
>> I was just wondering if there is a equivalent of py2exe on linux (centOS)
>> and mac (OS X). I have a python script that uses wx and I dont want to
>> install wx on linux/mac machines. What are my choices?
>> Thanks
>> Astan
>>
>> --
>> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose
>> two." -David Morgan-Mar
>>
>>
>>
>> Animal Logic
>> http://www.animallogic.com
>>
>> Please think of the environment before printing this email.
>>
>> This email and any attachments may be confidential and/or privileged. If
>> you are not the intended recipient of this email, you must not disclose or
>> use the information contained in it. Please notify the sender immediately
>> and delete this document if you have received it in error. We do not
>> guarantee this email is error or virus free.
>>
>>
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: managing releases of web applications: is svn checkout the best way?

2008-10-07 Thread jdd
On Oct 7, 3:55 am, Ksenia <[EMAIL PROTECTED]> wrote:
> Hi,
>
> For website development, I am using SVN repository to commit the code
> from my development computer, and on the production server use svn
> checkout to update the code to the latest version.
> Is this the most common approach people using? Or is there maybe a
> better way to manage "live" releases, like creating an egg for each
> release? Assuming the code is closed-source and should be kept secure.
>
> Just wondering how you people deal with that.
> Thanks
> Ksenia

I think it's a pretty common means of doing releases.

I use bzr, one of the distributed Version Controlling Systems, with a
webapp I wrote using cherrypy. It works out rather well as I don't
have to deal with setting up svn as a server (or deal with svns
quirks). Also, since branching is rather cheap in VCSs (at least in
all the ones that I'm aware of), I have a much "safer" workflow.

My workflow looks like this:

1. Branch from server to implement feature
2. Implement and commit on local machine
3. From server, merge in changes from local machine.

This has worked well for me on projects that involved multiple people
as well, as long as they kept up to date. I imagine that a lot of
other peoples workflows are similar.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Builing Python 2.6 on AIX 5.2

2008-10-07 Thread brasse
On Oct 6, 10:16 am, brasse <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I am having some trouble building Python 2.6 on AIX. The steps I have
> taken are:
>
> export PATH=/usr/bin/:/usr/vacpp/bin/
> ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6
> make
>
> This is the error message I'm seeing:
> ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/
> temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/_multiprocessing/
> multiprocessing.o build/temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/
> _multiprocessing/socket_connection.o build/temp.aix-5.2-2.6/home/mabr/
> Python-2.6/Modules/_multiprocessing/semaphore.o -L/usr/local/lib -o
> build/lib.aix-5.2-2.6/_multiprocessing.so
> ld: 0711-317 ERROR: Undefined symbol: .sem_timedwait
> ld: 0711-317 ERROR: Undefined symbol: .CMSG_SPACE
> ld: 0711-317 ERROR: Undefined symbol: .CMSG_LEN
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> *** WARNING: renaming "_multiprocessing" since importing it failed: No
> such file or directory
> error: No such file or directory
> make: The error code from the last command is 1.
>
> Have someone on this list had similar problems? Am I missing some
> libraries? The configure script runs without errors, I would have
> expected some kind of error there if I was missing something.
>
> Regards,
> Mattias

OK. I have made some changes in the source that lets me build on AIX
5.2. I thought I could post the patch here and perhaps someone can
tell me if I am on the wrong track or if this is an OK fix on AIX.

Basically I have changed setup.py to define HAVE_SEM_TIMED_WAIT=0 on
aix. I have also defined CMESG_SPACE and CMESG_LEN in terms of
_CMSG_ALIGN (see http://homepage.mac.com/cjgibbons/rubyonaixhowto/x72.html)
in multipocessing.c. (I realise that this breaks some other platforms,
but right now I just need to build on AIX).

Here is a patch:

diff -Naur Python-2.6/Modules/_multiprocessing/multiprocessing.c
Python-2.6-clean-patch/Modules/_multiprocessing/multiprocessing.c
--- Python-2.6/Modules/_multiprocessing/multiprocessing.c
2008-06-14 00:38:33.0 +0200
+++ Python-2.6-clean-patch/Modules/_multiprocessing/
multiprocessing.c   2008-10-07 12:23:55.0 +0200
@@ -8,6 +8,13 @@

 #include "multiprocessing.h"

+#ifndef CMSG_SPACE
+#define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) +
_CMSG_ALIGN(len))
+#endif
+#ifndef CMSG_LEN
+#define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
+#endif
+
 PyObject *create_win32_namespace(void);

 PyObject *pickle_dumps, *pickle_loads, *pickle_protocol;
diff -Naur Python-2.6/setup.py Python-2.6-clean-patch/setup.py
--- Python-2.6/setup.py 2008-09-30 02:15:45.0 +0200
+++ Python-2.6-clean-patch/setup.py 2008-10-07 12:23:34.0
+0200
@@ -1277,6 +1277,14 @@
 )
 libraries = []

+elif platform.startswith('aix'):
+macros = dict(
+HAVE_SEM_OPEN=1,
+HAVE_SEM_TIMEDWAIT=0,
+HAVE_FD_TRANSFER=1
+)
+libraries = ['rt']
+
 else:   # Linux and other
unices
 macros = dict(
 HAVE_SEM_OPEN=1,

Perhaps this should go to some other list?

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


Re: equivalent of py2exe in other os

2008-10-07 Thread Astan Chee

Hi,
Thanks for the replies. I forgot to add that I am developing my python 
scripts in windows, but would like to make executables/binaries for win, 
linux and osx without the os themselves.
Does this make sense? Also, it seems that freeze requires some sort of 
python installed on the linux box, what I'm looking for is a stand-alone 
binary/executable.

Thanks again for the suggestions
Astan

Lars Stavholm wrote:

Almar Klein wrote:
  

Hi,
I was going to say "try google", but it seems quite hard to find indeed.
Use "freeze" for linux and "py2app" for osx.



http://python.net/crew/atuining/cx_Freeze
/L

  

I know of a program called gui2exe which is a gui which uses the three
to compile executables of your os of choise (but I think only py2exe was
implemented thus far).

Almar

2008/10/7 Astan Chee <[EMAIL PROTECTED] >

Hi,
I was just wondering if there is a equivalent of py2exe on linux
(centOS) and mac (OS X). I have a python script that uses wx and I
dont want to install wx on linux/mac machines. What are my choices?
Thanks
Astan

-- 
"Formulations of number theory: Complete, Consistent, Non-trivial.

Choose two." -David Morgan-Mar



Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or
privileged. If you are not the intended recipient of this email, you
must not disclose or use the information contained in it. Please
notify the sender immediately and delete this document if you have
received it in error. We do not guarantee this email is error or
virus free.



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





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





  


--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." 
-David Morgan-Mar




Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you 
are not the intended recipient of this email, you must not disclose or use the 
information contained in it. Please notify the sender immediately and delete 
this document if you have received it in error. We do not guarantee this email 
is error or virus free.

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


Re: equivalent of py2exe in other os

2008-10-07 Thread Benjamin Kaplan
I believe that all (or nearly all) Unix variants come with Python
preinstalled. Ubuntu, at least, has a lot of system programs written in
Python. Even Mac OS X requires Python.

On Tue, Oct 7, 2008 at 7:43 AM, Astan Chee <[EMAIL PROTECTED]> wrote:

>  Hi,
> Thanks for the replies. I forgot to add that I am developing my python
> scripts in windows, but would like to make executables/binaries for win,
> linux and osx without the os themselves.
> Does this make sense? Also, it seems that freeze requires some sort of
> python installed on the linux box, what I'm looking for is a stand-alone
> binary/executable.
> Thanks again for the suggestions
> Astan
>
>
> Lars Stavholm wrote:
>
> Almar Klein wrote:
>
>
>  Hi,
> I was going to say "try google", but it seems quite hard to find indeed.
> Use "freeze" for linux and "py2app" for osx.
>
>
>  http://python.net/crew/atuining/cx_Freeze
> /L
>
>
>
>  I know of a program called gui2exe which is a gui which uses the three
> to compile executables of your os of choise (but I think only py2exe was
> implemented thus far).
>
> Almar
>
> 2008/10/7 Astan Chee <[EMAIL PROTECTED]  <[EMAIL 
> PROTECTED]>>
>
> Hi,
> I was just wondering if there is a equivalent of py2exe on linux
> (centOS) and mac (OS X). I have a python script that uses wx and I
> dont want to install wx on linux/mac machines. What are my choices?
> Thanks
> Astan
>
> --
> "Formulations of number theory: Complete, Consistent, Non-trivial.
> Choose two." -David Morgan-Mar
>
>
>
> Animal Logic
> http://www.animallogic.com
>
> Please think of the environment before printing this email.
>
> This email and any attachments may be confidential and/or
> privileged. If you are not the intended recipient of this email, you
> must not disclose or use the information contained in it. Please
> notify the sender immediately and delete this document if you have
> received it in error. We do not guarantee this email is error or
> virus free.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
>
> 
>
> --http://mail.python.org/mailman/listinfo/python-list
>
>
> --
> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose 
> two." -David Morgan-Mar
>
>
>
>  
>
> Please think of the environment before printing this email.
>
> This email and any attachments may be confidential and/or privileged. If
> you are not the intended recipient of this email, you must not disclose or
> use the information
> contained in it. Please notify the sender immediately and delete this
> document if you have received it in error. We do not guarantee this email is
> error or virus free.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Python 2.5.3: call for patches

2008-10-07 Thread Aahz
On Tue, Oct 07, 2008, "Martin v. L?wis" wrote:
> 
> In principle, the release will include all changes that are already on
> the release25-maint branch in subversion [1]. If you think that specific
> changes should be considered, please create an issue in the bug tracker
> [2], and label it with the 2.5.3 version. Backports of changes that
> are already released in Python 2.6 but may apply to 2.5 are of
> particular interest.

Just to emphasize this, "changes" means "bugfixes".  (I'm mentioning this
mainly because of the people who joined for 2.6/3.0.)  For more info,
see PEP6 about bugfix releases:
http://www.python.org/dev/peps/pep-0006/
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"...if I were on life-support, I'd rather have it run by a Gameboy than a
Windows box."  --Cliff Wells, comp.lang.python, 3/13/2002
--
http://mail.python.org/mailman/listinfo/python-list


Re: Getting namespaces right when parsing/executing Python ASTs

2008-10-07 Thread Gordon Fraser
Hi,

Am Dienstag, den 07.10.2008, 15:30 +0100 schrieb Orestis Markou:
> Have you tried passing in empty dicts for globals and locals? I think
> that the defaults will be the *current* globals and locals, and then
> of course your namespace is broken...

That seems to work, thanks. Still trying to make sense of the manual for
eval, as it says if the passed globals dict lacks '__builtins__' it will
copy the current globals, and if no dict is passed it will use the
current globals (so what's the difference?). But anyway, as long as it
works I'm happy!

Thanks,
Gordon


> 
> On Tue, Oct 7, 2008 at 1:26 PM, Gordon Fraser <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm trying to parse Python code to an AST, apply some changes to the AST
> > and then compile and run the AST, but I'm running into problems when
> > trying to evaluate/execute the resulting code object. It seems that the
> > global namespace differs depending on where I call parse and eval/exec.
> >
> > The following code parses a file, compiles and then evaluates the AST.
> > If I call Python directly on this code, then it works:
> >
> >import sys, parser
> >ast = parser.suite(open(sys.argv[1]).read())
> >code = ast.compile()
> >exec(code)
> >
> > ...and it also works this way with Python2.6:
> >
> >ast = compile(open(sys.argv[1]).read(), "",
> > 'exec',_ast.PyCF_ONLY_AST)
> >code = compile(ast, " >exec(code)
> >
> > However, if I include that snippet in a different scope (some function
> > or class), then the namespace that the code object will have differs -
> > it seems the symbols defined in the AST are not included when executing
> > the code. For example:
> >
> >import sys,parser
> >
> >def main():
> >ast = parser.suite(open(sys.argv[1]).read())
> >code = ast.compile()
> >exec(code)
> >
> >if __name__ == "__main__":
> >  main()
> >
> > In particular this is a problem if I'm parsing a module with several
> > functions - none of these functions actually ends up in the scope of the
> > code object (same behavior with Python2.6 and the PyCF_ONLY_AST
> > version).
> >
> > The function "exec" takes parameters for globals and locals, but I have
> > no idea where to get these dictionaries from the "parser" module. My
> > guess is that I am misunderstanding something about how Python treats
> > namespaces. Can anyone help me here?
> >
> > Thanks,
> > Gordon
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> 
> 

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


Re: HARD REAL TIME PYTHON

2008-10-07 Thread Kurt Mueller

Am 07.10.2008 um 11:44 schrieb Diez B. Roggisch:

Kurt Mueller wrote:

David,
As others mentioned before, python is not the right tool for "HARD
REAL TIME".
But: Maybe you can isolate the part of your application that needs
"HARD REAL TIME".
   Then implement this part in an approriate Environment (Language,
OS, HW).
   Then implement the rest of your application which is not "HARD
REAL TIME"
   in python.
I've done this using RTAI + ctypes. Of course the hard realtime  
tasks are

written in C - but only the absolutely minimal core.
Works like a charm.


(Btw, what is this application like)


Yes.
The key is to
!*isolate*!
the part of the application that needs "HARD REAL TIME".
Thats what you have done with the "absolutely minimal core"
in RTAI + ctypes.



Sometimes it is even questionable if an application really
needs "HARD REAL TIME".
sometimes it is enough to have "soft real time" or even
"fast enough" is enough.

Good enough is good enough!

"HARD REAL TIME" is mostly expensive.



Grüessli
--
Kurt Müller, [EMAIL PROTECTED]

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


Re: equivalent of py2exe in other os

2008-10-07 Thread Joe Strout

On Oct 7, 2008, at 8:43 AM, Benjamin Kaplan wrote:

I believe that all (or nearly all) Unix variants come with Python  
preinstalled. Ubuntu, at least, has a lot of system programs written  
in Python. Even Mac OS X requires Python.


Yes, but with significant differences between different Python  
distributions, you might be safer bundling whatever version of Python  
your app requires with the app itself.  Otherwise, you risk your app  
failing (and probably puking up runtime exceptions all over the poor  
user's lap) on some distros or versions.


(My Mac OS X machine comes with Python 2.5.1, for example, which is  
hardly the latest.)


Best,
- Joe

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


Re: several version of eggs

2008-10-07 Thread Sed
> you need to easy_install with -m/--multi-version. All of your packages.
Unfortunately, this is not even working :(
let's try it:

$ easy_install -m 'SQLAlchemy==0.4.6'
...
$ easy_install -m 'SQLAlchemy==0.4.4'
...

check that the easy-install.pth doesn't contain any more some sql
entry:
$ grep -i sql /home/system/briner/py-lib/easy-install.pth
./SQLObject-0.9.4-py2.4.egg
no more sqlachemy in it

$ python
>>> import pkg_resources
>>> pkg_resources.require("SQLAlchemy==0.4.4")
[SQLAlchemy 0.4.4 (/home/system/briner/py-lib/SQLAlchemy-0.4.4-
py2.5.egg)]
>>> pkg_resources.require("SQLAlchemy==0.4.6")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
in require
needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (SQLAlchemy 0.4.4 (/home/system/briner/
py-lib/SQLAlchemy-0.4.4-py2.5.egg),
Requirement.parse('SQLAlchemy==0.4.6'))

CTRL+D

So it seems that we still have the same behavior as described before

> Diez

cEd

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


Re: HARD REAL TIME PYTHON

2008-10-07 Thread Diez B. Roggisch
>> I've done this using RTAI + ctypes. Of course the hard realtime
>> tasks are
>> written in C - but only the absolutely minimal core.
>> Works like a charm.
> 
> (Btw, what is this application like)

It's for a robot with 8 motors, with a industrial PIII-based PC on board,
running RTAI Linux 2.6. The core control task is user-space realtime with a
1ms loop and gets it's controlling commands via plain C-structs that I pass
in using python/ctypes.

On of the great things about this is that there is Python's GC working in
favor of me, as I can simple allocate/deallocate data structures from
withing Python.

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


Re: how to get the thighest bit position in big integers?

2008-10-07 Thread Thomas Heller
Mark Dickinson schrieb:
> On Oct 5, 11:40 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
>> Your point, that taking floor(log2(x)) is redundant, is a good catch.
>> However, you should have added 'untested' ;-).  When value has more
>> significant bits than the fp mantissa can hold, this expression can be 1
>> off (but no more, I assume).   The following correction should be
>> sufficient:
>>
>> res = math.frexp(value)[1] - EXP_OF_ONE
>> test = 1<> if test > r: res -= 1
>> elif 2*test < r: res += 1
>>
>> For value = 2**n -1, n > 53, it is always 1 too high on my Intel
>> machine, so the first correction is sometimes needed.  I do not know if
>> the second is or not.
> 
> See also http://bugs.python.org/issue3439
> where there's a proposal to expose the _PyLong_NumBits method.  This
> would give an O(1) solution.
> 
> Mark

Here is ctypes code that works (tested with Python 2.5):

from ctypes import *

_PyLong_NumBits = pythonapi._PyLong_NumBits
_PyLong_NumBits.argtypes = py_object,
_PyLong_NumBits.restype = c_int

for i in range(64):
x = 1 << i
print i, _PyLong_NumBits(long(x))


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


Re: equivalent of py2exe in other os

2008-10-07 Thread Diez B. Roggisch
Astan Chee wrote:

> Hi,
> I was just wondering if there is a equivalent of py2exe on linux
> (centOS) and mac (OS X). I have a python script that uses wx and I dont
> want to install wx on linux/mac machines. What are my choices?
> Thanks
> Astan

Did you bother googling? 

http://www.google.com/search?q=os+x+py2exe&ie=UTF-8&oe=UTF-8

First hit.

Linux gives a lot of results too.

Diez 

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


ssh problem using paramiko?

2008-10-07 Thread sa6113

I use this code :


import paramiko
import socket

hostname = "192.168.1.4"
username = "test"
port = 22
password = ''123456"

# now connect
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))
except Exception, e:
print 'Connect failed: ' + str(e)
traceback.print_exc()
sys.exit(1)

--
and I got this error :
sock.connect((hostname, port))
File "", line 1 , in  connect
error:(10061 ,'Connection refused')
---
what is the problem?
I have a computer with this Ip and username , password in my network.
Do I have to install ssh or somthing else in that computer(server) or run
any script?


-- 
View this message in context: 
http://www.nabble.com/ssh-problem-using-paramiko--tp19857268p19857268.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


How do you get rid of useless warnings?

2008-10-07 Thread Grant Edwards


I'm getting awfully tired of constant warnings about what's
going to happen at some point in the future.

Warnings like this:

  ./surfplot.py:313: Warning: 'with' will become a reserved keyword in Python 
2.6

And this:

  /usr/lib/python2.5/site-packages/scipy/linalg/__init__.py:32: 
DeprecationWarning: NumpyTest will be removed in the next release; please 
update your code to use nose or unittest

And so on...
  
_I'm_not_using_Python_2.6_.  When I decided to switch to 2.6,
I'll worry about what works and doesn't work in 2.6.  In the
meantime, how do I get rid of this useless warning?  It's not
practical at this point in time to update on my production
machines the module that uses 'with' as a parameter.  Python
has been whinging at me for over a year about how 'with' is
going to become a keyword in 2.6. Yes thanks, I know.  I've
known about it for ages.  Now how do I get it to shut up about
it?

I'm also not using "the next release" of scipy, I'm using
_this_ release of scipy.  I've no clue what any of the "nose"
or "unittest" stuff is about, and it's really annoying to have
to sort through a bunch of meaningless exception messages when
I'm trying to get real work done.

I realize that every module author thinks their module is the
absolutely most important thing in the world to everybody and
all users should read hourly updates about what what the future
plans are for that module, but could you please provide an easy
way to shut off the nagging for those of us who are just trying
to get some work done with the current version...



-- 
Grant Edwards   grante Yow! We are now enjoying
  at   total mutual interaction in
   visi.coman imaginary hot tub ...
--
http://mail.python.org/mailman/listinfo/python-list


Re: equivalent of py2exe in other os

2008-10-07 Thread Lars Stavholm
Almar Klein wrote:
> Hi,
> I was going to say "try google", but it seems quite hard to find indeed.
> Use "freeze" for linux and "py2app" for osx.

http://python.net/crew/atuining/cx_Freeze
/L

> I know of a program called gui2exe which is a gui which uses the three
> to compile executables of your os of choise (but I think only py2exe was
> implemented thus far).
> 
> Almar
> 
> 2008/10/7 Astan Chee <[EMAIL PROTECTED] >
> 
> Hi,
> I was just wondering if there is a equivalent of py2exe on linux
> (centOS) and mac (OS X). I have a python script that uses wx and I
> dont want to install wx on linux/mac machines. What are my choices?
> Thanks
> Astan
> 
> -- 
> "Formulations of number theory: Complete, Consistent, Non-trivial.
> Choose two." -David Morgan-Mar
> 
> 
> 
> Animal Logic
> http://www.animallogic.com
> 
> Please think of the environment before printing this email.
> 
> This email and any attachments may be confidential and/or
> privileged. If you are not the intended recipient of this email, you
> must not disclose or use the information contained in it. Please
> notify the sender immediately and delete this document if you have
> received it in error. We do not guarantee this email is error or
> virus free.
> 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list


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


url - Free

2008-10-07 Thread wbdismalgoldstein
http://forums.vogue.com.au/member.php?u=92158 zoo tube 365 com
http://forums.vogue.com.au/member.php?u=92159 zootube365 com
http://forums.vogue.com.au/member.php?u=92166 miley cyrus naked
http://forums.vogue.com.au/member.php?u=92164 tila tequila nude
http://forums.vogue.com.au/member.php?u=92163 sextube com
http://forums.vogue.com.au/member.php?u=92162 animalssex
http://forums.vogue.com.au/member.php?u=92161 zooskool
http://forums.vogue.com.au/member.php?u=92160 www zootube365
http://forums.vogue.com.au/member.php?u=92170 dreammovies
http://forums.vogue.com.au/member.php?u=92171 xxxstash
http://forums.vogue.com.au/member.php?u=92169 qporno
http://forums.vogue.com.au/member.php?u=92168 sunporno
http://forums.vogue.com.au/member.php?u=92167 keezmovies
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pure Python interface to MySQL?

2008-10-07 Thread Gerhard Häring

James Mills wrote:

On Tue, Oct 7, 2008 at 9:15 AM, Roy Smith <[EMAIL PROTECTED]> wrote:

Does there exist a pure Python version of a MySQL module?  I've got a data
logging application that needs to run on a whole bunch of OSs, ranging from
Windows to a dozen different unix flavors on all sorts of hardware.

Portability is much more important than performance for this application.
We're only inserting a few hundred records a day from each system, but the
ability to quickly deploy to anywhere I've already got Python running is
key.


My solution (tm):

You could implement a proxy server/client
sub-system [...]


Or instead of reinventing the wheel, you could use SQLRelay 
(http://sqlrelay.sourceforge.net/), which has a pure-Python DB-API module.


-- Gerhard

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


Re: Builing Python 2.6 on AIX 5.2

2008-10-07 Thread M.-A. Lemburg
On 2008-10-07 12:24, brasse wrote:
> OK. I have made some changes in the source that lets me build on AIX
> 5.2. I thought I could post the patch here and perhaps someone can
> tell me if I am on the wrong track or if this is an OK fix on AIX.

Thanks. Please post the patch on the Python bug tracker, so we can
include this  patch in Python 2.6.1:

http://bugs.python.org/[EMAIL PROTECTED]

> Basically I have changed setup.py to define HAVE_SEM_TIMED_WAIT=0 on
> aix. I have also defined CMESG_SPACE and CMESG_LEN in terms of
> _CMSG_ALIGN (see http://homepage.mac.com/cjgibbons/rubyonaixhowto/x72.html)
> in multipocessing.c. (I realise that this breaks some other platforms,
> but right now I just need to build on AIX).
> 
> Here is a patch:
> 
> diff -Naur Python-2.6/Modules/_multiprocessing/multiprocessing.c
> Python-2.6-clean-patch/Modules/_multiprocessing/multiprocessing.c
> --- Python-2.6/Modules/_multiprocessing/multiprocessing.c
> 2008-06-14 00:38:33.0 +0200
> +++ Python-2.6-clean-patch/Modules/_multiprocessing/
> multiprocessing.c   2008-10-07 12:23:55.0 +0200
> @@ -8,6 +8,13 @@
> 
>  #include "multiprocessing.h"
> 
> +#ifndef CMSG_SPACE
> +#define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) +
> _CMSG_ALIGN(len))
> +#endif
> +#ifndef CMSG_LEN
> +#define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
> +#endif
> +
>  PyObject *create_win32_namespace(void);
> 
>  PyObject *pickle_dumps, *pickle_loads, *pickle_protocol;
> diff -Naur Python-2.6/setup.py Python-2.6-clean-patch/setup.py
> --- Python-2.6/setup.py 2008-09-30 02:15:45.0 +0200
> +++ Python-2.6-clean-patch/setup.py 2008-10-07 12:23:34.0
> +0200
> @@ -1277,6 +1277,14 @@
>  )
>  libraries = []
> 
> +elif platform.startswith('aix'):
> +macros = dict(
> +HAVE_SEM_OPEN=1,
> +HAVE_SEM_TIMEDWAIT=0,
> +HAVE_FD_TRANSFER=1
> +)
> +libraries = ['rt']
> +
>  else:   # Linux and other
> unices
>  macros = dict(
>  HAVE_SEM_OPEN=1,
> 
> Perhaps this should go to some other list?
> 
> :.:: mattias
> --
> http://mail.python.org/mailman/listinfo/python-list

-- 
Marc-Andre Lemburg
eGenix.com

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


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


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


time

2008-10-07 Thread Gabriel Rossetti

Hello everyone!

I trying to work with time and I a bit confused... If I look at my 
clock, it's 16:59 (4:59pm), if I type "date" in a terminal, it says the 
same thing. I'm wanting to write a simple NTP-type server/client (it's 
not NTP at all actually, but does the same thing). The idea is that a 
client sends it it's UTC offset and it returns the current time, so the 
server side checks the time and adds the UTC offset given by the client. 
I'm a UTC/GMT +1, I tried obtaining the UTC time, it says it's 2 hours 
earlier than the current time (14:59). I tried various other methods, I 
still get the wrong time. Does anyone have an idea with what is wrong?


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


Re: equivalent of py2exe in other os

2008-10-07 Thread bieffe62
On 7 Ott, 11:32, Astan Chee <[EMAIL PROTECTED]> wrote:
> Hi,
> I was just wondering if there is a equivalent of py2exe on linux
> (centOS) and mac (OS X). I have a python script that uses wx and I dont
> want to install wx on linux/mac machines. What are my choices?
> Thanks
> Astan
>
> --
> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose 
> two." -David Morgan-Mar
>
> Animal Logichttp://www.animallogic.com
>
> Please think of the environment before printing this email.
>
> This email and any attachments may be confidential and/or privileged. If you 
> are not the intended recipient of this email, you must not disclose or use 
> the information contained in it. Please notify the sender immediately and 
> delete this document if you have received it in error. We do not guarantee 
> this email is error or virus free.

For Linux I know of (but never used myself) PyInstaller :
http://pyinstaller.python-hosting.com/
They seem to have a in-development version for OS/X too, so maybe you
could give it a try ...

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


Re: In Python 2.6, bytes is str

2008-10-07 Thread Christian Heimes

Bryan Olson wrote:


Python 3 has the 'bytes' type, which the string type I've long wanted in 
various languages. Among other advantages, it is immutable, and 
therefore bytes objects can be dict keys. There's a mutable version too, 
called "bytearray".


In Python 2.6, the name 'bytes' is defined, and bound to str. The 2.6 
assignment presents some pitfalls. Be aware.


[...]

I'm thinking I should just avoid using 'bytes' in Python 2.6. If there's 
 another Python release between 2.6 and 3.gold, I'd advocate removing 
the pre-defined 'bytes', or maybe defining it as something else.


I guess you got the intention of the bytes alias wrong. It's partly my 
fault because I didn't document the bytes alias. We are well aware that 
the bytes alias in 2.6 isn't fully compatible with the bytes type in 
3.0. The bytes alias isn't MEANT to be compatible, too. :)


At first I wanted to backport the bytes type from 3.0 to 2.6. But it was 
too many work and the implications of yet another types were too 
complex. So I just added the alias in order to help people with writing 
forward compatible code like e.g. isinstance(egg, bytes).


Summa summarum the bytes alias serves was added for documentary purpose 
and to aid the 2to3 transition of code where 'str' is ambiguous.


Christian

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


how can we send keys to keyboard

2008-10-07 Thread mhangman
how can we send keys to keyboard? i want to write a script that will
push keyboard buttons and do what i want. its for a macro prog. there
are some kinds at c++ and at java. for example actools prog. but i
want to this in python...

note:im not talking about print a key im talking about use it from its
device
please help
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pure Python interface to MySQL?

2008-10-07 Thread Skip Montanaro
> http://github.com/mopemope/pure-python-mysql/tree/master/pymysql
> 
> I've never used it, though, so I have no idea whether it works or how
> well it works.

On the project's home page I noticed:

pymysql is Pure Perl MySQL driver.

pymysql is the Python DB API-2.0 interface.

support MySQL versions 4.1-5.1

Hopefully the code is more robust than the author's proofreading. ;-)

Skip


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


Re: several version of eggs

2008-10-07 Thread Diez B. Roggisch
Sed wrote:

>> you need to easy_install with -m/--multi-version. All of your packages.
> Unfortunately, this is not even working :(

It is.

[EMAIL PROTECTED]:/tmp$ virtualenv --no-site-packages test
New python executable in test/bin/python2.5
Installing setuptoolsdone.
[EMAIL PROTECTED]:/tmp$ . test/bin/activate
(test)[EMAIL PROTECTED]:/tmp$ easy_install-2.5 -m SQLAlchemy==0.4.4
Searching for SQLAlchemy==0.4.4
Reading http://pypi.python.org/simple/SQLAlchemy/
Reading http://www.sqlalchemy.org
Best match: SQLAlchemy 0.4.4
Downloading
http://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.4.4.zip#md5=4b1d072f6493421088126e451bd8cb6e
Processing SQLAlchemy-0.4.4.zip
Running SQLAlchemy-0.4.4/setup.py -q
bdist_egg --dist-dir 
/tmp/easy_install-xhMYOI/SQLAlchemy-0.4.4/egg-dist-tmp-WTjxmH
zip_safe flag not set; analyzing archive contents...
sqlalchemy.databases.mysql: module MAY be using inspect.stack

Installed /tmp/test/lib/python2.5/site-packages/SQLAlchemy-0.4.4-py2.5.egg

Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:

pkg_resources.require("SQLAlchemy")  # latest installed version
pkg_resources.require("SQLAlchemy==0.4.4")  # this exact version
pkg_resources.require("SQLAlchemy>=0.4.4")  # this version or higher

Processing dependencies for SQLAlchemy==0.4.4
Finished processing dependencies for SQLAlchemy==0.4.4
(test)[EMAIL PROTECTED]:/tmp$ easy_install-2.5 -m SQLAlchemy==0.4.6
Searching for SQLAlchemy==0.4.6
Reading http://pypi.python.org/simple/SQLAlchemy/
Reading http://www.sqlalchemy.org
Best match: SQLAlchemy 0.4.6
Downloading
http://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.4.6.tar.gz#md5=3d1e737bb408de25b2fadb19a736b40e
Processing SQLAlchemy-0.4.6.tar.gz
Running SQLAlchemy-0.4.6/setup.py -q
bdist_egg --dist-dir 
/tmp/easy_install-pJtAmh/SQLAlchemy-0.4.6/egg-dist-tmp-PW4OHw
zip_safe flag not set; analyzing archive contents...
sqlalchemy.databases.mysql: module MAY be using inspect.stack

Installed /tmp/test/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg

Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:

pkg_resources.require("SQLAlchemy")  # latest installed version
pkg_resources.require("SQLAlchemy==0.4.6")  # this exact version
pkg_resources.require("SQLAlchemy>=0.4.6")  # this version or higher

Processing dependencies for SQLAlchemy==0.4.6
Finished processing dependencies for SQLAlchemy==0.4.6
(test)[EMAIL PROTECTED]:/tmp$ python2.5
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named sqlalchemy
>>> import pkg_resources
>>> pkg_resources.require("SQLAlchemy==0.4.4")
[SQLAlchemy 0.4.4
(/tmp/test/lib/python2.5/site-packages/SQLAlchemy-0.4.4-py2.5.egg)]
>>> import sqlalchemy
>>> sqlalchemy.__file__
'/tmp/test/lib/python2.5/site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/__init__.pyc'
>>>   

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


Compiler, ast and forwards/backwards compatibility

2008-10-07 Thread Orestis Markou
Hello,

I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a
static analysis/intellisense provider for Python. I am targeting
Python 2.4 code so I'm using the compiler package.

I've been toying around yesterday with the ast module in Python 2.6
and it seems much more cleaner. One thing I don't understand is how
should one handle backwards and forwards compatibility.

The documentation for the ast module states that it "helps to find out
programmatically what the current grammar looks like". I can't find
any reference (even when reading the code) on how you should go about
this, other than checking the sys.version number and reading up on the
changes.

My understanding is that there is no way to write, say, an ast visitor
that runs under Python 3.0 that targets 2.4 because the ast has
changed, and there's no way to indicate that you want to parse another
version.

I guess that Python 2.6 can target Python 2.3-6, and with specific
compiler flags it can also target 3.0, so it seems that the correct
thing to do is to use that.

Am I correct? Am I seriously confused? Please help!

Thanks,
Orestis
-- 
[EMAIL PROTECTED]
http://orestis.gr
--
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite Python System Administration Examples

2008-10-07 Thread Mike Driscoll
On Oct 6, 2:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> I'm giving a talk at LISA this year, and while the slides are ready I
> would like to go armed with as many examples of good system
> administration code as possible.
>
> If you have a favorite administration tool that you wouldn't mind me
> using I'd love to know about it. Feel free to email me personally or
> submit via the list.
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/


There's lots of good stuff on Tim Golden's site (for Windows) that
I've used and modified the past couple of years:

http://timgolden.me.uk/python/

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


Re: gif creator

2008-10-07 Thread Peter Pearson
On Mon, 6 Oct 2008 08:18:14 -0700 (PDT), [EMAIL PROTECTED] wrote:
> has anyone written a gif creator program purely in python that doesn't
> require PIL or tons of other claptrap?

If you would be interested in an old and simpleminded Python
program for manipulating PNM files, contact me by email.
The comments include these lines:

# Usage:
#import pnm
#f = pnm.InputFile( "blooey.ppm" )
#print f.width, f.height, f.maxval
#for x in range( f.width ):
#  for y in range( f.height ):
#doSomethingWith( f.readPixel )


-- 
To email me, substitute nowhere->spamcop, invalid->net.
--
http://mail.python.org/mailman/listinfo/python-list


RE: Array of dict or lists or ....?

2008-10-07 Thread Barak, Ron
Would the following be suitable data structure:
...
struct = {}
struct["Nebraska"] = "Wabash"
struct["Nebraska"]["Wabash"] = "Newville"
struct["Nebraska"]["Wabash"]["Newville"]["topics"] = "Math"
struct["Nebraska"]["Wabash"]["Newville"]["Math"]["Max Allowed Students"] = 20
struct["Nebraska"]["Wabash"]["Newville"]["Math"]["Current enrolled Students"] = 0
...

Have an easy Yom Kippur,
Ron.

-Original Message-
From: Pat [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 08, 2008 04:16
To: python-list@python.org
Subject: Re: Array of dict or lists or ?

Dennis Lee Bieber wrote:
> On Mon, 06 Oct 2008 19:45:07 -0400, Pat <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
>> I can't figure out how to set up a Python data structure to read in
>> data that looks something like this (albeit somewhat simplified and 
>> contrived):
>>
>>
>> States
>> Counties
>>   Schools
>> Classes
>>Max Allowed Students
>>Current enrolled Students
>>
>> Nebraska, Wabash, Newville, Math, 20, 0 Nebraska, Wabash, Newville,
>> Gym, 400, 0 Nebraska, Tingo,  Newfille, Gym, 400, 0 Ohio, Dinger,
>> OldSchool, English, 10, 0
>
>   
>

> The structure looks more suited to a database -- maybe SQLite since
> the interface is supplied with the newer versions of Python (and
> available for older versions).

I don't understand why I need a database when it should just be a matter of 
defining the data structure.  I used a fictional example to make it easier to 
(hopefully) convey how the data is laid out.

One of the routines in the actual program checks a few thousand computers to 
verify that certain processes are running.  I didn't want to complicate my 
original question by going through all of the gory details (multiple userids 
running many processes with some of the processes having the same name).  To 
save time, I fork a process for each computer that I'm checking.  It seems to 
me that banging away at a database would greatly slow down the program and make 
the program more complicated.

The Perl routine works fine and I'd like to emulate that behavior but since 
I've just starting learning Python I don't know the syntax for designing the 
data structure.  I would really appreciate it if someone could point me in the 
right direction.

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


ms-word automation- Properties

2008-10-07 Thread gita ziabari
I want to automatically add some text in properties of ms-word using python.
I know the function to be called is CustomDocumentProperties, but my code is
not working. Any suggestion?

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


Getting namespaces right when parsing/executing Python ASTs

2008-10-07 Thread Gordon Fraser
Hi,

I'm trying to parse Python code to an AST, apply some changes to the AST
and then compile and run the AST, but I'm running into problems when
trying to evaluate/execute the resulting code object. It seems that the
global namespace differs depending on where I call parse and eval/exec.

The following code parses a file, compiles and then evaluates the AST.
If I call Python directly on this code, then it works:

import sys, parser
ast = parser.suite(open(sys.argv[1]).read())
code = ast.compile()
exec(code)

...and it also works this way with Python2.6:

ast = compile(open(sys.argv[1]).read(), "",
'exec',_ast.PyCF_ONLY_AST)
code = compile(ast, "http://mail.python.org/mailman/listinfo/python-list


Re: type-checking support in Python?

2008-10-07 Thread Bas
On Oct 7, 8:36 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> In message <[EMAIL PROTECTED]>, Gabriel
>
> Genellina wrote:
> > As an example, in the oil industry here in my country there is a mix of
> > measurement units in common usage. Depth is measured in meters, but pump
> > stroke in inches; loads in lbs but pressures in kg/cm².
>
> Isn't the right way to handle that to attach dimensions to each number?

What they taught me as a physics undergrad is to always convert random
units given as input to SI units as soon as possible, do all your
calculations internally in SI units and (only if really needed)
convert back to arbitrary units on output. Now, 15 years later, I am
still trying to stick to this rule whenever possisble. This convention
allows you to 'forget' about units and save your pre/post-fixes for
the exceptional case:
inch = 0.0254
lenght_inch = some_user_input_in_inch()
length = length_inch * inch

I have heard about some python package which overloads numbers and
calculations to include units (quick google found unum, not sure if
that is the only one). I guess that unless you are dealing with life-
critical equipment or are using extreme programming, this is overkill
(but I guess python is not really the right language for that anyway,
imagine a garbage collection just when you want to launch your
shuttle).

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


Race condition when generating .pyc files

2008-10-07 Thread [EMAIL PROTECTED]
I have a large body of Python code which runs on many different (Unix)
machines concurrently.  Part of the code lives in one place, but most
of it lives in directories which I find at runtime.  I only have one
copy of each Python source file and I think I'm hitting a race
condition where two hosts attempt to import the same module at the
same time.  My import fails on one of the machines and the following
exception is thrown:
EOFError: EOF read where object expected
My hypothesis is that there's contention between the two (or more)
hosts when the module's .pyc file is generated.

Possible solutions I see:
1) Running a cron job before my code executes which compiles all the
python source first.
2) Making separate copies of all the .py files for each host running
the code - I'd rather not do this, it seems like a big pain.
3) Inhibiting the generation of .pyc files altogether if that's even
possible - I saw a PEP for a possible -R flag (http://www.python.org/
dev/peps/pep-0304/) but I don't think it has been added to a released
version of Python yet plus I am stuck with Python 2.4 for the time
being.

Any and all help appreciated.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: equivalent of py2exe in other os

2008-10-07 Thread Almar Klein
Hi,
I was going to say "try google", but it seems quite hard to find indeed.
Use "freeze" for linux and "py2app" for osx.

I know of a program called gui2exe which is a gui which uses the three
to compile executables of your os of choise (but I think only py2exe was
implemented thus far).

Almar

2008/10/7 Astan Chee <[EMAIL PROTECTED]>

> Hi,
> I was just wondering if there is a equivalent of py2exe on linux (centOS)
> and mac (OS X). I have a python script that uses wx and I dont want to
> install wx on linux/mac machines. What are my choices?
> Thanks
> Astan
>
> --
> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose
> two." -David Morgan-Mar
>
>
>
> Animal Logic
> http://www.animallogic.com
>
> Please think of the environment before printing this email.
>
> This email and any attachments may be confidential and/or privileged. If
> you are not the intended recipient of this email, you must not disclose or
> use the information contained in it. Please notify the sender immediately
> and delete this document if you have received it in error. We do not
> guarantee this email is error or virus free.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do you get rid of useless warnings?

2008-10-07 Thread skip
Grant> In the meantime, how do I get rid of this useless warning?

I thought something like this would work:

% python2.5 -W 'ignore:.*:Warning:.*:0'
Python 2.5.3a0 (release25-maint:66627M, Sep 26 2008, 14:40:24)
[GCC 4.2.2] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> with = 8
:1: Warning: 'with' will become a reserved keyword in Python 2.6

but so far, no joy in Mudville.  Futz around with that and see if you can
make it work.  I used this documentation section to come up with what I've
got so far:

http://www.python.org/doc/2.5.2/lib/warning-filter.html

The 2.6 docs look more fleshed out:

http://docs.python.org/library/warnings.html

but I haven't checked to see if it offers a little more detail about
supressing warnings from the command line.

HTH,

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


export opengl context to pdf

2008-10-07 Thread Vaibhav . bhawsar
Hi,
Does anyone know of a package that will allow me to output an opengl
context as a PDF (or postscript)?
I am using pyglet to render something on screen that i want to save as PDF.

thanks!
vaibhav



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


Lenovo Laptops N3000 0769CVQ - Buy Lenovo Laptops N3000 0769CVQ

2008-10-07 Thread Online Shopping
Lenovo Laptops N3000 0769CVQ - Buy Lenovo N3000 0769CVQ Laptop online
at this laptop shop | homeshop18 offers best Lenovo laptops at lowest
price online. To know more visit:
http://www.homeshop18.com/shop/u/y/p-Computers-Q-and-Q-Peripherals-S-Laptops-S-Lenovo-Q-N3000-Q-0769CVQ-Q-Notebook/Home_Online-pI_20249-clI_2-cI_920-pCI_909-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Builing Python 2.6 on AIX 5.2

2008-10-07 Thread Tino Wildenhain

brasse wrote:

Hello!

I am having some trouble building Python 2.6 on AIX. The steps I have
taken are:


... a funny side note: I was originally drawn to python because
perl wouldn't build on my particular installation of AIX
but python did :-) But this was 1.4 or so back then :-)

Cheers
Tino


smime.p7s
Description: S/MIME Cryptographic Signature
--
http://mail.python.org/mailman/listinfo/python-list


Professional training in Python & Biopython

2008-10-07 Thread bioinformatica
Dear Students,

The Bioinformatica Solutions is providing training in all the fields
of Bioinformatics like vaccine design, siRNA design, Gene
identification, Structure based rational  Drug designing, genomics,
proteomics, QSAR, metabolomics, new metabolic pathway design ,bioperl,
biopython, pharma informatics, etc.
We are also giving training in Bio-Perl. bio-Phython,ASP.Net etc.whic
are the industry oriented course in IT. Accommodation is available
here nearby our institute & we assist in accommodation finding also.
Many papers are published from this institute in reputated journal
from the students which was doing dissertation work from TBS. You can
download the application form from the site: www.thebioinformatica.com
and registration can be done by sending your CV and form.


Shuchi Smita
Director
The Bioinformatica Solutions




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


Re: how can we send keys to keyboard

2008-10-07 Thread Mike Driscoll
On Oct 7, 10:13 am, mhangman <[EMAIL PROTECTED]> wrote:
> how can we send keys to keyboard? i want to write a script that will
> push keyboard buttons and do what i want. its for a macro prog. there
> are some kinds at c++ and at java. for example actools prog. but i
> want to this in python...
>
> note:im not talking about print a key im talking about use it from its
> device
> please help


If I understand you correctly, you're probably wanting something like
SendKeys:

http://pypi.python.org/pypi/SendKeys/0.3

Unfortunately, this is for Windows only (as far as I can tell). But
you didn't say what OS you were using, so maybe this will work.

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


equivalent of py2exe in other os

2008-10-07 Thread Astan Chee

Hi,
I was just wondering if there is a equivalent of py2exe on linux 
(centOS) and mac (OS X). I have a python script that uses wx and I dont 
want to install wx on linux/mac machines. What are my choices?

Thanks
Astan

--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." 
-David Morgan-Mar



Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you 
are not the intended recipient of this email, you must not disclose or use the 
information contained in it. Please notify the sender immediately and delete 
this document if you have received it in error. We do not guarantee this email 
is error or virus free.



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


Re: HARD REAL TIME PYTHON

2008-10-07 Thread Diez B. Roggisch
Kurt Mueller wrote:

> David,
> 
> 
> Am 07.10.2008 um 01:25 schrieb Blubaugh, David A.:
>> I have done some additional research into the possibility of utilizing
>> Python for hard real time development.  I have seen on various
>> websites
>> where this has been discussed before on the internet.  However, I was
>> wondering as to how successful anyone has truly been in developing a
>> program project either in windows or in Linux that was or extremely
>> close to real time constraints? For example is it possible to
>> develop a
>> python program that can address an interrupt or execute an operation
>> within 70 Hz or less?? Are there any additional considerations that I
>> should investigate first regarding this matter??
> 
> 
> As others mentioned before, python is not the right tool for "HARD
> REAL TIME".
> 
> But: Maybe you can isolate the part of your application that needs
> "HARD REAL TIME".
>Then implement this part in an approriate Environment (Language,
> OS, HW).
>Then implement the rest of your application which is not "HARD
> REAL TIME"
>in python.
> 
> To be more helpful, we should know what you mean by "HARD REAL TIME".
>Do you mean:
>- Handle at least 70 interrupt per second("SPEED")
>- If one fails, this is catastrophic for the application ("HARD")
>- Deliver an response to an interrupt within 5-10[ms]("REAL
> TIME")
> 
> see http://en.wikipedia.org/wiki/Real-time

I've done this using RTAI + ctypes. Of course the hard realtime tasks are
written in C - but only the absolutely minimal core.

Works like a charm.

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


Re: HARD REAL TIME PYTHON

2008-10-07 Thread Kurt Mueller

David,


Am 07.10.2008 um 01:25 schrieb Blubaugh, David A.:

I have done some additional research into the possibility of utilizing
Python for hard real time development.  I have seen on various  
websites

where this has been discussed before on the internet.  However, I was
wondering as to how successful anyone has truly been in developing a
program project either in windows or in Linux that was or extremely
close to real time constraints? For example is it possible to  
develop a

python program that can address an interrupt or execute an operation
within 70 Hz or less?? Are there any additional considerations that I
should investigate first regarding this matter??



As others mentioned before, python is not the right tool for "HARD  
REAL TIME".


But: Maybe you can isolate the part of your application that needs  
"HARD REAL TIME".
  Then implement this part in an approriate Environment (Language,  
OS, HW).
  Then implement the rest of your application which is not "HARD  
REAL TIME"

  in python.

To be more helpful, we should know what you mean by "HARD REAL TIME".
  Do you mean:
  - Handle at least 70 interrupt per second("SPEED")
  - If one fails, this is catastrophic for the application ("HARD")
  - Deliver an response to an interrupt within 5-10[ms]("REAL  
TIME")


see http://en.wikipedia.org/wiki/Real-time


Grüessli
--
Kurt Müller, [EMAIL PROTECTED]

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


Re: How do you get rid of useless warnings?

2008-10-07 Thread Martin Geisler
Grant Edwards <[EMAIL PROTECTED]> writes:

> I'm getting awfully tired of constant warnings about what's
> going to happen at some point in the future.
>
> Warnings like this:
>
>   ./surfplot.py:313: Warning: 'with' will become a reserved keyword in
>   Python 2.6
>
> And this:
>
>   /usr/lib/python2.5/site-packages/scipy/linalg/__init__.py:32:
>   DeprecationWarning: NumpyTest will be removed in the next release;
>   please update your code to use nose or unittest
>
> And so on...

Take a look at the -W command line option to python. From the man page:

 -W argument
Warning control.  Python sometimes  prints  warning  message  to
sys.stderr.   A  typical warning message has the following form:
file:line: category:  message.   By  default,  each  warning  is
printed  once for each source line where it occurs.  This option
controls how often warnings are printed.   Multiple  -W  options
may  be  given; when a warning matches more than one option, the
action for the last matching option is  performed.   Invalid  -W
options  are ignored (a warning message is printed about invalid
options when the first warning is issued).  Warnings can also be
controlled  from within a Python program using the warnings mod-
ule.

The simplest form of argument is one  of  the  following  action
strings  (or  a unique abbreviation): ignore to ignore all warn-
ings; default to explicitly request the default behavior (print-
ing  each  warning once per source line); all to print a warning
each time it occurs (this may generate many messages if a  warn-
ing  is  triggered  repeatedly for the same source line, such as
inside a loop); module to print each warning only only the first
time  it  occurs in each module; once to print each warning only
the first time it occurs in the program; or error  to  raise  an
exception instead of printing a warning message.

The   full  form  of  argument  is  action:message:category:mod-
ule:line.  Here, action is as explained above but  only  applies
to messages that match the remaining fields.  Empty fields match
all values; trailing empty fields may be omitted.   The  message
field  matches  the  start  of the warning message printed; this
match is case-insensitive.  The category field matches the warn-
ing category.  This must be a class name; the match test whether
the actual warning category of the message is a subclass of  the
specified  warning category.  The full class name must be given.
The module field matches the (fully-qualified) module name; this
match  is  case-sensitive.  The line field matches the line num-
ber, where zero matches all line numbers and is thus  equivalent
to an omitted line number.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.


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


Re: how can we send keys to keyboard

2008-10-07 Thread mhangman
On 7 Ekim, 18:34, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Oct 7, 10:13 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > how can we send keys to keyboard? i want to write a script that will
> > push keyboard buttons and do what i want. its for a macro prog. there
> > are some kinds at c++ and at java. for example actools prog. but i
> > want to this in python...
>
> > note:im not talking about print a key im talking about use it from its
> > device
> > please help
>
> If I understand you correctly, you're probably wanting something like
> SendKeys:
>
> http://pypi.python.org/pypi/SendKeys/0.3
>
> Unfortunately, this is for Windows only (as far as I can tell). But
> you didn't say what OS you were using, so maybe this will work.
>
> Mike

ty mike but it use a c++ module with it. cant we find python/made
module?
or donno..

bdw: OS windows, linux doesnt matter just let me learn this
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do you get rid of useless warnings?

2008-10-07 Thread Grant Edwards
On 2008-10-07, Martin Geisler <[EMAIL PROTECTED]> wrote:
> Grant Edwards <[EMAIL PROTECTED]> writes:
>
>> I'm getting awfully tired of constant warnings about what's
>> going to happen at some point in the future.
>>
>> Warnings like this:
>>
>>   ./surfplot.py:313: Warning: 'with' will become a reserved keyword in
>>   Python 2.6
>>
>> And this:
>>
>>   /usr/lib/python2.5/site-packages/scipy/linalg/__init__.py:32:
>>   DeprecationWarning: NumpyTest will be removed in the next release;
>>   please update your code to use nose or unittest
>>
>> And so on...
>
> Take a look at the -W command line option to python. From the
> man page:

I've -W options before without much luck, but I'll give it
another go.  It certainly appears that should be the solution.

-- 
Grant Edwards   grante Yow! World War III?
  at   No thanks!
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: time

2008-10-07 Thread Mike Driscoll
On Oct 7, 10:05 am, Gabriel Rossetti <[EMAIL PROTECTED]>
wrote:
> Hello everyone!
>
> I trying to work with time and I a bit confused... If I look at my
> clock, it's 16:59 (4:59pm), if I type "date" in a terminal, it says the
> same thing. I'm wanting to write a simple NTP-type server/client (it's
> not NTP at all actually, but does the same thing). The idea is that a
> client sends it it's UTC offset and it returns the current time, so the
> server side checks the time and adds the UTC offset given by the client.
> I'm a UTC/GMT +1, I tried obtaining the UTC time, it says it's 2 hours
> earlier than the current time (14:59). I tried various other methods, I
> still get the wrong time. Does anyone have an idea with what is wrong?
>
> Thanks,
> Gabriel

Take a look at the time module. It has the functions you'll need.
Here's a proof of concept:



import time

def getCurrentTime(offset):
"""
Assumes offset is in hours and must convert
the offset to seconds
"""
offset = offset * 60 * 60
now = time.time() # returns seconds since the epoch
# gmtime creates a time_struct instance to allow formatting
now_struct = time.gmtime(now)
print time.strftime("Current time: %H:%M", now_struct)
now += offset
now_struct = time.gmtime(now)
print time.strftime("Current time: %H:%M", now_struct)
return now

if __name__ == "__main__":
getCurrentTime(-2)



See the docs for more info:  
http://www.python.org/doc/2.5.2/lib/module-time.html

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


Re: Race condition when generating .pyc files

2008-10-07 Thread Gerhard Häring

[EMAIL PROTECTED] wrote:

I have a large body of Python code which runs on many different (Unix)
machines concurrently.  Part of the code lives in one place, but most
of it lives in directories which I find at runtime.  I only have one
copy of each Python source file and I think I'm hitting a race
condition where two hosts attempt to import the same module at the
same time.  My import fails on one of the machines and the following
exception is thrown:
EOFError: EOF read where object expected
My hypothesis is that there's contention between the two (or more)
hosts when the module's .pyc file is generated.

Possible solutions I see:
1) Running a cron job before my code executes which compiles all the
python source first.
2) Making separate copies of all the .py files for each host running
the code - I'd rather not do this, it seems like a big pain.
3) Inhibiting the generation of .pyc files altogether if that's even
possible [...]


If you don't want pyc files to be created, you could set Unix 
permissions such that Python cannot write to the directory.


-- Gerhard

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


Re: how can we send keys to keyboard

2008-10-07 Thread Mike Driscoll
On Oct 7, 10:42 am, mhangman <[EMAIL PROTECTED]> wrote:
> On 7 Ekim, 18:34, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 7, 10:13 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > > how can we send keys to keyboard? i want to write a script that will
> > > push keyboard buttons and do what i want. its for a macro prog. there
> > > are some kinds at c++ and at java. for example actools prog. but i
> > > want to this in python...
>
> > > note:im not talking about print a key im talking about use it from its
> > > device
> > > please help
>
> > If I understand you correctly, you're probably wanting something like
> > SendKeys:
>
> >http://pypi.python.org/pypi/SendKeys/0.3
>
> > Unfortunately, this is for Windows only (as far as I can tell). But
> > you didn't say what OS you were using, so maybe this will work.
>
> > Mike
>
> ty mike but it use a c++ module with it. cant we find python/made
> module?
> or donno..
>
> bdw: OS windows, linux doesnt matter just let me learn this


What difference does it make if it includes a c file (it's not C++)?
Python itself relies on C code too for some of it's fastest bits. The
"xrange" builtin is one good example. Besides, I think learning C/C++
would be a good idea for any Python programmer that wants to get truly
proficient in his snake charming.

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


Re: time

2008-10-07 Thread Richard Brodie

"Gabriel Rossetti" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
.
> I'm a UTC/GMT +1, I tried obtaining the UTC time, it says it's 2 hours 
> earlier than the 
> current time (14:59). I tried various other methods, I still get the wrong 
> time. Does 
> anyone have an idea with what is wrong?

It would be helpful to specify a named timezone. 2 hours earlier would be
expected for central Europe, it being summer. Sorry if that's obvious. 


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


Re: how to get the thighest bit position in big integers?

2008-10-07 Thread mmgarvey
> See also http://bugs.python.org/issue3439
> where there's a proposal to expose the _PyLong_NumBits method.  This
> would give an O(1) solution.

> > In every case I can think of, I've wanted (0).numbits() to be 0.

Here is surely the wrong place to respond to
  http://bugs.python.org/msg71384
but I want to make clear that I think that (0).numbits()==-1
is the natural solution. At least for all square-and-multiply-like
algorithms needed in cryptography (modular exponentiation, point
multiplication
on elliptic curves, generation of lucas numbers, etc) this property
of .numbits()
would be needed.

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


Re: time

2008-10-07 Thread Mike Driscoll
On Oct 7, 11:11 am, "Richard Brodie" <[EMAIL PROTECTED]> wrote:
> "Gabriel Rossetti" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> .
>
> > I'm a UTC/GMT +1, I tried obtaining the UTC time, it says it's 2 hours 
> > earlier than the
> > current time (14:59). I tried various other methods, I still get the wrong 
> > time. Does
> > anyone have an idea with what is wrong?
>
> It would be helpful to specify a named timezone. 2 hours earlier would be
> expected for central Europe, it being summer. Sorry if that's obvious.

There are "tzset" and "tzname" methods to the time module. I've heard
conflicting reports about their effectiveness, but never tried them
myself.

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


Re: how to start thread by group?

2008-10-07 Thread Terry Reedy

Lawrence D'Oliveiro wrote:

In message <[EMAIL PROTECTED]>, Gabriel
Genellina wrote:


Usually it's more efficient to create all the MAX_THREADS at once, and
continuously feed them with tasks to be done.


Given that the bottleneck is most likely to be the internet connection, I'd
say the "premature optimization is the root of all evil" adage applies
here.


There is also the bottleneck of programmer time to understand, write, 
and maintain.  In this case, 'more efficient' is simpler, and to me, 
more efficient of programmer time.  Feeding a fixed pool of worker 
threads with a Queue() is a standard design that is easy to understand 
and one the OP should learn.  Re-using tested code is certainly 
efficient of programmer time.  Managing a variable pool of workers that 
die and need to be replaced is more complex (two loops nested within a 
loop) and error prone (though learning that alternative is probably not 
a bad idea also).


tjr

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


Re: how can we send keys to keyboard

2008-10-07 Thread mhangman
On 7 Ekim, 18:57, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Oct 7, 10:42 am, mhangman <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 7 Ekim, 18:34, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
> > > On Oct 7, 10:13 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > > > how can we send keys to keyboard? i want to write a script that will
> > > > push keyboard buttons and do what i want. its for a macro prog. there
> > > > are some kinds at c++ and at java. for example actools prog. but i
> > > > want to this in python...
>
> > > > note:im not talking about print a key im talking about use it from its
> > > > device
> > > > please help
>
> > > If I understand you correctly, you're probably wanting something like
> > > SendKeys:
>
> > >http://pypi.python.org/pypi/SendKeys/0.3
>
> > > Unfortunately, this is for Windows only (as far as I can tell). But
> > > you didn't say what OS you were using, so maybe this will work.
>
> > > Mike
>
> > ty mike but it use a c++ module with it. cant we find python/made
> > module?
> > or donno..
>
> > bdw: OS windows, linux doesnt matter just let me learn this
>
> What difference does it make if it includes a c file (it's not C++)?
> Python itself relies on C code too for some of it's fastest bits. The
> "xrange" builtin is one good example. Besides, I think learning C/C++
> would be a good idea for any Python programmer that wants to get truly
> proficient in his snake charming.
>
> Mike

ty mike,
im just looking for other ways which can improve my style,information.
i read some java stuff some c++ some c# and c about this work. but can
python do this whiout include any of this?
need to learn, thanks for helping
--
http://mail.python.org/mailman/listinfo/python-list


Re: automatically insert text in ms-word properties

2008-10-07 Thread Peter Wang
"gita ziabari" <[EMAIL PROTECTED]> writes:

> All,
>
> I wanna use python to automatically insert text in ms-word properties.
> Anyone could help me?
Why not use VBA for that work? 
>
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Re: Compiler, ast and forwards/backwards compatibility

2008-10-07 Thread Terry Reedy

Orestis Markou wrote:

Hello,

I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a
static analysis/intellisense provider for Python. I am targeting
Python 2.4 code so I'm using the compiler package.

I've been toying around yesterday with the ast module in Python 2.6
and it seems much more cleaner. One thing I don't understand is how
should one handle backwards and forwards compatibility.


My impression is that the 2.6 ast package is quite different from the 
2.4 compiler package, but I have not looked at it (in its 3.0 version) 
yet.  If the 2.4 code you are analyzing is syntactically and sematically 
valid as 2.6 code, which I believe is usual, then of course there is no 
problem.  If it is not, then I would not be sure.



I guess that Python 2.6 can target Python 2.3-6, and with specific
compiler flags it can also target 3.0, so it seems that the correct
thing to do is to use that.


If you want to target 2.3 to 3.0, 2.6 is the only option as far as I 
know.  I expect you will want to run your code through 2to3 (still being 
improved) and run under 3.0 to properly handle 3.0 code.


Maybe someone else can give a better answer.

tjr

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


Re: Array of dict or lists or ....?

2008-10-07 Thread Aaron "Castironpi" Brady
On Oct 7, 10:16 am, "Barak, Ron" <[EMAIL PROTECTED]> wrote:
> Would the following be suitable data structure:
> ...
> struct = {}
> struct["Nebraska"] = "Wabash"
> struct["Nebraska"]["Wabash"] = "Newville"
> struct["Nebraska"]["Wabash"]["Newville"]["topics"] = "Math"
> struct["Nebraska"]["Wabash"]["Newville"]["Math"]["Max Allowed Students"] = 20
> struct["Nebraska"]["Wabash"]["Newville"]["Math"]["Current enrolled Students"] 
> = 0
> ...

That's not quite right as stated.

>>> struct = {}
>>> struct["Nebraska"] = "Wabash"
>>> struct["Nebraska"]["Wabash"] = "Newville"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'str' object does not support item assignment

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


Re: Race condition when generating .pyc files

2008-10-07 Thread Aaron "Castironpi" Brady
On Oct 7, 10:21 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have a large body of Python code which runs on many different (Unix)
> machines concurrently.  Part of the code lives in one place, but most
> of it lives in directories which I find at runtime.  I only have one
> copy of each Python source file and I think I'm hitting a race
> condition where two hosts attempt to import the same module at the
> same time.  My import fails on one of the machines and the following
> exception is thrown:
> EOFError: EOF read where object expected
> My hypothesis is that there's contention between the two (or more)
> hosts when the module's .pyc file is generated.


Acquire an flock on the .py file, then compile it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Race condition when generating .pyc files

2008-10-07 Thread Bruno Desthuilliers

[EMAIL PROTECTED] a écrit :

I have a large body of Python code which runs on many different (Unix)
machines concurrently.  Part of the code lives in one place, but most
of it lives in directories which I find at runtime.  I only have one
copy of each Python source file and I think I'm hitting a race
condition where two hosts attempt to import the same module at the
same time.  My import fails on one of the machines and the following
exception is thrown:
EOFError: EOF read where object expected
My hypothesis is that there's contention between the two (or more)
hosts when the module's .pyc file is generated.

Possible solutions I see:
1) Running a cron job before my code executes which compiles all the
python source first.


If you package your apps using setup, pyc should be automatically 
generated. Don't know if it can apply to your problem. But surely I'd go 
this way (ie : automating pyc creation one way or another).



2) Making separate copies of all the .py files for each host running
the code - I'd rather not do this, it seems like a big pain.


yeps.


3) Inhibiting the generation of .pyc files altogether if that's even
possible - I saw a PEP for a possible -R flag (http://www.python.org/
dev/peps/pep-0304/) but I don't think it has been added to a released
version of Python yet plus I am stuck with Python 2.4 for the time
being.


Not having pyc means the modules will have to be recompiled on each 
import. Not sure this is what you want.


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


Re: how can we send keys to keyboard

2008-10-07 Thread Jason Scheirer
On Oct 7, 9:28 am, mhangman <[EMAIL PROTECTED]> wrote:
> On 7 Ekim, 18:57, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 7, 10:42 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > > On 7 Ekim, 18:34, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
> > > > On Oct 7, 10:13 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > > > > how can we send keys to keyboard? i want to write a script that will
> > > > > push keyboard buttons and do what i want. its for a macro prog. there
> > > > > are some kinds at c++ and at java. for example actools prog. but i
> > > > > want to this in python...
>
> > > > > note:im not talking about print a key im talking about use it from its
> > > > > device
> > > > > please help
>
> > > > If I understand you correctly, you're probably wanting something like
> > > > SendKeys:
>
> > > >http://pypi.python.org/pypi/SendKeys/0.3
>
> > > > Unfortunately, this is for Windows only (as far as I can tell). But
> > > > you didn't say what OS you were using, so maybe this will work.
>
> > > > Mike
>
> > > ty mike but it use a c++ module with it. cant we find python/made
> > > module?
> > > or donno..
>
> > > bdw: OS windows, linux doesnt matter just let me learn this
>
> > What difference does it make if it includes a c file (it's not C++)?
> > Python itself relies on C code too for some of it's fastest bits. The
> > "xrange" builtin is one good example. Besides, I think learning C/C++
> > would be a good idea for any Python programmer that wants to get truly
> > proficient in his snake charming.
>
> > Mike
>
> ty mike,
> im just looking for other ways which can improve my style,information.
> i read some java stuff some c++ some c# and c about this work. but can
> python do this whiout include any of this?
> need to learn, thanks for helping

You definitely need SendKeys, and you definitely need to talk to
Windows through some C library. It doesn't matter which bridge you
use, but your code is going to touch something written in C eventually
to accomplish this.

Check out this example: http://code.activestate.com/recipes/65107/

The pywin32 libraries are pretty much a must if you're working in
Windows and Python regardless.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Race condition when generating .pyc files

2008-10-07 Thread [EMAIL PROTECTED]
> If you package your apps using setup, pyc should be automatically
> generated. Don't know if it can apply to your problem. But surely I'd go
> this way (ie : automating pyc creation one way or another).

Yeah, I don't package up my code, it's all integrated into my build
system,
not an actual deliverable.

> Not having pyc means the modules will have to be recompiled on each
> import. Not sure this is what you want.
I realize that that would be slower, but I think it would avoid the
problem
I'm seeing because no host would actually be creating a .pyc file.
But is it even possible in Python 2.4?


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


Re: type-checking support in Python?

2008-10-07 Thread Aaron "Castironpi" Brady
On Oct 7, 5:24 am, Bas <[EMAIL PROTECTED]> wrote:
> On Oct 7, 8:36 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
>
> central.gen.new_zealand> wrote:
> > In message <[EMAIL PROTECTED]>, Gabriel
>
> > Genellina wrote:
> > > As an example, in the oil industry here in my country there is a mix of
> > > measurement units in common usage. Depth is measured in meters, but pump
> > > stroke in inches; loads in lbs but pressures in kg/cm².
>
> > Isn't the right way to handle that to attach dimensions to each number?
>
> What they taught me as a physics undergrad is to always convert random
> units given as input to SI units as soon as possible, do all your
> calculations internally in SI units and (only if really needed)
> convert back to arbitrary units on output.
(snip)

If you think it's a potential source of error, a lightweight version
wouldn't be hard to implement.  This one is absolute minimal, using
strings for the units.  Multiplication is harder, since you want 'foot
pounds' == 'pound feet'.

>>> class UnitScalar:
... def __init__( self, val, type ):
... self.val, self.type= val, type
... def __add__( self, other ):
... assert self.type== other.type, 'Must be same type'
... return self.__class__( self.val+ other.val,
self.type )
... def __repr__( self ):
... return ''% ( self.val, self.type )
...
>>> a, b= UnitScalar( 2, 'feet' ), UnitScalar( 3, 'feet' )
>>> a+ b

>>> a, b= UnitScalar( 2, 'feet' ), UnitScalar( 3, 'inches' )
>>> a+ b
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 5, in __add__
AssertionError: Must be same type
--
http://mail.python.org/mailman/listinfo/python-list


Re: equivalent of py2exe in other os

2008-10-07 Thread Benjamin Kaplan
On Tue, Oct 7, 2008 at 10:58 AM, Joe Strout <[EMAIL PROTECTED]> wrote:

> On Oct 7, 2008, at 8:43 AM, Benjamin Kaplan wrote:
>
>  I believe that all (or nearly all) Unix variants come with Python
>> preinstalled. Ubuntu, at least, has a lot of system programs written in
>> Python. Even Mac OS X requires Python.
>>
>
> Yes, but with significant differences between different Python
> distributions, you might be safer bundling whatever version of Python your
> app requires with the app itself.  Otherwise, you risk your app failing (and
> probably puking up runtime exceptions all over the poor user's lap) on some
> distros or versions.
>
> (My Mac OS X machine comes with Python 2.5.1, for example, which is hardly
> the latest.)
>

1) 2.6 doesn't break backwards-compatibility, just don't use anything added
in 2.6 and you're fine.

2)wx hasn't been compiled for 2.6 yet, so the OP is probably still using 2.5
and there are no api changes between 2.5.1 and 2.5.2


> Best,
> - Joe
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do you get rid of useless warnings?

2008-10-07 Thread Terry Reedy

Grant Edwards wrote:


  /usr/lib/python2.5/site-packages/scipy/linalg/__init__.py:32:

 DeprecationWarning: NumpyTest will be removed in the next release;
 please update your code to use nose or unittest


I'm also not using "the next release" of scipy, I'm using
_this_ release of scipy.  I've no clue what any of the "nose"
or "unittest" stuff is about,


Unittest is a stdlib module.  Nose is a 3rd party test framework built 
on top of unittest.  The code you are running currently uses NumpyTest.
In the future relative to the release you are using, NumpyTest will 
disappear but can be replaced either with unittest or nose.


If the -W warning suppression does not work as advertised, now is the 
time to check the tracker at bugs.python.org to see if there is already 
a report for 2.5 (possibly closed) and if not, make one.  2.5.3 will be 
released in a month or two and will be the last general bugfix release 
for that series.  A report will not guarantee a fix, but no report will 
guarantee no fix.


tjr

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


Re: How do you get rid of useless warnings?

2008-10-07 Thread Peter Otten
Grant Edwards wrote:

> I'm getting awfully tired of constant warnings about what's
> going to happen at some point in the future.
> 
> Warnings like this:
> 
> ./surfplot.py:313: Warning: 'with' will become a reserved keyword in
> Python 2.6

The "with" and "as" warnings bypass the warning mechanism. The only way I
can see to avoid them is to compile the python code:

$ cat warnwith.py
with = 42
$ python warnwith.py
warnwith.py:1: Warning: 'with' will become a reserved keyword in Python 2.6
$ python -c "import warnwith"
warnwith.py:1: Warning: 'with' will become a reserved keyword in Python 2.6
$ python warnwith.pyc

Peter


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


Re: Compiler, ast and forwards/backwards compatibility

2008-10-07 Thread Orestis Markou
On Tue, Oct 7, 2008 at 5:39 PM, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Orestis Markou wrote:
>>
>> Hello,
>>
>> I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a
>> static analysis/intellisense provider for Python. I am targeting
>> Python 2.4 code so I'm using the compiler package.
>>
>> I've been toying around yesterday with the ast module in Python 2.6
>> and it seems much more cleaner. One thing I don't understand is how
>> should one handle backwards and forwards compatibility.
>
> My impression is that the 2.6 ast package is quite different from the 2.4
> compiler package, but I have not looked at it (in its 3.0 version) yet.  If
> the 2.4 code you are analyzing is syntactically and sematically valid as 2.6
> code, which I believe is usual, then of course there is no problem.  If it
> is not, then I would not be sure.

The ast module is indeed very different from the compiler package, as
it depends on the exact grammar definition that the interpreter is
using, rather a re-implementation (which I understand the compiler.ast
is).

My confusion starts with the fact that I'm not sure if all Python 2.4
code is going to be syntactically valid 2.6 code. I guess 2.3 is valid
2.4 is valid 2.5, which should be valid 2.6 (but not valid 3.0) - I
think it's the lockstep of 2.6 and 3.0 that's misleading me...
>
>> I guess that Python 2.6 can target Python 2.3-6, and with specific
>> compiler flags it can also target 3.0, so it seems that the correct
>> thing to do is to use that.
>
> If you want to target 2.3 to 3.0, 2.6 is the only option as far as I know.
>  I expect you will want to run your code through 2to3 (still being improved)
> and run under 3.0 to properly handle 3.0 code.

That sounds correct. It's annoying that I have to require Python 2.6
for this - I guess that since the compiler module is there in 2.6 I'm
not compelled to use ast until I want to run under 3.0...
>
> Maybe someone else can give a better answer.
>
> tjr
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
[EMAIL PROTECTED]
http://orestis.gr
--
http://mail.python.org/mailman/listinfo/python-list


Re: how can we send keys to keyboard

2008-10-07 Thread mhangman
On 7 Ekim, 19:50, Jason Scheirer <[EMAIL PROTECTED]> wrote:
> On Oct 7, 9:28 am, mhangman <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 7 Ekim, 18:57, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
> > > On Oct 7, 10:42 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > > > On 7 Ekim, 18:34, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
> > > > > On Oct 7, 10:13 am, mhangman <[EMAIL PROTECTED]> wrote:
>
> > > > > > how can we send keys to keyboard? i want to write a script that will
> > > > > > push keyboard buttons and do what i want. its for a macro prog. 
> > > > > > there
> > > > > > are some kinds at c++ and at java. for example actools prog. but i
> > > > > > want to this in python...
>
> > > > > > note:im not talking about print a key im talking about use it from 
> > > > > > its
> > > > > > device
> > > > > > please help
>
> > > > > If I understand you correctly, you're probably wanting something like
> > > > > SendKeys:
>
> > > > >http://pypi.python.org/pypi/SendKeys/0.3
>
> > > > > Unfortunately, this is for Windows only (as far as I can tell). But
> > > > > you didn't say what OS you were using, so maybe this will work.
>
> > > > > Mike
>
> > > > ty mike but it use a c++ module with it. cant we find python/made
> > > > module?
> > > > or donno..
>
> > > > bdw: OS windows, linux doesnt matter just let me learn this
>
> > > What difference does it make if it includes a c file (it's not C++)?
> > > Python itself relies on C code too for some of it's fastest bits. The
> > > "xrange" builtin is one good example. Besides, I think learning C/C++
> > > would be a good idea for any Python programmer that wants to get truly
> > > proficient in his snake charming.
>
> > > Mike
>
> > ty mike,
> > im just looking for other ways which can improve my style,information.
> > i read some java stuff some c++ some c# and c about this work. but can
> > python do this whiout include any of this?
> > need to learn, thanks for helping
>
> You definitely need SendKeys, and you definitely need to talk to
> Windows through some C library. It doesn't matter which bridge you
> use, but your code is going to touch something written in C eventually
> to accomplish this.
>
> Check out this example:http://code.activestate.com/recipes/65107/
>
> The pywin32 libraries are pretty much a must if you're working in
> Windows and Python regardless.

ty jason i got my answer^^ i will look for it
--
http://mail.python.org/mailman/listinfo/python-list


re : do something in time interval

2008-10-07 Thread Hendrik van Rooyen
"Petr Jakeš" <[EMAIL PROTECTED]> wrote:

>"Leon Zhang" <[EMAIL PROTECTED]> wrote:
>
>>
>> I am not an expert, but why not to use time.sleep(5)?
>> If you are using wxPython, you may also try wx.Timer, in which you could
>> set its interval.
>>
>>
>Thanks for your reply.
>During the 5s period my script has to do some stuff instead of sleeping.
>Thats why it runs in the loop and once in 5s period it has to trigger some
>other stuff(function, method, action) to do.


import time
while True:
end_time = time.time() + 5
while time.time() < end_time:
do_the_in_between_stuff()
do_the_every_five_second_stuff()

HTH - Hendrik

--
Real programmers disdain structured programming.  Structured
programming is for compulsive neurotics who were prematurely
toilet-trained.  They wear neckties and carefully line up
pencils on otherwise clear desks.



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


re: HARD REAL TIME PYTHON

2008-10-07 Thread Hendrik van Rooyen

"Blubaugh, David A."  wrote:


>I have done some additional research into the possibility of utilizing
>Python for hard real time development.  I have seen on various websites
>where this has been discussed before on the internet.  However, I was
>wondering as to how successful anyone has truly been in developing a
>program project either in windows or in Linux that was or extremely
>close to real time constraints? For example is it possible to develop a
>python program that can address an interrupt or execute an operation
>within 70 Hz or less?? Are there any additional considerations that I
>should investigate first regarding this matter??

I am running some i/o in a thing called an eBox running Slackware
Linux for which GPIO port we have made some I/O boards. 
This is a very weak machine - 500Mhz 486 without fp, 128Mb ram.
Its just cheap, which is why we are using it.

I can send it 64 bytes, which it then puts out from userland
using ctypes to do the Linux calls, and it reads 64 bytes of
input in - the actual I/O can accomodate only eight bytes of
bits in and out, but we intend to add some analogue capability
later, so the rest hits the bit bucket, and the extra reads see
bus pullup values for now.

>From my PC over the lan, it does this between 74 and 75 times
a second, reliably.

If I run it between 2 PC's, faking the I/O by writing to a disk,
I sometimes get up to 250 such "pings" per second. Going full
duplex would pass a lot more info, but you lose the stimulus-
response nature, which is kind of nice to have in a control
environment.

Its not real time, but its not exactly yesterday's stuff either.

Both PC's have more than a gig of memory and two processors,
but that is not remarkable anymore.

We have also used python to do the HMI for an Injection
Moulding machine, talking to a custom controller with
an 8031 and an ARM on it via an RS-422 link running at
115200 - and the python keeps the link fully occupied 

And this is python that is interpreting another virtual
machine assembler...

So don't be afraid - go for it!

- Hendrik

--
Real programmers disdain structured programming.  Structured
programming is for compulsive neurotics who were prematurely
toilet-trained.  They wear neckties and carefully line up
pencils on otherwise clear desks. 


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


Making Non Callable Objects Callable

2008-10-07 Thread exiquio
I am trying to figure out if there is a way to make an object in
python callable, modules in particular. I wrongly assume that defining
'__call__' in the the objects __dict__ would work. Any help would be
appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >