about framework

2007-02-26 Thread memcached
Python has some web framework.I'm not familiar with all of them.
Do you think which is best popular of  them?Thanks.
** AOL now offers free 
email to everyone.  Find out more about what's free from AOL at 
http://www.aol.com.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nested Parameter Definitions

2007-02-26 Thread Paddy
On Feb 25, 11:41 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:

> Just looks like an extension of the normal tuple unpacking feature
> of the language.
>

Yep, it looks like good Python to me too. Maybe the tutorial could be
extended to cover this form of parameter too?
It would be good if Brett Cannon could add some comments on why he
asked for a show of hands on the features use?
I'd hate for the feature to be removed because it is not often used,
when the reason it is not often used is because it is hard to find
examples of its use, because its buried in the language reference
manual.

Do any Python books mention nested parameters?

- Paddy.

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


Re: Question about idiomatic use of _ and private stuff.

2007-02-26 Thread Eric Brunel
On Sun, 25 Feb 2007 22:12:52 +0100, Bruno Desthuilliers  
<[EMAIL PROTECTED]> wrote:

> Steven W. Orr a écrit :
>> I understand that two leading underscores in a class attribute make the  
>> attribute private.
>
> Nope. It doesn't make it "private", it mangles the attribute name with  
> the class name (ie : Bar.__mangled will become Bar._Bar__mangled  
> everywhere except inside Bar). This is only useful when you want to make  
> sure an attribute will not be *accidentally* accessed by a child class.  
> FWIW, I've found it of very limited use so far...

If I'm not mistaken, it was originally introduced to allow designers of  
sub-classes to use any attribute name they liked, without bothering to go  
up the whole class hierarchy to make sure this name was not already used.  
Even if Python relies far less on inheritance than other languages, class  
hierarchies are sometimes quite large. If in addition, each class has a  
lot of attributes, looking for an unused name can become long and painful.  
In this context, the double-underscore may be a blessing.

My [€£$¥]0.02...
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Having multiple instances of a single application start a single instance of another one

2007-02-26 Thread Eric Brunel
On Fri, 23 Feb 2007 23:39:03 +0100, Troy Melhase <[EMAIL PROTECTED]>  
wrote:

>> The first time A starts, it should open a B process and start
>> communicating with it. All other times an A instance starts it should
>> simply talk with the B that already is open.
>
> B should write its process id to a location known by both
> applications.  When A starts, it should read that PID from the file
> and attempt to communicate with the process having that PID.
>
> When B starts, it should also check for the file.  If it's found and
> if the PID in it is present in the process table, then B should exit.
> Otherwise, it should start normally and write its own PID to the file.

You have a race condition here: if another instance of B is created  
between the check and the creation of the file, you'll have two instances  
running. And remember Murphy's law: yes, it will happen, and quicker than  
you can imagine ;-)

To prevent this from happening, I usually create a special directory for  
the PID file, and I delete both the file and the directory when the  
process exits. The advantage is that os.mkdir is basically a "test and  
set" in a single operation: if two of these are attempted at "the same  
time", only one can succeed. It is also cross-platform and even works on  
shared file systems.

So the code would be something like:

## Try to create directory
try:
   os.mkdir(os.path.join(common_directory, "B_lock"))
except OSError:
   ## Failed: another instance is running
   sys.exit()
## Create the PID file
# (...)
try:
   ## Application code
   # (...)
finally:
   ## Remove the PID file
   # (...)
   ## Delete directory
   os.rmdir(os.path.join(common_directory, "B_lock"))

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help regarding python and jsp

2007-02-26 Thread Ant
On Feb 26, 6:41 am, [EMAIL PROTECTED] wrote:
> Hi,
> i am working with jsp ..
> i wanna help regarding how to import or how to call  python modules to
> jsp

You are aware that JSP's are a Java technology, and not Python. And
that they are a templating language in themselves. And that scriptlets
(Java code inside of a JSP) have not been regarded as good practice
for years now, and that would be the only way of getting Python code
inside a JSP (using an ugly hack such as creating a Jython engine and
writing the python as strings to be eval'ed)

So what is it that you are trying to do exactly here?

--
Ant.

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


Re: compile python with sqlite3

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Nader Emami wrote:
> L.S.,
>
> I have to compile (install) locally Python 2.5, because I don't have
> 'root' permission. Besides I would use 'sqlite3' as a database for
> TurboGears/Django. I have installed 'sqlite3' somewhere on my Linux
> (/path/to/sqlite'). What do I have to do if I want to compile 'Python'
> with 'sqlite3'? I would appreciate if somebody tells me to solve this
> problem.
>
> With regards,
> Nader
You need PySQLite ..


- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4qf21LDUVnWfY8gRArLiAKCfOG3Jh6xcJJA5ASJZ1zM01mv1BACgml19
DIMioieQqKrHqIUk0mp5kvQ=
=a8si
-END PGP SIGNATURE-

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

Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread dixkey
On Feb 26, 6:32 am, Tech HR <[EMAIL PROTECTED]> wrote:
> Our
> website is currently a LAMP appication with P=Python. We are looking for
> bright motivated people who know or are willing to learn Python and/or
> Linux, Apache and MySQL system administration skills. (And if you want
> to convince us that we should switch over to Postgres, we're willing to
> listen.)
This is more out of curiosity, but does it mean that you wouldn't be
willing
to listen about a switch from Python to Lisp?

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


Re: help regarding python and jsp

2007-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> Hi,
> i am working with jsp ..
> i wanna help regarding how to import or how to call  python modules to
> jsp
> 
> if a piece of code is availabe will be very helpful for me

jsp is Java. Python is ... Python.


There is Jython available, a python-interpreter running in a Java JVM. Go
visit

http://jython.org/

to learn more about it.

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


Re: writing a file:newbie question

2007-02-26 Thread kavitha thankaian
Hi All,
   
  Thanks for your reply Gabriel ,,,
  I just had to use a backslash character to write newline in the 
proper loop.So I could solve that problem.But now my question is I would 
like to delete the comma at the end.
  say for example,,i have a file test.txt and the file has the list
   
  a,b,c,d,
   
  i would like to delete the trailing comma at the end,,,
   
  if someone knows pls write to me,,,
   
  kavitha


Gabriel Genellina <[EMAIL PROTECTED]> wrote:  En Mon, 19 Feb 2007 08:02:29 
-0300, kavitha thankaian 
escribió:

> Hi,
> i have a file test.txt and it contains a list of strings say,,,
> "a","b","c","d","a1","b1","c1","d1","a2","b2","c2","d2",
> i would like to write the file as
> "a","b","c","d"
> "a1","b1","c1","d1
> "a2","b2","c2","d2"
> and would like to delete the comma at the end.

Not enough info...
Does the input file contain only one line, or many lines?
Always exactly 12 items? Including a trailing , ?

The following may work for 12 items. Use the csv module to read the file:

import csv
reader = csv.reader(open("test.txt", "r"))
writer = csv.writer(open("output.txt", "w"))
for row in reader:
writer.writerow(row[:4])
writer.writerow(row[4:8])
writer.writerow(row[8:])

-- 
Gabriel Genellina

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



-
 Here’s a new way to find what you're looking for - Yahoo! Answers -- 
http://mail.python.org/mailman/listinfo/python-list

Re: The Python interactive interpreter has no command history

2007-02-26 Thread ThomasC
Thank you a lot!

I will try add readline library in my system.
Thank you.

On 2月16日, 上午1時13分, Laurent Rahuel <[EMAIL PROTECTED]> wrote:
> Hi,
>
> You need to have readline installed.
>
> Laurent
>
> ThomasCwrote:



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

newbie question(file-delete trailing comma)

2007-02-26 Thread kavitha thankaian
hi,
   
  i have a file which has the contents as follows:
   
  a,b,c,d,
  a1,b1,c1,d1,
  a2,b2,c2,d2,
   
  i would like to delete all the trailing commas,,
   
  if someoneknows pls help me,,
   
  kavitha


-
 Here’s a new way to find what you're looking for - Yahoo! Answers -- 
http://mail.python.org/mailman/listinfo/python-list

Re: newbie question(file-delete trailing comma)

2007-02-26 Thread Mohammad Tayseer
in_file = open('in.txt')
out_file = open('out.txt', 'w')
for line in in_file:
print >> out_file, line.strip(',')

kavitha thankaian <[EMAIL PROTECTED]> wrote: hi,
   
  i have a file which has the contents as follows:
   
  a,b,c,d,
  a1,b1,c1,d1,
  a2,b2,c2,d2,
   
  i would like to delete all the trailing commas,,
   
  if someoneknows pls help me,,
   
  kavitha
 

-
  Here’s a new way to find what you're looking for - Yahoo! Answers -- 
http://mail.python.org/mailman/listinfo/python-list

 
-
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: newbie question(file-delete trailing comma)

2007-02-26 Thread Robin Becker
kavitha thankaian wrote:
> hi,
>
>   i have a file which has the contents as follows:
>
>   a,b,c,d,
>   a1,b1,c1,d1,
>   a2,b2,c2,d2,
>
>   i would like to delete all the trailing commas,,
>
>   if someoneknows pls help me,,
>
>   kavitha
..

I often use sed for such small problems.

c:\tmp>cat ex.txt
a,b,c,d,
a1,b1,c1,d1,
a2,b2,c2,d2,

c:\tmp>sed -e"s/,$//" ex.txt
a,b,c,d
a1,b1,c1,d1
a2,b2,c2,d2

c:\tmp>

that doesn't involve python of course. I recommend one of the many tutorial 
introductions to python if the problem requires its use.
-- 
Robin Becker

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


Re: Help Required for Choosing Programming Language

2007-02-26 Thread sturlamolden
On Feb 24, 7:04 pm, Thomas Bartkus <[EMAIL PROTECTED]> wrote:

> Most user apps. require 95% of coding effort to provide a usable user
> interface and 5% effort on the algorithmic meat.  The "afterwards" you
> allude to. So why do we still endure so much programming effort on the
> unimportant part?

> Why should a programmer waste even so much as 10% of his effort to throw
> together a standard interface with ordinary textboxes, labels, and option
> buttons?  Over and over again?

That is why at least two modern GUI toolkits (Microsoft's 'avalon' and
GTK with GLADE) export the GUI as an XML-resource from a graphical GUI
designer. It then takes only a line of code to import the GUI and
another to register the event handlers.







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


Re: Help on object scope?

2007-02-26 Thread Duncan Booth
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

> You can interact just fine, just qualify the objects with the module 
> names. So in q, you need to use p.r instead of just r.

No. When p.py is being run as a script, the module you need to access is 
__main__.

Much better to put the globals into a separate module created specifically 
to hold the global variables rather than having them in something which 
might or might not be the main script.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pep 3105: the end of print?

2007-02-26 Thread Neil Cerutti
On 2007-02-23, I V <[EMAIL PROTECTED]> wrote:
> On Tue, 20 Feb 2007 10:46:31 -0800, Beliavsky wrote:
>> I think the C and C++ committees also take backwards
>> compatibility seriously, in part because they know that
>> working programmers will ignore them if they break too much
>> old code.
>
> While that's true, C++ compiler vendors, for example, take
> backwards compatibility significantly less seriously, it seems
> to me. 

Compiler vendors usually take care of their customers with
compiler switches that enable backwards compatibility.

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


[OT] python notation in new NVIDIA architecture

2007-02-26 Thread Daniel Nogradi
Something funny:

The new programming model of NVIDIA GPU's is called CUDA and I've
noticed that they use the same __special__ notation for certain things
as does python. For instance their modified C language has identifiers
such as __device__, __global__, __shared__, etc. Is it a coincidence?
Probably it is. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] python notation in new NVIDIA architecture

2007-02-26 Thread James Stroud
Daniel Nogradi wrote:
> Something funny:
> 
> The new programming model of NVIDIA GPU's is called CUDA and I've
> noticed that they use the same __special__ notation for certain things
> as does python. For instance their modified C language has identifiers
> such as __device__, __global__, __shared__, etc. Is it a coincidence?
> Probably it is. :)

Cuda is usually taken as short for "barracuda", a fish. Fish have been 
known to slither under the right circumstances. Perhaps this is the link?

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


comp post

2007-02-26 Thread john smith
comp post
-- 
http://mail.python.org/mailman/listinfo/python-list


a=b change b a==b true??

2007-02-26 Thread rstupplebeen
I do not have a clue what is happening in the code below.

>>> a=[[2,4],[9,3]]
>>> b=a
>>> [map(list.sort,b)]
[[None, None]]
>>> b
[[2, 4], [3, 9]]
>>> a
[[2, 4], [3, 9]]

I want to make a copy of matrix a and then make changes to the
matrices separately.  I assume that I am missing a fundamental
concept.  Any help would be appreciated.

Rob Stupplebeen

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


Re: a=b change b a==b true??

2007-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> I do not have a clue what is happening in the code below.
> 
 a=[[2,4],[9,3]]
 b=a
 [map(list.sort,b)]
> [[None, None]]
 b
> [[2, 4], [3, 9]]
 a
> [[2, 4], [3, 9]]
> 
> I want to make a copy of matrix a and then make changes to the
> matrices separately.  I assume that I am missing a fundamental
> concept.  Any help would be appreciated.


You are missing that the operation 

b=a

is not a copying, but a mere name-binding. The object that a points to now
is also pointed at by b. 

If you need copies, use the copy-module, with it's method deepcopy.

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


Re: a=b change b a==b true??

2007-02-26 Thread Chris Mellon
On 26 Feb 2007 05:50:24 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I do not have a clue what is happening in the code below.
>
> >>> a=[[2,4],[9,3]]
> >>> b=a
> >>> [map(list.sort,b)]
> [[None, None]]
> >>> b
> [[2, 4], [3, 9]]
> >>> a
> [[2, 4], [3, 9]]
>
> I want to make a copy of matrix a and then make changes to the
> matrices separately.  I assume that I am missing a fundamental
> concept.  Any help would be appreciated.
>

this:
>>> b=a

does not make a copy. It binds the name b to the same object that is
bound to the name a. If you want a copy, ask for a copy.

>>> a = [1,2]
>>> import copy
>>> b = copy.copy(a) #shallow copy
>>> a.append(3)
>>> a,b
([1, 2, 3], [1, 2])
>>>


You may need to do something else depending on exactly what copy
semantics you want, read the docs on the copy module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] python notation in new NVIDIA architecture

2007-02-26 Thread Daniel Nogradi
> > Something funny:
> >
> > The new programming model of NVIDIA GPU's is called CUDA and I've
> > noticed that they use the same __special__ notation for certain things
> > as does python. For instance their modified C language has identifiers
> > such as __device__, __global__, __shared__, etc. Is it a coincidence?
> > Probably it is. :)
>
> Cuda is usually taken as short for "barracuda", a fish. Fish have been
> known to slither under the right circumstances. Perhaps this is the link?

Wow! How is it that I didn't think about this before?! Thanks a million!
-- 
http://mail.python.org/mailman/listinfo/python-list


Copy a module build to another machine

2007-02-26 Thread bg_ie
Hi,

I have downloaded the source for PyXML-0.8.4, which has no binaries
available for Python 2.5. Therefore I built it myself doing something
like this -

python2.5 setup.py build
python2.5 setup.py install

having installed cygwin (with gcc). Now lets say I'd like to install
PyXML-0.8.4 on a number of other machines running the same os, what
files would I need to copy, and to where, in order to install PyXML
with just the line -

python2.5 setup.py install

In other words, I don't want to have to install cygwin on all these
machines and build for each machine. Instead I want to create a simple
install.

Thanks for your help,

Barry.

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


Re: a=b change b a==b true??

2007-02-26 Thread Philipp Pagel
[EMAIL PROTECTED] wrote:
> I do not have a clue what is happening in the code below.

> >>> a=[[2,4],[9,3]]
> >>> b=a
> >>> [map(list.sort,b)]
> [[None, None]]
> >>> b
> [[2, 4], [3, 9]]
> >>> a
> [[2, 4], [3, 9]]

> I want to make a copy of matrix a and then make changes to the
> matrices separately.  I assume that I am missing a fundamental
> concept.

The concept you are missing is the fact that b = a makes b another name
for your nested list. As you correctly stated you really want a copy.
This will do what you want:

>>> import copy
>>> a=[[2,4],[9,3]]
>>> b = copy.deepcopy(a)
>>> [map(list.sort,b)]
[[None, None]]
>>> a
[[2, 4], [9, 3]]
>>> b
[[2, 4], [3, 9]]

cu
Philipp

-- 
Dr. Philipp Pagel  Tel. +49-8161-71 2131
Dept. of Genome Oriented BioinformaticsFax. +49-8161-71 2186
Technical University of Munich
http://mips.gsf.de/staff/pagel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a=b change b a==b true??

2007-02-26 Thread bayer . justin
If you want to copy lists, you do it by using the [:] operator. e.g.:

>>> a = [1,2]
>>> b = a[:]
>>> a
[1, 2]
>>> b
[1, 2]
>>> b[0] = 2
>>> a
[1, 2]
>>> b
[2, 2]

If you want to copy a list of lists, you can use a list comprehension
if you do not want to use the copy module:

>>> a = [[1,2],[3,4]]
>>> b = [i[:] for i in a]
>>> a
[[1, 2], [3, 4]]
>>> b
[[1, 2], [3, 4]]
>>> b[0][0] = "foo"
>>> a
[[1, 2], [3, 4]]
>>> b
[['foo', 2], [3, 4]]

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


Re: The Python interactive interpreter has no command history

2007-02-26 Thread Paul Boddie
On 16 Feb, 11:40, Alan Franzoni
<[EMAIL PROTECTED]> wrote:
> Il Thu, 15 Feb 2007 15:14:00 -0200, Eduardo "EdCrypt" O. Padoan ha scritto:
>
> > Are you using Ubuntu? The last comes with 2.4.x and 2.5. This only
> > occurs on 2.5. This happens when you compile Python with libreadline
> > installed, AFAIK.
>
> I'm on Edgy and command history works well both with 2.4 and 2.5 with my
> config. If it's really an Edgy glitch, it must be configuration-related!

I guess it depends on how one is building the software. According to
the package information [1] libreadline5 is stated as a dependency, so
if one uses the Debian tools to make a package from the sources (plus
the diffs), one should get complaints about missing dependencies
rather than inadvertently getting an installable version of Python
with broken command history support.

Paul

[1] http://packages.ubuntu.com/edgy/python/python2.5

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


Re: Copy a module build to another machine

2007-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> Hi,
> 
> I have downloaded the source for PyXML-0.8.4, which has no binaries
> available for Python 2.5. Therefore I built it myself doing something
> like this -
> 
> python2.5 setup.py build
> python2.5 setup.py install
> 
> having installed cygwin (with gcc). Now lets say I'd like to install
> PyXML-0.8.4 on a number of other machines running the same os, what
> files would I need to copy, and to where, in order to install PyXML
> with just the line -
> 
> python2.5 setup.py install
> 
> In other words, I don't want to have to install cygwin on all these
> machines and build for each machine. Instead I want to create a simple
> install.

I'm not sure if that really works out. You can create eggs as distribution
format if you ahve setuptools installed like this:

easy_install-2.5 .

in the PyXML-dir.

This should create an egg that you then can install on all other machines
using

easy_install-2.5 

However, given that you used the GCC, I doubt you can really omit cygwin.

If you do things with the mingw though, it might work out.

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


Re: a=b change b a==b true??

2007-02-26 Thread rstupplebeen
All,
It works great now.  Thank you for all of your incredibly quick
replies.
Rob

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


wxPython - 2 x foldpanelbar with tree...

2007-02-26 Thread w.p.
Hello!
I have some trouble with my GUI. I have left panel with foldpanelbar,
but i need one item but not collapsed - simple button. I split my left
panel into two foldpanelbars with one button between.
But a have trouble...
Sorry for english :/


Simple code:

#--
import sys
import wx


import  wx.html as  html
import wx.lib.foldpanelbar as fpb
import os
import sys

ID_New  = wx.NewId()
ID_Exit = wx.NewId()


#--
class MyMDIChildFrame(wx.MDIChildFrame):
#--
def __init__(self,parent,id,name=""):
  wx.MDIChildFrame.__init__(self,parent, id, name)
  self.InitGUI()

 
#--
def InitGUI(self):
 
#--
  self.mainSplitter = wx.SplitterWindow(self,  -1,
style=wx.SP_NOBORDER)
  self.infoViewer = html.HtmlWindow(self.mainSplitter, -1,
style=wx.NO_FULL_REPAINT_ON_RESIZE)
  #self.infoViewer.LoadPage("http://wxwidgets.org/manuals/2.5.4/
wx_wxbutton.html")
  self.infoViewer.SetPage("Here is some formatted
text loaded from a string.")
  self.leftPanel = wx.Panel(self.mainSplitter)
  self.CreateFoldPanel()
  self.mainSplitter.Initialize(self.infoViewer)
  self.mainSplitter.SplitVertically(self.leftPanel,
self.infoViewer, 180)

 
#--
def CreateFoldPanel(self):
 
#--

  # foldpanel #1
  self.foldPanel1 = fpb.FoldPanelBar(self.leftPanel, -1,
wx.DefaultPosition, wx.Size(-1,-1), fpb.FPB_DEFAULT_STYLE,
fpb.FPB_SINGLE_FOLD)
  self.bs = wx.BoxSizer(wx.VERTICAL)
  self.leftPanel.SetSizer(self.bs)
  self.leftPanel.SetBackgroundColour(wx.BLACK)

  item = self.foldPanel1.AddFoldPanel("Documents",
collapsed=False)
  item.SetBackgroundColour(wx.RED)
  button1 = wx.Button(item, wx.ID_ANY, "In")
  button2 = wx.Button(item, wx.ID_ANY, "Out")
  self.foldPanel1.AddFoldPanelWindow(item, button1)
  self.foldPanel1.AddFoldPanelWindow(item, button2)

  item = self.foldPanel1.AddFoldPanel("Projects", collapsed=False)
  item.SetBackgroundColour(wx.BLUE)
  button1 = wx.Button(item, wx.ID_ANY, "Name")
  button2 = wx.Button(item, wx.ID_ANY, "Type")
  button3 = wx.Button(item, wx.ID_ANY, "Data")
  self.foldPanel1.AddFoldPanelWindow(item, button1)
  self.foldPanel1.AddFoldPanelWindow(item, button2)
  self.foldPanel1.AddFoldPanelWindow(item, button3)

  item = self.foldPanel1.AddFoldPanel("Contacts", collapsed=False)
  item.SetBackgroundColour(wx.CYAN)
  button1 = wx.Button(item, wx.ID_ANY, "Name")
  button2 = wx.Button(item, wx.ID_ANY, "Mail")
  button3 = wx.Button(item, wx.ID_ANY, "City")
  self.foldPanel1.AddFoldPanelWindow(item, button1)
  self.foldPanel1.AddFoldPanelWindow(item, button2)
  self.foldPanel1.AddFoldPanelWindow(item, button3)

  self.bs.Add(self.foldPanel1, 0, wx.EXPAND)

  # button
  button1 = wx.Button(self.leftPanel, wx.ID_ANY, "Calendar")
  self.bs.Add(button1, 0, wx.ALL|wx.EXPAND, 4)

  # foldpanel #2
  self.foldPanel2 = fpb.FoldPanelBar(self.leftPanel, -1,
wx.DefaultPosition, wx.Size(-1,-1), fpb.FPB_DEFAULT_STYLE,
fpb.FPB_SINGLE_FOLD)
  item = self.foldPanel2.AddFoldPanel("Treenote", collapsed=True)
  item.SetBackgroundColour(wx.GREEN)
  self.tree = wx.TreeCtrl(item, wx.ID_ANY, wx.DefaultPosition,
wx.DefaultSize,wx.TR_HAS_BUTTONS| wx.TR_EDIT_LABELS|
wx.TR_HIDE_ROOT)#| wx.TR_MULTIPLE#| wx.TR_HIDE_ROOT)
  self.foldPanel2.AddFoldPanelWindow(item, self.tree)
  self.LoadTree()
  self.bs.Add(self.foldPanel2, 0, wx.EXPAND)

  self.foldPanel1.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
  self.foldPanel2.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
  self.bs.Fit(self)
  self.bs.Layout()
  self.foldPanel1.Layout()
  self.foldPanel2.Layout()
 
#--
def OnPressCaption(self, event):
 
#--
  self.bs.Layout()
  event.Skip()

 
#--
def LoadTree(self):
 
#--
  self.root = self.tree.AddRoot("The Root Item")
  for x in range(15):
child = self.tree.AppendItem(self.root, "Test item %d" % x)
for y in range(5):
  last = self.tree.AppendItem(child, "test item %d-%s" % (x,
chr(ord("a")+y)))
  for z in range(5):
item = self.tree.AppendItem(last,  "t

Python / Socket speed

2007-02-26 Thread [EMAIL PROTECTED]
Seems like sockets are about 6 times faster on OpenSUSE than on
Windows XP in Python.

http://pyfanatic.blogspot.com/2007/02/socket-performance.html

Is this related to Python or the OS?

/MSkou

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


Re: newbie question(file-delete trailing comma)

2007-02-26 Thread kavitha thankaian
the input file what i have is  already opened with write mode.
  say i have a file input.txt which has 
   
  a,b,c,d,
   
  and i need the output also in the same input.txt,,ie., the trailing comma in 
the input.txt file should be deleted,,,i dont need a file output.txt,,,
   
  is there a way??
   
  kavitha

Mohammad Tayseer <[EMAIL PROTECTED]> wrote:
  ok, it should be
--
import sys

in_file = open(sys.argv[1])
out_file = open(sys.argv[2], 'w')

for line in in_file:
print >> out_file, line.strip().strip(',')

--
strip(',') will remove the ',' char from the beginning & end of the string, not 
the middle. empty strip() will remove whitespaces from the beginning & end of 
the string

I hope this solves your problem

kavitha thankaian <[EMAIL PROTECTED]> wrote:hi
   
  i would like to have the output as follows:
   
  a,b,c,d
  a1,b1,c1,d1
  a2,b2,c2,d2
   
  i would like to delete only the comma at the end and not the commas inbetween.
   
  thanks,,,




-
  Any questions? Get answers on any topic at Yahoo! Answers. Try it now.


-
 Here’s a new way to find what you're looking for - Yahoo! Answers -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python / Socket speed

2007-02-26 Thread Richard Brodie

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Seems like sockets are about 6 times faster on OpenSUSE than on
> Windows XP in Python.
>
> http://pyfanatic.blogspot.com/2007/02/socket-performance.html
>
> Is this related to Python or the OS?

It's 6 times faster even when not using Python, so what do you think?
It's probably 'just' tuning though, the default window sizes are in the
same ratio. 


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


How to delete PyGTK ComboBox entries?

2007-02-26 Thread Maël Benjamin Mettler
Hello list!

I need to repopulate PyGTK ComboBox on a regular basis. In order to do
so I have to remove all the entries and then add the new ones. I tried
to remove all entries like that:

def clear_comboboxes(boxreference):
try:
while True:
boxreference.remove_text(0)
except:
pass

And then repopulate by iterating through the list of desired entries and
calling ComboBox.append_text(text). It works, but is painfully
slw! Is there a faster way to completely change the entries in a
ComboBox, by using an all erase method or overwriting the container
object? I haven't found anything with google, as the searches are too
ambiguous to yield usable results.

Thanks,

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


Re: Python / Socket speed

2007-02-26 Thread Paul Boddie
On 26 Feb, 15:54, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Seems like sockets are about 6 times faster on OpenSUSE than on
> Windows XP in Python.
>
> http://pyfanatic.blogspot.com/2007/02/socket-performance.html
>
> Is this related to Python or the OS?

>From the output:

> TCP window size: 8.00 KByte (default)
> TCP window size: 49.4 KByte (default)

I don't pretend to be an expert on TCP/IP, but might the window size
have something to do with it?

Paul

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


Interactive os.environ vs. os.environ in script

2007-02-26 Thread boris . smirnov
Hi there,

I have a problem with setting environment variable in my script that
uses qt library. For this library I have to define a path to tell the
script whre to find it.

I have a script called "shrink_bs_070226" that looks like this:
**
import sys, re, glob, shutil
import os

os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

from qt import *
***

When I run this script I get this error:


> python shrink_bs_070226.py
Traceback (most recent call last):
  File "shrink_bs_070226.py", line 25, in ?
from qt import *
  File "/path/Linux/python/rh_linux/lib/python2.2/site-packages/
qt.py", line 46, in ?
import libsip
ImportError: libadamsqt.so: cannot open shared object file: No such
file or directory

What is important here that when I set this variable interactive in
python session, there is no problem with import.

> python
Python 2.2.3 (#1, Aug  8 2003, 08:44:02)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os

>>> import shrink_bs_070226
Traceback (most recent call last):
  File "", line 1, in ?
  File "shrink_bs_070226.py", line 25, in ?
from qt import *
ImportError: No module named qt

>>> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

>>> import shrink_bs_070226
>>>

Could anybody explain me the logic here? Am I missing something?
Thank in advance.
Rg
Boris

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


Re: convert python scripts to exe file

2007-02-26 Thread Larry Bates
Eric CHAO wrote:
> I know py2exe can make an exe file. But python runtime dll is still
> there. How can I combine the dll file into the exe, just make one
> file?
> 
> Thanks.

You can use the bundle= parameter to get "less" files, but you can't
get to only 1 because you need mscvr71.dll and w9xpopen.exe at a
minimum as external files.  If you want to have only 1 .EXE to
distribute, use Inno Installer.  Your users will thank you for
having a proper installer, uninstaller.

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


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> On Feb 26, 6:32 am, Tech HR <[EMAIL PROTECTED]> wrote:
> > Our
> > website is currently a LAMP appication with P=Python. We are looking for
> > bright motivated people who know or are willing to learn Python and/or
> > Linux, Apache and MySQL system administration skills. (And if you want
> > to convince us that we should switch over to Postgres, we're willing to
> > listen.)
> This is more out of curiosity, but does it mean that you wouldn't be
> willing to listen about a switch from Python to Lisp?

No, it doesn't mean that.  In fact, there is a significant faction in 
the technical staff (including the CTO) who would like nothing better 
than to be able to use Lisp instead of Python.  But we have some pretty 
compelling reasons to stick with Python, not least of which is that it 
is turning out to be very hard to find Lisp programmers.  (Actually, 
it's turning out to be hard to find Python programmers too, but it's 
easier to train a Java programmer or a Perler on Python than Lisp.  We 
also have fair bit of infrastructure built up in Python at this point.)

But we're a very young company (barely six months old at this point) so 
we're willing to listen to most anything at this point.  (We're using 
Darcs for revision control.  Haskell, anyone?)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CSV(???)

2007-02-26 Thread Neil Cerutti
On 2007-02-24, David C  Ullrich <[EMAIL PROTECTED]> wrote:
> On 23 Feb 2007 19:13:10 +0100, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
>>On 2007-02-23, David C  Ullrich <[EMAIL PROTECTED]> wrote:
>>> Is there a csvlib out there somewhere?
>>>
>>> And/or does anyone see any problems with
>>> the code below?
>>>
>>> [...]
>>>
>>> (Um: Believe it or not I'm _still_ using python 1.5.7. So
>>> comments about iterators, list comprehensions, string
>>> methods, etc are irrelevent. Comments about errors in the
>>> algorithm would be great. Thanks.)
>>
>>Two member functions of indexedstring are not used: next and
>>lookahead. __len__ and __getitem__ appear to serve no real
>>purpose.
>
> Hey, thanks! I didn't realize that using an object with methods
> that were never called could cause an algorithm to fail...
> shows how much I know.

Sorry I couldn't provide the help you wanted.

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


ez_setup.py

2007-02-26 Thread Nader Emami
L.S.,

I have installed locally Python-2.4.4 without any problem. Then I would 
install the "ez_setup.py" to be able using of "easy_install" tool, but I 
get the next error:

%python ez_setup.py
Traceback (most recent call last):
   File "ez_setup.py", line 223, in ?
 main(sys.argv[1:])
   File "ez_setup.py", line 155, in main
 egg = download_setuptools(version, delay=0)
   File "ez_setup.py", line 111, in download_setuptools
 import urllib2, shutil
   File "/usr/people/emami/lib/python2.4/urllib2.py", line 108, in ?
 import cookielib
   File "/usr/people/emami/lib/python2.4/cookielib.py", line 35, in ?
 from calendar import timegm
   File "/usr/people/emami/calendar.py", line 23, in ?
 import pygtk
ImportError: No module named pygtk

I don't understand what is the problem! Could somebody tell me what I 
have to do to solve it?

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


Re: ez_setup.py

2007-02-26 Thread Tim Golden
Nader Emami wrote:
> L.S.,
> 
> I have installed locally Python-2.4.4 without any problem. Then I would 
> install the "ez_setup.py" to be able using of "easy_install" tool, but I 
> get the next error:
> 
> %python ez_setup.py
> Traceback (most recent call last):
>File "ez_setup.py", line 223, in ?
>  main(sys.argv[1:])
>File "ez_setup.py", line 155, in main
>  egg = download_setuptools(version, delay=0)
>File "ez_setup.py", line 111, in download_setuptools
>  import urllib2, shutil
>File "/usr/people/emami/lib/python2.4/urllib2.py", line 108, in ?
>  import cookielib
>File "/usr/people/emami/lib/python2.4/cookielib.py", line 35, in ?
>  from calendar import timegm
>File "/usr/people/emami/calendar.py", line 23, in ?
>  import pygtk
> ImportError: No module named pygtk
> 
> I don't understand what is the problem! Could somebody tell me what I 
> have to do to solve it?


You have a module called "calendar" in your user directory
/usr/people/emami/calendar.py which is shadowing the stdlib
calendar module -- which doesn't get used much so you've
probably never noticed. Either rename your local one or take
your home folder off the Python path... at least for long enough
for ez_setup to do its stuff.

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


ctypes and using c_char_p without NULL terminated string

2007-02-26 Thread kpoman
Hi to all,
I am trying to use some dll which needs some data types that I can't
find in python. From the dll documentation, I am trying to use this:

HRESULT IMKWsq::Compress  (  [in] VARIANTrawImage,
  [in] shortsizeX,
  [in] shortsizeY,
  [out] VARIANT *wsqImage,
  [out, retval] short *result
 )


I then tried using the following python code to achieve this:


# CODE START

import os
import sys
from ctypes import *
import win32con

MKWSQ_OK= 0
MKWSQ_MEMORY_ALLOC_ERROR= (MKWSQ_OK+200)  #// Memory allocation error
MKWSQ_MEMORY_FREE_ERROR = (MKWSQ_OK+499)  #// Memory disallocation
MKWSQ_INPUT_FORMAT_ERROR= (MKWSQ_OK+700)  #// Error in the format of
the compressed data
MKWSQ_NULL_INPUT_ERROR  = (MKWSQ_OK+5000) #// input buffer is NULL
MKWSQ_ROWSIZE_ERROR = (MKWSQ_OK+5003) #// Number of rows in 
the
image must be betwen 64 and 4000
MKWSQ_COLSIZE_ERROR = (MKWSQ_OK+5004) #// Number of columns 
in the
image must be between 64 and 4000
MKWSQ_RATIO_ERROR   = (MKWSQ_OK+5005) #// The minimum 
compression
ratio value is 1.6 and the maximum 80, usually 12 for 15 real
MKWSQ_INPUT_PTR_ERROR   = (MKWSQ_OK+5006) #// compress_buffer must be
the address of a char pointer
MKWSQ_OUTPUTSIZE_ERROR  = (MKWSQ_OK+5007) #// compressed_filesize must
be the address of a long
MKWSQ_RATIO_PTR_ERROR   = (MKWSQ_OK+5008) #// ratio_achieved must be
the address of a float
MKWSQ_NULL_OUTPUT_ERROR = (MKWSQ_OK+6000) #// compress_buffer has a
NULL value
MKWSQ_OUTPUT_ROWSIZE_ERROR  = (MKWSQ_OK+6002) #// rows must be the
adress of an int
MKWSQ_OUTPUT_COLSIZE_ERROR  = (MKWSQ_OK+6003) #// cols must be the
adress of an int
MKWSQ_OUTPUT_SIZE_ERROR = (MKWSQ_OK+6006) #// output_filesize must be
the adress of a long
MKWSQ_OUTPUT_PTR_ERROR  = (MKWSQ_OK+6007) #// output_buffer must be
the adress of a char*
MKWSQ_DONGLE_ERROR  = (MKWSQ_OK+9045) #// dongle or dongle 
driver is
not present
MKWSQ_DONGLE_TYPE_ERROR = (MKWSQ_OK+9046) #// the dongle licence does
not authorize to use the function
MKWSQ_LICENSE_ERROR = (MKWSQ_OK+133)  #// invalid or 
nonexistent
software license

#Cargo la libreria e memoria
_wsq = cdll.mkwsq

def MKWsq_compress( iBuffer, iFreeBufferOption, iRows, iCols, iRatio,
oCompressedBuffer, oCompressedFileSize, oRatioAchieved):
''' Esta es la funcion de compresion '''
return _wsq.MKWsq_compress(iBuffer, iFreeBufferOption, iRows, iCols,
iRatio, 0, 0, byref(oCompressedBuffer), byref(oCompressedFileSize),
byref(oRatioAchieved))

def MKWsq_decompress(iCompressedBuffer, oRows, oCols, oFileSize,
oBuffer):
'''Funcion que se encarga de descomprimir la huella'''
return _wsq.MKWsq_decompress(iCompressedBuffer, 0, oRows, oCols,
0, 0, oFileSize, c_char_p(oBuffer))

def MKWsq_free(iCompressedBuffer):
''' Funcion para liberar la memoria alocada '''
return _wsq.MKWsq_free(iCompressedBuffer)


if __name__ == '__main__':
'''test del modulo'''
#Prueba de compresion desde RAW
fh=open("test.raw","r")
imRaw=fh.read()
fh.close()

fSize=c_long()
ratio=c_float(12.0)
ratioAchieved=c_float()

#imWSQ=c_ubyte(win32con.NULL)   #declara la variable como NULL

imWSQ=c_char_p('\x00'*(20*1024))

status=MKWsq_compress(imRaw,
1,416,416,ratio,imWSQ,fSize,ratioAchieved)

print "Status=%d\tSize=%d bytes   Ratio=%f"%
(status,fSize.value,ratioAchieved.value)

print repr(imWSQ)
print len(imWSQ.value[:10])

filito=open("file.wsq","wb")
filito.write(imWSQ[:fSize.value])
filito.close()

# CODE END

which gives me the following result:

c:\>python MKWsq_new.py
Status=0Size=12735 bytes   Ratio=13.589006
c_char_p('\xff\xa0\xff\xa8')
4
Traceback (most recent call last):
  File "MKWsq_new.py", line 65, in ?
filito.write(imWSQ[:fSize.value])
TypeError: unsubscriptable object

c:\>




the problem is on this result line:
c_char_p('\xff\xa0\xff\xa8')

because of the c_char_p spec, it is a \x00 (null) character terminated
string, but my result has some null characters on it. Which ctype
should I then use to be able to retrieve the result from python ?

Thanks in advance,

Patricio

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


Re: How to delete PyGTK ComboBox entries?

2007-02-26 Thread Osmo Salomaa
ma, 2007-02-26 kello 16:08 +0100, Maël Benjamin Mettler kirjoitti:
> I need to repopulate PyGTK ComboBox on a regular basis. In order to do
> so I have to remove all the entries and then add the new ones.

> And then repopulate by iterating through the list of desired entries and
> calling ComboBox.append_text(text). It works, but is painfully
> slw!

model = combo_box.get_model()
combo_box.set_model(None)
model.clear()
for entry in desired_entries:
model.append([entry])
combo_box.set_model(model)

model.append is essentially the same as combo_box.append_text. Setting
the model to None before making changes to it speeds things at least in
the case of tree views. I'm not sure if it does much with combo boxes.
If you experince speed issues with combo boxes you're either doing
something very wrong or you have so many entries that you ought to be
using a tree view instead.

-- 
Osmo Salomaa

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

Re: Interactive os.environ vs. os.environ in script

2007-02-26 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> Hi there,
> 
> I have a problem with setting environment variable in my script that
> uses qt library. For this library I have to define a path to tell the
> script whre to find it.
> 
> I have a script called "shrink_bs_070226" that looks like this:
> **
> import sys, re, glob, shutil
> import os
> 
> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
> 
> from qt import *
> ***
> 
> When I run this script I get this error:
> 
> 
>> python shrink_bs_070226.py
> Traceback (most recent call last):
>   File "shrink_bs_070226.py", line 25, in ?
> from qt import *
>   File "/path/Linux/python/rh_linux/lib/python2.2/site-packages/
> qt.py", line 46, in ?
> import libsip
> ImportError: libadamsqt.so: cannot open shared object file: No such
> file or directory
> 
> What is important here that when I set this variable interactive in
> python session, there is no problem with import.
> 
>> python
> Python 2.2.3 (#1, Aug  8 2003, 08:44:02)
> [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 import os
> 
 import shrink_bs_070226
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "shrink_bs_070226.py", line 25, in ?
> from qt import *
> ImportError: No module named qt
> 
 os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
> 
 import shrink_bs_070226

> 
> Could anybody explain me the logic here? Am I missing something?

Until Python 2.4 a failed import could leave some debris which would make
you think a second import did succeed.

Try

>>> import os
>>> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
>>> import shrink_bs_070226 # I expect that to fail

in a fresh interpreter to verify that what you see is an artifact of your
test method.

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


SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread zefciu
I am trying to embed a c function in my python script for a first time.
 When I try to call it I get an error

SystemError: new style getargs format but argument is not a tuple

Guido said on some mailing list, that it is probably an effect of the
lack of METH_VARARGS in the functions' array, but it's ok in my source
code.  Here is the full code:

#include 

static PyObject * mandelpixel(PyObject *self, PyObject *args)
{
double z_real = 0, z_imag = 0, z_real2 = 0, z_imag2 = 0, c_real,
c_imag, bailoutsquare;
int iteration_number;
register int i;
PyObject coord;
if (!PyArg_ParseTuple(args, "Oid", &coord, &iteration_number,
&bailoutsquare))
return NULL;
if (!PyArg_ParseTuple(&coord, "dd", &c_real, &c_imag))
return NULL;



for(i = 1; i <= iteration_number; i++)
{
z_imag = 2 * z_real * z_imag + c_imag;
z_real = z_real2 - z_imag2 + c_real;
z_real2 = z_real * z_real;
z_imag2 = z_imag * z_imag;
if (z_real2 + z_imag2 > bailoutsquare)
return Py_BuildValue("i", i);
}
return Py_BuildValue("i", 0);
}

static PyMethodDef MandelcMethods[] =
{
{
"mandelpixel", mandelpixel, METH_VARARGS, "check the pixel for
Mandelbrot set"
},
{
NULL, NULL, 0, NULL
}
};

PyMODINIT_FUNC initmandelc(void)
{
(void) Py_InitModule ("mandelc", MandelcMethods);
}

int main(int argc, char **argv)
{
Py_SetProgramName(argv[0]);
Py_Initialize();
initmandelc();
return 0;
}

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


Re: The Python interactive interpreter has no command history

2007-02-26 Thread skip

> I will try add readline library in my system.

Thomas,

Once you have it installed here's an example of how to use it for command
history:

http://www.webfast.com/~skip/python/completions.py

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


Re: ez_setup.py

2007-02-26 Thread Nader Emami
Tim Golden wrote:
> Nader Emami wrote:
>> L.S.,
>>
>> I have installed locally Python-2.4.4 without any problem. Then I 
>> would install the "ez_setup.py" to be able using of "easy_install" 
>> tool, but I get the next error:
>>
>> %python ez_setup.py
>> Traceback (most recent call last):
>>File "ez_setup.py", line 223, in ?
>>  main(sys.argv[1:])
>>File "ez_setup.py", line 155, in main
>>  egg = download_setuptools(version, delay=0)
>>File "ez_setup.py", line 111, in download_setuptools
>>  import urllib2, shutil
>>File "/usr/people/emami/lib/python2.4/urllib2.py", line 108, in ?
>>  import cookielib
>>File "/usr/people/emami/lib/python2.4/cookielib.py", line 35, in ?
>>  from calendar import timegm
>>File "/usr/people/emami/calendar.py", line 23, in ?
>>  import pygtk
>> ImportError: No module named pygtk
>>
>> I don't understand what is the problem! Could somebody tell me what I 
>> have to do to solve it?
> 
> 
> You have a module called "calendar" in your user directory
> /usr/people/emami/calendar.py which is shadowing the stdlib
> calendar module -- which doesn't get used much so you've
> probably never noticed. Either rename your local one or take
> your home folder off the Python path... at least for long enough
> for ez_setup to do its stuff.
> 
> TJG
How can do the second solution, (take off the home from Python path)?

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


Re: Interactive os.environ vs. os.environ in script

2007-02-26 Thread boris . smirnov
On Feb 26, 4:32 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi there,
>
> > I have a problem with setting environment variable in my script that
> > uses qt library. For this library I have to define a path to tell the
> > script whre to find it.
>
> > I have a script called "shrink_bs_070226" that looks like this:
> > **
> > import sys, re, glob, shutil
> > import os
>
> > os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
>
> > from qt import *
> > ***
>
> > When I run this script I get this error:
>
> >> python shrink_bs_070226.py
> > Traceback (most recent call last):
> >   File "shrink_bs_070226.py", line 25, in ?
> > from qt import *
> >   File "/path/Linux/python/rh_linux/lib/python2.2/site-packages/
> > qt.py", line 46, in ?
> > import libsip
> > ImportError: libadamsqt.so: cannot open shared object file: No such
> > file or directory
>
> > What is important here that when I set this variable interactive in
> > python session, there is no problem with import.
>
> >> python
> > Python 2.2.3 (#1, Aug  8 2003, 08:44:02)
> > [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
>  import os
>
>  import shrink_bs_070226
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> >   File "shrink_bs_070226.py", line 25, in ?
> > from qt import *
> > ImportError: No module named qt
>
>  os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
>
>  import shrink_bs_070226
>
> > Could anybody explain me the logic here? Am I missing something?
>
> Until Python 2.4 a failed import could leave some debris which would make
> you think a second import did succeed.
>
> Try
>
> >>> import os
> >>> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
> >>> import shrink_bs_070226 # I expect that to fail
>
> in a fresh interpreter to verify that what you see is an artifact of your
> test method.
>
> Peter- Hide quoted text -
>
> - Show quoted text -

You are right:

 > python
Python 2.2.3 (#1, Aug  8 2003, 08:44:02)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import  os

>>> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

>>> import shrink_bs_070226
Traceback (most recent call last):
  File "", line 1, in ?
  File "shrink_bs_070226.py", line 25, in ?
from qt import *
ImportError: No module named qt
>>>

OK then I have to reformulate my question. :)

In my script I have a line with

os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

but this line didn't work.
But when I set this environment variable in Linux shell it works. Here
is a small example.

> python shrink_bs_070226.py
Traceback (most recent call last):
  File "shrink_bs_070226.py", line 25, in ?
from qt import *
  File "/path/Linux/python/rh_linux/lib/python2.2/site-packages/
qt.py", line 46, in ?
import libsip
ImportError: libadamsqt.so: cannot open shared object file: No such
file or directory

> setenv LD_LIBRARY_PATH /path/Linux/rh_linux

> python shrink_bs_070226.py

Starting Script "Shrinker" 

Why it's not working in script with command

os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

but in shell it works?

I hope it's understandable. :)
Thanks,
boris

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

zefciu wrote:
> I am trying to embed a c function in my python script for a first
> time. When I try to call it I get an error
>
> SystemError: new style getargs format but argument is not a tuple
>
> Guido said on some mailing list, that it is probably an effect of
> the lack of METH_VARARGS in the functions' array, but it's ok in my
> source code. Here is the full code:
>
> #include 
>
> static PyObject * mandelpixel(PyObject *self, PyObject *args) {
> double z_real = 0, z_imag = 0, z_real2 = 0, z_imag2 = 0, c_real,
> c_imag, bailoutsquare; int iteration_number; register int i;
> PyObject coord; if (!PyArg_ParseTuple(args, "Oid", &coord,
> &iteration_number, &bailoutsquare)) return NULL; if
> (!PyArg_ParseTuple(&coord, "dd", &c_real, &c_imag)) return NULL;
Is coord always tuple?

- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4wQB1LDUVnWfY8gRAtWsAKCavY85KUtoppRSj0uQTeVnmLu5UwCgyfk1
0c5fkRgKaejDja1YWdKkaTg=
=vMjd
-END PGP SIGNATURE-

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

Re: ez_setup.py

2007-02-26 Thread Tim Golden
Nader Emami wrote:
> Tim Golden wrote:
>> Nader Emami wrote:
>>> L.S.,
>>>
>>> I have installed locally Python-2.4.4 without any problem. Then I 
>>> would install the "ez_setup.py" to be able using of "easy_install" 
>>> tool, but I get the next error:
>>>
>>> %python ez_setup.py
>>> Traceback (most recent call last):
>>>File "ez_setup.py", line 223, in ?
>>>  main(sys.argv[1:])
>>>File "ez_setup.py", line 155, in main
>>>  egg = download_setuptools(version, delay=0)
>>>File "ez_setup.py", line 111, in download_setuptools
>>>  import urllib2, shutil
>>>File "/usr/people/emami/lib/python2.4/urllib2.py", line 108, in ?
>>>  import cookielib
>>>File "/usr/people/emami/lib/python2.4/cookielib.py", line 35, in ?
>>>  from calendar import timegm
>>>File "/usr/people/emami/calendar.py", line 23, in ?
>>>  import pygtk
>>> ImportError: No module named pygtk
>>>
>>> I don't understand what is the problem! Could somebody tell me what I 
>>> have to do to solve it?
>>
>> You have a module called "calendar" in your user directory
>> /usr/people/emami/calendar.py which is shadowing the stdlib
>> calendar module -- which doesn't get used much so you've
>> probably never noticed. Either rename your local one or take
>> your home folder off the Python path... at least for long enough
>> for ez_setup to do its stuff.
>>
>> TJG
> How can do the second solution, (take off the home from Python path)?

Depends on your setup. Since you're on *nix, I can't
test whether $HOME is automatically on sys.path (it
isn't on Win32). Are you running *in* /usr/people/emami?
If so, go somewhere else before you run ez_setup. Check
your PYTHONPATH env var; perhaps reset it before
running ez_setup. There are other more obscure possibilities
to do with things set in site.py but they're less likely.

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


Re: ez_setup.py

2007-02-26 Thread Tim Golden
Nader Emami wrote:

>>> How can do the second solution, (take off the home from Python path)?
>>
>> Depends on your setup. Since you're on *nix, I can't
>> test whether $HOME is automatically on sys.path (it
>> isn't on Win32). Are you running *in* /usr/people/emami?
>> If so, go somewhere else before you run ez_setup. Check
>> your PYTHONPATH env var; perhaps reset it before
>> running ez_setup. There are other more obscure possibilities
>> to do with things set in site.py but they're less likely.
>>
>> TJG
> I have a Linux and I don't have any PYTHONPTH variable, because if I run 
> the next command it returns nothig:
> 
> %env | grep -i pythonpath or
> %env | grep -i python

I'm no expert here, but I believe that Linux is
case-sensitive, so you'd need to do:

env | grep PYTHONPATH

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


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread John Nagle
Tech HR wrote:
> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] wrote:
>>This is more out of curiosity, but does it mean that you wouldn't be
>>willing to listen about a switch from Python to Lisp?
> 
> 
> No, it doesn't mean that.  In fact, there is a significant faction in 
> the technical staff (including the CTO) who would like nothing better 
> than to be able to use Lisp instead of Python.  But we have some pretty 
> compelling reasons to stick with Python, not least of which is that it 
> is turning out to be very hard to find Lisp programmers.

 As someone who knows both languages, I'd stay with Python, although
trying to do heavy number crunching in a naive interpreter may be a problem.

 That's a tough scheduling problem.  It took about a year for the
NetJets people to develop their application for it.

John Nagle

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


Re: Python / Socket speed

2007-02-26 Thread casevh
On Feb 26, 7:05 am, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> On 26 Feb, 15:54, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Seems like sockets are about 6 times faster on OpenSUSE than on
> > Windows XP in Python.
>
> >http://pyfanatic.blogspot.com/2007/02/socket-performance.html
>
> > Is this related to Python or the OS?
> >From the output:
> > TCP window size: 8.00 KByte (default)
> > TCP window size: 49.4 KByte (default)
>
> I don't pretend to be an expert on TCP/IP, but might the window size
> have something to do with it?
>
> Paul

Tuning the TCP window size will make a big difference with Windows XP
performance. I'm more curious about the original script. Either the
test was against the loopback address, or he has a very impressive
netork to sustain 1.8Gbit/s.

casevh

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


Re: message processing/threads

2007-02-26 Thread joncfoo
Thank you all for your input. I now have some new ways that I need to
look into and see what fits best.

Thanks once again,

Jonathan

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


Re: ez_setup.py

2007-02-26 Thread Tim Golden
Nader Emami wrote:
> Tim Golden wrote:
>> Nader Emami wrote:
>>
> How can do the second solution, (take off the home from Python path)?

 Depends on your setup. Since you're on *nix, I can't
 test whether $HOME is automatically on sys.path (it
 isn't on Win32). Are you running *in* /usr/people/emami?
 If so, go somewhere else before you run ez_setup. Check
 your PYTHONPATH env var; perhaps reset it before
 running ez_setup. There are other more obscure possibilities
 to do with things set in site.py but they're less likely.

 TJG
>>> I have a Linux and I don't have any PYTHONPTH variable, because if I 
>>> run the next command it returns nothig:
>>>
>>> %env | grep -i pythonpath or
>>> %env | grep -i python
>>
>> I'm no expert here, but I believe that Linux is
>> case-sensitive, so you'd need to do:
>>
>> env | grep PYTHONPATH
>>
>> TJG
> 'grep' with 'i' option can catch both of them. I have done with capital 
> letters also and the answer stays the same:
> %env | grep PYTHONPATH of %env | grep PTYTHON

OK. Keep copying to the list, please. As I said, I'm not
a *nix person (and I'm running here on Windows) so you'll
get a more informed and wider audience from c.l.py.

If there's no PYTHONPATH that means it's just down to
your system setup what goes on the path. Try (from
within the python interpreter):


import sys
for i in sys.path:
   print i



Do you see your home directory there?

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


Re: Python / Socket speed

2007-02-26 Thread John Nagle
Richard Brodie wrote:
> <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>Seems like sockets are about 6 times faster on OpenSUSE than on
>>Windows XP in Python.
>>
>>http://pyfanatic.blogspot.com/2007/02/socket-performance.html
>>
>>Is this related to Python or the OS?
> 
> 
> It's 6 times faster even when not using Python, so what do you think?
> It's probably 'just' tuning though, the default window sizes are in the
> same ratio. 

 Sockets and pipes are a terrible way to do local interprocess
communication, but it's what we've got.  The problem is that what you
want is a subroutine call, but what the OS gives you is an I/O operation.
If you want to see it done right, take a look at QNX messaging.  QNX
does everything, including I/O and networking, via its interprocess
communication message passing system.  There's the cost of one extra
copy for every I/O operation, but you don't notice it much in practice.
I've run 640x480x15FPSx24bits video through QNX messaging and only used
2% of an 1.5GHZ x86 CPU doing it.

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


Re: newbie question(file-delete trailing comma)

2007-02-26 Thread Mohammad Tayseer
kavitha thankaian <[EMAIL PROTECTED]> wrote:
> and i need the output also in the same input.txt

just add

import os
os.remove('in.txt')
os.rename('out.txt', 'in.txt')

 
-
Don't be flakey. Get Yahoo! Mail for Mobile and 
always stay connected to friends.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python / Socket speed

2007-02-26 Thread Paul Rubin
John Nagle <[EMAIL PROTECTED]> writes:
>  Sockets and pipes are a terrible way to do local interprocess
> communication, but it's what we've got.  The problem is that what you
> want is a subroutine call, but what the OS gives you is an I/O operation.

Using TCP sockets is ridiculous but Unix domain sockets aren't that
bad.  There's also mmap or shm.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interactive os.environ vs. os.environ in script

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

[EMAIL PROTECTED] wrote:
>
> OK then I have to reformulate my question. :)
>
> In my script I have a line with
>
> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'
>
> but this line didn't work. But when I set this environment variable
> in Linux shell it works. Here is a small example.
>
>> python shrink_bs_070226.py
> Traceback (most recent call last): File "shrink_bs_070226.py", line
> 25, in ? from qt import * File
> "/path/Linux/python/rh_linux/lib/python2.2/site-packages/ qt.py",
> line 46, in ? import libsip ImportError: libadamsqt.so: cannot open
> shared object file: No such file or directory
ld-elf.so reads environment variables when it was loaded.
It never reads environment variables again!
That you setting environment in the process does not make link-editor
to re-read environment variable and take effect.

To resolve the problem, you can try to add the path to sys.path.

- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4w6H1LDUVnWfY8gRAoI0AKCLikYsFU2N6aaOZFDd1L2KY8DjqACg3QQn
KsEEcrvpw1CktEkVCKe/ojk=
=EQG6
-END PGP SIGNATURE-

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

Re: How to delete PyGTK ComboBox entries?

2007-02-26 Thread Maël Benjamin Mettler
Hej!
> >
> > model = combo_box.get_model()
> > combo_box.set_model(None)
> > model.clear()
> > for entry in desired_entries:
> > model.append([entry])
> > combo_box.set_model(model)
> >
> > model.append is essentially the same as combo_box.append_text. Setting
> > the model to None before making changes to it speeds things at least in
> > the case of tree views. I'm not sure if it does much with combo boxes.
> > If you experince speed issues with combo boxes you're either doing
> > something very wrong or you have so many entries that you ought to be
> > using a tree view instead.
> >

Works like a charm. Thanks a lot!

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread zefciu
Thinker wrote:
> zefciu wrote:
>>> I am trying to embed a c function in my python script for a first
>>> time. When I try to call it I get an error
>>>
>>> SystemError: new style getargs format but argument is not a tuple
>>>
>>> Guido said on some mailing list, that it is probably an effect of
>>> the lack of METH_VARARGS in the functions' array, but it's ok in my
>>> source code. Here is the full code:

> Is coord always tuple?

Yes it is.  The script launches it with tuple and two numeric arguments.
 On the other hand when I try it in interactive mode with
mandelpixel((1,1), 1, 1) it segfaults, which I completely don't understand.

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


Re: ez_setup.py

2007-02-26 Thread Tim Golden
Nader Emami wrote:
> Tim Golden wrote:
>> Nader Emami wrote:
>>> Tim Golden wrote:
 Nader Emami wrote:

>>> How can do the second solution, (take off the home from Python 
>>> path)?
>>
>> Depends on your setup. Since you're on *nix, I can't
>> test whether $HOME is automatically on sys.path (it
>> isn't on Win32). Are you running *in* /usr/people/emami?
>> If so, go somewhere else before you run ez_setup. Check
>> your PYTHONPATH env var; perhaps reset it before
>> running ez_setup. There are other more obscure possibilities
>> to do with things set in site.py but they're less likely.
>>
>> TJG
> I have a Linux and I don't have any PYTHONPTH variable, because if 
> I run the next command it returns nothig:
>
> %env | grep -i pythonpath or
> %env | grep -i python

 I'm no expert here, but I believe that Linux is
 case-sensitive, so you'd need to do:

 env | grep PYTHONPATH

 TJG
>>> 'grep' with 'i' option can catch both of them. I have done with 
>>> capital letters also and the answer stays the same:
>>> %env | grep PYTHONPATH of %env | grep PTYTHON
>>
>> OK. Keep copying to the list, please. As I said, I'm not
>> a *nix person (and I'm running here on Windows) so you'll
>> get a more informed and wider audience from c.l.py.
>>
>> If there's no PYTHONPATH that means it's just down to
>> your system setup what goes on the path. Try (from
>> within the python interpreter):
>>
>> 
>> import sys
>> for i in sys.path:
>>   print i
>>
>> 
>>
>> Do you see your home directory there?
>>
>> TJG
> This is the result of the code:
> /usr/people/emami/lib/python24.zip
> /usr/people/emami/lib/python2.4
> /usr/people/emami/lib/python2.4/plat-linux2
> /usr/people/emami/lib/python2.4/lib-tk
> /usr/people/emami/lib/python2.4/lib-dynload
> /usr/people/emami/lib/python2.4/site-packages

(Sigh). Copying back to the list.

So, are you running in /usr/people/emami when
you're call ez_setup?

TJG

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

zefciu wrote:
> I am trying to embed a c function in my python script for a first
> time. When I try to call it I get an error
>
> SystemError: new style getargs format but argument is not a tuple
>
> Guido said on some mailing list, that it is probably an effect of
> the lack of METH_VARARGS in the functions' array, but it's ok in my
> source code. Here is the full code:
>
> #include 
>
> static PyObject * mandelpixel(PyObject *self, PyObject *args) {
> double z_real = 0, z_imag = 0, z_real2 = 0, z_imag2 = 0, c_real,
> c_imag, bailoutsquare; int iteration_number; register int i;
> PyObject coord;
It should be "PyObject *coord;" .
Maybe, it is what is wrong with your program!

- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4xDz1LDUVnWfY8gRAmAAAJ9FJPqGyeI0InxrcvdNXHtGMXWK1wCg570r
z3hcYDsjmqRp4BnpEFjbDy0=
=REQM
-END PGP SIGNATURE-

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

NetUseAdd mystery

2007-02-26 Thread king kikapu

Is anyone see any error in the following code:

mapDrive = "MyServer\\C$"
data = {'remote' : mapDrive, 'local' : 'M:', 'password' :
'mypassword', 'user' : 'Administrator', 'asg_type' : 0}
win32net.NetUseAdd(None, 1, data)

It gives me "pywintypes.error: (1326, 'NetUseAdd', 'Logon failure:
unknown user name or bad password.')" and i cannot figured out why...I
searched the forum about the syntax of NetUseAdd command and i think
that the syntax is correct and also are the data that i pass to it.
(the same data can give me a connection if i use "net use ..." from a
command line"

So, what am i doing the wrong way (and keeps me on this the last 2
hours??...)


Thanks for a any enlightenment...

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread zefciu
Thinker wrote:

> It should be "PyObject *coord;" .
> Maybe, it is what is wrong with your program!
> 
>
Should it?  The gcc shows me a warning then:

warning: 'coord' is used uninitialized in this function

and during the execution I get the same error *plus* a segfault.

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


Re: ez_setup.py

2007-02-26 Thread Paul Boddie
On 26 Feb, 17:36, Tim Golden <[EMAIL PROTECTED]> wrote:
>
> OK. Keep copying to the list, please. As I said, I'm not
> a *nix person (and I'm running here on Windows) so you'll
> get a more informed and wider audience from c.l.py.

Just to clarify one thing, $HOME isn't automatically inserted into
sys.path on UNIX, at least in all versions of Python I've used.
However, the directory where an executed Python program resides may be
used in the process of locating modules: it seems to be inserted
automatically into sys.path as the first element, in fact.

So if calendar.py is in the same directory as ez_setup.py, I would
imagine that any attempt to import the calendar module will result in
the this non-standard calendar.py being found and imported, rather
than the standard library's calendar module. The most appropriate
solution is to put ez_setup.py in other location and then to run it.
For example:

mv ez_setup.py /tmp
python /tmp/ez_setup.py

Putting the non-standard calendar.py in a directory separate from
other programs might be an idea, too.

Paul

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


[Fwd: Re: ez_setup.py]

2007-02-26 Thread Tim Golden
OK. He's solved it. For the historical record...

Tim Golden wrote:
> Nader Emami wrote:
>> Tim Golden wrote:
>>> Nader Emami wrote:
 Tim Golden wrote:
> Nader Emami wrote:
>
 How can do the second solution, (take off the home from Python 
 path)?
>>>
>>> Depends on your setup. Since you're on *nix, I can't
>>> test whether $HOME is automatically on sys.path (it
>>> isn't on Win32). Are you running *in* /usr/people/emami?
>>> If so, go somewhere else before you run ez_setup. Check
>>> your PYTHONPATH env var; perhaps reset it before
>>> running ez_setup. There are other more obscure possibilities
>>> to do with things set in site.py but they're less likely.
>>>
>>> TJG
>> I have a Linux and I don't have any PYTHONPTH variable, because 
>> if I run the next command it returns nothig:
>>
>> %env | grep -i pythonpath or
>> %env | grep -i python
>
> I'm no expert here, but I believe that Linux is
> case-sensitive, so you'd need to do:
>
> env | grep PYTHONPATH
>
> TJG
 'grep' with 'i' option can catch both of them. I have done with 
 capital letters also and the answer stays the same:
 %env | grep PYTHONPATH of %env | grep PTYTHON
>>>
>>> OK. Keep copying to the list, please. As I said, I'm not
>>> a *nix person (and I'm running here on Windows) so you'll
>>> get a more informed and wider audience from c.l.py.
>>>
>>> If there's no PYTHONPATH that means it's just down to
>>> your system setup what goes on the path. Try (from
>>> within the python interpreter):
>>>
>>> 
>>> import sys
>>> for i in sys.path:
>>>   print i
>>>
>>> 
>>>
>>> Do you see your home directory there?
>>>
>>> TJG
>> This is the result of the code:
>> /usr/people/emami/lib/python24.zip
>> /usr/people/emami/lib/python2.4
>> /usr/people/emami/lib/python2.4/plat-linux2
>> /usr/people/emami/lib/python2.4/lib-tk
>> /usr/people/emami/lib/python2.4/lib-dynload
>> /usr/people/emami/lib/python2.4/site-packages
>
> (Sigh). Copying back to the list.
>
> So, are you running in /usr/people/emami when
> you're call ez_setup?
>
> TJG
>
I have solved it. I have copied the "ez_setup.py" to my bin directory
where "python" is installed and he hes done his job.

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


Re: python notation in new NVIDIA architecture

2007-02-26 Thread Bart Ogryczak
On Feb 26, 2:03 pm, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote:
> Something funny:
>
> The new programming model of NVIDIA GPU's is called CUDA and I've
> noticed that they use the same __special__ notation for certain things
> as does python. For instance their modified C language has identifiers
> such as __device__, __global__, __shared__, etc. Is it a coincidence?
> Probably it is. :)

It's no coincidence. __* and __*__ have been used in C long before
Python. And Python (as almost any modern language) takes a lot of
syntax from C/C++.






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


gmpy moving to code.google.com

2007-02-26 Thread Alex Martelli
If you're interested in gmpy (the Python wrapper of GMP, for
unlimited-precision arithmetic, rationals, random number generation,
number-theoretical functions, etc), please DO check out
http://code.google.com/p/gmpy/ -- gmpy 1.02 is there (as far as I can
tell) in a workable state.  Source on Subversion (and a prerelease
zipfile too), downloadable binaries for MacOSX (download and read the
README file first!) and Windows (for Python 2.4 and 2.5 only, built and
minimally tested on a shaky Win2K+mingw -- on -- Parallels/MacOSX
setup... I have no other Windows machine to check 'em out...!).

Please help me check that the move-and-upgrade went OK -- download some
or all of the pieces (including an svn checkout of the sources), build,
install, test, try it out.  I will HEARTILY welcome feedback (mail
[EMAIL PROTECTED]) telling me what worked and/or what didn't so I can
finalize this release -- and hopefully move on to a future 1.03 (I won't
aim to 1.03 until I'm convinced that 1.02 is OK...).


Thanks in advance,

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

zefciu wrote:
> Thinker wrote:
>
>> It should be "PyObject *coord;" . Maybe, it is what is wrong with
>> your program!
>>
>>
> Should it? The gcc shows me a warning then:
>
> warning: 'coord' is used uninitialized in this function
>
> and during the execution I get the same error *plus* a segfault.
>
> zefciu
Yes! Please refer http://docs.python.org/api/arg-parsing.html#l2h-210
And your second PyArg_ParseTuple() call, should not make a reference
on coord.
It should be PyArg_ParseTuple(coord, ...) since you declare coord as a
pointer.
You can add some printf() to throw out messages to make sure where the
program stop at.
If you can compile the module with debug information and use gdb to
backtrace dump file,
it would be useful.

- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4xaG1LDUVnWfY8gRAsW7AKC7D3oZ8p8iWVFcBvkiVwMSrG1oNwCg36ym
e1Fa0AO3KzSD5FcYs0LK7P4=
=kYLW
-END PGP SIGNATURE-

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

Re: NetUseAdd mystery

2007-02-26 Thread Larry Bates
king kikapu wrote:
> Is anyone see any error in the following code:
> 
> mapDrive = "MyServer\\C$"
> data = {'remote' : mapDrive, 'local' : 'M:', 'password' :
> 'mypassword', 'user' : 'Administrator', 'asg_type' : 0}
> win32net.NetUseAdd(None, 1, data)
> 
> It gives me "pywintypes.error: (1326, 'NetUseAdd', 'Logon failure:
> unknown user name or bad password.')" and i cannot figured out why...I
> searched the forum about the syntax of NetUseAdd command and i think
> that the syntax is correct and also are the data that i pass to it.
> (the same data can give me a connection if i use "net use ..." from a
> command line"
> 
> So, what am i doing the wrong way (and keeps me on this the last 2
> hours??...)
> 
> 
> Thanks for a any enlightenment...
> 

I think your problem is that C$ is a "special" share.  Try creating
a share and connect to it instead.  It is either that your your userid/
password are in fact incorrect.

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread zefciu
Thinker wrote:

> You can add some printf() to throw out messages to make sure where the
> program stop at.
> If you can compile the module with debug information and use gdb to
> backtrace dump file,
> it would be useful.

Did it.  The arguments are parsed, but the coord tuple isn't.  But can
PyArg_ParseTuple be used to tuples other than function arguments?  If
not, what should I use?

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

zefciu wrote:
> Thinker wrote:
>
>> You can add some printf() to throw out messages to make sure
>> where the program stop at. If you can compile the module with
>> debug information and use gdb to backtrace dump file, it would be
>> useful.
>
> Did it. The arguments are parsed, but the coord tuple isn't. But
> can PyArg_ParseTuple be used to tuples other than function
> arguments? If not, what should I use?
Since PyArg_ParseTuple() is supposed to parse arguments, I recommand you
to use PyTuple_GetItem() or PyTuple_GET_ITEM(). You can find more
functions
at http://docs.python.org/api/genindex.html .

- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4xyq1LDUVnWfY8gRAilNAKDFTKwahXpuxFImhR57Yw5efAGP1wCfR/qU
o774g2YB5gMBLrUa9YltDSQ=
=/tWC
-END PGP SIGNATURE-

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

Reading Excel using xlrd package in python

2007-02-26 Thread Ananthashayana V

Hi John,

With reference to your reply to kath
http://mail.python.org/pipermail/python-list/2006-October/407157.html

I have a small query, my code is as follows

#--- Reading excel--

import xlrd
book = xlrd.open_workbook("E:/test.xls")

print "The number of worksheets is", book.nsheets
print "Worksheet name(s):", book.sheet_names()

sh = book.sheet_by_index(0)
for rx in range(sh.nrows):
#print sh.row(rx)
   val = sh.row(rx)
   print val

#-

Now the results are as follows

[text:u'test1\xa0', text:u'text1', xldate:39066.0, number:1234.1]
[text:u'test2', text:u'text2', xldate:39066.0, number:1234.2]
[text:u'test3\xe9', text:u'text3', xldate:39066.0, number:1234.3]
[text:u'test4\xe9', text:u'text4', xldate:39066.0, number:1234.4]
-


Now as you can clearly observe, I want to:
1. Remove the additional tags like text, xldate, number.
2. Display date in normal form like dd-mm-, or dd/mm/ or may be
-mm-dd .
3. Finally would like remove the spaces and some UNICODE characters, here
its being represented as \xe9 or \xa0

Can you please help me out on this. I would really appreciate it.

Thanks in advance.

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

I don't quite understand this error...

2007-02-26 Thread Alexander Orchard

I'm trying to create a simple accounting system based off of an example GUI.
The coding is as follows:

#!/usr/bin/python

from Tkinter import *
from os import urandom
from twisted.internet import tksupport
from twisted.internet import reactor
from accounts import accountlist

def whichSelected () :
   print "At %s of %d" % (select.curselection(), len(accountlist))
   return int(select.curselection()[0])

def addEntry () :
   accountlist.append ([userVar.get(), passwVar.get(), balanceVar.get()])
   setSelect ()

def Withdrawl() :
   user, passw, balance = accountlist[whichSelected()]
   userVar.set(user)
   passwVar.set(passw)
   balanceVar.set(balance)
   balanceVar -= amount
   balance.set(balanceVar)
   setSelect ()

def Deposit() :
   user, passw, balance = accountlist[whichSelected()]
   balance += amount
   accountlist[whichSelected()] = [user, passw, balance]
   setSelect ()

def loadEntry  () :
   user, passw, balance = accountlist[whichSelected()]
   userVar.set(user)
   passwVar.set(passw)
   balanceVar.set(balance)


def makeWindow () :
   global userVar, passwVar, balanceVar, amount, select
   win = Tk()

   frame1 = Frame(win)
   frame1.pack()

   Label(frame1, text="User Name").grid(row=0, column=0, sticky=W)
   userVar = StringVar()
   user = Entry(frame1, textvariable=userVar)
   user.grid(row=0, column=1, sticky=W)

   Label(frame1, text="Password").grid(row=1, column=0, sticky=W)
   passwVar= StringVar()
   passw= Entry(frame1, textvariable=passwVar)
   passw.grid(row=1, column=1, sticky=W)

   Label(frame1, text="Balance ($)").grid(row=2, column=0, sticky=W)
   balanceVar= IntVar()
   balance= Entry(frame1, textvariable=balanceVar)
   balance.grid(row=2, column=1, sticky=W)

   frame2 = Frame(win)
   frame2.pack()
   b1 = Button(frame2,text=" Add  ",command=addEntry)
   b2 = Button(frame2,text="Withdraw Amount",command=Withdrawl)
   b3 = Button(frame2,text="Deposit Amount",command=Deposit)
   b4 = Button(frame2,text=" Load ",command=loadEntry)
   b1.pack(side=LEFT); b2.pack(side=LEFT)
   b3.pack(side=LEFT); b4.pack(side=LEFT)

   frame3 = Frame(win)
   frame3.pack()
   scroll = Scrollbar(frame3, orient=VERTICAL)
   select = Listbox(frame3, yscrollcommand=scroll.set, height=6)
   scroll.config (command=select.yview)
   scroll.pack(side=RIGHT, fill=Y)
   select.pack(side=LEFT,  fill=BOTH, expand=1)

   frame4 = Frame(win)
   frame4.pack()

   Label(frame4, text="Amount ($)").grid(row=0, column=0, sticky=W)
   amountVar= IntVar()
   amount= Entry(frame4, textvariable=amountVar)
   amount.grid(row=0, column=1, sticky=W)
   return win

def setSelect () :
   accountlist.sort()
   select.delete(0,END)
   for user,passw,balance in accountlist :
   select.insert (END, user)


# Install the Reactor support
def main():
   root = makeWindow()
   setSelect ()
   tksupport.install(root)
#root.pack()
   print "starting event loop"
   reactor.run()

#if __name__ == "__main__":
main()




Also, for reference, the "accounts" imported from are as follows:

accountlist = [
 ['Alex',  'shera', '400'],
 ['Sam',  'tish', '0']
]





Thus far, everything works fine unless I'm trying the Deposit or Withdrawal
functions. (I know they're different, but both give roughly the same error.)
Whenever I attempt one of these functions I get the following error message:


Exception in Tkinter callback
Traceback (most recent call last):
 File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
   return self.func(*args)
 File "C:\Python24\AEOpaypal.py", line 27, in Deposit
   user, passw, balance = accountlist[whichSelected()]
 File "C:\Python24\AEOpaypal.py", line 11, in whichSelected
   return int(select.curselection()[0])
IndexError: tuple index out of range


I honestly don't understand what's going on... I've managed to stumble my
way through understanding what error messages mean, but I'm not sure what do
here. Just to clarify, to deposit money, first you select the account, and
click "Load" to bring it up on screen. Then you put the amount in the
"Amount" text box. Then you click "Deposit Amount"

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

Re: NetUseAdd mystery

2007-02-26 Thread king kikapu
> I think your problem is that C$ is a "special" share.  Try creating
> a share and connect to it instead.  It is either that your your userid/
> password are in fact incorrect.
>
> -Larry

No, my credentials are absolutely correct. As for the "$", what is the
possible problem with that ?? Net use is working great and i think
that also the net functions of win32api are working correct.
The problem must be in some other point...

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


Re: NetUseAdd mystery

2007-02-26 Thread Roger Upole

king kikapu wrote:
> Is anyone see any error in the following code:
>
>mapDrive = "MyServer\\C$"
>data = {'remote' : mapDrive, 'local' : 'M:', 'password' :
> 'mypassword', 'user' : 'Administrator', 'asg_type' : 0}
>win32net.NetUseAdd(None, 1, data)
>
> It gives me "pywintypes.error: (1326, 'NetUseAdd', 'Logon failure:
> unknown user name or bad password.')" and i cannot figured out why...I
> searched the forum about the syntax of NetUseAdd command and i think
> that the syntax is correct and also are the data that i pass to it.
> (the same data can give me a connection if i use "net use ..." from a
> command line"
>
> So, what am i doing the wrong way (and keeps me on this the last 2
> hours??...)
>
>
> Thanks for a any enlightenment...


You need to use level 2 info to pass the username.
Level 1 is for the old-style share with its own password.
Also, it should be 'username': instead of just 'user':.

 hth
   Roger





== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread zefciu
Thinker wrote:

> Since PyArg_ParseTuple() is supposed to parse arguments, I recommand you
> to use PyTuple_GetItem() or PyTuple_GET_ITEM().

Ok.  Now I do it this way:

c_real = PyFloat_AsDouble(PyTuple_GetItem(coord,0));
c_imag = PyFloat_AsDouble(PyTuple_GetItem(coord,1));

And it worked... once.  The problem is really funny - in the interactive
the function fails every second time.

>>> mandelpixel((1.5, 1.5), 9, 2.2)
args parsed
coord parsed
ii3
>>> mandelpixel((1.5, 1.5), 9, 2.2)
TypeError: bad argument type for built-in operation
>>> mandelpixel((1.5, 1.5), 9, 2.2)
args parsed
coord parsed
ii3
>>> mandelpixel((1.5, 1.5), 9, 2.2)
TypeError: bad argument type for built-in operation

etcaetera (the "args parsed" "coord parsed" and "i" are effect of
printfs in the code, as you see when it fails, it doesn't even manage to
parse the arguments.

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


2.4->2.5 current directory change?

2007-02-26 Thread Chris Mellon
This appears to be a change in behavior from Python 2.4 to Python 2.5,
which I can't find documented anywhere. It may be windows only, or
related to Windows behavior.

In 2.4, the current directory (os.curdir) was on sys.path. In 2.5, it
appears to be the base directory of the running script. For example,
if you execute the file testme.py in your current working directory,
'' is on sys.path. If you execute c:\Python25\Scripts\testme.py, '' is
*not* on sys.path, and C:\Python25\Scripts is.

That means if you run a Python script located in another directory,
modules/etc in your current working directory will not be found. This
makes .py scripts in the PYTHONHOME\Scripts file moderately useless,
because they won't find anything in the current working directory.


I first noticed this because it breaks Trial, but I'm sure there are
other scripts affected by it. Is this desirable behavior? Is there
anything to work around it except by pushing os.curdir onto sys.path?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread Thinker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

zefciu wrote:
> Thinker wrote:
>
>> Since PyArg_ParseTuple() is supposed to parse arguments, I
>> recommand you to use PyTuple_GetItem() or PyTuple_GET_ITEM().
>
> Ok. Now I do it this way:
>
> c_real = PyFloat_AsDouble(PyTuple_GetItem(coord,0)); c_imag =
> PyFloat_AsDouble(PyTuple_GetItem(coord,1));
>
> And it worked... once. The problem is really funny - in the
> interactive the function fails every second time.
>
 mandelpixel((1.5, 1.5), 9, 2.2)
> args parsed coord parsed ii3
 mandelpixel((1.5, 1.5), 9, 2.2)
> TypeError: bad argument type for built-in operation
I guess it is caused by ill handling reference count of coord.
You should call Py_INCREF() to get a reference since it is borrowed
from PyArg_ParseTuple().
You can find more information at http://docs.python.org/ext/refcounts.html

- --
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF4yuP1LDUVnWfY8gRAqOmAJ0SaIwpnRk/GZYm2Z5nnC7xH7EYKwCgjz8o
0Z/S7i5PULQMeAFI7U/Cy5I=
=4C3l
-END PGP SIGNATURE-

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

Last Reminder: Survey about Architecture and Design Patterns

2007-02-26 Thread Joerg Rech
Dear software practitioners, consultants, and researchers,
  we are currently conducting an international survey about
architecture and design patterns. Our goal is to discover how familiar
people are with these patterns (and anti-patterns) as well as to
elicit the information need, the usage behavior, and the experience of
software organizations regarding architecture patterns and design
patterns.

Therefore, we would like to invite you and members of your
organizations to participate in the survey at http://softwarepatterns.eu.
Answering the survey should take about 20-30 minutes. The survey will
close on 1 March 2007.

All data will be treated confidentially.

Please pass information about this survey on to your colleagues and
managers as well as other contacts who might be interested in this
topic and have experience with architecture and design patterns.

Many thanks in advance,
Joerg Rech

---
Joerg Rech
Speaker of the GI-Workgroup Architecture and Design Patterns (AKAEM)
Web: http://www.architekturmuster.de (in German)
XING: http://www.xing.com/profile/Joerg_Rech/

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


jsString class

2007-02-26 Thread Subscriber123

Hi all,

Some of you may find this useful. It is a class I wrote that acts like the
way strings do in JavaScript. It is a little buggy, and not complete, but
could be useful.

class jsString:
   def __init__(self,string):
   if string.__class__ is list:
   print "list:",string
   self.list=string
   else:
   print "string:",string
   self.list=[string]
   def __add__(self,other):
   try:
   r=self.list[:-1]+[self.list[-1]+other]
   except:
   r=self.list+[other]
   return jsString(r)
   def __mul__(self,other):
   try:
   r=self.list[:-1]+[self.list[-1]*other]
   except:
   r=self.list*other
   return jsString(r)
   def __len__(self):
   return len(str(self))
   def __str__(self):
   r=""
   for obj in self.list:
   r+=str(obj)
   return r
   def __repr__(self):
   return str(self.list)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: about framework

2007-02-26 Thread raf
On Feb 24, 10:09 pm, [EMAIL PROTECTED] wrote:
> Python has some web framework.I'm not familiar with all of them.
> Do you think which is best popular of  them?Thanks.
> ** AOL now offers free
> email to everyone.  Find out more about what's free from AOL 
> athttp://www.aol.com.

take a look at http://djangoproject.org



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


Re: Rational numbers

2007-02-26 Thread aleaxit
On Feb 25, 3:09 pm, Fernando Perez <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > gmpy itself is or should be pretty trivial to build on any platform
> > (and I'll always happily accept any fixes that make it better on any
> > specific platform, since it's easy to make them conditional so they'll
> > apply to that platform only), but the underlying GMP is anything but:-
> > (.
>
> Alex, have you had a look at SAGE?
>
> http://modular.math.washington.edu/sage/
>
> it uses GMP extensively, so they've had to patch it to work around these
> issues.  You can look at the SAGE release (they package everything as the
> original tarball + patches) for the GMP-specific stuff you need, though I
> suspect you'll still want to play with SAGE a little bit :).  It's a mighty
> impressive system.

Thanks Fernando, I will take a look at that.


Alex

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


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Ray Dillinger
Tech HR wrote:

> But we're a very young company (barely six months old at this point) so 
> we're willing to listen to most anything at this point.  (We're using 
> Darcs for revision control.  Haskell, anyone?)

Tell us, where you would expect an applicant for one or more of these
jobs to live if they accepted a job with your firm?  It's not at all
apparent from your website or job descriptions where the worksite is
physically located.

Bear

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


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Bruce Lewis
Tech HR <[EMAIL PROTECTED]> writes:

> (Actually, 
> it's turning out to be hard to find Python programmers too, but it's 
> easier to train a Java programmer or a Perler on Python than Lisp.

Is this speculation or experience?  If it was experience, what Lisp were
you trying to train Java programmers in, and what problems did you
encounter?
-- 
http://mail.python.org/mailman/listinfo/python-list


Python object to xml biding

2007-02-26 Thread raf
Hi there,


I'm looking for a python to XSD/xml biding library to easy handling
this very large protocol spec I need to tackle. I've searched google
quite extensibly and I haven't found anything that properly fits the
bill... I'm mostly interested at the xml -> python and python->xml
marshalling/unmarshalling much like jaxb for java.

Any ideas?

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


Re: [EMAIL PROTECTED] Re: *** ISRAELI TERRORISTS BLEW UP INDIAN TRAIN ***

2007-02-26 Thread thermate
Now I see, its the mossad spoooks ... obviously they pulled 911, bush/
cheney thankful for it and fell for it, what do they care about 3000
dead and others with lung disease ... the israelis were paged SMS
before 911, and larrysilversteins took day off ... its the mossad

On Feb 26, 2:19 am, Arash <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>
> Forge cancel huh.
>
> Subject: *** ISRAELI TERRORISTS BLEW UP INDIAN TRAIN ***
> From: [EMAIL PROTECTED]
> Date: Sun, 25 Feb 2007 09:28:55 + (UTC)
> Newsgroups:sci.materials,soc.culture.indian,comp.text.tex,comp.lang.python,sci.math
> Path:news.cn99.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail
> Newsgroups:sci.materials,soc.culture.indian,comp.text.tex,comp.lang.python,sci.math
> Control: cancel <[EMAIL PROTECTED]>
> Organization:http://groups.google.com
> Lines: 2
> Message-ID: <[EMAIL PROTECTED]>
> NNTP-Posting-Host: p54b2b8cd.dip0.t-ipconnect.de
> X-Trace: online.de 1172395735 1519 84.178.184.205 (25 Feb 2007 09:28:55 GMT)
> X-Complaints-To: [EMAIL PROTECTED] & [EMAIL PROTECTED]
> NNTP-Posting-Date: Sun, 25 Feb 2007 09:28:55 + (UTC)
> Xref: news.cn99.com control.cancel:10701723


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


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Ken Tilton


Tech HR wrote:
> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] wrote:
> 
> 
>>On Feb 26, 6:32 am, Tech HR <[EMAIL PROTECTED]> wrote:
>>
>>>Our
>>>website is currently a LAMP appication with P=Python. We are looking for
>>>bright motivated people who know or are willing to learn Python and/or
>>>Linux, Apache and MySQL system administration skills. (And if you want
>>>to convince us that we should switch over to Postgres, we're willing to
>>>listen.)
>>
>>This is more out of curiosity, but does it mean that you wouldn't be
>>willing to listen about a switch from Python to Lisp?
> 
> 
> No, it doesn't mean that.  In fact, there is a significant faction in 
> the technical staff (including the CTO) who would like nothing better 
> than to be able to use Lisp instead of Python.

Ah, you must lack courage in your convictions. Unless you plan on being 
out of business in six months, Do the Right Thing. Use the best 
language. Then worry about little things like libraries and filling seats.

There is a great saying, "Think you can or think you cannot, either way 
you will be right." Something like that.

>  But we have some pretty 
> compelling reasons to stick with Python, not least of which is that it 
> is turning out to be very hard to find Lisp programmers.  (Actually, 
> it's turning out to be hard to find Python programmers too, but it's 
> easier to train a Java programmer or a Perler on Python than Lisp.

Place two ads, both for "Java/Perl/C programmers". One looking for folks 
willing to learn Python, one for those willing to learn Lisp. I 
guarantee you respondents to the second group will be more fun to go 
bar-hopping with. Oh, and twice as good at programming as the first group.

You are solving the wrong problem. "lisp is the best language and we 
cannot find Lisp programmers." The problem is not the choice of Lisp, 
the problem is finding people to program Lisp. They do not have to be 
Lisp programmers with certified scorched areas from being flamed by me 
on c.l.l. They just need to be great programmers, in any language.

Choosing Lisp will make all of you twenty to one hundred percent happier 
to go to work each day and stay a little longer each night to grind out 
CFFI bindings for the libs you need. Hiring a good programmer to learn 
Lisp will have them putting in about a hundred hours a week and loving 
it. Tap into the energy, man.

>  We 
> also have fair bit of infrastructure built up in Python at this point.)

Do I tell you my problems?

:)

kt

-- 
Well, I've wrestled with reality for 35 years, Doctor, and
I'm happy to state I finally won out over it.
   -- Elwood P. Dowd

In this world, you must be oh so smart or oh so pleasant.
   -- Elwood's Mom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread bearophileHUGS
Tech HR:
> In fact, there is a significant faction in
> the technical staff (including the CTO) who would like nothing better
> than to be able to use Lisp instead of Python.

I think CLisp and Python have different enough application areas, so
often where one is fit the other can't be much fit. Doing number
crunching or heavy processing, or lot of symbolic/pattern processing
with Python isn't positive (using Pyrex, Psyco, and numpy may help
solve a small part of such problems). If you want to do some kind of
html, text processing, and various other things Python may be a better
choice.

Bye,
bearophile

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


Re: SystemError: new style getargs format but argument is not a tuple

2007-02-26 Thread Ziga Seilnacht
zefciu wrote:
> Ok.  Now I do it this way:
>
> c_real = PyFloat_AsDouble(PyTuple_GetItem(coord,0));
> c_imag = PyFloat_AsDouble(PyTuple_GetItem(coord,1));
>
> And it worked... once.  The problem is really funny - in the interactive
> the function fails every second time.
>
> >>> mandelpixel((1.5, 1.5), 9, 2.2)
>
> args parsed
> coord parsed
> ii3>>> mandelpixel((1.5, 1.5), 9, 2.2)
>
> TypeError: bad argument type for built-in operation>>> mandelpixel((1.5, 
> 1.5), 9, 2.2)
>
> args parsed
> coord parsed
> ii3>>> mandelpixel((1.5, 1.5), 9, 2.2)
>
> TypeError: bad argument type for built-in operation
>
> etcaetera (the "args parsed" "coord parsed" and "i" are effect of
> printfs in the code, as you see when it fails, it doesn't even manage to
> parse the arguments.

The direct solution to your problem is to use the "tuple unpacking"
feature of PyArg_ParseTuple by using "(dd)id" as format argument.
This is shown in the first example.
The second example uses your approach and is a bit more cumbersome,
but still works. Could you post your current version of the code?
I don't understand where your problem could be.

#include "Python.h"

static PyObject *
mandelpixel1(PyObject *self, PyObject *args)
{
double z_real = 0, z_imag = 0, z_real2 = 0, z_imag2 = 0;
double c_real, c_imag, bailoutsquare;
int iteration_number;
register int i;

if (!PyArg_ParseTuple(args, "(dd)id", &c_real, &c_imag,
   &iteration_number, &bailoutsquare))
return NULL;

for (i = 1; i <= iteration_number; i++) {
z_imag = 2 * z_real * z_imag + c_imag;
z_real = z_real2 - z_imag2 + c_real;
z_real2 = z_real * z_real;
z_imag2 = z_imag * z_imag;
if (z_real2 + z_imag2 > bailoutsquare)
return Py_BuildValue("i", i);
}

return Py_BuildValue("i", 0);
}

static PyObject *
mandelpixel2(PyObject *self, PyObject *args)
{
double z_real = 0, z_imag = 0, z_real2 = 0, z_imag2 = 0;
double c_real, c_imag, bailoutsquare;
int iteration_number;
PyObject *coord;
register int i;

if (!PyArg_ParseTuple(args, "Oid", &coord,
   &iteration_number, &bailoutsquare))
return NULL;


if (!PyTuple_Check(coord)) {
PyErr_SetString(PyExc_TypeError, "something informative");
return NULL;
}

if (!PyArg_ParseTuple(coord, "dd", &c_real, &c_imag))
return NULL;

for (i = 1; i <= iteration_number; i++) {
z_imag = 2 * z_real * z_imag + c_imag;
z_real = z_real2 - z_imag2 + c_real;
z_real2 = z_real * z_real;
z_imag2 = z_imag * z_imag;
if (z_real2 + z_imag2 > bailoutsquare)
return Py_BuildValue("i", i);
}

return Py_BuildValue("i", 0);
}

static PyMethodDef MandelcMethods[] = {
{"mandelpixel1", mandelpixel1, METH_VARARGS, "first version"},
{"mandelpixel2", mandelpixel2, METH_VARARGS, "second version"},
{NULL, NULL, 0, NULL},
};

PyMODINIT_FUNC
initmandelc(void)
{
Py_InitModule("mandelc", MandelcMethods);
}

Ziga

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


Python+Windows specific questions

2007-02-26 Thread hg
Hi,

Do I need the pywin32 extentions to:

1) change the pc system date ?
2) launch a ppp connection   ?

Thanks,

hg

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


Add images together

2007-02-26 Thread iceman
Hi,

I am trying to add together a number of images:

im = image1 + image2 + ...

How can i do this? I have tried to add two image instances
together but i get the following error:
TypeError: unsupported operand type(s)  for +: 'instance' and
'instance'

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


Re: Add images together

2007-02-26 Thread Diez B. Roggisch
iceman schrieb:
> Hi,
> 
> I am trying to add together a number of images:
> 
> im = image1 + image2 + ...
> 
> How can i do this? I have tried to add two image instances
> together but i get the following error:
> TypeError: unsupported operand type(s)  for +: 'instance' and
> 'instance'

Create a new image of double size, and blit the images to the correct 
destination.

Diez

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


*** MOSSAD TERRORIST OPERATIONS IN INDIA ***

2007-02-26 Thread thermate2
On Feb 25, 12:07 am, [EMAIL PROTECTED] wrote:
> Eye opener research
>
> http://www.apfn.org/apfn/WTC_STF.htm

EXCERPT:

Now I'm really going to rock your faith in the false religion of 9-11.
In February of 2000, Indian intelligence officials detained 11 members
of what they thought was an Al Qaeda hijacking conspiracy. It was then
discovered that these 11 "Muslim preachers" were all Israeli
nationals! India's leading weekly magazine, The Week, reported:

On January 12 Indian intelligence officials in Calcutta detained 11
foreign nationals for interrogation before they were to board a Dhaka-
bound Bangladesh Biman flight. They were detained on the suspicion of
being hijackers. "But we realized that they were tabliqis (Islamic
preachers), so we let them go", said an Intelligence official.

The eleven had Israeli passports but were believed to be Afghan
nationals who had spent a while in Iran. Indian intelligence
officials, too, were surprised by the nationality profile of the
eleven. "They say that they have been on tabligh (preaching Islam) in
India for two months. But they are Israeli nationals from the West
Bank," said a Central Intelligence official. He claimed that Tel Aviv
"exerted considerable pressure" on Delhi to secure their release. "It
appeared that they could be working for a sensitive organization in
Israel and were on a mission to Bangladesh," the official said. 72
(emphasis added)

What were these 11 Israelis doing trying to impersonate Al Qaeda men?
Infiltrating?...perhaps. Framing?...more likely. But the important
precedent to understand is this: Israeli agents were once caught red
handed impersonating Muslim hijackers!

This event becomes even more mind boggling when we learn that it was
Indian Intelligence that helped the US to so quickly identify the "19
hijackers"! On April 3, 2002, Express India, quoting the Press Trust
of India, revealed:

Washington, April 3: Indian intelligence agencies helped the US to
identify the hijackers who carried out the deadly September 11
terrorist attacks in New York and Washington, a media report said here
on Wednesday. 73

Ain't that a kick in the ass?!! Did you catch that? The Indian
intelligence officials that were duped into mistaking Israeli agents
for Al Qaeda hijackers back in 2000, were the very same clowns telling
the FBI who it was that hijacked the 9-11 planes! Keep in mind that
Indian intelligence has an extremely close working relationship with
Israel's Mossad because both governments hate the Muslim nation of
Pakistan. 74

Now about Mohamed Atta, you know, the so-called "ring leader". There
are a number of inconsistencies with that story as well. Like some of
the 7 hijackers known to be still alive, Atta also had his passport
stolen in 1999, 75 (the same passport that miraculously survived the
WTC explosion and collapse?) making him an easy mark for an identity
theft. Atta was known to all as a shy, timid, and sheltered young man
who was uncomfortable with women. 76 The 5 foot 7 inch, 150 pound
architecture student was such a "goody two shoes" that some of his
university acquaintances in Germany refrained from drinking or cursing
in front of him. How this gentle, non- political mamma's boy from a
good Egyptian family suddenly transformed himself into the vodka
drinking, go-go girl groping terrorist animal described by the media,
has to rank as the greatest personality change since another classic
work of fiction, Dr. Jekyll and Mr. Hyde.

Atta, or someone using Atta's identity, had enrolled in a Florida
flight school in 2001 and then broke off his training, making it a
point to tell his instructor he was leaving for Boston. In an October
2001 interview with an ABC affiliate in Florida, flight school
president Rudi Dekkers said that his course does not qualify pilots to
fly commercial jumbo jets. 77 He also described Atta as "an asshole".
78 Part of the reason for Dekker's dislike for Atta stems from a
highly unusual incident that occurred at the beginning of the course.
Here's the exchange between ABC producer Quentin McDermott and
Dekkers:

MCDERMOTT: "Why do you say Atta was an asshole?"

DEKKERS: "Well, when Atta was here and I saw his face on several
occasions in the building, then I know that they're regular students
and then I try to talk to them, it's kind of a PR - where are you
from? I tried to communicate with him. I found out from my people that
he lived in Hamburg and he spoke German so one of the days that I saw
him, I speak German myself, I'm a Dutch citizen, and I started in the
morning telling him in German, "Good morning. How are you? How do you
like the coffee? Are you happy here?", and he looked at me with cold
eyes, didn't react at all and walked away. That was one of my first
meetings I had." 79

This is eerily similar to the way in which Zacharias Moussaoui (the so-
called "20th hijacker") became "belligerent" when his Minnesota flight
instructor tried to speak to him in French (his first language), at
the beginning of

Re: I don't quite understand this error...

2007-02-26 Thread Daniel Nogradi
> Thus far, everything works fine unless I'm trying the Deposit or Withdrawal
> functions. (I know they're different, but both give roughly the same error.)
> Whenever I attempt one of these functions I get the following error message:
>
>
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
> return self.func(*args)
>   File "C:\Python24\AEOpaypal.py", line 27, in Deposit
> user, passw, balance = accountlist[whichSelected()]
>   File "C:\Python24\AEOpaypal.py", line 11, in whichSelected
> return int(select.curselection()[0])
> IndexError: tuple index out of range

"IndexError: tuple index out of range" means that you are trying to
access an element of a tuple which does not exist. In your case
int(select.curselection()[0]) raises the exception so your tuple
select.curselection() doesn't have a 0th entry which means it's empty.

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


RE: [OT] python notation in new NVIDIA architecture

2007-02-26 Thread Delaney, Timothy (Tim)
Daniel Nogradi wrote:

>>> Something funny:
>>> 
>>> The new programming model of NVIDIA GPU's is called CUDA and I've
>>> noticed that they use the same __special__ notation for certain
>>> things as does python. For instance their modified C language has
>>> identifiers such as __device__, __global__, __shared__, etc. Is it
>>> a coincidence? Probably it is. :)
>> 
>> Cuda is usually taken as short for "barracuda", a fish. Fish have
>> been known to slither under the right circumstances. Perhaps this is
>> the link? 
> 
> Wow! How is it that I didn't think about this before?! Thanks a
> million! 

Actually, I think it's more likely to be a direct link to the Fish
Slapping Dance ...

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


RE: a=b change b a==b true??

2007-02-26 Thread Delaney, Timothy (Tim)
[EMAIL PROTECTED] wrote:

> All,
> It works great now.  Thank you for all of your incredibly quick
> replies.
> Rob

You should have a read of these:

http://wiki.python.org/moin/BeginnersGuide
http://effbot.org/zone/python-objects.htm

Cheers,

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


Re: about framework

2007-02-26 Thread Bruno Desthuilliers
raf a écrit :
> On Feb 24, 10:09 pm, [EMAIL PROTECTED] wrote:
> 
>>Python has some web framework.I'm not familiar with all of them.
>>Do you think which is best popular of  them?Thanks.
>>** AOL now offers free
>>email to everyone.  Find out more about what's free from AOL 
>>athttp://www.aol.com.
> 
> 
> take a look at http://djangoproject.org
> 
This answers the "popular" part of the question. For the "best" part, 
look here :
http://pylonshq.com/

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


Re: gmpy moving to code.google.com

2007-02-26 Thread Daniel Nogradi
> If you're interested in gmpy (the Python wrapper of GMP, for
> unlimited-precision arithmetic, rationals, random number generation,
> number-theoretical functions, etc), please DO check out
> http://code.google.com/p/gmpy/ -- gmpy 1.02 is there (as far as I can
> tell) in a workable state.  Source on Subversion (and a prerelease
> zipfile too), downloadable binaries for MacOSX (download and read the
> README file first!) and Windows (for Python 2.4 and 2.5 only, built and
> minimally tested on a shaky Win2K+mingw -- on -- Parallels/MacOSX
> setup... I have no other Windows machine to check 'em out...!).
>
> Please help me check that the move-and-upgrade went OK -- download some
> or all of the pieces (including an svn checkout of the sources), build,
> install, test, try it out.  I will HEARTILY welcome feedback (mail
> [EMAIL PROTECTED]) telling me what worked and/or what didn't so I can
> finalize this release -- and hopefully move on to a future 1.03 (I won't
> aim to 1.03 until I'm convinced that 1.02 is OK...).
>
>
> Thanks in advance,
>
> Alex

Svn checkout, compilation and installation went okay but some tests
failed, this is the output of 'python test_gmpy.py':


Unit tests for gmpy 1.02 release candidate
on Python 2.5 (r25:51908, Nov  1 2006, 11:42:37)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)]
Testing gmpy 1.02 (GMP 4.1.4), default caching (20, 20, -2..11)
gmpy_test_cvr 270 tests, 0 failures
gmpy_test_rnd  26 tests, 0 failures
gmpy_test_mpf 155 tests, 0 failures
gmpy_test_mpq 264 tests, 0 failures
**
File "/home/nogradi/tmp/gmpy/test/gmpy_test_mpz.py", line ?, in
gmpy_test_mpz.__test__.number
Failed example:
_memsize()-_siz
Expected:
0
Got:
-4
**
1 items had failures:
   2 of 132 in gmpy_test_mpz.__test__.number
***Test Failed*** 2 failures.
gmpy_test_mpz 388 tests, 2 failures
**
1 items had failures:
   2 of 132 in gmpy_test_mpz.__test__.number
***Test Failed*** 2 failures.
gmpy_test_dec  16 tests, 0 failures
7 items had no tests:
gmpy_test_cvr._test
gmpy_test_dec._test
gmpy_test_mpf._test
gmpy_test_mpq._test
gmpy_test_mpz._memsize
gmpy_test_mpz._test
gmpy_test_rnd._test
30 items passed all tests:
   6 tests in gmpy_test_cvr
  12 tests in gmpy_test_cvr.__test__.misc_stuff
 252 tests in gmpy_test_cvr.__test__.user_errors
   1 tests in gmpy_test_dec
  15 tests in gmpy_test_dec.__test__.elemop
   1 tests in gmpy_test_mpf
  32 tests in gmpy_test_mpf.__test__.binio
  33 tests in gmpy_test_mpf.__test__.cmpr
  49 tests in gmpy_test_mpf.__test__.elemop
  34 tests in gmpy_test_mpf.__test__.format
   6 tests in gmpy_test_mpf.__test__.newdiv
   2 tests in gmpy_test_mpq
  26 tests in gmpy_test_mpq.__test__.binio
  62 tests in gmpy_test_mpq.__test__.cmpr
  66 tests in gmpy_test_mpq.__test__.elemop
  54 tests in gmpy_test_mpq.__test__.format
  12 tests in gmpy_test_mpq.__test__.newdiv
  18 tests in gmpy_test_mpq.__test__.power
  24 tests in gmpy_test_mpq.__test__.qdiv
   4 tests in gmpy_test_mpz
  34 tests in gmpy_test_mpz.__test__.binio
  62 tests in gmpy_test_mpz.__test__.bitops
  48 tests in gmpy_test_mpz.__test__.cmpr
  42 tests in gmpy_test_mpz.__test__.elemop
  36 tests in gmpy_test_mpz.__test__.format
  14 tests in gmpy_test_mpz.__test__.index
  12 tests in gmpy_test_mpz.__test__.newdiv
   4 tests in gmpy_test_mpz.factorize
   1 tests in gmpy_test_rnd
  25 tests in gmpy_test_rnd.__test__.rand
**
1 items had failures:
   2 of 132 in gmpy_test_mpz.__test__.number
1119 tests in 38 items.
1117 passed and 2 failed.
***Test Failed*** 2 failures.



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


  1   2   >