Re: What's wrong with Zope 3 ?

2005-05-31 Thread Wolfram Kraus
Kay Schluehr wrote:
> The last downloadable release is from november 2004. The Windows
> installer is configured for Python 2.3(!). The Zope.org main page
> announces Zope 2.8 beta 2. Is it stillborn? 
> 
> Kay
> 
What you see is not Zope 3, it is Zope X 3. To quote from the X3 
information page: "Zope X3 3.0 is for developers. If you are expecting 
an end-user application, this is not for you."
The current stable brance is Zope2.X If you want to incorporate some 
functionalty from X3 in Zope 2.X, do a search for "Five"

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


Re: pickle alternative

2005-05-31 Thread simonwittber
> I can't reproduce your large times for marshal.dumps.  Could you
> post your test code?


Certainly:

import sencode
import marshal
import time

value = [r for r in xrange(100)] +
[{1:2,3:4,5:6},{"simon":"wittber"}]

t = time.clock()
x = marshal.dumps(value)
print "marshal enc T:", time.clock() - t

t = time.clock()
x = marshal.loads(x)
print "marshal dec T:", time.clock() - t

t = time.clock()
x = sencode.dumps(value)
print "sencode enc T:", time.clock() - t
t = time.clock()
x = sencode.loads(x)
print "sencode dec T:", time.clock() - t

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


Re: something like CPAN, PPMs?

2005-05-31 Thread Maurice LING
Hi Alex,

I am actually working on something like that as an academic project. At 
this stage, at least for the purpose of my scope, it will not be as 
extensive as CPAN but a set of mechanisms for the same effect for Python.

maurice

Alex Gittens wrote:
> I'm new to Python from Perl, and loving it. Has there ever been any
> discussion of creating a similar resource as CPAN for Python, or a
> similar distribution method as PPMs? Seems like it would make a great
> language even better.
> 
> Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Python types

2005-05-31 Thread Paul McNett
Uppal, Deepali wrote:
> Hello,
Hello, and welcome to the world of Python. Don't take anything we say 
too personally, it is meant to help.

> I am facing a bit of a problem due to python implicitly 
> attaching a type to an object. 

Ooh. In general, don't say 'implicit'. For the most part, Python only 
does things explicitly. See the Zen of Python by opening a Python 
interpreter and typing "import this".


> I will briefly tell you the problem that
> I am facing. I am trying to print the docstring of a test case in 
> my pyUnit base test class. I accept the name of the test class as
> a command line option. So instead of printing the docstring of
> the test case, it prints the docString of a string object.

Which is expected, because all command line options are strings. I 
assume you are getting the command line option using the idiom:

import sys
options = sys.argv[1:]

> I would like to give an example here
> import test_script  
> 
> gettatr( test_script.test_class.test_case, ‘__doc__’)

I think you meant:

print getattr(test_script.test_class.test_case, '__doc__')


> With this simple code, I am able to print the docstring
> of the test case.

Yep, Python is simple and expressive.


> However, since I accept the test case information as a command line
> option. So instead of printing the docstring of the test case it
> prints the docstring of a string object.

Right, because all command line options are strings, since that is all 
the shell can really hand off to Python.


> Is there someway, I can tell the script to change the type of
> the object from string to an instancetype of a test case?

In your first example, you import the test_script, and then do a 
getattr() on the test_class inside test_script.py. If you are trying to 
mimic that, and sending one or more test_script's, your code would look 
something like:

import sys

for test_module in sys.argv[1:]
try:
_module = __import__(test_module)
_class = _module.test_class
_case = _class.test_case
print _case.__doc__
except ImportError:
print "Couldn't import module '%s'. Skipping..." % test_module  


> I am quite a newbie in python so I would appreciate any help on this.

The above should get you started, even though it won't satisfy your 
exact needs.

-- 
Paul McNett
http://paulmcnett.com

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


Beginner question: Python types

2005-05-31 Thread Uppal, Deepali








 

Hello,

 

    I
am facing a bit of a problem due to python implicitly attaching

a type to an object. I will briefly
tell you the problem that

I am facing. I am trying to print
the docstring of a test case in 

my pyUnit base test class. I accept
the name of the test class as

a command line option. So instead of
printing the docstring of

the test case, it prints the docString
of a string object.

 

I would like to give an example here

 

import test_script   

gettatr( test_script.test_class.test_case,
‘__doc__’)  

 

With this simple code, I am able to
print the docstring

of the test case.

 

However, since I accept the test
case information as a command line

option. So instead of printing the docstring
of the test case it

prints the docstring of a string
object.

=>  'str(object) -> string\n\nReturn a nice string representation
of the object.\nIf

 the argument
is a string, the return value is the same object.'

 

Is there someway, I can tell the
script to change the type of

the object from string to an instancetype
of a test case?

 

I am quite a newbie in python so I
would appreciate any help on this.

 

Regards,

Deepali

 






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

Re: Rss lib in python?

2005-05-31 Thread lihui
Please use feedparser:

 http://feedparser.org/

2005/6/1, Grant Edwards <[EMAIL PROTECTED]>:
> On 2005-06-01, Owen <[EMAIL PROTECTED]> wrote:
> 
> > i want to know some rss library in python.For example, some
> > for rss readers, and some for generator.
> 
> http://www.learnwebskills.com/search/main.html
> http://www.learnwebskills.com/search/google.html
> 
> Googling for "python rss library" generate a whole page
> full of useful looking stuff:
> 
>   http://www.google.com/search?q=python+rss+library
> 
> Here's an RSS aggregator written in Python:
> 
>   http://offog.org/code/rawdog.html
> 
> --
> Grant Edwards   grante Yow!  HOW could a GLASS
>   at   be YELLING??
>visi.com
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
my gmail:lihuimail(at)gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rss lib in python?

2005-05-31 Thread Grant Edwards
On 2005-06-01, Owen <[EMAIL PROTECTED]> wrote:

> i want to know some rss library in python.For example, some
> for rss readers, and some for generator.

http://www.learnwebskills.com/search/main.html
http://www.learnwebskills.com/search/google.html

Googling for "python rss library" generate a whole page
full of useful looking stuff:

  http://www.google.com/search?q=python+rss+library

Here's an RSS aggregator written in Python:

  http://offog.org/code/rawdog.html

-- 
Grant Edwards   grante Yow!  HOW could a GLASS
  at   be YELLING??
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-31 Thread Tassilo v. Parseval
Also sprach Dale King:

> David Formosa (aka ? the Platypus) wrote:
>> On Tue, 24 May 2005 09:16:02 +0200, Tassilo v. Parseval
>> <[EMAIL PROTECTED]> wrote: 
>> 
>>> [...] I haven't yet come across a language that is both statically and
>>>strongly typed, in the strictest sense of the words. I wonder whether
>>>such a language would be usable at all.
>> 
>> 
>> Modula2 claims to be both statically typed and strongly typed.  And
>> your wonder at its usablity is justified.
>
> I used a variant of Modula-2 and it was one of the best languages I have 
> ever used. That strong, static type checking was a very good thing. It 
> often took a lot of work to get the code to compile without error. 
> Usually those errors were the programmers fault for trying to play fast 
> and loose with data. But once you got it to compile it nearly always worked.

I am only familiar with its successor Modula-3 which, as far as I
understand, is Modula-2 with uppercased keywords and some OO-notion
bolted onto it (I still recall 'BRANDED' references). 

I have to say that doing anything with this language was not exactly a
delight.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rss lib in python?

2005-05-31 Thread lihui
PyRSS2Gen

http://www.dalkescientific.com/Python/PyRSS2Gen.html

example:
mport datetime
import PyRSS2Gen

rss = PyRSS2Gen.RSS2(
title = "Andrew's PyRSS2Gen feed",
link = "http://www.dalkescientific.com/Python/PyRSS2Gen.html";,
description = "The latest news about PyRSS2Gen, a "
  "Python library for generating RSS2 feeds",

lastBuildDate = datetime.datetime.now(),

items = [
   PyRSS2Gen.RSSItem(
 title = "PyRSS2Gen-0.0 released",
 link = "http://www.dalkescientific.com/news/030906-PyRSS2Gen.html";,
 description = "Dalke Scientific today announced PyRSS2Gen-0.0, "
   "a library for generating RSS feeds for Python.  ",
 guid = PyRSS2Gen.Guid("http://www.dalkescientific.com/news/";
  "030906-PyRSS2Gen.html"),
 pubDate = datetime.datetime(2003, 9, 6, 21, 31)),
   PyRSS2Gen.RSSItem(
 title = "Thoughts on RSS feeds for bioinformatics",
 link = "http://www.dalkescientific.com/writings/diary/";
"archive/2003/09/06/RSS.html",
 description = "One of the reasons I wrote PyRSS2Gen was to "
   "experiment with RSS for data collection in "
   "bioinformatics.  Last year I came across...",
 guid = PyRSS2Gen.Guid("http://www.dalkescientific.com/writings/";
   "diary/archive/2003/09/06/RSS.html"),
 pubDate = datetime.datetime(2003, 9, 6, 21, 49)),
])

rss.write_xml(open("pyrss2gen.xml", "w"))




31 May 2005 20:10:20 -0700, nephish <[EMAIL PROTECTED]>:
> Hey man, i would like to know this too.
> hope someone knows...
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
my gmail:lihuimail(at)gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scripting browsers from Python

2005-05-31 Thread Olivier Favre-Simon
On Tue, 31 May 2005 00:52:33 -0700, Michele Simionato wrote:

> I would like to know what is available for scripting browsers from
> Python.
> For instance, webbrowser.open let me to perform GET requests, but I
> would like
> to do POST requests too. I don't want to use urllib to emulate a
> browser, I am
> interested in checking that browser X really works as intended with my
> application. Any suggestion?
> 
>Michele Simionato


ClientForm  http://wwwsearch.sourceforge.net/ClientForm/

I use it for automation of POSTs of entire image directories to
imagevenue.com/imagehigh.com/etc hosts.

Works above urllib2.

You access forms by name or indice, then you access HTML elements as a
dict attribute of the form.

Support file upload within POST.

The only drawback I've found are:
- does not support nested forms (since forms are returned in a list)
- does not like ill-formed HTML (Uses HTMLParser as the underlying parser.
you may pass a parser class as parameter (say SGMLParser for greater
acceptance of stupid HTML code) but it's tricky because there is no well
defined parser interface)

Hope this helps.

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


Re: Software licenses and releasing Python programs for review

2005-05-31 Thread poisondart
> I'm a little curious about your position.
>
> Though code encodes knowledge (hence the word, of course :-), the
> system of concepts embodied in your code is not the same thing as the
> code itself.  Right?
>
> So, firstly, I don't follow your argument there: how does it follow
> from the fact that scientific and mathematical knowledge should not be
> treated by the law as - in some sense - property (a moot point of
> course, though I lean towards your view) that it doesn't 'make sense'
> (scare quotes because I'm not sure of your precise meaning) to sell
> your software for profit?

Hi,
I view my situation from the point of view of a teacher. That is, to
allude to a proverb, I'm trying to teach a person how to fish. I did
not invent the knowledge of fishing and selling this knowledge is not
what I want to do. I believe that I am putting this knowledge into a
form which I deem learnable for the student.

>
> Secondly, do you think it's a bad thing for anybody to sell software
> that makes use of the *concepts* in your code (provided that the use
> of those concepts is not restricted by financial or other legal
> means)?  If so, why?
>
>
> John

To be honest. I'm not sure. The knowledge that I learnt was all given
to me freely, I just consolidated it into these programs. I feel that
it would be unfair that along this chain of knowledge passing, one
person decided to exploit the free system and harbour his knowledge for
profit.
(Please read the next thread...)

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


Re: Incrementing letters

2005-05-31 Thread Dan Sommers
On 27 May 2005 10:52:36 -0400,
Dan Sommers <[EMAIL PROTECTED]> wrote:

> And use string.ascii_letters[ 1 : ] + string.ascii_letters[ 0 ] for the
> second parameter to string.maketrans.

Oops.  Thank you Duncan and Rocco for correcting my mistake.

Regards,
Dan

-- 
Dan Sommers

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


Re: Rss lib in python?

2005-05-31 Thread nephish
Hey man, i would like to know this too.
hope someone knows...

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


Rss lib in python?

2005-05-31 Thread Owen
Hi all,

i want to know some rss library in python.For example, some for rss
readers, and some for generator.

Thanks for any information.

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


Re: The need to put "self" in every method

2005-05-31 Thread John Machin
Skip Montanaro wrote:
> Simon> Of course, if you *don't* use 'self', you should expect an angly
> Simon> mob with pitchforks and torches outside your castle.
> 
> I take it an "angly mob" is a large group of stick figures? 
> 
> Skip

Yep -- straw men.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The need to put "self" in every method

2005-05-31 Thread Skip Montanaro

Simon> Of course, if you *don't* use 'self', you should expect an angly
Simon> mob with pitchforks and torches outside your castle.

I take it an "angly mob" is a large group of stick figures? 

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


Re: pickle alternative

2005-05-31 Thread Andrew Dalke
simonwittber wrote:
> marshal can serialize small structures very qucikly, however, using the
> below test value:
> 
> value = [r for r in xrange(100)] +
> [{1:2,3:4,5:6},{"simon":"wittber"}]
> 
> marshal took 7.90 seconds to serialize it into a 561 length string.
> decode took 0.08 seconds.

Strange.  Here's what I found:

>>> value = [r for r in xrange(100)] +[{1:2,3:4,5:6},{"simon":"wittber"}]
>>> import time, marshal
>>> t1=time.time();s=marshal.dumps(value);t2=time.time()
>>> t2-t1
0.22474002838134766
>>> len(s)
561
>>> t1=time.time();new_value=marshal.loads(s);t2=time.time()
>>> t2-t1
0.3606879711151123
>>> new_value == value
True
>>> 

I can't reproduce your large times for marshal.dumps.  Could you
post your test code?

Andrew
[EMAIL PROTECTED]

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


ignoring SIGPIPE in a python script?

2005-05-31 Thread Dan Stromberg

I have a python script that sometimes gets a SIGPIPE signal, and errors
out.  And I want it to just terminate as though it had hit EOF.

I'm running:

   signal.signal(signal.SIGPIPE,signal.SIG_IGN)

...in the main function, but the script is still erroring out on sigpipe
when the consumer to its producer terminates early.

Am I going to have to code in a handful of exceptions, and then
conditionalize what happens in those exception handlers, to get the
desired behavior?

ISTR hearing that although bash notifies one of SIGPIPE errors, tcsh
generally silently ignores them.  From this, I conclude that it might be
reasonable for my script to ignore SIGPIPE.

Thanks!

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


Re: Questions on using Qt or wxWindows with Python and OS X

2005-05-31 Thread Kevin Walzer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I maintain a lot of wxPython and PyQt packages for OS X: in fact, I
released the first generally available binary installer for PyQt on the
Mac. I'm not at an advanced level with either toolkit, but here's my two
cents:

1. Both are robust in the sense of being powerful, fairly comprehensive
toolkits. You probably know that already, but in terms of Python
development on the Mac, either is a viable choice.

2. In terms of developer resources, I'd say that wxPython is clearly
farther along on the Mac. There are more users, more informal
documentation (in terms of tutorials, wikis, etc., especially for
Mac-specific issues), more active development from a hands-on core of
developers, and so on. wxPython also has the advantage of looking
completely native, as it wraps the native Aqua widgets. The wxPython-OS
X package has been a bit buggy in the past, but now at 2.6.0 I'd say
it's very strong.

3. With PyQt, you're more in the wilderness. The Mac community is *very*
small, and as such there's a lot of uncharted territory in terms of
documentation, best practices, etc. The most lively community for PyQt
is, not surprisingly, based on Linux; you'll find mailing lists and lots
of online tutorials geared for Linux. Supporting the Mac also isn't the
main priority for the chief developer of PyQt. I'm not an experienced
enough Python developer to add much to PyQt per se: I released the
binary package simply because I had some experience building Qt apps,
wanted to try PyQt anyway, and figured it would be a useful service to
become the de-facto Mac maintainer.

Another drawback to PyQt is that Qt apps, in general, don't look as
native as wxPython. The differences are subtle but they are noticable.

Even with these cautios, PyQt runs very well on the Mac, and I've built
a few PyQt applications that ran with no modification on my part.
wxPython apps require some hacks to get all the Mac gui conventions
right (i.e. the help menu, about menu, etc.)  This is a testament to the
fact that, at its core, Qt is a very well-designed and documented toolkit.

My personal preference is for wxPython, as it just fits my brain better.
Qt's "signals and slots" approach is, for me, counterintuitive. But I'll
~ continue to support PyQt as long as there's a need for it.

If you want more information, see my software site:
http://www.wordtech-software.com/python.html

I've also done a lot of discussion of Python development on the Mac at
my blog:

http://www.kevin-walzer.com

Hope this helps.

Kenneth McDonald wrote:
| If this is not an appropriate newsgroup for this type of posting,
| please let me know and (if possible) suggest an alternative. I've
| done a fair bit of research on the net, but information is scattered
| all over the place and I haven't been able to find mailing lists
| relating specifically to python and UIs.
|
| I'd like to start using Python for some GUI programming again. I'd
| like to use Tk, but it seems to be dying a slow death, so it's
| probably time to look at wxPython and PythonQt.
|
| I'd appreciate any comments on the relevant merits of these two
| libraries, both with respect to Python and more generally. I know
| about the differences in licensing, that's not an issue. My most
| specific concerns are ease of use (which includes how much in the way
| of documentation or examples for using through Python are available,
| and how easy the Python libs are to use in each case); availability of
| a generally capable styled text widget, as one of the things I need to
| build is an editor, which needs to be able to handle different fonts,
| styles, tabs, and so forth; and ease of installation on a Macintosh,
| since that is my preferred dev platform, and installing things made
| for other UNIX variants can be a little wonky at times.
|
| I'm also curious as to the quality of documentation available for
| wxPython and wxWindows, and any differences between the
| wxWindows text widget (which is generally Scintilla I believe),
| and the Qt text widget classes. I've had a hard time finding good
| docs for wxWindows or wxPython, and the bit of documentation
| on Scintilla I've found and read seems to indicate that it has some
| restrictions, such as needing to use the same line height for all lines
| regardless of content.
|
| Many thanks for any feedback you can give.
|
|
| Cheers,
| Ken


- --
Cheers,

Kevin Walzer, PhD
WordTech Software--Open Source Applications and Packages for OS X
http://www.wordtech-software.com
http://www.kevin-walzer.com
mailto:[EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCnQ1mJmdQs+6YVcoRAub0AJ9fw6yLi+ZarCnT9AbaR3CotKfqeACeN1rI
quUqc9dh7LKXLUs6IQFlz9o=
=SwEx
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Version 0.9 of RUR-PLE

2005-05-31 Thread =?ISO-8859-1?Q?Andr=E9_Roberge?=
Version 0.9 of RUR: a Python Learning Environment has been released.
Information about RUR-PLE can be obtained at
http://rur-ple.sourceforge.net

Note that the project website is slightly out of date.

Among the changes in this new version:

***Spanish translation added.*

Changed image for language selection to reflect addition.

Changed directory structure of lessons.

Fixed "non-existent file" problem when changing language
with unstranslated lesson file open in browser; the
browser will open the default file in the chosen language
instead.

Changed dialogs (beepers to robot and resize world)
to use GridBagSizer for layout as opposed to specific
coordinates.

Added parameter  wx.BUFFER_VIRTUAL_AREA in
dc = wx.BufferedPaintDC(self, self.buffer, wx.BUFFER_VIRTUAL_AREA)
in world_display.py; this is required to get proper scrolling
since wxPython 2.5.4.1.

Added SetFocus() when positioning sizer on "Robot: code and learn"
page.  This gets rid of the unwanted grey background.

Changed list of beepers that can be placed at an intersection from
0 ... 15, 16, 17, 18, 19, 20  to
0 ... 15, 20, 40, 60, 80, 99.

Removed the "from __future__ import division" command to the interpreter.
Since this is not likely to be the default version for a *long* time, it 
seems
a better idea to revert to the default behaviour for the interpreter.
TODO: The lesson needs to be updated to reflect this change.

World redrawn immediately after selecting a new language, so that
the words "streets" and "avenues" are updated right away.

Corrected tooltip language setting on speed selection slider.

Added possibility to change background colour of robot world
through user program.  This is to be used in the random maze escape lesson.

Changed the 20 robot images so that their background
is transparent.

Removed obsolete self-testing code in various files as well as
redundant import statements.

Fixed problem with seemingly random
"invalid world file" error.  This occured when
a robot was removed from the world, and an
attempt was made at resetting the world.

Added SetFocus() to WorldGui.OnLeftDown().  Somehow,
the WorldGUI (i.e. robot world) would no longer get focus
as a matter of course when left-clicked.  This meant that it
was no longer possible to position the robot using the cursor keys.
This problem has appeared since I made the switch to
wxPython 2.6.

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


Re: running tkinter

2005-05-31 Thread flamesrock
I'm having the same problem (latest gentoo 2005.0) and I've installed
the tcl and tk languages.

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


Re: Swig compile errors

2005-05-31 Thread [EMAIL PROTECTED]
Nop No luck. That dint work.

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


Re: The need to put "self" in every method

2005-05-31 Thread Peter Hansen
John Machin wrote:
> Simon Brunning wrote:
>> Of course, if you *don't* use 'self', you should expect an angly mob
>> with pitchforks and torches outside your castle.
> 
> Wouldn't an angly mob be carrying fishing rods?

No, I rather think they'd be acutely obtuse, right?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Swig compile errors

2005-05-31 Thread John Machin
[EMAIL PROTECTED] wrote:
> Hi I am trying to write a python wrapper for a C code I have using
> swig. when i try to compile the _wrap.c i get a bunch of these warnings
> and errors can anyone help
> Steps I followed :
> 
> $swig -python test_hk.c
> this generates test_hk.py and test_hk_wrap.c
> then i compile it as
> 
> $gcc -Wall -std=c99 test_hk.c test_hk_wrap.c -I/usr/include/python2.3/

Worth a try:

gcc -Wall -std=c99 -I/usr/include/python2.3/ test_hk.c test_hk_wrap.c


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


Re: The need to put "self" in every method

2005-05-31 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 Carl Friedrich Bolz <[EMAIL PROTECTED]> wrote:

> John Machin wrote:
> 
> >>Of course, if you *don't* use 'self', you should expect an angly mob
> >>with pitchforks and torches outside your castle.
> >>
> > 
> > Wouldn't an angly mob be carrying fishing rods?
> > 
> 
> Well, I thought they would be carrying pitchfolks and tolches.

You sure that's not perchforks?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The need to put "self" in every method

2005-05-31 Thread Carl Friedrich Bolz
John Machin wrote:

>>Of course, if you *don't* use 'self', you should expect an angly mob
>>with pitchforks and torches outside your castle.
>>
> 
> Wouldn't an angly mob be carrying fishing rods?
> 

Well, I thought they would be carrying pitchfolks and tolches.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with re.match - Newbie needs some advice

2005-05-31 Thread John Machin
rh0dium wrote:
> Hi all,
> 
>I can't seem to get into the
> second re.match.  Can someone point out my apparent error?

errorS:
1. Imprecision -- the problem is in the *third* re.match ...
2. ... which should be re.search
3. Using re at all when simple string methods would do -- see below

[snip]
> for line in self.cpudata:
> # Remove the newlines..
> ### line=line.strip()
   tokens = line.split()
> ### if re.match(r"^processor\s+:", line):
   if tokens[0] == "processor":
> cpucount += 1
> ### if re.match(r"^flags\s+:", line):
   elif tokens[0] == "flags" and "ht" in tokens:
> ### flags=re.split(r":\s",line)
>  print "Found flags", flags[1]
> ### if re.match(r"\bht\b",flags[1]):
> print "HT on"
> ht=1
-- 
http://mail.python.org/mailman/listinfo/python-list


Swig compile errors

2005-05-31 Thread [EMAIL PROTECTED]
Hi I am trying to write a python wrapper for a C code I have using
swig. when i try to compile the _wrap.c i get a bunch of these warnings
and errors can anyone help
Steps I followed :

$swig -python test_hk.c
this generates test_hk.py and test_hk_wrap.c
then i compile it as

$gcc -Wall -std=c99 test_hk.c test_hk_wrap.c -I/usr/include/python2.3/

/usr/lib/gcc-lib/i486-linux/3.3.5/../../../crt1.o(.text+0x18): In
function `_start':
../sysdeps/i386/elf/start.S:98: undefined reference to `main'
/tmp/ccayOWVb.o(.text+0xb6f): In function `PySwigObject_repr':
: undefined reference to `PyString_FromFormat'
/tmp/ccayOWVb.o(.text+0xbe1): In function `PySwigObject_str':
: undefined reference to `PyString_FromString'
/tmp/ccayOWVb.o(.text+0xc22): In function `PySwigObject_long':
: undefined reference to `PyLong_FromUnsignedLong'
/tmp/ccayOWVb.o(.text+0xc87): In function `PySwigObject_oct':
: undefined reference to `PyOS_snprintf'
and a bunch of them..

: undefined reference to `PyModule_GetDict'
collect2: ld returned 1 exit status

do I have to include any libraries or whats it that I am missing.

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


Re: DLL load failed: The specified procedure could not be found

2005-05-31 Thread John Machin
Bill Davy wrote:
> sys.path:
>  H:\Husky\HostPC\V1\SHIP\Debug
>  H:\Husky\HostPC\V1\SHIP
>  E:\Bill\Python-2.4.1\PCbuild\python24_d.zip
>  C:\Python24\Lib
>  C:\Python24\DLLs
>  C:\Python24\Lib\lib-tk
>  H:\Husky\HostPC\V1\RunSHIP
>  H:\Husky\HostPC\V1\Debug
>  C:\Python24
>  C:\Python24\lib\site-packages
> 
> Traceback (most recent call last):
>   File "H:\Husky\HostPC\V1\SHIP\test1.py", line 7, in ?
> import SHIP
>   File "H:\Husky\HostPC\V1\Debug\SHIP.py", line 5, in ?
> import _SHIP
> ImportError: DLL load failed: The specified procedure could not be found.
> 
> a) What "specified procedure "
> b) SHIP was made by SWIG

and so presumably was _SHIP ... therefore it appears that you might be 
better off asking for help on the SWIG mailing list.

> c) Is there some way to find out which DLL and which procedure is involved?

One would expect given the reported context (import _SHIP) that it has 
found (somewhere!) a DLL called "_SHIP.pyd" and is looking in it 
(unsuccessfully) for an entrypoint called "init_SHIP".

The usual suspect here would be the C (or C++) compiler messing with the 
name of the entrypoint; possible messes include underscores at the front 
and/or frame size at the end e.g. "[EMAIL PROTECTED]" instead of just 
"initfoo". Possibly you are using a C[++] compiler that's not the one 
that SWIG thinks you are using.

But exactly which DLL? Given your "interesting" sys.path, it might be an 
idea to run python with the -v argument, so you can see where all your 
imports are resolved.

Once you have worked out which _SHIP.pyd is the cause, you can inspect 
it and determine what entrypoint(s) it has.

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


cgi help

2005-05-31 Thread nephish
Hey there,
i am trying to write an online application using the cgi module.
what i want to do is have an html form display a drop-down list and
have the values of that list be the lines of text written in a file.
this would be updated almost every time the site is visited.
i have been sucessful in writing text to a file from an html form. but
i need to access this so it can be selected.
is there a way to do this? i have found limited info on how to really
use the cgi module.  so if there is more indepth tutorials or docs on
the use of this module, that may be helpful also.
what i mean is. i am willing to rtfm, if i can find one.
thanks,

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


What's wrong with Zope 3 ?

2005-05-31 Thread Kay Schluehr
The last downloadable release is from november 2004. The Windows
installer is configured for Python 2.3(!). The Zope.org main page
announces Zope 2.8 beta 2. Is it stillborn? 

Kay

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


ANN: PyAuthD - beta 3

2005-05-31 Thread Heiko Wundram
Hi all!

I've tagged PyAuthD, beta 3 today. This release marks a milestone, as PyAuthD 
has superseded PyPAM and PyNSS (the precursors not implemented on a 
client/server model which are private to my univ) on the mail server which 
hosts our university's student email accounts.

I'm able to release a demo server along with the actual modules (and 
an !untested! Postfix patch to enable PyAuthD to serve Postfix maps) under an 
adapted BSD license.

What is PyAuthD?


A client/server implementation of a Python authentication daemon. The 
initiative to implement a Python authentication daemon came from the fact 
that MS SQL-Server is used as the backend server for our univ's HIS 
(Hochschul-Informations-System, university information system), and there are 
no proper PAM and NSS modules which can access MS SQL-server (as far as I 
found).

Looking at the winbind sources (of the samba project) taking the step to 
implement short and concise C modules which access a Python daemon which does 
the actual handling wasn't much farfetched.

Currently, PyAuthD offers:

1) PAM authentication
2) NSS handling by dispatching to the server process on get(pw/sp/gr)* 
functions, which foregoes reentrancy issues
3) PPPd authentication which requires the authentication daemon to hand out 
clear-text passwords over the socket
4) Untested Postfix map implementation

This allows unprecedented abilities for authentication purposes by being able 
to program authentication logic in a high-level language under a single 
unified structure.

What is it not?
---

A "round" system. PyAuthD is a system that "works for me and my univ" (TM), 
and as such I'm just releasing it (minus the actual authentication part we 
use) for all people out there who want to hack on it just as I do.

On the other hand I don't think that creating a single infrastructure is 
sensible at all, and as such won't spend much time creating any more means to 
access and compile it than I currently do.

If you feel you want to create a distribution or add autoconf/automake 
handling and are willing to spend the time, feel free to contact me!

What about security?


Currently PyAuthD will run under standard Python. "Standard Python" does not 
offer security features which enable it to work reliably in a 
multiuser-environment (as there is a requirement that all users can connect 
to it), as Python does not clear memory on releasing it making several 
attacks possible in case users have login-shells on the server.

Furthermore Linux offers the possibility to access process information on the 
connecting process of a Unix-Domain-Socket, but this functionality is not 
exposed in standard Python.

All this has led to the spin-off of a further project also hosted along with 
PyAuthD called SEPython, which aims at improving this situation. SEPython is 
currently based on standard Python 2.4.1, and has implemented the necessary 
recvmsg and sendmsg calls for retrieving process/user information from a unix 
domain socket.

SEPython hasn't implemented clearing of memory yet.

As we don't offer user-login shells on the mail-server which uses PyAuthD, we 
currently don't spend time on SEPython, but this situation will change when 
the mail-server has been fully migrated to the new infrastructure.

If there's interest I'll package my patches on SEPython for inclusion in the 
standard Python tree, but I don't think that platform-dependent patches like 
sendmsg/recvmsg will ever make it into the official tree.

ChangeLog
-

Please look at the commit log since tag beta-2.

Download


Access using Subversion:

svn co http://svn.asta.mh-hannover.de/svn/repos/PyAuthD/tags/beta-3 PyAuthD

or ViewCVS:

http://svn.asta.mh-hannover.de/viewcvs/PyAuthD/tags/beta-3/

License
---

PyAuthD as in subversion is released under an adapted BSD-license, except the 
Postfix module, which is released under the Postfix Secure Mailer license.

Contact
---

Heiko Wundram <[EMAIL PROTECTED]>
or
Heiko Wundram <[EMAIL PROTECTED]>

-- 
--- Heiko.
listening to: De/Vision - Miss You More
  see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/


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

Re: The need to put "self" in every method

2005-05-31 Thread John Machin
Simon Brunning wrote:
> On 31 May 2005 08:45:45 -0700, Fernando M.
> <[EMAIL PROTECTED]> wrote:
> 
>>i was just wondering about the need to put "self" as the first
>>parameter in every method a class has because, if it's always needed,
>>why the obligation to write it?
> 
> 
> It doesn't need to be 'self'. You could use 'this', or 's', or whatever.
> 
> Of course, if you *don't* use 'self', you should expect an angly mob
> with pitchforks and torches outside your castle.
> 

Wouldn't an angly mob be carrying fishing rods?


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


Problem with re.match - Newbie needs some advice

2005-05-31 Thread rh0dium
Hi all,

I am having a problem with the method cpuNum.  Basically I look to see
if the "flag" for "ht" is enabled.  If it is the total processors
should be cpucount/2.  It's not working.  I can't seem to get into the
second re.match.  Can someone point out my apparent error?

class Sysinfo:
def __init__(self, cpuinfo="/proc/cpuinfo",
meminfo="/proc/meminfo"):
cpustat = open(cpuinfo)
self.cpudata = cpustat.readlines()
cpustat.close()

def cpuNum(self):
cpucount=0
ht=0
for line in self.cpudata:
# Remove the newlines..
line=line.strip()
if re.match(r"^processor\s+:", line):
cpucount += 1
if re.match(r"^flags\s+:", line):
flags=re.split(r":\s",line)
#print "Found flags", flags[1]
if re.match(r"\bht\b",flags[1]):
print "HT on"
ht=1
if ht:
return cpucount/2
else:
return cpucount

s = Sysinfo( cpuinfo="cpuinfo.1", meminfo="meminfo.1" )
print s.cpuNum()


 cpuinfo.1 (abbreviated) 
processor   : 0
flags   : cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss
ht tm pbe cid

processor   : 1
flags   : cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss
ht tm pbe cid

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


Re: anygui,anydb, any opinions?

2005-05-31 Thread Shane Hathaway
rzed wrote:
> That's all I'm talking about here. To be able to write a Python 
> application that can ultimately be displayed using wxWidgets or Qt 
> or Tkinter or Curses. Then, without having to do more than to 
> change which interface package is imported, to expect to see the 
> result displayed. To have it just happen, and to have expectations 
> when using Python that it *will* just happen that way.
> 
> So what do you think? What's wrong with the picture? Why isn't 
> there a greater priority to work in this direction?

See "The Law of Leaky Abstractions" by Joel Spolsky.

http://www.joelonsoftware.com/articles/LeakyAbstractions.html

As he says, "All non-trivial abstractions, to some degree, are leaky."
GUI abstractions tend to leak badly.  As I write this email in
Thunderbird, my initial impression is that most of the controls on the
screen are pretty standard and could be done with virtually any
toolkit... or are they?  Looking again, the "from" field has both a
place for me to type and some grayed out text that reminds me I'm
posting from a different account; the "to", "cc", and "newsgroup" fields
are not quite combo boxes; the toolbar has pulldown buttons.

So it turns out that Thunderbird is actually tied to a particular
toolkit, and for good reason: GUI development has not stagnated; toolkit
developers continue to invent new, interesting widgets and variations,
leading to better UIs.  Application developers want to take advantage of
those innovations.

Even anydbm is a pretty leaky abstraction.  I recently tested the
behavior of 5 Python dbm implementations when they run out of disk
space.  Most left the database in an inconsistent state, some swallowed
the exception, some segfaulted, and one deadlocked.  If I'm going to
rely on a dbm module, I really need to know what it's going to do when
it hits an exceptional condition.  Thus anydbm seemed like a bad choice.

Shane

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


Re: convert a string to tuple

2005-05-31 Thread flamesrock
lol

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


Re: something like CPAN, PPMs?

2005-05-31 Thread Michael Hoffman
Alex Gittens wrote:
> I'm new to Python from Perl, and loving it. Has there ever been any
> discussion of creating a similar resource as CPAN for Python,

PyPI.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 CVS broken for HP-UX platform?

2005-05-31 Thread =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
mg wrote:
> While trying to compile Python 2.5 from the nighlty CVS image, it raises
> the following errors on HP-UX. This disables me the use of HP-UX for
> some projects:

Please submit patches to sf.net/projects/python.

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


Re: convert a string to tuple

2005-05-31 Thread Peter Hansen
Steven Bethard wrote:
> Just be sure you know where your strings come from.  You wouldn't want 
> someone to pass you
> """__import__('os').system('rm -rf /')"""
> and then send that to eval. =)

Why not, Steven?  I just tried it and my compu
-- 
http://mail.python.org/mailman/listinfo/python-list


Python as client-side browser script language

2005-05-31 Thread Rune Strand
What would it take to create a Firefox extension that enables Python as
a script language in the browser - just like Javascript? Is it at all
possible? Are the hundred good reasons not to bother?

I once made an application that used MozPython[1]. It was fun and very
fast compared to the Mod_Python I eventually replaced it with. I had
to, because of all the mess updating Mozilla caused. ActiveState has a
project too [2]. But none of these can replace Javascript

Grail used Python as scrpt language, I believe. And by the
Win32-wonders of Mr. Hammeond it's possible to use Python in IE. But
what aboit a easy-to-install extension for Firefox? Wouldn't that be
cool?


[1] http://www.thomas-schilz.de/MozPython/README.html
[2] http://www.mozilla.org/catalog/architecture/xpcom/pyxpcom/

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


Re: The need to put "self" in every method

2005-05-31 Thread Piet van Oostrum
> "Fernando M." <[EMAIL PROTECTED]> (FM) wrote:

>FM> Hi,
>FM> i was just wondering about the need to put "self" as the first
>FM> parameter in every method a class has because, if it's always needed,
>FM> why the obligation to write it? couldn't it be implicit?

>FM> Or is it a special reason for this being this way?

There is.
Inside a method there are 3 kinds of identifiers:
- local ones e.g. parameters and local variables
- global ones (actually module-level)
- instance variables and methods

Because Python has no declarations there must be a different way to
indicate in which category an identifier falls. For globals it is done with
the 'global' keyword (which actually is a declaration), for instance
variables the dot notation (object.name) is used and the rest is local.
Therefore every instance variable or instance method must be used with the
dot notation, including the ones that belong to the object `itself'. Python
has chosen that you can use any identifier to indicate the instance, and
then obviously you must name it somewhere. It could have chosen to use a
fixed name, like 'this' in Java or C++. It could even have chosen to use a
keyword 'local' to indicate local ones and let instance ones be the
default. But if instance variable would be implicit, local ones should have
been explicit.
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determine if windows drive letter is hard drive or optical from python?

2005-05-31 Thread Wolfgang Strobl
Magnus Lycka <[EMAIL PROTECTED]>:

>Wolfgang Strobl wrote:
>> ... for drive in string.letters[len(string.letters)/2:]:
>
>Or better...
>..for drive in string.ascii_uppercase:
>
>string.letters differ with locale, but Windows drives are always
>only A-Z (right?) and just iterating over upper case (or lower)
>seems more clear than to iterate over half of the sum of both...

Ooops. Your're right, of course. In my defense, I could argue that it
was a cut&paste job, from a program written long ago ...

-- 
Thank you for observing all safety precautions
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running tkinter

2005-05-31 Thread James Stroud
On Tuesday 31 May 2005 01:44 pm, Jim Anderson wrote:
> Are tcl/tk still supposed to be an intergrated part of the
> python release?
>
> Do I have to download, configure, make, install tcl and tk
> packages to get tkinter running?

I had to do this. Don't forget blt.

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

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


Re: convert a string to tuple

2005-05-31 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> Pass it to eval:
> 
eval('(1, 2, 3, 4, 5)')
> (1, 2, 3, 4, 5)

Just be sure you know where your strings come from.  You wouldn't want 
someone to pass you
 """__import__('os').system('rm -rf /')"""
and then send that to eval. =)

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


Re: working with pointers

2005-05-31 Thread Shane Hathaway
Michael wrote:
> sorry, I'm used to working in c++ :-p
> 
> if i do
> a=2
> b=a
> b=0
> then a is still 2!?
> 
> so when do = mean a reference to the same object and when does it mean make
> a copy of the object??

To understand this in C++ terms, you have to treat everything, including
simple integers, as a class instance, and every variable is a reference
(or "smart pointer".)  The literals '0' and '2' produce integer class
instances rather than primitive integers.  Here's a reasonable C++
translation of that code, omitting destruction issues:

class Integer
{
private:
int value;
public:
Integer(int v) { value = v; }
int asInt() { return value; }
}

void test()
{
Integer *a, *b;
a = new Integer(2);
b = a;
b = new Integer(0);
}

In that light, do you see why a is still 2?

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


Re: convert a string to tuple

2005-05-31 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> b is a string  b = '(1,2,3,4)' to b = (1,2,3,4)

py> tuple(int(s) for s in '(1,2,3,4)'[1:-1].split(','))
(1, 2, 3, 4)

Or if you're feeling daring:

py> eval('(1,2,3,4)', dict(__builtins__=None))
(1, 2, 3, 4)

Python makes no guarantees about the security of this second one though.

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


Re: convert a string to tuple

2005-05-31 Thread [EMAIL PROTECTED]
Pass it to eval:

>>> eval('(1, 2, 3, 4, 5)')
(1, 2, 3, 4, 5)

Basically what you are doing it evaluating the repr of the tuple.

-Brett

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


Re: convert a string to tuple

2005-05-31 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, querypk wrote:

> how do I convert 
> b is a string  b = '(1,2,3,4)' to b = (1,2,3,4)

In [1]: b = '(1,2,3,4)'

In [2]: b[1:-1]
Out[2]: '1,2,3,4'

In [3]: b[1:-1].split(',')
Out[3]: ['1', '2', '3', '4']

In [4]: tuple(b[1:-1].split(','))
Out[4]: ('1', '2', '3', '4')

Ooops, you wanted ints in there:

In [5]: tuple(map(int, b[1:-1].split(',')))
Out[5]: (1, 2, 3, 4)

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: avl tree

2005-05-31 Thread =?utf-8?q?Berthold_H=C3=B6llmann?=
Zunbeltz Izaola <[EMAIL PROTECTED]> writes:

> On Mon, 30 May 2005 21:13:57 +0200, Berthold Höllmann wrote:
>
>> 
>> I'm afraid you won't be happy with the code. It's very old and likely
>> won't compile. We have an inhouse version of this module which
>> compiles and run on Sparc solaris (32 Bit) and linux x86 with Python
>> up to 2.4. I fixed some warnigs just today for compilation on Linux
>> x86_64, it also seems to work on this platform now. Installation is
>> setup.py based. I'm quite sure we once sent patches to Sam Rushing,
>> but they never made it into his release. I'll try to publish our
>> version the next days. 
>
> Thanks. I will be looking forward to the release.

You can grab it from 

  

Please report any problems to me. I'll do my best to solve them.

Regards,
Berthold
-- 
[EMAIL PROTECTED] / 
[EMAIL PROTECTED] / 
-- 
http://mail.python.org/mailman/listinfo/python-list

running tkinter

2005-05-31 Thread Jim Anderson

I have just installed Fedora Core 3 on my pc. Python runs
fine, but when I try to run tkinter the tkinter library is
not found. I tried installing python 2.4.1 and could not get
tkinter to run there either.

When I look through the build directories for 2.4.1, I find
a lib-tk, but I do not find anything for tcl. In past releases,
my recollection is that tcl/tk were part of the release and
that if TCL_LIBRARY and TK_LIBRARY environment variables were
set right, then tkinter would work.

Are tcl/tk still supposed to be an intergrated part of the
python release?

Do I have to download, configure, make, install tcl and tk
packages to get tkinter running?

Thanks for any suggestions in advance.

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


Re: Newbie Here

2005-05-31 Thread newcoder
The impression for me for python is that it can be scalable and you can
really build a full fledge application from it. In the past I used to
evangelized on certain language and think that the world is full of
philips screws that I can use my philips screwdriver to screw at. I was
totally wrong. But generally I think if you are looking at web
scripting, PHP is simple to learn and fast to execute; if you want to
automate and parse data on the fly, Perl is no doubt; and if you want
to build application and not in particular in execution speed, Python
is the way to go. I considered myself as a newbie too as I always
trying to learn a thing or two, here and there.

The way I learn to program usually I would get one of those open source
application written in whatever language I wish to learn and I would
study it from ground zero. I would try to understand the programmer
style and also try to understand his logic and why he want to do this
or that. You may think its crazy but I kinda like to pretend I am a
detective trying to solve a case. When you have the right attitude and
fun, you will pick up fast. This way you will basically learn
everything. Books are good but just don't get sucked into everything. I
discovered that in real programming life, 80% of what you apply comes
from the 20% of the knowledge you've learn. Just my n cents worth.

Pardon my political incorrect grammar if any, as I am not a native
english speaker.


Mark Sargent wrote:
> Hi All,
>
> I'm taking the plunge into Python. I'm currently following this tutorial,
> http://docs.python.org/tut/
> I am not a programmer in general, although I've learnt a bit of bash
> scripting and some php/asp. I want to get into python to use it for
> Linux/Unix related stuff. A question I have, is, those of you who use it
> for the same things, what do you primarily use it for. Could you show me
> some examples.? I find the hardest thing with programming, is not
> remember the syntax/logic etc, but, when to use it. Perhaps that is also
> a personal thing, but, I'd love to see some basic examples out there.
> Cheers.
> 
> Mark Sargent.

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


convert a string to tuple

2005-05-31 Thread querypk
how do I convert 
b is a string  b = '(1,2,3,4)' to b = (1,2,3,4)

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


Re: exit after process exit

2005-05-31 Thread Jeff Epler
You might want
os.spawnv(os.P_WAIT, "a.exe", ["a.exe"])

os.system("a.exe")

Jeff


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

Re: how to prepend string to a string?

2005-05-31 Thread newcoder
How about this:

dirList = ['depth1', 'depth2', 'depth3']
string = """position"""

for x in range(len(dirList)):
string += '>> %s' % dirList.pop(0)

print string



flamesrock wrote:
> Thanks for all the responses :)
>
> You're right, Kent. That does exactly what I need it to.
>
> Anyways.. if there isn't a prepend function, I'm going to request it
> from the devs. Would be cool to see that in future versions of python.

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


Re: working with pointers

2005-05-31 Thread Rocco Moretti
> "Dave Brueck" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
>>Michael wrote:
>>
>>>sorry, I'm used to working in c++ :-p
>>>
>>>if i do
>>>a=2
>>>b=a
>>>b=0
>>>then a is still 2!?
>>>
>>>so when do = mean a reference to the same object
>>
>>Always.
>>
>>
>>>and when does it mean make a copy of the object??
>>
>>Never.
>>

Michael wrote:
 > except numbers??
 >

1) Please avoid top posting

2) '=' always makes a reference. It's just that

'b = 0' makes a *new* reference for b to 0, without changing the 
reference of a to 2.

b.pop() modifies the object referenced by b itself, which, since it is 
referenced by both a & b, means that the object referenced by a is also 
modified.

see also:

http://starship.python.net/crew/mwh/hacks/objectthink.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with pointers

2005-05-31 Thread Grant Edwards
On 2005-05-31, Michael <[EMAIL PROTECTED]> wrote:

> except numbers??

Um, no?

Unless you provide some context, how are we supposed to know
what you're asking about?

Numbers are immutable, so there is no practical difference. 

-- 
Grant Edwards   grante Yow!  Are we THERE yet? My
  at   MIND is a SUBMARINE!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Stupid Newbie Question Concerning CGI and Reading Forward Slashes

2005-05-31 Thread Joey C.
Steve Holden wrote:
> It's not a common question, but it's relatively easily answered. You are
> splitting everything but the filename off with os.path.split and then
> complaining about the result! Once you stop doing that your problem is
> solved.

Thus, it's a stupid newbie question.  Thanks a lot for your help.  It
seems I was just being plain stupid.

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


Re: working with pointers

2005-05-31 Thread Chris Cioffi
Nope, numbers too.  When you do:
 
a = 4
 
You are storing a reference to the literal 4 in a.   
>>> a = 4>>> dir(a)['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getne
wargs__', '__hash__', '__hex__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__redu
ce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__str__', '__sub__', '__truediv__', '__xor__']
>>>
 
Unlike a list, there is no way to alter the interger value of 4.
 
If we go further, and then do something like:
>>> b = a>>> b4>>>
 
Both a and b refer to the same object, in this case the 4 object.
 
If you want a copy of the object check out the copy module.
 
Chris 
On 31/05/05, Michael <[EMAIL PROTECTED]> wrote:
except numbers??"Dave Brueck" <[EMAIL PROTECTED]
> wrote in messagenews:[EMAIL PROTECTED]> Michael wrote:> > sorry, I'm used to working in c++ :-p> >> > if i do> > a=2> > b=a
> > b=0> > then a is still 2!?> >> > so when do = mean a reference to the same object>> Always.>> > and when does it mean make a copy of the object??
>> Never.>> -Dave--http://mail.python.org/mailman/listinfo/python-list-- "I was born not knowing and have had only a little time to change that here and there." -- Richard Feynman 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: working with pointers

2005-05-31 Thread Steven Bethard
Michael wrote:
> if i do
> a=2
> b=a
> b=0
> then a is still 2!?
> 
> so when do = mean a reference to the same object and when does it mean make
> a copy of the object??

It *always* means a reference. It *never* makes a copy.

Although the terminology isn't quite right, you can think of all 
"variables" in Python being "references".  Assignment statements in 
Python then simply change the object that a "variable" "points" to.

Your example with integers:

py> a = 2
py> b = a
py> b = 0
py> a
2
py> b
0

A simlar example with lists:

py> a = [5, 7]
py> b = a
py> b = []
py> a
[5, 7]
py> b
[]

Of course, if you modify an object while two names are bound to it ("two 
variables hold pointers to it") then the modifications will be visible 
through either name ("either pointer"):

py> a = [5, 7]
py> b = a
py> a.pop()
7
py> a
[5]
py> b
[5]

Note that since integers are immutable, I can't give you a direct 
example like this with integers, but try:

py> class I(int):
...pass
...
py> a = I(42)
py> a
42
py> b = a
py> b
42
py> a.flag = True
py> b.flag
True
py> a.flag = False
py> b.flag
False

So even with ints (or at least a mutable subclass of ints), 
modifications made to an object through one name ("reference") are also 
visible through other names ("references") to that object.

HTH,

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


[no subject]

2005-05-31 Thread python-list-bounces+archive=mail-archive . com
#! rnews 1598
Newsgroups: comp.lang.python
Path: 
news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!newsfeeder.wxs.nl!textfeed1.on.meganewsservers.com!meganewsservers.com!feeder2.on.meganewsservers.com!216.196.98.140.MISMATCH!border1.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp
From: Harry George <[EMAIL PROTECTED]>
Subject: Re: something like CPAN, PPMs?
X-Nntp-Posting-Host: cola2.ca.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: <[EMAIL PROTECTED]>
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4
Lines: 38
Sender: [EMAIL PROTECTED]
Organization: The Boeing Company
References: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Date: Tue, 31 May 2005 18:58:32 GMT
Xref: news.xs4all.nl comp.lang.python:379601

Alex Gittens <[EMAIL PROTECTED]> writes:

> I'm new to Python from Perl, and loving it. Has there ever been any
> discussion of creating a similar resource as CPAN for Python, or a
> similar distribution method as PPMs? Seems like it would make a great
> language even better.
> 
> Alex
> -- 
> http://tangentspace.net/cz

CPAN:
1. A lot of the CPAN subject matter is in the base python installation.

2. Much of the remainder is associated with projects which are doing
   something else and happen to provide python bindings.

3. That leaves python-specific libraries as
   candidates for a CPAN.  See:
http://www.python.org/pypi
(see also http://www.python.org/sigs/catalog-sig/)
http://www.vex.net/parnassus/  (the original classic)

PPM:
The typical python install is:
   a) unzip and untar
   b) run "python setup.py install"

So what you are looking for is setup.py, and its module, distutils
http://docs.python.org/lib/module-distutils.html


   

-- 
[EMAIL PROTECTED]
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with pointers

2005-05-31 Thread Leif K-Brooks
Michael wrote:
> a=2
> b=a
> b=0


That's more or less equivalent to this C++ code:

int *a;
int *b;
a = new int;
*a = 2;
b = a;
b = new int;
*b = 0;
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with pointers

2005-05-31 Thread Ivan Van Laningham
Hi All--

Dave Brueck wrote:
> 
> Michael wrote:
> > sorry, I'm used to working in c++ :-p
> >
> > if i do
> > a=2
> > b=a
> > b=0
> > then a is still 2!?
> >
> > so when do = mean a reference to the same object
> 
> Always.
> 
> > and when does it mean make a copy of the object??
> 
> Never.
> 

To which I would add (without attempting to preserve Dave's admirable
brevity):

a=[3,5,6]
b=a

"b" is a reference to a; both b and a are names bound to "[3,5,6]".

a=[3,5,6]
b=a[:]

a and b are now bound to different instances of [3,5,6]

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with pointers

2005-05-31 Thread Michael
except numbers??

"Dave Brueck" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Michael wrote:
> > sorry, I'm used to working in c++ :-p
> >
> > if i do
> > a=2
> > b=a
> > b=0
> > then a is still 2!?
> >
> > so when do = mean a reference to the same object
>
> Always.
>
> > and when does it mean make a copy of the object??
>
> Never.
>
> -Dave


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


Re: working with pointers

2005-05-31 Thread Dave Brueck
Michael wrote:
> sorry, I'm used to working in c++ :-p
> 
> if i do
> a=2
> b=a
> b=0
> then a is still 2!?
> 
> so when do = mean a reference to the same object 

Always.

> and when does it mean make a copy of the object??

Never.

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


Re: plotting with Python

2005-05-31 Thread Leonard J. Reder
Hi Philippe,

You may want to look at HippoDraw application.  The web site is 
http://www.slac.stanford.edu/grp/ek/hippodraw/.  I have used both
the C++ api and python bindings.  They have a layer of python called
hippoplotter.py to make it easy to instance the basic plotting canvase
and place multiple plots on it.  This tool is built on Qt and it was
very easy for me to get going with it.

Maybe worth looking at.

Len

Philippe C. Martin wrote:

> Look at wxPython
> 
> Regards,
> 
> Philippe
> 
> 
> 
> Rolf Wester wrote:
> 
> 
>>Hi,
>>
>>I have a Python console application that is intended to be used
>>interactively and I have to add plotting capabilities (multiple XY plots
>>and if possible 2D-surface plots). I'm loocking for a reasonably fast
>>plotting library (not GPL'ed, needs not be for free) that can be used
>>under Windows. An alternative would also be a standalone application
>>that can be controlled via TCP/IP from my Python application. I tried
>>matplotlib but this is not fast enough (especially under Windows). I
>>considered PyQwt but this is GPL'ed. So I would be very appreciative for
>>any help.
>>
>>With kind regards
>>
>>Rolf Wester
> 
> 

-- 

Leonard J. Reder
Jet Propulsion Laboratory
Interferometry Systems and Technology Section 383
Email: [EMAIL PROTECTED]
Phone (Voice): 818-354-3639
Phone (FAX): 818-354-4357
Mail Address:
Mail Stop: 171-113
4800 Oak Grove Dr.
Pasadena, CA. 91109
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with pointers

2005-05-31 Thread Michael
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Michael wrote:
> > Do expicit pointers exist in python??
> >
> > if i do:
> >
> > a = [5,7]
> > b = a
> >
> > a.empty()
> >
> > b = ?
>
> This is what the interactive prompt is for.  Try it:
>
> py> a = [5,7]
> py> b = a
> py> a.empty()
> Traceback (most recent call last):
>File "", line 1, in ?
> AttributeError: 'list' object has no attribute 'empty'
>
> Well, looks like you get an AttributeError.  Let's try a method that
> actually exists instead:
>
> py> a.pop()
> 7
> py> a
> [5]
> py> b
> [5]
>
> So, as you can see, since 'a' and 'b' are both names referring to the
> same object, when you modify the object referred to by 'a', you are also
> modifying the object referred to by 'b'.
>
> > how do i do explicit pointers??
>
> I don't know what you mean by "explicit pointers".  Care to elaborate?
> It also might help if you explained what it is you think you want
> "explicit pointers" to do.
>
> STeVe

sorry, I'm used to working in c++ :-p

if i do
a=2
b=a
b=0
then a is still 2!?

so when do = mean a reference to the same object and when does it mean make
a copy of the object??

regards

Mike


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


Re: working with pointers

2005-05-31 Thread Steven Bethard
Michael wrote:
> Do expicit pointers exist in python??
> 
> if i do:
> 
> a = [5,7]
> b = a
> 
> a.empty()
> 
> b = ?

This is what the interactive prompt is for.  Try it:

py> a = [5,7]
py> b = a
py> a.empty()
Traceback (most recent call last):
   File "", line 1, in ?
AttributeError: 'list' object has no attribute 'empty'

Well, looks like you get an AttributeError.  Let's try a method that 
actually exists instead:

py> a.pop()
7
py> a
[5]
py> b
[5]

So, as you can see, since 'a' and 'b' are both names referring to the 
same object, when you modify the object referred to by 'a', you are also 
modifying the object referred to by 'b'.

> how do i do explicit pointers??

I don't know what you mean by "explicit pointers".  Care to elaborate? 
It also might help if you explained what it is you think you want 
"explicit pointers" to do.

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


working with pointers

2005-05-31 Thread Michael
Do expicit pointers exist in python??

if i do:

a = [5,7]
b = a

a.empty()

b = ?

how do i do explicit pointers??

Mike


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


Re: how to prepend string to a string?

2005-05-31 Thread Peter Hansen
flamesrock wrote:
> Thanks for all the responses :)
> 
> You're right, Kent. That does exactly what I need it to.
> 
> Anyways.. if there isn't a prepend function, I'm going to request it
> from the devs. Would be cool to see that in future versions of python.

Since strings cannot be modified in-place (they are "immutable"), the 
concept of prepend for a string is meaningless (and so is append). 
Instead, you simply build a new string from other bits, and it's 
entirely up to you which comes first and which comes second (thus 
providing implementations equivalent to prepend or append, as you need).

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


Re: scripting browsers from Python

2005-05-31 Thread John J. Lee
"Michele Simionato" <[EMAIL PROTECTED]> writes:

> I would like to know what is available for scripting browsers from
> Python.
> For instance, webbrowser.open let me to perform GET requests, but I
> would like
> to do POST requests too. I don't want to use urllib to emulate a
> browser, I am
> interested in checking that browser X really works as intended with my
> application. Any suggestion?

Yes:

http://selenium.thoughtworks.com/index.html

http://agiletesting.blogspot.com/2005/03/web-app-testing-with-python-part-2.html

http://products.actimind.com/actiWATE/


Unfortunately, there's still no free (as in speech) "macro recorder"
implemented as a browser plugin (nor even one implemented on the HTTP
level that can produce output in a form selenium understands, AFAIK).

For some other relevant links, see under "Misc Links" here (and for
that matter, the previous bullet point too):

http://wwwsearch.sourceforge.net/bits/GeneralFAQ.html


John

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


Re: anygui,anydb, any opinions?

2005-05-31 Thread max
rzed <[EMAIL PROTECTED]> wrote in news:Xns9667883C1D343jreeder@
63.223.7.253:

> So what do you think? What's wrong with the picture? Why isn't 
> there a greater priority to work in this direction?
> 

Without giving any reasons beyond intuition, I would have to say that 
it boils down to 2 things: The size and scope of gui and database 
frameworks, and the fact that opinions differ about what is 'ideal'.

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


array concatenation

2005-05-31 Thread [EMAIL PROTECTED]
Hello,
I have 2 arrays defined with different typecodes.

a = array('B', '\0', 6)
b = array('L', '\0', 526)

for i in range( 6):
a[i] = 0xFF

for i in range( 520):
b[i] = 0x

How do i concatenate these two arrays so that, i get
b =
0xff 0xff 0xff 0xff 0xff 0xff 0x 0x
...
...
0x

I need an array because i am using a buffer_info method.

-Ashton

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


Re: how to prepend string to a string?

2005-05-31 Thread flamesrock
Thanks for all the responses :)

You're right, Kent. That does exactly what I need it to.

Anyways.. if there isn't a prepend function, I'm going to request it
from the devs. Would be cool to see that in future versions of python.

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


Re: Seti-like program

2005-05-31 Thread GMane Python
I want to have a program download pictures from a netCam (Axis 2100).  So, I
want to start & stop, and also see progress (how many photos, are there
errors, did I begin encoding to DivX, etc) for multiple cameras.

-Dave
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Other examples- PCAnyWhere, a Trojan Horse .. :)
>
> Anyway, this is quite simple.
> All you realy need is a server with a GUI that listens all the time for
> incoming connections,
> and a client that will connect to the server and work in the
> background.
>
> Here are some thoughts...
>
> - Figure out what action you want the client to do. Make sure you
> have a working script that does that already, that could later be
> connected to the actual client.
> - How much control do you need over the client? do you want to just
> send commands and see the result? or do you want to recieve
> screenshots, or even "live" view of the client?
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



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


anygui,anydb, any opinions?

2005-05-31 Thread rzed
Periodically, we see questions about which gui package is best, or 
which database package to use. These questions typically trigger 
some exchanges of opinion, though of course this no one best 
answer, and eventually things quiet down until the next round.

But it seems to me that what seldom gets asked is: why is it 
Python's concern which package to use for those purposes? It seems 
to me that a proper approach from the viewpoint of the language 
itself is to provide an interface, and for the package developers 
to provide an implementation of that interface. A Python program 
would thus address its api only, leaving it up to the package to 
interpret that properly. In the ideal world, this would mean that 
any Python program could swap the gui package (or the db package) 
without changing the logic of the program. Python-the-language 
(rather than Python-the-package) would theoretically be a more 
compact download, and the hooked-in parts could be installed 
separately.

Anygui and anydb have been attempts to reach the ideal interface 
(and there are others, I think), but each has its problems and 
neither is supported or developed as fully as the idealized 
interface would require. I don't see much evidence that the various 
packages are designed to conform to those designs (and I don't 
contend that they should be required to until and unless the 
generic interfaces are in a well-developed state). But the result 
of all this is that there continues to be confusion to newbies and 
even veterans who are new to a given area or platform. Shouldn't it 
be a priority to eliminate the source of that confusion?

Now, on the grounds that practicality beats purity, it's certainly 
reasonable to argue that the current system works better. If we 
could just jump into a state where there was a perfectly-
functioning anydb and anygui, then we'd already have been there, 
but we can't and so we won't try to go in that direction at all. 
Python-the-package marches on; it can't wait for some ideal to 
coalesce before it advances. It's hard to argue too strongly 
against that view.

Then, too, it's hard to see how an anygui or (more especially, I 
think) an anydb could possibly work in the real world. The various 
approaches to windowing and databases are too different for a 
single interface to encompass them all. Some capabilities would be 
unforeseen or ignored in any such interface. That argument carries 
a lot of force. Certainly it is true that adding parameters to a 
function call to accommodate some new feature gets real old real 
soon. But while it is a strong practical argument, it is not one 
that truly wins in the long run, I think. It is an argument in 
favor of changing the way arguments are passed, so that it becomes 
possible to handle the various pieces of information the lower-
level package needs. The interface should be agnostic as much as 
possible. The package should be able to get the information it 
needs from what is passed by the api. Both of these things must be 
true.

Back when I was programming in DEC C, I saw how their 
implementation of functions like printf departed from the C 
standard by adding optional keyword parameters. Using those 
parameters, DEC's more-sophisticated filesystem could be used 
productively without going deeply into the filesystem's api. 

Of course, a program written that way wouldn't work if transferred 
unchanged to another system, but it *could* have worked if the 
other system could also either handle the keywords (or some of 
them) or ignore them. The results may not have been exactly as 
desired, but there would have been results. Similarly, an elaborate 
call that allows access to a sophisticated gui should also produce 
results if the gui is simpler. Supposing that a given parameter 
required by the second system has not been included in the first 
place, it should be possible to add that parameter without 
affecting the first system one bit. The first one would still not 
be looking for the parameter, while the second would now find it.

That's all I'm talking about here. To be able to write a Python 
application that can ultimately be displayed using wxWidgets or Qt 
or Tkinter or Curses. Then, without having to do more than to 
change which interface package is imported, to expect to see the 
result displayed. To have it just happen, and to have expectations 
when using Python that it *will* just happen that way.

So what do you think? What's wrong with the picture? Why isn't 
there a greater priority to work in this direction?

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


Re: COM+, Javascript and Python

2005-05-31 Thread Peter Hansen
dannyguindi wrote:
> Do you guys know if there is a way to do this in Linux?

What is "this"?  Your subject line provides a context, but not a problem 
to which we can give you the solution.  Please be specific.

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


Re: sys.stderr and thread

2005-05-31 Thread Michele Petrazzo
Peter Hansen wrote:
> Michele Petrazzo wrote:
>> This is the exception:
>>
>> Unhandled exception in thread started by > Thread.__bootstrap of >
>> Traceback (most recent call last):
>>   File "C:\Python23\lib\threading.py", line 451, in __bootstrap
>> self.__stop()
>>   File "C:\Python23\lib\threading.py", line 460, in __stop
>> self.__block.notifyAll()
>>   File "C:\Python23\lib\threading.py", line 256, in notifyAll
>> self.notify(len(self.__waiters))
>>   File "C:\Python23\lib\threading.py", line 238, in notify
>> currentThread() # for side-effect
>> TypeError: 'NoneType' object is not callable
> 
> 
> One of the steps the interpreter takes is to go through all modules and 
> rebind all globals to None.  I suspect currentThread is a global in the 
> above (although I thought that particular issue was fixed in Python 
> 2.4... are you running an older version?).

Like you can see (c:\python23), I'm working with python 2.3. I'll try 
with 2.4.

> 
> The "simplest" thing to do is to ignore this exception because it's 
> spurious".  One way to ignore it is simply to wrap that particular 
> daemon thread's "run" method with a "try/except: pass" so that all 
> exceptions are swallowed quietly.  Often that's not preferable, however, 
> since it will of course swallow real exceptions too.

After a lot of tries, I modify the twisted threadselectreactor with your 
hack, and now it work.

> -Peter

Thanks a lot,
Michele
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The need to put "self" in every method

2005-05-31 Thread Roy Smith
Fernando M. <[EMAIL PROTECTED]> wrote:
>i was just wondering about the need to put "self" as the first
>parameter in every method a class has because, if it's always needed,
>why the obligation to write it? couldn't it be implicit?

Didn't this exact question get asked just a few days ago?

Anyway, the short answer is:

1) Yes, it's always needed.
2) It's part of the Python design philosophy that "explicit is better
than implicit".

Note that in languages like C++ where using "this->" is optional,
people invent their own conventions for keeping local and instance
variables distinct, like prepending m_ to member names (except that
different people do it different ways, so it's more confusing).

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


Re: Running twisted http server - "Method Not Allowed" error

2005-05-31 Thread Richard Townsend
On 30 May 2005 23:50:45 -0700, [EMAIL PROTECTED] wrote:

> from twisted.web import server, resource
> from twisted.internet import reactor
> 
> class Simple(resource.Resource):
> isLeaf = True
> def render_GET(self, request):
> return "Hello, world!"
> 
> site = server.Site(Simple())
> reactor.listenTCP(8080, site)
> reactor.run()   "
> 

Try adding the line:

allowedMethods = ('GET',)

after the line 

isLeaf = True

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


Re: The need to put "self" in every method

2005-05-31 Thread Erik Max Francis
Fernando M. wrote:

> i was just wondering about the need to put "self" as the first
> parameter in every method a class has because, if it's always needed,
> why the obligation to write it? couldn't it be implicit?
> 
> Or is it a special reason for this being this way?

Because it's not always needed.  See staticmethod or classmethod.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   The basis of optimism is sheer terror.
   -- Oscar Wilde
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seti-like program

2005-05-31 Thread [EMAIL PROTECTED]
Other examples- PCAnyWhere, a Trojan Horse .. :)

Anyway, this is quite simple.
All you realy need is a server with a GUI that listens all the time for
incoming connections,
and a client that will connect to the server and work in the
background.

Here are some thoughts...

- Figure out what action you want the client to do. Make sure you
have a working script that does that already, that could later be
connected to the actual client.
- How much control do you need over the client? do you want to just
send commands and see the result? or do you want to recieve
screenshots, or even "live" view of the client?

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


Re: The need to put "self" in every method

2005-05-31 Thread Simon Brunning
On 31 May 2005 08:45:45 -0700, Fernando M.
<[EMAIL PROTECTED]> wrote:
> i was just wondering about the need to put "self" as the first
> parameter in every method a class has because, if it's always needed,
> why the obligation to write it?

It doesn't need to be 'self'. You could use 'this', or 's', or whatever.

Of course, if you *don't* use 'self', you should expect an angly mob
with pitchforks and torches outside your castle.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: COM+, Javascript and Python

2005-05-31 Thread dannyguindi
Do you guys know if there is a way to do this in Linux?
Thanks.

Danny

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


DLL load failed: The specified procedure could not be found

2005-05-31 Thread Bill Davy
sys.path:
 H:\Husky\HostPC\V1\SHIP\Debug
 H:\Husky\HostPC\V1\SHIP
 E:\Bill\Python-2.4.1\PCbuild\python24_d.zip
 C:\Python24\Lib
 C:\Python24\DLLs
 C:\Python24\Lib\lib-tk
 H:\Husky\HostPC\V1\RunSHIP
 H:\Husky\HostPC\V1\Debug
 C:\Python24
 C:\Python24\lib\site-packages

Traceback (most recent call last):
  File "H:\Husky\HostPC\V1\SHIP\test1.py", line 7, in ?
import SHIP
  File "H:\Husky\HostPC\V1\Debug\SHIP.py", line 5, in ?
import _SHIP
ImportError: DLL load failed: The specified procedure could not be found.

a) What "specified procedure "
b) SHIP was made by SWIG
c) Is there some way to find out which DLL and which procedure is involved?

It's all debug build, sys.path has all the Debug directories.

tia
Bill 


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


Re: The need to put "self" in every method

2005-05-31 Thread Steven Bethard
Fernando M. wrote:
> i was just wondering about the need to put "self" as the first
> parameter in every method a class has because, if it's always needed,
> why the obligation to write it? couldn't it be implicit?

py> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
...


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


Re: The need to put "self" in every method

2005-05-31 Thread John Roth
"Fernando M." <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> i was just wondering about the need to put "self" as the first
> parameter in every method a class has because, if it's always needed,
> why the obligation to write it? couldn't it be implicit?
>
> Or is it a special reason for this being this way?

There are two different issues.

1. If self was made a keyword, there would be no need for
it in the method header. However, that would be a major
incompabible change affecting almost every script in existance.
Also some people use other words than self. (It would,
by the way, result in a performance improvement.)

2. There's been some talk of making the '.' operator allow an
implied instance. I'm not sure what the status of this is.

These two are actually separate issues; either could be
done without the other.

John Roth

> Thanks.
> 

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


Re: How do you drive-by-wire a car using Python ?

2005-05-31 Thread [EMAIL PROTECTED]
Cameron,

Good point, I know you are a newbie :-). Let me help you out, just tell
the guy in the hallway that for the recognition of the spelling for
garbage in any other languages we use the zipfile module as pointed out
in
http://pegasusbridge.blogspot.com/2005/05/on-being-innovative-part-i.html
"...Using the Right Classification Approach

One of our approach to make classification of images for the purpose of
road following as well as obstacle avoidance is based on defining some
type of distance between drivable and non-drivable scenes. There are
many different projection techniques available in the literature. Let
us take the example of the "zipping-classifier" mechanism and how we
are using it for obstacle avoidance. This technique uses a compressor
like Winzip or 7-zip to produce some type of distance between files
(here images.) A very nice description of it can be read here"

Hope this helps :-)

Cheers,

Igor.

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


Re: how to convert string to list or tuple

2005-05-31 Thread Steven Bethard
Duncan Booth wrote:
> e.g. Assuming that the MyDatabase class does something nasty to a file:
> 
class MyDatabase(object):
> 
> def __init__(self, filename):
> self.filename = filename
> def initialise(self):
> print "Splat %s" % self.filename
> 
eval('''[ cls for cls in {}.__class__.__bases__[0].__subclasses__()
> 
> if 'MyDatabase' in `cls` 
> ][0]('importantfile').initialise()''', dict(__builtins__=None))
> Splat importantfile

Interestingly, I don't seem to be able to create a file object as a 
class attribute in restricted mode:

py> class C(object):
... def __init__(self):
... self.f = file('temp.txt', 'w')
...
py> eval('''[ cls for cls in {}.__class__.__bases__[0].__subclasses__() 
if cls.__name__ == 'C'][0]().f.write("stuff")''', dict(__builtins__=None))
Traceback (most recent call last):
   File "", line 1, in ?
   File "", line 0, in ?
AttributeError: 'C' object has no attribute 'f'
py> eval('''[ cls for cls in {}.__class__.__bases__[0].__subclasses__() 
if cls.__name__ == 'C'][0]().__dict__''', dict(__builtins__=None))
{}

I don't get an error for calling the file constructor, but the f 
attribute is never set AFAICT.

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


Re: The need to put "self" in every method

2005-05-31 Thread Steve Holden
Fernando M. wrote:
> Hi,
> 
> i was just wondering about the need to put "self" as the first
> parameter in every method a class has because, if it's always needed,
> why the obligation to write it? couldn't it be implicit?
> 
> Or is it a special reason for this being this way?
> 
> Thanks.
> 
The reason can be found in the output from the python statement "import 
this". Explicit is better than implicit.

regards
  Steve
-- 
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/

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


Dr. Dobb's Python-URL! - weekly Python news and links (May 31)

2005-05-31 Thread Simon Brunning
QOTW: "Not tested but confident should be an oxymoron for a
programmer." - Peter Otten

(Asked "Is this unsurprising if I look at it right?") -  "Yes; in
general this is true across many domains for a very large number of
referents of "it" :-)" - John Machin

"Strong typing means there [are] a lot of variables whose names are
in ALL CAPS." - Paul Rubin


One common Python "gotcha" is that default argument values are
only evaluated once, at function definition time. David Isaac
wanted to know where the values are stored:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b09b4e9a78162261

A new era in Python package management?
http://dirtsimple.org/2005/05/easyinstall-new-era-in-python-package.html

Markus would like to limit his Python script to a fixed percentage of
CPU usage:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/17f108407779536a

How do you drive-by-wire a car using Python? The Pegasus Team is
doing some very cool stuff with Python - but I'd want to see their
test results before going within a mile of the thing.

http://pegasusbridge.blogspot.com/2005/05/how-do-you-drive-by-wire-car-using.html

Michael Smith wanted to check poker-dice rolls to see if they were a
full house. Raymond Hettinger gives him general purpose card hand
detection code:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/1eb194f0547c0c49

George asks for help with a regexp to do quoted string parsing, then
is shown the light, and uses PyParsing instead.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/7756f2cca64a5def

Fuzzyman tells us how to build a Movable Python CD - that is, Python
that you can run straight off the CD without any installation - with
a custom set of packages:
http://www.voidspace.org.uk/python/weblog/arch_d7_2005_05_21.shtml#e48

Why is Python case-sensitive? Because mathematical notation is,
apparently:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/6cd17bbab3d8ae80

Mark Williamson has difficulty generating API documentation.  Python
still needs a javadoc analogue that doesn't import code, it seems:



Gabor would like to be able to write to a single text file from
multiple processes simultaneously. This is hard.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/475d065fa7871e63

Eval is unsafe at any speed. Duncan Booth takes on all comers and
shows that you can do dangerous things with eval regardless of
attempts to make it safe:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/cbcc21b95af0d9cc

Notable releases:
Twisted 2.0.1
http://twistedmatrix.com/
wxPython 2.6.0.1
http://wxpython.org/
IPython 0.6.14
http://ipython.scipy.org/



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
  

Re: prime number

2005-05-31 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
lostinpython <[EMAIL PROTECTED]> wrote:
>It is a homework assignment from a book but not for a class.  I'm
>trying to teach my self some basic programming before I have to take it
>in college.  If I show enough understanding of the subject, my advisor
>will let me forgo Intro. to Programming and go into Intro. to C++.
>What civil engineers need with all this programming is beyond me.  We
>have to learn another language to program our CADD software, which I
>find much easier than this.  But needless to say, I'm stumped on this
.
.
.
What's the crack about first place being a paid weekend vacation 
in Philadelpha, and second place five days?  Without knowledge of
the particulars of your situation, "Intro. to C++" sounds to me
more like punishment than incentive.

And I like C++.

One important instinct for your programming career is sensitivity
to "easier".  I strongly suspect, though, that there are real
values in "basic programming" that your "CADD software" has not 
yet taught you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Alternative history (was: prime number)

2005-05-31 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Mike Meyer  <[EMAIL PROTECTED]> wrote:
.
.
.
>If it isn't a homework assignment, and you're honestly in such, then
>you should know there's been a lot of research in this area, because
>primes are important in cryptographic applications. Once again, google
.
.
.
There's been a lot of research in this area because some minds
burn to grasp the beauty of number theory, and can't stop think-
ing of Number despite blindness, hunger, family, political 
oppression, and the other frailties to which humans are prone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do you drive-by-wire a car using Python ?

2005-05-31 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>Please note we had to avoid trash cans when the DARPA folks came to
>visit us. Our vehicle aims at being a garbage avoidance system instead
>:-)
>
>Igor.
>

Python clearly is unsuitable for Grand Challenges, as I believe I once
heard someone in a hallway say that it doesn't properly release garbage
back to The System, and, anyway, it doesn't recognize every spelling for
garbage used in any other language.  Python must be for weak girlie men.
-- 
http://mail.python.org/mailman/listinfo/python-list


The need to put "self" in every method

2005-05-31 Thread Fernando M.
Hi,

i was just wondering about the need to put "self" as the first
parameter in every method a class has because, if it's always needed,
why the obligation to write it? couldn't it be implicit?

Or is it a special reason for this being this way?

Thanks.

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


Re: change vars in place w/loop or list comprehension

2005-05-31 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
> I am a python newbie, and am grappling with a fundamental concept.  I
> want to
> modify a bunch of variables in place.  Consider the following:
> 
[snip]
a = 'one'
b = 'two'
c = 'three'
[a, b, c] = [s.upper() for s in [a, b, c]]
> 
> Both of these accomplish what I'm after; I prefer the second for its
> brevity.
> But either approach requires that I spell out my list of vars-to-alter
> [a, b, c] twice.  This strikes me as awkward, and would be difficult
> with longer lists. Any suggestions for a better way to do this?

While the real question is why you think you need to modify a bunch of 
variables in place**, here's one solution to the immediate problem:

for name in 'a b c'.split():
 globals()[name] = globals()[name].upper()

That, of course, will work only if they really are globals, and not if 
they are local variables inside a function.  If that's the case, you 
really want to rethink this anyway (or use Raymond's approach, though it 
still appears to require spelling out your list of names twice).

** Why you might not want to do this at all:

It's very rare in real code to need to work with a large number of 
variables as a set like that.  More generally you should probably be 
storing the strings in something like a list and manipulating them 
there.  This would look like this:

shtuff = ['a', 'b', 'c']
for i,item in enumerate(shtuff):
 shtuff[i] = item.upper()

Or, even more likely:

newList = []
for item in shtuff:
 newList.append(item.upper())

shtuff = newList


If you think you really need to do this anyway, consider posting an 
example of real code from the program you are trying to write, 
explaining the actual use case, and we can analyze the real situation 
instead of debating contrived examples.

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


Re: sys.stderr and thread

2005-05-31 Thread Peter Hansen
Michele Petrazzo wrote:
> I have a wxpython application (the main program) and a lot of external
> modules (import mymodule) that use always 2 thread (one is my
> application and one is twisted with new threadselectreactor).
> Sometime when I close my app, I receive a thread error that I want to
> redirect to a file (I don't know why this error occur, but this is
> another problem...).

This looks like it must be an exception in a *daemon* thread that is 
still running even as the Python interpreter dismantles itself at 
application exit.

> This is the exception:
> 
> Unhandled exception in thread started by  Thread.__bootstrap of >
> Traceback (most recent call last):
>   File "C:\Python23\lib\threading.py", line 451, in __bootstrap
> self.__stop()
>   File "C:\Python23\lib\threading.py", line 460, in __stop
> self.__block.notifyAll()
>   File "C:\Python23\lib\threading.py", line 256, in notifyAll
> self.notify(len(self.__waiters))
>   File "C:\Python23\lib\threading.py", line 238, in notify
> currentThread() # for side-effect
> TypeError: 'NoneType' object is not callable

One of the steps the interpreter takes is to go through all modules and 
rebind all globals to None.  I suspect currentThread is a global in the 
above (although I thought that particular issue was fixed in Python 
2.4... are you running an older version?).

The "simplest" thing to do is to ignore this exception because it's 
spurious".  One way to ignore it is simply to wrap that particular 
daemon thread's "run" method with a "try/except: pass" so that all 
exceptions are swallowed quietly.  Often that's not preferable, however, 
since it will of course swallow real exceptions too.

The "safest" thing to do is to terminate that daemon thread before the 
application exits.  That basically means setting it to be a daemon 
thread is sort of pointless, but there's not really a much better solution.

A google search for "python interpreter thread bind global none" or 
something awful like that will probably turn up some background 
material, likely written by Tim Peters. :-)

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


Re: standard doc style for method signatures

2005-05-31 Thread David S.
David S.  alumni.tufts.edu> writes:

> 
> Is there a generally accepted way to denote method signatures---that is,
> expected type or required interface for each argument.  
> 
Here is an answer:
http://python.org/peps/pep-0257.html
http://www.python.org/peps/pep-0008.html



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


Re: change vars in place w/loop or list comprehension

2005-05-31 Thread Raymond Hettinger
> >>> a = 'one'
> >>> b = 'two'
> >>> c = 'three'
> >>> [a, b, c] = [s.upper() for s in [a, b, c]]
> >>> a
> 'ONE'
>
> Both of these accomplish what I'm after; I prefer the second for its
> brevity. But either approach requires that I spell out my list of
> vars-to-alter [a, b, c] twice.  This strikes me as awkward, and
> would be difficult
> with longer lists.

seq = a, b, c
a, b, c = seq = [s.upper() for s in seq]

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


something like CPAN, PPMs?

2005-05-31 Thread Alex Gittens
I'm new to Python from Perl, and loving it. Has there ever been any
discussion of creating a similar resource as CPAN for Python, or a
similar distribution method as PPMs? Seems like it would make a great
language even better.

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


Seti-like program

2005-05-31 Thread GMane Python
Hello

I'd like to consider making a program which is 'seti-like' where I could run
a command-line Python script to just 'do something', and then be able to
launch a viewer program (maybe linux x11 or Windows, possibly over a network
socket) using wxPython to be able to inter-act with it. (Start jobs, view
queue of jobs, modify jobs, etc, or even just watch the work process).

I was wondering if anyone out there had any experience with this, maybe had
an example to share.

I consider [EMAIL PROTECTED] a good example, also maybe Arcserve backup program 
with
manager.

-Dave



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


  1   2   >