Re: Why MyHDL?

2008-12-23 Thread Jan Decaluwe

Stef Mientki wrote:

hello Jan,

Jan Decaluwe wrote:

Hello:

MyHDL is a Python package for using Python as a
Hardware Description Language.

A new release is upcoming, and on this occasion
we have prepared a page about why MyHDL may
be useful to you:

http://www.myhdl.org/doku.php/why


Very Interesting,
I'm no expert at all (but as an exercise I'm just now writing an EDIF-v2 
to SystemC converter in Python) ,

I wonder why I only see comparison with VHDL and SystemVerilog,
and not with SystemC ?


MyHDL's target audience are the users of mainstream HDL-based design
flows (including synthesis and implementation.) I don't encounter
SystemC there.

Jan

--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Python as a hardware description language:
http://www.myhdl.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Strategy for determing difference between 2 very large dictionaries

2008-12-23 Thread Chris Rebert
On Tue, Dec 23, 2008 at 11:46 PM, Gabriel Genellina
 wrote:

>
> Yes; but isn't a dict comprehension more adequate?
>
> [key: (dict1[key], dict2[key]) for key in common_keys if
> dict1[key]!=dict2[key]}



That initial [ should be a { of course.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Strategy for determing difference between 2 very large dictionaries

2008-12-23 Thread Gabriel Genellina

En Wed, 24 Dec 2008 05:16:36 -0200,  escribió:


I'm looking for suggestions on the best ('Pythonic') way to
determine the difference between 2 very large dictionaries
containing simple key/value pairs.
By difference, I mean a list of keys that are present in the
first dictionary, but not the second. And vice versa. And a list
of keys in common between the 2 dictionaries whose values are
different.
The 2 strategies I'm considering are:
1. Brute force: Iterate through first dictionary's keys and
determine which keys it has that are missing from the second
dictionary. If keys match, then verify that the 2 dictionaries
have identical values for the same key. Repeat this process for
the second dictionary.
2. Use sets: Create sets from each dictionary's list of keys and
use Python's set methods to generate a list of keys present in
one dictionary but not the other (for both dictionaries) as well
as a set of keys the 2 dictionaries have in common.


I cannot think of any advantage of the first approach - so I'd use sets.

k1 = set(dict1.iterkeys())
k2 = set(dict2.iterkeys())
k1 - k2 # keys in dict1 not in dict2
k2 - k1 # keys in dict2 not in dict1
k1 & k2 # keys in both


Using the set
of keys in common, compare values across dictionaries to
determine which keys have different values (can this last step be
done via a simple list comprehension?)


Yes; but isn't a dict comprehension more adequate?

[key: (dict1[key], dict2[key]) for key in common_keys if  
dict1[key]!=dict2[key]}


(where common_keys=k1&k2 as above)

--
Gabriel Genellina

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


Most efficient way to build very large dictionaries

2008-12-23 Thread python
I'm working with some very large dictionaries (about 25M items
per dictionary) that get filled based on data parsed from text
based log files. I'm using Python dictionaries to track the
frequency of specific combinations of events, eg, I build a key
and then add various timing info from the current record to
that's key's current value. If the key doesn't exist, I create it
and initalize it to its first value. Most keys will have anywhere
from 2 to 10,000 value increments.
Over time, I've noticed that 90%+ of the keys in my dictionaries
stay constant across daily runs of my program. Can I take
advantage of this knowledge to optimize my dictionary performance
by pre-building my dictionary based on a given list of keys whose
values are all set to 0? Specifically, is there a way to bulk
load a dictionary with keys/initial values that is faster than
individually adding most dictionary entries one at a time?
Here are 2 high level strategies I've been thinking about for
improving the performance of my dictionaries.
1. Create a list of keys from a current dictionary, pickle this
list of keys and then on my next program run, load the pickled
list of keys and somehow convert this list to a dictionary with
all key values set to 0.
2. After I've performed my analysis on a current dictionary,
iterate through this dictionary, setting all values to 0 (is
there a fast way to do this?), and then on my next program run,
load this pickled dictionary of keys and zero values.
I would appreciate your thoughts on whether there are advantages
to working with a pre-built dictionary and if so, what are the
best ways to create a pre-loaded dictionary.
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list


GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008

2008-12-23 Thread Shaguf
---
 Great Indian Developer Summit 2009 - GIDS.Java 
 24 April 2009 
 J N Tata Auditorium, IISc, Bangalore 
 http://www.developersummit.com 
---

Dear Group members,

The economic downturn will run out of steam trying to outdo the 'ready
and waiting' software professional. Packed with premium knowledge,
action plans and advise from been-there-done-it veterans, creators,
and visionaries, the 2009 edition of Great Indian Developer Summit
features focused sessions, case studies, workshops and power panels
that will transform you into a force to reckon with.

Java Speakers at the 2009 edition of GIDS include: Clemens Utschig-
Utschig, Craig McClanahan, Debu Panda, Frank Nimphius, Howard Lewis
Ship, Dr. Jim Webber, Jonas Jacobi, Mike Keith, Ola Bini, Prabhu
Sunderraman, Thomas Marrs and Venkat Subramaniam. The conference this
year has sessions on Guerrilla SOA, REST, Groovy, Building Web
Services Using Spring, Struts 2.0 Deep Dive, Computing in the Cloud,
Building RESTful Applications with JAX-RS, Tuning performance of JPA
Applications, Diagnosing Production Java Applications, Building
RESTful Applications with Ruby on Rails, Maven 2 at Work, Apache
Utilities at Work, Web Services at Work, JRuby, Testing Java with
Ruby, Tapestry 5 Inversion of Control, Clojure: Concurrent Functional
Programming for the JVM, Unit testing, Apache Tapestry 5 and much
more. Please have a look at http://www.developersummit.com/speakers.html
for more info on the speakers and the sessions.

Register before the 29th of December for Rs. 1,999/-. Besides the
learning at the GIDS.Java conference on Friday, the 24th of April,
this fee also includes:

1. Discount of 35% on the standard fee
2. Assured Gift - GIDS 2009 Cult T-shirt (upon receipt of payment on
or before Jan 12 2009)
3. Entry into a lucky draw for the following gifts: Sony WEGA 29
inches (1), Mac Air Book (1), Wireless Mouse (50 nos), Apple iPOD 120
GB (5 nos).
4. Lunch and refreshments
5. Conference materials
6. Complimentary invitation to Cyrus Broacha's show at the Great
Indian Developer Awards on Saturday, the 25th of April 2009

So hurry up and register now under the GIDS Loyalty discount scheme:
http://www.developersummit.com/registration.html

Wishing you and your family a Merry Christmas and a wonderful year
ahead.

Thanks,
Shaguf
http://www.developersummit.com/
i...@developersummit.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Strategy for determing difference between 2 very large dictionaries

2008-12-23 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

pyt...@bdurham.com wrote:
> Feedback on my proposed strategies (or better strategies) would be
> greatly appreciated.

Both strategies will work but I'd recommend the second approach since it
uses already tested code written by other people - the chances of it
being wrong are far lower than new code.

You also neglected to mention what your concerns are or even what "very
large" is.  Example concerns are memory consumption, cpu consumption,
testability, utility of output (eg as a generator getting each result on
demand or a single list with complete results).  Some people will think
a few hundred entries is large.  My idea of large is a working set
larger than my workstation's 6GB of memory :-)

In general the Pythonic approach is:

1 - Get the correct result
2 - Simple code (developer time is precious)
3 - Optimise for your data and environment

Step 3 is usually not needed.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklR5DUACgkQmOOfHg372QSuWACgp0xrdpW+NSB6qqCM3oBY2e/I
LIEAn080VgNvmEYj47Mm7BtV69J1GwXN
=MKLl
-END PGP SIGNATURE-

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


Re: no sign() function ?

2008-12-23 Thread Steven D'Aprano
On Tue, 23 Dec 2008 14:36:53 +0100, Pierre-Alain Dorange wrote:

> Steven D'Aprano  wrote:
> 
>> But this is just duplicating what timeit already does. Trust me, learn
>> to use it, you won't be sorry. Here's a trick that took me a long time
>> to learn: instead of copying your functions into the setup code of
>> timeit, you can just import them.
> 
> Thanks for the advise, i made the test using timeit and your very
> interesting method to import... Now i know how to use timeit simply ;-)
> 
> New results on 1000 float values randomized from -500.0 to +500.0. Each
> test is timeit(1000)
> 
> sign_0 : 0.375
> sign_1 : 0.444 (+18%)
> sign_2 : 0.661 (+76%)
> sign_3 : 0.498 (+33%)


Looking at those results, and remembering that each time is for one 
million iterations of one thousand calls each, I'd say that there's so 
little difference in speed between them, that you should choose whichever 
function is easier to understand. At least until you profile your 
application and discover that the sign() function is the bottleneck 
keeping your program slow.



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


Re: Python's popularity

2008-12-23 Thread Steven D'Aprano
On Tue, 23 Dec 2008 08:06:35 -0800, the anonymous troll known only as "r" 
replied to Thorsten Kampe and said:

> Thats "Thurstan", thank you very much! :)


I think Thorsten knows how to spell his own name.


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


Strategy for determing difference between 2 very large dictionaries

2008-12-23 Thread python
I'm looking for suggestions on the best ('Pythonic') way to
determine the difference between 2 very large dictionaries
containing simple key/value pairs.
By difference, I mean a list of keys that are present in the
first dictionary, but not the second. And vice versa. And a list
of keys in common between the 2 dictionaries whose values are
different.
The 2 strategies I'm considering are:
1. Brute force: Iterate through first dictionary's keys and
determine which keys it has that are missing from the second
dictionary. If keys match, then verify that the 2 dictionaries
have identical values for the same key. Repeat this process for
the second dictionary.
2. Use sets: Create sets from each dictionary's list of keys and
use Python's set methods to generate a list of keys present in
one dictionary but not the other (for both dictionaries) as well
as a set of keys the 2 dictionaries have in common. Using the set
of keys in common, compare values across dictionaries to
determine which keys have different values (can this last step be
done via a simple list comprehension?)
Feedback on my proposed strategies (or better strategies) would
be greatly appreciated.
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list


Re: socket send help

2008-12-23 Thread Gabriel Genellina
En Wed, 24 Dec 2008 03:59:42 -0200, greyw...@gmail.com  
 escribió:



New guy here.  I'm trying to figure out sockets in order to one day do
a multiplayer game.  Here's my problem:  even the simplest examples
don't work on my computer:

A simple server:

from socket import *
myHost = ''


Try with myHost = '127.0.0.1' instead - a firewall might be blocking your  
server.



s.listen(5) # allow 5 simultaneous connections


Not exactly: your server program only handles a single connection at a  
time. The 5 above specifies how many connections may exist "on hold"  
waiting for you to accept() them.



connection.send('echo -> ' + data)


That's fine for Python 2.6, but you must use b'echo -> ' with 3.0


And a simple client:

s.send('Hello world')   # send the data


Same as above, should be b'Hello world' with Python 3.0


If I run testserver.py via the cmd prompt in Windows XP and then the
testclient.py program, I get the following error:

Traceback (most recent call last):
  File "C:\Python30\testclient.py", line 12, in 
s.send('Hello world')   # send the data
TypeError: send() argument 1 must be string or buffer, not str


The above error message is wrong (and I think it was corrected on the 3.0  
final release; if you got it with 3.0 final, file a bug report at  
http://bugs.python.org/ )



This happens in 2.6 or 3.0 and with different example client & server
programs from the web.  What am I missing?


The error above surely comes from 3.0; with 2.6 you should get a different  
error (if it fails at all). Try again with 2.6.1. I didn't run the code  
but it looks fine -- if you got it from a book or article, unless it  
explicitely says "Python 3.0", assume it was written for the 2.x series.


--
Gabriel Genellina

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


Re: socket send help

2008-12-23 Thread Chris Rebert
On Tue, Dec 23, 2008 at 9:59 PM, greyw...@gmail.com  wrote:
> Hi everyone,
>
> New guy here.  I'm trying to figure out sockets in order to one day do
> a multiplayer game.  Here's my problem:  even the simplest examples
> don't work on my computer:
>
> A simple server:
>
> from socket import *
> myHost = ''
> myPort = 21500
>
> s = socket(AF_INET, SOCK_STREAM)# create a TCP socket
> s.bind((myHost, myPort))# bind it to the server port
> s.listen(5) # allow 5 simultaneous connections
>
> while True:
>connection, address = s.accept()
>while True:
>data = connection.recv(1024)
>if data:
>connection.send('echo -> ' + data)
>else:
>break
>connection.close()  # close socket
>
> And a simple client:
>
> import sys
> from socket import *
> serverHost = 'localhost'# servername is localhost
> serverPort = 21500  # use arbitrary port > 1024
>
> s = socket(AF_INET, SOCK_STREAM)# create a TCP socket
>
>
> s.connect((serverHost, serverPort)) # connect to server on the port
> s.send('Hello world')   # send the data
> data = s.recv(1024) # receive up to 1K bytes
> print(data)
>
>
> If I run testserver.py via the cmd prompt in Windows XP and then the
> testclient.py program, I get the following error:
>
> Traceback (most recent call last):
>  File "C:\Python30\testclient.py", line 12, in 
>s.send('Hello world')   # send the data
> TypeError: send() argument 1 must be string or buffer, not str
>
> This happens in 2.6 or 3.0 and with different example client & server
> programs from the web.  What am I missing?

The text of the error message seems outdated (it should probably say
"bytes or bytearray" instead of "string or buffer"), but what it's
trying to say is that you can only send() bytes, not unicode strings.
For a byte literal, you need to add a 'b' prefix, e.g. b'Hello World'
Alternatively, you can encode the unicode into bytes using .encode(),
e.g. "Hello World".encode('utf8')

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


socket send help

2008-12-23 Thread greyw...@gmail.com
Hi everyone,

New guy here.  I'm trying to figure out sockets in order to one day do
a multiplayer game.  Here's my problem:  even the simplest examples
don't work on my computer:

A simple server:

from socket import *
myHost = ''
myPort = 21500

s = socket(AF_INET, SOCK_STREAM)# create a TCP socket
s.bind((myHost, myPort))# bind it to the server port
s.listen(5) # allow 5 simultaneous connections

while True:
connection, address = s.accept()
while True:
data = connection.recv(1024)
if data:
connection.send('echo -> ' + data)
else:
break
connection.close()  # close socket

And a simple client:

import sys
from socket import *
serverHost = 'localhost'# servername is localhost
serverPort = 21500  # use arbitrary port > 1024

s = socket(AF_INET, SOCK_STREAM)# create a TCP socket


s.connect((serverHost, serverPort)) # connect to server on the port
s.send('Hello world')   # send the data
data = s.recv(1024) # receive up to 1K bytes
print(data)


If I run testserver.py via the cmd prompt in Windows XP and then the
testclient.py program, I get the following error:

Traceback (most recent call last):
  File "C:\Python30\testclient.py", line 12, in 
s.send('Hello world')   # send the data
TypeError: send() argument 1 must be string or buffer, not str

This happens in 2.6 or 3.0 and with different example client & server
programs from the web.  What am I missing?

Thanks,

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


Re: Multi-dimension list

2008-12-23 Thread Carl Banks
On Dec 23, 10:29 pm, "Steven Woody"  wrote:
> Hi,
>
> In the book Python Essential Reference, Chapter 3, when talking about
> extended slicing, it gives an example:  a = m[0:10, 3:20].  But I
> don't understand how the 'm' was defined.  What should it looks like?

I suspect what the book is saying is that the Python language will
accept and multidimensional indexing and slicing (it's legal syntax),
even though there are no types built into Python that use
multidimensional slicing.

However, some third party libraries do provide types that allow
multidimensional indexing and slicing, most notably numpy.

So, for instance, if you were install numpy, you could get
multidimensional arrays and slice 'em up however you'd like:

import numpy
a = numpy.array([[1,2,3],[4,5,6],[7,8,9]])
print a[1:3,0:2]


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


www.iofferkicks.com china cheap wholesale nike shoes,air jordan shoes,air force one shoes.

2008-12-23 Thread www.iofferkicks.com
Get Nike Shoes at Super Cheap Prices
Discount Nike air jordans  (www.iofferkicks.com)
Discount Nike Air Max 90 Sneakers  (www.iofferkicks.com)
Discount Nike Air Max 91 Supplier  (www.iofferkicks.com)
Discount Nike Air Max 95 Shoes Supplier  (www.iofferkicks.com)
Discount Nike Air Max 97 Trainers  (www.iofferkicks.com)
Discount Nike Air Max 2003 Wholesale  (www.iofferkicks.com)
Discount Nike Air Max 2004 Shoes Wholesale
(www.iofferkicks.com)
Discount Nike Air Max 2005 Shop  (www.iofferkicks.com)
Discount Nike Air Max 2006 Shoes Shop  (www.iofferkicks.com)
Discount Nike Air Max 360 Catalogs  (www.iofferkicks.com)
Discount Nike Air Max Ltd Shoes Catalogs  (www.iofferkicks.com)
Discount Nike Air Max Tn Men's Shoes  (www.iofferkicks.com)
Discount Nike Air Max Tn 2 Women's Shoes  (www.iofferkicks.com)
Discount Nike Air Max Tn 3 Customize  (www.iofferkicks.com)
Discount Nike Air Max Tn 4 Shoes Customize
( www.iofferkicks.com)
Discount Nike Air Max Tn 6 Supply  (www.iofferkicks.com)
Discount Nike Shox NZ Shoes Supply  (www.iofferkicks.com)
Discount Nike Shox OZ Sale  (www.iofferkicks.com)
Discount Nike Shox TL Store  (www.iofferkicks.com)
Discount Nike Shox TL 2 Shoes Store (www.iofferkicks.com)
Discount Nike Shox TL 3 Distributor (www.iofferkicks.com)
Discount Nike Shox Bmw Shoes Distributor  (www.iofferkicks.com)
Discount Nike Shox Elite Shoes Manufacturer
(www.iofferkicks.com)
Discount Nike Shox Monster Manufacturer  (www.iofferkicks.com)
Discount Nike Shox R4 Running Shoes  (www.iofferkicks.com)
Discount Nike Shox R5 Mens Shoes  (www.iofferkicks.com)
Discount Nike Shox Ride Womens Shoes (www.iofferkicks.com)
Discount Nike Shox Rival Shoes Wholesaler  (www.iofferkicks.com)
Discount Nike Shox Energia Wholesaler  (www.iofferkicks.com)
Discount Nike Shox LV Sneaker  (www.iofferkicks.com)
Discount Nike Shox Turbo Suppliers  (www.iofferkicks.com)
Discount Nike Shox Classic Shoes Suppliers
(www.iofferkicks.com)
Discount Nike Shox Dendara Trainer  (www.iofferkicks.com)
Discount Nike Air Jordan 1 Seller  (www.iofferkicks.com)
Discount Nike Air Jordan 2 Shoes Seller  (www.iofferkicks.com)
Discount Nike Air Jordan 3 Collection  (www.iofferkicks.com)
Discount Nike Air Jordan 4 Shoes Collection
(www.iofferkicks.com)
Discount Nike Air Jordan 5 Chaussure Shoes
(www.iofferkicks.com)
Discount Nike Air Jordan 6 Catalog  (www.iofferkicks.com)
Discount Nike Air Jordan 7 Shoes Catalog  (www.iofferkicks.com)
Discount Nike Air Jordan 8 Customized  (www.iofferkicks.com)
Discount Nike Air Jordan 9 Shoes Customized
(www.iofferkicks.com)
Discount Nike Air Jordan 10 Wholesalers  (www.iofferkicks.com)
Discount Nike Jordan 11 Shoes Wholesalers (www.iofferkicks.com)
Discount Nike Air Jordan 12 Factory  (www.iofferkicks.com)
Discount Nike Air Jordan 13 Shoes Factory (www.iofferkicks.com)
Discount Nike Air Jordan 14 Shoes Sell  (www.iofferkicks.com)
Discount Nike Air Jordan 16 Exporter  (www.iofferkicks.com)
Discount Nike Air Jordan 17 Shoes Exporter
(www.iofferkicks.com)
Discount Nike Air Jordan 18 Offer  (www.iofferkicks.com)
Discount Nike Air Jordan 19 Shoes Offer  (www.iofferkicks.com)
Discount Nike Air Jordan 20 Manufacture  (www.iofferkicks.com)
Discount Nike Jordan 21 Shoes Manufacture  (www.iofferkicks.com)
EMAIL:iofferki...@gmail.com
MSN :iofferki...@msn.com
--
http://mail.python.org/mailman/listinfo/python-list


earn more then,15,989$/-

2008-12-23 Thread kela
THE REAL ONLINE JOB from,USA.
earn more then,15,989$/-
per month,if you want more detail,on
No investment.
http://onlinejob4ind.homestead.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimension list

2008-12-23 Thread Steven Woody
Hi,

In the book Python Essential Reference, Chapter 3, when talking about
extended slicing, it gives an example:  a = m[0:10, 3:20].  But I
don't understand how the 'm' was defined.  What should it looks like?

Thanks.

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


Multi-dimension list

2008-12-23 Thread Steven Woody
Hi,

In the book Python Essential Reference, Chapter 3, I see an example:
--
http://mail.python.org/mailman/listinfo/python-list


Re: turtle ?

2008-12-23 Thread sai
On Tue, Dec 23, 2008 at 2:29 AM, Gerhard Häring  wrote:
> sai wrote:
>> python newbie here  :-)
>>
>> I am trying to get turtle to run but got stuck here:
>>
>> $ python
>> Python 2.5.2 (r252:60911, Aug  5 2008, 16:17:28)
>> [GCC 4.2.2 20071128 (prerelease) (4.2.2-3.1mdv2008.0)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
> import turtle
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> ImportError: No module named turtle
>>
>> I have used google to search the web and the newsgroup but got
>> nothing. The Linux distro is Mandriva, if that makes a difference.
>
> Mandriva have probably split Python into several packages. If so,
> chances are one of them contains the tkinter GUI library. You should
> look in your package management tool for a package called
> python-tkinter, python-tk or similar and install it.
>
> HTH
>
> Gerhard
>

there is a Mandriva rpm called  tkinter-apps !

thanks Gerhard.

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


Re: On Whose Desktop

2008-12-23 Thread James Stroud

Steve Holden wrote:

Thanks to Barry Warsaw the "On Your Desktop" blog now has a new entry:


Note the thumb trackball. It's the shiznizzle. Give one two weeks of 
your patience and you'll seriously consider having it implanted in your 
thigh so you don't have to worry about missing it when you travel.

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


Re: using subprocess module in Python CGI

2008-12-23 Thread Matt Nordhoff
ANURAG BAGARIA wrote:
> Hello,
> 
> I am a Python Newbie and would like to call a short python script via
> browser using a CGI script, but initially I am trying to call the same
> python script directly through python command line. The script intends
> to perform a few command line in a pipe and I have written the script (a
> short one) as follows.
> 
> #!/usr/bin/python
> 
> import cgi, string, os, sys, cgitb, commands, subprocess
> import posixpath, macpath
> #file = "x.tar.gz"
> #comd = "tar -xf %s" % (file)
> #os.system(comd)
> #commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../')
> comd = [\
> "tar -xf x.tar.gz", \
> "cd demo", \
> "cp README ../", \
>   ]

That's not how subprocess.call() works. You're trying to run an
executable called "tar -xf x.tar.gz", passing it the arguments "cd demo"
and "cp README ../".

> outFile = os.path.join(os.curdir, "output.log")
> outptr = file(outFile, "w")
> errFile = os.path.join(os.curdir, "error.log")
> errptr = file(errFile, "w")
> retval = subprocess.call(comd, 0, None, None, outptr, errptr)
> errptr.close()
> outptr.close()
> if not retval == 0:
> errptr = file(errFile, "r")
> errData = errptr.read()
> errptr.close()
> raise Exception("Error executing command: " + repr(errData))
> 
> 
> but after trying to execute this independently, I get the following
> error which I am unable to interpret :
> 
> Traceback (most recent call last):
>   File "process.py", line 18, in 
> retval = subprocess.call(comd, 0, None, None, outptr, errptr)
>   File "/usr/lib/python2.5/subprocess.py", line 443, in call
> return Popen(*popenargs, **kwargs).wait()
>   File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
> errread, errwrite)
>   File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
> raise child_exception
> 
> 
> Could someone suggest where am I going wrong and if corrected, what is
> the probability of this script being compatible with being called
> through the browser. Thanking you people in advance.

Well, you'd need to output something, but otherwise, sure, why not?

print "Content-Type: text/html"
print
print "..."

> Regards.

Why do you even need to use subprocess to do this? All it's doing is
extracting the README file from a tarball, right? You can use the
tarfile module for that.


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


Re: SuSE11.1 eclipse 64 pydev can't add python path

2008-12-23 Thread Benjamin Kaplan
On Tue, Dec 23, 2008 at 5:08 PM, Nikolas Tautenhahn  wrote:

> Hi,
>
> Reimar Bauer wrote:
> > I can install pydev using the update manager in eclipse for 64 bit from
> the
> > SuSE 11.1 repo. But I can't configure pydev without crashing it.
> > I can select the interpreter /usr/bin/python
> > and I do see the System PYTHONPATH
> > Forced builtin libs also looks good.
> >
> > But Apply gives me
> > #
> > # An unexpected error has been detected by Java Runtime Environment:
> > #
> > # SIGSEGV (0xb) at pc=0x7f2d7abebaed, pid=6544, tid=139832007596368
> > #
> > # Java VM: IcedTea 64-Bit Server VM (1.7.0-b24 mixed mode linux-amd64)
> > # Problematic frame:
> > # V [libjvm.so+0x21baed]
> > #
> > # An error report file with more information is saved as:
> > # /home/user/hs_err_pid6544.log
> > #
> > # If you would like to submit a bug report, please visit:
> > # http://icedtea.classpath.org/bugzilla
> > # The crash happened outside the Java Virtual Machine in native code.
> > # See problematic frame for where to report the bug.
>
> unfortunately I can't help but reproduce the problem. My eclipse was
> already configured when I updated openSuSE 11.0 to 11.1 so it is not
> *that* bad for me (only when I install new eggs and want pydev to take
> notice of them).
>
> The question is who is responsible for this... java? pydev? (suse?)


If it was a PyDev problem, you'd see either a Python or a Java error
message. This is a known bug in the HotSpot VM on Linux 64. It affects both
the Sun and OpenJDK versions of Java. It was fixed in the newer builds.

>
>
> If you open a ticket in a bugtracker, please post the url here and I
> will add myself, too
>
> Best regards,
> Nikolas Tautenhahn
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: no sign() function ?

2008-12-23 Thread ajaksu
On Dec 23, 2:45 pm, Mark Dickinson  wrote:
> On Dec 23, 4:27 pm, ajaksu  wrote:
>
> > Is "x ** 0 > 0." instead of "atan2(x, -1.) > 0." unreliable across
> > platforms?
>
> x**0 doesn't distinguish between x = -0.0 and x = 0.0.
>
> I suspect you're confusing -0.0**0.0 with (-0.0)**0.0.

Yes, fooled me :)

Thanks for the heads-up!

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


Re: 2to3 used in the Shootout

2008-12-23 Thread Isaac Gouy
On Dec 23, 11:51 am, bearophileh...@lycos.com wrote:
> They have translated the Python benchmarks of the Shootout site from
> Py2 to Py3 using 2to3:
>
> http://shootout.alioth.debian.org/u32/benchmark.php?test=all〈=pyt...


So please re-write those programs to remove problems created by
automatic translation and better take advantage of Python 3
functionality...


http://shootout.alioth.debian.org/u32/faq.php#play



> It shows some "performance bugs" of Python3 itself (especially
> regarding the binary-trees benchmark, that was unexpected by me), and
> two points where 2to3 may be improved, for example after the
> translation this gives error:
>          table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
>                                 'TGVHCDM
> \nKNSYAAWBRTGVHCDMKNSYAAWBR')):
>
> Gives:
> TypeError: maketrans arguments must be bytes objects
>
> Bye,
> bearophile

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


Re: SuSE11.1 eclipse 64 pydev can't add python path

2008-12-23 Thread Nikolas Tautenhahn
Hi,

Reimar Bauer wrote:
> I can install pydev using the update manager in eclipse for 64 bit from the
> SuSE 11.1 repo. But I can't configure pydev without crashing it.
> I can select the interpreter /usr/bin/python
> and I do see the System PYTHONPATH
> Forced builtin libs also looks good.
> 
> But Apply gives me
> #
> # An unexpected error has been detected by Java Runtime Environment:
> #
> # SIGSEGV (0xb) at pc=0x7f2d7abebaed, pid=6544, tid=139832007596368
> #
> # Java VM: IcedTea 64-Bit Server VM (1.7.0-b24 mixed mode linux-amd64)
> # Problematic frame:
> # V [libjvm.so+0x21baed]
> #
> # An error report file with more information is saved as:
> # /home/user/hs_err_pid6544.log
> #
> # If you would like to submit a bug report, please visit:
> # http://icedtea.classpath.org/bugzilla
> # The crash happened outside the Java Virtual Machine in native code.
> # See problematic frame for where to report the bug.

unfortunately I can't help but reproduce the problem. My eclipse was
already configured when I updated openSuSE 11.0 to 11.1 so it is not
*that* bad for me (only when I install new eggs and want pydev to take
notice of them).

The question is who is responsible for this... java? pydev? (suse?)

If you open a ticket in a bugtracker, please post the url here and I
will add myself, too

Best regards,
Nikolas Tautenhahn
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2to3 used in the Shootout

2008-12-23 Thread Terry Reedy

bearophileh...@lycos.com wrote:

They have translated the Python benchmarks of the Shootout site from
Py2 to Py3 using 2to3:

http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=python3

It shows some "performance bugs" of Python3 itself (especially
regarding the binary-trees benchmark, that was unexpected by me), and
two points where 2to3 may be improved, for example after the
translation this gives error:
 table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
'TGVHCDM
\nKNSYAAWBRTGVHCDMKNSYAAWBR')):

Gives:
TypeError: maketrans arguments must be bytes objects


Perhaps you could file a tracker item.

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


Re: [ANN] Python 2.5.4 (final)

2008-12-23 Thread Terry Reedy

Martin v. Löwis wrote:


For more information on Python 2.5.4, including download
links for various platforms, release notes, and known issues, please
see:

http://www.python.org/2.5.4


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

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


Re: python3 urlopen(...).read() returns bytes

2008-12-23 Thread ajaksu
On Dec 23, 12:51 pm, Christian Heimes  wrote:
> If you want to do it right ... It should be a clean patch against the
> py3k svn branch including documentation and a unit test.

Got all three at http://bugs.python.org/issue4733 . Probably got all
three wrong too, so any feedback is very welcome :)

I think a neat improvement, besides better docs, names, code, etc.,
would be to implement Carl Bank's idea of checking Content-Encoding.

Oh, and there's a 'print("Using default charset '%s'" %
response.charset)' in there that seemed educational when I wrote it,
but now sounds lame :)

Glenn, can you test the patch[1] there?

Thanks for the encouragement, Chris! I hope we don't regret it :D

Daniel

[1]http://bugs.python.org/file12437/urlopen_text.diff
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-23 Thread Rhodri James
On Tue, 23 Dec 2008 15:39:52 -, Aaron Stepp   
wrote:



import random
from rtcmix import *
from chimes_source import * # Chime.play()
from rhythmblock import * # rhythmBlock.rhythmTwist() and  
rhythmBlock.printStuff()
from pitchblock import * # pitchBlock.pitchTwist() and  
pitchBlock.printStuff()

from lenEval import *  #greaterThan.sovler()

indexrand = random.Random()
indexrand.seed(2)

chime = Chime()
notes = pitchBlock()
rhythm = rhythmBlock()
solve = greaterThan()

class arrayBlock:

def __init__(self, theTempo, start):
self.__A = []
self.__B = []
self.__start = start
self.__tempo = theTempo

def player(self, length, tempo, octave, pan, seed):

tempo = (120, self.__tempo)

for a in range(length):

one = indexrand.randint(0, 3)

two = indexrand.randint(0, 7)

self.__A = self.__A + notes.pitchTwist(one , two)

for b in range(length):

one = indexrand.randint(0, 3)

two = indexrand.randint(0, 7)

self.__B = self.__B + rhythm.rhythmTwist(one , two)

lenA = len(self.__A)
lenB = len(self.__B)

var = solve.solver(lenA, lenB)


for c in range(var):

print self.__A[c]

self.__start = self.__start + tb(self.__B[var])

chime.play(self.__start, self.__A[var], octave, pan, 
seed)

This almost does exactly what I want, and is far cleaner than my  
previous attempts.


The only problem is that now all my arguments are being passed as zeros!


Which "all" your arguments?  There are an awful lot there; what *exactly*  
do

you mean?


I assume this has to do with WHEN I'm referencing self.__A and self.__B?


If you mean __A and __B are full of zeroes, then you should suspect your
notes.pitchTwist() and rhythm.rhythmTwist() methods of returning zeroes.

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Haskell-cafe] Initializing GHC from Python

2008-12-23 Thread Jason Dusek
  I upmodded this on Reddit. Thank you for your work.

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


Re: Beep

2008-12-23 Thread Ivan Illarionov
On Dec 22, 3:16 am, Jeffrey Barish  wrote:
> I use sys.stdout.write('\a') to beep.  It works fine on Kubuntu, but not on
> two other platforms (one of which is Ubuntu).  I presume that the problem
> is due to a system configuration issue.  Can someone point me in the right
> direction?  Thanks.
> --
> Jeffrey Barish

gnome-terminal (default terminal on Ubuntu) uses X11 bell for its
beep.
Try 'xset b on' to turn the beep on. See 'man xset' for more options.

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


Re: Get applications to open a given file (Mac and, or Windows)

2008-12-23 Thread Tommy Nordgren


On Dec 23, 2008, at 5:29 PM, riklau...@gmail.com wrote:


Under Linux/Unix I use GIO (pygobject) or gnome-vfs-python to get a
list of installed applications that can open given file (for example
image in graphics software). Is there something that can be used for
MS Windows or Mac OS X?
--
http://mail.python.org/mailman/listinfo/python-list

On mac, there are the modules Carbon.Launch and Carbon.LaunchServices
Maybe you'll find useful items in the PyObjC framework as well
-
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
tommy.nordg...@comhem.se




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


Re: pseudo terminal usage from Python?

2008-12-23 Thread Grant Edwards
On 2008-12-23, s...@pobox.com  wrote:
> Grant> Are you sure it's not Python buffering its input?  Have you tried
> Grant> "python -u mympstat.py"?
>
> >> Nope.  -u unbuffers stdout and stderr, not stdin.  It really must be
> >> mpstat being uncooperative.
>
> Grant> That's not what my python man page says:
>
> Grant>-u Force stdin, stdout and stderr to be totally
> Grant>   unbuffered.  On systems where it matters, also put
> Grant>   stdin, stdout and stderr in binary mode.
>
> Grant> That's for 2.5.2, but that's how I remember previous versions
> Grant> working as well.
>
> I'm still running 2.4.5 at work.  It's -u help:
>
> -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
>  see man page for details on internal buffering relating to '-u'
>
> Was stdin unbuffering maybe added in 2.5?

Let's do some experiments...

  $ cat echo.py
  import sys

  while 1:
  line = sys.stdin.readline()
  sys.stdout.write(line)

  $ (while sleep 1; do date; done) | python2.4 echo.py

[I see a line printed once per second.]

  $ (while sleep 1; do date; done) | python2.5 echo.py

[same as 2.4]

Is python stdin is line-buffered by default?  We'll do a
version that doesn't have newlines in the input stream...

  $ cat echo2.py
  import sys

  while 1:
  sys.stdout.write(sys.stdin.read(1))


  $ (while sleep 1; do echo -n $(date); done) | python2.4 echo2.py

[wait 10-20 seconds -- no output.  When I hit ctrl-C, I see a
all the output.]

  $ (while sleep 1; do echo -n $(date); done) | python2.5 echo2.py

[same as 2.4]

It appears the by default both 2.4 and 2.5 have line-buffered
stdin.

Let's try -u...

  $ (while sleep 1; do echo -n $(date); done) | python2.4 -u echo2.py

[I see output once per second.]

  $ (while sleep 1; do echo -n $(date); done) | python2.5 -u echo2.py

[same as 2.4]

Under Linux, the '-u' option unbuffers stdin in both 2.4 and
2.5.  It just isn't mentioned in the help output or the man
page for 2.4.

-- 
Grant Edwards   grante Yow! Will the third world
  at   war keep "Bosom Buddies"
   visi.comoff the air?
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL - font kerning

2008-12-23 Thread Ivan Illarionov
On Dec 23, 11:22 pm, Ivan Illarionov 
wrote:
> On 23 дек, 16:44, carsn  wrote:
>
> > Hey all,
>
> > anybody know, if there´s a way to specify the kerning of a font, when
> > you draw text with PIL?
>
> > I´d like to achieve the same effect that you get, when you set a
> > negative kerning in Gimp/Photshop - ie. reduce the spacing between
> > glyphs.
>
> > Can PIL do that or do I use another lib for that?
>
> > Thx for any pointers & some nice xmas days to U all!
> > carsten
>
> No. PIL can't do that. I suggest combination of cairo/pango/pangocairo
> (pycairo and pygtk packages).
>
> Ivan

I found a little helper function that does what you want (and more)

import cairo
import pango
import pangocairo

def draw_text(surface, context, text, font="sans 14", position=None,
color=None,
box_width=None,
alignment=pango.ALIGN_CENTER,
line_spacing=None, letter_spacing=None,
extra_kerning=None):
if color is None:
color = (0.0, 0.0, 0.0)
context.set_source_rgb(*color)
pc = pangocairo.CairoContext(context)
layout = pc.create_layout()
layout.set_text(text)
layout.set_font_description(pango.FontDescription(font))
if box_width: layout.set_width(box_width)
layout.set_alignment(alignment)
if line_spacing: layout.set_spacing(spacing)
alist = pango.AttrList()
if letter_spacing:
alist.insert(pango.AttrLetterSpacing(letter_spacing, 0, len
(text)))
if extra_kerning:
for pos, kern in extra_kerning.iteritems():
alist.insert(pango.AttrLetterSpacing(kern, pos, pos
+1))
layout.set_attributes(alist)
if position is None:
width, height = surface.get_width(), surface.get_height()
w, h = layout.get_pixel_size()
position = (width/2.0 - w/2.0, height/2.0 - h/2.0)
context.move_to(*position)
pc.show_layout(layout)

And example usage:

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
context = cairo.Context(surface)
draw_text(surface, context, 'Hello world!',
font="sans 52", color=(.25,.28,.33),
letter_spacing=-6000,
extra_kerning={0:-9000, 1:-1000, 6:6000, 7:-15000, 8:5000,
9:-7000})

surface.write_to_png("hello.png")

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


Re: Are python objects thread-safe?

2008-12-23 Thread Aaron Brady
On Dec 23, 7:30 am, Duncan Booth  wrote:
> Aaron Brady  wrote:
> > Th.1   Th.2
> > a=X
> >        a=Y
> > a=Z
>
> > You are saying that if 'a=Z' interrupts 'a=Y' at the wrong time, the
> > destructor for 'X' or 'Y' might not get called.  Correct?  In serial
> > flow, the destructor for X is called, then Y.
>
> No, the destructors will be called, but the destructors can do pretty much
> anything they want so you can't say the assignment is atomic. This isn't
> actually a threading issue: you don't need multiple threads to experience
> werid issues here. If you do strange things in a destructor then you can
> come up with confusing code even with a single thread.

I see.  What about

del a
a= Z

Then, can we say 'a=Z' is atomic?  At least, it eliminates the
destructor issue you raise.

> >> Other nasty things can happen if you use dictionaries from multiple
> >> threads. You cannot add or remove a dictionary key while iterating over
> >> a dictionary. This isn't normally a big issue, but as soon as you try to
> >> share the dictionary between threads you'll have to be careful never to
> >> iterate through it.
>
> > These aren't documented, IIRC.  Did you just discover them by trial
> > and error?
>
> It is documented, but I can't remember where for Python 2.x. For Python 3,
> PEP 3106 says: "As in Python 2.x, mutating a dict while iterating over it
> using an iterator has an undefined effect and will in most cases raise a
> RuntimeError exception. (This is similar to the guarantees made by the Java
> Collections Framework.)"

I infer that d.items() holds the GIL during the entire operation, and
it's safe to put in a thread.  It is merely using an iterator that is
unsafe.  (Python 3.0 removed d.items(), leaving only the iterator, I
understand.)

I'm looking at the code, and I don't see where the size is safely
checked.  That is, can't I sneak in an add and a remove during
iteration, so long as it doesn't catch me?

I'm looking at 'dict_traverse':
while (PyDict_Next(op, &i, &pk, &pv)) {
Py_VISIT(pk);
Py_VISIT(pv);
}

No locks are acquired here, though I might have missed acquiring the
GIL somewhere else.

In the OP's example, he wasn't changing the size of the dict.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL - font kerning

2008-12-23 Thread Ivan Illarionov
On 23 дек, 16:44, carsn  wrote:
> Hey all,
>
> anybody know, if there´s a way to specify the kerning of a font, when
> you draw text with PIL?
>
> I´d like to achieve the same effect that you get, when you set a
> negative kerning in Gimp/Photshop - ie. reduce the spacing between
> glyphs.
>
> Can PIL do that or do I use another lib for that?
>
> Thx for any pointers & some nice xmas days to U all!
> carsten

No. PIL can't do that. I suggest combination of cairo/pango/pangocairo
(pycairo and pygtk packages).

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


[ANN] Python 2.5.4 (final)

2008-12-23 Thread Martin v. Löwis
On behalf of the Python development team and the Python community, I'm
happy to announce the release of Python 2.5.4 (final).

Python 2.5.3 unfortunately contained an incorrect patch that could
cause interpreter crashes; the only change in Python 2.5.4 relative
to 2.5.4 is the reversal of this patch.

2.5.4 is the last bug fix release of Python 2.5. Future 2.5.x releases
will only include security fixes. According to the release notes, about
80 bugs and patches have been addressed since Python 2.5.2, many of
them improving the stability of the interpreter, and improving its
portability.

See the release notes at the website (also available as Misc/NEWS in
the source distribution) for details of bugs fixed; most of them prevent
interpreter crashes (and now cause proper Python exceptions in cases
where the interpreter may have crashed before).

For more information on Python 2.5.4, including download
links for various platforms, release notes, and known issues, please
see:

http://www.python.org/2.5.4

Highlights of the previous major Python releases are available
from the Python 2.5 page, at

http://www.python.org/2.5/highlights.html

Enjoy this release,
Martin

Martin v. Loewis
mar...@v.loewis.de
Python Release Manager
(on behalf of the entire python-dev team)
--
http://mail.python.org/mailman/listinfo/python-list


Re: pseudo terminal usage from Python?

2008-12-23 Thread skip
Grant> Are you sure it's not Python buffering its input?  Have you tried
Grant> "python -u mympstat.py"?

>> Nope.  -u unbuffers stdout and stderr, not stdin.  It really must be
>> mpstat being uncooperative.

Grant> That's not what my python man page says:

Grant>-u Force stdin, stdout and stderr to be totally
Grant>   unbuffered.  On systems where it matters, also put
Grant>   stdin, stdout and stderr in binary mode.

Grant> That's for 2.5.2, but that's how I remember previous versions
Grant> working as well.

I'm still running 2.4.5 at work.  It's -u help:

-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
 see man page for details on internal buffering relating to '-u'

Was stdin unbuffering maybe added in 2.5?

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


2to3 used in the Shootout

2008-12-23 Thread bearophileHUGS
They have translated the Python benchmarks of the Shootout site from
Py2 to Py3 using 2to3:

http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=python3

It shows some "performance bugs" of Python3 itself (especially
regarding the binary-trees benchmark, that was unexpected by me), and
two points where 2to3 may be improved, for example after the
translation this gives error:
 table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
'TGVHCDM
\nKNSYAAWBRTGVHCDMKNSYAAWBR')):

Gives:
TypeError: maketrans arguments must be bytes objects

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: pseudo terminal usage from Python?

2008-12-23 Thread Grant Edwards
On 2008-12-23, s...@pobox.com  wrote:
>
> Grant> Are you sure it's not Python buffering its input?  Have you tried
> Grant> "python -u mympstat.py"?
>
> Nope.  -u unbuffers stdout and stderr, not stdin.  It really must be mpstat
> being uncooperative.

That's not what my python man page says:

   -u Force stdin, stdout and stderr to be totally
  unbuffered.  On systems where it matters, also
  put stdin, stdout and stderr in binary mode.

That's for 2.5.2, but that's how I remember previous versions
working as well.
  
-- 
Grant Edwards   grante Yow! We have DIFFERENT
  at   amounts of HAIR --
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Symposium “Visualization and Human-Computer” wit hin the IRF’2009 Conference – Announce & Call for Papers

2008-12-23 Thread tava...@fe.up.pt


(Apologies for cross-posting)

Symposium on “Visualization and Human-Computer”
3rd International Conference on Integrity, Reliability & Failure
(IRF’2009)
Faculty of Engineering, University of Porto, Porto – PORTUGAL, 20-24
July 2009
http://paginas.fe.up.pt/clme/IRF2009/index.htm

(We would appreciate if you could distribute this information by your
colleagues and co-workers.)



Dear Colleague,

Within the 3rd International Conference on Integrity, Reliability &
Failure (IRF’2009), to be held in FEUP, Porto, Portugal, in July
20-24, 2009, we are organizing the Symposium “Visualization and Human-
Computer”.
Examples of some topics that will be considered are: Scientific Data
Visualization, Spatial Data in Visualization, Data Processing and
Analysis, Information Visualization, Visualization Techniques, Large
Data Visualization, Image Processing and Analysis, Hardware for
Visualization, Human-Computer Interaction, Visual Analytics, Visual
Data Mining and Knowledge Discovery, Human Perception, Interface
Design, Evaluation and User Studies, Software Development, Grid and
High Performance Computing, Applications in Engineering, Biomechanics,
Bioinformatics, Bioimaging, Physical, Earth, Space, Environmental and
Information Sciences.
Due to your research activities in those fields, we would like to
invite you to submit your work and participate in the Symposium
“Visualization and Human-Computer”.

For instructions and submission, please access to the conference
website at:
http://paginas.fe.up.pt/clme/IRF2009/index.htm
Please note that, when submitting your work you should select the
Symposium #7 “Visualization and Human-Computer”.

Important dates:

- February 28, 2009: Deadline for abstract submission;
- March 21, 2009: Notification of abstract acceptance;
- May 10, 2009: Receipt of Full Papers;
- July 20-24, 2009: Conference Events.

Kind regards,

João Manuel R. S. Tavares (University of Porto, Portugal,
tava...@fe.up.pt)
Renato Natal Jorge (University of Porto, Portugal, rna...@fe.up.pt)
(Symposium organizers)
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-23 Thread ajaksu
On Dec 23, 12:51 pm, Christian Heimes  wrote:

> If you want to do it right ... It should be a clean patch against the
> py3k svn branch
Done

> including documentation
This thread is a good start :)

> and a unit test.
Doing this now.

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


Re: Are python objects thread-safe?

2008-12-23 Thread Gabriel Genellina
En Tue, 23 Dec 2008 11:30:25 -0200, Duncan Booth  
 escribió:



Aaron Brady  wrote:


Th.1   Th.2
a=X
   a=Y
a=Z

You are saying that if 'a=Z' interrupts 'a=Y' at the wrong time, the
destructor for 'X' or 'Y' might not get called.  Correct?  In serial
flow, the destructor for X is called, then Y.


No, the destructors will be called, but the destructors can do pretty  
much

anything they want so you can't say the assignment is atomic. This isn't
actually a threading issue: you don't need multiple threads to experience
werid issues here. If you do strange things in a destructor then you can
come up with confusing code even with a single thread.


A simple example showing what you said:

py> class A:
...   def __del__(self):
... global a
... a = None
...
py> a = A()
py> a = 3
py> print a
None

--
Gabriel Genellina

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


Re: pseudo terminal usage from Python?

2008-12-23 Thread skip

Grant> Are you sure it's not Python buffering its input?  Have you tried
Grant> "python -u mympstat.py"?

Nope.  -u unbuffers stdout and stderr, not stdin.  It really must be mpstat
being uncooperative.

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


Re: pseudo terminal usage from Python?

2008-12-23 Thread Grant Edwards
On 2008-12-23, s...@pobox.com  wrote:
> Grant> Are you sure it's not Python buffering its input?  Have you tried
> Grant> "python -u mympstat.py"?
>
> Hmmm...  No, I hadn't considered that.  I'll check it out.  Thanks...
>
> Grant> I had a Linux pty example running once upon a time.  If "python
> Grant> -u" doesn't work post again, and I'll try to find it.
>
> Would be helpful even if I don't need it for this task, as I've not been
> able to find any simple examples on the net.  (Maybe there's a recipe at
> ActiveState, but Google didn't pick up anything with the search terms I was
> using.)

I'll try to dig it up.  The application for which I was trying
to use ptys needed to communication modem control/status line
state info between master and slave (as well as parity and
word-length settings), so I abandoned ptys when I found they
only implement a small subset of the icotl's that are defined
for tty devices.

I've proposed enhancing the Linux pty driver so that it can
actually be used to simulate a serial port, but the proposal
has been ignored so far.

-- 
Grant Edwards   grante Yow! I'm definitely not
  at   in Omaha!
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


[Offtopic] Re: I always wonder ...

2008-12-23 Thread Pierre-Alain Dorange
r  wrote:

> [...]
> Well that shows that even lads with tiny nads can be brave, any of the
> other trolls want to expose them selfs?

This thread is offtopic, please just keep silent and let it be closed...

-- 
Pierre-Alain Dorange

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

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


Re: Python's popularity

2008-12-23 Thread Pierre-Alain Dorange
r  wrote:

> > I've already stated, and you've already proven, that it's pretty trivial
> > to ascertain my true identity, if one actually cares.  OTOH, that's
> > *not* the case with you.  Who is hiding now?
> 
> I told you, my name is Thurstan Howell III. Do you want to know my
> favorite color too?

Only if it's pythonic.

-- 
Pierre-Alain Dorange

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

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


Re: wxPython.button.disabled still catching clicks

2008-12-23 Thread Mike Driscoll
On Dec 23, 7:27 am, mynthon  wrote:
> On Dec 23, 11:58 am, Aaron Brady  wrote:
>
>
>
> > On Dec 23, 4:50 am, mynthon  wrote:
>
> > > Hello! (sorry for my english)
>
> > > I have a problem with buttons in wxPython. When button is disabled
> > > (by .Disable() or .Enable(False)) it is grayed out but still receive
> > > clicks.
>
> > > Eg. i have button that disable itself, runs long action and enable
> > > itself:
>
> > > def onClick(self, evt):
> > >     self.btn.Enable(False)
> > >     for i in range (1000):
> > >         print i
> > >     self.btn.Enable(True)
>
> > > when for loop is running button is greyed out and when i click on it
> > > nothing happens but when loop ends another one is started because
> > > button "remebered" thad i click on it when was diabled. My only idea
> > > is to reposition button outside frame instead of disabling it but this
> > > solution is...not good.
>
> > > thanks for any help. Ive searched groups, google and it looks that
> > > only i have this problem :)
>
> > No, it is very common.  During your for loop, the loop is dominating
> > the process completely.  Events are just building up in the app's
> > message queue, and don't get handled until after you yield on control.
>
> > If you need to run a long task, look into threading, the OnIdle
> > method, the 'multiprocessing' module, or pump messages during your
> > long task.
>
> ok, maybe someone will need it. I dont know how it works because i
> didnt have time to read docs and i cannot explain everything. I used
> google and wxPython demo (in tree: wxpython overview / process and
> events / process)
>
> class leftPanel(wx.Panel):
>     def __init__(self, parent, id):
>         wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)
>
>         # here you have to define new process, IDLE event, and
> onPRocessEnd event
>         self.process = None
>         self.GetParent().Bind(wx.EVT_IDLE, self.onIdle)
>         self.Bind(wx.EVT_END_PROCESS, self.onProcessEnd)
>
>         # create button and bind event to it
>         self.runScriptBtn = wx.Button(self, -1, 'RUN ME!', (10,220))
>         self.runScriptBtn.Bind(wx.EVT_BUTTON, self.onClick,
> self.runScriptBtn)
>
>     def onClick(self, evt):
>         # disable button
>         self.runScriptBtn.Enable(False)
>
>         # here you have to enter command to run
>         # previusly i heve here exec('python myScript.py')
>         # but now it will be a subprocess
>         cmd = 'python xxx1.py'
>
>         #create new process
>         self.process = wx.Process(self)
>
>         # dont know what it is for
>         self.process.Redirect()
>
>         # execute cmd command
>         pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)
>
>     def onIdle(self, evt):
>         # beacuse this method is called only when app enters idle mode
>         # the line below is nedded to "simulate" entering idle mode
>         # dont know how it works but it works
>         evt.RequestMore(True)
>
>         # here is some code to catch subprocess output
>         if self.process is not None:
>             stream = self.process.GetInputStream()
>             if stream.CanRead():
>                 text = stream.read()
>                 print text
>
>     def onProcessEnd(self, evt):
>         # here is some code to catch subprocess output
>         # when it is destroyed
>         stream = self.process.GetInputStream()
>         if stream.CanRead():
>             text = stream.read()
>             print text
>
>         # dont know it is necessary
>         self.process.CloseOutput()
>
>         # remove (clear) process object
>         self.process.Destroy()
>         self.process = None
>
>         # show button again
>         self.runScriptBtn.Enable()

I'm pretty sure there's a better way to do this. If you disable the
button and click on it, you'll notice that it isn't firing events, so
something else is going on here. It seems like the wx.Frame or
wx.Application is queuing the mouse button clicks or something. I
would post to the wxPython mailing list: http://wxpython.org/maillist.php

They'll be better able to address this and they'll probably have a
simpler solution too.

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


Re: String Format Error.

2008-12-23 Thread Paulo Repreza
Thank You!

On Tue, Dec 23, 2008 at 3:49 AM, Steve Holden  wrote:

>  Chris Rebert wrote:
> > On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza 
> wrote:
> >> Hi,
> >>
> >> I'm a newbie with python and I recently bought Beginning with Python
> (Which
> >> is a book I recommend) but the problem that I'm facing it's the
> following:
> >>
> >> This is the code:
> >>
> >> #!/usr/bin/python2.5
> >> # Filename: str_format.py
> >>
> >> age = 25
> >> name = 'foobar'
> >>
> >> print('{0} is {1} years old'.format(name, age))
> >> print('Why is {0} playing with that python?'.format(name))
> >>
> >>
> >> But when I run the script I receive this error:
> >>
> >> Traceback (most recent call last):
> >>   File "str_format.py", line 7, in 
> >> print('{0} is {1} years old'.format(name, age))
> >> AttributeError: 'str' object has no attribute 'format'
> >>
> >>
> >> It is an error because of the version that I'm using ? Python 2.5.2
> (Debian
> >> lenny)
> >
> > Yes, Python 2.6 or higher is required to use .format() according to
> > http://docs.python.org/whatsnew/2.6.html
> >
> For a replacement that will work in 2.5, see the "%" sign as an operator
> (sometimes called "string interpolation").
>
> regards
>  Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: On Whose Desktop

2008-12-23 Thread Arnaud Delobelle
Aaron Brady  writes:
> +1 whose (posessive)

-1 posessive :)

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


Re: On Whose Desktop

2008-12-23 Thread Aaron Brady
On Dec 23, 8:19 am, Steve Holden  wrote:
> Fuzzyman wrote:
> > On Dec 23, 12:06 pm, Steve Holden  wrote:
> >> Thanks to Barry Warsaw the "On Your Desktop" blog now has a new entry:
>
> >>  http://onyourdesktop.blogspot.com/
>
> >> Who would you like to see profiled next?
>
> > Guido (of course), Brett Cannon, Martin v Loewis, Jim Hugunin, Ted
> > Leung, Dino Viehland (core developer of IronPython), Titus Brown, Ivan
> > Kristic, Mark Shuttleworth, Tim Golden, Michele Simionato, Thomas
> > Heller, Greg Ewing - any and all of these would be great.
>
> > Any women in Python you could ask - how about Anna Ravenscroft?
> > Bruno Desthuilliers wrote:
>
> > The effbot ?
>
> s...@pobox.com wrote:
> > Maybe Martin v. Loewis?  He contributes so much to Python.  I met him once
> > several years ago at a Python conference (or maybe it was still just a
> > workshop then), but beyond seeing his titanic contributions to Python, I
> > know little about the guy.
>
> I hope *everyone* knows that Martin was the winner of this year's Frank
> Willison Award:
>
> http://www.python.org/community/awards/frank-willison/#martin-von-l-w...
>
> Great! Keep the suggestions coming, please!

+1 whose (posessive)
--
http://mail.python.org/mailman/listinfo/python-list


Re: no sign() function ?

2008-12-23 Thread Mark Dickinson
On Dec 23, 4:27 pm, ajaksu  wrote:
> Is "x ** 0 > 0." instead of "atan2(x, -1.) > 0." unreliable across
> platforms?

x**0 doesn't distinguish between x = -0.0 and x = 0.0.

I suspect you're confusing -0.0**0.0 with (-0.0)**0.0.

Mark

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


Re: Python's popularity

2008-12-23 Thread r
Benjamin Kaplin wrote:
You're the one who keeps bringing up the need to spread python. For
most people, this is a forum to ask questions and have experts respond
to them. Most people who post here aren't looking for your opinion,
they want answers. If you know the answer to a question, answer it. If
not, read the answers of people who have seen it before. When you post
your opinions, you're just creating more noise.

School time son,
This forum is much more than a question answer session, son. Sure
people are welcome to ask a Python related question. But this forum is
really the main highway of Python development and future. If your a
n00b go to the "Python forum.org", you will feel more comfy over
there.

If you have no opinion(Benjamin) thats your perogitive, don't tell me
how to live my life, or what "I" should do when i visit this forum. Do
I go to any of "your" threads and start a ruckus? NO, because if i do
not like what you are saying I will just ignore it. Take an example
son!

Sure i may have went off in thread, by i have kept my thought true to
the thread subject. A troll go's from thread to thread posting off
subject insults and attacks on other posters... hmmm, i have seen some
of those kind in this thread?? Know of who i speak, Bennie?
--
http://mail.python.org/mailman/listinfo/python-list


Get applications to open a given file (Mac and, or Windows)

2008-12-23 Thread riklau...@gmail.com
Under Linux/Unix I use GIO (pygobject) or gnome-vfs-python to get a
list of installed applications that can open given file (for example
image in graphics software). Is there something that can be used for
MS Windows or Mac OS X?
--
http://mail.python.org/mailman/listinfo/python-list


Re: no sign() function ?

2008-12-23 Thread ajaksu
On Dec 22, 9:18 am, Christian Heimes  wrote:
> Sure? :) Are you aware that the IEEE 754 standard makes a difference
> between the floats +0.0 and -0.0?
>
> from math import atan2
> def sign(x):
>     if x > 0 or (x == 0 and atan2(x, -1.) > 0.):
>         return 1
>     else:
>         return -1

Is "x ** 0 > 0." instead of "atan2(x, -1.) > 0." unreliable across
platforms?


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


Re: no sign() function ?

2008-12-23 Thread Mark Dickinson
On Dec 23, 2:59 pm, Christian Heimes  wrote:
> All algorithm including my own suffer from one mistake. Nobody accounts
> for NaN (not a number). You have to check for NaNs, too. NaNs have no
> sign at all.

I think that's not quite true:  NaNs have a sign;  it's just not
accorded any particular meaning by IEEE 754---in particular,
the standard says nothing about the sign of a NaN result
for most arithmetic operations. However, the sign bit of
a NaN does play its usual role in operations like
copysign, abs, negation.  For example, here's a Python
2.6 session on OS X, where the 'default' nan is negative,
in the sense that its sign bit is set:

>>> nan = float('nan')
>>> from math import copysign
>>> copysign(5.0, nan)
-5.0
>>> copysign(5.0, -nan)
5.0
>>> copysign(5.0, abs(nan))
5.0

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


Re: Python's popularity

2008-12-23 Thread r
On Dec 23, 8:21 am, Thorsten Kampe  wrote:
> You don't have a single clue about neither Python nor Ruby:
> 'According to the Ruby FAQ, "If you like Perl, you will like Ruby and be
> right at home with its syntax. [...] If you like Python, you may or may
> not be put off by the huge difference in design philosophy between
> Python and Ruby/Perl."'[1]

So you read the preface to the tut and that somehow makes you more
than a R00b n00b? Come on!

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


Re: Python's popularity

2008-12-23 Thread r
On Dec 23, 10:12 am, je.s.t...@hehxduhmp.org wrote:
> r  wrote:
> > You are the epitimy of an internet troll. A troll tries to hide his
> > identity. Why are you so concerned about your TRUE identity. Are the
>
> I've already stated, and you've already proven, that it's pretty trivial
> to ascertain my true identity, if one actually cares.  OTOH, that's
> *not* the case with you.  Who is hiding now?

I told you, my name is Thurstan Howell III. Do you want to know my
favorite color too?
--
http://mail.python.org/mailman/listinfo/python-list


Re: pseudo terminal usage from Python?

2008-12-23 Thread skip
Grant> Are you sure it's not Python buffering its input?  Have you tried
Grant> "python -u mympstat.py"?

Hmmm...  No, I hadn't considered that.  I'll check it out.  Thanks...

Grant> I had a Linux pty example running once upon a time.  If "python
Grant> -u" doesn't work post again, and I'll try to find it.

Would be helpful even if I don't need it for this task, as I've not been
able to find any simple examples on the net.  (Maybe there's a recipe at
ActiveState, but Google didn't pick up anything with the search terms I was
using.)

Skip

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


Re: iterating initalizations

2008-12-23 Thread Steve Holden
D'Arcy J.M. Cain wrote:
> On Tue, 23 Dec 2008 10:20:59 -0500
> Steve Holden  wrote:
>> D'Arcy J.M. Cain wrote:
>>> Well, if all you want is a loop:
>>>
>>> for v in vars:
>>> locals()[v] = []
>>>
>> Note that this isn't guaranteed to work. While locals() will return a
>> dict containing the names and values from the local namespace, you won't
>> affect the local namespace by assigning values to the appropriate keys:
>>
> def f():
>> ...   a = "hello"
>> ...   locals()["a"] = "goodbye"
>> ...   print a
> 
> This was my test:
> 
 locals()['x'] = "hello"
 x
> 'hello'
 locals()['x'] = "goodbye"
 x
> 'goodbye'
> 
> Just didn't want people to think that I post without testing.
> 
> In any case, even if that worked as expected I am pretty sure that it
> is the wrong solution but without knowing more about what the OP is
> doing it is impossible to know what the right answer is.
> 
The thing you overlooked was that the locals of a function are special.
The locals of a module are the globals!

>>> def lisg():
...   return locals() is globals()
...
>>> locals() is globals()
True
>>> lisg()
False
>>>

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

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


Re: Python's popularity

2008-12-23 Thread r
On Dec 23, 8:21 am, Thorsten Kampe  wrote:
> * r (Mon, 22 Dec 2008 10:44:32 -0800 (PST))>
>
> > Steve Holden
> > > What makes you assume this is a zero-sum game, and that Python won't
> > > survive if any other language becomes popular. Every language borrows
> > > from those that came before it. Terms like "outright plagiarism" don't
> > > encourage rational debate, and make you seem like a troll who is more
> > > interested in stirring up controversy than actually doing things to help
> > > promote the language.
>
> > This is a war Steve, and i will explain why. Python does not need to
> > compete with perl, lisp, C, basic, etc, etc. WHY, well because python
> > is SO radically different than those languages. Ruby on the other
> > hand, took most from python, the only difference is Ruby's full OO
> > integration.(12.method()). Since Ruby is so similar to python [...]
>
> You don't have a single clue about neither Python nor Ruby:
> 'According to the Ruby FAQ, "If you like Perl, you will like Ruby and be
> right at home with its syntax. [...] If you like Python, you may or may
> not be put off by the huge difference in design philosophy between
> Python and Ruby/Perl."'[1]
>
> Thorsten
> [1]http://en.wikipedia.org/wiki/Ruby_(programming_language)#Semantics

Thats "Thurstan", thank you very much! :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: pseudo terminal usage from Python?

2008-12-23 Thread Grant Edwards
On 2008-12-23, s...@pobox.com  wrote:
>
> I ran into an interesting problem yesterday.  The mpstat(1) command on
> Solaris formats its output like so:
>
>   CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
> 0   42   1 1184   812  265  227   12   44   370  11316   2   0  93
> 1   25   1  933   4472  203   37   75   120   9025   4   0  91
> 2   17   0  195   4951  201   41   77   130   5145   1   0  94
> 34   0  117   882  405  171   34   65   210   4495   2   0  93
>
> I'm only interested in presenting the CPU numbers and user+sys values
> prefixed by a timestamp.  For example, the above might be formatted like so:
>
> 07:28:46.373328 0 8 1 9 2 6 3 7
>
> The obvious solution might be something simple like this:
>
> mpstat 1 | python mympstat.py
>
> where mympstat.py does a trival amount of reformatting.
>
> The problem is that mpstat recognizes when its output is a pipe and block
> buffers it so the Python script sees input in massive blobs, not the
> second-by-second output you'd see running "mpstat 1" by itself.

Are you sure it's not Python buffering its input?  Have you
tried "python -u mympstat.py"?

> I suspect there is some magic I can perform with pseudo terminals (this is
> on Solaris 10.)  The documentation for the pty module contains no examples
> and I've been so far unable to find any using Google.

I had a Linux pty example running once upon a time.  If "python -u"
doesn't work post again, and I'll try to find it.

-- 
Grant Edwards   grante Yow! Please come home with
  at   me ... I have Tylenol!!
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: I always wonder ...

2008-12-23 Thread r
On Dec 22, 11:12 pm, ajaksu  wrote:
> On Dec 22, 9:24 pm, r  wrote:
>
> > You know what i hate more than a troll, a spineless jellyfish who goes
> > around rating peoples post with one star. You are the lowest form of
> > life. You are the same type of person who would key someones car in
> > the parking lot. You do not have the balls to face you enemy.
>
> > If who made a rating were visible, then i would have respect for you,
> > but since you lurk in the shadows, you are scum. Come out and face me
> > if you dare!
>
> > I never have rated a post UNLESS i rate it with 5 stars, WHY, you ask,
> > Because my balls are so big i walk around bow-legged! F'in  Cowards!
>
> That would be me, for at least a dozen of your posts. Glad to know it
> was more effective than telling you to shut up or calm down.
>
> Cnidaria-ly y'rs,
> Daniel

Well that shows that even lads with tiny nads can be brave, any of the
other trolls want to expose them selfs?
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-23 Thread D'Arcy J.M. Cain
On Tue, 23 Dec 2008 10:20:59 -0500
Steve Holden  wrote:
> D'Arcy J.M. Cain wrote:
> > Well, if all you want is a loop:
> > 
> > for v in vars:
> > locals()[v] = []
> > 
> Note that this isn't guaranteed to work. While locals() will return a
> dict containing the names and values from the local namespace, you won't
> affect the local namespace by assigning values to the appropriate keys:
> 
> >>> def f():
> ...   a = "hello"
> ...   locals()["a"] = "goodbye"
> ...   print a

This was my test:

>>> locals()['x'] = "hello"
>>> x
'hello'
>>> locals()['x'] = "goodbye"
>>> x
'goodbye'

Just didn't want people to think that I post without testing.

In any case, even if that worked as expected I am pretty sure that it
is the wrong solution but without knowing more about what the OP is
doing it is impossible to know what the right answer is.

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


Re: Python's popularity

2008-12-23 Thread Adrian Cherry
r  wrote in
news:ae1bb365-7755-4c5f-8166-e704c51a7...@i20g2000prf.googlegro
ups.com: 

> 
> Oh Steve... Listen, my words are ment as a wake-up-call to
> all who still love Python, and i believe you are one of
> them. Maybe old age has slowed your hand, that's OK, Us
> "youngsters" will take the helm. And be serious, do you
> really think this group is read by "hundreds-of- thousands
> of news readers? I wish it were, but I highly doubt it. 
> 

Thus spake the artilleryman from Horsell Common!

Adrian Cherry

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


Re: iterating initalizations

2008-12-23 Thread Aaron Stepp

import random
from rtcmix import *
from chimes_source import * # Chime.play()
from rhythmblock import * # rhythmBlock.rhythmTwist() and  
rhythmBlock.printStuff()
from pitchblock import * # pitchBlock.pitchTwist() and  
pitchBlock.printStuff()

from lenEval import *  #greaterThan.sovler()

indexrand = random.Random()
indexrand.seed(2)

chime = Chime()
notes = pitchBlock()
rhythm = rhythmBlock()
solve = greaterThan()

class arrayBlock:

def __init__(self, theTempo, start):
self.__A = []
self.__B = []
self.__start = start
self.__tempo = theTempo

def player(self, length, tempo, octave, pan, seed):

tempo = (120, self.__tempo)

for a in range(length):

one = indexrand.randint(0, 3)

two = indexrand.randint(0, 7)

self.__A = self.__A + notes.pitchTwist(one , two)

for b in range(length):

one = indexrand.randint(0, 3)

two = indexrand.randint(0, 7)

self.__B = self.__B + rhythm.rhythmTwist(one , two)

lenA = len(self.__A)
lenB = len(self.__B)

var = solve.solver(lenA, lenB)


for c in range(var):

print self.__A[c]

self.__start = self.__start + tb(self.__B[var])

chime.play(self.__start, self.__A[var], octave, pan, 
seed)

This almost does exactly what I want, and is far cleaner than my  
previous attempts.


The only problem is that now all my arguments are being passed as zeros!

I assume this has to do with WHEN I'm referencing self.__A and self.__B?

AS


On Dec 23, 2008, at 10:20 AM, Steve Holden wrote:


D'Arcy J.M. Cain wrote:

On Mon, 22 Dec 2008 22:32:17 -0500
Aaron Stepp  wrote:

Instead of writing a long list of initializations like so:

A = [ ]
B = [ ]
...
Y = [ ]
Z = [ ]

I'd like to save space by more elegantly turning this into a  
loop.  If


Well, if all you want is a loop:

   for v in vars:
   locals()[v] = []


Note that this isn't guaranteed to work. While locals() will return a
dict containing the names and values from the local namespace, you  
won't
affect the local namespace by assigning values to the appropriate  
keys:



def f():

...   a = "hello"
...   locals()["a"] = "goodbye"
...   print a
...

f()

hello




If you look at the function's code you will see that the local "a" is
accessed using the LOAD_FAST and STORE_FAST opcodes, which take
advantage of the knowledge that the name is local - the interpreter
analyzed the function body looking for assignments to non-globals, and
optimizes its treatment of such names.


dis.dis(f)

 2   0 LOAD_CONST   1 ('hello')
 3 STORE_FAST   0 (a)

 3   6 LOAD_CONST   2 ('goodbye')
 9 LOAD_GLOBAL  0 (locals)
12 CALL_FUNCTION0
15 LOAD_CONST   3 ('a')
18 STORE_SUBSCR

 4  19 LOAD_FAST0 (a)
22 PRINT_ITEM
23 PRINT_NEWLINE
24 LOAD_CONST   0 (None)
27 RETURN_VALUE





It's hard to tell if that's what you actually need though without
deeper analysis of your requirements.


I think it's unlikely that the OP really does need to create names
dynamically, and should look at using either a dict indexed by the
letters of self.__abet, or a list indexed from 0 to 24 instead. But  
you

*are* correct about the need for a little more information ;-)

regards
Steve


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

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



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


Re: pseudo terminal usage from Python?

2008-12-23 Thread skip
Steve> Look at the pexpect module - you can run interactive tasks
Steve> through that.

Thanks.  Worked like a charm.

-- 
Skip Montanaro - s...@pobox.com - http://smontanaro.dyndns.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-23 Thread Steve Holden
D'Arcy J.M. Cain wrote:
> On Mon, 22 Dec 2008 22:32:17 -0500
> Aaron Stepp  wrote:
>> Instead of writing a long list of initializations like so:
>>
>> A = [ ]
>> B = [ ]
>> ...
>> Y = [ ]
>> Z = [ ]
>>
>> I'd like to save space by more elegantly turning this into a loop.  If  
> 
> Well, if all you want is a loop:
> 
> for v in vars:
> locals()[v] = []
> 
Note that this isn't guaranteed to work. While locals() will return a
dict containing the names and values from the local namespace, you won't
affect the local namespace by assigning values to the appropriate keys:

>>> def f():
...   a = "hello"
...   locals()["a"] = "goodbye"
...   print a
...
>>> f()
hello
>>>

If you look at the function's code you will see that the local "a" is
accessed using the LOAD_FAST and STORE_FAST opcodes, which take
advantage of the knowledge that the name is local - the interpreter
analyzed the function body looking for assignments to non-globals, and
optimizes its treatment of such names.

>>> dis.dis(f)
  2   0 LOAD_CONST   1 ('hello')
  3 STORE_FAST   0 (a)

  3   6 LOAD_CONST   2 ('goodbye')
  9 LOAD_GLOBAL  0 (locals)
 12 CALL_FUNCTION0
 15 LOAD_CONST   3 ('a')
 18 STORE_SUBSCR

  4  19 LOAD_FAST0 (a)
 22 PRINT_ITEM
 23 PRINT_NEWLINE
 24 LOAD_CONST   0 (None)
 27 RETURN_VALUE
>>>

> It's hard to tell if that's what you actually need though without
> deeper analysis of your requirements.
> 
I think it's unlikely that the OP really does need to create names
dynamically, and should look at using either a dict indexed by the
letters of self.__abet, or a list indexed from 0 to 24 instead. But you
*are* correct about the need for a little more information ;-)

regards
 Steve


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

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


Re: print to console without a line break

2008-12-23 Thread Qian Xu
Lie Ryan wrote:
 
> If you don't mind an extra space, you can use this:
> 
> print 'Testing something ...',
> # note the trailing comma

Thanks. However, the contents will be saved in buffer and will not be shown
until print "(last piece)"

sys.stdout.flush() can solve this problem :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: print to console without a line break

2008-12-23 Thread Qian Xu
Albert Hopkins wrote:

> On Tue, 2008-12-23 at 13:18 +, Lie Ryan wrote:
> 
> Probably because your stdout is line-buffered. Try:
> 
> sys.stdout.write("Testing something...")
> sys.stout.flush() # flush the stdout buffer

Thanks. This works for me ^^)
--
http://mail.python.org/mailman/listinfo/python-list


Re: no sign() function ?

2008-12-23 Thread Christian Heimes
All algorithm including my own suffer from one mistake. Nobody accounts
for NaN (not a number). You have to check for NaNs, too. NaNs have no
sign at all.

You could also try to do some fancy bit mask operation like

>>> ord(struct.pack("d", 0.)[7]) & 0x80
0
>>> ord(struct.pack("d", -0.)[7]) & 0x80
128

But you have to take care of little endian, big endian and mixd endian
IEEE 754 platforms, too. There are also platforms that don't have IEEE
754 floats at all ... Have fun :)

Christian

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


Re: python3 urlopen(...).read() returns bytes

2008-12-23 Thread Christian Heimes
ajaksu wrote:
> On Dec 22, 9:05 pm, Christian Heimes  wrote:
>> ajaksu schrieb:
>>
>>> That said, a "decode to declared HTTP header encoding" version of
>>> urlopen could be useful to give some users the output they want (text
>>> from network io) or to make it clear why bytes is the safe way.
>> Yeah, your idea sounds both useful and feasible. A patch is welcome! :)
> 
> Would monkeypatching what urlopen returns be good enough or should we
> aim at a cleaner implementation?

If you want to do it right ... It should be a clean patch against the
py3k svn branch including documentation and a unit test. Don't worry!
It's not as hard as it sounds. Besides Python core development is fun. :)

Christian

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


Re: print to console without a line break

2008-12-23 Thread Albert Hopkins
On Tue, 2008-12-23 at 13:18 +, Lie Ryan wrote:
> On Tue, 23 Dec 2008 11:50:59 +0100, Qian Xu wrote:
> 
> > Hello All,
> > 
> > Is it possible to print something to console without a line break?
> > 
> > I tried:
> >   sys.stdout.write("Testing something ...") // nothing will be printed
> >   time.sleep(1)
> >   sys.stdout.write("done\n") // now, the whole string will be printed
> > 

Probably because your stdout is line-buffered. Try:

sys.stdout.write("Testing something...")
sys.stout.flush() # flush the stdout buffer





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


Re: pseudo terminal usage from Python?

2008-12-23 Thread Steve Holden
s...@pobox.com wrote:
> I ran into an interesting problem yesterday.  The mpstat(1) command on
> Solaris formats its output like so:
> 
>   CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
> 0   42   1 1184   812  265  227   12   44   370  11316   2   0  93
> 1   25   1  933   4472  203   37   75   120   9025   4   0  91
> 2   17   0  195   4951  201   41   77   130   5145   1   0  94
> 34   0  117   882  405  171   34   65   210   4495   2   0  93
> 
> I'm only interested in presenting the CPU numbers and user+sys values
> prefixed by a timestamp.  For example, the above might be formatted like so:
> 
> 07:28:46.373328 0 8 1 9 2 6 3 7
> 
> The obvious solution might be something simple like this:
> 
> mpstat 1 | python mympstat.py
> 
> where mympstat.py does a trival amount of reformatting.
> 
> The problem is that mpstat recognizes when its output is a pipe and block
> buffers it so the Python script sees input in massive blobs, not the
> second-by-second output you'd see running "mpstat 1" by itself.  I've been
> reduced to a much more complicated solution which involves forking mpstat
> with output to a file, then reading the end of that file every second.  A
> three-line Python script balloons into a one-page script.  Yuck.  Add to
> that I'm writing this for an admin who is considering Python as a scripting
> language.   Double Yuck.  (But not nyuk nyuk, this is not the Stooges.)
> 
> I suspect there is some magic I can perform with pseudo terminals (this is
> on Solaris 10.)  The documentation for the pty module contains no examples
> and I've been so far unable to find any using Google.
> 
> Any pointers/examples?  I will gladly add an example to the pty module docs
> (I have the power!) once I have a couple working examples (maybe one example
> each of reading and writing?)
> 
Look at the pexpect module - you can run interactive tasks through that.

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

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


Re: Python's popularity

2008-12-23 Thread Benjamin Kaplan
On Tue, Dec 23, 2008 at 12:05 AM, r  wrote:

> On Dec 22, 10:09 pm, Ben Kaplan  wrote:
> > That's just because most of us don't say anything unless we have
> > something useful to say. We prefer to let the experts answer the
> > questions, but we read the threads so we can benefit from them.
>
> OK Ben, So you are saying
>
> 1.) do not question the gods!
> 2.) speak only when spoken to!
> 3.) do not have an opinion!
>
> Somehow this reminds me of some old and brainwashing religions, Not an
> OSS project. Just observations Ben.



You're the one who keeps bringing up the need to spread python. For most
people, this is a forum to ask questions and have experts respond to them.
Most people who post here aren't looking for your opinion, they want
answers. If you know the answer to a question, answer it. If not, read the
answers of people who have seen it before. When you post your opinions,
you're just creating more noise.

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


Re: iterating initalizations

2008-12-23 Thread D'Arcy J.M. Cain
On Mon, 22 Dec 2008 22:32:17 -0500
Aaron Stepp  wrote:
> Instead of writing a long list of initializations like so:
> 
> A = [ ]
> B = [ ]
> ...
> Y = [ ]
> Z = [ ]
> 
> I'd like to save space by more elegantly turning this into a loop.  If  

Well, if all you want is a loop:

for v in vars:
locals()[v] = []

It's hard to tell if that's what you actually need though without
deeper analysis of your requirements.

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


Re: Python's popularity

2008-12-23 Thread Thorsten Kampe
* r (Mon, 22 Dec 2008 10:44:32 -0800 (PST))> 
> Steve Holden
> > What makes you assume this is a zero-sum game, and that Python won't
> > survive if any other language becomes popular. Every language borrows
> > from those that came before it. Terms like "outright plagiarism" don't
> > encourage rational debate, and make you seem like a troll who is more
> > interested in stirring up controversy than actually doing things to help
> > promote the language.
> 
> This is a war Steve, and i will explain why. Python does not need to
> compete with perl, lisp, C, basic, etc, etc. WHY, well because python
> is SO radically different than those languages. Ruby on the other
> hand, took most from python, the only difference is Ruby's full OO
> integration.(12.method()). Since Ruby is so similar to python [...]

You don't have a single clue about neither Python nor Ruby:
'According to the Ruby FAQ, "If you like Perl, you will like Ruby and be 
right at home with its syntax. [...] If you like Python, you may or may 
not be put off by the huge difference in design philosophy between 
Python and Ruby/Perl."'[1]

Thorsten
[1] http://en.wikipedia.org/wiki/Ruby_(programming_language)#Semantics
--
http://mail.python.org/mailman/listinfo/python-list


Re: On Whose Desktop

2008-12-23 Thread Steve Holden
Fuzzyman wrote:
> On Dec 23, 12:06 pm, Steve Holden  wrote:
>> Thanks to Barry Warsaw the "On Your Desktop" blog now has a new entry:
>>
>>  http://onyourdesktop.blogspot.com/
>>
>> Who would you like to see profiled next?
>
> Guido (of course), Brett Cannon, Martin v Loewis, Jim Hugunin, Ted
> Leung, Dino Viehland (core developer of IronPython), Titus Brown, Ivan
> Kristic, Mark Shuttleworth, Tim Golden, Michele Simionato, Thomas
> Heller, Greg Ewing - any and all of these would be great.
>
> Any women in Python you could ask - how about Anna Ravenscroft?
> Bruno Desthuilliers wrote:
> 
> The effbot ?
> 
s...@pobox.com wrote:
> Maybe Martin v. Loewis?  He contributes so much to Python.  I met him once
> several years ago at a Python conference (or maybe it was still just a
> workshop then), but beyond seeing his titanic contributions to Python, I
> know little about the guy.

I hope *everyone* knows that Martin was the winner of this year's Frank
Willison Award:

http://www.python.org/community/awards/frank-willison/#martin-von-l-wis-2008

Great! Keep the suggestions coming, please!

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

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


Re: Python's popularity

2008-12-23 Thread Lie Ryan
On Mon, 22 Dec 2008 21:05:22 -0800, r wrote:

> On Dec 22, 10:09 pm, Ben Kaplan  wrote:
>> That's just because most of us don't say anything unless we have
>> something useful to say. We prefer to let the experts answer the
>> questions, but we read the threads so we can benefit from them.
> 
> OK Ben, So you are saying
> 
> 1.) do not question the gods!

Hmmm... when we talk about something we don't know, only trash would come 
out of our mouth.

> 2.) speak only when spoken to!

He (Ben) does not say anything remotely like that. 

> 3.) do not have an opinion!

Again, you're adding sauce, meat, beef, and spices to his statement.

> Somehow this reminds me of some old and brainwashing religions, Not an
> OSS project. Just observations Ben.

Isn't it you that have been accused of religionizing python by many 
people in this list?

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


PIL - font kerning

2008-12-23 Thread carsn
Hey all,

anybody know, if there´s a way to specify the kerning of a font, when
you draw text with PIL?

I´d like to achieve the same effect that you get, when you set a
negative kerning in Gimp/Photshop - ie. reduce the spacing between
glyphs.

Can PIL do that or do I use another lib for that?

Thx for any pointers & some nice xmas days to U all!
carsten
--
http://mail.python.org/mailman/listinfo/python-list


Re: SuSE11.1 eclipse 64 pydev can't add python path

2008-12-23 Thread Benjamin Kaplan
On Tue, Dec 23, 2008 at 7:49 AM, Reimar Bauer  wrote:

> Hi
>
> I can install pydev using the update manager in eclipse for 64 bit from the
> SuSE 11.1 repo. But I can't configure pydev without crashing it.
> I can select the interpreter /usr/bin/python
> and I do see the System PYTHONPATH
> Forced builtin libs also looks good.
>
> But Apply gives me
> #
> # An unexpected error has been detected by Java Runtime Environment:
> #
> # SIGSEGV (0xb) at pc=0x7f2d7abebaed, pid=6544, tid=139832007596368
> #
> # Java VM: IcedTea 64-Bit Server VM (1.7.0-b24 mixed mode linux-amd64)
> # Problematic frame:
> # V [libjvm.so+0x21baed]
> #
> # An error report file with more information is saved as:
> # /home/user/hs_err_pid6544.log
> #
> # If you would like to submit a bug report, please visit:
> # http://icedtea.classpath.org/bugzilla
> # The crash happened outside the Java Virtual Machine in native code.
> # See problematic frame for where to report the bug.
>
>
> That problem happens also with the recent
> eclipse-cpp-ganymede-SR1-linux-gtk-x86_64.tar.gz
>
> What can be the cause for this problem? Do you know a workaround e.g.
> manually configuring pydev?
>
> Does one have pydev or eclipse working on SuSE11.1?
>
>
> cheers
> Reimar
>

This isn't a problem with PyDev. This is a known bug in the 64-bit Java,
both Sun and OpenJDK. It was fixed in the really recent updates (Sun 6u10
and OpenJDK 6b12, I think), which I guess SuSE doesn't have yet.

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


pseudo terminal usage from Python?

2008-12-23 Thread skip

I ran into an interesting problem yesterday.  The mpstat(1) command on
Solaris formats its output like so:

  CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
0   42   1 1184   812  265  227   12   44   370  11316   2   0  93
1   25   1  933   4472  203   37   75   120   9025   4   0  91
2   17   0  195   4951  201   41   77   130   5145   1   0  94
34   0  117   882  405  171   34   65   210   4495   2   0  93

I'm only interested in presenting the CPU numbers and user+sys values
prefixed by a timestamp.  For example, the above might be formatted like so:

07:28:46.373328 0 8 1 9 2 6 3 7

The obvious solution might be something simple like this:

mpstat 1 | python mympstat.py

where mympstat.py does a trival amount of reformatting.

The problem is that mpstat recognizes when its output is a pipe and block
buffers it so the Python script sees input in massive blobs, not the
second-by-second output you'd see running "mpstat 1" by itself.  I've been
reduced to a much more complicated solution which involves forking mpstat
with output to a file, then reading the end of that file every second.  A
three-line Python script balloons into a one-page script.  Yuck.  Add to
that I'm writing this for an admin who is considering Python as a scripting
language.   Double Yuck.  (But not nyuk nyuk, this is not the Stooges.)

I suspect there is some magic I can perform with pseudo terminals (this is
on Solaris 10.)  The documentation for the pty module contains no examples
and I've been so far unable to find any using Google.

Any pointers/examples?  I will gladly add an example to the pty module docs
(I have the power!) once I have a couple working examples (maybe one example
each of reading and writing?)

Thanks,

-- 
Skip Montanaro - s...@pobox.com - http://smontanaro.dyndns.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: no sign() function ?

2008-12-23 Thread Pierre-Alain Dorange
Steven D'Aprano  wrote:

> But this is just duplicating what timeit already does. Trust me, learn to
> use it, you won't be sorry. Here's a trick that took me a long time to
> learn: instead of copying your functions into the setup code of timeit,
> you can just import them.

Thanks for the advise, i made the test using timeit and your very
interesting method to import... Now i know how to use timeit simply ;-)

New results on 1000 float values randomized from -500.0 to +500.0.
Each test is timeit(1000)

sign_0 : 0.375
sign_1 : 0.444 (+18%)
sign_2 : 0.661 (+76%)
sign_3 : 0.498 (+33%)

It seems it don't change the relative results between the methods.
Using timeit make measure accurate and remove print/range footprints.

I also try Arnaud's proposition, it make sign_0 just a little better
(-1%)

-- 
Pierre-Alain Dorange

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

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


Re: Are python objects thread-safe?

2008-12-23 Thread Duncan Booth
Aaron Brady  wrote:

> Th.1   Th.2
> a=X
>a=Y
> a=Z
> 
> You are saying that if 'a=Z' interrupts 'a=Y' at the wrong time, the
> destructor for 'X' or 'Y' might not get called.  Correct?  In serial
> flow, the destructor for X is called, then Y.

No, the destructors will be called, but the destructors can do pretty much 
anything they want so you can't say the assignment is atomic. This isn't 
actually a threading issue: you don't need multiple threads to experience 
werid issues here. If you do strange things in a destructor then you can 
come up with confusing code even with a single thread.

> 
>> Other nasty things can happen if you use dictionaries from multiple
>> threads. You cannot add or remove a dictionary key while iterating over
>> a dictionary. This isn't normally a big issue, but as soon as you try to
>> share the dictionary between threads you'll have to be careful never to
>> iterate through it.
> 
> These aren't documented, IIRC.  Did you just discover them by trial
> and error?
> 
It is documented, but I can't remember where for Python 2.x. For Python 3, 
PEP 3106 says: "As in Python 2.x, mutating a dict while iterating over it 
using an iterator has an undefined effect and will in most cases raise a 
RuntimeError exception. (This is similar to the guarantees made by the Java 
Collections Framework.)"


-- 
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython.button.disabled still catching clicks

2008-12-23 Thread mynthon
On Dec 23, 11:58 am, Aaron Brady  wrote:
> On Dec 23, 4:50 am, mynthon  wrote:
>
>
>
> > Hello! (sorry for my english)
>
> > I have a problem with buttons in wxPython. When button is disabled
> > (by .Disable() or .Enable(False)) it is grayed out but still receive
> > clicks.
>
> > Eg. i have button that disable itself, runs long action and enable
> > itself:
>
> > def onClick(self, evt):
> >     self.btn.Enable(False)
> >     for i in range (1000):
> >         print i
> >     self.btn.Enable(True)
>
> > when for loop is running button is greyed out and when i click on it
> > nothing happens but when loop ends another one is started because
> > button "remebered" thad i click on it when was diabled. My only idea
> > is to reposition button outside frame instead of disabling it but this
> > solution is...not good.
>
> > thanks for any help. Ive searched groups, google and it looks that
> > only i have this problem :)
>
> No, it is very common.  During your for loop, the loop is dominating
> the process completely.  Events are just building up in the app's
> message queue, and don't get handled until after you yield on control.
>
> If you need to run a long task, look into threading, the OnIdle
> method, the 'multiprocessing' module, or pump messages during your
> long task.


ok, maybe someone will need it. I dont know how it works because i
didnt have time to read docs and i cannot explain everything. I used
google and wxPython demo (in tree: wxpython overview / process and
events / process)


class leftPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)

# here you have to define new process, IDLE event, and
onPRocessEnd event
self.process = None
self.GetParent().Bind(wx.EVT_IDLE, self.onIdle)
self.Bind(wx.EVT_END_PROCESS, self.onProcessEnd)

# create button and bind event to it
self.runScriptBtn = wx.Button(self, -1, 'RUN ME!', (10,220))
self.runScriptBtn.Bind(wx.EVT_BUTTON, self.onClick,
self.runScriptBtn)


def onClick(self, evt):
# disable button
self.runScriptBtn.Enable(False)

# here you have to enter command to run
# previusly i heve here exec('python myScript.py')
# but now it will be a subprocess
cmd = 'python xxx1.py'

#create new process
self.process = wx.Process(self)

# dont know what it is for
self.process.Redirect()

# execute cmd command
pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)


def onIdle(self, evt):
# beacuse this method is called only when app enters idle mode
# the line below is nedded to "simulate" entering idle mode
# dont know how it works but it works
evt.RequestMore(True)

# here is some code to catch subprocess output
if self.process is not None:
stream = self.process.GetInputStream()
if stream.CanRead():
text = stream.read()
print text


def onProcessEnd(self, evt):
# here is some code to catch subprocess output
# when it is destroyed
stream = self.process.GetInputStream()
if stream.CanRead():
text = stream.read()
print text

# dont know it is necessary
self.process.CloseOutput()

# remove (clear) process object
self.process.Destroy()
self.process = None

# show button again
self.runScriptBtn.Enable()
--
http://mail.python.org/mailman/listinfo/python-list


Re: print to console without a line break

2008-12-23 Thread Lie Ryan
On Tue, 23 Dec 2008 11:50:59 +0100, Qian Xu wrote:

> Hello All,
> 
> Is it possible to print something to console without a line break?
> 
> I tried:
>   sys.stdout.write("Testing something ...") // nothing will be printed
>   time.sleep(1)
>   sys.stdout.write("done\n") // now, the whole string will be printed
> 
> What I want, is to see "Testing something ..." first. And after 1
> second, to see "done" (with a line break)
> 
> The only one solution I have found is to call "echo -n 'my_string'". But
> it is not nice. Because I have to escape all special chars in the string
> manually.
> 
> Any advice?
> Best regards
> -- Qian Xu

If you don't mind an extra space, you can use this:

print 'Testing something ...', 
# note the trailing comma

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


SuSE11.1 eclipse 64 pydev can't add python path

2008-12-23 Thread Reimar Bauer
Hi

I can install pydev using the update manager in eclipse for 64 bit from the
SuSE 11.1 repo. But I can't configure pydev without crashing it.
I can select the interpreter /usr/bin/python
and I do see the System PYTHONPATH
Forced builtin libs also looks good.

But Apply gives me
#
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x7f2d7abebaed, pid=6544, tid=139832007596368
#
# Java VM: IcedTea 64-Bit Server VM (1.7.0-b24 mixed mode linux-amd64)
# Problematic frame:
# V [libjvm.so+0x21baed]
#
# An error report file with more information is saved as:
# /home/user/hs_err_pid6544.log
#
# If you would like to submit a bug report, please visit:
# http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.


That problem happens also with the recent
eclipse-cpp-ganymede-SR1-linux-gtk-x86_64.tar.gz

What can be the cause for this problem? Do you know a workaround e.g.
manually configuring pydev?

Does one have pydev or eclipse working on SuSE11.1?


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


Re: Why MyHDL?

2008-12-23 Thread Stef Mientki

hello Jan,

Jan Decaluwe wrote:

Hello:

MyHDL is a Python package for using Python as a
Hardware Description Language.

A new release is upcoming, and on this occasion
we have prepared a page about why MyHDL may
be useful to you:

http://www.myhdl.org/doku.php/why


Very Interesting,
I'm no expert at all (but as an exercise I'm just now writing an EDIF-v2 
to SystemC converter in Python) ,

I wonder why I only see comparison with VHDL and SystemVerilog,
and not with SystemC ?

thanks,
Stef

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


Re: On Whose Desktop

2008-12-23 Thread Bruno Desthuilliers

Steve Holden a écrit :

Thanks to Barry Warsaw the "On Your Desktop" blog now has a new entry:

  http://onyourdesktop.blogspot.com/

Who would you like to see profiled next?


The effbot ?


regards
 Steve

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


Re: On Whose Desktop

2008-12-23 Thread Fuzzyman
On Dec 23, 12:06 pm, Steve Holden  wrote:
> Thanks to Barry Warsaw the "On Your Desktop" blog now has a new entry:
>
>  http://onyourdesktop.blogspot.com/
>
> Who would you like to see profiled next?
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/

Guido (of course), Brett Cannon, Martin v Loewis, Jim Hugunin, Ted
Leung, Dino Viehland (core developer of IronPython), Titus Brown, Ivan
Kristic, Mark Shuttleworth, Tim Golden, Michele Simionato, Thomas
Heller, Greg Ewing - any and all of these would be great.

Any women in Python you could ask - how about Anna Ravenscroft?

Conspicuously missing from the ones you have already done is Steve
Holden of course...

All the best,

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


On Whose Desktop

2008-12-23 Thread Steve Holden
Thanks to Barry Warsaw the "On Your Desktop" blog now has a new entry:

  http://onyourdesktop.blogspot.com/

Who would you like to see profiled next?

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

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


Re: Very basic question

2008-12-23 Thread Sengly
Thank you very much everyone.

Regards,

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


Why MyHDL?

2008-12-23 Thread Jan Decaluwe

Hello:

MyHDL is a Python package for using Python as a
Hardware Description Language.

A new release is upcoming, and on this occasion
we have prepared a page about why MyHDL may
be useful to you:

http://www.myhdl.org/doku.php/why

Regards,

Jan

--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Python as a hardware description language:
http://www.myhdl.org

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


Re: String Format Error.

2008-12-23 Thread Steve Holden
Chris Rebert wrote:
> On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza  wrote:
>> Hi,
>>
>> I'm a newbie with python and I recently bought Beginning with Python (Which
>> is a book I recommend) but the problem that I'm facing it's the following:
>>
>> This is the code:
>>
>> #!/usr/bin/python2.5
>> # Filename: str_format.py
>>
>> age = 25
>> name = 'foobar'
>>
>> print('{0} is {1} years old'.format(name, age))
>> print('Why is {0} playing with that python?'.format(name))
>>
>>
>> But when I run the script I receive this error:
>>
>> Traceback (most recent call last):
>>   File "str_format.py", line 7, in 
>> print('{0} is {1} years old'.format(name, age))
>> AttributeError: 'str' object has no attribute 'format'
>>
>>
>> It is an error because of the version that I'm using ? Python 2.5.2 (Debian
>> lenny)
> 
> Yes, Python 2.6 or higher is required to use .format() according to
> http://docs.python.org/whatsnew/2.6.html
> 
For a replacement that will work in 2.5, see the "%" sign as an operator
(sometimes called "string interpolation").

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

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


Re: Very basic question

2008-12-23 Thread Bryan Olson

Sengly wrote:

I can hack it by doing eval('1.0*12/5') but is there any better method?


Where did you get the string? If you generated it, you might as well 
make one or both the operands float to begin with. If you got it as 
input, calling eval() on it is a world of security hurt.


The right way would be to parse the expression, so you can evaluate it 
as you wish.


Security defects aside, just prepending '1.0 *' doesn't work in general, 
because the string could be something like '5 + 12 / 5'. If you replace 
each '/' that isn't immediately followed by another '/' with '* 1.0 /', 
that might work... or maybe someone fill find counter-examples.


Python 3 does what you want. The / operator is float division. The // 
operator is still integer division.



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


Re: Very basic question

2008-12-23 Thread Sion Arrowsmith
Sengly   wrote:
>I would like to calculate a string expression to a float. For example,
>I have ('12/5') and I want 2.4 as a result. I tried to use eval but it
>only gives me 2 instead of 2.5

py> from __future__ import division
py> print eval('12/5')
2.4
py> print eval('12//5')
2

Or switch to 3.0 which gives you this behaviour without the __future__
import.

-- 
\S -- si...@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
--
http://mail.python.org/mailman/listinfo/python-list


Re: Very basic question

2008-12-23 Thread John Machin
On Dec 23, 9:49 pm, Sengly  wrote:
> I can hack it by doing eval('1.0*12/5') but is there any better method?

from __future__ import division
--
http://mail.python.org/mailman/listinfo/python-list


Re: print to console without a line break

2008-12-23 Thread Qian Xu
Qian Xu wrote:

> Hello All,
> 
> Is it possible to print something to console without a line break?
> 
> I tried:
>   sys.stdout.write("Testing something ...") // nothing will be printed
>   time.sleep(1)
>   sys.stdout.write("done\n") // now, the whole string will be printed
> 
> What I want, is to see "Testing something ..." first.
> And after 1 second, to see "done" (with a line break)
> 

I have solved the problem by calling
  sys.stdout.flush()

--Qian Xu


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


print to console without a line break

2008-12-23 Thread Qian Xu
Hello All,

Is it possible to print something to console without a line break?

I tried:
  sys.stdout.write("Testing something ...") // nothing will be printed
  time.sleep(1)
  sys.stdout.write("done\n") // now, the whole string will be printed

What I want, is to see "Testing something ..." first. 
And after 1 second, to see "done" (with a line break)

The only one solution I have found is to call "echo -n 'my_string'".
But it is not nice. Because I have to escape all special chars in the string
manually.

Any advice?
Best regards
-- Qian Xu
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython.button.disabled still catching clicks

2008-12-23 Thread Aaron Brady
On Dec 23, 4:50 am, mynthon  wrote:
> Hello! (sorry for my english)
>
> I have a problem with buttons in wxPython. When button is disabled
> (by .Disable() or .Enable(False)) it is grayed out but still receive
> clicks.
>
> Eg. i have button that disable itself, runs long action and enable
> itself:
>
> def onClick(self, evt):
>     self.btn.Enable(False)
>     for i in range (1000):
>         print i
>     self.btn.Enable(True)
>
> when for loop is running button is greyed out and when i click on it
> nothing happens but when loop ends another one is started because
> button "remebered" thad i click on it when was diabled. My only idea
> is to reposition button outside frame instead of disabling it but this
> solution is...not good.
>
> thanks for any help. Ive searched groups, google and it looks that
> only i have this problem :)

No, it is very common.  During your for loop, the loop is dominating
the process completely.  Events are just building up in the app's
message queue, and don't get handled until after you yield on control.

If you need to run a long task, look into threading, the OnIdle
method, the 'multiprocessing' module, or pump messages during your
long task.
--
http://mail.python.org/mailman/listinfo/python-list


wxPython.button.disabled still catching clicks

2008-12-23 Thread mynthon
Hello! (sorry for my english)

I have a problem with buttons in wxPython. When button is disabled
(by .Disable() or .Enable(False)) it is grayed out but still receive
clicks.

Eg. i have button that disable itself, runs long action and enable
itself:

def onClick(self, evt):
self.btn.Enable(False)
for i in range (1000):
print i
self.btn.Enable(True)

when for loop is running button is greyed out and when i click on it
nothing happens but when loop ends another one is started because
button "remebered" thad i click on it when was diabled. My only idea
is to reposition button outside frame instead of disabling it but this
solution is...not good.

thanks for any help. Ive searched groups, google and it looks that
only i have this problem :)
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >