Python Ireland November Talks - 10/10/2007
Hi All, Python Ireland presents this month talks at Trinity College (thanks to Brian who arranged the room, but will not be present in the country at that time, but I will try to be there early.). When: Wed 10th October 2007 (19:00 - 21:00) Where: Davis Theatre, Room 3074 in the Arts block ( Map : http://www.tcd.ie/Maps/arts_block.html ) Talk details: 19:00 - 19:30 Topic: Reading Python Code Speaker: Kevin Gill 19:30 - 20:00 Topic: z3c.dav – an implementation of WebDAV for Zope3 Speaker: Michael Kerrin 20:30 - 21:00 Topic: Short introduction to SQLAlchemy Speaker: Michael Twomey Then we head off to the pub. Maybe O'Neill's on Suffolk St, since it's the nearest I can think of. Any other suggestions? More details: http://wiki.python.ie/moin.cgi/PythonMeetup/October2007 Cheers, /// Vicky -- ~~ ~~ http://irishbornchinese.com ~~ ~~ http://www.python.ie~~ ~~ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANNOUNCE: wxPython 2.8.6.0
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. Source code is available, as well as binaries for Python 2.3, 2.4 and 2.5, for Windows and Mac, as well some pacakges for various Linux distributions. A summary of changes is listed below and also at http://wxpython.org/recentchanges.php. What is wxPython? - wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module that wraps the GUI components of the popular wxWidgets cross platform library, which is written in C++. wxPython is a cross-platform toolkit. This means that the same program will usually run on multiple platforms without modifications. Currently supported platforms are 32-bit Microsoft Windows, most Linux or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most cases the native widgets are used on each platform to provide a 100% native look and feel for the application. Changes in 2.8.6.0 -- This release is mostly about fixing a number of bugs and inconsistencies in wxWidgets and wxPython. In other words, there have been a whole lot more changes than what is listed here, but they are not new features or API visible changes, which is what are usually listed in this file. Some Menu APIs added to make things more consistent. Added wx.MenuBar.SetMenuLabel, wx.MenuBar.GetMenuLabel, wx.MenuBar.GetMenuLabelText, wx.Menu.GetLabelText, wx.MenuItem.SetItemLabel, wx.MenuItem.GetItemLabel, wx.MenuItem.GetItemLabelText, wx.MenuItem.GetLabelText. The Get...Label functions get the raw label with mnemonics and accelerators, and the Get...LabelText functions get the text only, without mnemonics/accelerators. Added wx.BORDER_THEME style. This style will attempt to use a theme specific style, if the current platform and environment is themeable and has a specific theme style. For example, you could use this on Windows XP on a custom control to give it a themed border style that looks like what is used by default on the native wx.TextCtrl or wx.ListBox. Since there were not any more available bits for border styles, this style replaces wx.BORDER_DOUBLE. -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python and SSL
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. But how can I tell my Python program to trust my SSL certificate? When I tried before I received the error 503 Thank you for help L, -- http://mail.python.org/mailman/listinfo/python-list
marshal bug?
I have been chasing a problem in my code since hours and it bolis down to this import marshal marshal.dumps(str(123)) != marshal.dumps(str(123)) Can someone please tell me why? when str(123) == str(123) or are they different? it also means that if s = str(123) marshal.dumps(s) != marshal.dumps(marshal.loads(marshal.dumps(s))) rgds Anurag -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI for viewing/editing python data structures?
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Numeric command-line options vs. negative-number arguments
Steven Bethard [EMAIL PROTECTED] writes: Did you try it and find it didn't work as you expected? No, I was commenting on the behaviour you described (hence why I said That would be irritating). 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. -- \ When I was a kid I used to pray every night for a new bicycle. | `\Then I realised that the Lord doesn't work that way so I stole | _o__)one and asked Him to forgive me. -- Emo Philips | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: marshal bug?
Anurag wrote: I have been chasing a problem in my code since hours and it bolis down to this import marshal marshal.dumps(str(123)) != marshal.dumps(str(123)) Can someone please tell me why? when str(123) == str(123) or are they different? it also means that if s = str(123) marshal.dumps(s) != marshal.dumps(marshal.loads(marshal.dumps(s))) rgds Anurag Any string in Python can be interned or not, the difference being how/where the value is stored internally. The marshal module includes such information in its output. What you are doing is probably considered a misuse of the marshal module. I'd suggest using the pickle (or cPickle) modules instead. Here's the relevant part of the manual for marshal: version: Indicates the format that the module uses. Version 0 is the historical format, version 1 (added in Python 2.4) shares interned strings and version 2 (added in Python 2.5) uses a binary format for floating point numbers. The current version is 2 Gary Herron. -- http://mail.python.org/mailman/listinfo/python-list
Re: marshal bug?
On 9/28/07, Anurag [EMAIL PROTECTED] wrote: I have been chasing a problem in my code since hours and it bolis down to this import marshal marshal.dumps(str(123)) != marshal.dumps(str(123)) I'm not sure why, but marshal does dump the 2 differently. ie: marshal.dumps(str(123)) 's\x03\x00\x00\x00123' marshal.dumps(str(123)) 't\x03\x00\x00\x00123' Somehow, marshal detects a difference between these 2 and changes the first character in it's output. From the documentation: Details of the format are undocumented on purpose; it may change between Python versions (although it rarely does). So you could check the C code to find out what the s and t mean, but your assumptions on the format for your app could become incorrect with new Python versions, or with different marshalling backends. -- http://mail.python.org/mailman/listinfo/python-list
Re: marshal bug?
I'm not sure why, but marshal does dump the 2 differently. ie: marshal.dumps(str(123)) 's\x03\x00\x00\x00123' marshal.dumps(str(123)) 't\x03\x00\x00\x00123' I've just checked the source [1]. 's' refers to a regular string, 't' refers to an interned[2] string. In other words the difference between the 2 marshal dumps is an internal python implementation detail. You probably shouldn't be comparing marshal dumps in your app in the first place. [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) [2] http://mindprod.com/jgloss/interned.html -- http://mail.python.org/mailman/listinfo/python-list
Re: marshal bug?
Thanks for the reply. It seems problem is due to Any string in Python can be interned or not, the difference being how/where the value is stored internally. The marshal module includes such information in its output. What you are doing is probably considered a misuse of the marshal module. I'd suggest using the pickle (or cPickle) modules instead. as mentioned by Gary Herron Now is there a easy way to by pass it (hack around it) I tried various options but all fail e.g. i= 123; marshal.dumps(%d%123) != marshal.dumps(%d%i) So maybe I have to change all my code to use pickle, which also consumes for memory per string. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
TheFlyingDutchman schrieb: - Abstract Base Classes URL:http://www.python.org/dev/peps/pep-3119/ 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. But I know all such additions are vigorously defended by the most ardent users of each language. The fact that you compare and criticise the simple annotations like static or abstract with the much more powerful decorator concept shows that, despite being the maintainer of a soon-to-be-ruling-the-python-world Python 3 fork, lack understanding of even the most basic language features. Which isn't exactly news.[1] The decorator syntax was vigorously discussed. I personally don't mind the @-based syntax, but could live with anything else - because I like and often need the feature for it's capabilities. 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 Diez [1] http://groups.google.de/group/comp.lang.python/browse_thread/thread/a9a52694148fc52c/28c9ee2e1c64cdde#28c9ee2e1c64cdde -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
Never would look like a good time scale to me given that a lot of the stuff I use is being ripped out -- http://mail.python.org/mailman/listinfo/python-list
Re: ValueError: too many values to unpack,
J. Clifford Dyer a écrit : On Thu, Sep 27, 2007 at 09:50:26PM +0200, Bruno Desthuilliers wrote regarding Re: ValueError: too many values to unpack,: Shawn Minisall a ?crit : (snip) I did and it printed everything up until the 3rd line with 3 numbers for deposits. I have since figured it out...the teacher put in an extra tab after the last value so python thought it was 4 values for three. I went back into the file and deleted the extra tab after the 3rd number and saved it...now it's working fine. I'm going to kill her... You'd better learn how to deal with this-cant-happen-here situation, because it's how it is in real-life. And preferably learn how to deal with it in your code, not in the data that's given to you. Thanks for clarifying this point, which is of course what I meant. -- http://mail.python.org/mailman/listinfo/python-list
Re: Numeric command-line options vs. negative-number arguments
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. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: A question on python performance.
Joe Goldthwaite wrote: I didn't know about the getattr function. I tried to search for that type of function but not knowing how to word the search request, I couldn't find it. You should really read through chapter 2 (Built-in Objects) of the library reference. All that stuff is core Python functionality that you should be aware of. Reading chapter 3 (Built-in Types) is also a really good idea. A lot of the rest is good too, but there is really no excuse for not knowing the contents of those chapters. ;) It's just a few pages, and very useful to know. Read them now! -- http://mail.python.org/mailman/listinfo/python-list
Re: recipient validation with smtplib
Robin Becker wrote: Tim Williams wrote: On 28/09/2007, Robin Becker [EMAIL PROTECTED] wrote: Is there a way to use smtplib to get recipient validation. I can use smtplib quite happily to send emails using the locahost's sendmail, but sendmail is just fire and forget, so some bad addresses eg [EMAIL PROTECTED] don't cause any error in the sending application. I know some smtp setups do enforce recipient validation, but it doesn't seem terribly easy to do this with sendmail. I wondered if there were some way to do this in python? There is no way of validating *every* email address you send to using SMTP alone. Some servers accept every address and bounce later - as you have found out. So for the purpose of the SMTP client, or relaying server, the address is valid at sending time to those servers. Checking DNS for MX records is a possibility for removing some bad addresses, but it's not fool proof as the RFCs don't require MX records to exist for a domain to be able to receive email. If no MX records are present, one (and only one!) IP address returned from the domain's A record(s) should be tried. HTH :) Thanks, it's at least ammunition for me to say it cannot easily be done. I found this milter http://www.jmaimon.com/sendmail/callahead-milter/ but I think this will cause every send to be checked which is probably not what we need. I have a client who gets many spurious web sign-ups (they are a telephone service). One of the signs of fraud is a bogus email address, so it became very important to detect these. The only way we could satisfactorily do so was to process the mailbox that received the bounces and detect a GUID in the bounce message to identify the potentially bogus accounts. This apparently works well enough to stop most scammers from making their first 'phone call. In general there is no way to tell when sending that an address is or is not valid. 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?
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. All the major third-party libraries working and available with working builds for all major platforms. That working set of components in all the major distros used on servers. The major hosting companies having that up and running on their servers. Windows installers that install a collection of components that all play well together. That's what I mean by working. I.e., you mean tasks appropriate for maintainers of all the major third-party libraries, distros, and hosting companies -- great, go convince them, or go convince all warmongers on Earth to make peace if you want an even harder tasks with even better potential impact on the state of the world, then. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
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. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
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 Coq doesn't have any way to write an infinite loop, because that would allow writing functions that fail to return. So there is no halting program in Coq (every Coq program halts), which means Coq is not Turing-complete. That allows Coq to generate code about which it can make all kinds of guarantees that most languages can't (not simply that the programs halt but that they actually fulfill their computational specifications), so it's being used in various high-assurance applications, though usually to write just the most critical parts of a program, not the entire program. Of course it's a matter of semantics but in some meaningful ways, I'd say Coq is a more serious language than Python. Here is a famous early paper explaining why Turing-completeness isn't all it's cracked up to be: http://sblp2004.ic.uff.br/papers/turner.pdf This paper shows some of the advantages of the total approach. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On Sep 28, 2:49 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: TheFlyingDutchman wrote: The fact that you compare and criticise the simple annotations like static or abstract with the much more powerful decorator concept shows that, despite being the maintainer of a soon-to-be-ruling-the-python-world Python 3 fork, lack understanding of even the most basic language features. Which isn't exactly news.[1] Don't you mean lack appreciation for the non-basic language features? static, class and abstract are basic language features that I appreciate. decorators have been in Python for only a small part of its existence, they aren't in the vast majority of languages (if any other language even has them) which means people write all kinds of software without them. Or rather, most of the software ever written didn't use decorators. Doesn't sound basic at all. People did write all kinds of software in Assembler. And large portions of these people complained about every feature that some new language introduced. 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. 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. 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. 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. -- http://mail.python.org/mailman/listinfo/python-list
Delete spaces
If I have a text file that is delimited by spaces, how do I import it and get to comma delimited? Here is a row of data from the text file: 1110:55:14 265 8.5 1.4+1.1 2.5 Class-2 0 I tried a few examples from the group and it didn't work, since the file also has a header row and a row of seperators ( ---). The lengths of each row is something like 130, so there are extra spaces after the last value as well. I have tried joining and other things, but I couldn't figure out how to get the values to come together. Thanks. Kou -- http://mail.python.org/mailman/listinfo/python-list
Re: [Zope] how do I test for the current item in an iteration
+---[ kamal hamzat ]-- | Dear All, | | I have this error after i added the if statement Time for you to do some reading of your own. That's three in less than an hour... -- Andrew Milton [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
is there a posh Win32 binary? or, compiling with MS 2005 Express...
Is there a posh Win32 binary? Or better, has anyone successfully compiled modules for Python 2.4 with the newest free tools? Do I need to move to 2.5? I could not get it to compile with my (apparently incomplete) MS C++ 7.1 install (which did, however, work for weave/blitz, before). The 7.1 compiler with the 1.1SDK is no longer available, so I can't repair the install. I went through the motions of compiling yesterday with the new MS Express Toolkit on another machine and failed. Distutils keeps saying that the SDK for 7.1 is not installed. Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing Module To Use Variables In A Second Module
Most problems like this are caused by trying to access the attributes of the module before that module is fully executed, and thus before they are defined. For example, if you have A.py: import B data = TEST And B.py: import A print A.data Now, if you run A,py, it will import B before it defines its global variable 'data', so that when the B module tries to import A and then print A.data, it has not been defined yet. Look into the possibility that such an import loop is occurring in your code. You can import in loops, but not if you access things defined globally in one from a global scope in another. On 27 Sep 2007 21:30:10 GMT, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm stymied by what should be a simple Python task: accessing the value of a variable assigned in one module from within a second module. I wonder if someone here can help clarify my thinking. I've re-read Chapter 16 (Module Basics) in Lutz and Ascher's Learning Python but it's not working for me. In one module (the source), variablePage.py, three wxPython widgets display values that are assigned to variables: curVar, UoDlow, and UoDhigh. I want to display then in equivalent widgets on a wxPython notebook tab in a different module, the importer. At the top of the importer module I have: from variablePage import curVar, UoDlow, UoDhigh and I try to display the values of those variables in widgets on this page. But, python complains: from variablePage import curVar, UoDlow, UoDhigh ImportError: cannot import name curVar I've also tried import variablePage as VP and referenced the variables as VP.curVar, VP.UoDlow, and VP.UoDhigh, but python still doesn't like this: File /data1/eikos/fuzSetPage.py, line 364, in loadParVar first = VP.curVar AttributeError: 'module' object has no attribute 'curVar' Both of these forms are used in the book (pages 260-261) in simple examples. I also get errors if I try importing using the class name before the variable name. A clue stick would be very helpful since I am not seeing just what I'm doing incorrectly. Rich -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
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
Re: recipient validation with smtplib
On 28/09/2007, Robin Becker [EMAIL PROTECTED] wrote: Tim Williams wrote: On 28/09/2007, Robin Becker [EMAIL PROTECTED] wrote: Is there a way to use smtplib to get recipient validation. I can use smtplib quite happily to send emails using the locahost's sendmail, but sendmail is just fire and forget, so some bad addresses eg [EMAIL PROTECTED] don't cause any error in the sending application. I know some smtp setups do enforce recipient validation, but it doesn't seem terribly easy to do this with sendmail. I wondered if there were some way to do this in python? There is no way of validating *every* email address you send to using SMTP alone. Some servers accept every address and bounce later - as you have found out. So for the purpose of the SMTP client, or relaying server, the address is valid at sending time to those servers. Checking DNS for MX records is a possibility for removing some bad addresses, but it's not fool proof as the RFCs don't require MX records to exist for a domain to be able to receive email. If no MX records are present, one (and only one!) IP address returned from the domain's A record(s) should be tried. HTH :) Thanks, it's at least ammunition for me to say it cannot easily be done. I found this milter http://www.jmaimon.com/sendmail/callahead-milter/ but I think this will cause every send to be checked which is probably not what we need. Hmm, call-ahead functions just initiate the first part of the SMTP dialogue - to the RCPT TO, unless you cache the results so that the call-ahead only checks each address once a day or so there is no benefit. Without caching it will just slow down sending process as you will get 1.5 SMTP conversations per outgoing message instead of just 1.However, they still won't catch invalid email addresses when the server accepts all addresses* and bounces later. * all addresses = all addresses on domains local to that server. I have written functions like this in the past for outbound/inbound (recipient/sender) address checking, using combinations of SMTP dialogue, DNS and port checking, bounce-collection, SPF and other techniques over the years. There is no guaranteed way of checking that all email addresses in your list are either VALID or INVALID. Valid email addresses can get refused/bounce for a variety of reasons, and invalid addresses sometimes get accepted/don't bounce at all. You should work on either a best-effort basis, running some checks but accepting that its not foolproof -OR- use no checks at all knowing that most invalid email addresses will be handled correctly by the SMTP processes HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Traveling Europe
on 9/27/2007 10:43 PM Eric Sosman said the following: [EMAIL PROTECTED] wrote: World's most popular traveling destinations http://... Nobody goes there any more; it's too crowded. -- LPB Besides, It gets late there early -- LPB -- Bill In Hamptonburgh, NY To email, remove the double zeroes after @ -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug: spurious indentation error
Mridula Ramesh wrote: hi. is this the right place to report a bug? i had written this by mistake: filemenu = Menu(menu) , bg=White) instead of filemenu = Menu(menu, bg=Pink) and the compiler kept giving me an indentation error in a line much further down which was perfectly okay. i am using python 2.5.1 with IDLE 1.2.1 on a windows XP machine. anyone else struggling with the same thing, beware! :) -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 stdin, 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 -- 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
Bug: spurious indentation error
hi. is this the right place to report a bug? i had written this by mistake: filemenu = Menu(menu) , bg=White) instead of filemenu = Menu(menu, bg=Pink) and the compiler kept giving me an indentation error in a line much further down which was perfectly okay. i am using python 2.5.1 with IDLE 1.2.1 on a windows XP machine. anyone else struggling with the same thing, beware! :) -mridula. -- http://mail.python.org/mailman/listinfo/python-list
recipient validation with smtplib
Is there a way to use smtplib to get recipient validation. I can use smtplib quite happily to send emails using the locahost's sendmail, but sendmail is just fire and forget, so some bad addresses eg [EMAIL PROTECTED] don't cause any error in the sending application. I know some smtp setups do enforce recipient validation, but it doesn't seem terribly easy to do this with sendmail. I wondered if there were some way to do this in python? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: getopt with negative numbers?
Ben Finney wrote: Casey [EMAIL PROTECTED] writes: Well, it is a hack and certainly not as clean as having getopt or optparse handle this natively (which I believe they should). 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. I don't agree. First of all, what is 'established interface'? There are precedents from well-known C and C++ libraries, such as 'getopt', 'popt', and boost::program_options. IIRC, each of these will treat a negative number following an option that requires a number as a number. Besides this, the behavior I just described is really required. Otherwise, numeric options are basically broken. -- http://mail.python.org/mailman/listinfo/python-list
Re: Emailing the attachment created with the Quick Screenshots Script(Python + PIL)
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. If someone can see where I've gone wrong, it would be greatly appreciated. Simple script to capture your screen, save it named with today's date and then open it to allow editing and markup (circle problems, etc) Created by Greg Pinero ([EMAIL PROTECTED]) Spring 2005 To run this you'll need: Python Imaging Library (PIL) -http://www.pythonware.com/products/pil/ Python 2.3 or later - http://www.python.org Windows? import os import sys import time import Image import ImageGrab #- #User Settings: SaveDirectory=r'C:\Downloads\Python\Attachments' ImageEditorPath=r'C:\WINDOWS\system32\mspaint.exe' #Here is another example: #ImageEditorPath=r'C:\Program Files\IrfanView\i_view32.exe' #- img=ImageGrab.grab() saveas=os.path.join(SaveDirectory,'ScreenShot_'+time.strftime('%Y_%m_%d%_%H_ %M_%S')+'.jpg') img.save(saveas) editorstring='start%s %s'% (ImageEditorPath,saveas) #Just for Windows right now? #Notice the first leading above? This is the bug in python that no one will admit... os.system(editorstring) # Import smtplib for the actual sending function import smtplib # Here are the email package modules we'll need from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart COMMASPACE = ', ' # Create the container (outer) email message. msg = MIMEMultipart() msg['Subject'] = 'TEST' # me == the sender's email address # family = the list of all recipients' email addresses msg['From'] = (Mark Bratcher) msg['To'] = COMMASPACE.join(Mark Bratcher) msg.preamble = 'TEST' # Assume we know that the image files are all in JPG format for file in c:\downloads\python\Attachments\*.jpg: # Open the files in binary mode. Let the MIMEImage class automatically # guess the specific image type. fp = open(file, 'rb') img = MIMEImage(fp.read()) fp.close() msg.attach(img) # Send the email via our own SMTP server. s = smtplib.SMTP() s.connect() s.sendmail(me, family, msg.as_string()) s.close() The errors I'm receiving in the Python Shell are: Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 54, in module fp = open('C:\Downloads\Python\Attachments\*.jpg', 'rb') IOError: [Errno 2] No such file or directory: 'C:\\Downloads\\Python\\Attachments\\*.jpg' Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 54, in module fp = open('\Downloads\Python\Attachments\*.jpg', 'rb') IOError: [Errno 2] No such file or directory: '\\Downloads\\Python\\Attachments\\*.jpg' Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 54, in module fp = open('*.jpg', 'rb') IOError: [Errno 2] No such file or directory: '*.jpg' Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 51, in module for file in jpgfiles: NameError: name 'jpgfiles' is not defined Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 54, in module fp = open(file, 'rb') IOError: [Errno 2] No such file or directory: 'c' Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 54, in module fp = open(file, 'rb') IOError: [Errno 2] No such file or directory: 'c' Traceback (most recent call last): File C:\Downloads\Python\screenshooter.pyw, line 54, in module fp = open(file, 'rb') IOError: [Errno 2] No such file or directory: 'c' Mark Bratcher Consolidated Citrus, LP 4210-250 Metro, Parkway Fort Myers, FL 33916 239-275-4060 ext 219 -- http://mail.python.org/mailman/listinfo/python-list
FW: OCBC connection
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: OCBC connection
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
Re: getopt with negative numbers?
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?
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: Emailing the attachment created with the Quick Screenshots Script(Python + PIL)
On 9/28/07, Mark Bratcher [EMAIL PROTECTED] wrote: I tried the suggestion at the other end of this link without any luck. Does anyone have a working script which will send the screenshot file created by the Quick Screenshots Script (Python + PIL)? I receive errors like access denied errors and not defined errors. Could you show us the code you are running, and the exact error messages that you get? This might be worth a look: http://tinyurl.com/anel . -- Cheers, Simon B. [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
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?
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: Emailing the attachment created with the Quick Screenshots Script(Python + PIL)
I tried the suggestion at the other end of this link without any luck. Does anyone have a working script which will send the screenshot file created by the Quick Screenshots Script (Python + PIL)? I receive errors like access denied errors and not defined errors. See the second example from the email package; it creates a MIME message with an attachment and sends it using SMTP. http://docs.python.org/lib/node162.html Mark Bratcher Consolidated Citrus, LP 4210-250 Metro, Parkway Fort Myers, FL 33916 239-275-4060 ext 219 -- http://mail.python.org/mailman/listinfo/python-list
Re: [Zope] how do I test for the current item in an iteration
--On 28. September 2007 16:36:43 +0100 kamal hamzat [EMAIL PROTECTED] wrote: Dear All, 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) return printed Look at Python's enumerate() method. -aj pgp4LZBeowRiB.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: FW: OCBC connection
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=datasourcename;' 'UID=username;' 'PWD=password;' 'KEYWORD=value') # 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
Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?
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: Delete spaces
[EMAIL PROTECTED] wrote: If I have a text file that is delimited by spaces, how do I import it and get to comma delimited? Here is a row of data from the text file: 1110:55:14 265 8.5 1.4+1.1 2.5 Class-2 0 I tried a few examples from the group and it didn't work, since the file also has a header row and a row of seperators ( ---). The lengths of each row is something like 130, so there are extra spaces after the last value as well. I have tried joining and other things, but I couldn't figure out how to get the values to come together. Thanks. Kou After you recognize and handle the header and separator lines, the remaining lines can be handled this way: l = '1110:55:14 265 8.5' f = l.split() print f ['1', '1', '10:55:14', '2', '65', '8.5'] ','.join(f) '1,1,10:55:14,2,65,8.5' or ', '.join(f) '1, 1, 10:55:14, 2, 65, 8.5' Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: getopt with negative numbers?
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: Python 3.0 migration plans?
On Thu, Sep 27, 2007 at 09:17:30PM -0400, Steve Holden wrote: So what we need is a poll on what the questions should be. I *love* c.l.py. I will switch as soon as Debian has all the tools for an easy conversion available, and Python 3000 has reached the default release status. e -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 -- http://mail.python.org/mailman/listinfo/python-list
C Source Code Generator For Test Cases
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: Python 3.0 migration plans?
The fact that you compare and criticise the simple annotations like static or abstract with the much more powerful decorator concept shows that, despite being the maintainer of a soon-to-be-ruling-the-python-world Python 3 fork, lack understanding of even the most basic language features. Which isn't exactly news.[1] Don't you mean lack appreciation for the non-basic language features? static, class and abstract are basic language features that I appreciate. decorators have been in Python for only a small part of its existence, they aren't in the vast majority of languages (if any other language even has them) which means people write all kinds of software without them. Or rather, most of the software ever written didn't use decorators. Doesn't sound basic at all. 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: A question on python performance.
Joe Goldthwaite a écrit : (snip) I guess I still think of decorators as the people who got the gym ready for the prom. I've tried getting up to speed on decorators but I haven't had much success. The @decorator syntax is just syntactic sugar for a common use of higher order functions. So to understand decorators, you first need understand the concepts of higher order functions and closures. Both are documented in many places on the web. Bruno Desthuilliers wrote: IOW, direct access to obj.__class__.__dict__ bypasses both inheritence and per-instance overriding. Thanks for your response also Bruno. I don't understand the code you posted well enough yet to even ask a useful question. There are a number of things I haven't seen before. It's very 101 python code, apart from this line : c2.dothis = dothat.__get__(c2, type(c2)) which is a way to dynamically attach a function as method to an instance, directly invoking the descriptor protocol (it's documented on python.org) FWIW, it's most often done using the 'new' module, and possibly less confusing: import new c2.dothis = new.instancemethod(dothat, c2, type(c2)) Now I really feel like a newbie! My fault - this example wasn't that necessary, the main point was wrt/ direct access to instance.__class__.__dict__ bypassing normal attribute lookup rules so inherited attributes are not resolved... I'm working on it though so I may have some questions later. You're welcome. -- http://mail.python.org/mailman/listinfo/python-list
Re: marshal bug?
En Fri, 28 Sep 2007 04:26:39 -0300, Anurag [EMAIL PROTECTED] escribi�: Now is there a easy way to by pass it (hack around it) I tried various options but all fail e.g. i= 123; marshal.dumps(%d%123) != marshal.dumps(%d%i) You can't. Don't use marshal to compare objects. You appear to assume that two objects that compare equal, should have the same marshalled representation, and that is simply not true. py [1, 2.0, 3+0j, 4] == [1.0, 2+0j, 3, u4] True So maybe I have to change all my code to use pickle, which also consumes for memory per string. Neither marshal nor pickle guarantee that equal objects have equal representations, so in this regard pickle won't help either. Maybe if you explain what you really want to do someone could suggest a solution. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On Sep 27, 2007, at 8:17 PM, Steve Holden wrote: James Stroud wrote: Steve Holden wrote: I wondered if a straw poll could get some idea of readers' thoughts about when they will be migrating to 3.0 on, so I used the new widget on Blogger to add a poll for that. I'd appreciate if if you would go to http://holdenweb.blogspot.com/ and register your vote on your intended migration timescale. Thanks! I'm going to abstain voting until 'public beta + about 1 year' is a choice. Richard Jones wrote: I'll use the no plans response for my actual no simple answer real response. So what we need is a poll on what the questions should be. I *love* c.l.py. Does professional vs. personal use matter here? What if I plan to switch in the morning or at midnight on the first solstice after the second alpha release? Is Mercury or Venus in retrograde? These things matter... :) 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
Re: Python 3.0 migration plans?
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
Re: Python 3.0 migration plans?
Ian Dickinson wrote: Never would look like a good time scale to me given that a lot of the stuff I use is being ripped out Has any one actually converted any real code or significant bits of code using the 3.0 converter (in the sandbox somewhere), and if so what kinds of things actually failed? Nothing I've read about 3.0 has alarmed me that much yet, but I've not yet actually tried converting code for it (except a few extension modules, which at least _compiled_ just fine against 3.0). - Stephan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
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
Can I overload the compare (cmp()) function for a Lists ([]) index function?
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: recipient validation with smtplib
Tim Williams wrote: On 28/09/2007, Robin Becker [EMAIL PROTECTED] wrote: Is there a way to use smtplib to get recipient validation. I can use smtplib quite happily to send emails using the locahost's sendmail, but sendmail is just fire and forget, so some bad addresses eg [EMAIL PROTECTED] don't cause any error in the sending application. I know some smtp setups do enforce recipient validation, but it doesn't seem terribly easy to do this with sendmail. I wondered if there were some way to do this in python? There is no way of validating *every* email address you send to using SMTP alone. Some servers accept every address and bounce later - as you have found out. So for the purpose of the SMTP client, or relaying server, the address is valid at sending time to those servers. Checking DNS for MX records is a possibility for removing some bad addresses, but it's not fool proof as the RFCs don't require MX records to exist for a domain to be able to receive email. If no MX records are present, one (and only one!) IP address returned from the domain's A record(s) should be tried. HTH :) Thanks, it's at least ammunition for me to say it cannot easily be done. I found this milter http://www.jmaimon.com/sendmail/callahead-milter/ but I think this will cause every send to be checked which is probably not what we need. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?
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: Python 3.0 migration plans?
TheFlyingDutchman wrote: The fact that you compare and criticise the simple annotations like static or abstract with the much more powerful decorator concept shows that, despite being the maintainer of a soon-to-be-ruling-the-python-world Python 3 fork, lack understanding of even the most basic language features. Which isn't exactly news.[1] Don't you mean lack appreciation for the non-basic language features? static, class and abstract are basic language features that I appreciate. decorators have been in Python for only a small part of its existence, they aren't in the vast majority of languages (if any other language even has them) which means people write all kinds of software without them. Or rather, most of the software ever written didn't use decorators. Doesn't sound basic at all. People did write all kinds of software in Assembler. And large portions of these people complained about every feature that some new language introduced. All serious languages are turing-complete. So can we put away with this non-sense argument right away, please? 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. And as you seem being so reluctant to let new features creep into the language, the introduction of new keywords you like? 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? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Delete spaces
[EMAIL PROTECTED] a écrit : If I have a text file that is delimited by spaces, spaces or tabs ? how do I import it and get to comma delimited? Here is a row of data from the text file: 1110:55:14 265 8.5 1.4+1.1 2.5 Class-2 0 I tried a few examples from the group and it didn't work, since the file also has a header row and a row of seperators ( ---). The lengths of each row is something like 130, so there are extra spaces after the last value as well. I have tried joining and other things, but I couldn't figure out how to get the values to come together. Thanks. This should answer your question - but certainly not solve your problem (cf below): f = open('/path/to/file.txt'); file.readline(); # skip headers for line in f: # skip separators if line.startswith('---'): continue parts = filter(line.rstrip().split()) print ';'.join(parts) f.close() Now the problem is that, obviously, the position of a group of data in a line is meaningfull, so just filtering out spaces isn't the solution. Did you check that it's not really a tab-delimited file ? If yes, doing line.split('\t') might help. Or just trying with the csv module FWIW. My 2 cents... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
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
Re: recipient validation with smtplib
On 28/09/2007, Robin Becker [EMAIL PROTECTED] wrote: Is there a way to use smtplib to get recipient validation. I can use smtplib quite happily to send emails using the locahost's sendmail, but sendmail is just fire and forget, so some bad addresses eg [EMAIL PROTECTED] don't cause any error in the sending application. I know some smtp setups do enforce recipient validation, but it doesn't seem terribly easy to do this with sendmail. I wondered if there were some way to do this in python? There is no way of validating *every* email address you send to using SMTP alone. Some servers accept every address and bounce later - as you have found out. So for the purpose of the SMTP client, or relaying server, the address is valid at sending time to those servers. Checking DNS for MX records is a possibility for removing some bad addresses, but it's not fool proof as the RFCs don't require MX records to exist for a domain to be able to receive email. If no MX records are present, one (and only one!) IP address returned from the domain's A record(s) should be tried. HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
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?
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 snip/ 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?
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: [Zope] how do I test for the current item in an iteration
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?
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: Python 3.0 migration plans?
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: OCBC connection
[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?
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: OCBC connection
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?
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?
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?
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
Bug with lists of pairs of lists and append()
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?
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: Python 3.0 migration plans?
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: C Source Code Generator For Test Cases
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
Re: Python 3.0 migration plans?
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?
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: GUI for viewing/editing python data structures?
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?
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: OCBC connection
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: Bug with lists of pairs of lists and append()
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?
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: C Source Code Generator For Test Cases
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: Python 3.0 migration plans?
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: Python 3.0 migration plans?
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?
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: 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
Re: Python 3.0 migration plans?
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: Python 3.0 migration plans?
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: OCBC connection
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
List search
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: Python 3.0 migration plans?
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
Re: List search
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?
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: Python 3.0 migration plans?
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: List search
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: List search
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: Python 3.0 migration plans?
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