Wing IDE for Python v. 3.0 beta1 released
Hi, I'm happy to announce the first beta release of Wing IDE 3.0. It is available from http://wingware.com/wingide/beta Wing IDE is a commercial IDE designed specifically for Python programmers. More information about the product and free trials are available at http://wingware.com/ The major new features introduced in Wing 3.0 are: * Multi-threaded debugger * Debug value tooltips in editor, debug probe, and interactive shell * Autocompletion in debug probe and interactive shell * Automatically updating project directories * Testing tool, currently supporting unittest derived tests (*) * OS Commands tool for executing and interacting with external commands (*) * Rewritten indentation analysis and conversion (*)'d items are available in Wing IDE Professional only. The CHANGELOG.txt file in the installation provides additional details. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Reporting Bugs -- Please report bugs using the Submit Bug Report item in the Help menu or by emailing support at wingware dot com. This is beta quality software that installs side-by-side with Wing 2.x or 1.x. We advise you to make frequent backups of your work when using any pre-release version of Wing IDE. Upgrading - To upgrade a 2.x license or purchase a new 3.x license: Upgradehttps://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 normal price to upgrade. Thanks! The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python Package Index hostname change
The Python Packaging Index (the software formerly known as Cheeseshop) is now available at http://pypi.python.org/pypi The old addresses (www.python.org/pypi, and cheeseshop.python.org/pypi) will continue to work, either as aliases or using HTTP redirections. The software was renamed to its old name (PyPI - Python Package Index), as the Cheeseshop name was ever confusing people unfamiliar with British television comedy sketch (and puzzling even to people familiar with the sketch, as you *can* get packages from the package index). If you would like to discuss PyPI and its future, please join [EMAIL PROTECTED] Regards, Martin -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
MailingLogger 3.2.0 Released!
With help from Jens Vagelpohl, I'm pleased to announce a new release of Mailinglogger that now supports filtering of log entries... Mailinglogger enables log entries to be emailed either as the entries are logged or as a summary at the end of the running process. This pair of enhanced emailing handlers for the python logging framework is now available as a standard python package and as an egg. The handlers have the following features: - customisable and dynamic subject lines for emails sent - emails sent with an X-Mailer header for easy filtering - flood protection to ensure the number of emails sent is not excessive - support for SMTP servers that require authentication - fully documented and tested In addition, extra support is provided for configuring the handlers when using ZConfig, Zope 2 or Zope 3. Installation is as easy as: easy_install mailinglogger For more information, please see: http://www.simplistix.co.uk/software/python/mailinglogger cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
PyCon UK talks announced
Details of the talks we'll be having at the UK Python conference in September are now appearing on the website: http://www.pyconuk.org/talks.html. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Reading a two-column file into an array?
On Mon, 30 Jul 2007 21:57:17 -0700, Nagarajan wrote: a = [] import csv reader = csv.reader(open(filename, r), delimiter='\t' ) for row in reader: a.append( row ) I would keep a reference to the file to close it properly and the loop can be replaced by a call to `list()`: import csv def main(): data_file = open('filename', 'rb') a = list(csv.reader(data_file, delimiter='\t')) data_file.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Pysqlite storing file as blob example
On Jul 30, 6:25 pm, [EMAIL PROTECTED] wrote: I'm trying to store binary data in a sqlite database and call into the db using pysqlite 3. What I've got so far is this: import sqlite con = sqlite.connect(DB_PATH) cur = con.cursor() query = create table t1( ID INTEGER PRIMARY KEY, dataBLOB ); cur.execute(query) con.commit() b = buffer('/path/to/binary/file') buffer() ? From the docs: There are several built-in functions that are no longer essential to learn, know or use in modern Python programming. They have been kept here to maintain backwards compatibility with programs written for older versions of Python. ... buffer(object[, offset[, size]]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Directory
On 30 Lip, 23:43, Rohan [EMAIL PROTECTED] wrote: I would like to get a list of sub directories in a directory. If I use os.listdir i get a list of directories and files in that . i only want the list of directories in a directory and not the files in it. anyone has an idea regarding this. Hi Rohan, http://diveintopython.org/file_handling/os_module.html Hope this helps, Cheers, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Replacing overloaded functions with closures.
Ok, i see... Thank you all :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Where do they tech Python officialy ?
Star a écrit : MIT's freshman survey, EECS 1 is taught in Python and Scheme, soon to be just Python. they should keep scheme or replace it with another (statically typed ?) functional language IMHO. OT please do the world (or at least usenet and mailing lists users) a favour : learn to answer properly !-) 1/ don't top-post 2/ only keep from the post you're answering waht you're answering to 3/ if possible, answer to the right post (given the content of your post, you should have answered to the OP, not to me) Sorry to be the annoying dude here... /OT -Star On Wed, 25 Jul 2007, Bruno Desthuilliers wrote: Omari Norman a écrit : On Mon, Jul 23, 2007 at 10:48:10PM -0700, Paul Rubin wrote: If you're having trouble with Python because you're new at programming, I can sympathize--I don't think it's the most beginner-friendly of languages despite the efforts in that direction by the designers. Just curious--what language would you recommend as most beginner-friendly? C ?-) (sorry, just kidding.) My previous programming experience was with BASIC--and I think it is true that BASIC will, in many ways, rot your brain. So will Java. I learned programming with Hypertalk (MacIntosh's Hypercard scripting language, which more or less gave birth to AppleTalk), then RealBasic (Mac's Better VB-like), then VB, then Java, then C, then bits of Pascal, then Python, and this is where I started to see the light. But I had hard time unlearning all those java-ish anal-retentive stupidities and arbitrary overcomplexifications before I really enjoyed Python. Playing with Lisp (Common Lisp and Scheme) and Smalltalk helped getting rid of mental pollution wrt/ declarative static typing. To be honest, playing with Haskell and O'Caml also helped me understanding that static typing is not necessarily bad by itself. I had used QBasic and, later, a little VBA and some PHP. It took some time to unlearn some bad things (object orientation in VBA seems to be mostly a hack, for example, while PHP seems to be a big hack generally) Well... this is not exactly a scoop !-) but it seems to me that Python helped me learn my first modern programming language. I think Python is not used in university programs very much. Look for one that uses SICP (Scheme) or CTM (Mozart/Oz) or a functional language like Haskell, in preference to the ones that use Java (the Cobol of the 1990's). With some reasonable experience in Scheme or Mozart or Haskell, plus a Python manual, you'll be well on your way. I had heard of these languages, but learning them is a bit discouraging because (Java excepted) they don't seem to get much practical use. Before considering practical use (FWIW, Python was pretty far from mainstream 7 year ago), you should ask yourself how learning one of these languages will affect the way you thing about programming. While mostly in the imperative/OO camp, Python stole quite a lot from functional languages, and this is obviously a GoodThing(tm). My 2 cents -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Simple question about logging module.
Hullo, I have started to use Python's logging, and got a problem. I have created some loggers and wrote some lines in the log. The problem is, that most of the lines appear doubled in the log, and some lines do not appear at all. Any ideas or comments are wellcome, Gabor Here is the code: import sys import logging l = logging.getLogger('XmlTester') handler = logging.StreamHandler(sys.stderr) l.addHandler(handler) formatter = logging.Formatter(%(name)s %(asctime)s %(filename)s %(lineno)d %(levelname)s %(message)s) handler.setFormatter(formatter) la = logging.getLogger('XmlTester.XmlParser') handler = logging.StreamHandler(sys.stderr) la.addHandler(handler) handler.setFormatter(formatter) lb = logging.getLogger('XmlTester.TestExecutor') handler = logging.StreamHandler(sys.stderr) lb.addHandler(handler) handler.setFormatter(formatter) l.setLevel(logging.DEBUG) la.setLevel(logging.DEBUG) lb.setLevel(logging.DEBUG) l.debug(Start) la.debug(Start la) lb.debug(This debug) lb.info(This started.) l.info(Info written) l.warning(This is a warning) l.error(Error occured) test = Info.pck la.info(Hi there!) la.critical(No file named '%s'%test) l.critical(End of all) Here is the output: XmlTester.XmlParser 2007-07-31 10:34:12,303 plogtest.py 21 DEBUG Start la XmlTester.XmlParser 2007-07-31 10:34:12,303 plogtest.py 21 DEBUG Start la XmlTester.TestExecutor 2007-07-31 10:34:12,319 plogtest.py 22 DEBUG This debug XmlTester.TestExecutor 2007-07-31 10:34:12,319 plogtest.py 22 DEBUG This debug XmlTester.TestExecutor 2007-07-31 10:34:12,319 plogtest.py 23 INFO This started. XmlTester.TestExecutor 2007-07-31 10:34:12,319 plogtest.py 23 INFO This started. XmlTester.XmlParser 2007-07-31 10:34:12,319 plogtest.py 28 INFO Hi there! XmlTester.XmlParser 2007-07-31 10:34:12,319 plogtest.py 28 INFO Hi there! XmlTester.XmlParser 2007-07-31 10:34:12,319 plogtest.py 29 CRITICAL No file named 'Info.pck' XmlTester.XmlParser 2007-07-31 10:34:12,319 plogtest.py 29 CRITICAL No file named 'Info.pck' XmlTester 2007-07-31 10:34:12,319 plogtest.py 30 CRITICAL End of all -- http://mail.python.org/mailman/listinfo/python-list
Re: File handle not being released by close
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: [ ... ] for fileName in fileNames: fileBeginning = os.path.splitext(fileName)[0] fileEnd = os.path.splitext(fileName)[1] if fileEnd == .py: print fileName f=open(fileBeginning+.tmp, 'w') f.write(Hello) f.close f.close() Gary Duzan Motorola CHS -- http://mail.python.org/mailman/listinfo/python-list
simple string backspace question
Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
[EMAIL PROTECTED] wrote: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? [EMAIL PROTECTED] ~ % python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type help, copyright, credits or license for more information. text=Hello\bworld print text Hellworld What system are u using? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On 31 srp, 11:44, [EMAIL PROTECTED] wrote: Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran Hi, If you mean on operating system then unfortunately Windows XP. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
[EMAIL PROTECTED] wrote: If you mean on operating system then unfortunately Windows XP. I don't know for sure but maybe it doesn't support all ASCII escapes codes. Why do you care about \b anyway :-) ? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On 31 srp, 12:03, [EMAIL PROTECTED] (Lawrence Oluyede) wrote: [EMAIL PROTECTED] wrote: If you mean on operating system then unfortunately Windows XP. I don't know for sure but maybe it doesn't support all ASCII escapes codes. Why do you care about \b anyway :-) ? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair Hi, I need this inevitable for my programming language, for code indentation. I don't know how to write script with module tokenize for code indentation. Regards, Vedran -- http://mail.python.org/mailman/listinfo/python-list
Re: win32 question in Python
On Jul 30, 11:49 pm, Brad Johnson [EMAIL PROTECTED] wrote: Huang, Shun-Hsien shuang at ercot.com writes: but how do I copy a excel file into database table by using Python? I'm not sure if this helps, but you can access the Excel Automation model very easily with: import win32com.client x1 = client.Dispatch(Excel.Application) Now you can use the x1 object to access any of the properties and methods in the Excel Automation model. I have only used this to export data as Excel, but it may fulfill your needs for importing: http://sourceforge.net/projects/pyexcelerator/ Ali -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
[EMAIL PROTECTED] wrote: On 31 srp, 12:03, [EMAIL PROTECTED] (Lawrence Oluyede) wrote: [EMAIL PROTECTED] wrote: If you mean on operating system then unfortunately Windows XP. I don't know for sure but maybe it doesn't support all ASCII escapes codes. Why do you care about \b anyway :-) ? -- Lawrence, oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair Hi, I need this inevitable for my programming language, for code indentation. I don't know how to write script with module tokenize for code indentation. Still not giving up reinventing the wheel? You should take some lessons on syntax analysis before attempting this. But I know this words won't be heard... So, to your actual problem: that backspace is removing a character is something an editor or a terminal do, because they interpret the backspace. You wouldn't expect the string font color=bluefoo/font to be rendered blue by magic as well, wouldn't you? So what you need to do is: search the string for backspaces, and remove the BS as well as the character before. Something along these lines (untested): teststring = abc\bcde\b while teststring.find(\b) -1: pos = teststring.find(\b) teststring = teststring[:pos-1] + teststring[pos+1:] Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple question about logging module.
Gabor Urban [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: --=_Part_36089_18686793.1185871599583 Hullo, I have started to use Python's logging, and got a problem. I have created some loggers and wrote some lines in the log. The problem is, that most of the lines appear doubled in the log, and some lines do not appear at all. Any ideas or comments are wellcome, Gabor Here is the code: import sys import logging l = logging.getLogger('XmlTester') la = logging.getLogger('XmlTester.XmlParser') lb = logging.getLogger('XmlTester.TestExecutor') I other worlds, loggers are hierarchical, and so XmlTester.XmlParser may be a child of XmlTester and so inheriting some of the properties of its parent. bests, ./alex -- .w( the_mindstorm )p. -- http://mail.python.org/mailman/listinfo/python-list
interaction of 'with' and 'yield'
I'm wondering if a generator that is within a 'with' scope exits the 'with' when it encounters 'yield'. I would like to use a generator to implement RAII without having to syntactically enclose the code in the 'with' scope, and I am hoping that the the yield does not exit the 'with' scope and release the resource. -- http://mail.python.org/mailman/listinfo/python-list
Re: problems with logging module
You are not going beyond basicConfig - I'd write the above as: Intentionally didn't go beyond basicConfig. The problem is global level configuration vs. easy local (in function or in class) configuration. logging.basicConfig(...) def __init__(self, x): self.x = x self.log = logging.getLogger(a.nice.name) If you *do* need more than a handler, or different formatters for different loggers, then you must write your own setup anyway; perhaps using logging.config files, or perhaps writing your own code. I can't think of a simple and generic approach (beyond what basicConfig provides) but if you can write something that other people find useful, feel free to submit a patch. Why not indeed... let's see what happens. AK -- http://mail.python.org/mailman/listinfo/python-list
Re: interaction of 'with' and 'yield'
On Tue, 31 Jul 2007 07:34:09 -0400, Neal Becker [EMAIL PROTECTED] wrote: I'm wondering if a generator that is within a 'with' scope exits the 'with' when it encounters 'yield'. I would like to use a generator to implement RAII without having to syntactically enclose the code in the 'with' scope, and I am hoping that the the yield does not exit the 'with' scope and release the resource. It doesn't. Keep in mind that if the generator isn't resumed or garbage collected, the cleanup with never run, though. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Plotting Images
Hi ALL: I have only been switched from matlab to python few months ago. I having trouble of plotting images from a matrix size of 8x1 (unfortunately that is the size of my data.) for example, x = rand(8,1) inshow(x) I have tried to use matplotlib function imshow(), but all i get is a long thin line (unable to see the color display and the my matrix information). i think imshow() has the same problem in matlab, but i think there is a alternative in matlab, imagesc(). I did search on web about plt.imagesc().but when i try to run the example code, python just tell me cannot find module plt. from scipy import plt ImportError: cannot import name plt I have installed scipy, wxpython2.6and it still seem not to work! is there some alternitive? or what have i done wrong? Thank you Pei 想及時通知通訊錄裡的所有親朋好友好消息,就來 Yahoo!奇摩電子信箱發簡訊! http://tw.mobile.yahoo.com/texts/mail.php -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the functional way of doing this?
Considering I am a beginner I did a little test. Funny results too. The function I proposed (lists1.py) took 11.4529998302 seconds, while the other one (lists2.py) took 16.141324 seconds, thats about 40% more. They were run in IDLE from their own windows (F5). Of course my little test may me wrong (just started with this language), in which case I would appreciate any corrections, or comments. lists1.py : def f(n): if n 0: return ([n%26] + f(n/26)) else: return [] import time start = time.time() for x in range(1,100): f(21) end = time.time() print end - start --- lists2.py : def f(n): def mseq(n): while n 0: n,a = divmod(n, 26) yield a return list(mseq(n)) import time start = time.time() for x in range(1,100): f(21) end = time.time() print end - start -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On Jul 31, 8:01 pm, [EMAIL PROTECTED] wrote: On 31 srp, 11:44, [EMAIL PROTECTED] wrote: Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran Hi, If you mean on operating system then unfortunately Windows XP. Point (1) Works on Windows XP for me: C:\junkver Microsoft Windows XP [Version 5.1.2600] C:\junk\python25\python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. text = Hello\bworld print text Hellworld or, for mild amusement: import sys, time for x in xrange(100): ... sys.stdout.write(|/-\\[x 3] + \b) ... time.sleep(0.1) ... Point (2): Backspace??? YAGNI --- backspace hasn't been much use for anything (except when typing text) since the days when in order to get a bold letter (say X) on a character impact printer, one would transmit X\bX\bX ... -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On Jul 31, 7:17 am, John Machin [EMAIL PROTECTED] wrote: On Jul 31, 8:01 pm, [EMAIL PROTECTED] wrote: On 31 srp, 11:44, [EMAIL PROTECTED] wrote: Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran Hi, If you mean on operating system then unfortunately Windows XP. Point (1) Works on Windows XP for me: C:\junkver Microsoft Windows XP [Version 5.1.2600] C:\junk\python25\python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. text = Hello\bworld print text Hellworld or, for mild amusement: import sys, time for x in xrange(100): ... sys.stdout.write(|/-\\[x 3] + \b) ... time.sleep(0.1) ... Now try it on IDLE. Point (2): Backspace??? YAGNI --- backspace hasn't been much use for anything (except when typing text) since the days when in order to get a bold letter (say X) on a character impact printer, one would transmit X\bX\bX ... -- http://mail.python.org/mailman/listinfo/python-list
Nasm_with_C++_with_Python
I am wanting to write a library in nasm and call it from python. Because python can call c++ libraries. And nasm can be used in c++. So I was wondering how I would go about using nasm in python? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pysqlite storing file as blob example
On Tue, 2007-07-31 at 00:13 -0700, 7stud wrote: On Jul 30, 6:25 pm, [EMAIL PROTECTED] wrote: I'm trying to store binary data in a sqlite database and call into the db using pysqlite 3. What I've got so far is this: import sqlite con = sqlite.connect(DB_PATH) cur = con.cursor() query = create table t1( ID INTEGER PRIMARY KEY, dataBLOB ); cur.execute(query) con.commit() b = buffer('/path/to/binary/file') buffer() ? Using buffer is not in itself wrong, as some DB-API modules, including sqlite3, do use buffer objects to encapsulate binary data. However, the encapsulation should be called in a portable way by using the standard Binary factory function: b = sqlite3.Binary(contents). What is wrong, though, is passing the filename into it instead of the contents. This is in addition to the wrong execute call and using the wrong version of the sqlite module, as I pointed out in my previous reply. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Why no maintained wrapper to Win32?
Gilles Ganault a écrit : On Sun, 29 Jul 2007 06:40:35 +0200, Martin v. Löwis [EMAIL PROTECTED] wrote: Why do you say that the Win32 API lacks documentation? I find the documentation at msdn.microsoft.com to be quite useful. No, I meant documentation on how to write Win32 apps using PyWin. Yes, there haven't been many changes to Win32 in recent years (there haven't been many system releases in the first place). Most additions did not concern GUI programming, which is what you were after, and even those that are recent additions are rather rarely needed, so you likely won't miss them. Makes sense. Do you know of good places to hang around when looking for information on writing Win32-based GUI apps in Pythons For the Win32 part, there's a dedicated newsgroup in the comp.* hierarchy (sorry, can't remember the exact name, but you shouldn't have problems finding it). For the Python part, I'd say you're at the right place. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why no maintained wrapper to Win32?
Gilles Ganault a écrit : On Sun, 29 Jul 2007 21:49:04 -0700, sturlamolden [EMAIL PROTECTED] wrote: Why inflict suffering on yourself with MFC when you can use wxPython or PyGTK? Because I'd like to avoid having to pack several MB + having to install the toolkit. Considering the size of the typical Python script, it seemed overkill. Sure, you could use ctypes to make calls into user32.dll, gdi32.dll and kernel32.dll. Then you can program Python GUIs using the plain Win32 API, avoiding PyWin32's MFC or wxPython. But who would do such a thing? So the PyWin32 interface doesn't make it easier to program Win32 GUI apps? Did you ever tried writing a Win32 GUI app in C ?-) But you should re-read the above more carefully. What I do understand from it is that PyWin32 adds support for the MFC toolkit (nb: didn't check myself since I'm not concerned...). It's just C that looks like Python? Guess I have the answer as to no one seems to write GUI apps for Windows natively :-) Fact is that either the app is a small, casual tool, and then Tkinter is quite enough, or it's a real, fullblown app and then better to use a decent (and, if possible, crossplatform) toolkit - like, you know, wxWidgets !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string backspace question
On Jul 31, 10:33 pm, Dustan [EMAIL PROTECTED] wrote: On Jul 31, 7:17 am, John Machin [EMAIL PROTECTED] wrote: On Jul 31, 8:01 pm, [EMAIL PROTECTED] wrote: On 31 srp, 11:44, [EMAIL PROTECTED] wrote: Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld Should this character \b (backspace) in this text return this: Helloworld? Regards, Vedran Hi, If you mean on operating system then unfortunately Windows XP. Point (1) Works on Windows XP for me: C:\junkver Microsoft Windows XP [Version 5.1.2600] C:\junk\python25\python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. text = Hello\bworld print text Hellworld or, for mild amusement: import sys, time for x in xrange(100): ... sys.stdout.write(|/-\\[x 3] + \b) ... time.sleep(0.1) ... Now try it on IDLE. So the OP should have been slagging off at PythonWin and IDLE, not at Windows. -- http://mail.python.org/mailman/listinfo/python-list
create a toolbar + images using wxpython for windows
hi everery one I Need help on getting examles of how to create a toolbar with images using wxpython on a windows pc how can i add a toolbar to a GUI all sample codes i could find contain errors. i did the following but it is wrong! what is it with the IMAGES? do i have to create them, load them...? or they come with python like in Matlab thank you. import wx from pylab import* class MainWindow(wx.Frame): def __init__(self,parent,id,title): self.dirname='' wx.Frame.__init__(self,parent,wx.ID_ANY, title,wx.DefaultPosition, wx.Size(320,410)) ##___ADDING A TOOLBAR___## toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER) toolbar.AddSimpleTool(1, wx.Image('stock_new.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '') toolbar.Realize() Frame.Add(toolbar, 0, border=5) app = wx.PySimpleApp() frame = MainWindow(None, -1, dipole antenna ) frame.show(1) frame.SetBackgroundColour('light grey') app.MainLoop() __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.espanol.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Images
On Jul 31, 6:41 am, Pei-Yu CHAO [EMAIL PROTECTED] wrote: Hi ALL: I have only been switched from matlab to python few months ago. I having trouble of plotting images from a matrix size of 8x1 (unfortunately that is the size of my data.) for example, x = rand(8,1) inshow(x) I have tried to use matplotlib function imshow(), but all i get is a long thin line (unable to see the color display and the my matrix information). i think imshow() has the same problem in matlab, but i think there is a alternative in matlab, imagesc(). I did search on web about plt.imagesc().but when i try to run the example code, python just tell me cannot find module plt. from scipy import plt ImportError: cannot import name plt I have installed scipy, wxpython2.6and it still seem not to work! is there some alternitive? or what have i done wrong? Thank you Pei 想及時通知通訊錄裡的所有親朋好友好消息,就來 Yahoo!奇摩電子信箱發簡訊!http://tw.mobile.yahoo.com/texts/mail.php The wxPython mailing list would be the better place for this set of questions. I see them talking about this topic quite a bit. Here's a link to their list: http://www.wxpython.org/maillist.php Mike -- http://mail.python.org/mailman/listinfo/python-list
how to add a toolbar to a Frame using wxpython
hi please am learning wxpython and I Need help on getting examles of how to create a toolbar with images that is add a toolbar to a Frame using wxpython using wxpython on a windows pc how can i add a toolbar to a GUI all sample codes i could find contain errors. i did the following but it is wrong! my biggest trouble seems to be with the IMAGES? do i have to create them, load them...? or they come with python like in Matlab thank you. import wx from pylab import* class MainWindow(wx.Frame): def __init__(self,parent,id,title): self.dirname='' wx.Frame.__init__(self,parent,wx.ID_ANY, title,wx.DefaultPosition, wx.Size(320,410)) ##___ADDING A TOOLBAR___## toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER) toolbar.AddSimpleTool(1, wx.Image('stock_new.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '') toolbar.Realize() Frame.Add(toolbar, 0, border=5) app = wx.PySimpleApp() frame = MainWindow(None, -1, dipole antenna ) frame.show(1) frame.SetBackgroundColour('light grey') app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Directory
Rohan wrote: I would like to get a list of sub directories in a directory. If I use os.listdir i get a list of directories and files in that . i only want the list of directories in a directory and not the files in it. anyone has an idea regarding this. How far down do you want to go? All the way to the bottom: for root, dirs, files in os.walk('.'): for d in dirs: print os.path.join(root, d) Only your current directory: x = os.listdir('.') for item in x: if os.path.isdir(item): print item -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Images
Pei-Yu CHAO wrote: Hi ALL: I have only been switched from matlab to python few months ago. I having trouble of plotting images from a matrix size of 8x1 (unfortunately that is the size of my data.) for example, x = rand(8,1) inshow(x) I have tried to use matplotlib function imshow(), but all i get is a long thin line (unable to see the color display and the my matrix information). i think imshow() has the same problem in matlab, but i think there is a alternative in matlab, imagesc(). I did search on web about plt.imagesc().but when i try to run the example code, python just tell me cannot find module plt. from scipy import plt ImportError: cannot import name plt I have installed scipy, wxpython2.6and it still seem not to work! is there some alternitive? or what have i done wrong? Thank you Pei you might try wxPyPlot, this seems to be a very light weight and yet powerfull graph unit. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
get directory and file names
I am working with Python 2.5 on Windows XP (SP2). How can I traverse a folder, loop through a list of files and get their file name and extension in an elegant, pythonic way? Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: get directory and file names
On Tue, 31 Jul 2007 07:23:06 -0700, Alchemist wrote: I am working with Python 2.5 on Windows XP (SP2). How can I traverse a folder, loop through a list of files and get their file name and extension in an elegant, pythonic way? Take a look at the `os` and the `os.path` modules. In particular `os.listdir()`, `os.path.isfile()` and `os.path.splitext()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: get directory and file names
Alchemist a écrit : I am working with Python 2.5 on Windows XP (SP2). How can I traverse a folder, loop through a list of files and get their file name and extension in an elegant, pythonic way? http://docs.python.org/lib/module-os.path.html http://docs.python.org/lib/os-file-dir.html (= os.walk) -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Images
On Jul 31, 8:41 am, Pei-Yu CHAO [EMAIL PROTECTED] wrote: Hi ALL: I have only been switched from matlab to python few months ago. I having trouble of plotting images from a matrix size of 8x1 (unfortunately that is the size of my data.) for example, x = rand(8,1) inshow(x) I have tried to use matplotlib function imshow(), but all i get is a long thin line (unable to see the color display and the my matrix information). What is the screen size of your image? If it's scaled down so that the largest dimension is 1000px, then the smaller dimension will be reduced to 1px. Try breaking your image into various strips. HTH, Andr i think imshow() has the same problem in matlab, but i think there is a alternative in matlab, imagesc(). I did search on web about plt.imagesc().but when i try to run the example code, python just tell me cannot find module plt. from scipy import plt ImportError: cannot import name plt I have installed scipy, wxpython2.6and it still seem not to work! is there some alternitive? or what have i done wrong? Thank you Pei 想及時通知通訊錄裡的所有親朋好友好消息,就來 Yahoo!奇摩電子信箱發簡訊!http://tw.mobile.yahoo.com/texts/mail.php -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the functional way of doing this?
Kept testing (just in case). There was this other version of lists2.py (see below). So I created lists3.py and lists4.py. The resulting times are lists1.py : 11.4529998302 lists2.py : 16.141324 lists3.py : 3.1713134 lists4.py : 20.983676 lists3.py is by far the better time, but it does not generate a list but a generator object, as soon as you make it into a list (lists4.py) times go up (I don't know why do they go up that much). Apparently the way you use the conversion to a list, in the function(lists2.py) or in the loop (lists4.py), makes a big difference. Anyway lists1.py is still the best of the list generating times, and (in my view) the most elegant and easy to understand expression of the algorithm. lists1.py : def f(n): if n 0: return ([n%26] + f(n/26)) else: return [] import time start = time.time() for x in range(1,100): f(21) end = time.time() print end - start --- lists2.py : def f(n): def mseq(n): while n 0: n,a = divmod(n, 26) yield a return list(mseq(n)) import time start = time.time() for x in range(1,100): f(21) end = time.time() print end - start lists3.py def f(n): if n0: yield n%26 for i in f(n/26): yield i import time start = time.time() for x in range(1,100): f(21) end = time.time() print end - start lists4.py def f(n): if n0: yield n%26 for i in f(n/26): yield i import time start = time.time() for x in range(1,100): list(f(21)) end = time.time() print end - start -- http://mail.python.org/mailman/listinfo/python-list
Re: how to add a toolbar to a Frame using wxpython
On Jul 31, 8:24 am, yadin [EMAIL PROTECTED] wrote: hi please am learning wxpython and I Need help on getting examles of how to create a toolbar with images that is add a toolbar to a Frame using wxpython using wxpython on a windows pc how can i add a toolbar to a GUI all sample codes i could find contain errors. i did the following but it is wrong! my biggest trouble seems to be with the IMAGES? do i have to create them, load them...? or they come with python like in Matlab thank you. import wx from pylab import* class MainWindow(wx.Frame): def __init__(self,parent,id,title): self.dirname='' wx.Frame.__init__(self,parent,wx.ID_ANY, title,wx.DefaultPosition, wx.Size(320,410)) ##___ADDING A TOOLBAR___## toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER) toolbar.AddSimpleTool(1, wx.Image('stock_new.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '') toolbar.Realize() Frame.Add(toolbar, 0, border=5) app = wx.PySimpleApp() frame = MainWindow(None, -1, dipole antenna ) frame.show(1) frame.SetBackgroundColour('light grey') app.MainLoop() The internal pictures that I've found so far for wxPython are listed here: http://www.wxpython.org/docs/api/wx.ArtProvider-class.html If you need to create your own icons / bitmaps, I use the img2py utility included with wxPython. It's usage is below: code # on the command line in windows # You have to pass a filename in for img2py to sends its output to c:\Python24\Lib\site-packages\wx-2.8-msw-ansi\wx\toolspython img2py.py -i iconFileName iconPyFile.py /code Also see: http://www.wxpython.org/docs/api/wx.tools.img2py-module.html Then I just created a function to create my toolbar: code def createToolbar(self): toolbar = self.CreateToolBar() toolbar.SetToolBitmapSize((31,31)) bmp = mail_ico.getBitmap() sendTool = toolbar.AddSimpleTool(-1, bmp, 'Send', 'Sends Email') self.Bind(wx.EVT_MENU, self.OnSend, sendTool) toolbar.Realize() /code One caveat: I don't know how to force an image to scale to the size of the toolbar button. You'll have to figure that out on your own. You can also post to the wxPython list, which might give you more coherent answers: http://www.wxpython.org/maillist.php Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling 2.5.1 on OpenBSD 4.1
I don't have OpenBSD available, so I have to do all my research over the web. I would really appreciate if this problem could be solved for good. In the past, it was always difficult that the *BSDs would hide interfaces if I say that my program uses XOPEN/Unix. Python uses a POSIX+ approach: use POSIX interfaces where available; use platform-specific ones elsewhere. I'll be happy to test anything you want WRT OpenBSD. I have one here and I don't think it's going anywhere. I see. The macros _BSD_SOURCE didn't actually get defined. Please try the revised patch below. This looks to have fixed it. Build was succesful. Thanks! dnm -- http://mail.python.org/mailman/listinfo/python-list
Re: get directory and file names
Alchemist wrote: I am working with Python 2.5 on Windows XP (SP2). How can I traverse a folder, loop through a list of files and get their file name and extension in an elegant, pythonic way? Thank you. try this: for root, dirs, files in os.walk('.'): for f in files: print os.path.splitext(os.path.join(root,f)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Where do they tech Python officialy ?
NicolasG [EMAIL PROTECTED] wrote: ... The problem is that I would like to work as a Python programmer but all the job vacancies I can find requires a couple of years of professional experience ... that I don't have. How a wanna be programmer can start working as a programmer if there is no chance to start from somewhere ? That's the reason I created this topic. Open source projects do not require previous professional experience to accept volunteers. So, one way out of your dilemma is to make a name for yourself as an open source contributor -- help out with Python itself and/or with any of the many open source projects that use Python, and you will both learn a lot _and_ acquire professional experience that any enlightened employer will recognize as such. That will take a while, but not as long as getting a college degree (and it will be far cheaper than the degree). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading a two-column file into an array?
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Mon, 30 Jul 2007 21:57:17 -0700, Nagarajan wrote: a = [] import csv reader = csv.reader(open(filename, r), delimiter='\t' ) for row in reader: a.append( row ) I would keep a reference to the file to close it properly and the loop can be replaced by a call to `list()`: import csv def main(): data_file = open('filename', 'rb') a = list(csv.reader(data_file, delimiter='\t')) data_file.close() That's what 2.5's with statement is all about...: from __future__ import with_statement def main(): with open('filename', 'rb') as f: return list(csv.reader(f, delimiter='\t')) Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: From D
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: code files? What's the regular expression for locating a number with an arbitrary number of digits seperated into an arbitrary number of blocks of an arbitray number of digits with an arbitrary number of whitespace characters between each block? For a decimal integer (or octal) number, I'd use something similar to: r'\d[\d\s]+' This also gets trailing whitespace, but that shouldn't be much of a problem in most practical cases. Of course, just like today, it becomes a bit hairier if you also want to find hex, oct (to be 0o777 in the future), other future notations such as binary, floats, complex numbers, c:-) -- but the simple fact that a [\d\s] is accepted where today only a \d would be, per se, would not contribute to that hair in any significant way, it seems to me. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the functional way of doing this?
On Jul 30, 5:48 pm, beginner [EMAIL PROTECTED] wrote: Hi, If I have a number n and want to generate a list based on like the following: def f(n): l=[] while n0: l.append(n%26) n /=26 return l I am wondering what is the 'functional' way to do the same. Thanks, beginner I see. It is interesting (and not surprisingly) that recursion or yield are required. Thanks for everyone's help. -- http://mail.python.org/mailman/listinfo/python-list
standalone process to interact with the web
Hi Everyone, I am looking for a way to allow a standalone python process to easily interactive with a few web pages. It has to be able to easily receive requests from the web and post data to the web. I am thinking about implementing a standalone soap server, but I am not sure which library is good. Any suggestions? Thanks a lot, Geoffrey -- http://mail.python.org/mailman/listinfo/python-list
Re: standalone process to interact with the web
beginner wrote: Hi Everyone, I am looking for a way to allow a standalone python process to easily interactive with a few web pages. It has to be able to easily receive requests from the web and post data to the web. I am thinking about implementing a standalone soap server, but I am not sure which library is good. Any suggestions? Thanks a lot, Geoffrey Look nor further than mechanize - http://wwwsearch.sourceforge.net/mechanize/ With mechanize and its partner ClientForm you can rule the web world ;-) 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 --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Where do they tech Python officialy ?
On Jul 31, 11:37 am, [EMAIL PROTECTED] (Alex Martelli) wrote: NicolasG [EMAIL PROTECTED] wrote: ... The problem is that I would like to work as a Python programmer but all the job vacancies I can find requires a couple of years of professional experience ... that I don't have. How a wanna be programmer can start working as a programmer if there is no chance to start from somewhere ? That's the reason I created this topic. Open source projects do not require previous professional experience to accept volunteers. So, one way out of your dilemma is to make a name for yourself as an open source contributor -- help out with Python itself and/or with any of the many open source projects that use Python, and you will both learn a lot _and_ acquire professional experience that any enlightened employer will recognize as such. That will take a while, but not as long as getting a college degree (and it will be far cheaper than the degree). Alex Starting this Fall, Michigan State University's computer science department is moving to Python for its introductory courses. Student's following the ugrad curriculum will be exposed to both Python (early) and C++ (later). We feel this gives our students the best of both worlds: a high level scripting language that is easier to work with and provides many modules to do actual work, and an efficient, lower level language for speed and to interface with OS, graphics, networks etc. If you want more information, visit the dept. web pages at http://www.cse.msu.edu. However, and not suprisingly, things are out of date there and will probably not be up to date till the semester starts. So if you want something now, please send email to bill.punch AT gmail.com -- http://mail.python.org/mailman/listinfo/python-list
encode() question
s1 = hello s2 = s1.encode(utf-8) s1 = an accented 'e': \xc3\xa9 s2 = s1.encode(utf-8) The last line produces the error: --- Traceback (most recent call last): File test1.py, line 6, in ? s2 = s1.encode(utf-8) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128) --- The error is a decode error, and as far as I can tell, decoding happens when you convert a regular string to a unicode string. So, is there an implicit conversion taking place from s1 to a unicode string before encode() is called? By what mechanism? -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the functional way of doing this?
On Tue, 31 Jul 2007 09:01:42 -0300, Ricardo Aráoz wrote: Considering I am a beginner I did a little test. Funny results too. The function I proposed (lists1.py) took 11.4529998302 seconds, while the other one (lists2.py) took 16.141324 seconds, thats about 40% more. They were run in IDLE from their own windows (F5). [snip code] You may find that using the timeit module is better than rolling your own timer. def recursive_func(n): ... if n 0: ... return [n % 26] + recursive_func(n/26) ... else: ... return [] ... def generator_func(n): ... def mseq(n): ... while n 0: ... n, a = divmod(n, 26) ... yield a ... return list(mseq(n)) ... import timeit N = 10**6+1 timeit.Timer(recursive_func(N), ... from __main__ import N, recursive_func).repeat() [16.48972487449646, 17.000514984130859, 16.520529985427856] timeit.Timer(generator_func(N), ... from __main__ import N, generator_func).repeat() [27.938560009002686, 28.970781087875366, 23.977837085723877] If you're going to compare speeds, you should also test this one: def procedural_func(n): ... results = [] ... while n 0: ... n, a = divmod(n, 26) ... results.append(a) ... return results ... timeit.Timer(procedural_func(N), ... from __main__ import N, procedural_func).repeat() [15.577107906341553, 15.60145378112793, 15.345284938812256] I must admit that I'm surprised at how well the recursive version did, and how slow the generator-based version was. But I'd be careful about drawing grand conclusions about the general speed of recursion etc. in Python from this one single example. I think this is simply because the examples tried make so few recursive calls. Consider instead an example that makes a few more calls: N = 26**100 + 1 timeit.Timer(recursive_func(N), ... from __main__ import N, recursive_func).repeat(3, 1) [7.0015969276428223, 7.6065640449523926, 6.8495190143585205] timeit.Timer(generator_func(N), ... from __main__ import N, generator_func).repeat(3, 1) [3.5656340129, 3.1132731437683105, 3.8274538516998291] timeit.Timer(procedural_func(N), ... from __main__ import N, procedural_func).repeat(3, 1) [3.3509068489074707, 4.0872640609741211, 3.3742849826812744] -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: encode() question
En Tue, 31 Jul 2007 13:53:11 -0300, 7stud [EMAIL PROTECTED] escribió: s1 = hello s2 = s1.encode(utf-8) s1 = an accented 'e': \xc3\xa9 s2 = s1.encode(utf-8) The last line produces the error: --- Traceback (most recent call last): File test1.py, line 6, in ? s2 = s1.encode(utf-8) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128) --- The error is a decode error, and as far as I can tell, decoding happens when you convert a regular string to a unicode string. So, is there an implicit conversion taking place from s1 to a unicode string before encode() is called? By what mechanism? Converting from unicode characters into a string of bytes is the encode operation: unicode.encode() - str Converting from string of bytes to unicode characters is the decode operation: str.decode() - unicode str.decode and unicode.encode should NOT exist, or at least issue a warning (IMHO). When you try to do str.encode, as the encode operation requires an unicode source, the string is first decoded using the default encoding - and fails. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Encryption recommendation
Can someone help me find the proper way to do AES encryption/decryption using Python? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Error with Tkinter and tkMessageBox
hi all, this Tkinter very simple code work fine: ## from Tkinter import * win = Tk() win.mainloop() ## but if I try to open a message box, it happens: Exception in Tkinter callback Traceback (most recent call last): File lib-tk/Tkinter.py, line 1348, in __call__ return self.func(*args) File /home/fabio/Desktop/prova.py, line 5, in reply showinfo(title='ciao', message='hello') File lib-tk/tkMessageBox.py, line 84, in showinfo return _show(title, message, INFO, OK, **options) File lib-tk/tkMessageBox.py, line 75, in _show res = Message(**options).show() File lib-tk/tkCommonDialog.py, line 52, in show s = w.tk.call(self.command, *w._options(self.options)) TclError: bad pad value 2m: must be positive screen distance ## from Tkinter import * from tkMessageBox import * def reply(): showinfo(title='ciao', message='hello') win = Tk() but = Button(win, text='press me', command=reply) but.pack() win.mainloop() ## these are versions: python: 2.4.4 or 2.5.1 Tkinter.TclVersion: 8.4 Tkinter.TkVersion: 8.4 can anyone help me? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: encode() question
On Jul 31, 11:18 am, Gabriel Genellina [EMAIL PROTECTED] wrote: str.decode and unicode.encode should NOT exist, or at least issue a warning (IMHO). Yes, that sounds like a good idea. -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption recommendation
On Jul 31, 10:19 am, JS [EMAIL PROTECTED] wrote: Can someone help me find the proper way to do AES encryption/decryption using Python? Thanks! I did a quick look around the internet and found this seemingly good link AES in general. Might be a good start. http://msdn.microsoft.com/msdnmag/issues/03/11/AES/#S4 Looks like you'll need some matrix manipulations modules, and hopefully you'll be able to utilize Python's indexing and data strengths to keep things simple! -- http://mail.python.org/mailman/listinfo/python-list
Iteration over strings
Hi, I have the following code: str = C:/somepath/folder/file.txt for char in str: if char == \\: char = / The above doesn't modify the variable 'str' directly. I'm still pretty new to Python so if someone could explain to me why this isn't working and what I can do to achieve the same effect I would greatly appreciate it. -- http://mail.python.org/mailman/listinfo/python-list
Re: standalone process to interact with the web
Hi Steve, On Jul 31, 11:42 am, Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Everyone, I am looking for a way to allow a standalone python process to easily interactive with a few web pages. It has to be able to easily receive requests from the web and post data to the web. I am thinking about implementing a standalone soap server, but I am not sure which library is good. Any suggestions? Thanks a lot, Geoffrey Look nor further than mechanize - http://wwwsearch.sourceforge.net/mechanize/ With mechanize and its partner ClientForm you can rule the web world ;-) 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 --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - This seems to be an HTTP client library. It is very interesting, but is not what I need. I am looking for something that can provide service to web pages. For example, when a browser requests a web page, the web page is going to send a few requests to my server. My server then is going to respond, and the web page takes the response and format it in human readable form. -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption recommendation
JS [EMAIL PROTECTED] writes: Can someone help me find the proper way to do AES encryption/decryption using Python? http://google.com/search?q=AES+Python -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Robert Dailey wrote: Hi, I have the following code: str = C:/somepath/folder/file.txt for char in str: if char == \\: char = / The above doesn't modify the variable 'str' directly. I'm still pretty new to Python so if someone could explain to me why this isn't working and what I can do to achieve the same effect I would greatly appreciate it. Hi Robert, strings in Python are immutable - in other words, they cannot be updated in place as you're doing above. However, that doesn't mean you can't achieve what you're after. In Python, the way to approach this problem since you cannot modify the string in place, is to create a new string object with the desired content: str = C:/somepath/folder/file.txt newstr = for char in str: if char == \\: char = / newstr = newstr + char str = newstr Note that for this particular example, there are also better ways of acheiving your goal: str = C:/somepath/folder/file.txt str = str.replace(\\, /) HTH, -Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: standalone process to interact with the web
In article [EMAIL PROTECTED], Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Everyone, I am looking for a way to allow a standalone python process to easily interactive with a few web pages. It has to be able to easily receive requests from the web and post data to the web. I am thinking about implementing a standalone soap server, but I am not sure which library is good. Any suggestions? Thanks a lot, Geoffrey Look nor further than mechanize - http://wwwsearch.sourceforge.net/mechanize/ With mechanize and its partner ClientForm you can rule the web world ;-) . . . For a more narrative approach to the same point, I like to think that URL: http://www.unixreview.com/documents/s=10133/ur0706e/ helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: standalone process to interact with the web
beginner wrote: Hi Steve, On Jul 31, 11:42 am, Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Everyone, I am looking for a way to allow a standalone python process to easily interactive with a few web pages. It has to be able to easily receive requests from the web and post data to the web. I am thinking about implementing a standalone soap server, but I am not sure which library is good. Any suggestions? Thanks a lot, Geoffrey Look nor further than mechanize - http://wwwsearch.sourceforge.net/mechanize/ With mechanize and its partner ClientForm you can rule the web world ;-) 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 --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - This seems to be an HTTP client library. It is very interesting, but is not what I need. I am looking for something that can provide service to web pages. For example, when a browser requests a web page, the web page is going to send a few requests to my server. My server then is going to respond, and the web page takes the response and format it in human readable form. Well, surely in that case you can use any protocol you like. It's up to the web server and your web server server to agree how to communicate. Take a look at the SocketServer library, for example. regartds 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 --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Robert Dailey wrote: Hi, I have the following code: str = C:/somepath/folder/file.txt for char in str: if char == \\: char = / The above doesn't modify the variable 'str' directly. I'm still pretty new to Python so if someone could explain to me why this isn't working and what I can do to achieve the same effect I would greatly appreciate it. The thing that you need to remember is that strings in Python never change (and nothing ever changes that). Any time that you start out thinking I need to change this string' you need to immediately translate that thought into I need to create a new string with some changes made to this string. String objects can already do what you're trying to do here: str = C:\\somepath\\folder\\file.txt str 'C:\\somepath\\folder\\file.txt' str2 = str.replace('\\', '/') str2 'C:/somepath/folder/file.txt' str 'C:\\somepath\\folder\\file.txt' replace() returns a new string with all instances of the 1st subsstring replaced with the second substring -- note that the original string 'str' is unmodified. Also note that if this is your actual use case, the standard lib also contains a function os.path.normpath() that does all the correct manipulations to correctly normalize file paths on the current platform. -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Jay Loden schrieb: Robert Dailey wrote: str = C:/somepath/folder/file.txt for char in str: if char == \\: char = / strings in Python are immutable - in other words, they cannot be updated in place as you're doing above. However, that doesn't mean you can't achieve what you're after. In Python, the way to approach this problem since you cannot modify the string in place, is to create a new string object with the desired content: Also note, that you are just extracting one char from the string into another variable (which you then change) and you are *not* getting any reference to the char in the string. As has been alreagy told, use the str.replace() function -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption recommendation
Azazello wrote: On Jul 31, 10:19 am, JS [EMAIL PROTECTED] wrote: Can someone help me find the proper way to do AES encryption/decryption using Python? Thanks! I did a quick look around the internet and found this seemingly good link AES in general. Might be a good start. http://msdn.microsoft.com/msdnmag/issues/03/11/AES/#S4 Looks like you'll need some matrix manipulations modules, and hopefully you'll be able to utilize Python's indexing and data strengths to keep things simple! Or you might use PyCrypto (http://python.codezoo.com/pub/component/5284) which might be easier. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the functional way of doing this?
Steven D'Aprano wrote: On Tue, 31 Jul 2007 09:01:42 -0300, Ricardo Aráoz wrote: Considering I am a beginner I did a little test. Funny results too. The function I proposed (lists1.py) took 11.4529998302 seconds, while the other one (lists2.py) took 16.141324 seconds, thats about 40% more. They were run in IDLE from their own windows (F5). [snip code] You may find that using the timeit module is better than rolling your own timer. def recursive_func(n): ... if n 0: ... return [n % 26] + recursive_func(n/26) ... else: ... return [] ... def generator_func(n): ... def mseq(n): ... while n 0: ... n, a = divmod(n, 26) ... yield a ... return list(mseq(n)) ... import timeit N = 10**6+1 timeit.Timer(recursive_func(N), ... from __main__ import N, recursive_func).repeat() [16.48972487449646, 17.000514984130859, 16.520529985427856] timeit.Timer(generator_func(N), ... from __main__ import N, generator_func).repeat() [27.938560009002686, 28.970781087875366, 23.977837085723877] If you're going to compare speeds, you should also test this one: def procedural_func(n): ... results = [] ... while n 0: ... n, a = divmod(n, 26) ... results.append(a) ... return results ... timeit.Timer(procedural_func(N), ... from __main__ import N, procedural_func).repeat() [15.577107906341553, 15.60145378112793, 15.345284938812256] I must admit that I'm surprised at how well the recursive version did, and how slow the generator-based version was. But I'd be careful about drawing grand conclusions about the general speed of recursion etc. in Python from this one single example. I think this is simply because the examples tried make so few recursive calls. Consider instead an example that makes a few more calls: N = 26**100 + 1 timeit.Timer(recursive_func(N), ... from __main__ import N, recursive_func).repeat(3, 1) [7.0015969276428223, 7.6065640449523926, 6.8495190143585205] timeit.Timer(generator_func(N), ... from __main__ import N, generator_func).repeat(3, 1) [3.5656340129, 3.1132731437683105, 3.8274538516998291] timeit.Timer(procedural_func(N), ... from __main__ import N, procedural_func).repeat(3, 1) [3.3509068489074707, 4.0872640609741211, 3.3742849826812744] Yup! As soon as the size of the list increases the generator function gets better (50% in my tests). But it's interesting to note that if the list is within certain limits (I've tested integers (i.e. 2,100,000,000 = 7 member list)) and you only vary the times the funct. is called then the recursive one does better. -- http://mail.python.org/mailman/listinfo/python-list
With Statement Contexts and Context Managers
Hi, Could somebody please point me to a good resource to read about the contexts, context managers, and with_statement Best Rgd, G. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where do they tech Python officialy ?
In article [EMAIL PROTECTED], Alex Martelli [EMAIL PROTECTED] wrote: Open source projects do not require previous professional experience to accept volunteers. So, one way out of your dilemma is to make a name for yourself as an open source contributor -- help out with Python itself and/or with any of the many open source projects that use Python, and you will both learn a lot _and_ acquire professional experience that any enlightened employer will recognize as such. That will take a while, but not as long as getting a college degree (and it will be far cheaper than the degree). Ayup. My current job didn't even bother asking for references, largely because my boss knew me from the Python community. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ This is Python. We don't care much about theory, except where it intersects with useful practice. -- http://mail.python.org/mailman/listinfo/python-list
Re: standalone process to interact with the web
On Jul 31, 1:11 pm, Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Steve, On Jul 31, 11:42 am, Steve Holden [EMAIL PROTECTED] wrote: beginner wrote: Hi Everyone, I am looking for a way to allow a standalone python process to easily interactive with a few web pages. It has to be able to easily receive requests from the web and post data to the web. I am thinking about implementing a standalone soap server, but I am not sure which library is good. Any suggestions? Thanks a lot, Geoffrey Look nor further than mechanize - http://wwwsearch.sourceforge.net/mechanize/ With mechanize and its partner ClientForm you can rule the web world ;-) 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 --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - This seems to be an HTTP client library. It is very interesting, but is not what I need. I am looking for something that can provide service to web pages. For example, when a browser requests a web page, the web page is going to send a few requests to my server. My server then is going to respond, and the web page takes the response and format it in human readable form. Well, surely in that case you can use any protocol you like. It's up to the web server and your web server server to agree how to communicate. Take a look at the SocketServer library, for example. regartds 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 --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading -- Hide quoted text - - Show quoted text - Yes exactly. I just don't want to reinvent the wheel as I imagine there are already tons of libraries and frameworks that support RPC or the like functions. Thanks, Geoffrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Error with Tkinter and tkMessageBox
On Jul 31, 12:30 pm, Fabio Z Tessitore [EMAIL PROTECTED] wrote: hi all, this Tkinter very simple code work fine: ## from Tkinter import * win = Tk() win.mainloop() ## but if I try to open a message box, it happens: Exception in Tkinter callback Traceback (most recent call last): File lib-tk/Tkinter.py, line 1348, in __call__ return self.func(*args) File /home/fabio/Desktop/prova.py, line 5, in reply showinfo(title='ciao', message='hello') File lib-tk/tkMessageBox.py, line 84, in showinfo return _show(title, message, INFO, OK, **options) File lib-tk/tkMessageBox.py, line 75, in _show res = Message(**options).show() File lib-tk/tkCommonDialog.py, line 52, in show s = w.tk.call(self.command, *w._options(self.options)) TclError: bad pad value 2m: must be positive screen distance ## from Tkinter import * from tkMessageBox import * def reply(): showinfo(title='ciao', message='hello') win = Tk() but = Button(win, text='press me', command=reply) but.pack() win.mainloop() ## these are versions: python: 2.4.4 or 2.5.1 Tkinter.TclVersion: 8.4 Tkinter.TkVersion: 8.4 can anyone help me? thanks I'm not sure, but I don't think you need the win variable at all. I can get it to work as follows: code from Tkinter import * from tkMessageBox import showinfo def reply(): showinfo(title='ciao', message='hello') Button(text='press me', command=reply).pack(fill=X) mainloop() /code Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Images
Pei-Yu CHAO wrote: Hi ALL: I have only been switched from matlab to python few months ago. I having trouble of plotting images from a matrix size of 8x1 (unfortunately that is the size of my data.) for example, x = rand(8,1) inshow(x) Read the docstrings, they explain how to use the function: imshow(x,aspect=300) gives a reasonable size to look at such a thin matrix, after you widen the window a fair bit. Cheers, f -- http://mail.python.org/mailman/listinfo/python-list
Re: Error with Tkinter and tkMessageBox
Il Tue, 31 Jul 2007 19:12:48 +, kyosohma ha scritto: I'm not sure, but I don't think you need the win variable at all. I can get it to work as follows: code from Tkinter import * from tkMessageBox import showinfo def reply(): showinfo(title='ciao', message='hello') Button(text='press me', command=reply).pack(fill=X) mainloop() /code Mike You're right. But the problem I have is always there. Tkinter doesn't work properly and I don't understand why. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Wing IDE for Python v. 3.0 beta1 released
Hi, I'm happy to announce the first beta release of Wing IDE 3.0. It is available from http://wingware.com/wingide/beta Wing IDE is a commercial IDE designed specifically for Python programmers. More information about the product and free trials are available at http://wingware.com/ The major new features introduced in Wing 3.0 are: * Multi-threaded debugger * Debug value tooltips in editor, debug probe, and interactive shell * Autocompletion in debug probe and interactive shell * Automatically updating project directories * Testing tool, currently supporting unittest derived tests (*) * OS Commands tool for executing and interacting with external commands (*) * Rewritten indentation analysis and conversion (*)'d items are available in Wing IDE Professional only. The CHANGELOG.txt file in the installation provides additional details. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Reporting Bugs -- Please report bugs using the Submit Bug Report item in the Help menu or by emailing support at wingware dot com. This is beta quality software that installs side-by-side with Wing 2.x or 1.x. We advise you to make frequent backups of your work when using any pre-release version of Wing IDE. Upgrading - To upgrade a 2.x license or purchase a new 3.x license: Upgradehttps://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 normal price to upgrade. Thanks! The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple question about logging module.
Thx guys You gave me good ideas. At the moment I do not have time for it, but I would like to write a summary. Have fun -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption recommendation
JS wrote: Can someone help me find the proper way to do AES encryption/decryption using Python? Thanks! Use pycrypto. You can roll it into a standalone program for any major OS. See http://passerby.sf.net. Don't attempt to write your own AES implementation for production software. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: With Statement Contexts and Context Managers
On Tue, 2007-07-31 at 14:57 -0400, G wrote: Hi, Could somebody please point me to a good resource to read about the contexts, context managers, and with_statement There's PEP 343 at http://www.python.org/dev/peps/pep-0343/. I don't know if that fits your definition of good, but it should at least get you started. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: encode() question
On Tue, 31 Jul 2007 10:45:26 -0700, 7stud wrote: On Jul 31, 11:18 am, Gabriel Genellina [EMAIL PROTECTED] wrote: str.decode and unicode.encode should NOT exist, or at least issue a warning (IMHO). Yes, that sounds like a good idea. It sounds like horrible idea as those are the ones that are really needed. One could argue about `str.encode` and `unicode.decode`. But there are at least uses for `str.encode` like 'sting-escape', 'hex', 'bz2', 'base64' etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Creating a shared object in python
Is there a way to create a shared object in python? Thx, Edgar -- http://mail.python.org/mailman/listinfo/python-list
Re: Why no maintained wrapper to Win32?
On Jul 31, 4:35 am, Gilles Ganault [EMAIL PROTECTED] wrote: Because I'd like to avoid having to pack several MB + having to install the toolkit. Considering the size of the typical Python script, it seemed overkill. But you are happy to pack a Python runtime and PyWin32? This is really a dumb argument. Sure, you could use ctypes to make calls into user32.dll, gdi32.dll and kernel32.dll. Then you can program Python GUIs using the plain Win32 API, avoiding PyWin32's MFC or wxPython. But who would do such a thing? So the PyWin32 interface doesn't make it easier to program Win32 GUI apps? It's just C that looks like Python? PyWin32 wraps MFC, which is a C++ library for Windows (and Motif) GUI programming. It is not more 'native' than wxPython. MFC and wxWidgets does the same job, except that wxWidgets does it better. PyWin32 does not expose the GUI parts of the 'native' Win32 API directly. You will have to use ctypes to access that directly. Guess I have the answer as to no one seems to write GUI apps for Windows natively :-) wxPyhton is 'native' enough. Is uses native widgets on Windows (unlike Qt, GTK and tk). -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a shared object in python
On Jul 31, 2:37 pm, Delgado, Edgardo CIV NAVAIR 4.1.4.3 [EMAIL PROTECTED] wrote: Is there a way to create a shared object in python? Thx, Edgar You can save variables in a separate module. Something like this structure works quite well: code # shared.py # shared variables / object someNum = 0 /code code # first module import shared x = shared.someNum # do something x = 5 /code code # second module import shared y = shared.someNum /code Basically as the code is called, be it a dialog from a main gui or whatever, it updates this variable that is kind of held out there in memory. Thus, it is available for and other running modules that import it. It's kind of hard to get your mind around at first, but I've used it before for some cool programming magic. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: zip() function troubles
Chris Mellon [EMAIL PROTECTED] writes: Better hand in your computer, then. You're never going to find a situation where the environment won't affect the running time of your algorithms. The environment may affect the running time by an additive or linear multiplicative constant but it should never turn an O(n) algorithm into an O(n**2) one. For the record, the python GC is generational. This is a case of a default heuristic giving pathological behavior in a corner case, not anything broken about the design of the python GC. No, it is broken, per discussion on a comp.compilers/comp.lang.functional thread this week. The notion of using a generational collector was to collect less and less frequently for older and older generations (e.g. doubling the amount of allocation between generations) but the usual solution is apparently to increase the heap size by some multiplicative factor when GC fails to free enough memory. -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Hey, Thanks a lot for your answers guys. I had already known that strings are immutable, but having been a C++ programmer for years I'm still trying to get over the fact that it's not std::string :) The python documentation isn't that easy to navigate in my opinion, so I wasn't able to find the 'replace()' function you guys are talking about. It's actually the perfect solution for the problem. I appreciate your time. On 7/31/07, Hexamorph [EMAIL PROTECTED] wrote: Jay Loden schrieb: Robert Dailey wrote: str = C:/somepath/folder/file.txt for char in str: if char == \\: char = / strings in Python are immutable - in other words, they cannot be updated in place as you're doing above. However, that doesn't mean you can't achieve what you're after. In Python, the way to approach this problem since you cannot modify the string in place, is to create a new string object with the desired content: Also note, that you are just extracting one char from the string into another variable (which you then change) and you are *not* getting any reference to the char in the string. As has been alreagy told, use the str.replace() function -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
MailingLogger 3.2.0 Released!
With help from Jens Vagelpohl, I'm pleased to announce a new release of Mailinglogger that now supports filtering of log entries... Mailinglogger enables log entries to be emailed either as the entries are logged or as a summary at the end of the running process. This pair of enhanced emailing handlers for the python logging framework is now available as a standard python package and as an egg. The handlers have the following features: - customisable and dynamic subject lines for emails sent - emails sent with an X-Mailer header for easy filtering - flood protection to ensure the number of emails sent is not excessive - support for SMTP servers that require authentication - fully documented and tested In addition, extra support is provided for configuring the handlers when using ZConfig, Zope 2 or Zope 3. Installation is as easy as: easy_install mailinglogger For more information, please see: http://www.simplistix.co.uk/software/python/mailinglogger cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
◘ Legally Access FREE Satellite TV on PC ◘
Turn your Computer into a Ultimate TV • Watch all your favorite shows on your Computer TV! • Channels you can’t get any other place in the U.S.A! • Watch from anywhere in the world! • Save 1000's of $$$ over many years on cable and satellite bills • INSTANT DOWNLOAD • And much, much more! For More Details: http://tvonpc.7p.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a shared object in python
Il Tue, 31 Jul 2007 15:37:26 -0400, Delgado, Edgardo CIV NAVAIR 4.1.4.3 ha scritto: Is there a way to create a shared object in python? Thx, Edgar Usually object are shared in Python. i.e. # a list l = [ 1 , 2 , 3 ] # a list containing l m = [ l, 4, 5 ] # now m is [ [1,2,3] , 4 , 5 ] # ok, let's change l l[0] = 10 # now m is changed # NOW m is [ [10,2,3] , 4 , 5 ] -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Robert Dailey wrote: Hey, Thanks a lot for your answers guys. I had already known that strings are immutable, but having been a C++ programmer for years I'm still trying to get over the fact that it's not std::string :) The python documentation isn't that easy to navigate in my opinion, so I wasn't able to find the 'replace()' function you guys are talking about. It's actually the perfect solution for the problem. I appreciate your time. I have to agree with you WRT to the Python documentation, it does tend to be lacking and difficult to find things at times. In this case the two ways I can think of to look for something like this would have been: pydoc string which lists the replace() method in the documentation for the string module, or to search Google for it. There are a lot of code samples out there for Python such as the online Python Cookbook: http://aspn.activestate.com/ASPN/Python/Cookbook/ I also highly recommend Python in Nutshell, the Python Cookbook, or Programming Python (all O'Reilly books). Programming Python is a huge tome but like all O'Reilly books in the Programming X series, it is aimed at someone who's not necessarily new to programming but is new to the language. That in combination with lots of code samples might be best for you since you're familiar with programming and it's language specifics you need references for. I'm sure there are other great books, those just happen to be the ones I'm familiar with :-) -Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Process Control Help
Azazello wrote: We're looking to run some industrial machinery from a PC. Starting with some basic servo controls and IO port reading for something like an XYZ table (just X would be a good start!). Now there is some existing software out there for PC control but this software is, to my understanding, largely unnecessary and black box. This black box creates a problem when trying to e.g. control servos and IO with the same program. And if we want to include an HMI like a touchscreen, or export the machinery's production into a RSS feed, the web of software becomes messy and slow. Soo I need to find some ethernet friendly IO, serial would be fine but but it's a leash in many instances. I know some protocols have been ported to ethernet, but I am having extreme difficulty figuring out what these protocols entail. ModBus/TCP is the one I'd like to choose. I know that people have done this kind of software but it seems that industrial python remains a bit taboo because of proprietary issues... It has nothing to do with 'proprietary issues'. A lot of it has to do with the perception of support -- who will support Python and custom Python code if my plant shuts down? Who will train my developers and operators? Who can I sue? The rest of it is because of the way the industry evolved, and the kinds of programmers and development teams that write industrial control packages. If we could consolidate this software into a single, non black-box package, we could see significant improvements in development time. You *might* save on development time (although I wouldn't bet on it), but you'll lose on testing time. Heck, you'll even lose because you have to document your stuff and train people to use it -- what happens to your custom system if you get hit by a bus? Having to program 3 different devices with three different languages to control your PLC, Servos, and module X is the status quo we face, but it is quite frustrating and limited. I share your frustration with the status quo in industrial automation. On the other hand, I've been brought in to customer sites a number of time to fix their re-invented wheels, and my advice is not to re-invent the wheel. Yes, it's a shame that you have to buy three packages to perform three functions, and then buy other 3rd-party packages to tie them together. Yes, it's a shame that industrial software is expensive, and proprietary, and Windows-only, and generally has a brain-dead scripting language (when it has any scriptability at all). Still, as much as it galls me to say it, if your company's primary business isn't writing industrial automation software, don't write industrial automation software. For reasons of quality, long-term supportability, manageability, insurability, and several other -ilities, the sad facts are: * Unless you're a hobbyist, if you want to do machine/motion control, do it from a PLC. Windows is not reliable, stable, or real-time enough to be trusted to control moving pieces of hardware, and custom software, possibly with hand-crafted multithreading, is not as reliable or predicatable as ladder logic on a PLC. (Look up Therac 25 for some reasons why.) Python is a great language, but it depends on the underlying OS for threading, and has a GIL that can bite you too. The first time you see twenty tons of machinery move unexpectedly because you inadvertently changed one bit in memory, you become very conservative about your software platform. * Unless you're a hobbyist, if you want to do data acquisition or i/o, purchase an i/o server for your particular bus/instrumentation from a major manufacturer. You *can* write your own i/o server, especially for simple protocols like Modbus, but the commercial versions have been tested more exhaustively than you can manage. Also, the most common protocol these days is OPC, which isn't a protocol at all in the conventional sense -- it's a set of APIs to a Windows DLL, with the wire-level details completely opaque -- so you'd have to buy a library for that anyway. * Unless you're a hobbyist, if you want an HMI, purchase LabView or InTouch or RSView or whatever, and use their tools to draw and 'configure' your screens. (Where 'configure' generally means 'program in Visual Basic or some other brain-dead language', but we try not to say program -- customers and underwriters *hate* custom software.) I personally think it's a tragedy that every manufacturer bases its HMI on Visual Basic for Applications rather than a better (and free and Open Source!) language like Python. It's also a tragedy that the dominant i/o 'protocol' for industrial automation isn't really a protocol, and is Windows-only to boot. It's horrifying that the primary means of communication between process control and data acquisition applications is via DDE or ActiveX. And I find it incredible that people and companies will
Extending Python by Adding Keywords Data types
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced python developers. II want to add some more KEYWORDS and DATATYPES into the python script apart from the existing ones. It would be really great if anybody could guide me as which files and modules I need to look to make these additions and enhancements to the existing python version. Thanks a lot in advance and your help is really appreciated. Vishak -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess and pipe-fork-exec primitive
From my experience, this primitive will fail with 'no child processes' at the waitpid call if the forked child dies very quickly - before the parent is scheduled back for execution. This seems to happen because Python has a default SIGCHLD handler that, in this case, will reap the process before the parent has the chance to do it. What operating system is your experience from? On a POSIX system, this should not happen - i.e. delivery of SIGCHLD should not cause to make the child waited-for. Python itself does not perform wait() in response to SIGCHLD. I would like to know if this is correct, or am I missing something here? You must be missing something, although I'm uncertain what precisely that is. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
split a string of space separated substrings - elegant solution?
Hi, I'm looking for an elegant solution to the following (quite common) problem: Given a string of substrings separated by white space, split this into tuple/list of elements. The problem are quoted substrings like abc xy z 1 2 3 a \ x should be split into ('abc','xy z','1 2 3','a x') For that, one probably has to protect white space between quotes, then split by white space and finally converted the 'protected white space' to normal white space again. Is there an elegant solution - perhaps without using a lexer and something else. With regular expressions alone it seems clumsy. Many thanks for a hint, Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list
Re: encode() question
str.decode and unicode.encode should NOT exist, or at least issue a warning (IMHO). Yes, that sounds like a good idea. It sounds like horrible idea as those are the ones that are really needed. Correct. One could argue about `str.encode` and `unicode.decode`. But there are at least uses for `str.encode` like 'sting-escape', 'hex', 'bz2', 'base64' etc. Indeed, in Py3k, those will be gone. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Live editing...
There's been some chatter on edu-sig (python.org) of late regarding Python's capabilities in the edit/continue tradition, meaning debugging tools, and/or IDE tools, that give the developer real time write access to running programs. I think a good design would be something like the ZODB, or the ZODB itself, to save the entire working environment, like a Smalltalk image, at which point a supervisor Python (a whole different instance, perhaps on another chip), could do brain surgery on the hibernating Python (like a patient undergoing surgery). You basically simulate or emulate the operating table version, without putting yourself at its mercy. If you break it completely, while doing your brain surgery, just abort the instance and roll back to the previously saved version. It's like sitting on top of a version control system, while never getting to directly edit the currently operating version (the supervisor). The alternative, allowing a developer to undermine his/her own running platform, seems to unnecessarily conflate a runtime and design time mode, which isn't just some stupid prejudice. We need that separation, just as we keep distance between production and development copies of things. Don't fix a running engine if you can fix an emulated running engine. Once you're happy with your changes, commit, and set it running for real. It still might crash, which is why you're glad for rollback capabilities. Smalltalk images meet CVS? Python atop Mercurial? Kirby -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Jay Loden schrieb: I have to agree with you WRT to the Python documentation, it does tend to be lacking and difficult to find things at times. In this case the two ways I can think of to look for something like this would have been: Hmm, I find the Python documentation just excellent. You are searching for a *string* related problem? Then just check the *string* class. Also try the dir() function, like dir(some_string_variable) If you come from a C++ background this should be familar to you. Check the appropriate class before trying some procedural way. Anyway, glad we could help :) -- http://mail.python.org/mailman/listinfo/python-list
Re: split a string of space separated substrings - elegant solution?
Helmut Jarausch wrote: Hi, I'm looking for an elegant solution to the following (quite common) problem: Given a string of substrings separated by white space, split this into tuple/list of elements. The problem are quoted substrings like abc xy z 1 2 3 a \ x should be split into ('abc','xy z','1 2 3','a x') import csv s = 'abc xy z 1 2 3 a \\ x' r = iter(csv.reader([s], delimiter= , escapechar=\\)) print r.next() w. -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a shared object in python
Delgado, Edgardo CIV NAVAIR 4.1.4.3 wrote: Is there a way to create a shared object in python? What's a shared object? Do you mean IPC or .so libraries, or something different? Regards, Björn -- BOFH excuse #404: Sysadmin accidentally destroyed pager with a large hammer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Iteration over strings
Hexamorph schrieb: Jay Loden schrieb: I have to agree with you WRT to the Python documentation, it does tend to be lacking and difficult to find things at times. Hmm, I find the Python documentation just excellent. You are searching for a *string* related problem? Then just check the *string* class. Also try the dir() function, like dir(some_string_variable) If you come from a C++ background this should be familar to you. Check the appropriate class before trying some procedural way. Anyway, glad we could help :) -- http://mail.python.org/mailman/listinfo/python-list
Python Package Index hostname change
The Python Packaging Index (the software formerly known as Cheeseshop) is now available at http://pypi.python.org/pypi The old addresses (www.python.org/pypi, and cheeseshop.python.org/pypi) will continue to work, either as aliases or using HTTP redirections. The software was renamed to its old name (PyPI - Python Package Index), as the Cheeseshop name was ever confusing people unfamiliar with British television comedy sketch (and puzzling even to people familiar with the sketch, as you *can* get packages from the package index). If you would like to discuss PyPI and its future, please join [EMAIL PROTECTED] Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: split a string of space separated substrings - elegant solution?
On Tue, 2007-07-31 at 22:30 +0200, Helmut Jarausch wrote: Hi, I'm looking for an elegant solution to the following (quite common) problem: Given a string of substrings separated by white space, split this into tuple/list of elements. The problem are quoted substrings like abc xy z 1 2 3 a \ x should be split into ('abc','xy z','1 2 3','a x') import shlex shlex.split('abc xy z 1 2 3 a \\ x') ['abc', 'xy z', '1 2 3', 'a x'] I hope that's elegant enough ;) -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list