matplotlib on osx 10.6

2011-10-07 Thread luca72
hello i try to install matplotlib on osx 10.6 , i have also installed
freetype libpng and numpy but i get this error:
BUILDING MATPLOTLIB
matplotlib: 1.1.0
python: 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC
4.2.1 (Apple Inc. build 5646)]
  platform: darwin

REQUIRED DEPENDENCIES
 numpy: 1.2.1
 freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers
in any
* of '.', './freetype2'.

OPTIONAL BACKEND DEPENDENCIES
libpng: found, but unknown version (no pkg-config)
* Could not find 'libpng' headers in any of
'.'
   Tkinter: Tkinter: 67083, Tk: 8.5, Tcl: 8.5
  Gtk+: no
* Building for Gtk+ requires pygtk; you must
be able
* to "import gtk" in your build/install
environment
   Mac OS X native: yes
Qt: no
   Qt4: Qt: 4.7.0, PyQt4: 4.8.2
 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
  datetime: present, version unknown
  dateutil: present, version unknown
  pytz: matplotlib will provide
adding pytz

OPTIONAL USETEX DEPENDENCIES
dvipng: no
   ghostscript: /bin/sh: gs: command not found
 latex: no

[Edit setup.cfg to suppress the above messages]

pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends',
'matplotlib.backends.qt4_editor', 'matplotlib.projections',
'matplotlib.testing', 'matplotlib.testing.jpl_units',
'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d',
'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1',
'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri',
'matplotlib.delaunay', 'pytz']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.macosx-10.6-
universal-2.6/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/
lib.macosx-10.6-universal-2.6/matplotlib/mpl-data
running build_ext
building 'matplotlib.ft2font' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -
Os -Wall -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -
DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/System/
Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/
numpy/core/include -I. -I/System/Library/Frameworks/Python.framework/
Versions/2.6/Extras/lib/python/numpy/core/include/freetype2 -I./
freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.6/
include/python2.6 -c src/ft2font.cpp -o build/temp.macosx-10.6-
universal-2.6/src/ft2font.o
In file included from src/ft2font.h:16,
 from src/ft2font.cpp:3:
/usr/local/include/ft2build.h:56:38: error: freetype/config/
ftheader.h: No such file or directory
In file included from src/ft2font.cpp:3:
src/ft2font.h:17:10: error: #include expects "FILENAME" or 
src/ft2font.h:18:10: error: #include expects "FILENAME" or 
src/ft2font.h:19:10: error: #include expects "FILENAME" or 
src/ft2font.h:20:10: error: #include expects "FILENAME" or 
src/ft2font.h:21:10: error: #include expects "FILENAME" or 
In file included from src/ft2font.cpp:3:
src/ft2font.h:35: error: ‘FT_Bitmap’ has not been declared
src/ft2font.h:35: error: ‘FT_Int’ has not been declared
src/ft2font.h:35: error: ‘FT_Int’ has not been declared
src/ft2font.h:91: error: expected ‘,’ or ‘...’ before ‘&’ token
src/ft2font.h:91: error: ISO C++ forbids declaration of ‘FT_Face’ with
no type
src/ft2font.h:138: error: ‘FT_Face’ does not name a type
src/ft2font.h:139: error: ‘FT_Matrix’ does not name a type
src/ft2font.h:140: error: ‘FT_Vector’ does not name a type
src/ft2font.h:141: error: ‘FT_Error’ does not name a type
src/ft2font.h:142: error: ‘FT_Glyph’ was not declared in this scope
src/ft2font.h:142: error: template argument 1 is invalid
src/ft2font.h:142: error: template argument 2 is invalid
src/ft2font.h:143: error: ‘FT_Vector’ was not declared in this scope
src/ft2font.h:143: error: template argument 1 is invalid
src/ft2font.h:143: error: template argument 2 is invalid
src/ft2font.h:149: error: ‘FT_BBox’ does not name a type
src/ft2font.cpp:51: error: ‘FT_Library’ does not name a type
src/ft2font.cpp:114: error: variable or field ‘draw_bitmap’ declared
void
src/ft2font.cpp:114: error: ‘FT_Bitmap’ was not declared in this scope
src/ft2font.cpp:114: error: ‘bitmap’ was not declared in this scope
src/ft2font.cpp:115: error: ‘FT_Int’ was not declared in this scope
src/ft2font.cpp:116: error: ‘FT_Int’ was not declared in this scope
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/
python/numpy/core/include/numpy/__multiarray_api.h:958: warning: ‘int
_import_array()’ defined but not used
In file included from src/ft2font.h:16,

Re: Deleting files on a shared server

2011-10-07 Thread Tim Golden

On 07/10/2011 02:14, Josh English wrote:

This is a follow-up to some questions I posted a month or two ago. I
have two programs running on various Windows XP boxes, sharing
several resource files on a Windows 2003 server. It's a mapped drive
on the workstations to a shared folder.

I am using a locking utility that works by creating ".lock" files in
the shared folder and deleting those files when the program is done
with them.

To delete the files, I am using os.unlink.

One lock file refuses to disappear, even though I have code at both
application startup and shutdown (on the OnInit and OnExit methods to
the wxPython Application object) that hunts down .lock files and
deletes them.


Assuming that your code paths succeed and that the unlink actually
happens, it is possible for files to continue to exist after they
have been successfully deleted. This happens if another process
has opened them with share-delete mode; typically this will be
a virus checker or a process like the TortoiseSVN cache (or its
counterparts for other VCS). The file won't actually disappear
until the last handle on it is released.

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


Re: database connection

2011-10-07 Thread Gabriel Genellina
En Fri, 07 Oct 2011 02:18:04 -0300, masood shaik   
escribió:



 can u please tell me how we can connect to database without changing
the permission of db file using sqlite3


The OS user who executes the Python script must have read (and write,  
usually) access to the database file - *any* OS user who can read the  
database file can connect to it.


sqlite does not have internal users, and does not implement GRANT/REVOKE  
statements.


--
Gabriel Genellina

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


Re: How to inspect slot wrappers arguments in Python?

2011-10-07 Thread Gabriel Genellina
En Sat, 01 Oct 2011 12:13:45 -0300, julian bilcke  
 escribió:


I would like to get the list of parameters I need to initialize an AST  
node.


I'm trying to use the `inspect` module, however it seems I can't use it  
on a

built-in (native?) class, or else I misunderstood. [...]

>>> import inspect
>>> import ast
>>> inspect.getargspec(ast.If.__init__)
Traceback (most recent call last):
  File "", line 1, in 
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py",
line 813, in getargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError:  is not a
Python function

I am wondering if there is another way to get these parameters
automatically? (ie. without compiling myself a dict)


I'm afraid there is no way; this kind of introspection does not work for  
functions written in C. The function itself usually has a generic  
signature resembling (*args, **kw), and its parameters are usually  
unpacked calling a suitable variant of PyArg_ParseXXX. The information  
about the number and type of expected arguments is encoded in its 'format'  
parameter, and is not stored anywhere.


--
Gabriel Genellina

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


Thread handling issue

2011-10-07 Thread Paul
I'm wondering what the best solution for this problem is.

I've got a wxpython app, in one part a user makes some selections then opens a 
dialog to select where to output. At which point the app starts a thread 
processing their selection while they're choosing an output location, hopefully 
ready for when they're done.

My problem is if the user doesn't select an output location and cancels the
dialog to go back to the selection I want to terminate the thread to avoid the 
user opening and closing the output selection firing off a ton of threads. 

As there's no inbuilt way of killing threads I was wondering the best way to 
prevent this?

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


Re: Thread handling issue

2011-10-07 Thread Tim Golden

On 07/10/2011 09:29, Paul wrote:

I'm wondering what the best solution for this problem is.

I've got a wxpython app, in one part a user makes some selections then opens a
dialog to select where to output. At which point the app starts a thread
processing their selection while they're choosing an output location, hopefully
ready for when they're done.

My problem is if the user doesn't select an output location and cancels the
dialog to go back to the selection I want to terminate the thread to avoid the
user opening and closing the output selection firing off a ton of threads.

As there's no inbuilt way of killing threads I was wondering the best way to
prevent this?


The most common approach is to have the thread monitor an event which is
set if, for example, the user cancels. The thread may of course have to
wait, for example, for a long-running database query to complete before
it can discover that its time has been wasted :)

The exact mechanism will depend on how your code is structured,
what the thread is doing, and how it's passing anything back
to the main thread.

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


Python selenium web driver

2011-10-07 Thread Yesudian Rajkumar Johnkoilpillai
Hi,

I am looking into using Selenium 2.0 for launching Firefox and browse few
sites. I am using Python APIs to talk to webdriver on Ubuntu 11.04. I am
basically trying to follow the steps mentioned at
http://pypi.python.org/pypi/selenium . When I run the program, it throws
error as below.

yesudian@yesudian-virtual-machine:~/Try$ sudo python five.py
[sudo] password for yesudian:
Traceback (most recent call last):
  File "five.py", line 6, in 
browser = webdriver.Firefox() # Get local session of firefox
  File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py",
line 46, in __init__
self.binary, timeout),
  File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py",
line 46, in __init__
self.binary.launch_browser(self.profile)
  File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py",
line 44, in launch_browser
self._wait_until_connectable()
  File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py",
line 87, in _wait_until_connectable
raise WebDriverException("Can't load the profile. Profile Dir : %s" %
self.profile.path)
selenium.common.exceptions.WebDriverException: Message: "Can't load the
profile. Profile Dir : /tmp/tmpCR4CB7"

I tried to launch chrome also and the same issue happens. Do you have any
thoughts ?

Regards
Yesudian Rajkumar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending ftp file list to mail???

2011-10-07 Thread Gabriel Genellina
En Fri, 07 Oct 2011 03:23:57 -0300, selahattin ay   
escribió:


hi all. I want to get my ftp list and send the list to my mail adress...  
my codes are


And your problem is...?

--
Gabriel Genellina

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


Re: sending ftp file list to mail???

2011-10-07 Thread Gabriel Genellina
En Fri, 07 Oct 2011 03:23:57 -0300, selahattin ay   
escribió:


hi all. I want to get my ftp list and send the list to my mail adress...  
my codes are



baglanti = FTP("ftp.guncelyorum.org")
baglanti.login("**", "***")
print baglanti.dir()
posta = MIMEMultipart()
def posta_olustur():
posta['Subject']=konu
posta['From']=gmail_kullanici
posta['To']=kime
posta.attach(MIMEText(baglanti.retrlines("LIST")))  <-- what  
can I do for here


Ah, I didn't notice that part.
MIMEText expects a string. retrlines, by default, outputs to stdout, isn't  
very useful. Try this:


def posta_olustur():
  ...
  lines = []
  baglanti.retrlines("LIST", lines.append)
  text = '\n'.join(lines)
  posta.attach(MIMEText(text))



--
Gabriel Genellina

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


Re: socket.getsockname is returning junk!!

2011-10-07 Thread Gabriel Genellina
En Wed, 05 Oct 2011 08:56:08 -0300, Wong Wah Meng-R32813  
 escribió:


I am migrating my application from python 1.5.2 to 2.7.1. One of the  
existing code breaks. The getsockname method from socket object somehow  
returns me with some number which I deem as junk, rather than the  
listening port as I would have expected in the older python. Has anyone  
seen the same thing or is it due to my python is built with some  
corrupted library or something?



$ python
Python 2.7.1 (r271:86832, Oct  5 2011, 18:34:15) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.

import socket
sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 )
sock.setsockopt( socket.IPPROTO_TCP, 1, 1 )
server_address=('zmy02hp3', 1)
sock.bind(server_address)
sock.getsockname()

(0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

In python 1.5.2

server_address=('zmy02aix04', 1)
sock.bind(server_address)
sock.getsockname()

('10.228.51.41', 1)


I'd say it's a problem with the _socket module; did the unit tests flag  
anything when you built Python?


On Windows, Python 2.7.1:


server_address=('lepton', 1)
sock.bind(server_address)
sock.getsockname()

('127.0.0.1', 1)

--
Gabriel Genellina

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


Re: A tuple in order to pass returned values ?

2011-10-07 Thread Jean-Michel Pichavant

Steven D'Aprano wrote:

Jean-Michel Pichavant wrote:

  

In a general manner, ppl will tend to use the minimum arguments
required. However, do not pack values into tuple if they are not related.



How would you return multiple values if not in a tuple?

Tuples are *the* mechanism for returning multiple values in Python. If
you're doing something else, you're wasting your time.


  

A better thing to do would be to use objects instead of tuples, tuples
can serve as lazy structures for small application/script, they can
become harmful in more complexe applications, especialy when used in
public interfaces.



First off, tuples *are* objects, like everything else in Python.

If you are creating custom classes *just* to hold state, instead of using a
tuple, you are wasting time. Instead of this:

class Record:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z

result = Record(1, 2, 3)

Just use a tuple or a namedtuple: the work is already done for you, you have
a well-written, fast, rich data structure ready to use. For two or three
items, or for short-lived results that only get used once, an ordinary
tuple is fine, but otherwise a namedtuple is much better:

from collections import namedtuple
result = namedtuple('Record', 'x y z')(1, 2, 3)

  

I don't have access to namedtuple, working with python 2.5
It sounds to me that namedtuple exactly tries to fix what I dislike in 
tuples : undocumented packing of unrelated data.


However, I'm not sure it fixes the main issue: unpacking. Unpacking 
prevents you from adding any additional fields to your 'tuple' without 
breaking any line of code that was unpacking the tuple (to oppose to 
accessing an object attribute). And it did annoy me a lot when improving 
applications. Now I'm using tuples only in small applications, and try 
to avoid unpacking as much as possible.


namedtuple sounds great (if you don't use unpacking :o) ), too bad it is 
available only from python 2.6.


JM


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


RE: socket.getsockname is returning junk!!

2011-10-07 Thread Wong Wah Meng-R32813
Thanks. Someone pointed out that this could be due to a corrupted build, which 
I revisited the process. I included -lxnet in the linking process of the build, 
and this problem is resolved. The -lxnet was stated in README file for HP-UX 
Itanium build, which I somehow dropped it out in the middle of the process and 
wasn't aware it was essential as excluding it cost me the junk I was seeing. 
Problem solved!! Thanks a lot for reverting. :)

Regards,
Wah Meng


-Original Message-
From: python-list-bounces+wahmeng=freescale@python.org 
[mailto:python-list-bounces+wahmeng=freescale@python.org] On Behalf Of 
Gabriel Genellina
Sent: Friday, October 07, 2011 5:37 PM
To: python-list@python.org
Subject: Re: socket.getsockname is returning junk!!

En Wed, 05 Oct 2011 08:56:08 -0300, Wong Wah Meng-R32813  
 escribió:

> I am migrating my application from python 1.5.2 to 2.7.1. One of the  
> existing code breaks. The getsockname method from socket object somehow  
> returns me with some number which I deem as junk, rather than the  
> listening port as I would have expected in the older python. Has anyone  
> seen the same thing or is it due to my python is built with some  
> corrupted library or something?
>
>
> $ python
> Python 2.7.1 (r271:86832, Oct  5 2011, 18:34:15) [C] on hp-ux11
> Type "help", "copyright", "credits" or "license" for more information.
 import socket
 sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
 sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
 sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 )
 sock.setsockopt( socket.IPPROTO_TCP, 1, 1 )
 server_address=('zmy02hp3', 1)
 sock.bind(server_address)
 sock.getsockname()
> (0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
>
> In python 1.5.2
 server_address=('zmy02aix04', 1)
 sock.bind(server_address)
 sock.getsockname()
> ('10.228.51.41', 1)

I'd say it's a problem with the _socket module; did the unit tests flag  
anything when you built Python?

On Windows, Python 2.7.1:

>>> server_address=('lepton', 1)
>>> sock.bind(server_address)
>>> sock.getsockname()
('127.0.0.1', 1)

-- 
Gabriel Genellina

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


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


Re: Thread handling issue

2011-10-07 Thread Paul
Tim Golden  timgolden.me.uk> writes:

> 
> On 07/10/2011 09:29, Paul wrote:
> > I'm wondering what the best solution for this problem is.
> >
> > I've got a wxpython app, in one part a user makes some selections then 
> > opens 
a
> > dialog to select where to output. At which point the app starts a thread
> > processing their selection while they're choosing an output location, 
hopefully
> > ready for when they're done.
> >
> > My problem is if the user doesn't select an output location and cancels the
> > dialog to go back to the selection I want to terminate the thread to avoid 
the
> > user opening and closing the output selection firing off a ton of threads.
> >
> > As there's no inbuilt way of killing threads I was wondering the best way to
> > prevent this?
> 
> The most common approach is to have the thread monitor an event which is
> set if, for example, the user cancels. The thread may of course have to
> wait, for example, for a long-running database query to complete before
> it can discover that its time has been wasted :)
> 
> The exact mechanism will depend on how your code is structured,
> what the thread is doing, and how it's passing anything back
> to the main thread.
> 
> TJG
> 

My first thought was to use a flag but wouldn't the new thread see the cancel 
flag and stop as well? I could set it back but then any other threads might 
have 
been busy and not seen it while the flag was on.

The thread goes through the selection and does a few quick server calls for 
each 
one building up a data file. I guess as the server calls are quite fast the 
thread would be able to check flags quite often unless it's getting time-outs 
or 
something.

The threads don't pass anything back they're passed a reference to a data 
object 
which is constructed before the thread starts. The thread makes updates to the 
data object and sets a complete attribute flag in the object before finishing.


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


Re: A tuple in order to pass returned values ?

2011-10-07 Thread Cameron Simpson
On 07Oct2011 11:43, Jean-Michel Pichavant  wrote:
| namedtuple sounds great (if you don't use unpacking :o) ), too bad
| it is available only from python 2.6.

It is easy enough to roll your own.

Here's some example code with several flaws (it claims tuplehood,
but is actually a list; it is not immutable; it takes a list of field
names instead of a space separated string as namedtuple does) and isn't
very tested.

But feel free to take it and adapt it:

  def NamedTupleClassFactory(*fields):
''' Construct classes for named tuples a bit like the named tuples
coming in Python 2.6/3.0.
NamedTupleClassFactory('a','b','c') returns a subclass of "list"
whose instances have properties .a, .b and .c as references to
elements 0, 1 and 2 respectively.
'''
class NamedTuple(list):
  for i in range(len(fields)):
f=fields[i]
exec('def getx(self): return self[%d]' % i)
exec('def setx(self,value): self[%d]=value' % i)
exec('%s=property(getx,setx)' % f)
return NamedTuple

  def NamedTuple(fields,iter=()):
''' Return a named tuple with the specified fields.
Useful for one-off tuples/lists.
'''
return NamedTupleClassFactory(*fields)(iter)

More old code:-( I can see I need to go back to that and make it
cleaner. Surely I can get rid of the exec(0s at least:-)

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

Hacker: One who accidentally destroys.
Wizard: One who recovers afterwards.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A tuple in order to pass returned values ?

2011-10-07 Thread Peter Otten
Cameron Simpson wrote:

> On 07Oct2011 11:43, Jean-Michel Pichavant  wrote:
> | namedtuple sounds great (if you don't use unpacking :o) ), too bad
> | it is available only from python 2.6.
> 
> It is easy enough to roll your own.

Or use Raymond Hettinger's implementation:

http://code.activestate.com/recipes/500261-named-tuples/


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


Testing properties that are date-related

2011-10-07 Thread Tim Chase
Are there best practices for testing dates that are properties 
which take the current date into consideration?  I have something 
like


  class Foo:
def _get_year_range(self):
  return (self._min_year, self._max_year)
def _set_year_range(self, year):
  if isinstance(year, tuple):
_min, _max = map(window_date, year)
if _min > _max: _min, _max = _max, _min
  else: # a raw int
_min = _max = window_date(year)
  self._min_year, self._max_year = _min, _max
year_range = property(
  fget=_get_year_range,
  fget=_get_year_range,
  )

The problem is that the behavior of the window_date function 
depends on the current date (the function makes a guess about 
adding the century if the year was <100).  It *does* take an 
"around" parameter that defaults to the current date.  So for 
pure testing of the window_date() function, I can hard-code some 
date where I know what the expected values should be.


However if I want to write a test-harness for my property, I have 
no way (AFAIK) to pass in this fixed date to _set_year_range() so 
that the success/failure of my tests doesn't depend on the day I 
run them:


  class TestFoo:
def test_year_range(self):
  around = date(2011,1,1)
  f = Foo()
  f.year_range = (97, 84)
  self.assertEqual(f.year_range, (1984, 1997))

Any suggestions/tips/hints?  Thanks,

-tkc




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


Re: Testing properties that are date-related

2011-10-07 Thread Peter Otten
Tim Chase wrote:

> Are there best practices for testing dates that are properties
> which take the current date into consideration?  I have something
> like
> 
>class Foo:
>  def _get_year_range(self):
>return (self._min_year, self._max_year)
>  def _set_year_range(self, year):
>if isinstance(year, tuple):
>  _min, _max = map(window_date, year)
>  if _min > _max: _min, _max = _max, _min
>else: # a raw int
>  _min = _max = window_date(year)
>self._min_year, self._max_year = _min, _max
>  year_range = property(
>fget=_get_year_range,
>fget=_get_year_range,
>)
> 
> The problem is that the behavior of the window_date function
> depends on the current date (the function makes a guess about
> adding the century if the year was <100).  It *does* take an
> "around" parameter that defaults to the current date.  So for
> pure testing of the window_date() function, I can hard-code some
> date where I know what the expected values should be.
> 
> However if I want to write a test-harness for my property, I have
> no way (AFAIK) to pass in this fixed date to _set_year_range() so
> that the success/failure of my tests doesn't depend on the day I
> run them:
> 
>class TestFoo:
>  def test_year_range(self):
>around = date(2011,1,1)
>f = Foo()
>f.year_range = (97, 84)
>self.assertEqual(f.year_range, (1984, 1997))
> 
> Any suggestions/tips/hints?  Thanks,

Temporarily replace the window_date() function with something that you can 
control completely. Assuming Foo and window_date are defined in foo.py:

# untested
import foo

class TestFoo:
def setUp(self):
foo.window_date = functools.partial(foo.window_date, 
around=date(2011, 1, 1))
def tearDown(self):
foo.window_date = foo.window_date.func
def test_year_range(self):
f = Foo()
f.year_range = (97, 84)
self.assertEqual(f.year_range, (1984, 1997))

See also http://www.voidspace.org.uk/python/mock/

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


Re: Testing properties that are date-related

2011-10-07 Thread Tim Chase

On 10/07/11 07:38, Peter Otten wrote:

Are there best practices for testing dates that are properties
which take the current date into consideration

The problem is that the behavior of the window_date function
depends on the current date (the function makes a guess about
adding the century if the year was<100).  It *does* take an
"around" parameter that defaults to the current date.  So for
pure testing of the window_date() function, I can hard-code some
date where I know what the expected values should be.

However if I want to write a test-harness for my property, I have
no way (AFAIK) to pass in this fixed date to _set_year_range() so
that the success/failure of my tests doesn't depend on the day I
run them


Temporarily replace the window_date() function with something that you can
control completely. Assuming Foo and window_date are defined in foo.py:

# untested
import foo

class TestFoo:
 def setUp(self):
 foo.window_date = functools.partial(foo.window_date,
around=date(2011, 1, 1))
 def tearDown(self):
 foo.window_date = foo.window_date.func
 def test_year_range(self):
 f = Foo()
 f.year_range = (97, 84)
 self.assertEqual(f.year_range, (1984, 1997))


I had to twiddle my class code a bit to make sure it referenced 
module.window_date() everywhere instead of just a raw 
window_date() (originally pulled in via "from module import 
window_date") so that it picked up the new function, but 
otherwise it worked like a charm.


(there was also the matter of some function properties that were 
used for an undetailed parameter to allow for suggesting that the 
window_date bias backwards, forwards or around the current date, 
but a little hackery took care of that too, just copying the 
germane properties from the saved function object to the result 
of the partial() call)


Thanks!

-tkc


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


Re: passing multiple string to a command line option

2011-10-07 Thread Miki Tebeka
Seems like self.ptype is a type that has __init__ with no arguments (other than 
self).

You can add "print type(self.ptype)" as first line of "convert" to see what 
type it is (or place a breakpoint there).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing properties that are date-related

2011-10-07 Thread Ethan Furman

Tim Chase wrote:

On 10/07/11 07:38, Peter Otten wrote:

Are there best practices for testing dates that are properties
which take the current date into consideration

The problem is that the behavior of the window_date function
depends on the current date (the function makes a guess about
adding the century if the year was<100).  It *does* take an
"around" parameter that defaults to the current date.  So for
pure testing of the window_date() function, I can hard-code some
date where I know what the expected values should be.

However if I want to write a test-harness for my property, I have
no way (AFAIK) to pass in this fixed date to _set_year_range() so
that the success/failure of my tests doesn't depend on the day I
run them


Temporarily replace the window_date() function with something that you 
can

control completely. Assuming Foo and window_date are defined in foo.py:

# untested
import foo

class TestFoo:
 def setUp(self):
 foo.window_date = functools.partial(foo.window_date,
around=date(2011, 1, 1))
 def tearDown(self):
 foo.window_date = foo.window_date.func
 def test_year_range(self):
 f = Foo()
 f.year_range = (97, 84)
 self.assertEqual(f.year_range, (1984, 1997))


I had to twiddle my class code a bit to make sure it referenced 
module.window_date() everywhere instead of just a raw window_date() 
(originally pulled in via "from module import window_date") so that it 
picked up the new function, but otherwise it worked like a charm.


Another option is injection:

import foo

def window_date(...):
...

foo.window_date = window_date


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


Re: Thread handling issue

2011-10-07 Thread Tim Golden

On 07/10/2011 11:15, Paul wrote:

My first thought was to use a flag but wouldn't the new thread see the cancel
flag and stop as well? I could set it back but then any other threads might have
been busy and not seen it while the flag was on.

The thread goes through the selection and does a few quick server calls for each
one building up a data file. I guess as the server calls are quite fast the
thread would be able to check flags quite often unless it's getting time-outs or
something.

The threads don't pass anything back they're passed a reference to a data object
which is constructed before the thread starts. The thread makes updates to the
data object and sets a complete attribute flag in the object before finishing.


Well a lot depends on how you're doing things. (ie "It Depends"). You
could generate an event for each thread so a second thread started while
the first was running down wouldn't cause confusion. It's not clear
whether the data object is common to all threads -- in which case
you need to make sure you're locking etc. -- or is a new instance
for each thread.

I did try a couple of passes at a code-sketch, but there are too
many unknowns to do justice to it. Basically, have the thread poll
an event as it moves through. Have the UI set the event and join to
the existing thread (ie wait for it to finish) and then fire off
a new one. Or -- if the data items are independent -- fire off
the new one regardless and let the old one die when it sees its
event, assuming that the data object it's populating is disposable.

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


Re: Testing properties that are date-related

2011-10-07 Thread Tim Chase

On 10/07/11 09:45, Ethan Furman wrote:

Tim Chase wrote:

On 10/07/11 07:38, Peter Otten wrote:

  def setUp(self):
  foo.window_date = functools.partial(foo.window_date,
around=date(2011, 1, 1))


it worked like a charm.


Another option is injection:

import foo

def window_date(...):
  ...

foo.window_date = window_date


The problem is that I *want* the functionality of the existing 
window_date() because that's part of what's being tested. 
Peter's suggestion of injection to the module namespace via 
functools.partial() to specify the missing parameter was the tip 
I needed to be able to write tests that exercised things properly 
without overly invasive changes to the code.  But thanks for your 
idea.


-tkc


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


Re: passing multiple string to a command line option

2011-10-07 Thread Mahmood Naderan
That print command generated a lot of errors. Since that error in my first post 
is related to the python code in simulator, I emailed them and consulted for 
help. Seems that it is going to be fixed

Thanks for your kindness :)

 
// Naderan *Mahmood;


- Original Message -
From: Miki Tebeka 
To: comp.lang.pyt...@googlegroups.com
Cc: python mailing list ; Miki Tebeka 
; Mahmood Naderan 
Sent: Friday, October 7, 2011 5:41 PM
Subject: Re: passing multiple string to a command line option

Seems like self.ptype is a type that has __init__ with no arguments (other than 
self).

You can add "print type(self.ptype)" as first line of "convert" to see what 
type it is (or place a breakpoint there).

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


Re: help

2011-10-07 Thread Redcat
On Fri, 07 Oct 2011 15:59:55 +, X1 wrote:

> I have this program that fails:
> 
> $ vapt
> Traceback (most recent call last):
>   File "/usr/local/bin/vapt", line 3, in 
> from vapt import vapt
>   File "/usr/lib/python2.6/site-packages/vapt/__init__.py", line 11, in
> 
> __import__(name, glob, loc, [])
>   File "/usr/lib/python2.6/site-packages/vapt/cadview.py", line 13, in
> 
> import OpenGL.Tk as gltk
> ImportError: No module named Tk
> 
> 
> can you help me?
> This is on fedora

The OpenGL.Tk module is looking for the Tk module and not finding it. 
Install the Tk module.

Try "sudo easy_install Tk".
-- 
http://mail.python.org/mailman/listinfo/python-list


unsupported operand type(s) for pow(): 'unicode', 'long', 'long': Pycrypto

2011-10-07 Thread Kayode Odeyemi
Hello everyone,

I'm writing a fairly large app which uses Oauth (python-oauth2). I am trying
to generate a
public/private key pair on user supplied parameters (whitespaced-delimited
strings basically).

When trying to encrypt the key, I'm getting the "unsupported operand type(s)
for pow(): 'unicode', 'long', 'long'"

>From Interactive shell, the program worked successfully.

My question is do I have to make the user supplied data of a non-unicode
string to make this work?

Thanks

-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unsupported operand type(s) for pow(): 'unicode', 'long', 'long': Pycrypto

2011-10-07 Thread Ian Kelly
On Fri, Oct 7, 2011 at 11:16 AM, Kayode Odeyemi  wrote:
> Hello everyone,
>
> I'm writing a fairly large app which uses Oauth (python-oauth2). I am trying
> to generate a
> public/private key pair on user supplied parameters (whitespaced-delimited
> strings basically).
>
> When trying to encrypt the key, I'm getting the "unsupported operand type(s)
> for pow(): 'unicode', 'long', 'long'"
>
> From Interactive shell, the program worked successfully.
>
> My question is do I have to make the user supplied data of a non-unicode
> string to make this work?

Please include the traceback and the snippet of code where you make
the call that is failing.  Without that, it is not at all clear
exactly what you are doing, especially since python-oauth2 does not
seem to provide any encryption API.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help

2011-10-07 Thread Redcat
> Thanks,
> I have the Tk module installed, but the program still fails. Probably it
> is a problem of path?

That would be my guess - that the Tk module is installed somewhere other 
than where OpenGL.Tk is looking for it.

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


Re: unsupported operand type(s) for pow(): 'unicode', 'long', 'long': Pycrypto

2011-10-07 Thread Kayode Odeyemi
On Fri, Oct 7, 2011 at 7:23 PM, Ian Kelly  wrote:

> On Fri, Oct 7, 2011 at 11:16 AM, Kayode Odeyemi  wrote:
> > Hello everyone,
> >
> > I'm writing a fairly large app which uses Oauth (python-oauth2). I am
> trying
> > to generate a
> > public/private key pair on user supplied parameters
> (whitespaced-delimited
> > strings basically).
> >
> > When trying to encrypt the key, I'm getting the "unsupported operand
> type(s)
> > for pow(): 'unicode', 'long', 'long'"
> >
> > From Interactive shell, the program worked successfully.
> >
> > My question is do I have to make the user supplied data of a non-unicode
> > string to make this work?
>
> Please include the traceback and the snippet of code where you make
> the call that is failing.  Without that, it is not at all clear
> exactly what you are doing, especially since python-oauth2 does not
> seem to provide any encryption API.
>

Thanks for writing in.

I had this:

encrypted = public_key.encrypt(params, 16)

I was able to fix it with:

encrypted = public_key.encrypt(str(params), 16)

pow() needs params in non-unicode.

I understand python-oauth2 does not have encryption API built-in. I'm
creating one
before using it.


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Thread handling issue

2011-10-07 Thread Prasad, Ramit
-Original Message-
From: python-list-bounces+ramit.prasad=jpmorgan@python.org 
[mailto:python-list-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of 
Paul
Sent: Friday, October 07, 2011 3:29 AM
To: python-list@python.org
Subject: Thread handling issue

I'm wondering what the best solution for this problem is.

I've got a wxpython app, in one part a user makes some selections then opens a 
dialog to select where to output. At which point the app starts a thread 
processing their selection while they're choosing an output location, hopefully 
ready for when they're done.

My problem is if the user doesn't select an output location and cancels the
dialog to go back to the selection I want to terminate the thread to avoid the 
user opening and closing the output selection firing off a ton of threads. 

As there's no inbuilt way of killing threads I was wondering the best way to 
prevent this?

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


Why not just wait until they are done with all user input and then fire threads 
after that? 


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Advise on using logging.getLogger needed.

2011-10-07 Thread Vinay Sajip
On Oct 2, 11:12 pm, "Steven W. Orr"  wrote:
> I hope I don't sound like I'm ranting :-(

You don't, but neither is it absolutely clear what you're trying to
achieve. BTW the term "root logger" in the logging docs refers to a
logger internal to the logging package, and not to a logger that you
create. For that, it's best to refer to "top level logger for my
application/library".

Supposing you want your top-level logger always to be the name of your
main script, and you want other loggers to live below this logger. In
your main script module, therefore, you do the equivalent of

pname = compute_program_name(sys.argv[0])
logger = logging.getLogger(pname)
# configure logging handlers, filters etc. for your application

In your library modules, if you want them to live under that top-level
logger, then you can do something like

pname = compute_program_name(sys.argv[0])
logger = logging.getLogger('%s.%s' % pname, __name__)

where you can use something other than __name__ for the logger name
suffix, if you want.

> My problem is that I just want the modules that I write, to be able to get the
>  named root logger and still be able to refer to possible sub-loggers.

According to the scheme I describe, if you have two scripts called
"foo" and "bar" which make use of a common module "baz", then events
in the foo module would appear under logger "foo", and events in the
baz module when run from foo would be logged under logger "foo.baz".
When running "bar", events in the bar module would appear under logger
"bar", whereas events in the baz module when run from bar would be
logged under logger "bar.baz". This seems to be what you're asking
for, but I may have misunderstood.

> I am running 2.6, so I don't have access to logging.getChild, but I'm not
> clear that I even want that.

getChild is just a convenience method, you don't need it - you can
just build the logger name as in my example above.

> My modules are used by multiple programs. Does this mean that I should simply
> use __name__ all the time? (That seems inelegant, no?)

Actually __name__ is very elegant, as it is impervious to you moving
your code around and follows the Python package hierarchy. Also, if
you are using third party code (especially from various sources),
using __name__ will make things unambiguous about where exactly events
are being logged from. Third party code typically won't know about
your top-level logger, and __name__ is the one scheme that everything
can agree on - the point about logger names being that they're
supposed to codify "where" in your application events occur, and the
package hierarchy is the canonical representation of source locations
in an application.

Regards,

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


deepcopy does not work for A subclassed list

2011-10-07 Thread txismis unzetabarrenetxeagoikolea

This is the issue

I have created a mylist class by subclassing a List, added several attributes 
to mylist , and overrided the append method which takes into account one of the 
new attributes.

mylist class is functional and works as I planned, but when I try to deepcopy 
objects from mylist  I received errors because the attribute has not been 
copied and the override append raise an error.

When I want to deepcopy one object from mylist the algorithm does not take into 
account the attributes I created; ergo, I have some errors from the copy module

I can use pickle to dump and load objects from my subclass with no errors.

Any ideas about how to make the copy module to behave as expected.

Thanks!

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


[ANN] pypiserver 0.3.0 - minimal pypi server

2011-10-07 Thread Ralf Schmitt
Hi,

I've just uploaded pypiserver 0.3.0 to the python package index.

pypiserver is a minimal PyPI compatible server. It can be used to serve
a set of packages and eggs to easy_install or pip.

pypiserver is easy to install (i.e. just easy_install pypiserver). It
doesn't have any external dependencies.

http://pypi.python.org/pypi/pypiserver/ should contain enough
information to easily get you started running your own PyPI server in a
few minutes.

The code is available on github: https://github.com/schmir/pypiserver


Changes in version 0.3.0
-
- pypiserver now scans the given root directory and it's
  subdirectories recursively for packages. Files and directories
  starting with a dot are now being ignored.
- /favicon.ico now returns a "404 Not Found" error
- pypiserver now contains some unit tests to be run with tox

-- 
Cheers,
Ralf

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


Memory

2011-10-07 Thread Frank Ruiz
Quick question,

What is the best way for pulling resource information for a system
running linux? Was wondering if there was a python only way.

Methods I am aware of are:

1. Parsing contents of /proc
2. Running a system command like free, or dmidecode and parsing the output.

Is there any other way to pull.. lets say memory information? i.e.
Find how much total RAM a system has on it.

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


Re: Dabo 0.9.4 Released!

2011-10-07 Thread Ed Leafe
On Oct 6, 2011, at 12:18 PM, Neal Becker wrote:

> What is it?

Sorry, I guess I should have included that. We've been around for so 
long I sometimes assume that everyone knows what Dabo is.

Dabo is a framework for building desktop applications. It is strongly 
geared toward database applications, although a database connection is 
completely optional. We wrap the wxPython GUI toolkit, hiding its C++ roots and 
presenting a more Pythonic interface for creating your UI.

 See more at http://dabodev.com, and feel free to ask any more 
questions.



-- Ed Leafe



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


Re: Memory

2011-10-07 Thread Christian Heimes
Am 07.10.2011 21:39, schrieb Frank Ruiz:
> Quick question,
> 
> What is the best way for pulling resource information for a system
> running linux? Was wondering if there was a python only way.
> 
> Methods I am aware of are:
> 
> 1. Parsing contents of /proc
> 2. Running a system command like free, or dmidecode and parsing the output.
> 
> Is there any other way to pull.. lets say memory information? i.e.
> Find how much total RAM a system has on it.

Yes, use psutil. http://code.google.com/p/psutil/

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


Re: recommend a graphics library for plotting by the pixel?

2011-10-07 Thread Adam Funk
On 2011-10-04, Ian Kelly wrote:

> On Tue, Oct 4, 2011 at 3:56 AM, Adam Funk  wrote:
>> I'd like to create a window with a "pause" button and a large plotting
>> area, in which I'd like to draw a polygon, detect the pixel
>> coördinates of a mouse click, and then start setting the colors of
>> pixels by (x,y) coördinates.  (This is just for my own amusement, to
>> play with some formulas for generating fractals using random numbers.)
>>
>> There seems to be a large number of different python GUI libraries,
>> and I wonder if someone can recommend the easiests one to learn for
>> this purpose?  (The only python graphics library I've used is PyGame,
>> which I don't think is the way to go here.)
>
> You could use wxPython.  You'll need to create a custom control and
> have it paint itself by blitting from a wx.Bitmap, which you'll draw
> on by using a wx.MemoryDC and then refreshing the control.
>
> I would probably just use pygame myself.  I guess you're avoiding it
> because of the requirement for a button, but there are GUI libraries
> available for it, or if all you need are a couple of buttons you could
> easily roll your own.

Excellent suggestion.  I got it to work, but using keypresses (pause,
step, quit) instead of buttons, and a mouse event for letting the user
pick the start point on the screen.


-- 
I worry that 10 or 15 years from now, [my daughter] will come to me
and say 'Daddy, where were you when they took freedom of the press
away from the Internet?'  [Mike Godwin]
http://www.eff.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recommend a graphics library for plotting by the pixel?

2011-10-07 Thread Adam Funk
On 2011-10-05, Westley Martínez wrote:

> On Wed, Oct 05, 2011 at 02:29:38PM +0100, Adam Funk wrote:

>> I only know PyGame because we did an exercise in recreating the old
>> breakout game and messing around with it at a local Python group.
>> 
>> I was under the mistaken impression from that exercise that you have
>> to maintain a set of all the objects on the screen and redraw them all
>> every time through the loop that ends with pygame.display.flip() ---
>> *but* I now see that the loop starts with these:
>> 
>> clock.tick(tick_rate)
>> screen.fill((0,0,0))
>> # comes from screen = 
>> pygame.display.set_mode((screen_width,screen_height))
>> # before the loop
>> 
>> and that I was then deleting hit bricks, calculating the new positions
>> of the balls, and then redrawing everything that was left on the
>> secondary screen because things were moving around and disappearing.
>> 
>> I guess if I don't clear the screen at the beginning of the loop but
>> just blit pixels onto it, when I call display.flip(), it will add the
>> new blittings to what was already there?  If that's true, this will be
>> much easier than I thought.

> Yep.  Blitting is replacing the old colors with new colors.  It doesn't
> replace colors unless you tell it to.

My mistake was in sample code, running with it, & not looking at it
too closely.  ;-)


-- 
Mathematiker sind wie Franzosen: Was man ihnen auch sagt, übersetzen
sie in ihre eigene Sprache, so daß unverzüglich etwas völlig anderes
daraus wird.[Goethe]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: deepcopy does not work for A subclassed list

2011-10-07 Thread MRAB

On 07/10/2011 20:29, txismis unzetabarrenetxeagoikolea wrote:

This is the issue

I have created a mylist class by subclassing a List, added several
attributes to mylIst , and overrided the append method which takes into
account one of the new attributes.

mylist class is functional and works as I planned, but when I try to
deepcopy objects from mylist I received errors because the attribute has
not been copied and the override append raise an error.

When I want to deepcopy one object from mylist the algorithm does not
take into account the attributes I created; ergo, I have some errors
from the copy module

I can use pickle to dump and load objects from my subclass with no errors.

Any ideas about how to make the copy module to behave as expected.


The documentation talks about defining a "__deepcopy__" method.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Thread handling issue

2011-10-07 Thread Cameron Simpson
On 07Oct2011 10:15, Paul  wrote:
| Tim Golden  timgolden.me.uk> writes:
| > On 07/10/2011 09:29, Paul wrote:
| > > My problem is if the user doesn't select an output location and cancels 
the
| > > dialog to go back to the selection I want to terminate the thread to 
avoid the
| > > user opening and closing the output selection firing off a ton of threads.
| > >
| > > As there's no inbuilt way of killing threads I was wondering the best way 
to
| > > prevent this?
| > 
| > The most common approach is to have the thread monitor an event which is
| > set if, for example, the user cancels. The thread may of course have to
| > wait, for example, for a long-running database query to complete before
| > it can discover that its time has been wasted :)
[...]
| My first thought was to use a flag but wouldn't the new thread see the cancel 
| flag and stop as well? I could set it back but then any other threads might 
have 
| been busy and not seen it while the flag was on.

I'd be inclined to dispatch threads via a control object of some kind.
You'd have a default one for your program as a whole, but when you have
a circumstance such as you describe instantiate a new control object.
Set the cancel flag in the control objects. Have threads poll their
invoking control object. That way you can have a flag that applies to
your desired set of threads.

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

He's silly and he's ignorant, but he's got guts, and guts is enough.
- Sgt. Hartmann
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: deepcopy does not work for A subclassed list

2011-10-07 Thread Terry Reedy

On 10/7/2011 4:37 PM, MRAB wrote:

On 07/10/2011 20:29, txismis unzetabarrenetxeagoikolea wrote:



Any ideas about how to make the copy module to behave as expected.


The documentation talks about defining a "__deepcopy__" method.


Specifically, in the copy module doc
"In order for a class to define its own copy implementation, it can 
define special methods __copy__() and __deepcopy__(). The former is 
called to implement the shallow copy operation; no additional arguments 
are passed. The latter is called to implement the deep copy operation; 
it is passed one argument, the memo dictionary. If the __deepcopy__() 
implementation needs to make a deep copy of a component, it should call 
the deepcopy() function with the component as first argument and the 
memo dictionary as second argument."


All the possible customization methods are discussed in Language 
Reference 3.3. Special method names


--
Terry Jan Reedy

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


Re: help

2011-10-07 Thread Terry Reedy

On 10/7/2011 12:56 PM, Redcat wrote:

On Fri, 07 Oct 2011 15:59:55 +, X1 wrote:


I have this program that fails:

$ vapt
Traceback (most recent call last):
   File "/usr/local/bin/vapt", line 3, in
 from vapt import vapt
   File "/usr/lib/python2.6/site-packages/vapt/__init__.py", line 11, in

 __import__(name, glob, loc, [])
   File "/usr/lib/python2.6/site-packages/vapt/cadview.py", line 13, in

 import OpenGL.Tk as gltk
ImportError: No module named Tk


can you help me?
This is on fedora


The OpenGL.Tk module is looking for the Tk module and not finding it.
Install the Tk module.


Or there is no OpenGL.Tk module

>>> import itertools.xxx
Traceback (most recent call last):
  File "", line 1, in 
import itertools.xxx
ImportError: No module named xxx


Try "sudo easy_install Tk".


--
Terry Jan Reedy

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


Re: unsupported operand type(s) for pow(): 'unicode', 'long', 'long': Pycrypto

2011-10-07 Thread Terry Reedy

On 10/7/2011 2:54 PM, Kayode Odeyemi wrote:


pow() needs params in non-unicode.


pow() need 2 or 3 numbers as args. The function that calls it must turn 
the (2.x) string into a number, either with hash() or its own hash 
function. That latter function probably want integers code in range(256).


"pow(x, y[, z])

Return x to the power y; if z is present, return x to the power y, 
modulo z (computed more efficiently than pow(x, y) % z). The 
two-argument form pow(x, y) is equivalent to using the power operator: x**y.


The arguments must have numeric types. With mixed operand types, 
the coercion rules for binary arithmetic operators apply. For int 
operands, the result has the same type as the operands (after coercion) 
unless the second argument is negative; in that case, all arguments are 
converted to float and a float result is delivered. For example, 10**2 
returns 100, but 10**-2 returns 0.01. If the second argument is 
negative, the third argument must be omitted. If z is present, x and y 
must be of integer types, and y must be non-negative.

"
--
Terry Jan Reedy

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


The hyper fused upper part of Nike Air

2011-10-07 Thread jerser-2009
The hyper fused upper part of Nike Air Max displays the humanity of
the designer because of its lightweight, breathability and a feeling
of plusher fitness. The mesh inner collar, and the soft springy
cushion http://www.outlet-nike-air-max.com/inside can protect the feet
against most possible injures. Besides the rubber materials around the
translucent perimeter displays a particular appearance of the shoes,
which is a love of most women, especially those who pursuit to be in
fashion. Meanwhile the rubber material is a guaranty of the durability
and traction, which is fully the practice. With the {2}{/2}dynamic
colors of Women’s Nike Air Max 2011, you will soon experience the
vitality of sports when you are dressed in such a pair of classic nice
cheap Nike running shoes, because it can not only create a healthy
condition for feet, but also can restore the original active in the
shortest time. What’s more, the Nike Air Max 2011 will not cause any
exacerbation if you once were injured in feet.
http://www.outlet-nike-air-max.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deleting files on a shared server

2011-10-07 Thread Gabriel Genellina
En Fri, 07 Oct 2011 04:45:32 -0300, Tim Golden   
escribió:

On 07/10/2011 02:14, Josh English wrote:



To delete the files, I am using os.unlink.

One lock file refuses to disappear, even though I have code at both
application startup and shutdown (on the OnInit and OnExit methods to
the wxPython Application object) that hunts down .lock files and
deletes them.


Assuming that your code paths succeed and that the unlink actually
happens, it is possible for files to continue to exist after they
have been successfully deleted. This happens if another process
has opened them with share-delete mode; typically this will be
a virus checker or a process like the TortoiseSVN cache (or its
counterparts for other VCS). The file won't actually disappear
until the last handle on it is released.


In such cases the openfiles command [1] is very useful for detecting who  
is holding the file open.


[1]  
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/openfiles.mspx


--
Gabriel Genellina

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