Re: C Source Code Generator For Test Cases

2007-09-28 Thread Marc 'BlackJack' Rintsch
On Fri, 28 Sep 2007 12:57:49 -0700, gamename wrote:

>> How about using c-types to access your C-stuff to test, and use python + the
>> testcase-tables to invoke that?
>>
> 
> Sure, that's possible.  But the source code for tests (once all the
> parms are read)
> still needs to be generated.  Calling the lib from python or from C,
> there still
> needs to be a way to generate 100+ test routines. ;-)

Instead of reading the testcase tables and generating source for test
routines you simply can do the tests right away.

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


Re: your opinion on book "Foundations of Python Network Programming"?

2007-09-28 Thread [EMAIL PROTECTED]
On Sep 28, 12:38 pm, "sean tierney" <[EMAIL PROTECTED]> wrote:
> I just read it (though I bought it half a year ago...don't judge :).
>
> Author recommends Python 2.3 and above...and as far as I know the
> examples are good.  And if anything IS outdated -- you'll be able to
> do some quick research to get you to where you need to be...and he
> does mention code several areas of change/addition/modification. (ie
> urllib and urllib2).  He uses a couple of 3rd party projects too.
>
> I really liked the book.  I think Goerzen did a good job.  He
> addresses the code in the context of the problem the code is meant to
> solve, which I found helpful.  That said, it's not a substitute for
> actually reading the code.
>
> ...if you haven't read the most recent edition of Programming Python
> by Mark Lutz (O'Reilly), I'd recommend that first.  Programming Python
> covers (some) networking and everything else.  More bang for the $$.
>
> Sean

Sean, thanks for your review and recommendation of the book
Programming Python. atm, i'm looking for a book that has detailed
coverage on networking. so "Foundations of ..." seems to be a good
choice for me.

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


Re: python 2.5 and 3gb switch

2007-09-28 Thread neil
why?
I am asking if any one knows of a 3gb python build.
The code runs successfully in lesser missions it just wont run in the extra 
memory available when I try to run it along with my other programs in a 3gb 
space.
thanks for your reply though 


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


Re: your opinion on book "Foundations of Python Network Programming"?

2007-09-28 Thread [EMAIL PROTECTED]
On Sep 28, 12:10 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> I have not read this book but just wanted to say, in case you don't
> already know, they have Chapter 13 on FTP available as a free download
> at the publisher's web site:
>
> http://www.apress.com/book/view/1590593715

thanks for the link, i just downloaded the chapter.

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


Re: Python and SSL

2007-09-28 Thread Paul Rubin
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:
> > But how can I tell my Python program to trust my SSL certificate?
> 
> Why do you want to tell it that? The SSL module will trust *any*
> server certificate, no need to tell it explicitly which ones to
> trust.

Er, the whole idea of SSL is that you don't trust the connection.  So
failing to authenticate the other end is a security failure and SSL
should not be used that way.  From RFC 4346:

   Warning: Completely anonymous connections only provide protection
against passive eavesdropping.  Unless an independent
tamper-proof channel is used to verify that the finished
messages were not replaced by an attacker, server
authentication is required in environments where active
man-in-the-middle attacks are a concern.

It's silly to worry about an eavesdropper being nosy enough to
intercept your data passively, but somehow still expect them to be
considerate enough to not use an MITM attack.  Always use
authentication if it's worth bothering with cryptographic security at
all.  

Another plan for server to server communication might be to use a VPN
rather than connection level SSL.  That would simplify your
application programming if you can set up the encrypted network at
both ends.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: Bug: spurious indentation error

2007-09-28 Thread Gabriel Genellina
En Sat, 29 Sep 2007 01:43:53 -0300, Mridula Ramesh  
<[EMAIL PROTECTED]> escribi�:

> Lol, nope, I checked today too, and it happened again. Try running this  
> as a
> script, not from the prompt -

I got a SyntaxError on line 10 as expected.
After correcting it, I got an `IndentationError: expected an indented  
block` on line 23, due to a long line being wrapped onto the next line.

A syntax error may be reported some lines later than the actual mistake,  
if the following lines build a good construct. For example, a missing  
close parenthesis.

-- 
Gabriel Genellina

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

Re: Re: Bug: spurious indentation error

2007-09-28 Thread Mridula Ramesh
Hi.

Lol, nope, I checked today too, and it happened again. Try running this as a
script, not from the prompt -

class main():
def __init__(self):
rt.geometry("680x600")
rt.config(bg="CornSilk")
rt.title("my miniscule app")
#MENU
menu = Menu(rt)
rt.config(menu=menu)
# create a menu
filemenu = Menu(menu), bg="White") #syntax error/ typo in this line.
menu.add_cascade(label="Options", menu=filemenu)
filemenu.add_command(label="Add New")#, command=callback)
filemenu.add_command(label="Edit")
filemenu.add_command(label="Delete")
filemenu.add_separator()
filemenu.add_command(label="Exit")
self.dbConnect()
self.nowgather(gctr)
self.showfixed()
self.showrecords()

def dbConnect(self): #error gets thrown here as a tab-space indentation
error.
#connects to database D:/Catalogue.mdb, and gathers all data in a
recordset
#called rs. Puts this information into individual lists by field
name
global gmax
#setting record count to zero afresh.
import win32com.client
conn = win32com.client.Dispatch('ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA
SOURCE=D:/Catalogue.mdb;'
conn.Open(DSN)
rs = win32com.client.Dispatch('ADODB.Recordset')
rs_name="MyRecordSet"
rs.Cursorlocation = 3
rs.Open('SELECT * FROM Library', conn)
gmax = rs.RecordCount


Regards,
Mridula.



This is probably a bug in your mind, not in the compiler ;-)

Without more detail (i.e. the complete code or a sizable and relevant
chunk of it, pkus the copied error message) it's impossible to say
exactly what was happening. However I am pretty confident that the
2.5.21 compiler will immediately report an unopened closing parenthesis
as a syntax error.

 >>> something = "abc".replace("c"), "d")
  File "", line 1
something = "abc".replace("c"), "d")
   ^
SyntaxError: invalid syntax
 >>>

So, what was the problem again? Give us a little more detail,  please.

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

Re: Python and SSL

2007-09-28 Thread John Nagle
Heikki Toivonen wrote:
> Johny wrote:
>> I need to use Python with SSL comunication betweeen servers.
>> (I use hhtplib but I think urllib2 can also be used )
>>  I think I need to use SSL root certificate and tell  a program to
>> trust this certificate.
> 
> You can't do secure SSL with the builtin SSL support, you need to use a
> third party module. There are a few available, including M2Crypto, TLS
> Lite, pyOpenSSL and pyOpenSSL-extended. Since I am the maintainer of
> M2Crypto I will naturally recommend that ;)
> 
> http://chandlerproject.org/Projects/MeTooCrypto

 Any progress on getting M2Crypto 0.18 to build successfully
on Fedora Core?

John Nagle

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


Re: cute use of lambda

2007-09-28 Thread Kay Schluehr
On 29 Sep., 03:55, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> "Simon Forman" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> | class FakeQueue(list):
> |put = list.append
> |get = lambda self: self.pop(0)
>
> Sorry, to me this is a foolish use of lambda as it is exactly the same as
>
>   def get(self): self.pop(0)

Better use

def get(self): return self.pop(0)

otherwise you will *get* nothing ;)

BTW I wonder why a destructive operation is named *get* instead of
*take* ?

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


Re: Python 3.0 migration plans?

2007-09-28 Thread John Nagle
George Sakkis wrote:
> On Sep 28, 11:53 am, John Nagle <[EMAIL PROTECTED]> wrote:
> 
>> Alex Martelli wrote:
>>> John Nagle <[EMAIL PROTECTED]> wrote:
 TheFlyingDutchman wrote:
> It seems that Python 3 is more significant for what it removes than
> what it adds.
> What are the additions that people find the most compelling?
 I'd rather see Python 2.5 finished, so it just works.
>>> And I'd rather see peace on Earth and goodwill among men than _either_
>>> Python 3 or your cherished "finished" 2.5 -- the comparison and implied
>>> tradeoff make about as much sense as yours.
>>  Insofar as Python has an organization, it's not adequately managing
>> extension modules.  Each extension module has its own infrastructure,
>> with its own build procedures, its own bug list, and its own maintainers.
>> There's not even an archive.  Unlike CPAN, Cheese Shop is just a directory of
>> URLs.
>>
>>  Take a look at how Perl does it.  Here are the instructions on
>> how to contribute to CPAN:
>>
>>http://www.cpan.org/modules/04pause.html
>>
>> There's a way to get your module into the system, a standardized format,
>> build, and installation procedure, and an archive which is mirrored.
>> There's a common bug reporting system.  Modules abandoned by their
>> original developers are not lost, and can be "adopted" by someone else.
>>
>>  Python doesn't have any of this.  And that's far more of a problem
>> than Python 3.x.
> 
> Does Perl support extension modules, and if so, are they so prevalent
> as in Python ? 

 Yes, Perl supports non-Perl extension modules.  But most of the
important ones are either maintained as part of the standard Perl distribution,
or supported by the organization that provides whatever they link to.
For example, MySQL AB supports a Perl binding to MySQL, but not a
Python binding.

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


How to display a videostream in the PyQt GUI by a efficient way

2007-09-28 Thread kivilaya
Hello, everyone, : )

  I'm a beginner of pyqt, and recently I'm having a problem with it. I
hope someone could help me.

  As required, I need to get a videostream from a camera, and process
every frame to add some information on it, and then display the frame
in a PyQt GUI.
  But I don't know how to display the videostream in the PyQt GUI by a
efficient way.

Currently, I do these like this:
1. Get the videostream by the videocapture module (a useful module
written by Markus Gritsch) in the format of  PIL images;
2. Process every PIL image and add the information;
3. Convert every PIL image to QPixmap and display it using
QLabel.setPixmap.


I think it is a very inefficient way, but I don't known how to display
the videostream in other ways, so I need your help,  Thanks!

PS:I do it with Windows XP, Python 2.5.1, PyQt4.3.0

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

Re: python 2.5 and 3gb switch

2007-09-28 Thread James Stroud
neil wrote:
> Hello group,
> 
> I have a question I hope someone knowledgeable here might assist me with :o)
> 
> I am working on a python exporter to get a scene out of Blender and into a 
> renderer called Indigo. I hope you at least have heard of open source 
> Blender..
> The scene is very large requiring me to use a 3gb switch enabled version of 
> Blender and of course boot into a 3gb XP.
> Unfortunately it seems that the limitation is now that python wont handle 
> the mission I pass to it.
> I am wondering if there is any build of python available that is 3gb aware? 
> ( if that is indeed the issue)
> I see python is not really there for 64 bit yet but most of the people 
> wanting to use this exporter will have 32 bit anyway.
> 
> Any assistance is appreciated
> regards
> Neil 
> 
> 

Please post the relevant code and error messages.

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


Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread Gabriel Genellina
En Fri, 28 Sep 2007 14:36:54 -0300, xkenneth <[EMAIL PROTECTED]> escribi�:

> On Sep 28, 12:30 pm, xkenneth <[EMAIL PROTECTED]> wrote:
>> Looking to do something similair. I'm working with alot of timestamps
>> and if they're within a couple seconds I need them to be indexed and
>> removed from a list.
>> Is there any possible way to index with a custom cmp() function?

The comparison is made by the list elements themselves (using their __eq__  
or __cmp__), not by the index method nor the list object.
So you should modify __cmp__ for all your timestamps (datetime.datetime, I  
presume?), but that's not very convenient. A workaround is to wrap the  
object you are searching into a new, different class - since the list  
items won't know how to compare to it, Python will try reversing the  
operands.
datetime objects are a bit special in this behavior: they refuse to  
compare to anything else unless the other object has a `timetuple`  
attribute (see  note (4))


import datetime

class datetime_tol(object):
 timetuple=None # unused, just to trigger the reverse comparison to  
datetime objects
 default_tolerance = datetime.timedelta(0, 10)

 def __init__(self, dt, tolerance=None):
 if tolerance is None:
 tolerance = self.default_tolerance
 self.dt = dt
 self.tolerance = tolerance

 def __cmp__(self, other):
 tolerance = self.tolerance
 if isinstance(other, datetime_tol):
 tolerance = min(tolerance, other.tolerance)
 other = other.dt
 if not isinstance(other, datetime.datetime):
 return cmp(self.dt, other)
 delta = self.dt-other
 return -1 if delta<-tolerance else 1 if delta>tolerance else 0

def index_tol(dtlist, dt, tolerance=None):
 return dtlist.index(datetime_tol(dt, tolerance))


d1 = datetime.datetime(2007, 7, 18, 9, 20, 0)
d2 = datetime.datetime(2007, 7, 18, 9, 30, 25)
d3 = datetime.datetime(2007, 7, 18, 9, 30, 30)
d4 = datetime.datetime(2007, 7, 18, 9, 30, 35)
d5 = datetime.datetime(2007, 7, 18, 9, 40, 0)
L = [d1,d2,d3,d4,d5]

assert d3 in L
assert L.index(d3)==2
assert L.index(datetime_tol(d3))==1 # using 10sec tolerance
assert index_tol(L, d3)==1
assert index_tol(L, datetime.datetime(2007, 7, 18, 9, 43, 20),  
datetime.timedelta(0, 5*60))==4 # 5 minutes tolerance


-- 
Gabriel Genellina

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

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-09-28 Thread Damien Kick
Giorgos Keramidas wrote:
> On Fri, 22 Jun 2007 23:08:02 -, [EMAIL PROTECTED] wrote:
>> So much for the "free" in "free software". If you can't actually use
>> it without paying money, whether for the software or for some book, it
>> isn't really free, is it?
> 
> Please do not confuse the term 'free' in 'free software' with 'gratis'.
> 
> 'Gratis', i.e. 'lacking a monetary price tag' is something *very*
> different from the meaning of 'free' in 'free software'.

If you were referring to the "free" in "free Mumia Abu Jamal", I would 
agree with you.  I don't think anyone would imagine that this phrase 
meant that someone was going to get Mumia Abu Jamal gratis.  Like it or 
not, "free software" referring to "free as in beer" is probably the most 
common interpretation of the phrase for a native English speaker. 
Admittedly, I do not have a "scientific" survey handy.  However, I just 
asked my wife--who has absolutely no interest in anything related to 
programming, has never heard of the FSF, Eric Raymond, nor the 
disagreement between those two camps, nor probably will she ever have an 
interest--what she thinks I mean when I say "free software".  After 
getting over the "why are you asking such a stupid question" phase, the 
first thing that jumped to her mind was "free as in beer".  You can 
stamp, growl, swagger, spit, curse, and bluster all you want on this 
point, but millions of English speakers are going to ignore you anyway. 
  Lucky for most of them, they do not have to suffer the lectures of 
sociopolitically motivated language mavens trying to "correct" them from 
the error of mistaking the meaning of a phrase to be the normal meaning 
of that phrase.
-- 
http://mail.python.org/mailman/listinfo/python-list


using inspect on pygtk

2007-09-28 Thread Chris Pax
Hello,

I recently been trying to use the inspect module to inspect the
arguments of gtk objects, such as gtk.Button. I tried like this:

inspect.getargspec(gtk.Button.__init__)

and get the fallowing error:

  File "", line 1, in 
  File "/usr/lib/python2.5/inspect.py", line 743, in getargspec
raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function


I have been trying to do this through code so that I don't have to
have a list of all possible gtk classes and their arguments.

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


Re: cute use of lambda

2007-09-28 Thread Terry Reedy

"Simon Forman" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| class FakeQueue(list):
|put = list.append
|get = lambda self: self.pop(0)

Sorry, to me this is a foolish use of lambda as it is exactly the same as

  def get(self): self.pop(0)

except that in the latter, the resulting function object gets a proper 
internal name instead of '', therefore giving a more informative 
traceback in case of an exception.

tjr



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


python 2.5 and 3gb switch

2007-09-28 Thread neil
Hello group,

I have a question I hope someone knowledgeable here might assist me with :o)

I am working on a python exporter to get a scene out of Blender and into a 
renderer called Indigo. I hope you at least have heard of open source 
Blender..
The scene is very large requiring me to use a 3gb switch enabled version of 
Blender and of course boot into a 3gb XP.
Unfortunately it seems that the limitation is now that python wont handle 
the mission I pass to it.
I am wondering if there is any build of python available that is 3gb aware? 
( if that is indeed the issue)
I see python is not really there for 64 bit yet but most of the people 
wanting to use this exporter will have 32 bit anyway.

Any assistance is appreciated
regards
Neil 


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


Re: Emailing the attachment created with the Quick Screenshots Script(Python + PIL)

2007-09-28 Thread Gabriel Genellina
En Fri, 28 Sep 2007 12:56:18 -0300, Mark Bratcher  
<[EMAIL PROTECTED]> escribi�:

> The quick screenshots script works great for the project I'm working on  
> and
> I'm trying to modify it to include emailing the JPG file it generates.  I
> retrieved both scripts from the Python Archives.  The modified script is
> pasted below and the errors below that.  My goal is to have the latest  
> date
> stamped file emailed to me.

> editorstring='"start"%s" "%s"'% (ImageEditorPath,saveas) #Just for  
> Windows
> right now?

Do you really want to open the image with MSPaint? If not, remove the  
above line and the os.system call
(it's wrong, anyway...)

> # me == the sender's email address
>
> # family = the list of all recipients' email addresses
>
> msg['From'] = ("Mark Bratcher")
>
> msg['To'] = COMMASPACE.join("Mark Bratcher")

Ouch... Try printing msg['To'] (before correcting anything) and see what  
happens :)

msg['From'] = "[EMAIL PROTECTED]"
msg['To'] = "[EMAIL PROTECTED]"

They might be the same address. That COMMASPACE.join was to account for  
multiple recipients - just ignore it for now.

> for file in "c:\downloads\python\Attachments\*.jpg":

a) This `for` iterates over all the LETTERS on c:\downloads...
b) The path should be written r"c:\downloads..." as seen on the first  
lines on your script
c) Don't you want a SINGLE jpg? Why iterate over all ones? You already  
know the filename, it's the `saveas` variable above.

Replace the whole for loop with:

# Open the files in binary mode.  Let the MIMEImage class automatically
fp = open(saveas, 'rb')
img = MIMEImage(fp.read())
fp.close()
msg.attach(img)

> # Send the email via our own SMTP server.
> s = smtplib.SMTP()

Above, you may need to provide details about your SMTP, like  
SMTP("mail.cclpcitrus.com")

> s.connect()
> s.sendmail(me, family, msg.as_string())
> s.close()

me? family?
Try with:
s.sendmail(msg['From'], msg['To'], msg.as_string())

Good luck!

-- 
Gabriel Genellina

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

Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread Hrvoje Niksic
xkenneth <[EMAIL PROTECTED]> writes:

> Looking to do something similair. I'm working with alot of timestamps
> and if they're within a couple seconds I need them to be indexed and
> removed from a list.
> Is there any possible way to index with a custom cmp() function?
>
> I assume it would be something like...
>
> list.index(something,mycmp)

The obvious option is reimplementing the functionality of index as an
explicit loop, such as:

def myindex(lst, something, mycmp):
for i, el in enumerate(lst):
if mycmp(el, something) == 0:
return i
raise ValueError("element not in list")

Looping in Python is slower than looping in C, but since you're
calling a Python function per element anyway, the loop overhead might
be negligible.

A more imaginative way is to take advantage of the fact that index
uses the '==' operator to look for the item.  You can create an object
whose == operator calls your comparison function and use that object
as the argument to list.index:

class Cmp(object):
def __init__(self, item, cmpfun):
self.item = item
self.cmpfun = cmpfun
def __eq__(self, other):
return self.cmpfun(self.item, other) == 0

# list.index(Cmp(something, mycmp))

For example:

>>> def mycmp(s1, s2):
...   return cmp(s1.tolower(), s2.tolower())
>>> ['foo', 'bar', 'baz'].index(Cmp('bar', mycmp))
1
>>> ['foo', 'bar', 'baz'].index(Cmp('Bar', mycmp))
1
>>> ['foo', 'bar', 'baz'].index(Cmp('nosuchelement', mycmp))
Traceback (most recent call last):
  File "", line 1, in 
ValueError: list.index(x): x not in list

The timeit module shows, somewhat surprisingly, that the first method
is ~1.5 times faster, even for larger lists.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread Paul Rubin
xkenneth <[EMAIL PROTECTED]> writes:
> Looking to do something similair. I'm working with alot of timestamps
> and if they're within a couple seconds I need them to be indexed and
> removed from a list.
> Is there any possible way to index with a custom cmp() function?

This sounds like you want itertools.groupby.  What is the exact
requirement?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> On Sep 28, 8:30 pm, xkenneth <[EMAIL PROTECTED]> wrote:
>> Looking to do something similair. I'm working with alot of timestamps
>> and if they're within a couple seconds I need them to be indexed and
>> removed from a list.
>> Is there any possible way to index with a custom cmp() function?
>>
>> I assume it would be something like...
>>
>> list.index(something,mycmp)
>>
>> Thanks!
> 
> Wouldn't it be enough to get the items that are "within a couple of
> seconds" out of the list and into another list. Then you can process
> the other list however you want. Like this:
> 
>  def isNew(x):
>  return x < 5
> 
>  data = range(20)
>  print data
>  out, data = filter(isNew, data), filter(lambda x: not isNew(x), data)
>  print out, data

Slightly off topic here, but these uses of filter will be slower than 
the list comprehension equivalents::

 out = [x for x in data if x < 5]
 data = [x for x in data if x >= 5]

Here are sample timings::

$ python -m timeit -s "data = range(20)" -s "def is_new(x): return x < 
5" "filter(is_new, data)"
10 loops, best of 3: 5.05 usec per loop
$ python -m timeit -s "data = range(20)" "[x for x in data if x < 5]"
10 loops, best of 3: 2.15 usec per loop

Functions like filter() and map() are really only more efficient when 
you have an existing C-coded function, like ``map(str, items)``. Of 
course, if the filter() code is clearer to you, feel free to use it, but 
I find that most folks find list comprehensions easier to read than 
map() and filter() code.

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


Re: Numeric command-line options vs. negative-number arguments

2007-09-28 Thread Steven Bethard
Carl Banks wrote:
> On Sep 28, 9:51 am, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> It was decided that practicality beats purity here. Arguments with
>> leading hyphens which look numeric but aren't in the parser are
>> interpreted as negative numbers. Arguments with leading hyphens which
>> don't look numeric and aren't in the parser raise errors. Sure, it's not
>> the pure answer, but it's the practical answer: "-123" is much more
>> likely to be a negative number than an option.
> 
> What if (for example) you define a option "-3", and also accept
> numerical arguments on the command line.  Then you could get sudden
> unexpected behavior if you input the wrong number:
> 
> "./hello -1"  works ok.
> "./hello -2"  works ok.
> "./hello -3"  ... whoops, now the negative number is suddenly an
> option.
> 
> Granted, it would be stupid for a program to do that, but it suggests
> to me that it's probably a good idea to treat all negative numbers the
> same.  I.e. if there are any numerical options, then all negative
> numbers are treated as options.  If there are none, then negative
> numbers are treated as numbers.

That's probably a good guideline. Anyone mixing numeric flags with 
negative number arguments is asking for an exception of some sort. ;-) 
I'm going to let it sit for a while and think about it, but I'll 
probably make that change in the next release.

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


Re: Bug with lists of pairs of lists and append()

2007-09-28 Thread Jason M Barnes
On 9/28/07, Gabriel Zachmann <[EMAIL PROTECTED]> wrote:
> Well,
>
> could some kind soul please explain to me why the following trivial code is
> misbehaving?
>
> #!/usr/bin/python
>
> lst = [ 0, 1, 2 ]
>
> s = []
>
> l = [ lst[0] ]
> r = lst[1:]
> while r:
> x = (l,r)
> print x
> s.append( x )
>
> l.append( r.pop(0) )
>
> print s
>
>
>
> The output I get is:
>
> ([0], [1, 2])
> ([0, 1], [2])
> [([0, 1, 2], []), ([0, 1, 2], [])]
>
> and the error is in the last line: the two pairs in the outer list are
> identical and they should be as the pairs on the first and the 2nd line,
> respectively!
>
> I think I'm going nuts -- for the life of me I don't see what's going on ...
> (I've been tracking down a bug in my larger python script, and the cause
> seems to boil down to the above snippet.)
>
> Thanks a lot in advance for any insights, etc.
>
> Best regards,
> Gabriel.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

If you're familiar with C or C++, think of s as holding a pointer to x
which in turn holds a pointer to l and r, so when you change l or r, x
(and s indirectly) is still pointing to the same lists which by the
end of your loop have changed to r=[] and l=[0,1,2].

BTW:  It's not really "misbehaving."  It's doing exactly what you're
telling it to do ;-)

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


Re: getopt with negative numbers?

2007-09-28 Thread Carl Banks
On Sep 28, 6:19 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
> > A user shouldn't have to go out of their way to specify regular
> > numbers on the command line, regardless of whether they're positive
> > or negative.
>
> A user shouldn't have to go out of their way to know whether what they
> type on a command line will be treated as an option or an argument.

I guess typing

./program --help

is out of the question.



Carl Banks

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


Re: Numeric command-line options vs. negative-number arguments

2007-09-28 Thread Carl Banks
On Sep 28, 9:51 am, Steven Bethard <[EMAIL PROTECTED]> wrote:
> Ben Finney wrote:
> > Steven Bethard <[EMAIL PROTECTED]> writes:
> >> Argparse knows what your option flags look like, so if you specify
> >> one, it knows it's an option.  Argparse will only interpret it as a
> >> negative number if you specify a negative number that doesn't match
> >> a known option.
>
> > That's also irritating, and violates the expected behaviour. It leads
> > to *some* undefined options being flagged as errors, and others
> > interpreted as arguments. The user shouldn't need to know the complete
> > set of options to know which leading-hyphen arguments will be treated
> > as options and which ones won't.
>
> > The correct behaviour would be to *always* interpret an argument that
> > has a leading hyphen as an option (unless it follows an explicit '--'
> > option), and complain if the option is unknown.
>
> It was decided that practicality beats purity here. Arguments with
> leading hyphens which look numeric but aren't in the parser are
> interpreted as negative numbers. Arguments with leading hyphens which
> don't look numeric and aren't in the parser raise errors. Sure, it's not
> the pure answer, but it's the practical answer: "-123" is much more
> likely to be a negative number than an option.

What if (for example) you define a option "-3", and also accept
numerical arguments on the command line.  Then you could get sudden
unexpected behavior if you input the wrong number:

"./hello -1"  works ok.
"./hello -2"  works ok.
"./hello -3"  ... whoops, now the negative number is suddenly an
option.

Granted, it would be stupid for a program to do that, but it suggests
to me that it's probably a good idea to treat all negative numbers the
same.  I.e. if there are any numerical options, then all negative
numbers are treated as options.  If there are none, then negative
numbers are treated as numbers.


Carl Banks

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


Re: Bug with lists of pairs of lists and append()

2007-09-28 Thread Paul Hankin
On Sep 28, 11:25 pm, Gabriel Zachmann <[EMAIL PROTECTED]
clausthal.de> wrote:
> could some kind soul please explain to me why the following trivial code is
> misbehaving?
>
> lst = [ 0, 1, 2 ]
> s = []
> l = [ lst[0] ]
> r = lst[1:]
> while r:
> x = (l,r)
> print x
> s.append( x )
> l.append( r.pop(0) )
> print s

What TeroV said - you need to copy the lists into s otherwise they'll
still mutate when you pop or append to them.
Try putting an extra "print s" after the s.append(x) line, and you'll
find that s changes between there and the final print statement
outside the loop.

Here's code that works:
s, l, r = [], [0], [1, 2]
while r:
x = (list(l), list(r))
print x
s.append(x)
l.append(r.pop(0))
print s

I'm using list(l) to copy the list, Tero uses l[:], but the idea is
the same.

But do you just want all proper partitions of lst? Then this is much
simpler:
lst = [0, 1, 2]
s = [(lst[:i], lst[i:]) for i in range(1, len(lst))]

--
Paul Hankin

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Richard Jones
John Nagle wrote:
>  Insofar as Python has an organization, it's not adequately managing
> extension modules.  Each extension module has its own infrastructure,
> with its own build procedures, its own bug list, and its own maintainers.
> There's not even an archive.  Unlike CPAN, Cheese Shop is just a directory
> of URLs.

Ah, it's not usenet without someone speaking from ignorance! :)


Richard

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


ANN: PyQt v4.3.1 Released

2007-09-28 Thread Phil Thompson
Riverbank Computing is pleased to announce the release of PyQt v4.3.1 
available from http://www.riverbankcomputing.co.uk/pyqt/.

This is mainly a bug fix release.

A Windows installer is provided for the GPL version of PyQt which contains 
everything needed for PyQt development (including Qt, Qt Designer, Qwt, 
QScintilla and the eric IDE) except Python itself.

PyQt is a comprehensive set of Qt bindings for the Python programming language 
and supports the same platforms as Qt (Windows, Linux and MacOS/X).  Like Qt, 
PyQt is available under the GPL and a commercial license.

See http://www.riverbankcomputing.com/Docs/PyQt4/html/classes.html for the 
class documentation.

PyQt v4 supports Qt v4 (http://www.trolltech.com/products/qt/index.html).  
PyQt v3 is still available to support earlier versions of Qt.

PyQt v4 is implemented as a set of 11 extension modules containing 
approximately 400 classes and 6,000 functions and methods.

QtCore
The non-GUI infrastructure including event loops, threads, i18n, Unicode,
signals and slots, user and application settings.

QtGui
A rich collection of GUI widgets.

QtNetwork
A set of classes to support TCP and UDP socket programming and higher
level protocols (eg. HTTP, SSL).

QtOpenGL
A set of classes that allows PyOpenGL to render onto Qt widgets.

QtScript
A set of classes that implements a JavaScript interpreter.

QtSql
A set of classes that implement SQL data models and interfaces to industry
standard databases.  Includes an implementation of SQLite.

QtSvg
A set of classes to render SVG files onto Qt widgets.

QtTest
A set of classes to automate unit testing of PyQt applications and GUIs.

QtXML
A set of classes that implement DOM and SAX parsers.

QtAssistant
A set of classes that enables the Qt Assistant online help browser to be
integrated with an application.

QAxContainer
A set of classes for Windows that allows the integration of ActiveX
controls and COM objects.

PyQt includes the pyuic4 utility which generates Python code to implement user 
interfaces created with Qt Designer in the same way that the uic utility 
generates C++ code.  It is also able to load Designer XML files dynamically.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: your opinion on book "Foundations of Python Network Programming"?

2007-09-28 Thread sean tierney
I just read it (though I bought it half a year ago...don't judge :).

Author recommends Python 2.3 and above...and as far as I know the
examples are good.  And if anything IS outdated -- you'll be able to
do some quick research to get you to where you need to be...and he
does mention code several areas of change/addition/modification. (ie
urllib and urllib2).  He uses a couple of 3rd party projects too.

I really liked the book.  I think Goerzen did a good job.  He
addresses the code in the context of the problem the code is meant to
solve, which I found helpful.  That said, it's not a substitute for
actually reading the code.

...if you haven't read the most recent edition of Programming Python
by Mark Lutz (O'Reilly), I'd recommend that first.  Programming Python
covers (some) networking and everything else.  More bang for the $$.



Sean



On 9/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> i'm debating if i should buy this book. it received good reviews at
> Amazon: http://tinyurl.com/24zvrf. but it was published in 2004 and
> i'm afraid quite some materials might be outdated? any input?
>
> thanks,
>
> kelie
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: marshal bug?

2007-09-28 Thread Martin v. Löwis
> [1] http://coverage.livinglogic.de/Python/marshal.c.html. (Actually, I
> checked the downloaded bz2, but this is the only URL for marshal.c I
> could find)

A better URL is

http://svn.python.org/projects/python/trunk/Python/marshal.c

or

http://svn.python.org/view/python/trunk/Python/marshal.c

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


Bug with lists of pairs of lists and append()

2007-09-28 Thread Gabriel Zachmann
Well,

could some kind soul please explain to me why the following trivial code is
misbehaving?

#!/usr/bin/python

lst = [ 0, 1, 2 ]

s = []

l = [ lst[0] ]
r = lst[1:]
while r:
x = (l,r)
print x
s.append( x )

l.append( r.pop(0) )

print s



The output I get is:

([0], [1, 2])
([0, 1], [2])
[([0, 1, 2], []), ([0, 1, 2], [])]

and the error is in the last line: the two pairs in the outer list are
identical and they should be as the pairs on the first and the 2nd line,
respectively!

I think I'm going nuts -- for the life of me I don't see what's going on ...
(I've been tracking down a bug in my larger python script, and the cause
seems to boil down to the above snippet.)

Thanks a lot in advance for any insights, etc.

Best regards,
Gabriel.

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


Re: Python and SSL

2007-09-28 Thread Martin v. Löwis
> I heard that python 2.6 will include full "server-side SSL
> support" (whatever this means).
> Is it true?

Yes, that's true.

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


Re: Python and SSL

2007-09-28 Thread Martin v. Löwis
> I need to use Python with SSL comunication betweeen servers.
> (I use hhtplib but I think urllib2 can also be used )
>  I think I need to use SSL root certificate and tell  a program to
> trust this certificate.

I don't think so - what the SSL module does is already fine for you.

> But how can I tell my Python program to trust my SSL certificate?

Why do you want to tell it that? The SSL module will trust *any*
server certificate, no need to tell it explicitly which ones to
trust.

> When I tried  before I received the error 503

That must be an independent error.

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


Re: Checking for the existence of Duplicates

2007-09-28 Thread Paul Hankin
On Sep 28, 10:27 pm, AndyB <[EMAIL PROTECTED]> wrote:
> ...
> This is in a program that generates random numbers to do a brute force
> solve on a sudoku-like puzzle.  Once a certain level of difficulty in
> the puzzle is reached, performance goes off a cliff because the
> duplicate checking code, although fast, is executed so many times.

For a sudoku solver, you may be better dodging the problem, and
maintaining a set per row, column and box saying which numbers have
been placed already - and thus avoiding adding duplicates in the first
place. It may be better to use a bitfield instead (ie use bits 1..9 of
an int to represent these sets). You should also check out Donald
Knuth's 'Dancing Links' algorithm as a clever implementation of a
brute-force search that works perfectly for sudoku solving. (It uses
linked lists, but the idea still works in python).

But to answer your actual question:

> I have found a lot of material on removing duplicates from a list, but I
> am trying to find the most efficient way to just check for the existence
> of duplicates in a list.  Here is the best I have come up with so far:
>
>  CheckList = [x[ValIndex] for x in  self.__XRList[z]]
>  FilteredList = filter((lambda x:x != 0),CheckList)
>  if len(FilteredList) > len(sets.Set(FilteredList)): return

In general, the natural way to test for duplicates is as you have it,
except that set is now built-in, so you can write
def has_no_duplicates(x):
return len(x) == len(set(x))

But in your case, you're having to construct the list and filter, so
it's better just to loop and do everything at once:

found = set()
for x in self.__XRList[z]:
cell = x[ValIndex]
if cell != 0 and cell in found:
return False
found.add(cell)

Since your elements are probably numbers 1 to 9 (or 0), you might use
bitfields. I'd expect this to be faster, but you should check:

found = 0
for x in self.__XRList[z]:
cellbit = 1 << x[ValIndex]
if cellbit != 1 and (cellbit & found):
return False
found |= cellbit

--
Paul Hankin

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


Re: getopt with negative numbers?

2007-09-28 Thread Ben Finney
Steven Bethard <[EMAIL PROTECTED]> writes:

> A user shouldn't have to go out of their way to specify regular
> numbers on the command line, regardless of whether they're positive
> or negative.

A user shouldn't have to go out of their way to know whether what they
type on a command line will be treated as an option or an argument.

-- 
 \"When I was crossing the border into Canada, they asked if I |
  `\ had any firearms with me. I said, 'Well, what do you need?'"  |
_o__) -- Steven Wright |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 migration plans?

2007-09-28 Thread Steve Holden
Kay Schluehr wrote:
> On 28 Sep., 17:53, John Nagle <[EMAIL PROTECTED]> wrote:
>> Alex Martelli wrote:
>>> John Nagle <[EMAIL PROTECTED]> wrote:
 TheFlyingDutchman wrote:
> It seems that Python 3 is more significant for what it removes than
> what it adds.
> What are the additions that people find the most compelling?
 I'd rather see Python 2.5 finished, so it just works.
>>> And I'd rather see peace on Earth and goodwill among men than _either_
>>> Python 3 or your cherished "finished" 2.5 -- the comparison and implied
>>> tradeoff make about as much sense as yours.
>>  Insofar as Python has an organization, it's not adequately managing
>> extension modules.  Each extension module has its own infrastructure,
>> with its own build procedures, its own bug list, and its own maintainers.
>> There's not even an archive.  Unlike CPAN, Cheese Shop is just a directory of
>> URLs.
> 
> John, can't you please piss off?
> 
> Thanks, Kay
> 
Oops! Let's get back to goodwill and peace to all men, can we - 
including {Flying Dutch,wo}men?

crabbi-ly y'rs  - steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

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


Re: your opinion on book "Foundations of Python Network Programming"?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 2:59 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> i'm debating if i should buy this book. it received good reviews at
> Amazon:http://tinyurl.com/24zvrf. but it was published in 2004 and
> i'm afraid quite some materials might be outdated? any input?
>
> thanks,
>
> kelie

I have not read this book but just wanted to say, in case you don't
already know, they have Chapter 13 on FTP available as a free download
at the publisher's web site:

http://www.apress.com/book/view/1590593715


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


Re: ANNOUNCE: wxPython 2.8.6.0

2007-09-28 Thread Don Dwiggins
Robin Dunn wrote:
> Announcing
> --
> 
> The 2.8.6.0 release of wxPython is now available for download at
> http://wxpython.org/download.php.  This release is mostly about fixing
> a number of bugs and inconsistencies in wxWidgets and wxPython.

This raises a policy question for me.  I'm currently on 2.8.3, not 
having had any clear need to upgrade for a while.  Is there any reason 
why I shouldn't continue to track the releases, but not upgrade to them 
until I need something specific (a fix for a bug, a new feature I want, 
...)?

For example, if I don't upgrade to 2.8.x.y when it comes out, might I 
have trouble in the future upgrading to 2.8.x+9.w?

BTW, since I haven't said it recently: thanks again for a really useful 
product and support forum for it!

-- 
Don Dwiggins
Advanced Publishing Technology

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


your opinion on book "Foundations of Python Network Programming"?

2007-09-28 Thread [EMAIL PROTECTED]
Hello,

i'm debating if i should buy this book. it received good reviews at
Amazon: http://tinyurl.com/24zvrf. but it was published in 2004 and
i'm afraid quite some materials might be outdated? any input?

thanks,

kelie

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


Re: GUI for viewing/editing python data structures?

2007-09-28 Thread Joshua J. Kugler
On Thursday 27 September 2007 20:20, Paddy wrote:

> On Sep 26, 11:23 pm, "Joshua J. Kugler" <[EMAIL PROTECTED]> wrote:
>> A while back, I seem to remember coming across a small program that could
>> view and edit python data structures via a nice expanding tree view.  I'm
>> now in need of something like that (to verify data is imported correctly
>> into a shelve file) and having a GUI would be much simpler than trying to
>> wade through the output of str(d) or repr(d).
>>
>> I've tried googling with the obvious keywords (gui (view OR edit) python
>> data structures) but t didn't get me anywhere.
>>
> 
> The magic googling phrase is:
>   Python bean-editor
> 
> Which gave http://home.gna.org/oomadness/en/editobj/index.html
> 
> I've never used it. Could you tell me how you get on?
> 
> - Paddy.

Thank you!! This is EXACTLY what I was looking for. Should serve me well. 
For editing shelves, you just have to pull the data out via the key, and
then edit that, since a shelf is not a true dict, just acts like one.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Python 3.0 migration plans?

2007-09-28 Thread Erik Jones

On Sep 28, 2007, at 3:00 PM, TheFlyingDutchman wrote:

> On Sep 28, 12:45 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
>> On Sep 28, 3:29 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
>>
>>> One issue I have with this group and that I encountered many  
>>> years ago
>>> in the Perl group is that there is no separate group
>>> comp.lang.python.beginner where you can ask questions without  
>>> getting
>>> hit with RTFM! and the like.
>>
>> Which shows once again that you're trying to break the world  
>> record of
>> being wrong in as many sentences as possible:
>>
>>http://mail.python.org/mailman/listinfo/tutor
>>
>> You would do yourself (and others) a favor by migrating there for a
>> few weeks or months.
>>
>> George
>
> Being in a land where every nit can be picked, I am surprised that you
> offered up a mailing list when I was asking for a newsgroup.

I'm usually pretty quiet on this list.  That's what I find is the  
best way to participate.  However, I'm going to have to speak up and  
point out that that response is exactly the type of comment and/or  
reasoning that everyone here is trying to explain to you.  The  
resources are available for you to educate yourself.  Semantic  
arguments such as this are, at best, at a junior high level.  You are  
completely free to ask any question (about Python) you want here --  
just don't argue with the people giving you the answers.  And, to  
address the actual content of that response:  nobody, online or off,  
in newsgroups or on mailing lists, likes a nitpick.  So, please,  
quit.  I'd prefer you didn't leave and, instead, decided to actually,  
actively get along with the others here.  I think some of the  
question you've begun threads with have been both good and valid.   
It's just that you need some work on your e-people skills, man.

Erik Jones

Software Developer | Emma®
[EMAIL PROTECTED]
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com


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


Reentrancy of Python interpreter

2007-09-28 Thread Brad Johnson
I have embedded a single threaded instance of the Python interpreter in my
application.

I have a place where I execute a Python command that calls into C++ code which
then in turn calls back into Python using the same interpreter. I get a fatal
error which is "PyThreadStage_Get: no current thread."

I guess I understand why I can't have two invocations of the same interpreter
thread in one call stack, but how would I go about solving this?

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


Checking for the existence of Duplicates

2007-09-28 Thread AndyB
I have found a lot of material on removing duplicates from a list, but I 
am trying to find the most efficient way to just check for the existence 
of duplicates in a list.  Here is the best I have come up with so far:

 CheckList = [x[ValIndex] for x in  self.__XRList[z]]
 FilteredList = filter((lambda x:x != 0),CheckList)
 if len(FilteredList) > len(sets.Set(FilteredList)): return 
False

The first statement pulls the slice out of a matrix I need to check.
The filter statement gets rid of zeroes (they don't count as duplicates).
The if statement is the actual duplicates check

This is in a program that generates random numbers to do a brute force 
solve on a sudoku-like puzzle.  Once a certain level of difficulty in 
the puzzle is reached, performance goes off a cliff because the 
duplicate checking code, although fast, is executed so many times.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List search

2007-09-28 Thread Kevin Walzer
Robert Kern wrote:

> line == 'x11'
> 

D'oh! That was simple, wasn't it? *smacks head*

That did the trick. Thanks!

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and SSL

2007-09-28 Thread Giampaolo Rodolà
I heard that python 2.6 will include full "server-side SSL
support" (whatever this means).
Is it true?

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


Re: Python and SSL

2007-09-28 Thread Heikki Toivonen
Johny wrote:
> I need to use Python with SSL comunication betweeen servers.
> (I use hhtplib but I think urllib2 can also be used )
>  I think I need to use SSL root certificate and tell  a program to
> trust this certificate.

You can't do secure SSL with the builtin SSL support, you need to use a
third party module. There are a few available, including M2Crypto, TLS
Lite, pyOpenSSL and pyOpenSSL-extended. Since I am the maintainer of
M2Crypto I will naturally recommend that ;)

http://chandlerproject.org/Projects/MeTooCrypto

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 1:09 pm, Steve Holden <[EMAIL PROTECTED]> wrote:

> That's because the tutor list doesn't offer a newsgroup. He was probably
> just trying to get rid of you.
>
> Now at 98.75% ...

Not sure if that's the reading on your trollmeter or on the meter that
measures what percentage of your posts you get huffy.

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


Re: List search

2007-09-28 Thread Tim Williams
On 28/09/2007, Kevin Walzer <[EMAIL PROTECTED]> wrote:
> I'm having a problem with searching a list. Here's my code:
>
> mylist = ['x11', 'x11-wm', 'x11-system']
>
> for line in mylist:
>if 'x11' in line:
>print line
>
> This results in the following output:
>
> x11
> x11-wm
> x11-system
>

That output is correct,  you are asking your script to print any list
item containing x11 when what you actually wanted was a list item that
is the string 'x11'

mylist = ['x11', 'x11-wm', 'x11-system']
for item in mylist:
  if item ==  'x11':
   print line

If there is only ever one 'x11' in the list you could also consider

print mylist.index('x11')

and

print mylist[mylist.index('x11')]

Also, before iterating the whole list check that 'x11' exists

if 'x11' in mylist:
do stuff

and list comprehesions

print [x for x in mylist if x == 'x11']

HTH :)

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


Re: List search

2007-09-28 Thread Robert Kern
Kevin Walzer wrote:
> I'm having a problem with searching a list. Here's my code:
> 
> mylist = ['x11', 'x11-wm', 'x11-system']
> 
> for line in mylist:
>   if 'x11' in line:
>   print line
> 
> This results in the following output:
> 
> x11
> x11-wm
> x11-system
> 
> I'm looking to return the list item that just has 'x11'.  How can I 
> structure my search term so that this output is returned?

line == 'x11'

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Colin J. Williams
TheFlyingDutchman wrote:
>> Or bind resources of these pocket protectors that otherwise would lead to
>> answers for people that do seek enlightment...
> 
> I don't think it would be correct to characterize my posts as not
> seeking enlightenment. I do also happen to voice my opinion which
> seems appropriate since this can be characterized as a discussion
> group. It theoretically is possible for a discussion group to tolerate
> opinions that diverge from the majority.
+1
> 
> One issue I have with this group and that I encountered many years ago
> in the Perl group is that there is no separate group
> comp.lang.python.beginner where you can ask questions without getting
> hit with RTFM! and the like.
> 

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Kay Schluehr
On 28 Sep., 17:53, John Nagle <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
> > John Nagle <[EMAIL PROTECTED]> wrote:
>
> >> TheFlyingDutchman wrote:
> >>> It seems that Python 3 is more significant for what it removes than
> >>> what it adds.
>
> >>> What are the additions that people find the most compelling?
> >> I'd rather see Python 2.5 finished, so it just works.
>
> > And I'd rather see peace on Earth and goodwill among men than _either_
> > Python 3 or your cherished "finished" 2.5 -- the comparison and implied
> > tradeoff make about as much sense as yours.
>
>  Insofar as Python has an organization, it's not adequately managing
> extension modules.  Each extension module has its own infrastructure,
> with its own build procedures, its own bug list, and its own maintainers.
> There's not even an archive.  Unlike CPAN, Cheese Shop is just a directory of
> URLs.

John, can't you please piss off?

Thanks, Kay

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


Re: List search

2007-09-28 Thread Stefan Bellon
On Fri, 28 Sep, Kevin Walzer wrote:

> I'm having a problem with searching a list. Here's my code:
> 
> mylist = ['x11', 'x11-wm', 'x11-system']
> 
> for line in mylist:
>   if 'x11' in line:
>   print line

Just compare for equality:

   if line == 'x11':

or

print "\n".join(x for x in mylist if x == 'x11')

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Colin J. Williams
Steve Holden wrote:
> TheFlyingDutchman wrote:
>> On Sep 28, 10:01 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>>> On Fri, 28 Sep 2007 09:42:49 -0700, TheFlyingDutchman wrote:
 Which of the common languages have higher order functions and what is
 the syntax?
>>> C, C++, Pascal, Perl, PHP, Ruby have them.  And of course the functional
>>> languages, most notably Lisp and Scheme as you asked for common languages.
>>>
>>> Don't know if C#'s delegates qualify.
>>>
>>> Ciao,
>>> Marc 'BlackJack' Rintsch
>> What is the syntax of a higher order function in C, C++ and Pascal?
>>
> This is like listening to a four-year-old torment its parents with 
> incessant questions. Do you *have* to ask every question that pops into 
> your mind?
> 
> regards
>   Steve
Tut Tut!

A reasonable question is being asked.

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


List search

2007-09-28 Thread Kevin Walzer
I'm having a problem with searching a list. Here's my code:

mylist = ['x11', 'x11-wm', 'x11-system']

for line in mylist:
if 'x11' in line:
print line

This results in the following output:

x11
x11-wm
x11-system

I'm looking to return the list item that just has 'x11'.  How can I 
structure my search term so that this output is returned?
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: OCBC connection

2007-09-28 Thread Sugrue, Sean
I want to connect on the windows side to a solaris server which has a
postgres database installed.
I can connect to the postgres database using the postgres odbc
connection but I'm using excel. 
I'd rather use python because it ports easily over to solaris. I will
install psycopg2 and try the code 
that was sent.

Thanks
Sean  

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Steve Holden
Sent: Friday, September 28, 2007 4:04 PM
To: python-list@python.org
Subject: Re: OCBC connection

[EMAIL PROTECTED] wrote:
[...]
>>
>>  >>> curs = conn.cursor()
>>  >>> import psycopg2 as db
>>  >>> conn = db.connect(database="pycon", user="username",
>>  password="password", host="localhost", port=5432)  >>> curs 
>> = conn.cursor()  >>> curs.execute("SELECT orgid, orgname FROM 
>> organization")  >>> from pprint import pprint # just for neatness  
>> >>> pprint(curs.fetchall()) [(1, 'AB Strakt'),
>>   (79, 'DevIS'),
>>  ...
>>   (113, 'Test Organization'),
>>   (19, 'Holden Web LLC')]
>>  >>>

> Whoops! I almost posted some code using the adodb or the odbc module, 
> which is what I would have probably used, but I figured I'd take a 
> look and see if there was a postgres module available. I'm not seeing 
> any basic differences between your code and the code I linked to 
> though...except that if I ran your first line of code, I would get an 
> exception as "conn" hasn't been defined yet.
> 
> Whatever. I apologize for being misleading(?)
> 
I screwed up anyway - the first line shouldn't have been included.

But perhaps Sean could enlighten us as to whether ODBC is really a
requirement, or simply the first solution that he thought of. I don't
know why one would *require* ODBC.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 12:34 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> TheFlyingDutchman wrote:
>
> >> Or bind resources of these pocket protectors that otherwise would lead to
> >> answers for people that do seek enlightment...
>
> > I don't think it would be correct to characterize my posts as not
> > seeking enlightenment. I do also happen to voice my opinion which
> > seems appropriate since this can be characterized as a discussion
> > group. It theoretically is possible for a discussion group to tolerate
> > opinions that diverge from the majority.
>
> I would characterize
>
> """
> I like how someone here characterized decorators - those silly @
> things. They remind me of Perl. Not adding keywords for abstract and
> static is like Perl not adding a keyword for class.
> """
>
> not as seeking enlightenment, but as pure trolling. Disqualifying features
> without actually understanding them as "silly" certainly doesn't lie on one
> of the many path's to enlightenment known man - which to my knowledge
> usually require more humble approaches

Some posts seek enlightenment, some voice opinions. Opinions aren't
always voiced humbly. I don't think you will have to look far for
examples of people other than myself not expressing opinions humbly.

>
> > One issue I have with this group and that I encountered many years ago
> > in the Perl group is that there is no separate group
> > comp.lang.python.beginner where you can ask questions without getting
> > hit with RTFM! and the like.
>
> And I wish people that have no clue about the deeper workings of Python
> wouldn't insist on commenting on these in inappropriate ways as above, but
> instead try and _understand_ them before debunking them or suggesting
> changes.
>

I will grant you that "silly" is too strong a word to use in a group
of ardent users but I think it should be completely valid to gripe
about the syntax at least once.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Carsten Haese
On Fri, 2007-09-28 at 13:00 -0700, TheFlyingDutchman wrote:
> Being in a land where every nit can be picked, I am surprised that you
> offered up a mailing list when I was asking for a newsgroup.

nntp://news.gmane.org/gmane.comp.python.tutor

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: Python 3.0 migration plans?

2007-09-28 Thread Steve Holden
TheFlyingDutchman wrote:
> On Sep 28, 12:45 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
>> On Sep 28, 3:29 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
>>
>>> One issue I have with this group and that I encountered many years ago
>>> in the Perl group is that there is no separate group
>>> comp.lang.python.beginner where you can ask questions without getting
>>> hit with RTFM! and the like.
>> Which shows once again that you're trying to break the world record of
>> being wrong in as many sentences as possible:
>>
>>http://mail.python.org/mailman/listinfo/tutor
>>
>> You would do yourself (and others) a favor by migrating there for a
>> few weeks or months.
>>
>> George
> 
> Being in a land where every nit can be picked, I am surprised that you
> offered up a mailing list when I was asking for a newsgroup.
> 
That's because the tutor list doesn't offer a newsgroup. He was probably 
just trying to get rid of you.

Now at 98.75% ...

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

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


Re: Python 3.0 migration plans?

2007-09-28 Thread George Sakkis
On Sep 28, 11:53 am, John Nagle <[EMAIL PROTECTED]> wrote:

> Alex Martelli wrote:
> > John Nagle <[EMAIL PROTECTED]> wrote:
>
> >> TheFlyingDutchman wrote:
> >>> It seems that Python 3 is more significant for what it removes than
> >>> what it adds.
>
> >>> What are the additions that people find the most compelling?
> >> I'd rather see Python 2.5 finished, so it just works.
>
> > And I'd rather see peace on Earth and goodwill among men than _either_
> > Python 3 or your cherished "finished" 2.5 -- the comparison and implied
> > tradeoff make about as much sense as yours.
>
>  Insofar as Python has an organization, it's not adequately managing
> extension modules.  Each extension module has its own infrastructure,
> with its own build procedures, its own bug list, and its own maintainers.
> There's not even an archive.  Unlike CPAN, Cheese Shop is just a directory of
> URLs.
>
>  Take a look at how Perl does it.  Here are the instructions on
> how to contribute to CPAN:
>
>http://www.cpan.org/modules/04pause.html
>
> There's a way to get your module into the system, a standardized format,
> build, and installation procedure, and an archive which is mirrored.
> There's a common bug reporting system.  Modules abandoned by their
> original developers are not lost, and can be "adopted" by someone else.
>
>  Python doesn't have any of this.  And that's far more of a problem
> than Python 3.x.

Does Perl support extension modules, and if so, are they so prevalent
as in Python ? Either case, bringing up CPAN is moot in this case;
nothing can force an external open source contributor to maintain or
provide binaries for his packages. How is this a problem of the
*language* ?

George

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


Re: OCBC connection

2007-09-28 Thread Steve Holden
[EMAIL PROTECTED] wrote:
[...]
>>
>>  >>> curs = conn.cursor()
>>  >>> import psycopg2 as db
>>  >>> conn = db.connect(database="pycon", user="username",
>>  password="password", host="localhost", port=5432)
>>  >>> curs = conn.cursor()
>>  >>> curs.execute("SELECT orgid, orgname FROM organization")
>>  >>> from pprint import pprint # just for neatness
>>  >>> pprint(curs.fetchall())
>> [(1, 'AB Strakt'),
>>   (79, 'DevIS'),
>>  ...
>>   (113, 'Test Organization'),
>>   (19, 'Holden Web LLC')]
>>  >>>

> Whoops! I almost posted some code using the adodb or the odbc module,
> which is what I would have probably used, but I figured I'd take a
> look and see if there was a postgres module available. I'm not seeing
> any basic differences between your code and the code I linked to
> though...except that if I ran your first line of code, I would get an
> exception as "conn" hasn't been defined yet.
> 
> Whatever. I apologize for being misleading(?)
> 
I screwed up anyway - the first line shouldn't have been included.

But perhaps Sean could enlighten us as to whether ODBC is really a 
requirement, or simply the first solution that he thought of. I don't 
know why one would *require* ODBC.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 12:45 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Sep 28, 3:29 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
>
> > One issue I have with this group and that I encountered many years ago
> > in the Perl group is that there is no separate group
> > comp.lang.python.beginner where you can ask questions without getting
> > hit with RTFM! and the like.
>
> Which shows once again that you're trying to break the world record of
> being wrong in as many sentences as possible:
>
>http://mail.python.org/mailman/listinfo/tutor
>
> You would do yourself (and others) a favor by migrating there for a
> few weeks or months.
>
> George

Being in a land where every nit can be picked, I am surprised that you
offered up a mailing list when I was asking for a newsgroup.

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


Re: C Source Code Generator For Test Cases

2007-09-28 Thread gamename
>
> How about using c-types to access your C-stuff to test, and use python + the
> testcase-tables to invoke that?
>

Sure, that's possible.  But the source code for tests (once all the
parms are read)
still needs to be generated.  Calling the lib from python or from C,
there still
needs to be a way to generate 100+ test routines. ;-)

-T

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


Re: Bug with lists of pairs of lists and append()

2007-09-28 Thread TeroV
Gabriel Zachmann wrote:
> Well,
> 
> could some kind soul please explain to me why the following trivial code 
> is misbehaving?
> 
> 
> #!/usr/bin/python
> s = []
> l = [ 0 ]
> r = [0, 0]
> while r:
> x = (l,r)
> print x
> s.append( x )
> l.append( r.pop(0) )
> print s
> 
> 
> 
> The output I get is:
> 
> ([0], [0, 0])
> ([0, 0], [0])
> [([0, 0, 0], []), ([0, 0, 0], [])]
> 
> and the error is in the last line: the two pairs in the outer list are 
> identical and they should be equal to the pairs one the first and the 
> 2nd line, respectively! Shouldn't they?
> 
> I think I'm going nuts -- for the life of me I don't see what's going on 
> ...
> 
> Thanks a lot in advance for any insights, etc.
> 
> Best regards,
> Gabriel.

You didn't say what it is supposed to do.
But, does replacing line "x = (l, r)" with "x = l[:], r[:]" do the trick?

In the original code you do basically the same as this
 >>> a = []
 >>> b = [1,2]
 >>> a.append(b)
 >>> b.append(3)
 >>> a
[[1, 2, 3]]

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Steve Holden
George Sakkis wrote:
> On Sep 28, 3:29 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> 
>> One issue I have with this group and that I encountered many years ago
>> in the Perl group is that there is no separate group
>> comp.lang.python.beginner where you can ask questions without getting
>> hit with RTFM! and the like.
> 
> Which shows once again that you're trying to break the world record of
> being wrong in as many sentences as possible:
> 
> http://mail.python.org/mailman/listinfo/tutor
> 
> You would do yourself (and others) a favor by migrating there for a
> few weeks or months.
> 
> George
> 
Hopefully with a side dish of alt.attitude.adjustment.

It's not that we don't want you. it's just that you don't seem to 
realize how annoying you can be.

n the other hand, if you *do* realize how annoying you can be then 
please leave now and never come back ;-)

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OCBC connection

2007-09-28 Thread kyosohma
On Sep 28, 1:07 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Sep 28, 9:57 am, "Sugrue, Sean" <[EMAIL PROTECTED]> wrote:
> >> I'm trying to make an odbc connection to postgresql which is on a server
> >> using python.
> >> Does anyone have a code snippet to make a basic connection with a select
> >> query?
>
> >> Sean
>
> > Sean,
>
> > This appears to be what you're looking for:
>
> >http://www.devx.com/opensource/Article/29071
>
> > See also Python Database spec and module page:
>
> >http://www.python.org/topics/database/
>
> Mike:
>
> This doesn't address the ODBC part of the inquiry. I was actually going
> to respond saying I wasn't aware of an ODBC driver for PostgreSQL
> (though I'd be surprised if there wasn't one).
>
> Using the psycopg2 module, which is my preferred PostgreSQL interface
> module, it's easy to answer:
>
>  >>> curs = conn.cursor()
>  >>> import psycopg2 as db
>  >>> conn = db.connect(database="pycon", user="username",
>  password="password", host="localhost", port=5432)
>  >>> curs = conn.cursor()
>  >>> curs.execute("SELECT orgid, orgname FROM organization")
>  >>> from pprint import pprint # just for neatness
>  >>> pprint(curs.fetchall())
> [(1, 'AB Strakt'),
>   (79, 'DevIS'),
>  ...
>   (113, 'Test Organization'),
>   (19, 'Holden Web LLC')]
>  >>>
>
> regards
>   Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd  http://www.holdenweb.com
> Skype: holdenweb  http://del.icio.us/steve.holden
>
> Sorry, the dog ate my .sigline

Whoops! I almost posted some code using the adodb or the odbc module,
which is what I would have probably used, but I figured I'd take a
look and see if there was a postgres module available. I'm not seeing
any basic differences between your code and the code I linked to
though...except that if I ran your first line of code, I would get an
exception as "conn" hasn't been defined yet.

Whatever. I apologize for being misleading(?)

Mike

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


Re: Python 3.0 migration plans?

2007-09-28 Thread George Sakkis
On Sep 28, 3:29 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:

> One issue I have with this group and that I encountered many years ago
> in the Perl group is that there is no separate group
> comp.lang.python.beginner where you can ask questions without getting
> hit with RTFM! and the like.

Which shows once again that you're trying to break the world record of
being wrong in as many sentences as possible:

http://mail.python.org/mailman/listinfo/tutor

You would do yourself (and others) a favor by migrating there for a
few weeks or months.

George

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


Re: GUI for viewing/editing python data structures?

2007-09-28 Thread Joshua J. Kugler
On Thursday 27 September 2007 22:40, David wrote:

> On 9/27/07, Joshua J. Kugler <[EMAIL PROTECTED]> wrote:
>> A while back, I seem to remember coming across a small program that could
>> view and edit python data structures via a nice expanding tree view.  I'm
>> now in need of something like that (to verify data is imported correctly
>> into a shelve file) and having a GUI would be much simpler than trying to
>> wade through the output of str(d) or repr(d).
>>
>> I've tried googling with the obvious keywords (gui (view OR edit) python
>> data structures) but t didn't get me anywhere.
>>
>> Pointers?
>>
> 
> non-gui alternatives: Try pprint module. Or output as yaml (external
> library) into a text file. You could also output as XML (using
> built-in python modules), save to file and then use Firefox or another
> XML gui to inspect it. I haven't done the latter before but it should
> work.

I may give those a try.  I was also looking at the editing aspect too.  But
that's a good start.

Thanks.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Python 3.0 migration plans?

2007-09-28 Thread Diez B. Roggisch
TheFlyingDutchman wrote:

> 
>>
>> Or bind resources of these pocket protectors that otherwise would lead to
>> answers for people that do seek enlightment...
> 
> I don't think it would be correct to characterize my posts as not
> seeking enlightenment. I do also happen to voice my opinion which
> seems appropriate since this can be characterized as a discussion
> group. It theoretically is possible for a discussion group to tolerate
> opinions that diverge from the majority.

I would characterize

"""
I like how someone here characterized decorators - those silly @
things. They remind me of Perl. Not adding keywords for abstract and
static is like Perl not adding a keyword for class.
"""

not as seeking enlightenment, but as pure trolling. Disqualifying features
without actually understanding them as "silly" certainly doesn't lie on one
of the many path's to enlightenment known man - which to my knowledge
usually require more humble approaches

> One issue I have with this group and that I encountered many years ago
> in the Perl group is that there is no separate group
> comp.lang.python.beginner where you can ask questions without getting
> hit with RTFM! and the like.

And I wish people that have no clue about the deeper workings of Python
wouldn't insist on commenting on these in inappropriate ways as above, but
instead try and _understand_ them before debuking them or suggesting
changes.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman

>
> Or bind resources of these pocket protectors that otherwise would lead to
> answers for people that do seek enlightment...

I don't think it would be correct to characterize my posts as not
seeking enlightenment. I do also happen to voice my opinion which
seems appropriate since this can be characterized as a discussion
group. It theoretically is possible for a discussion group to tolerate
opinions that diverge from the majority.

One issue I have with this group and that I encountered many years ago
in the Perl group is that there is no separate group
comp.lang.python.beginner where you can ask questions without getting
hit with RTFM! and the like.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Steve Holden
TheFlyingDutchman wrote:
> On Sep 28, 11:16 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>> On Fri, 28 Sep 2007 11:04:39 -0700, TheFlyingDutchman <[EMAIL PROTECTED]> 
>> wrote:
>>> [snip]
>>> In this case I asked it as part of the original question and it was
>>> ignored. I have programmed in C and C++ and a little Pascal many years
>>> ago. I don't remember anything about Higher Order Functions and would
>>> like to see exactly how you do it and to verify the contention.
>> Perhaps you could do a bit of independent research.  Then your messages
>> to the group could contain more thoughtful questions and responses.
>>
> But you miss the fact that I am providing value to the group by
> providing unthoughtful questions and unthoughtful responses. By having
> most of the pocket protectors being thrown at me, I provide a
> diversion that allows others to speak more freely and without fear of
> reproach.
> 
> 
It's the knives and hand grenades you want to worry about. We are a very 
friendly and welcoming group, but we do have our limits. You're fast 
approaching 100% on my trollometer.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Diez B. Roggisch
TheFlyingDutchman wrote:

> On Sep 28, 11:16 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>> On Fri, 28 Sep 2007 11:04:39 -0700, TheFlyingDutchman <[EMAIL PROTECTED]>
>> wrote:
>> > [snip]
>>
>> >In this case I asked it as part of the original question and it was
>> >ignored. I have programmed in C and C++ and a little Pascal many years
>> >ago. I don't remember anything about Higher Order Functions and would
>> >like to see exactly how you do it and to verify the contention.
>>
>> Perhaps you could do a bit of independent research.  Then your messages
>> to the group could contain more thoughtful questions and responses.
>>
> But you miss the fact that I am providing value to the group by
> providing unthoughtful questions and unthoughtful responses. By having
> most of the pocket protectors being thrown at me, I provide a
> diversion that allows others to speak more freely and without fear of
> reproach.

Or bind resources of these pocket protectors that otherwise would lead to
answers for people that do seek enlightment...

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


Re: C Source Code Generator For Test Cases

2007-09-28 Thread Diez B. Roggisch
gamename wrote:

> Hi,
> 
> Can anyone recommend a good method of using python to generate c
> source code?   I have tables of test cases to use as input to a
> process which would generate the test's source code.  The Cheetah tool
> looks interesting.  Has anyone used it? Any other suggestions?

How about using c-types to access your C-stuff to test, and use python + the
testcase-tables to invoke that?

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


Bug with lists of pairs of lists and append()

2007-09-28 Thread Gabriel Zachmann
Well,

could some kind soul please explain to me why the following trivial code 
is misbehaving?


#!/usr/bin/python
s = []
l = [ 0 ]
r = [0, 0]
while r:
x = (l,r)
print x
s.append( x )
l.append( r.pop(0) )
print s



The output I get is:

([0], [0, 0])
([0, 0], [0])
[([0, 0, 0], []), ([0, 0, 0], [])]

and the error is in the last line: the two pairs in the outer list are 
identical and they should be equal to the pairs one the first and the 
2nd line, respectively! Shouldn't they?

I think I'm going nuts -- for the life of me I don't see what's going on ...

Thanks a lot in advance for any insights, etc.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 11:16 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Fri, 28 Sep 2007 11:04:39 -0700, TheFlyingDutchman <[EMAIL PROTECTED]> 
> wrote:
> > [snip]
>
> >In this case I asked it as part of the original question and it was
> >ignored. I have programmed in C and C++ and a little Pascal many years
> >ago. I don't remember anything about Higher Order Functions and would
> >like to see exactly how you do it and to verify the contention.
>
> Perhaps you could do a bit of independent research.  Then your messages
> to the group could contain more thoughtful questions and responses.
>
But you miss the fact that I am providing value to the group by
providing unthoughtful questions and unthoughtful responses. By having
most of the pocket protectors being thrown at me, I provide a
diversion that allows others to speak more freely and without fear of
reproach.


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


Re: OCBC connection

2007-09-28 Thread M.-A. Lemburg
On 2007-09-28 20:07, Steve Holden wrote:
> [EMAIL PROTECTED] wrote:
>> On Sep 28, 9:57 am, "Sugrue, Sean" <[EMAIL PROTECTED]> wrote:
>>> I'm trying to make an odbc connection to postgresql which is on a server
>>> using python.
>>> Does anyone have a code snippet to make a basic connection with a select
>>> query?
>>>
>>> Sean
>> Sean,
>>
>> This appears to be what you're looking for:
>>
>> http://www.devx.com/opensource/Article/29071
>>
>> See also Python Database spec and module page:
>>
>> http://www.python.org/topics/database/
>>
> Mike:
> 
> This doesn't address the ODBC part of the inquiry. I was actually going 
> to respond saying I wasn't aware of an ODBC driver for PostgreSQL 
> (though I'd be surprised if there wasn't one).

There is one:

http://www.postgresql.org/ftp/odbc/versions/

and it works quite well with mxODBC on all supported platforms.

Here's a step-by-step guide for the Windows installation:

http://www.sparxsystems.com/EAUserGuide/setupapostgresqlodbcdriver.htm

Note that you should add these settings to your odbc.ini
section for the PostgreSQL data source in order to avoid
problems with BLOBs:

# Fetch BYTEA and TEXT as LongVarXXX column types:
ByteaAsLongVarBinary = 1
TextAsLongVarchar = 1

Alternatively, you can try the OpenLink driver:

http://uda.openlinksw.com/odbc/st/odbc-postgres-st/

If you're on Max OS, you should have a look at the ActualTech
drivers:

http://www.actualtechnologies.com/product_opensourcedatabases.php

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 28 2007)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 11:21 am, "Francesco Guerrieri" <[EMAIL PROTECTED]>
wrote:
> On 9/28/07, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
>
> > On Sep 28, 10:57 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> > > This is like listening to a four-year-old torment its parents with
> > > incessant questions. Do you *have* to ask every question that pops into
> > > your mind?
>
> > In this case I asked it as part of the original question and it was
> > ignored. I have programmed in C and C++ and a little Pascal many years
> > ago. I don't remember anything about Higher Order Functions and would
> > like to see exactly how you do it and to verify the contention.
>
> You could just google for it. Just in case your connection to google
> or other similar search engines has been disabled for some reason,
> here are some links.
>
> Try for instance
>
> http://okmij.org/ftp/c++-digest/Lambda-CPP-more.html#Ex3
>
> or
>
> http://www.cc.gatech.edu/~yannis/fc++/
>
> or
>
> http://www.boost.org/libs/mpl/doc/tutorial/higher-order.html
>
Correct me if I am wrong, but none of those examples showed something
in C++ similar to a decorator in Python - that is, unique syntax in
the language for implementing a Higher Order Function. One thing I
will say about those examples is that they make Python decorators look
sweet!

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 11:16 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Fri, 28 Sep 2007 11:04:39 -0700, TheFlyingDutchman <[EMAIL PROTECTED]> 
> wrote:
> > [snip]
>
> >In this case I asked it as part of the original question and it was
> >ignored. I have programmed in C and C++ and a little Pascal many years
> >ago. I don't remember anything about Higher Order Functions and would
> >like to see exactly how you do it and to verify the contention.
>
> Perhaps you could do a bit of independent research.  Then your messages
> to the group could contain more thoughtful questions and responses.
>
But you miss the fact that I am providing value to the group by
providing unthoughtful questions and unthoughtful responses. By having
most of the pocket protectors being thrown at me, I provide a
diversion that allows others to speak more freely and without fear of
reproach.


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


Re: Python 3.0 migration plans?

2007-09-28 Thread Francesco Guerrieri
On 9/28/07, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> On Sep 28, 10:57 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> > This is like listening to a four-year-old torment its parents with
> > incessant questions. Do you *have* to ask every question that pops into
> > your mind?
> >
>
> In this case I asked it as part of the original question and it was
> ignored. I have programmed in C and C++ and a little Pascal many years
> ago. I don't remember anything about Higher Order Functions and would
> like to see exactly how you do it and to verify the contention.


You could just google for it. Just in case your connection to google
or other similar search engines has been disabled for some reason,
here are some links.

Try for instance

http://okmij.org/ftp/c++-digest/Lambda-CPP-more.html#Ex3

or

http://www.cc.gatech.edu/~yannis/fc++/

or

http://www.boost.org/libs/mpl/doc/tutorial/higher-order.html

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Paul Rubin
TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> What is the syntax of a higher order function in C, C++ and Pascal?

  void qsort(int *array, int length, int width, int (*compare)());

is a C library example.  I think we'd describe qsort as a HOF since
one of its arguments (the comparison routine) is a function.  We
wouldn't say that C has first class functions like Python or Scheme
does, since you can't create new functions at runtime.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Zope] how do I test for the current item in an iteration

2007-09-28 Thread Dieter Maurer
kamal hamzat wrote at 2007-9-28 16:36 +0100:
>I have this error after i added the if statement
>
>Error Type: TypeError
>Error Value: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a 'int'
>
>
>for i in context.zCatNewsCurrent():
> if i <= 5:  
>print "%s: %s: %s" % (i.id, i.author, i.summary)

You are aware that you use "i" both as an integer ("i <= 5")
as well as a structure ("i.id", "i.author", ...).

Python is quite polymorph -- but there are some limits.

Andreas suggestion was good: "enumerate" may help you...



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


Re: Python 3.0 migration plans?

2007-09-28 Thread Jean-Paul Calderone
On Fri, 28 Sep 2007 11:04:39 -0700, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> [snip]
>
>In this case I asked it as part of the original question and it was
>ignored. I have programmed in C and C++ and a little Pascal many years
>ago. I don't remember anything about Higher Order Functions and would
>like to see exactly how you do it and to verify the contention.
>

Perhaps you could do a bit of independent research.  Then your messages
to the group could contain more thoughtful questions and responses.

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


Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread irstas
On Sep 28, 8:30 pm, xkenneth <[EMAIL PROTECTED]> wrote:
> Looking to do something similair. I'm working with alot of timestamps
> and if they're within a couple seconds I need them to be indexed and
> removed from a list.
> Is there any possible way to index with a custom cmp() function?
>
> I assume it would be something like...
>
> list.index(something,mycmp)
>
> Thanks!

Wouldn't it be enough to get the items that are "within a couple of
seconds" out of the list and into another list. Then you can process
the other list however you want. Like this:

 def isNew(x):
 return x < 5

 data = range(20)
 print data
 out, data = filter(isNew, data), filter(lambda x: not isNew(x), data)
 print out, data

Why do you want to use 'index'?

Your suggestion "list.index.__cmp__ = mycmp" certainly doesn't do
anything good. In fact, it just fails because the assignment is
illegal.. I don't think any documentation suggests doing that, so why
are you even trying to do that? It's just not a good idea to invent
semantics and hope that they work, in general.

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


Re: OCBC connection

2007-09-28 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> On Sep 28, 9:57 am, "Sugrue, Sean" <[EMAIL PROTECTED]> wrote:
>> I'm trying to make an odbc connection to postgresql which is on a server
>> using python.
>> Does anyone have a code snippet to make a basic connection with a select
>> query?
>>
>> Sean
> 
> Sean,
> 
> This appears to be what you're looking for:
> 
> http://www.devx.com/opensource/Article/29071
> 
> See also Python Database spec and module page:
> 
> http://www.python.org/topics/database/
> 
Mike:

This doesn't address the ODBC part of the inquiry. I was actually going 
to respond saying I wasn't aware of an ODBC driver for PostgreSQL 
(though I'd be surprised if there wasn't one).

Using the psycopg2 module, which is my preferred PostgreSQL interface 
module, it's easy to answer:

 >>> curs = conn.cursor()
 >>> import psycopg2 as db
 >>> conn = db.connect(database="pycon", user="username",
 password="password", host="localhost", port=5432)
 >>> curs = conn.cursor()
 >>> curs.execute("SELECT orgid, orgname FROM organization")
 >>> from pprint import pprint # just for neatness
 >>> pprint(curs.fetchall())
[(1, 'AB Strakt'),
  (79, 'DevIS'),
 ...
  (113, 'Test Organization'),
  (19, 'Holden Web LLC')]
 >>>

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 10:57 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> TheFlyingDutchman wrote:
> > On Sep 28, 10:01 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> >> On Fri, 28 Sep 2007 09:42:49 -0700, TheFlyingDutchman wrote:
> >>> Which of the common languages have higher order functions and what is
> >>> the syntax?
> >> C, C++, Pascal, Perl, PHP, Ruby have them.  And of course the functional
> >> languages, most notably Lisp and Scheme as you asked for common languages.
>
> >> Don't know if C#'s delegates qualify.
>
> >> Ciao,
> >> Marc 'BlackJack' Rintsch
>
> > What is the syntax of a higher order function in C, C++ and Pascal?
>
> This is like listening to a four-year-old torment its parents with
> incessant questions. Do you *have* to ask every question that pops into
> your mind?
>

In this case I asked it as part of the original question and it was
ignored. I have programmed in C and C++ and a little Pascal many years
ago. I don't remember anything about Higher Order Functions and would
like to see exactly how you do it and to verify the contention.


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


Re: Python 3.0 migration plans?

2007-09-28 Thread Steve Holden
TheFlyingDutchman wrote:
> On Sep 28, 10:01 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Fri, 28 Sep 2007 09:42:49 -0700, TheFlyingDutchman wrote:
>>> Which of the common languages have higher order functions and what is
>>> the syntax?
>> C, C++, Pascal, Perl, PHP, Ruby have them.  And of course the functional
>> languages, most notably Lisp and Scheme as you asked for common languages.
>>
>> Don't know if C#'s delegates qualify.
>>
>> Ciao,
>> Marc 'BlackJack' Rintsch
> 
> What is the syntax of a higher order function in C, C++ and Pascal?
> 
This is like listening to a four-year-old torment its parents with 
incessant questions. Do you *have* to ask every question that pops into 
your mind?

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline
-- 
http://mail.python.org/mailman/listinfo/python-list


C Source Code Generator For Test Cases

2007-09-28 Thread gamename
Hi,

Can anyone recommend a good method of using python to generate c
source code?   I have tables of test cases to use as input to a
process which would generate the test's source code.  The Cheetah tool
looks interesting.  Has anyone used it? Any other suggestions?

TIA,
-T

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


Re: getopt with negative numbers?

2007-09-28 Thread Steven Bethard
Casey wrote:
> Ben Finney wrote:
>> I believe they shouldn't because the established interface is that a
>> hyphen always introduced an option unless (for those programs that
>> support it) a '--' option is used, as discussed.
>
> Not "THE" established interface; "AN" established interface.  There
> are other established interfaces that have different behaviors. I'm a
> pragmatist; I write software for users, not techies.  I suspect most
> users would expect a command like "abc -a -921 351 175" to treat the
> "-921" as a negative integer and not abort the program with some
> obscure error about option 921 not being known.

Glad I'm not alone in this. ;-) A user shouldn't have to go out of their 
way to specify regular numbers on the command line, regardless of 
whether they're positive or negative.

STeVe

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


Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread xkenneth
On Sep 28, 12:30 pm, xkenneth <[EMAIL PROTECTED]> wrote:
> Looking to do something similair. I'm working with alot of timestamps
> and if they're within a couple seconds I need them to be indexed and
> removed from a list.
> Is there any possible way to index with a custom cmp() function?
>
> I assume it would be something like...
>
> list.index(something,mycmp)
>
> Thanks!

or can i just say

list.index.__cmp__ = mycmp

and do it that way? I just want to make sure I'm not doing anything
evil.

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


Re: FW: OCBC connection

2007-09-28 Thread M.-A. Lemburg
On 2007-09-28 19:22, Sugrue, Sean wrote:
> Is this the right email list to be on for asking rather elementary
> python questions?
> If not do you have a suggestion

It's the right place, indeed :-)

Here's an example using mxODBC:

# mxODBC is available from http://www.egenix.com/products/python/mxODBC/:

# On Windows:
from mx.ODBC import Windows as Database

# On Mac OS X:
from mx.ODBC import iODBC as Database

# On Linux/BSD/etc.:
from mx.ODBC import unixODBC as Database
# or
from mx.ODBC import iODBC as Database

# Open a connection to the database
connection = Database.DriverConnect('DSN=;'
'UID=;'
'PWD=;'
'KEYWORD=')
# replace the values accordingly, add new keyword-value pairs as
# necessary for your data source; data sources are configured
# in the ODBC manager

# Create a cursor; this is used to execute commands
cursor = connection.cursor()

# Create a table
cursor.execute('CREATE TABLE mxodbcexample1 '
   ' (id integer, name varchar(10), data varchar(254))')
# this command does not create a result set, so there's nothing
# to fetch from the database; however in order to make the
# change permanent, we need to commit the change
connection.commit()

# Prepare some data rows to add to the table, ie. a list of tuples
rows = []
for i in range(42):
name = 'name-%i' % i
data = 'value-%i' % i
rows.append((i, name, data))

# Add the data in one go; the values from the tuples get assigned
# to the ?-mark parameter markers in the SQL statement based on
# their position and the SQL statement is executed once for
# each tuple in the list of rows
cursor.executemany('INSERT INTO mxodbcexample1 VALUES (?,?,?)',
   rows)

# If you apply changes to the database, be sure to commit or
# rollback your changes; a call to .commit() or .rollback()
# will implicitly start a new transaction
connection.commit()

# Now fetch some data rows
from_id = 40
to_id = 42
cursor.execute('SELECT * FROM mxodbcexample1'
   ' WHERE (id >= ?) and (id < ?)',
   (from_id, to_id))

# Fetch the results
for i, row in enumerate(cursor.fetchall()):
print 'Row %i: %r' % (i, row)

# Remove the table again
cursor.execute('DROP TABLE mxodbcexample1')
connection.commit()

# Close the connection
connection.close()

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 28 2007)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611


> Sean 
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf
> Of Sugrue, Sean
> Sent: Friday, September 28, 2007 10:58 AM
> To: python-list@python.org
> Subject: OCBC connection
> 
> I'm trying to make an odbc connection to postgresql which is on a server
> using python.
> Does anyone have a code snippet to make a basic connection with a select
> query?
> 
> Sean
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-09-28 Thread xkenneth
Looking to do something similair. I'm working with alot of timestamps
and if they're within a couple seconds I need them to be indexed and
removed from a list.
Is there any possible way to index with a custom cmp() function?

I assume it would be something like...

list.index(something,mycmp)

Thanks!

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 10:01 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 28 Sep 2007 09:42:49 -0700, TheFlyingDutchman wrote:
> > Which of the common languages have higher order functions and what is
> > the syntax?
>
> C, C++, Pascal, Perl, PHP, Ruby have them.  And of course the functional
> languages, most notably Lisp and Scheme as you asked for common languages.
>
> Don't know if C#'s delegates qualify.
>
> Ciao,
> Marc 'BlackJack' Rintsch

What is the syntax of a higher order function in C, C++ and Pascal?

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
On Sep 28, 9:30 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> > You said it was a most basic language feature. I still haven't heard
> > anything that leads me to believe that statement is correct. What
> > languages implemented decorators as a most basic language feature?
>
> I was talking about Python, the programming language that is discussed in
> this NG
>
> > Python didn't have them for over a decade so it doesn't qualify.
>
> Says who? For further comments, see below.

I had the impression you were saying it was a basic language feature
of most languages. In any event Guido Van Rossum didn't include them
for over a decade. If he felt they were a basic language feature it
seems that he would have included them in 1991.

>
>
>
> >> >> Maybe you should start using python more and _then_ start discussions
> >> >> about it's features, when you have good grounds and can provide viable
> >> >> alternatives? But I guess that's a wish that won't be granted
>
> >> > static and abstract keywords would seem to be very viable
> >> > alternatives. Viable enough that several language designers used them.
>
> >> As I said - you don't get it. The decorators (in conjunction with the
> >> descriptor protocol - ever heard of that?) are very powerful yet lead as
> >> an artifact to simple, declarative implementations of features you like,
> >> namely static and abstract methods.
>
> > You said I had to provide a viable alternative. I did that. I haven't
> > heard of the descriptor protocol.
>
> Where did you do provide that alternative?

def static
def abstract

I was not providing an alternative for decorators.


>
> > One of the problems with "getting" decorators is that they are not in
> > older books at all and newer books like Beginning Python from Novice
> > to Professional (c) 2005 Magnus Lie Hetland, that I own, devote almost
> > nothing to them. Out of 640 pages they are only mentioned
> > in one paragraph that is in a section titled "Static Methods and Class
> > Methods",(and followed by a class example with @staticmethod and
> > @classmethod).
>
> > So it seems like Magnus Lie Hetland didn't think they were very
> > important and he had Professional in his book title.
>
> I consider "core features of a language" the features that are part of the
> specification and implementation. Neither do I care if there is anecdotal
> evidence of prior usage in other languages, nor who or who not thinks they
> are important enough to be dealt with in a book.

By that definition isn't anything that is part of a language a core
feature?  Weren't we talking about basic features?

>
> And above all, I don't consider the time things have been around _without_
> any feature as proof of their irrelevance - or do you consider cars being
> not core to western culture because they only have been around about 100
> years, whereas horses have been there for thousands of years? Happy riding,
> cowboy!

A relevant analogy would talk about a feature of cars that was not on
them in the beginning but has been added later and whether it was a
basic (or now, core) feature. Your definition of core feature given
above means that anything on a car when it comes out of the factory is
a core feature.

>
> Python 2.4 has been released in 2003, btw - so decorators are around for 4
> years now.
>
> So unless you come up with a definition of "core feature of a language" that
> someone respectable in the CS-community wrote that features "time being
> around" or "random book authors consider worthy" or "persons lacking the
> motivation to really dig into do finally get it", I consider your
> definition worthless. Agreed?
>

Since you defined a core feature (haven't seen your definition of a
basic feature) as anything in the specification or implementation, I
agree that it makes sense for you to disregard anything that limits
core features to something less than everything.


> >> Besides, those 'several language designers' seem to think that the
> >> introduction of keywords isn't enough, but a general purpose annotation
> >> scheme seems to be viable - or how do you explain e.g. JDK 1.5
> >> Annotations?
>
> > I certainly wouldn't call them a basic language feature. Java 1.0 came
> > out in January 1996, Java 1.5 in September 2004. It doesn't appear
> > that the language designer of Java, James Gosling, is still at the
> > wheel or BDFL. But yes, Java is showing signs of "complexity creep".
> > You'll be happy to know that I really dislike the C++ template syntax
> > and Java has decided to add something similar.
>
> Again, your anecdotal language feature definition is nonsense.
>
> By the way, considering generics and C++-templates as "something similar"
> shows the inclined beholder that there are other languages out there you
> don't really understand.

For me understanding is all I can hope to attain. Really understanding
is something I must yield to the corps d'elite.


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


Re: OCBC connection

2007-09-28 Thread kyosohma
On Sep 28, 9:57 am, "Sugrue, Sean" <[EMAIL PROTECTED]> wrote:
> I'm trying to make an odbc connection to postgresql which is on a server
> using python.
> Does anyone have a code snippet to make a basic connection with a select
> query?
>
> Sean

Sean,

This appears to be what you're looking for:

http://www.devx.com/opensource/Article/29071

See also Python Database spec and module page:

http://www.python.org/topics/database/

Mike

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


FW: OCBC connection

2007-09-28 Thread Sugrue, Sean
Is this the right email list to be on for asking rather elementary
python questions?
If not do you have a suggestion

Sean 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Sugrue, Sean
Sent: Friday, September 28, 2007 10:58 AM
To: python-list@python.org
Subject: OCBC connection

I'm trying to make an odbc connection to postgresql which is on a server
using python.
Does anyone have a code snippet to make a basic connection with a select
query?

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


Re: getopt with negative numbers?

2007-09-28 Thread Casey
On Sep 27, 10:47 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> I believe they shouldn't because the established interface is that a
> hyphen always introduced an option unless (for those programs that
> support it) a '--' option is used, as discussed.
Not "THE" established interface; "AN" established interface.  There
are other established interfaces that have different behaviors. I'm a
pragmatist; I write software for users, not techies.  I suspect most
users would expect a command like "abc -a -921 351 175" to treat the
"-921" as a negative integer and not abort the program with some
obscure error about option 921 not being known.
>
> > But I think it is a simple and clever hack and still allows getopt
> > or optparse to function normally.
>
> Except that they *don't* function normally under that hack; they
> function in a way contradictory to the normal way.
Again, it depends on who is defining "normal" and what they are basing
it on. I suspect many (probably most) users who are familiar with
command line input are unaware of the "--" switch which was mainly
designed to support arbitrary arguments that might have an initial
hyphen, a much broader problem than supporting negative values.  I'm
not asking that the default behavior of getopt or optparse change;
only that they provide an option to support this behavior for those of
us who find it useful. Software libraries should be tools that support
the needs of the developer, not rigid enforcers of arbitrary rules.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Marc 'BlackJack' Rintsch
On Fri, 28 Sep 2007 09:42:49 -0700, TheFlyingDutchman wrote:

> Which of the common languages have higher order functions and what is
> the syntax?

C, C++, Pascal, Perl, PHP, Ruby have them.  And of course the functional
languages, most notably Lisp and Scheme as you asked for common languages.

Don't know if C#'s delegates qualify.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Diez B. Roggisch
Paul Rubin wrote:

> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>> All serious languages are turing-complete. So can we put away with this
>> non-sense argument right away, please?
> 
> Actually the so called "total" languages aren't Turing-complete.  I
> think Coq is an example: every Coq function must return a value.  So



Please, Paul. There is no need to hijack every thread to show off your mad
functional and wicked staticly typed programming language skillz. We had
that discussion at a different time, and you very well know that with
serious I didn't mean "can be used to program rockets that don't fall of
the earth", but that aren't toy-languages used to solve real-world
problems.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread TheFlyingDutchman
>
> Decorators are syntax sugar for higher order functions. Higher order
> functions are a both a basic and a fundamental language feature, and
> exist in many languages. The fact that you don't know this just
> proves, once again, that you like to talk more than you like to learn.

Which of the common languages have higher order functions and what is
the syntax?

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Diez B. Roggisch
> You said it was a most basic language feature. I still haven't heard
> anything that leads me to believe that statement is correct. What
> languages implemented decorators as a most basic language feature?

I was talking about Python, the programming language that is discussed in
this NG. 

> Python didn't have them for over a decade so it doesn't qualify.

Says who? For further comments, see below.
 
>>
>> >> Maybe you should start using python more and _then_ start discussions
>> >> about it's features, when you have good grounds and can provide viable
>> >> alternatives? But I guess that's a wish that won't be granted
>>
>> > static and abstract keywords would seem to be very viable
>> > alternatives. Viable enough that several language designers used them.
>>
>> As I said - you don't get it. The decorators (in conjunction with the
>> descriptor protocol - ever heard of that?) are very powerful yet lead as
>> an artifact to simple, declarative implementations of features you like,
>> namely static and abstract methods.
> 
> You said I had to provide a viable alternative. I did that. I haven't
> heard of the descriptor protocol.

Where did you do provide that alternative?

> One of the problems with "getting" decorators is that they are not in
> older books at all and newer books like Beginning Python from Novice
> to Professional (c) 2005 Magnus Lie Hetland, that I own, devote almost
> nothing to them. Out of 640 pages they are only mentioned
> in one paragraph that is in a section titled "Static Methods and Class
> Methods",(and followed by a class example with @staticmethod and
> @classmethod).
> 
> So it seems like Magnus Lie Hetland didn't think they were very
> important and he had Professional in his book title.


I consider "core features of a language" the features that are part of the
specification and implementation. Neither do I care if there is anecdotal
evidence of prior usage in other languages, nor who or who not thinks they
are important enough to be dealt with in a book. 

And above all, I don't consider the time things have been around _without_
any feature as proof of their irrelevance - or do you consider cars being
not core to western culture because they only have been around about 100
years, whereas horses have been there for thousands of years? Happy riding,
cowboy!

Python 2.4 has been released in 2003, btw - so decorators are around for 4
years now.

So unless you come up with a definition of "core feature of a language" that
someone respectable in the CS-community wrote that features "time being
around" or "random book authors consider worthy" or "persons lacking the
motivation to really dig into do finally get it", I consider your
definition worthless. Agreed?


>>
>> And as you seem being so reluctant to let new features creep into the
>> language, the introduction of new keywords you like?
> 
> I'm not against additions on principle.
> 
>>
>> Besides, those 'several language designers' seem to think that the
>> introduction of keywords isn't enough, but a general purpose annotation
>> scheme seems to be viable - or how do you explain e.g. JDK 1.5
>> Annotations?
> 
> I certainly wouldn't call them a basic language feature. Java 1.0 came
> out in January 1996, Java 1.5 in September 2004. It doesn't appear
> that the language designer of Java, James Gosling, is still at the
> wheel or BDFL. But yes, Java is showing signs of "complexity creep".
> You'll be happy to know that I really dislike the C++ template syntax
> and Java has decided to add something similar.

Again, your anecdotal language feature definition is nonsense.

By the way, considering generics and C++-templates as "something similar"
shows the inclined beholder that there are other languages out there you
don't really understand.

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


Re: Python 3.0 migration plans?

2007-09-28 Thread Chris Mellon
On 9/28/07, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> On Sep 28, 2:49 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> > TheFlyingDutchman wrote:
> >

> > All serious languages are turing-complete. So can we put away with this
> > non-sense argument right away, please?
>
> You said it was a most basic language feature. I still haven't heard
> anything that leads me to believe that statement is correct. What
> languages implemented decorators as a most basic language feature?
> Python didn't have them for over a decade so it doesn't qualify.
>

Decorators are syntax sugar for higher order functions. Higher order
functions are a both a basic and a fundamental language feature, and
exist in many languages. The fact that you don't know this just
proves, once again, that you like to talk more than you like to learn.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >