How To Call A DLL?

2006-02-13 Thread Anand
Greetings,

Can I get a code snippet of how to call a DLL and it's functionalities from
Python?

Thanks for your help.

Best regards,
Anand


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


Re: What editor shall I use?

2006-02-13 Thread Joel Hedlund
Lad wrote:
> What editor shall I use if my Python script must contain utf-8
> characters?

Also, don't overlook IDLE, the IDE that ships with python. I use it in my work 
every day. Once every three months or so I invest a day in looking for a better 
free python IDE/editor, and still after 3 years or so, I still haven't found 
anyhing that beats it. 

Good luck!
/Joel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread [EMAIL PROTECTED]
John Salerno wrote:
> I know it comes from the suffix -tuple, which makes me think it's
> pronounced as 'toople', but I've seen (at m-w.com) that the first
> pronunciation option is 'tuhple'

I went to university in Pittsburgh and work in Washington, DC.  I've
only ever heard it as toople.

If I heard someone say tuhple, I'd probably thing of Iago's words to
Desdemona's father along the lines of "that ram is tupping your ewe".
But I'm easily amused by alternate pronunciations.

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


Re: How To Call A DLL?

2006-02-13 Thread Fredrik Lundh
"Anand" <[EMAIL PROTECTED]> wrote:

> Can I get a code snippet of how to call a DLL and it's functionalities from
> Python?

start here:

http://starship.python.net/crew/theller/ctypes/

(there's no standard mechanism in Python for calling functions in
DLLs, unless they're explicitly designed for Python, in which case
you can simply import them)





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


Writing a Web Robot in Python

2006-02-13 Thread [EMAIL PROTECTED]
I'm working on writing a web robot (for searching web pages) in Python
so I've been browsing around the web looking for data about building
web robots.

I'm surprised to find that I didn't find much data. Seems like robots
would be kind of a common thing to build. I know there is this: "The
Web Robots Pages" (http://www.robotstxt.org/wc/robots.html) but that
doesn't have a lot of data and seems pretty out of date.

I checked amazon.com for books on building web robots and I didn't find
very much. Seems kind of weird that I don't find much data on this
subject. Anybody know some good places to go to get information on
building a web robots?

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


ANNOUNCE: Proposals due today, Feb. 13th, for OSCON 2006 (Python 14)

2006-02-13 Thread Kevin Altis
Save the date for the 8th annual O'Reilly Open Source Convention, happening
July 24-28, 2006 at the Oregon Convention Center in beautiful Portland,
Oregon.



Call For Participation
--

Submit a proposal-fill out the form at:

http://conferences.oreillynet.com/cs/os2006/create/e_sess/

Important Dates:

* Proposals Due: Midnight (PST) February 13, 2006
* Speaker Notification: March 27, 2006
* Tutorial Presentation Files Due: June 12, 2006
* Session Presentation Files Due: June 26, 2006
* Conference: July 24-28, 2006

Proposals
-

We are considering proposals for 45 minute sessions and 3 hour tutorials.
We rarely accept 90 minute proposals, as most general sessions are 45
minutes in length.  Your proposals are examined by a committee which draws
from them and which also solicits proposals to build the program.  Proposals
are due by midnight (PST), Feb. 13, 2006.  The OSCON Speaker Manager, Vee
McMillen, emails notification of the status of your talk (accepted or
otherwise) by March 27, 2006.  Unless the content of your talk is
particularly timely (e.g., features of a product that will be launched at
OSCON), you are required to send us your slides several weeks before the
conference begins. Submit proposals via the form below.

Some tips for writing a good proposal for a good talk:

* Keep it free of marketing: talk about open source software, but not about
a commercial product--the audience should be able to use and improve the
things you talk about without paying money
* Keep the audience in mind: they're technical, professional, and already
pretty smart.
* Clearly identify the level of the talk: is it for beginners to the topic,
or for gurus?  What knowledge should people have when they come to the talk?
* Give it a simple and straightforward title: fancy and clever titles make
it harder for people (committee and attendees) to figure out what you're
really talking about
* Limit the scope of the talk: in 45 minutes, you won't be able to cover
Everything about Widget Framework X.  Instead, pick a useful aspect, or a
particular technique, or walk through a simple program.
* Pages of code are unreadable: mere mortals can deal with code a line at a
time.  Sometimes three lines at a time.  A page of code can't be read when
it's projected, and can't be comprehended by the audience.
* Explain why people will want to attend: is the framework gaining traction?
Is the app critical to modern systems?  Will they learn how to deploy it,
program it, or just what it is?
* Let us know in your proposal notes whether you can give all the talks you
submitted proposals for
* Explain what you will cover in the talk

NOTE: All presenters whose talks are accepted (excluding Lightning Talks)
will receive free registration at the conference. For each half-day
tutorial, the presenter receives one night's accommodation, a limited travel
allowance, and an honorarium. We give tutors and speakers registration to
the convention (including tutorials), and tutors are eligible for a travel
allowance: up to US$300 from the west coast of the USA, up to US$500 from
the east coast of the USA, up to US$800 from outside the USA.

Registration opens April, 2006. If you would like to be notified by email
when registration opens, please use the form on our main page.



CONFERENCE INFO
===

The O'Reilly Open Source Convention is where coders, sysadmins,
entrepreneurs, and business people working in free and open source software
gather to share ideas, discover code, and find solutions. At OSCON 2005,
more than 2,400 attendees took part in 241 sessions and tutorials across
eleven technology tracks, learning about the newest features and versions
from creators and experts. A record number of products launches and
announcements were made, and sponsors and exhibitors from a wide range of
companies filled the largest exhibit hall in OSCON's history. We anticipate
that OSCON 2006 will be even more successful, and continue to be the place
for the open source community to meet up, debate, make deals, and connect
face to face. OSCON 2006 will take place at the Oregon Convention Center in
Portland, Oregon July 24-28, 2006.

OSCON 2006 will feature the projects, technologies, and skills that you need
to write and deploy killer modern apps.  We're looking for proposals on
platforms and applications around:

* Multimedia including voice (VoIP) and video
* AI including spam-busting, classification, clustering, and data mining
* Collaboration including email, calendars, RSS, OPML, mashups, IM,
presence, and session initialization
* Project best practices including governance, starting a project, and
managing communities
* Microsoft Windows-based open source projects including .NET, Mono, and
regular C/C++/Visual Basic Windows apps
* Enterprise Java techniques including integration, testing, and scalable
deployment solutions
* Linux kernel skills for sysadmins including virtualization, tuning, and
device drivers
* Device hack

Re: Writing a Web Robot in Python

2006-02-13 Thread Rene Pijlman
[EMAIL PROTECTED]:
>Anybody know some good places to go to get information on
>building a web robots?

Some pointers:
http://safari.oreilly.com/0596005776
http://www.python.org/doc/2.4.2/lib/module-HTMLParser.html
http://www.crummy.com/software/BeautifulSoup/
http://www.python.org/doc/2.4.2/lib/module-robotparser.html
http://cheeseshop.python.org/pypi/spider.py/0.5

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Too Many if Statements?

2006-02-13 Thread bruno at modulix
slogging_away wrote:
> bruno at modulix wrote:
> 
> 
>>Looks like a memory problem then...
> 
> 
> The system I am using has 2GB of memory, (unless you are syaing the
> memory is faulty).

Nope, just that I don't know of any system with unlimited memory. BTW,
having 2GB of ram does not mean there are 2GB available for your program.

(And BTW, this is just one of the *possible* reasons of the problem
you've discovered. May be quite unrelated as well...)

>>Why storing error messages ? Why don't you just write'em out (be it to
>>stdout or to a file) ?
>  
> I guess I could do that, (write them to a file as they are discovered).

Well, this is how most programs do.

> Right now the error messages are stored in the array and then the the
> array is scanned via, a for loop and the error messages are written to
> several files in different formats based on the severity of the errors,
> (on a per device basis, a per severity basis, etc.).  This keeps the
> write statements to a minimum and in a central location of the script
> instead of having several statements for each individual error message
> spread throughout the script, (three write statements per error message
> at over 500 error messages would be a significant change).

This is a design problem, not an implementation problem. Just factor out
the part that do the error message dispatch into a function, then call
this function instead of storing the message. Or even better, use an
existing logging library...

> Not to complain but if I can't use arrays  then thats a pretty
> significant limitation.

Please understand that available memory is a limitation of the *system*
- you'd get the same limitation with *every* language ever (well, if you
know of a language that expand free ram ad infinitum, please let us know !-)


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another n00b: Removing the space in "print 'text', var"

2006-02-13 Thread bruno at modulix
HappyHippy wrote:
> More of a minor niggle than anything but how would I remove the
> aforementioned space?


> eg.
> strName = 'World'
> print 'Hello', strName, ', how are you today?'


Already got an anwser, now just a coding-style suggestion: hungarian
notation is *evil*. And even *more* evil with a dynamically-typed language.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a Web Robot in Python

2006-02-13 Thread WEINHANDL Herbert
[EMAIL PROTECTED] schrieb:
> I'm working on writing a web robot (for searching web pages) in Python
> so I've been browsing around the web looking for data about building
> web robots.
> 
> I'm surprised to find that I didn't find much data. Seems like robots
> would be kind of a common thing to build. I know there is this: "The
> Web Robots Pages" (http://www.robotstxt.org/wc/robots.html) but that
> doesn't have a lot of data and seems pretty out of date.
> 
> I checked amazon.com for books on building web robots and I didn't find
> very much. Seems kind of weird that I don't find much data on this
> subject. Anybody know some good places to go to get information on
> building a web robots?

maybe one of the following packages will fullfill your needs

http://www.idyll.org/~t/www-tools/twill/

http://wwwsearch.sourceforge.net/mechanize/

http://python.org/pypi/mechanoid

happy pythoning

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


About undisclosed recipient

2006-02-13 Thread Liyana Robert
Sir,  Pls help me to know About undisclosed recipient.  How we can sent mails to other like this.     Regards,  Liya Robert.
		  
What are the most popular cars? Find out at Yahoo! Autos 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Yet another GUI toolkit question...

2006-02-13 Thread Phil Thompson
On Monday 13 February 2006 12:33 am, John J. Lee wrote:
> Kevin Walzer <[EMAIL PROTECTED]> writes:
> [...]
>
> > Commercial Qt is a little out of my price range.
>
> Commercial *PyQt* (including a license for Qt for use only with PyQt)
> is $400 (USD) per developer (plus an extra $300/year if you want
> upgrades).  That's compared to Qt license for use *with C++* varying
> from $1690 to $6260.  So PyQt is 4-15 times cheaper than old-fashioned
> C++ Qt!
>
> http://www.thekompany.com/products/blackadder/
>
>
> Apparently you get mxODBC in that price, too.  And the Blackadder
> development environment itself, of course, though personally I
> wouldn't use it.
>
> PyQt 4 now seems to exist, though not as a stable release yet, so I
> imagine it'll be a bit longer untill there's a release of Blackadder
> that supports Qt 4.  I recall the PyQt 2 --> PyQt 3 upgrade as being
> fairly painless (in terms of code changes), though.

There will never be a release of Blackadder that supports PyQt4.

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


Question regarding mkdir of ftputil

2006-02-13 Thread s99999999s2003
hi
i am currently using the FTP wrapper from
http://cheeseshop.python.org/pypi/ftputil/2.0.3
The documentation states "In the current implementation, this doesn't
construct "intermediate" directories which don't already exist".
i would like to make directories at the remote server whenever the path
doesn't exist
eg
/rootdir/path1// because  and  is
"changing"

Is there a way to do this using other FTP modules, or even ftplib?  or
the only way is to use "try, except" method?
thanks for any advice.

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


Re: by reference

2006-02-13 Thread Martin P. Hellwig
dirvine wrote:
> Yes I did
> 
> I was trying to do something like (pseudo code)
> 
> write:
> get files in path
> for each filename get size, type
> create dic called filename assign size:xx,type:y
> pickle to file
> 
> read:
> open pickled file
> read dict name and contents (hoping unpickling file gives me the dict
> name as it was saved, which may not be true)
> do stuff with file
> 
> 
> and thats it. My prog is a bit more complex than this but this is the
> general idea basically read files -> create dicts of files one at a
> time, very similar to bittorrent in that take a file smash to bits and
> store links to bits in a big file.
> 
> Many thanls
> David
> 

Well, although I still think you should use nested dicts doesn't say 
that what you want isn't possible, take a look at this snippet:
 >>> locals()['test']=dict()
 >>> test
{}
 >>>
It looks quite ugly too me but that is probably in the eye of the 
beholder. However even the faq has some info on that:
http://www.python.org/doc/faq/programming.html#how-do-i-use-strings-to-call-functions-methods

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


Re: Pulling all n-sized combinations from a list

2006-02-13 Thread Magnus Lycka
[EMAIL PROTECTED] wrote:
> But it turns out he actually had one, which he graciously provided
> in response to my observation. If I had kept my trap shut, I wouldn't
> have it, would I? 

I completely agree, but you could put your "questions" in
a way that increases your chances of helpful replies...
http://www.catb.org/~esr/faqs/smart-questions.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding mkdir of ftputil

2006-02-13 Thread s99999999s2003
Problem solved. Used try and except method

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


Re: Downloading Large Files -- Feedback?

2006-02-13 Thread Fuzzyman

mwt wrote:
> This code works fine to download files from the web and write them to
> the local drive:
>
> import urllib
> f =  urllib.urlopen("http://www.python.org/blah/blah.zip";)
> g = f.read()
> file = open("blah.zip", "wb")
> file.write(g)
> file.close()
>
> The process is pretty opaque, however. This downloads and writes the
> file with no feedback whatsoever. You don't see how many bytes you've
> downloaded already, etc. Especially the "g = f.read()" step just sits
> there while downloading a large file, presenting a pregnant, blinking
> cursor.
>
> So my question is, what is a good way to go about coding this kind of
> basic feedback? Also, since my testing has only *worked* with this
> code, I'm curious if it will throw a visibile error if something goes
> wrong with the download.
>

By the way, you can achieve what you want with urllib2, you may also
want to check out the pycurl library - which is a Python interface to a
very good C library called curl.

With urllib2 you don't *have* to read the whole thing in one go -

import urllib2
f =  urllib2.urlopen("http://www.python.org/blah/blah.zip";)
g = ''
while True:
  a = f.read(1024*10)
  if not a:
break
  print 'Read another 10k'
  g += a

file = open("blah.zip", "wb")
file.write(g)
file.close()

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
> Thanks for any pointers. I'm busily Googling away.

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


Re: About undisclosed recipient

2006-02-13 Thread Ganesan Rajagopal
> Liyana Robert <[EMAIL PROTECTED]> writes:

> Pls help me to know About undisclosed recipient.
> How we can sent mails to other like this.

Use Bcc header instead of To or Cc.

Ganesan

-- 
Ganesan Rajagopal



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


Re: pythonic exec* spawn*

2006-02-13 Thread Nick Craig-Wood
Daniel Nogradi <[EMAIL PROTECTED]> wrote:
>  Is it possible to pass a python object to a python program as
>  argument?

Yes - you can pickle it.

  http://www.python.org/doc/2.4.2/lib/module-cPickle.html

You can pickle just about anything into a string and unpickle it back
into python objects.  You shouldn't accept pickles from untrusted
sources as this may reperesent a security problem.

>  In my program I would like to start executing an other python program
>  and don't wait until that finishes, only launch it and keep running
>  the original program. The obvious way I can think of it is using the
>  exec* or spawn* function families. However, these are generic
>  functions to start any external program and I was wondering if there
>  was a special way to start a python program (as opposed to an
>  arbitrary program), especially because I would like to pass data to
>  this other program in the form of python objects.
> 
>  While the original program is running it creates all sorts of data in
>  a nice pythonic way, for example as a class instance with lot of
>  member data, and then I wouldn't want to convert all of this into
>  command line arguments because that would create a huge list. I would
>  like to pass the whole object at once to the second python program
>  which should start doing its thing with it while the original program
>  should keep running.
> 
>  I was looking around for threading and forking but couldn't come up
>  with a clear solution.

If you want to fork(), then I would use the subprocess module to
create a child process with a pipe to it.  I would then pass python
objects as pickles back and forth across that pipe.

  http://www.python.org/doc/2.4.2/lib/module-subprocess.html

You'll probably find threading easier though.

  http://www.python.org/doc/2.4.2/lib/module-threading.html

But it will use your multiple CPUs less efficiently than fork()-ing.

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mental Abuse

2006-02-13 Thread Heiko Wundram
[EMAIL PROTECTED] wrote:
> > 
> Can you say paranoid-schizophrenic?   I knew you could...

Schizophrenic is more than enough in this case...

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


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Steve Holden
Dennis Lee Bieber wrote:
> On Sun, 12 Feb 2006 23:30:25 -0500, Steve Holden <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
> 
> 
> 
>>I teach on both sides of the Atlantic, and have learned to draw a mental 
>>breath before trying to pronounce the word "router". Americans find the 
>>British pronunciation ("rooter") hilarious, despite the fact they tell 
>>me I drive on "Root 66" to get to DC. The Brits are politer, and only 
>>snigger behind my back when I pronounce it as Americans do, to rhyme 
>>with "outer".
>>
> 
>   Strange... I never knew Route 66 got that far east... As I recall,
> it runs (ran) from ~Los Angeles across the southwest before making an
> upward turn through Missouri (where it passed just outside of Ft.
> Leonard Wood) and there from meandered through St. Louis and up toward
> Chicago... 
> 
The Route 66 that runs past Manassas and into DC appears to be a 
completely different Interstate from the one made famous by the Chuck 
Berry song, and I was really confused by it when I moved to the DC Metro 
area.

>   Then again, from the "new world" perspective... A "route" is a fixed
> path between points... A "router" is something that dynamically
> determines paths -- so it may be seen as a different derivation...
> 
> {Or as I learned on my previous department: A pub's a bar, a bar's a
> gate, a gate's a street}
> 
:-)

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Python equivilant to msgbox()

2006-02-13 Thread Peter Decker
On 12 Feb 2006 17:27:56 -0800, André <[EMAIL PROTECTED]> wrote:

> It's also possible to something like that with wxPython.  Try:
> import wx
> app = wx.PySimpleApp()
> dlg = wx.TextEntryDialog(None, 'Enter value', 'Title', '')
> if dlg.ShowModal() == wx.ID_OK:
> val = dlg.GetValue()  # this line should be indented
> dlg.Destroy()
> print "you have entered %s" % val

That's the sort of butt-ugly code that got me convinced that Dabo is
the way to go. To get a simple message box, you have to create it,
show it, check a return value against an ugly constant (make sure you
don't forget an use wx.OK instead!), and then remember to destroy it
or your app will hang.

The same code in Dabo is:

val = dabo.ui.getString("Enter value", "Some Title")
if val in None:
   print "You canceled"
else:
   print "You entered %s" % val

Look at both examples, and tell me which looks more Pythonic to you.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python equivilant to msgbox()

2006-02-13 Thread Fredrik Lundh
Peter Decker wrote:

> > It's also possible to something like that with wxPython.  Try:
> > import wx
> > app = wx.PySimpleApp()
> > dlg = wx.TextEntryDialog(None, 'Enter value', 'Title', '')
> > if dlg.ShowModal() == wx.ID_OK:
> > val = dlg.GetValue()  # this line should be indented
> > dlg.Destroy()
> > print "you have entered %s" % val
>
> That's the sort of butt-ugly code that got me convinced that Dabo is
> the way to go. To get a simple message box, you have to create it,
> show it, check a return value against an ugly constant (make sure you
> don't forget an use wx.OK instead!), and then remember to destroy it
> or your app will hang.

if you're using a Python version without a "def" statement, it's time to 
upgrade.

 



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


Re: Python equivilant to msgbox()

2006-02-13 Thread Andre Roberge
On 2/13/06, Peter Decker <[EMAIL PROTECTED]> wrote:
> On 12 Feb 2006 17:27:56 -0800, André <[EMAIL PROTECTED]> wrote:
>
> > It's also possible to something like that with wxPython.  Try:
> > import wx
> > app = wx.PySimpleApp()
> > dlg = wx.TextEntryDialog(None, 'Enter value', 'Title', '')
> > if dlg.ShowModal() == wx.ID_OK:
> > val = dlg.GetValue()  # this line should be indented
> > dlg.Destroy()
> > print "you have entered %s" % val
>
> That's the sort of butt-ugly code that got me convinced that Dabo is
> the way to go. To get a simple message box, you have to create it,
> show it, check a return value against an ugly constant (make sure you
> don't forget an use wx.OK instead!), and then remember to destroy it
> or your app will hang.
>
> The same code in Dabo is:
>
> val = dabo.ui.getString("Enter value", "Some Title")
> if val in None:
>print "You canceled"
> else:
>print "You entered %s" % val
>
> Look at both examples, and tell me which looks more Pythonic to you.

While I agree that dabo's version is more Pythonic than wxPython, my
understanding is that dabo is built on top of wxPython.  There are
other framework (wax, anygui) that also aim to make the coding "more
pythonic", hiding "ugly" wxPython details.  Personnally, I am hesitant
to start using an extra layer on top of wxPython, with no guarantee
that it will be always updated.  Ideally, something like dabo+wxPython
would become part of the standard Python distribution.

The original post was asking if it was possible to have such message
dialogs using Python, without having a full gui app.  I'd say that the
answer is yes... and that one has a lot of options, depending on how
many packages one is ready to download.

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


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Ben Wilson
Yeah, I was going to say it's "I-66," not "Route 66," which has been
replaced in pertainent parts by I-40.

tuh-ple.

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


Re: Python equivilant to msgbox()

2006-02-13 Thread Peter Decker
On 2/13/06, Andre Roberge <[EMAIL PROTECTED]> wrote:

> While I agree that dabo's version is more Pythonic than wxPython, my
> understanding is that dabo is built on top of wxPython.

Yes. You get all the power of wxPython without having to deal with the
C++ style of coding.

> There are
> other framework (wax, anygui) that also aim to make the coding "more
> pythonic", hiding "ugly" wxPython details.  Personnally, I am hesitant
> to start using an extra layer on top of wxPython, with no guarantee
> that it will be always updated.  Ideally, something like dabo+wxPython
> would become part of the standard Python distribution.

I think the chances of Dabo not getting updated are about the same as
wxPython not getting updated. The authors have been highly active and
involved for a few years now, unlike Wax or anygui. Bugs get fixed in
hours usually, and enhancements to the tools are always being
released.

It would be way cool if the Powers that Be would adopt Dabo/wxPython
as part of the language. The combination is so much more powerful and
much better looking than Tkinter.

> The original post was asking if it was possible to have such message
> dialogs using Python, without having a full gui app.  I'd say that the
> answer is yes... and that one has a lot of options, depending on how
> many packages one is ready to download.

Oh, I understand your response. But I know that when people who are
familiar with Python first see wxPython code, their first reaction is
usually not positive. I was just trying to show that you can create
UIs easily and Pythonically.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 Steve Holden <[EMAIL PROTECTED]> wrote:

> I teach on both sides of the Atlantic, and have learned to draw a mental 
> breath before trying to pronounce the word "router".

It took me a while to get used to that too, but honestly, the warm beer was 
much more difficult to deal with.  It's supposed to be cold on the way in 
and warm on the way out.

My other problem is that I'm into woodworking as well as computers.  When 
I'm mindlessly browsing news and see an article headline that says 
something like "router bits", I often have to stop and think about in which 
context I'm supposed to interpret that (a router is a woodworking tool, 
into which you can fit a variety of cutting bits).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Netstat in python. Does it's possible?

2006-02-13 Thread billie
Thank you all for your helping.


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


py2exe 0.6.4 released

2006-02-13 Thread Jimmy Retzlaff
py2exe 0.6.4 released
=

py2exe is a Python distutils extension which converts Python scripts
into executable Windows programs, able to run without requiring a
Python installation. Console and Windows (GUI) applications, Windows
NT services, exe and dll COM servers are supported.

Changes in 0.6.4:

* New skip-archive option which copies the Python bytecode files
  directly into the dist directory and subdirectories - no
  archive is used.

* An experimental new custom-boot-script option which allows a
  boot script to be specified (e.g., --custom-boot-script=cbs.py)
  which can do things like installing a customized stdout
  blackhole. See py2exe's boot_common.py for examples of what can
  be done. The custom boot script is executed during startup of
  the executable immediately after boot_common.py is executed.

* Thomas Heller's performance improvements for finding needed
  modules.

* Mark Hammond's fix for thread-state errors when a py2exe
  created executable tries to use a py2exe created COM DLL.

Changes in 0.6.3:

* First release assembled by py2exe's new maintainer, Jimmy
  Retzlaff. Code changes in this release are from Thomas Heller
  and Gordon Scott.

* The dll-excludes option is now available on the command line.
  It was only possible to specify that in the options argument to
  the setup function before.

  The dll-excludes option can now be used to filter out dlls like
  msvcr71.dll or even w9xpopen.exe.

* Fix from Gordon Scott: py2exe crashed copying extension modules
  in packages.

Changes in 0.6.2:

* Several important bugfixes:

  - bundled extensions in packages did not work correctly, this
made the wxPython single-file sample fail with newer wxPython
versions.

  - occasionally dlls/pyds were loaded twice, with very strange
effects.

  - the source distribution was not complete.

  - it is now possible to build a debug version of py2exe.

Changes in 0.6.1:

* py2exe can now bundle binary extensions and dlls into the
  library-archive or the executable itself.  This allows to
  finally build real single-file executables.

  The bundled dlls and pyds are loaded at runtime by some special
  code that emulates the Windows LoadLibrary function - they are
  never unpacked to the file system.

  This part of the code is distributed under the MPL 1.1, so this
  license is now pulled in by py2exe.

* By default py2exe now includes the codecs module and the
  encodings package.

* Several other fixes.

Homepage:



Download from the usual location:



Enjoy,
Jimmy
-- 
http://mail.python.org/mailman/listinfo/python-list


Image to numeric array

2006-02-13 Thread Dimitrios Charitatos
Hello, 

I suspect that there is a quite straight forward answer to this, but I can't
find it... I want to import an image and extract a matrix (or array) from it
with elements showing the RGB value of each pixel. But I want to be able to do
this with all types of image formats. It was suggested that a function such as
'B = numeric.from_image(A)' was used but I can't find it in any of the
libraries. I was hoping you could help me on this.

Thank you,
Dimitris 

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


Re: Python equivilant to msgbox()

2006-02-13 Thread Claudio Grondi
LittlePython wrote:
> That is exactly what I was look for .. thx
Surprised to hear that.

As VisualBasic programmer I would expect you to have experience with 
ActiveX on Windows, where the best way to go with Python is to reuse all 
the ActiveX components and their known user interfaces (i.e. constants 
to use as parameter and constants for interpretation of return values) 
directly from within Python.

A message box goes e.g. this way:

 >>> import win32com.client
 >>> axWshShell = win32com.client.Dispatch("WScript.Shell")
 >>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself 
after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1)

By the way: is there a ready for direct use timed self closing Ok/Cancel 
message box in any of the proposed GUI packages?

Claudio
> 
> 
> "Kent Johnson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
>>LittlePython wrote:
>>
>>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
>>>would like to call this instead of print (to the screen) . I would like
>>>to write a simple script that is not an event drive gui but calls input
>>>boxes, message boxes, or maybe even a file open browser box as well?
>>
>>Take a look at EasyGUI:
>>http://www.ferg.org/easygui/
>>
>>Kent
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need a bit of help with a list..

2006-02-13 Thread rh0dium

Alex Martelli wrote:

> From this constuct I assume self.sections is a dict, in which case there
> may be better way to loop over the values in the dict; but that's an
> aside and does not affect your stated problem.  Rather, said problem is
> already shown in the next couple lines:
>
> > if re.match(r"^.*\+$",line):
> > line = line[:-1]
>
> A simple assignment _to a bare name_ (here, 'line') only ever affects
> that NAME itself - nothing else, and in particular not the object to
> which the name used to be bound before you re-bound it, not other names
> (or locations within a container) bound to the same object, and so on.

That's what I was thinking it was doing and a simple proof showed me
this..

> To affect some item, say the i-th one, of self.sections[section], you
> will need to assign something to self.sections[section][i].  You may
> give another and nicer name to the whole objects self.sections[section],
> but you will still need to assign to whatevername[i] to rebind the i-th
> item -- assign to an indexing, not to a bare name.
>
> There's another problem later in this inner loop:
>
> > del self.sections[section][nidx+1]
>
> ...don't alter the container you're directly looping on, for example by
> deleting some of its items: that will alter the semantics of the loop in
> way you most definitely don't want. I don't think it's biting you here,
> but in most cases it will indeed bite, and painfully.

Thanks so much for pointing this out - it explains some behaviour I was
seeing!!

> I would suggest restructuring your whole first nested loop, correcting
> other strangeness (which is innocuous) as we go, such as the strange re
> and the separate and identical increments of nidx along an if and an
> else branch.  For example, trying to stay as close as feasible to your
> original code, we might have:
>
> for lines in self.sections.itervalues():
> nidx = 0
> while nidx line = lines[nidx]
> if line.endswith('+'):
> lines[nidx] = line[:-1] + " " + lines[nidx+1]
> del lines[nidx+1]
> nidx += 1
>

Ah - A couple new methods - Thanks so much for your insightful comments
and concerns.  I will take it from here - much appreciated!!

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


Re: Rethinking the Python tutorial

2006-02-13 Thread Magnus Lycka
Ed Singleton wrote:
> How about putting the current tutorial into the wiki and seeing if
> people start updating it?  I'm not saying it would work, but it might
> have interesting effects...

There are abviously a lot of ideas in the air concerning on-line
editing of the new python web site, support for user comments in
the docs etc. I hope some of these things will be deployed soon.

Concerning the tutorial, I just felt that the two I mentioned are
the "best of breed", and it might be smarter to give them official
status. I don't see any value in maintaining Guido's tutorial for
all eternity. It's not as if we need backward compatibility in the
tutorial department... I suppose there are some gaps in A Byte Of
Python that needs to be filled. For instance, the discussion on
Unicode seems very thin. I still think it's a better starting point
for the ideal beginners tutorial than the old official tutorial.

I still feel it's a better beginner's tutorial though. Last time I
suggested the standard Python tutorial to someone, she dropped
Python almost at once, since she got the impression that it was
some kind of calculator program, and she wasn't looking for that.

I think there are a lot of potential improvements for Python docs.
The Language Reference is unreadable for mortals, and that means
that there is no standard reference document describing the real
fundamentals in Python, statements and operators. we just have the
tutorial for that.

The best resource in the Python docs is that Library Reference.
As far as I understand, it's not complete, and it could contain
more examples in places, but it's very useful.

The Lanugage Reference seems more like some kind of specification.
I think a *real* Python Language Guide would be great, and it could
still be a fairly short document, even if core Python has grown a
bit in recent versions. The builtins chapter in the Library Reference
(Ch 2) belongs here, and the Std Lib Ref is just for things  we
import. It's really strange to document e.g. string literals and the
string class in different manuals.

I was thinking that maybe some old paper book on Python could be
donated for this purpose, but now it seems that most of the good
ones are going to be reprinted soon, if they aren't already in the
stores. I'm really happy that they are still commercially viable,
but it would have been great if we had gotten one of these goodies
as a starting point. It's hard work to write such good books as
e.g. Martelli and Beazley did.

Of the good books, I just have Beazley's "Python Essential Reference"
1st Ed. nearby, but chapter 2-10 in that shows very well what I
think a Python Language Guide could look like.

BTW... Alex is now employed by a very rich and successful company
that really owes the Python community a lot of gratitude. It's great
that they are paying the salaries for some of the very best Python
people, and let them work some for the community, but perhaps Google
could buy the rights for "Python in a Nutshell" from Martelli/O'Reilly
and donate it do the community? :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread John Salerno
Markus Wankus wrote:

> I'm not sure, but I think it is pronounced "ménage à trois".

LOL. You guys are hilarious. I think I made the right decision to start 
learning Python!  :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread John Salerno
Erik Max Francis wrote:

> Even in mathematics, a tuple, or formally an n-tuple, makes more sense 
> to me pronounced the latter if you list out the various pronounciations 
> for large n, seems me the _uhs_ outweigh the _oos_.  (There's quadruple 
> on one side, but then quintuple, sextuple, septuple, heptuple, octuple, 
> etc., etc., etc.)

That's kind of the ironic thing. When I first saw the word, I thought 
maybe it was a Python-specific term (even something from a Monty Python 
skit, even!). My default pronunciation actually was 'toople', but then I 
looked it up to be sure and saw that it comes from words like quadruple, 
quintuple, etc. Well, even then, I was pronouncing those words in my 
head as 'quintoople', 'sextoople', etc., so that didn't really clarify 
it for me! But I think 'quintuple' is probably the more popular choice, 
which makes 'tuple' sound more correct, so to speak.

I still have a warm spot for 'toople', though, since that's what I 
called it first, but somehow 'tuple' seems less silly (and less like 
tupping!)  :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Grant Edwards
On 2006-02-13, John Salerno <[EMAIL PROTECTED]> wrote:
> Markus Wankus wrote:
>
>> I'm not sure, but I think it is pronounced "ménage à trois".
>
> LOL. You guys are hilarious. I think I made the right decision
> to start learning Python!  :)

Of course! What did you expect from devotees of a language
named after one of the greatest comedy shows in TV history?

-- 
Grant Edwards   grante Yow!  Edwin Meese made me
  at   wear CORDOVANS!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Image to numeric array

2006-02-13 Thread Diez B. Roggisch
Dimitrios Charitatos wrote:

> Hello,
> 
> I suspect that there is a quite straight forward answer to this, but I
> can't find it... I want to import an image and extract a matrix (or array)
> from it with elements showing the RGB value of each pixel. But I want to
> be able to do this with all types of image formats. It was suggested that
> a function such as 'B = numeric.from_image(A)' was used but I can't find
> it in any of the libraries. I was hoping you could help me on this.

You have to install the numeric library for that. Googling numeric python
will bring you there pretty quick.

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


[ANN] PyInstaller 1.1 released

2006-02-13 Thread Giovanni Bajo
PyInstaller 1.1
***

PyInstaller 1.1 has been released! This release has been composed also with
the help of patches provided by the community: many thanks to everybody!

Find the downloads at the usual locations:

http://pyinstaller.hpcf.upr.edu  (website)
http://pyinstaller.hpcf.upr.edu/source/1.1/pyinstaller_1.1.zip
http://pyinstaller.hpcf.upr.edu/source/1.1/pyinstaller_1.1.tar.gz


ChangeLog for this release:

 + (Windows) Make single-file packages not depend on MSVCRT71.DLL anymore,
   even under Python 2.4. You can eventually ship your programs really as
   single-file executables, even when using the newest Python version!
 + Fix problem with incorrect python path detection. Now using helpers from
   distutils.
 + Fix problem with rare encodings introduced in newer Python versions: now
all
   the encodings are automatically found and included, so this problem
should
   be gone forever.
 + Fix building of COM servers (was broken in 1.0 because of the new build
   system).
 + Mimic Python 2.4 behaviour with broken imports: sys.modules is cleaned up
   afterwise. This allows to package SQLObject applications under Windows
   with Python 2.4 and above.
 + Add import hook for the following packages:
 + GTK
 + PyOpenGL (tested 2.0.1.09)
 + dsnpython (tested 1.3.4)
 + KInterasDB (courtesy of Eugene Prigorodov)
 + Fix packaging of code using "time.strptime" under Python 2.3+.
 + (Linux) Ignore linux-gate.so while calculating dependencies (fix provided
   by Vikram Aggarwal).
 + (Windows) With Python 2.4, setup UPX properly so to be able to compress
   binaries generated with Visual Studio .NET 2003 (such as most of the
   extensions). UPX 1.92+ is needed for this.

-- 
Giovanni Bajo

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


FTPlib

2006-02-13 Thread Harlin Seritt
Using ftplib from Python I am trying to get all files in a particular
directory using ftplib and then send those same files to another ftp
server. I have tried using commands like 'get *' and 'mget *' with no
success.

I am using the following:

srcFtp = FTP(srcHost)
srcFtp.login(srcUser, srcPass)
srcDir = srcFtp.nlst('.')
for file in srcDir:
print file[2:]
srcFtp.transfercmd('get '+file[2:])

I've verified that I do have a connection with the ftp server and the
files as 'file[2:]' are indeed the file names.

Anyone know why I get the following error?

podcast-1.mp3
Traceback (most recent call last):
  File "podsync.py", line 17, in ?
srcFtp.transfercmd('get '+file[2:])
  File "C:\Python24\lib\ftplib.py", line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python24\lib\ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
  File "C:\Python24\lib\ftplib.py", line 241, in sendcmd
return self.getresp()
  File "C:\Python24\lib\ftplib.py", line 216, in getresp
raise error_perm, resp
ftplib.error_perm: 500 Syntax error, command unrecognized.

Thanks,

Harlin Seritt

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


ANNOUNCE: Mod_python 3.2.7

2006-02-13 Thread Gregory (Grisha) Trubetskoy

The Apache Software Foundation and The Apache HTTP Server Project are
pleased to announce the 3.2.7 release of mod_python. Mod_python 3.2.7
is considered a stable release, suitable for production use.

Mod_python is an Apache HTTP Server module that embeds the Python
language interpreter within the server. With mod_python you can write
web-based applications in Python that will run many times faster than
traditional CGI and will have access to advanced features such as
ability to maintain objects between requests, access to httpd
internals, content filters and connection handlers.

The 3.2.7 release has many new features, feature enhancements, fixed
bugs and other improvements over the previous version. See Appendix A
of mod_python documentation for more details.

Mod_python 3.2.7 is released under Apache License version 2.0.

Mod_python 3.2.7 is available for download from:

http://httpd.apache.org/modules/python-download.cgi

More information about mod_python is available at:

http://httpd.apache.org/modules/

Many thanks to Jim Gallacher, Graham Dumpleton, Nicolas Lehuen and
everyone else who contributed to and helped test this release, without
your help it would not be possible!

Regards,

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


Execute batch script on remote computer

2006-02-13 Thread py
I am trying to execute a batch script on a remote computer.

The batch script looks like:

@echo off
start c:\python24\python.exe c:\a_script.py


Here's the setup:
Computer A (my computer), Computer B (the remote computer).

So I map "W:" to Computer B and then copy the batch script to Computer
B.  Then from within Python on Computer A I run:
import subprocess
subprocess.Popen("W:\\foo.bat")

However, when it runs it says it can't find c:\a_script.py.  It seems
to be trying to look
at Computer A, not Computer B.  How can I do this?

Thanks

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


Re: how do you pronounce 'tuple'?

2006-02-13 Thread John Salerno
Grant Edwards wrote:
> On 2006-02-13, John Salerno <[EMAIL PROTECTED]> wrote:
>> Markus Wankus wrote:
>>
>>> I'm not sure, but I think it is pronounced "ménage à trois".
>> LOL. You guys are hilarious. I think I made the right decision
>> to start learning Python!  :)
> 
> Of course! What did you expect from devotees of a language
> named after one of the greatest comedy shows in TV history?
> 

Well, I hope this doesn't make me lose credibility, but I've actually 
never seen the show! I saw Holy Grail several years ago, though. But I'm 
very curious about this whole cheese shop skit, so when I get home 
tonight I'm going to download it. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python very slow compared to C

2006-02-13 Thread Peter Hansen
PA wrote:
> On Feb 13, 2006, at 06:44, [EMAIL PROTECTED] wrote:
> 
> 
>>And if we use market penetration as measure, Perl seems to be easier
>>for people ?
> 
> 
> Perl: Shell scripts/awk/sed are not enough like programming languages.
> 
> Python: Perl is a kludge.
> 
> "What Languages Fix"
> http://www.paulgraham.com/fix.html

Cute.  He's missing Assembly language though:

Assembly language: My fingers are numb.

;-)

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


Re: Rethinking the Python tutorial

2006-02-13 Thread Steve Holden
Magnus Lycka wrote:
> Ed Singleton wrote:
> 
>>How about putting the current tutorial into the wiki and seeing if
>>people start updating it?  I'm not saying it would work, but it might
>>have interesting effects...
> 
> 
> There are abviously a lot of ideas in the air concerning on-line
> editing of the new python web site, support for user comments in
> the docs etc. I hope some of these things will be deployed soon.
> 
You and me both!

> Concerning the tutorial, I just felt that the two I mentioned are
> the "best of breed", and it might be smarter to give them official
> status. I don't see any value in maintaining Guido's tutorial for
> all eternity. It's not as if we need backward compatibility in the
> tutorial department... I suppose there are some gaps in A Byte Of
> Python that needs to be filled. For instance, the discussion on
> Unicode seems very thin. I still think it's a better starting point
> for the ideal beginners tutorial than the old official tutorial.
> 
As with all such content, the first thing you will need is a band of 
volunteers dedicated to keeping the content up to date, both proactively 
and in response to reader comments.

This is a far from easy step.

> I still feel it's a better beginner's tutorial though. Last time I
> suggested the standard Python tutorial to someone, she dropped
> Python almost at once, since she got the impression that it was
> some kind of calculator program, and she wasn't looking for that.
> 
Yes, I think many people would agree that the existing tutorial is a 
little slanted towards people who are already familiar with programming, 
and sometimes programming in the Linux/Unix environment.

> I think there are a lot of potential improvements for Python docs.
> The Language Reference is unreadable for mortals, and that means
> that there is no standard reference document describing the real
> fundamentals in Python, statements and operators. we just have the
> tutorial for that.
> 
> The best resource in the Python docs is that Library Reference.
> As far as I understand, it's not complete, and it could contain
> more examples in places, but it's very useful.
> 
> The Lanugage Reference seems more like some kind of specification.

That's exactly what it's supposed to be: guidance for implementers.

> I think a *real* Python Language Guide would be great, and it could
> still be a fairly short document, even if core Python has grown a
> bit in recent versions. The builtins chapter in the Library Reference
> (Ch 2) belongs here, and the Std Lib Ref is just for things  we
> import. It's really strange to document e.g. string literals and the
> string class in different manuals.
> 
What we are talking about here is a Python Language Users' Guide.

> I was thinking that maybe some old paper book on Python could be
> donated for this purpose, but now it seems that most of the good
> ones are going to be reprinted soon, if they aren't already in the
> stores. I'm really happy that they are still commercially viable,
> but it would have been great if we had gotten one of these goodies
> as a starting point. It's hard work to write such good books as
> e.g. Martelli and Beazley did.
> 
> Of the good books, I just have Beazley's "Python Essential Reference"
> 1st Ed. nearby, but chapter 2-10 in that shows very well what I
> think a Python Language Guide could look like.
> 
> BTW... Alex is now employed by a very rich and successful company
> that really owes the Python community a lot of gratitude. It's great
> that they are paying the salaries for some of the very best Python
> people, and let them work some for the community, but perhaps Google
> could buy the rights for "Python in a Nutshell" from Martelli/O'Reilly
> and donate it do the community? :)

Google are very active supporters of Python already, though they don't 
make a big song and dance about it. You might notice, for example, that 
they are a Platinum Sponsor at PyCon this year, as well as being a 
sponsor member of the PSF. The Summer of Code also benefited Python in 
several ways.

There are older-established companies with more Python programmers who 
have made hardly any community contribution - the "takers" of the open 
source world. I wouldn't like Google to think that the Python community 
isn't recognizing their support.

You might also like to ask Alex what he'd feel about losing the 
"Nutshell" revenue stream!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Arcane deployment considerations (was: Single-file executables)

2006-02-13 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Thomas Heller  <[EMAIL PROTECTED]> wrote:
.
.
.
>Usually the bundle=1 option in py2exe can create a single file exe, but it also
>allows to have a separate shared library.zip file, which is useful if
>you need more than
>one exe-file.  With python 2.4, MSVCR71.dll is still required and not
.
.
.
For some of our projects, we provide a single executable, which
takes a command-line argument (or, rarely, environment variable)
to tell the executable whether to come up as server or client,
or GUI or command-line version, or ...  The result is that, even
for an architecturally-sophisticated development, the end-user
experiences a unitary delivery; he has just one file to install,
remove, archive, ...  
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Feb 13)

2006-02-13 Thread Cameron Laird
QOTW:  "Dangit!  I need to find a less honest programming language.  Anyone
have a Perl cookbook handy? ..." - Lonnie Princehouse

"The pursuit of orthogonality, while admirable, can lead to insanity if
pushed too far." - Steve Holden


One of this week's half-dozen examples of the, "Is there a better
way ...?  We've now improved it by a factor of 300", pattern has
to do with combinatorics--specifically, the combinations of n
items from a list of m:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1f7e62e5ab0edb90/

Is it possible to test a string for non-ASCII characters?  No,
it's more than possible; viewed in the correct perspective, it's
*easy*, and merely an application of Python's more general
encoding capabilities:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/9011319757576f45/

The next PyPy sprint will immediately follow PyCon 2006:
http://us.pycon.org/TX2006/Sprinting

JavaScript practitioners will find Python eases their transition
to the server- and native-sides:

http://htmatters.net/htm/1/2006/02/Why-Python-makes-sense-for-web-development.cfm

Paul McGuire reports satisfaction on his first use of an HTML-oriented
extension to unittest:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/369e0f8c7e4efef/

Pyvm is (yet) another Python implementation, one based on an independent
virtual machine.  It has now its own Wiki:
http://pyvm.pbwiki.com/



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.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
The old Python "To-Do List" now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?atid=355470&group_i

RE: Execute batch script on remote computer

2006-02-13 Thread Tim Golden
[py]

| I am trying to execute a batch script on a remote computer.
| 
| The batch script looks like:
| 
| @echo off
| start c:\python24\python.exe c:\a_script.py
| 
| 
| Here's the setup:
| Computer A (my computer), Computer B (the remote computer).
| 
| So I map "W:" to Computer B and then copy the batch script to Computer
| B.  Then from within Python on Computer A I run:
| import subprocess
| subprocess.Popen("W:\\foo.bat")
| 
| However, when it runs it says it can't find c:\a_script.py.  It seems
| to be trying to look
| at Computer A, not Computer B.  How can I do this?

You're confusing a couple of things here. One is a 
drive mapping, which presents the *filesystem* of a
remote computer as though it were local. The other
is a remote procedure call, which presents the
*processor* (and environment etc.) of a remote 
computer as though it were local.

What you're doing has the effect of running a
remote *file* on a local *processor*.

You could run a remote script -- on the *remote*
processor -- under vanilla Windows using WMI, and
possibly using some other DCOM-based technology, such
as WSH. But you'd run into some security / environment
issues depending on just what your remote script was
trying to do.

You could also -- if you were prepared to invest in
some more software infrastructure -- employ Pyro
(http://pyro.sf.net), Corba, XML-RPC or any one of
several other RPC-type technologies.

Are you even more confused now than you were when
I started? ;)

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Image to numeric array

2006-02-13 Thread Claudio Grondi
Diez B. Roggisch wrote:
> Dimitrios Charitatos wrote:
> 
> 
>>Hello,
>>
>>I suspect that there is a quite straight forward answer to this, but I
>>can't find it... I want to import an image and extract a matrix (or array)
>>from it with elements showing the RGB value of each pixel. But I want to
>>be able to do this with all types of image formats. It was suggested that
>>a function such as 'B = numeric.from_image(A)' was used but I can't find
>>it in any of the libraries. I was hoping you could help me on this.
> 
> 
> You have to install the numeric library for that. Googling numeric python
> will bring you there pretty quick.
> 
> Diez
Is there a difference between the 'Numeric' and 'numeric' module?
I have on my system only Numeric... And this has no function like 
'from_image'.

The usual way of doing such things is to use PIL (Python Image Library) 
to load the image from file, then export it from PIL to a Python string 
in order to import from this string to an array of the targeted 
numerical module.

Really curious if there is a direct way in any of the numerical 
packages, as it would save the time and effort of unnecessary 
conversions from PIL, ImageMagick or from other image libraries.

Claudio


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


Re: how do you pronounce 'tuple'?

2006-02-13 Thread John Salerno
Steve Holden wrote:

> No, no, no. The correct pronunciation is "tyoople" (or, if you're being 
> lazy, "choople"). Anything else is wrong, but we English are usually 
> prepared to forgive foreigners their ignorance :-)
> 
> [If I pronounced as badly as I type nobody would ever know what I was 
> saying].
> 
> not-that-we're-arrogant-or-anything-ly y'rs  - steve

::eyes the Brits suspiciously::

And I thought there were only choo ways to pronounce it...turns out 
there are free.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-ldap

2006-02-13 Thread Christos Georgiou
On 7 Feb 2006 10:02:23 -0800, rumours say that "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> might have written:

>_)_

On 7 Feb 2006 10:02:25 -0800, rumours say that "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> might have written:

>_)_

You can't beat Steve with a pair of arses, because Steve's hand is
physically higher than your arse (even considering a big age-gap between you
two).

If you said o0o, I'd call your bluff a zero and raise an eye (make that a
capital eye).  I also believe that I could fit a db in there (as thin as the
crack may be), but (o)(o) would be cozier as a receptacle.

Now, let us all smart_)_s peace off.

PS should anyone grab the chance and mix ethnic jokes based on my
nationality in a reply, I'll have to tell you that I have been offended by
professionals during my army service and you'll barely scratch my back :)
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Steve Holden
John Salerno wrote:
> Erik Max Francis wrote:
> 
> 
>>Even in mathematics, a tuple, or formally an n-tuple, makes more sense 
>>to me pronounced the latter if you list out the various pronounciations 
>>for large n, seems me the _uhs_ outweigh the _oos_.  (There's quadruple 
>>on one side, but then quintuple, sextuple, septuple, heptuple, octuple, 
>>etc., etc., etc.)
> 
> 
> That's kind of the ironic thing. When I first saw the word, I thought 
> maybe it was a Python-specific term (even something from a Monty Python 
> skit, even!). My default pronunciation actually was 'toople', but then I 
> looked it up to be sure and saw that it comes from words like quadruple, 
> quintuple, etc. Well, even then, I was pronouncing those words in my 
> head as 'quintoople', 'sextoople', etc., so that didn't really clarify 
> it for me! But I think 'quintuple' is probably the more popular choice, 
> which makes 'tuple' sound more correct, so to speak.
> 
> I still have a warm spot for 'toople', though, since that's what I 
> called it first, but somehow 'tuple' seems less silly (and less like 
> tupping!)  :)

No, no, no. The correct pronunciation is "tyoople" (or, if you're being 
lazy, "choople"). Anything else is wrong, but we English are usually 
prepared to forgive foreigners their ignorance :-)

[If I pronounced as badly as I type nobody would ever know what I was 
saying].

not-that-we're-arrogant-or-anything-ly y'rs  - steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Execute batch script on remote computer

2006-02-13 Thread py
WMI will work, i can create a new Win32_Process.  XML_RCP would be
nice, but probably to much for what i need.

thanks.

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


Re: Rethinking the Python tutorial

2006-02-13 Thread A.M. Kuchling
On Mon, 13 Feb 2006 11:03:55 -0500, 
Steve Holden <[EMAIL PROTECTED]> wrote:
> What we are talking about here is a Python Language Users' Guide.

I actually started on such a document over the holidays, but have only
described about 3 or 4 statements at this point.  However, it's
probably not going to be *much* smaller than the Reference Guide,
because pretty much every topic in the RefGuide needs to appear in the
user's guide.

--amk

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


Dr. Dobb's Python-URL! - weekly Python news and links (Feb 13)

2006-02-13 Thread Cameron Laird
QOTW:  "Dangit!  I need to find a less honest programming language.  Anyone
have a Perl cookbook handy? ..." - Lonnie Princehouse

"The pursuit of orthogonality, while admirable, can lead to insanity if
pushed too far." - Steve Holden


One of this week's half-dozen examples of the, "Is there a better
way ...?  We've now improved it by a factor of 300", pattern has
to do with combinatorics--specifically, the combinations of n
items from a list of m:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1f7e62e5ab0edb90/

Is it possible to test a string for non-ASCII characters?  No,
it's more than possible; viewed in the correct perspective, it's
*easy*, and merely an application of Python's more general
encoding capabilities:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/9011319757576f45/

The next PyPy sprint will immediately follow PyCon 2006:
http://us.pycon.org/TX2006/Sprinting

JavaScript practitioners will find Python eases their transition
to the server- and native-sides:

http://htmatters.net/htm/1/2006/02/Why-Python-makes-sense-for-web-development.cfm

Paul McGuire reports satisfaction on his first use of an HTML-oriented
extension to unittest:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/369e0f8c7e4efef/

Pyvm is (yet) another Python implementation, one based on an independent
virtual machine.  It has now its own Wiki:
http://pyvm.pbwiki.com/



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.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
The old Python "To-Do List" now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?atid=355470&group_i

Re: Python equivilant to msgbox()

2006-02-13 Thread [EMAIL PROTECTED]
Or just do the message box.

>>> import CLR.System.Windows.Forms as Forms
>>> Forms.MessageBox.Show("message goes here", "Window title goes here")

http://www.zope.org/Members/Brian/PythonNet/

In theory this will also work on a linux system with Mono installed

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


Re: Image to numeric array

2006-02-13 Thread Diez B. Roggisch
> Is there a difference between the 'Numeric' and 'numeric' module?
> I have on my system only Numeric... And this has no function like
> 'from_image'.

I actually didn't check that - I just wanted to point the OP to the
numeric-module(s) available, as he suggested that 

>The usual way of doing such things is to use PIL (Python Image Library) 
>to load the image from file, then export it from PIL to a Python string 
>in order to import from this string to an array of the targeted 
>numerical module.

I'd go for the getdata() method instead.

>Really curious if there is a direct way in any of the numerical 
>packages, as it would save the time and effort of unnecessary 
>conversions from PIL, ImageMagick or from other image libraries.

Whatever module is capable of converting needs to know how to read images -
either by itself, or by means of another module. 


I know for sure that pygame supports retrieving pixel-data as array.

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


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Grant Edwards
On 2006-02-13, John Salerno <[EMAIL PROTECTED]> wrote:
> Grant Edwards wrote:
>> On 2006-02-13, John Salerno <[EMAIL PROTECTED]> wrote:
>>> Markus Wankus wrote:
>>>
 I'm not sure, but I think it is pronounced "ménage à trois".
>>> LOL. You guys are hilarious. I think I made the right decision
>>> to start learning Python!  :)
>> 
>> Of course! What did you expect from devotees of a language
>> named after one of the greatest comedy shows in TV history?
>
> Well, I hope this doesn't make me lose credibility, but I've
> actually never seen the show! I saw Holy Grail several years
> ago, though. But I'm very curious about this whole cheese shop
> skit, so when I get home tonight I'm going to download it. :)

IMO, it's not as good as the dead-parrot skit, but it's still a
classic.

-- 
Grant Edwards   grante Yow!  Yow! Now we can
  at   become alcoholics!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


emacs keybindings for scite/scinitilla?

2006-02-13 Thread Grant Edwards
This is technically off-topic, but scite/scinitilla seems to
have a particular connection to the Python community.

I just tried scite for the first time and rather like it.  It
uses GTK, which is shared with my desktop (XFCE) so it starts
up fast.  It's fairly lean (at least by Emacs/Gnome/KDE
standards), but I don't think I can un-learn emacs keybindings.

Are emacs keybindings availble for scite somehow?

-- 
Grant Edwards   grante Yow!  .. Like I always
  at   say -- nothing can beat
   visi.comthe BRATWURST here in
   DUSSELDORF!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rethinking the Python tutorial

2006-02-13 Thread Magnus Lycka
[EMAIL PROTECTED] wrote:
> There are now more than 300 tutorials listed at
> www.awaretek.com/tutorials.html so one could even imagine a
> "mega-tutorial" using the best-of-breed tutorial for each sub-section,
> a la Turbogears ;-)))

We certainly don't need 300 tutorials. :) Pick the best in the
most relevant categories and promote them to official status.
In a way this is obviously like Turbo Gears... Pick the best
ones and package them together. I don't think we need a lot
of categories though. I think we should be conservative in
what we officially promote, and leave the pointers to various
special interests to the wiki. Perhaps one tutorial official
is enough? In that case it should be Swaroop's. That's the
core language tutorial. Mark's is more a series of visits to
the great land of Python applications, and

That's what I'm proposing. I looked at a few of the beginners
tutorials in the list above. Some are pretty old, others are
present a really bad introduction to Python, showing poor
coding style and a poor understanding of Python.

The current official tutorial isn't ideal for beginners without
previous programming experience, and providing a big bunch of
links for beginners to wade through (as in
http://wiki.python.org/moin/BeginnersGuide ) is far from ideal.
There are more than 40 links on that page for the beginners to
ponder over, and if they decide to follow the
BeginnersGuide/NonProgrammers link, they find another 20+ links.

These 60+ links are more or less equally prominent. There is
no "Go *HERE* first. If you have special interests, you might
want to look at something in this list of other resources as
well".

I'm pretty sure it hadn't looked like this if the official
tutorial had been good enough.

Somehow, the state of Python tutorials remind me of Python
web application toolkits...

I think that one good indication that a tutorial is good,
is that it's been translated to other languages. The ones
I know have been translated are Swaroop's, Mark Pilgrims,
Alan Gaulds, and Danny Yoo's Idle tutorial. Out of these,
Swaroop's and Pilgrim's are the "proper" Python Tutorials.
Danny's is an intro to Idle (which is a good thing) and
Alan's is really more focussed on programing in general
than on Python, although Python is the main vehicle.
(Just like How to Think Like a Computer Scientist.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread John Salerno
Grant Edwards wrote:
> On 2006-02-13, John Salerno <[EMAIL PROTECTED]> wrote:
>> Grant Edwards wrote:
>>> On 2006-02-13, John Salerno <[EMAIL PROTECTED]> wrote:
 Markus Wankus wrote:

> I'm not sure, but I think it is pronounced "ménage à trois".
 LOL. You guys are hilarious. I think I made the right decision
 to start learning Python!  :)
>>> Of course! What did you expect from devotees of a language
>>> named after one of the greatest comedy shows in TV history?
>> Well, I hope this doesn't make me lose credibility, but I've
>> actually never seen the show! I saw Holy Grail several years
>> ago, though. But I'm very curious about this whole cheese shop
>> skit, so when I get home tonight I'm going to download it. :)
> 
> IMO, it's not as good as the dead-parrot skit, but it's still a
> classic.
> 

Ah, now that one I have seen, and it is great! There's an episode of SNL 
where they sort of randomly show that skit, which is a little bizarre in 
itself.  :)
-- 
http://mail.python.org/mailman/listinfo/python-list


hard disk activity

2006-02-13 Thread VSmirk
I have a task that involves knowing when a file has changed.  But while
for small files this is an easy enough task, checking the modification
dates, or doing a compare on the contents, I need to be able to do this
for very large files.

Is there anything already available in Python that will allow me to
check the hard-disk itself, or that can make my routines aware when a
disk write has occurred?

Thanks for any help,

V

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


RE: Execute batch script on remote computer

2006-02-13 Thread Tim Golden
[py]

(re running remote processes)

| WMI will work, i can create a new Win32_Process.

OK, but remember that the process won't interact with the
desktop on the remote machine -- which may well be what you
want -- and also that the environment will likely be different,
unless you're connecting as a specific user (and even then
I'm not sure!) So make sure that your Python paths etc.
will work, and that the user the process is running under
has sufficient security to do whatever it needs.

| XML_RCP would be nice, but probably to much for what i need.

XML-RPC is quite lightweight, but requires a running server
on the remote machine. (Not a big deal, but still more than
using the already-there WMI).

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


cx_Oracle string problems...

2006-02-13 Thread MooMaster
After some google searching on the forum I couldn't find any topics
that seemed to relate exactly to my problem, so hopefully someone can
help me out...

I'm running python 2.4.1 on a local Win2K system and doing some
work-related development on an AIX box, and I'm running into a problem
using cx_Oracle to add some information to an Oracle 9.2 table.

I have a table_title defined as a VARCHAR2 data type, and when I'm
trying to retrieve the data from a GUI I do so like this:

tableTitle = self.window.TitleCB.GetValue()

After retrieving several pieces of information, including mostly
integers, like this from my display I create a string that represents a
valid SQL statement and then use cx_Oracle 4.1 to connect to the Oracle
db on the server and write the data to the table, like so:

###snipet#
sql = str('INSERT INTO prime.utwsLOT VALUES (' + str(self.kID) + ',' +
string)
curse = self.connection.cursor()
curse.execute(sql)
###/snipet#

which generates the following string in Windows
INSERT INTO prime.utwsLOT VALUES (0,400,  'goo ', 0,  3,   2,  1)

This sucessfully connects to the db and writes the data from my Windows
box to the AIX box. One of the requirements of the application I'm
writing, however, is that it be installed and run from the AIX box
itself. When I try to run my code on the AIX box, however, THIS string
is generated, and the following happens:

INSERT INTO prime.utwsLOTVALUES(0, 400, "goo", 0, 3, 2, 1)
Traceback (most recent call last):
  File "treedisp.py", line 147, in Export
MyExport.LineExporter()
  File "/users/z04857/nickUT/OracleExporter.py", line 118, in
LineExporter
self.prepareSQL(toExport, "lines")
  File "/users/z04857/nickUT/OracleExporter.py", line 249, in
prepareSQL
self.doExport(sql)
  File "/users/z04857/nickUT/OracleExporter.py", line 261, in doExport
curse.execute(string)
cx_Oracle.DatabaseError: ORA-00984: column not allowed here

In the words of Metal Gear Solid:2: FISSION MAILED...

Notice the double quotes in the above sql string. I thought this might
be a problem, so I ran my SQLPlus client with the same string and got
the same error. The double quotes is definitely a no go! Being an
enterprising programmer, I figured I would just hardcode the single
quotes into the string to fix the problem, so I did the following:

tableTitle =str("'" + self.window.TitleCB.GetValue() +"'")

...and got the following string was created on the AIX box (as
displayed by a print statement I put in the code):
INSERT INTO prime.utwsLOTVALUES(0, 400, "goo", 0, 3, 2, 1)

uh-oh...Thinking that perhaps an escape sequence would solve the
problem, I made the following modification:
tableTitle =str("\'" + self.window.TitleCB.GetValue() +"\'")

and receieved the following string:
INSERT INTO prime.utwsLOTVALUES(0, 400, "goo", 0, 3, 2, 1)

This is when I heard Claire Redfield's quote from Resident Evil 2, "You
LOSE, big boy!", ring loudly in my ears... No matter what I do, I can't
seem to get the string to be set in single quotes on the AIX box.
*Something* keeps converting the string to double quotes, which in turn
causes the cx_Oracle database write to fail. I have no clue what could
be doing this...Has anyone else ever encountered a similar problem? Can
anyone think of something else I can try?

Sorry for the length, but thanks for the help!

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


Re: Arcane deployment considerations

2006-02-13 Thread Thomas Heller
Cameron Laird wrote:
> In article <[EMAIL PROTECTED]>,
> Thomas Heller  <[EMAIL PROTECTED]> wrote:
>   .
>   .
>   .
>> Usually the bundle=1 option in py2exe can create a single file exe, but it 
>> also
>> allows to have a separate shared library.zip file, which is useful if
>> you need more than
>> one exe-file.  With python 2.4, MSVCR71.dll is still required and not
>   .
>   .
>   .
> For some of our projects, we provide a single executable, which
> takes a command-line argument (or, rarely, environment variable)
> to tell the executable whether to come up as server or client,
> or GUI or command-line version, or ...  The result is that, even
> for an architecturally-sophisticated development, the end-user
> experiences a unitary delivery; he has just one file to install,
> remove, archive, ...  

Ok, so you're down to about 0.2 files per application ;-)

Thomas

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


Re: Image to numeric array

2006-02-13 Thread Claudio Grondi
Diez B. Roggisch wrote:
>>Is there a difference between the 'Numeric' and 'numeric' module?
>>I have on my system only Numeric... And this has no function like
>>'from_image'.
> 
> 
> I actually didn't check that - I just wanted to point the OP to the
> numeric-module(s) available, as he suggested that 
> 
> 
>>The usual way of doing such things is to use PIL (Python Image Library) 
>>to load the image from file, then export it from PIL to a Python string 
>>in order to import from this string to an array of the targeted 
>>numerical module.
> 
> 
> I'd go for the getdata() method instead.
Yes, you are right.
Sorry, I should have checked it in source code before posting just from 
my memory. Usage of .tostring() was my first approach - I have replaced 
it later by .getdata() because of speed issues (we are speaking here 
about methods of the Image module available after installation of PIL).
As I have experience with numarray only, I can't help here directly with 
  a code example for Numeric.

Claudio
> 
> 
>>Really curious if there is a direct way in any of the numerical 
>>packages, as it would save the time and effort of unnecessary 
>>conversions from PIL, ImageMagick or from other image libraries.
> 
> 
> Whatever module is capable of converting needs to know how to read images -
> either by itself, or by means of another module. 
> 
> 
> I know for sure that pygame supports retrieving pixel-data as array.
> 
> Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: emacs keybindings for scite/scinitilla?

2006-02-13 Thread Grant Edwards
On 2006-02-13, Grant Edwards <[EMAIL PROTECTED]> wrote:
> This is technically off-topic, but scite/scinitilla seems to
> have a particular connection to the Python community.
>
> I just tried scite for the first time and rather like it.  It
> uses GTK, which is shared with my desktop (XFCE) so it starts
> up fast.  It's fairly lean (at least by Emacs/Gnome/KDE
> standards), but I don't think I can un-learn emacs keybindings.
>
> Are emacs keybindings availble for scite somehow?

It seems there isn't.  

And it's apparently not possible.

Scintilla only supports single-key bindings, so there's no way
to impliment "prefix" keys like emacs's META or Ctrl-C. :(

I guess that's the end of Scite for me.

-- 
Grant Edwards   grante Yow!  I'll show you MY
  at   telex number if you show
   visi.comme YOURS...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do you pronounce 'tuple'?

2006-02-13 Thread Sergei Organov
John Salerno <[EMAIL PROTECTED]> writes:

> Yes, silly question, but it keeps me up at night.  :)
>
> I know it comes from the suffix -tuple, which makes me think it's 
> pronounced as 'toople', but I've seen (at m-w.com) that the first 
> pronunciation option is 'tuhple', so I wasn't sure. Maybe it's both, but 
> which is most prevalent?

I just checked my English dictionary, and for, say, "quintuple", it
suggests ['kwintjupl] pronunciation. I didn't check it before, but I
tend to pronounce tuple as [tjupl] indeed (in fact Russians would say it's
closer to [chjupl]).

-- Sergei.

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


Re: Shortest prime number program

2006-02-13 Thread Tim Hochberg

In the spirit of pointless pessimization and obfuscation I have crushed 
something very similar to Alex Martelli's eratosthenes function onto a 
single line. It's truly monstrous, but somewhat entertaining [Some 
preemptive linebreaks added]:

def short():import itertools as it;D={};g=D.get;return (
q for q in it.count(2) if
D.__setitem__(it.dropwhile(D.__contains__, 
xrange(g(q,q)+q,2**30,g(q,q))).next(),g(q,q))
or q not in D and D.pop(q,1))


I'm sure there's a lesson to this somewhere. Something like I need to 
find something better to do with my spare time.

-tim

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


Re: hard disk activity

2006-02-13 Thread Rene Pijlman
VSmirk:
>I have a task that involves knowing when a file has changed.  But while
>for small files this is an easy enough task, checking the modification
>dates, 

Checking the modification time works the same way for large files. Why is
that not good enough?

What's your platform?

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cx_Oracle string problems...

2006-02-13 Thread tooper
Looks like a space is missing before VALUES keyword ?

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


Encoding

2006-02-13 Thread Lad
I have a script that uses utf-8 encoding. Now I would like to send some
data to an application ( on another server) that uses 1250 encoding.
How can I tell the server that the coming data will be in utf-8 code?
I tried this
params='some data'
h = httplib.HTTP(self.host)
h.putheader("Content-type", "multipart/form-data;
boundary=---7d329422844")
h.putheader("Content-length", "%d" % len(params))
h.putheader("Accept-Language", "us-en")
h.putheader('Accept', 'image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, */*')
h.putheader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.1)')
h.putheader('Host', 'server')
h.endheaders()
.


but it doesn't work. The data are not encoded properly
Thanks for help
L.B.

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


Location of Python modules

2006-02-13 Thread Byte
Pretty much self explanatry, where are Python modules stored in Linux?
(i.e. in /usr/bin/local, or where?)

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


Re: Encoding

2006-02-13 Thread Szabolcs Nagy
what about params='some data'.decode('utf8').encode('1250') ?

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


Re: Location of Python modules

2006-02-13 Thread Szabolcs Nagy
/usr/lib/python2.4/site-packages ?

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


Re: cx_Oracle string problems...

2006-02-13 Thread MooMaster
Lol, that was a copy paste error into the post on my part...but the
problem has been fixed. Turns out that there was a string.replace call
somewhere else in the code that replaced all single quotes with empty
strings, which thus caused the singe quotes to disappear! Whoops!

Thanks for the look, though

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


Re: Location of Python modules

2006-02-13 Thread Byte
No, not there

 -- /usr/bin/byte

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


Re: Location of Python modules

2006-02-13 Thread Fredrik Lundh
"Byte" wrote:

> Pretty much self explanatry, where are Python modules stored in Linux?
> (i.e. in /usr/bin/local, or where?)

it depends on how and where Python is installed.  to see where they
are on your install, use

$ python -c "import sys; print sys.path"
['', '/usr/lib/python24.zip', '/usr/lib/python2.4', 
'/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', 
...

to check where a given module is installed, you can do

$ python -c "import cgi; print cgi.__file__"
/usr/lib/python2.4/cgi.pyc

hope this helps!





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


Re: Location of Python modules

2006-02-13 Thread bruno at modulix
Byte wrote:
> Pretty much self explanatry, where are Python modules stored in Linux?
> (i.e. in /usr/bin/local, or where?)
> 
Depends on how you installed Python (or how your distro package system
installed it). But it's usually in $PREFIX/lib/pythonX.X , with $PREFIX
being one of /usr or /usr/local (third-part modules being in the
site-packages subdirectory).

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FTPlib

2006-02-13 Thread Fredrik Lundh
Harlin Seritt wrote:

> Using ftplib from Python I am trying to get all files in a particular
> directory using ftplib and then send those same files to another ftp
> server. I have tried using commands like 'get *' and 'mget *' with no
> success.
>
> I am using the following:
>
> srcFtp = FTP(srcHost)
> srcFtp.login(srcUser, srcPass)
> srcDir = srcFtp.nlst('.')
> for file in srcDir:
> print file[2:]
> srcFtp.transfercmd('get '+file[2:])
>
> I've verified that I do have a connection with the ftp server and the
> files as 'file[2:]' are indeed the file names.
>
> Anyone know why I get the following error?
>
> podcast-1.mp3
> Traceback (most recent call last):
>   File "podsync.py", line 17, in ?
> srcFtp.transfercmd('get '+file[2:])
>   File "C:\Python24\lib\ftplib.py", line 345, in transfercmd
> return self.ntransfercmd(cmd, rest)[0]
>   File "C:\Python24\lib\ftplib.py", line 327, in ntransfercmd
> resp = self.sendcmd(cmd)
>   File "C:\Python24\lib\ftplib.py", line 241, in sendcmd
> return self.getresp()
>   File "C:\Python24\lib\ftplib.py", line 216, in getresp
> raise error_perm, resp
> ftplib.error_perm: 500 Syntax error, command unrecognized.

ftplib works with FTP protocol commands, not ftp client commands (such
as get and mget).

to read data from a remote server, you can use something like:

dst = open(localfile, "wb")
srcFtp.retrbinary("RETR " + file[2:], dst.write)
dst.close()

for more examples, see

http://effbot.org/librarybook/ftplib.htm

for an extensive description of FTP-as-deployed, see daniel bernstein's
site:

http://cr.yp.to/ftp.html

hope this helps!





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


Re: Location of Python modules

2006-02-13 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED]:~$ python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
They are in one of the directories listed in sys.path, for me this is:
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python24.zip', '/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages/HTMLgen',
'/usr/lib/python2.4/site-packages/Numeric',
'/usr/lib/python2.4/site-packages/PIL',
'/usr/lib/python2.4/site-packages/cairo',
'/usr/lib/python2.4/site-packages/gtk-2.0']
>>>

see http://docs.python.org/lib/module-sys.html

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


Re: Encoding

2006-02-13 Thread Martin v. Löwis
Lad wrote:
> I have a script that uses utf-8 encoding. Now I would like to send some
> data to an application ( on another server) that uses 1250 encoding.
> How can I tell the server that the coming data will be in utf-8 code?

You can't, normally. In theory, you should put

Content-type: text/plain;charset=utf-8

into the individual *part*. However, many implementations will ignore
the charset= argument on a part.

Instead, the convention is that the data must be transmitted in the
encoding of the *HTML page* which contained the form you are submitting.

So most likely, you need to recode your data.

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


Re: Location of Python modules

2006-02-13 Thread Martin v. Löwis
Byte wrote:
> No, not there

Sure:

[EMAIL PROTECTED]:~$ ls /usr/lib/python2.4/site-packages
apt  debconf.pyNumeric  pygtk.py
 README
apt_inst.so  debconf.pyc   Numeric.pth  pygtk.pyc
 setuptools-0.6a8-py2.4.egg
apt_pkg.so   easy-install.pth  ORBit.la pygtk.pyo
 setuptools.pth
cairoFormEncode-0.4-py2.4.egg  ORBit.so pygtk.py.python2.4-gtk2
cairo.pthgtk-2.0   pygtk.pthpython-support.pth


You mean, on *your* Linux? Give me an SSH account to your machine,
and I find out for you.

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


Re: Location of Python modules

2006-02-13 Thread Byte
Found it in /usr/local/lib/python2.4/site-packages, thanks. Now, how do
i convert a .py program into a module?

 -- /usr/bin/byte

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


Re: cx_Oracle string problems...

2006-02-13 Thread Carsten Haese
On Mon, 2006-02-13 at 13:18, MooMaster wrote:
> Lol, that was a copy paste error into the post on my part...but the
> problem has been fixed. Turns out that there was a string.replace call
> somewhere else in the code that replaced all single quotes with empty
> strings, which thus caused the singe quotes to disappear! Whoops!

Please do yourself a favor and make use of the fact that Python's
database API allows parametrized queries. Here's a sketch of what that
might look like:

sql = 'INSERT INTO prime.utwsLOT VALUES (:kID, etc...)'
curse = self.connection.cursor()
curse.execute(sql, kID=self.kID, etc...)

Of course, "etc..." would have to be replaced with additional
placeholders and parameter values for all the columns in utwsLOT.

By using parametrized queries, you don't have to worry about any of the
supplied values requiring special treatment due to any quotation marks
or apostrophes that might they might contain.

Hope this helps,

Carsten.

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


Re: cx_Oracle string problems...

2006-02-13 Thread Carsten Haese
On Mon, 2006-02-13 at 13:50, Carsten Haese wrote:
> By using parametrized queries, you don't have to worry about any of the
> supplied values requiring special treatment due to any quotation marks
> or apostrophes that might they might contain.

Add grammar corrections to taste.

-Carsten


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


Re: Location of Python modules

2006-02-13 Thread Fredrik Lundh
"Byte" <[EMAIL PROTECTED]> wrote:

> Found it in /usr/local/lib/python2.4/site-packages, thanks. Now, how do
> i convert a .py program into a module?

a .py program is a module (the module's content is what's left when the
program is finished).

to make a useful module, just make sure that it defines all the stuff you
want to make available (functions, classes, constants, etc), and that it
doesn't have any unexpected side-effects.

to create a script that can be used both as a script and as a module, you
can check the __name__ variable.  see:

http://diveintopython.org/getting_to_know_python/testing_modules.html

for more on this.





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


Re: Rethinking the Python tutorial

2006-02-13 Thread Magnus Lycka
Steve Holden wrote:
> Magnus Lycka wrote:
> As with all such content, the first thing you will need is a band of 
> volunteers dedicated to keeping the content up to date, both proactively 
> and in response to reader comments.

That's why I suggested these already written tutorials. Both
authors have shown that they can make an effort, and there are
other people who have helped with contributions such as
translations. Hopefully, giving these texts a more official
status will stimulate them further and make more people
interested, but I guess it could also go the other way, if it
isn't handled well.

> What we are talking about here is a Python Language Users' Guide.

Agreed.

> Google are very active supporters of Python already, though they don't 
> make a big song and dance about it. You might notice, for example, that 
> they are a Platinum Sponsor at PyCon this year, as well as being a 
> sponsor member of the PSF. The Summer of Code also benefited Python in 
> several ways.

I didn't notice the PyCon sponsorship. Maybe that's something for
the EuroPython arrangers to think about... After all, EuroPython 2006
will be at CERN, and that's where the whole web thingie started... :)

> There are older-established companies with more Python programmers who 
> have made hardly any community contribution - the "takers" of the open 
> source world. I wouldn't like Google to think that the Python community 
> isn't recognizing their support.

It has improved lately, and I agree that others could chip in as well.

> You might also like to ask Alex what he'd feel about losing the 
> "Nutshell" revenue stream!

Well, I suggested they'd pay him for it. Perhaps a decent sized sack
of money now is as good as that long term stream... It was just a wild
idea though. You know, they don't usually come true, but who knows?
Suggesting it might increase the chances. It would certainly be a
boost for Python to have such excellent documentation on the web. It
would probably make it easier for Google (and you other big corps!)
to find good Python programmers in the future.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there a better way?

2006-02-13 Thread Magnus Lycka
[EMAIL PROTECTED] wrote:
> Problem:
> 
> You have a list of unknown length, such as this: list =
> [X,X,X,O,O,O,O].  You want to extract all and only the X's.  You know
> the X's are all up front and you know that the item after the last X is
> an O, or that the list ends with an X.  There are never O's between
> X's.
> 
> I have been using something like this:
> _
> 
> while list[0] != O:
> storage.append(list[0])
> list.pop(0)
> if len(list) == 0:
> break
> _
> 
> But this seems ugly to me, and using "while" give me the heebies.  Is
> there a better approach?

It seems few suggested solutions actually do the same thing as
your code shows. I think this does. (Untested)

try:
 ix = aList.index(O)
 storage, aList = aList[:ix], aList[ix:]
except ValueError:
 # No O's
 storage, aList = aList, []


The main advantage with my approach over yours is that
all iterations, all the looping, takes place in fast C
code, unless your list elements are Python classes that
implement __cmp__ etc. If testing 'aList[0] == O'
involves Python, things might slow down a bit...

.index() takes linear time, but it's fairly fast. As
Alex suggested, you might want to replace it with a
O(log n) solution for big lists. You might need rather
big lists for the Python based O(log n) to get faster
than the C based O(n) though. Measure.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Location of Python modules

2006-02-13 Thread Szabolcs Nagy
LOL

a .py program is a module, you can import it:
if it is in the sys.path (import modulename).
if it sits in a directory that is in the sys.path and the directory
also has a __init__.py file (import dirname.modulename / from dirname
import modulname).
if there is a modulename.pth file in the sys.path containing the path
to your .py file.
(the current dir is always in the sys.path).

if you want to install your module (copy it under the site-packages
dir), then you should use distutils module and create a setup.py script

the compiled bytecode (.pyc file) is always automatically generated

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


Re: hard disk activity

2006-02-13 Thread VSmirk
I'm working primarily on Windows XP, but my solution needs to be cross
platform.

The problem is that I need more than the fact that a file has been
modified.  I need to know what has been modified in that file.

I am needing to synchronize the file on a remote folder, and my current
solution, which simply copies the file if a date comparison or a
content comparison, becomes a bit unmanageable for very large files.
Some of the files I'm working with are hundreds of MB in size, or
larger.

So I need to skip copying a hundred MB file that has had only a few
bytes changed and instead identify which few bytes have changed and
where those changes are.  I was thinking having a module that worked
below the file system level, at the device level, might be a place to
look for a solution.

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


Re: Jython socket typecasting problems

2006-02-13 Thread Mark Fink
thanks to the help of this group I moved a tiny step forward. Obviously
it is not possible to resolve name localhost:
Type "copyright", "credits" or "license" for more information.
>>> import socket
>>> s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(localhost, 8080)
Traceback (innermost last):
  File "", line 1, in ?
NameError: localhost
>>> s.connect((localhost, 8080))
Traceback (innermost last):
  File "", line 1, in ?
NameError: localhost
>>> s.connect(('127.0.0.1', 8080))
Traceback (innermost last):
  File "", line 1, in ?
  File "D:\AUT_TEST\Jython21\Lib\socket.py", line 135, in connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:507)

Unfortunately this is not the solution (I tried 127.0.0.1 before my
first post).
I added the two print lines as recommended:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print type(self.host), repr(self.host)
print type(self.port), repr(self.port)
self.socket.connect((self.host, self.port))
self.socketOutput = self.socket.getOutputStream()

And more specific information:
D:\AUT_TEST\workspace\JyFIT\fit>jython JyFitServer2.py 127.0.0.1 1234
12
['JyFitServer2.py', '127.0.0.1', '1234', '12']
127.0.0.1
org.python.core.PyString '127.0.0.1'
org.python.core.PyString '1234'
Traceback (innermost last):
  File "JyFitServer2.py", line 148, in ?
  File "JyFitServer2.py", line 31, in run
  File "JyFitServer2.py", line 98, in establishConnection
  File "D:\AUT_TEST\Jython21\Lib\socket.py", line 135, in connect
TypeError: java.net.Socket(): 1st arg can't be coerced to
java.net.InetAddress or String

No casting from string to string?? I learned that there is no such
thing as explicit typecasting. What to do?

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


Re: python-ldap

2006-02-13 Thread [EMAIL PROTECTED]
hy...

if you dont know how to help people here... dont say "google it".

groups.google was made to help! not to say google it!

i really dont not what kind of professional you are to say "google it!"

you are smart boy!

i think your mom has much pride of you!

google it to learn more than say "google it!"

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


Re: hard disk activity

2006-02-13 Thread Paul Rubin
"VSmirk" <[EMAIL PROTECTED]> writes:
> I am needing to synchronize the file on a remote folder, and my current
> solution, which simply copies the file if a date comparison or a
> content comparison, becomes a bit unmanageable for very large files.
> Some of the files I'm working with are hundreds of MB in size, or
> larger.

Why don't you look at the rsync program:

  http://samba.anu.edu.au/rsync/

but for that much data, just plopping it all in a huge file is not
a great approach if you can help it.  Maybe you can use a database instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


trapping errors in function call syntax

2006-02-13 Thread Avi Kak

Hello:

   Suppose I write a function that I want to be called
   with ONLY keyword argumnts, how do I raise an
  exception should the function get called with 
  what look like position-specfic arguments?

  Any help would be appreciated.

Avi Kak

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


Bjam Boost Python Build

2006-02-13 Thread timsson
I need some help here.  When i build using the following jamfile it
moves my build files into the directories specified below except for
the boost_python.dll.   What would I add in to make the
boost_python.dll go to the same directory as the rest of the files.

SubDir TOP Dummy;

import python ;

extension Dummy: Dummy.cpp
@boost/libs/python/build/extension ;

stage $(TOP)/Tie : Dummy;

InstallFile $(TOP)\\Tie : test_Dummy.py ;

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



Re: trapping errors in function call syntax

2006-02-13 Thread Carsten Haese
On Mon, 2006-02-13 at 14:13, Avi Kak wrote:
> Hello:
> 
>Suppose I write a function that I want to be called
>with ONLY keyword argumnts, how do I raise an
>   exception should the function get called with 
>   what look like position-specfic arguments?
> 
>   Any help would be appreciated.

Something like this should do the trick:

def f(*args, **kwargs):
  if args: raise TypeError, "Please use keyword arguments."
  ...

-Carsten


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


Re: trapping errors in function call syntax

2006-02-13 Thread Fredrik Lundh
Avi Kak wrote:

> Suppose I write a function that I want to be called
> with ONLY keyword argumnts, how do I raise an
> exception should the function get called with
> what look like position-specfic arguments?

here's one way to do it:

>>> def func(*args, **kw):
... def myrealfunc(a=1, b=2, c=3):
... print a, b, c
... if args:
... raise TypeError("invalid call")
... return myrealfunc(**kw)
...
>>> func(1)
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 5, in func
TypeError: invalid call
>>> func(a=3)
3 2 3
>>> func()
1 2 3

here's another one:

>>> def func(dummy=None, a=1, b=2, c=3):
... if dummy is not None:
... raise TypeError("invalid call")
... print a, b, c

(but this is easier to trick).

hope this helps!





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


Re: Jython inherit from Java class

2006-02-13 Thread Mark Fink
Hi Kent,
many thanks for your help! In the meantime I received my "Jython
Essentials" book and hope that I have much fewer questions in the near
future.
One last question for this thread. I tried to inherit from a Java class
and override on method. I figured that this approach was nonsense
because the method used private attributes of the Java class. Now I
read that there is injection used in Jython. Jython uses setter and
getter methods to do the injection, right? Unfortunately the Java class
has no setters and getters for the private members. Is there another
way to override the method besides rewriting the Java class or is this
approach really doomed?

Cheers,
Mark

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


Re: trapping errors in function call syntax

2006-02-13 Thread Andrew Gwozdziewycz
While we're at it... Can someone point me to either an old post, or
documentation about tuple expansion with * ? I recently saw it used
and was shocked as i had no clue what it really did. I didn't know it
could be used outside of function definitions.

On 2/13/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Avi Kak wrote:
>
> > Suppose I write a function that I want to be called
> > with ONLY keyword argumnts, how do I raise an
> > exception should the function get called with
> > what look like position-specfic arguments?
>
> here's one way to do it:
>
> >>> def func(*args, **kw):
> ... def myrealfunc(a=1, b=2, c=3):
> ... print a, b, c
> ... if args:
> ... raise TypeError("invalid call")
> ... return myrealfunc(**kw)
> ...
> >>> func(1)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "", line 5, in func
> TypeError: invalid call
> >>> func(a=3)
> 3 2 3
> >>> func()
> 1 2 3
>
> here's another one:
>
> >>> def func(dummy=None, a=1, b=2, c=3):
> ... if dummy is not None:
> ... raise TypeError("invalid call")
> ... print a, b, c
>
> (but this is easier to trick).
>
> hope this helps!
>
> 
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
Andrew Gwozdziewycz <[EMAIL PROTECTED]>
http://ihadagreatview.org
http://plasticandroid.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trapping errors in function call syntax

2006-02-13 Thread Tim Hochberg
Avi Kak wrote:
> Hello:
> 
>Suppose I write a function that I want to be called
>with ONLY keyword argumnts, how do I raise an
>   exception should the function get called with 
>   what look like position-specfic arguments?
> 
>   Any help would be appreciated.

Say you want the signature to be foo(a, b, c) with no positional 
arguments allowed. You can do this:

def foo(*args, **kwargs):
 a = kwargs.pop('a')
 b = kwargs.pop('b')
 c = kwargs.pop('c')
 if args or kwargs:
 raise TypeError("foo takes only keyword arguments: foo(a,b,c)")
 # ...


Or something similar.

-tim

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


  1   2   3   >