RELEASED Python 2.5.1, FINAL
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.5.1 (FINAL) This is the first bugfix release of Python 2.5. Python 2.5 is now in bugfix-only mode; no new features are being added. According to the release notes, over 150 bugs and patches have been addressed since Python 2.5, including a fair number in the new AST compiler (an internal implementation detail of the Python interpreter). This is a production release of Python, and should be a painless upgrade from 2.5. Since the release candidate, we have backed out a couple of small changes that caused 2.5.1 to behave differently to 2.5. See the release notes for more. For more information on Python 2.5.1, including download links for various platforms, release notes, and known issues, please see: http://www.python.org/2.5.1/ Highlights of this new release include: Bug fixes. According to the release notes, at least 150 have been fixed. Highlights of the previous major Python release (2.5) are available from the Python 2.5 page, at http://www.python.org/2.5/highlights.html Enjoy this release, Anthony Anthony Baxter [EMAIL PROTECTED] Python Release Manager (on behalf of the entire python-dev team) pgp06hjbDDPkH.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
pyIDL 0.5 released
updated Python bindings for IDL http://www.its.caltech.edu/~mmckerns/software.html # Version 0.5: 04/18/07 fixed support for python2.5 (Thanks to several of you kicking me in the butt... especially N. Pirzkal) --- Mike McKerns California Institute of Technology http://www.its.caltech.edu/~mmckerns -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
cx_Oracle 4.3.1
What is cx_Oracle? cx_Oracle is a Python extension module that allows access to Oracle and conforms to the Python database API 2.0 specifications with a few exceptions. Where do I get it? http://starship.python.net/crew/atuining What's new? 1) Ensure that if the client buffer size exceeds 4000 bytes that the server buffer size does not as strings may only contain 4000 bytes; this allows handling of multibyte character sets on the server as well as the client. 2) Added support for using buffer objects to populate binary data and made the Binary() constructor the buffer type as requested by Ken Mason. 3) Fix potential crash when using full optimization with some compilers. Thanks to Aris Motas for noticing this and providing the initial patch and to Amaury Forgeot d'Arc for providing an even simpler solution. 4) Pass the correct charset form in to the write call in order to support writing to national character set LOB values properly. Thanks to Ian Kelly for noticing this discrepancy. Anthony Tuininga -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: comparison with None
Alan Isaac wrote: Terry Reedy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Should be in the reference manual section on comparisons. Only to this extent: http://www.python.org/doc/2.4/ref/comparisons.html objects of different types always compare unequal, and are ordered consistently but arbitrarily. (This unusual definition of comparison was used to simplify the definition of operations like sorting and the in and not in operators. In the future, the comparison rules for objects of different types are likely to change.) ... Most other types compare unequal unless they are the same object; the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently within one execution of a program. This does not provide a direct answer to why None comparisons. (As far as I can tell, None is less than any object.) However, Gary Herron's explanation makes sense: this provides a stable sort when None is involved, and meets the criterion that objects of different types must always compare unequal. However this would also be true if None always compared greater than any object, and the current behavior does not seem to be guaranteed. Is that about right? Cheers, Alan Isaac I love scripting languages ... but sometimes an explicit evaluation that one would find in a compiled language is better. Which is why I suggested using the explicit type(x) == types.NoneType as opposed to x is None -- http://mail.python.org/mailman/listinfo/python-list
Re: How to communicate via USB port
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Can someone explain how I would read the data from the USB port? I don't know if it matters, but I am trying to read the data from a GPS plugged in to the USB port. USB is a protocol bus. It isn't like a serial port, where you can just start reading bits. Each device has one or more interfaces, and each interface has one or more pipe for transmitting data. You have to know which pipe to talk to, what kind of pipe it is, and how to force the device to send before you can talk to it. On the other hand, as someone else pointed out, many types of USB devices fall into standard device classes, and the operating system supplies drivers for those classes. If your GPS device is in the communication class, you might be able to pretend it is a serial device. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Text Suffix to Prefix Conversion
On Apr 18, 11:08 pm, Steven Bethard [EMAIL PROTECTED] wrote: EMC ROY wrote: Original Sentence: An apple for you. Present: AnAT0 appleNN1 forPRP youPNP .. Desire:AT0An NN1apple PRPfor PNPyou .. text = 'AnAT0 appleNN1 forPRP youPNP ..' import re re.sub(r'(\S+)([^]+)(\s*)', r'\2\1\3', text) 'AT0An NN1apple PRPfor PNPyou ..' If you end up calling re.sub() repeatedly, e.g. for each line in your file, then you should compile the regular expression so that python doesn't have to recompile it for every call: import re text = 'AnAT0 appleNN1 forPRP youPNP ..' myR = re.compile(r'(\S+)([^]+)(\s*)', r'\2\1\3') re.sub(myR, r'\2\1\3', text) Unfortunately, I must be doing something wrong because I can't get that code to work. When I run it, I get the error: Traceback (most recent call last): File 2pythontest.py, line 3, in ? myR = re.compile(r'(\S+)([^]+)(\s*)', r'\2\1\3') File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre.py, line 180, in compile return _compile(pattern, flags) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre.py, line 225, in _compile p = sre_compile.compile(pattern, flags) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_compile.py, line 496, in compile p = sre_parse.parse(p, flags) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_parse.py, line 668, in parse p = _parse_sub(source, pattern, 0) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_parse.py, line 308, in _parse_sub itemsappend(_parse(source, state)) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_parse.py, line 396, in _parse if state.flags SRE_FLAG_VERBOSE: TypeError: unsupported operand type(s) for : 'str' and 'int' Yet, these two examples work without error: -- import re text = 'AnAT0 appleNN1 forPRP youPNP ..' #myR = re.compile(r'(\S+)([^]+)(\s*)', r'\2\1\3') print re.sub(r'(\S+)([^]+)(\s*)', r'\2\1\3', text) myR = re.compile(r'(hello)') text = hello world print re.sub(myR, r\1XXX, text) -output: AT0An NN1apple PRPfor PNPyou .. helloXXX world Can anyone help? -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested dictionaries trouble
On Wed, 18 Apr 2007 12:16:12 -0700, IamIan wrote: I am using the suggested approach to make a years list: years = [199%s % x for x in range(0,10)] years += [200%s % x for x in range(0,10)] I haven't had any luck doing this in one line though. Is it possible? years = [199%s % x for x in range(0,10)] + \ [200%s % x for x in range(0,10)] Sorry for the line continuation, my news reader insists on breaking the line. In your editor, just delete the \ and line break to make it a single line. If you don't like that solution, here's a better one: years = [str(1990 + n) for n in range(20)] Or there's this: years = [str(n) for n in range(1990, 2010)] Or this one: years = map(str, range(1990, 2010)) -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
On Thu, 19 Apr 2007 02:46:18 +, Alan Isaac wrote: However, Gary Herron's explanation makes sense: this provides a stable sort when None is involved, and meets the criterion that objects of different types must always compare unequal. That's only correct for sensible objects that don't do stupid things, like this one: class Mirror: # compares equal to just about everything def __eq__(self, other): return True However this would also be true if None always compared greater than any object, and the current behavior does not seem to be guaranteed. Is that about right? Yes, that's about right. You shouldn't expect comparisons between types to sort the same from one version of Python to another, although they may, and in the future (Python 3) it is likely to become an error to compare incomparable objects. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: What makes an iterator an iterator?
On Wed, 18 Apr 2007 01:45:10 -0700, Paul McGuire wrote: For the record, this is what I actually wanted: a four-line self-sorting dictionary: class SortedDict(dict): def __iter__(self): for key in sorted(self.keys()): yield key [snip] Very neat. Why not this? class SortedDict(dict): def __iter__(self): return iter(sorted(self.keys())) Good question. I don't have a good answer except for because I didn't think of it. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5 from source install problem with extensions
On Apr 18, 7:39 pm, Anton Hartl [EMAIL PROTECTED] wrote: Hi, On 2007-04-18, Florian Demmer [EMAIL PROTECTED] wrote: On Apr 18, 12:36 pm, Florian Demmer [EMAIL PROTECTED] wrote: Hi! I am doing a from source installation of Python 2.5 on some old Debian machine. As the target directoy I want /opt/somename so i added it to the configure like so: ./configure --prefix=/opt/somedir The following make works fine as far as I can see. Then the make install also actually works and installs python in /opt/somedir with all its subdirectoris (bin, lib, man, include). The extensions (*.so) however get put in /usr/local/lib/... and there also in the wrong python directoy: 2.4 Basically I had the same problem(s). (How) can I change the install_dir for the extensions? Why does it use python2.4 anyway?! What env var or else is set here that I cannot find? I've patched setup.py as follows: --- setup.py.orig Thu Aug 10 01:42:18 2006 +++ setup.pyMon Dec 25 19:05:29 2006 @@ -147,6 +147,14 @@ if ext.name in sys.builtin_module_names: self.extensions.remove(ext) + # so -lpython2.5 works in the build + ext.library_dirs.append('.') + + # so shared libs requiring libpython2.5.so work + py_instdir = os.environ.get(INSTDIR_PYTHON, None) + if py_instdir: + ext.library_dirs.append(os.path.join(py_instdir, 'lib')) + if platform != 'mac': # Parse Modules/Setup and Modules/Setup.local to figure out which # modules are turned on in the file. Then you have to add INSTDIR_PYTHON to your shell environment, i.e. INSTDIR_PYTHON=/opt/somedir ; export INSTDIR_PYTHON or whatever your shell requires. This works for me. Hope it helps, nice workaround (and it does work), thank you... at least until when i try to install Python2.6 and forget about that again ;) since i was not quite satisfied by the solution (i will have to install py25 from source on a customer's system that i dont know much about yet at a later time and that _has_ to work then), i searched for more reasons why it fails in the first place... and actually found something: ~/.pydistutils.cfg -- install_lib = /usr/local/lib/python2.4/site-packages ... uncommented it and ran make install again -- works! :D br Florian -- http://mail.python.org/mailman/listinfo/python-list
Re: What makes an iterator an iterator?
On Wed, 18 Apr 2007 19:45:50 -0700, Alex Martelli wrote: 7stud [EMAIL PROTECTED] wrote: ... Can you explain some of the details of why this code fails: ... def next(self): for word in Norwegian Blue's have beautiful plumage!.split(): yield word Sure, easily: a loop like for x in y: binds an unnamed temporary variable (say _t) to iter(y) and then repeatedly calls _t.next() [or to be pedantic type(_t).next(t)] until that raises StopIteration. Calling a generator, such as this next method, returns an iterator object; calling it repeatedly returns many such iterator objects, and never raises StopIteration, thus obviously producing an unending loop. Thank you for that answer Alex, even though I didn't ask the question I was wondering the same thing myself. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Text Suffix to Prefix Conversion
7stud wrote: On Apr 18, 11:08 pm, Steven Bethard [EMAIL PROTECTED] wrote: EMC ROY wrote: Original Sentence: An apple for you. Present: AnAT0 appleNN1 forPRP youPNP .. Desire:AT0An NN1apple PRPfor PNPyou .. text = 'AnAT0 appleNN1 forPRP youPNP ..' import re re.sub(r'(\S+)([^]+)(\s*)', r'\2\1\3', text) 'AT0An NN1apple PRPfor PNPyou ..' If you end up calling re.sub() repeatedly, e.g. for each line in your file, then you should compile the regular expression so that python doesn't have to recompile it for every call: import re text = 'AnAT0 appleNN1 forPRP youPNP ..' myR = re.compile(r'(\S+)([^]+)(\s*)', r'\2\1\3') re.compile() doesn't accept a replacement pattern: Help on function compile in module re: compile(pattern, flags=0) Compile a regular expression pattern, returning a pattern object. re.sub(myR, r'\2\1\3', text) Unfortunately, I must be doing something wrong because I can't get that code to work. When I run it, I get the error: Traceback (most recent call last): File 2pythontest.py, line 3, in ? myR = re.compile(r'(\S+)([^]+)(\s*)', r'\2\1\3') File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre.py, line 180, in compile return _compile(pattern, flags) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre.py, line 225, in _compile p = sre_compile.compile(pattern, flags) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_compile.py, line 496, in compile p = sre_parse.parse(p, flags) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_parse.py, line 668, in parse p = _parse_sub(source, pattern, 0) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_parse.py, line 308, in _parse_sub itemsappend(_parse(source, state)) File /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/sre_parse.py, line 396, in _parse if state.flags SRE_FLAG_VERBOSE: TypeError: unsupported operand type(s) for : 'str' and 'int' Yet, these two examples work without error: -- import re text = 'AnAT0 appleNN1 forPRP youPNP ..' #myR = re.compile(r'(\S+)([^]+)(\s*)', r'\2\1\3') print re.sub(r'(\S+)([^]+)(\s*)', r'\2\1\3', text) myR = re.compile(r'(hello)') text = hello world print re.sub(myR, r\1XXX, text) -output: AT0An NN1apple PRPfor PNPyou .. helloXXX world Can anyone help? You can precompile the regular expression like this: text = 'AnAT0 appleNN1 forPRP youPNP ..' r = re.compile(r'(\S+)([^]+)(\s*)') r.sub(r'\2\1\3', text) 'AT0An NN1apple PRPfor PNPyou ..' or even sub = re.compile(r'(\S+)([^]+)(\s*)').sub sub(r'\2\1\3', text) 'AT0An NN1apple PRPfor PNPyou ..' Note that this is not as much more efficient as you might think since re.sub() and the other re functions look up already compiled regexps in a cache. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On Apr 18, 2007, at 5:11 PM, Kevin Walzer wrote: James Stroud wrote: This appears more or less unique to Objective C. It looks that with PyObjC, you have to interact with the Objective C runtime to manage memory. This is not required, thankfully, with any other GUI tookits I've seen. I think the main difference is that PyObjC is not a GUI toolkit per se, but is simply a means to make the Objective C runtime (and hence Cocoa) available via a python layer. James That's kind of what I thought. Memory management? In Python? *shudder* I'm a Mac-only developer, and I keep telling myself I should drink the Mac-only Kool-aid of PyObjC. But Tk is burned into my brain, and anything else looks and feels weird to me. Tk is so flexible that it's fairly easy to tweak it to look Mac-like, and it's simpler to do that than learn a new tookit. PyObjC is pretty slick (and since Ronald hasn't made any commits in a while I'm nearly certain it'll show up in the next official distribution of the devtools). About the time you gave up on PyQt on the Mac and switched over to Tkinter, I switched to PyObjC. The learning curve is rather steep IMO, but worth it. One thing I think I should mention though is that if you move to PyObjC -- do some projects in Objective C first. Otherwise your brain will implode. hth, Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and __repr__()
Martin Drautzburg schrieb: I am using UTF-8 and assembling the string expression manually works okay and the umlaute appear correctly in the browser (so I could probably write my own serializer and it would work). That's what you should do. Or you can use one that people have already written, e.g. http://cheeseshop.python.org/pypi/simplejson Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Boost.Python create extra functions not in wrapped object
Hi, I have a python library created by wrapping the C++ library using Boost.Python, the problem is that the wrappers are not very pythonic so I want to add some methods that do not exist in the C+ + implementation, that would create a better Python interface. For example to initialize the data in an object in the library one must iterate through every point, setting a value for each individually. That's the way it works in C++ but in python it would be nice to instead just have one call that can receive a numpy array or a tuple. I want to add a call like: setData(array) to the python object, a call that does not exist in the C++ implementation and then in the C++ wrappers actually use setData to iterate through the array and set the values using the normal C++ method, say setValue(index, value). Something along the lines of this (initData is not in the constructor on purpose) C++ object: class Foo { public: void initData(int size) { data = new float[size]; }; // Create the data array void setValue(int index, float value) // Set given value { data[index] = value; } private: float *data; }; In python however I want to do this: obj = foo() ar = array([1,2,3,4,5], dtype=float) foo.setData(ar) Or even better: ar = array([1,2,3,4,5], dtype=float) obj = foo(ar) And have it somehow call initData() and setValue() iteration inside the C++ code of the wrapper. I've only used SWIG and don't really know much about Boost, I am not even sure how to label what I am trying to do. Can this be done with Boost, without changing the C++ library? Regards, Stou -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about Tkinter MenuOption variable
Chad wrote: Is there anyway to set the individual options in Tkinter to a particular variable. For example, I have a menu option(code is below) which has January, February, March and so on, which I would like to have corresponding values of 01, 02, 03 and so on. Can someone please tell me how to do that within the context of the code I have below - or even totally modify it if you must. Label(self, text = Month ).grid(row = 5, column = 1, sticky = W) OPTIONS = [ Jan, Feb, Mar, Apr, May, June, July, Aug, Sep, Oct, Nov, Dec] default_option = StringVar(self) default_option.set(OPTIONS[0]) self.month_option = OptionMenu(self, default_option, *OPTIONS) self.month_option.grid(row = 5, column = 2, sticky = W) What about using dictionary? For example: code import Tkinter as Tk def state(): print OPTIONS[default_option.get()] root = Tk.Tk() Tk.Label(root, text=Month).grid(row=1, column=1, sticky=Tk.W) OPTIONS = dict(Jan=1, Feb=2, Mar=3, Apr=4, May=5, June=6, July=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12) # or #OPTIONS = dict(Jan=01, Feb=02, Mar=03, Apr=04, May=05, June=06, July=07, # Aug=08, Sep=09, Oct=10, Nov=11, Dec=12) default_option = Tk.StringVar() default_option.set(Jan) month_option = Tk.OptionMenu(root, default_option, *OPTIONS.keys()) month_option.grid(row=1, column=2, sticky=Tk.W) Tk.Button(root, command=state, text='state').grid(row=2, column=1) root.mainloop() /code -- HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Wanted: Email Client with GUI
Hello, thanks, Chandler looks good, maybe I will give it a try. Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: Boost.Python create extra functions not in wrapped object
On 19 Apr 2007 00:37:36 -0700, Stou Sandalski [EMAIL PROTECTED] wrote: Hi, I have a python library created by wrapping the C++ library using Boost.Python, the problem is that the wrappers are not very pythonic so I want to add some methods that do not exist in the C+ + implementation, that would create a better Python interface. For example to initialize the data in an object in the library one must iterate through every point, setting a value for each individually. That's the way it works in C++ but in python it would be nice to instead just have one call that can receive a numpy array or a tuple. I want to add a call like: setData(array) to the python object, a call that does not exist in the C++ implementation and then in the C++ wrappers actually use setData to iterate through the array and set the values using the normal C++ method, say setValue(index, value). Something along the lines of this (initData is not in the constructor on purpose) C++ object: class Foo { public: void initData(int size) { data = new float[size]; }; // Create the data array void setValue(int index, float value) // Set given value { data[index] = value; } private: float *data; }; In python however I want to do this: obj = foo() ar = array([1,2,3,4,5], dtype=float) foo.setData(ar) Or even better: ar = array([1,2,3,4,5], dtype=float) obj = foo(ar) And have it somehow call initData() and setValue() iteration inside the C++ code of the wrapper. I've only used SWIG and don't really know much about Boost, I am not even sure how to label what I am trying to do. Can this be done with Boost, without changing the C++ library? Take a look on next link: http://boost.org/libs/python/doc/tutorial/doc/html/python/techniques.html#python.extending_wrapped_objects_in_python Regards, Stou -- http://mail.python.org/mailman/listinfo/python-list -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
Glen wrote: What seems to be happening is that the font that pyqt is using is not fixed width, so I did this: qTxtFormat = QTextCharFormat() qTxtFormat.setFontFixedPitch(True) ui.textEdit.setCurrentCharFormat(qTxtFormat) Does something like ui.textEdit.setCurrentFont(QFont('fixed')) work? It seems to work for me if you use plain text. Tabs or html/rich text formatting should be a better way to get the layout (or just use a table). Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
RELEASED Python 2.5.1, FINAL
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.5.1 (FINAL) This is the first bugfix release of Python 2.5. Python 2.5 is now in bugfix-only mode; no new features are being added. According to the release notes, over 150 bugs and patches have been addressed since Python 2.5, including a fair number in the new AST compiler (an internal implementation detail of the Python interpreter). This is a production release of Python, and should be a painless upgrade from 2.5. Since the release candidate, we have backed out a couple of small changes that caused 2.5.1 to behave differently to 2.5. See the release notes for more. For more information on Python 2.5.1, including download links for various platforms, release notes, and known issues, please see: http://www.python.org/2.5.1/ Highlights of this new release include: Bug fixes. According to the release notes, at least 150 have been fixed. Highlights of the previous major Python release (2.5) are available from the Python 2.5 page, at http://www.python.org/2.5/highlights.html Enjoy this release, Anthony Anthony Baxter [EMAIL PROTECTED] Python Release Manager (on behalf of the entire python-dev team) pgpGJ2NR4LirI.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Boost.Python create extra functions not in wrapped object
On 4/19/07, Stou Sandalski [EMAIL PROTECTED] wrote: Thanks for the reply, That is what I am doing now, the problem is that I need the code to be in C/C++ inside the wrapper. I am creating a lot of these objects and each time I am iterating over ~1.4 million points... and in python it's quite slow which is unpleasant especially since it's such a trivial operation. My calculation's in NumPy take seconds, and to create an object for visualization I have to wait 2 minutes. =( You can define function that first argument is a reference to the instance of your class. Then you can register it as usual function. For example: http://language-binding.net/pyplusplus/documentation/functions/transformation/built_in/input_c_buffer.html take a look on generated source code( at the bottom of the page ) Thanks again, Stou On 4/19/07, Roman Yakovenko [EMAIL PROTECTED] wrote: On 19 Apr 2007 00:37:36 -0700, Stou Sandalski [EMAIL PROTECTED] wrote: Hi, I have a python library created by wrapping the C++ library using Boost.Python, the problem is that the wrappers are not very pythonic so I want to add some methods that do not exist in the C+ + implementation, that would create a better Python interface. For example to initialize the data in an object in the library one must iterate through every point, setting a value for each individually. That's the way it works in C++ but in python it would be nice to instead just have one call that can receive a numpy array or a tuple. I want to add a call like: setData(array) to the python object, a call that does not exist in the C++ implementation and then in the C++ wrappers actually use setData to iterate through the array and set the values using the normal C++ method, say setValue(index, value). Something along the lines of this (initData is not in the constructor on purpose) C++ object: class Foo { public: void initData(int size) { data = new float[size]; }; // Create the data array void setValue(int index, float value) // Set given value { data[index] = value; } private: float *data; }; In python however I want to do this: obj = foo() ar = array([1,2,3,4,5], dtype=float) foo.setData(ar) Or even better: ar = array([1,2,3,4,5], dtype=float) obj = foo(ar) And have it somehow call initData() and setValue() iteration inside the C++ code of the wrapper. I've only used SWIG and don't really know much about Boost, I am not even sure how to label what I am trying to do. Can this be done with Boost, without changing the C++ library? Take a look on next link: http://boost.org/libs/python/doc/tutorial/doc/html/python/techniques.html#python.extending_wrapped_objects_in_python Regards, Stou -- http://mail.python.org/mailman/listinfo/python-list -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -- http://mail.python.org/mailman/listinfo/python-list
About installing new Python version.
Hi to all, i started with Python at v2.5 and now i see that a new version is released. As i already have a lot of stuff for Python installed in the site- packages directory, which is the correct way to install a new Python version without do any damage ? Remove Python and ALL Python related software and install them all over again (painful)? Remove Python and do not touch anything else and install new version on top of them at the same directory ? Any other choice available ? Thanks a lot for any help! -- http://mail.python.org/mailman/listinfo/python-list
Re: using the sysloghandler class
On Apr 18, 11:42 pm, Nicholas Milkovits [EMAIL PROTECTED] wrote: Hello all, I have a small script which attempts to write to the user.log syslog importlogging,logging.handlers logger =logging.getLogger('bender') handler =logging.handlers.SysLogHandler(('localhost',logging.handlers.SYSLOG_UDP_PORT),logging.handlers.SysLogHandler.LOG_USER) formatter =logging.Formatter('%(filename)s: %(levelname)s: %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) logger.error('what') but no log entries show up, however if I use the syslog module as such: import syslog syslog.syslog('testing syslog') everything works fine. I am not sure what I am doing wrong. Any help would be appreciated. The logging package's syslog handler attempts to use UDP to communicate with the syslog daemon; are you sure your system is set up with the daemon listening on SYSLOG_UDP_PORT? If it's not, then this could explain what you are seeing. Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 18, 2007, at 5:11 PM, Kevin Walzer wrote: James Stroud wrote: This appears more or less unique to Objective C. It looks that with PyObjC, you have to interact with the Objective C runtime to manage memory. This is not required, thankfully, with any other GUI tookits I've seen. I think the main difference is that PyObjC is not a GUI toolkit per se, but is simply a means to make the Objective C runtime (and hence Cocoa) available via a python layer. James That's kind of what I thought. Memory management? In Python? *shudder* I'm a Mac-only developer, and I keep telling myself I should drink the Mac-only Kool-aid of PyObjC. But Tk is burned into my brain, and anything else looks and feels weird to me. Tk is so flexible that it's fairly easy to tweak it to look Mac-like, and it's simpler to do that than learn a new tookit. PyObjC is pretty slick (and since Ronald hasn't made any commits in a while I'm nearly certain it'll show up in the next official distribution of the devtools). About the time you gave up on PyQt on the Mac and switched over to Tkinter, I switched to PyObjC. The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 18, 2007, at 5:11 PM, Kevin Walzer wrote: James Stroud wrote: This appears more or less unique to Objective C. It looks that with PyObjC, you have to interact with the Objective C runtime to manage memory. This is not required, thankfully, with any other GUI tookits I've seen. I think the main difference is that PyObjC is not a GUI toolkit per se, but is simply a means to make the Objective C runtime (and hence Cocoa) available via a python layer. James That's kind of what I thought. Memory management? In Python? *shudder* I'm a Mac-only developer, and I keep telling myself I should drink the Mac-only Kool-aid of PyObjC. But Tk is burned into my brain, and anything else looks and feels weird to me. Tk is so flexible that it's fairly easy to tweak it to look Mac-like, and it's simpler to do that than learn a new tookit. PyObjC is pretty slick (and since Ronald hasn't made any commits in a while I'm nearly certain it'll show up in the next official distribution of the devtools). About the time you gave up on PyQt on the Mac and switched over to Tkinter, I switched to PyObjC. The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. Mathematical absurdities aside, it's the common usage -- but perhaps you knew that. -- http://mail.python.org/mailman/listinfo/python-list
Re: About installing new Python version.
On Apr 19, 2:03 am, king kikapu [EMAIL PROTECTED] wrote: Hi to all, i started with Python at v2.5 and now i see that a new version is released. As i already have a lot of stuff for Python installed in the site- packages directory, which is the correct way to install a new Python version without do any damage ? Remove Python and ALL Python related software and install them all over again (painful)? Remove Python and do not touch anything else and install new version on top of them at the same directory ? Any other choice available ? Thanks a lot for any help! Just install the new version. It should link everything back up so the new version is active, but the old versions are intact. ~Sean -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling python from soruce vs RPM ?
On 19 Apr, 04:39, howa [EMAIL PROTECTED] wrote: One more question: How to uninstall using the source package? the source package doesn't come with `make uninstall`? Right. That's another pitfall of most source distributions (ie. the Python sources from python.org) compared to system packages (ie. the package built from a source RPM or equivalent system source package). If you want a really quick solution to this which seems to work much of the time, look at checkinstall: http://asic-linux.com.mx/~izto/checkinstall/ This tool will make system packages by taking control of the usual build process, and you can then install and uninstall those system packages. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: About installing new Python version.
On Apr 19, 11:39 am, [EMAIL PROTECTED] wrote: On Apr 19, 2:03 am, king kikapu [EMAIL PROTECTED] wrote: Hi to all, i started with Python at v2.5 and now i see that a new version is released. As i already have a lot of stuff for Python installed in the site- packages directory, which is the correct way to install a new Python version without do any damage ? Remove Python and ALL Python related software and install them all over again (painful)? Remove Python and do not touch anything else and install new version on top of them at the same directory ? Any other choice available ? Thanks a lot for any help! Just install the new version. It should link everything back up so the new version is active, but the old versions are intact. ~Sean I installed 2.5.1 and as the installer said, it have replaced my old installation with the new one, something like i wanted to do! So i checked and everything seems to working fine. But this is an update release to 2.5, i do not know what is happening when, for example, a totally new Python version come out, like 2.6 or 2.7 or... -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On 18/04/07, Kevin Walzer [EMAIL PROTECTED] wrote: James Stroud wrote: This appears more or less unique to Objective C. It looks that with PyObjC, you have to interact with the Objective C runtime to manage memory. This is not required, thankfully, with any other GUI tookits I've seen. I think the main difference is that PyObjC is not a GUI toolkit per se, but is simply a means to make the Objective C runtime (and hence Cocoa) available via a python layer. James That's kind of what I thought. Memory management? In Python? *shudder* I'm wondering if this might go away with the arrival of garbage collection in ObjectiveC? Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: About installing new Python version.
checked and everything seems to working fine. But this is an update release to 2.5, i do not know what is happening when, for example, a totally new Python version come out, like 2.6 or 2.7 or... Again just install it - it will by default install alongside Python 2.5 in a different directory, and set itself as the default python version. You'll then need to update all your third party extensions to ones compiled against the new version - so if you have a lot of these, it makes sense to wait a while before upgrading. -- Ant. -- http://mail.python.org/mailman/listinfo/python-list
Re: About installing new Python version.
On Apr 19, 12:10 pm, Ant [EMAIL PROTECTED] wrote: checked and everything seems to working fine. But this is an update release to 2.5, i do not know what is happening when, for example, a totally new Python version come out, like 2.6 or 2.7 or... Again just install it - it will by default install alongside Python 2.5 in a different directory, and set itself as the default python version. You'll then need to update all your third party extensions to ones compiled against the new version - so if you have a lot of these, it makes sense to wait a while before upgrading. -- Ant. Hmm...ok, i was sure that i wouldn't avoid that...The nice thing is that 2.5.1 installed in default directory so no problem for now. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
CGI Script using Python
Hello, is there anybody who can help me. I would like to use a Python Script to download Files from a Server to the Client, to update the Client. Thanx Ralf -- http://mail.python.org/mailman/listinfo/python-list
Helpbook and CHM
How to create a helpbook and display it using python(in Boa). Also, how to generate CHM files in Boa(Python)??? Any pointers please -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
Teja wrote: how to generate CHM files in Boa(Python)??? http://www.rutherfurd.net/software/rst2chm/index.html TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
On Apr 19, 3:48 pm, Tim Golden [EMAIL PROTECTED] wrote: Teja wrote: how to generate CHM files in Boa(Python)??? http://www.rutherfurd.net/software/rst2chm/index.html TJG Can't I do it in Boa constructor ??? I have seen an option in Boa to create a new helpbook and compile it to CHm and help files, But no clue how to do it... -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: PyObjC is pretty slick (and since Ronald hasn't made any commits in a while I'm nearly certain it'll show up in the next official distribution of the devtools). About the time you gave up on PyQt on the Mac and switched over to Tkinter, I switched to PyObjC. The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. Mathematical absurdities aside, it's the common usage -- but perhaps you knew that. I don't know how you come to the conclusion that it is a mathematical absurdity but consider this: If you find that common usage propagates something that is incorrect, should we just shrug it off or should we attemp a correction? There is always a chance that one day you find yourself exposed to a learning curve while going through a document. If you just depend on common usage you will probably draw the wrong conclusion. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
*plonk* -- http://mail.python.org/mailman/listinfo/python-list
using tkinter to display html
Hi all, I prefer using tkinter to wxpython (so sue me :) and i need to display a lot of html in a particular app. does anyone know if one of the existing add on tk html widgets have been wrapped for tkinter already? TIA for any reply, Stephen -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
On Apr 19, 3:58 am, Teja [EMAIL PROTECTED] wrote: On Apr 19, 3:48 pm, Tim Golden [EMAIL PROTECTED] wrote: Teja wrote: how to generate CHM files in Boa(Python)??? http://www.rutherfurd.net/software/rst2chm/index.html TJG Can't I do it in Boa constructor ??? I have seen an option in Boa to create a new helpbook and compile it to CHm and help files, But no clue how to do it... Not that I know of. Which version are you using? Where in the application did you find it? Indicate the menu's you navigated to get to that option. MS HTML Help Workshop is the standard compiler for CHM files. There are some other freeware/shareware. The workshop is simple enough though. -- http://mail.python.org/mailman/listinfo/python-list
Re: What makes an iterator an iterator?
7stud wrote: Hi, Thanks for the responses. 7stud [EMAIL PROTECTED] wrote: Can you explain some of the details of why this code fails: --- class Parrot(object): def __iter__(self): return self def __init__(self): self.next = self.next().next def next(self): for word in Norwegian Blue's have beautiful plumage!.split(): yield word P = Parrot() for word in P: print word -- On Apr 18, 8:45 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: ...a loop like for x in y: binds an unnamed temporary variable (say _t) to iter(y) and then repeatedly calls _t.next() [or to be pedantic type(_t).next(t)] until that raises StopIteration. A. Isn't this the crux: repeatedly calls[type(_t).next(t)] As far as I can tell, if the call was actually _t.next(), the code I asked about would work. However, the name look up for 'next' when you call: [snip wild goose chase that appears to miss the main point]. It's nothing to do with the name lookup. Alex mentioned that to remind us that the magic double-under names are looked up on the type rather than the instance, so messing around with instances won't change the behavior. [This is not true of old-style or classic classes, which we should be eschewing in preparation for their disappearance]. You have to understand the iterator protocol, which is how the language interacts with objects whose contents it iterates over (for example in for loops). When you iterate over an object X then the *interpreter*, under the hood, initializes the loop by calling iter(X) and stashing the result away as, let's say, _t. Every time a new value is needed in the iteration _t.next() is called to produce it. We can see this if we open a file: f = open(travel.txt) f.__iter__() open file 'travel.txt', mode 'r' at 0x7ff1f6e0 f.next() 'Virgin Flight booking extension 33024 Louise reference 1VV75R\r\n' Calling the file's .next() method produces the next line in the file. The point is that a function with yield expressions in it, when called, returns a generator object. So if an instance's next() method contains yield statements then repeated calls to it give you an (endless) sequence of generator objects. Here's a simple object class that adheres to the iterator protocol: class myI(object): ... def __init__(self, lim): ... self.lim = lim ... self.current = 0 ... def __iter__(self): ... return self ... def next(self): ... self.current += 1 ... if self.current self.lim: ... raise StopIteration ... return self.current # NOT yield! ... myi = myI(5) for i in myi: ... print i ... 1 2 3 4 5 I hope this helps. You appear to be forming a rather over-complex model of the way Python behaves. Think simple - Python tries to be as simple as it can to achieve its objectives. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
On Apr 19, 4:33 pm, Ravi Teja [EMAIL PROTECTED] wrote: On Apr 19, 3:58 am, Teja [EMAIL PROTECTED] wrote: On Apr 19, 3:48 pm, Tim Golden [EMAIL PROTECTED] wrote: Teja wrote: how to generate CHM files in Boa(Python)??? http://www.rutherfurd.net/software/rst2chm/index.html TJG Can't I do it in Boa constructor ??? I have seen an option in Boa to create a new helpbook and compile it to CHm and help files, But no clue how to do it... Not that I know of. Which version are you using? Where in the application did you find it? Indicate the menu's you navigated to get to that option. MS HTML Help Workshop is the standard compiler for CHM files. There are some other freeware/shareware. The workshop is simple enough though. If u have Boa constructor 0.4.4, Go to File---New---helpbook Save it. After saving, click File menu option and you will find, make HTB and make CHM But I dont know how to add files and generate a complete CHM file. -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
Michael Bentley wrote: On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: [...] The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. Mathematical absurdities aside, it's the common usage -- but perhaps you knew that. Perhaps in Belgium they prefer climbing mountains over walking up and down gentle hills? Or possibly they will simply pick any nit that is carelessly left within range? http://home.earthlink.net/~macrakis/Snail_Stew_Recipe.html Don't forget the salt, Antoon! regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: About installing new Python version.
king kikapu wrote: On Apr 19, 12:10 pm, Ant [EMAIL PROTECTED] wrote: checked and everything seems to working fine. But this is an update release to 2.5, i do not know what is happening when, for example, a totally new Python version come out, like 2.6 or 2.7 or... Again just install it - it will by default install alongside Python 2.5 in a different directory, and set itself as the default python version. You'll then need to update all your third party extensions to ones compiled against the new version - so if you have a lot of these, it makes sense to wait a while before upgrading. -- Ant. Hmm...ok, i was sure that i wouldn't avoid that...The nice thing is that 2.5.1 installed in default directory so no problem for now. Thanks! Good question. kk is right - with a change in *major* version (such as 2.4 to 3.5, 3.5 to 3.6) the compiled extensions will be incompatible, and will need to be recompiled. This can take a while, as extension authors frequently have other things to do besides maintain their extensions. As you have found out, though, when only the *minor* version changes you can just frop the new version in over the old and all your installed extensions and packages continue to work just fine. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: About installing new Python version.
On Apr 19, 1:51 pm, Steve Holden [EMAIL PROTECTED] wrote: Good question. kk is right - with a change in *major* version (such as 2.4 to 3.5, 3.5 to 3.6) the compiled extensions will be incompatible, and will need to be recompiled. This can take a while, as extension authors frequently have other things to do besides maintain their extensions. As you have found out, though, when only the *minor* version changes you can just frop the new version in over the old and all your installed extensions and packages continue to work just fine. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenwebhttp://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com Thanks Steve, it is just the way i understood this, after seeing what the installer did. -- http://mail.python.org/mailman/listinfo/python-list
Re: Future Python Gui?
[EMAIL PROTECTED] wrote: However, that file is completely useless without instructions on how to use it, and there are no instructions within the page or file. That is: - exactly where does it get installed In your Python site-packages directory. - what else needs to get installed (eg. some dll) The Tile package. Install ActiveTcl from http://www.activestate.com, find the Tile package, and copy it to Python's installation of Tcl/Tk (find the libs directory--I'm not on a Windows box ATM and don't remember exactly). - where do you find these other things http://www.activestate.com - where does that something else get installed See above. - how do you import this module import Tile - how does use of Tkinter change (if at all) once imported It shouldn't change at all. I use Frame for Tkinter frames and Tile.Frame for Tile frames, since a lot of the widgets have the same names. Here's a sample: from Tkinter import * import Tile root = Tk() root.tk.call('package', 'require', 'tile') def printme(): print You clicked me frame = Tile.Frame(root) frame.pack(fill=BOTH, expand=TRUE) button = Tile.Button(frame, text=Print, command=printme) button.pack() root.mainloop() HTH, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help Understanding mx.ODBC Error
Steve Holden wrote: Greg Corradini wrote: [actually, her wrote it here but I moved it to the bottom] Steve Holden wrote: Greg Corradini wrote: Hello All, A few weeks ago, I wrote two scripts using mx.ODBC on an Access DB. Among other things, both scripts create new tables, perform a query and then populate the tables with data in a dictionary that I've uploaded from elsewhere. These scripts have run hundreds of times in the last few weeks with no problems. But recently they continue to bail on the mycursor.execute('An SQL Statement') after the table has been created. I get the following error message: Traceback (most recent call last): File C:\Documents and Settings\marv1shi\Desktop\Workspace\Existence Script\DBF Checker\Access_SQL.py, line 35, in ? curse.execute(sql) ProgrammingError: ('07001', -3010, '[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4.', 4612) The real stinker, however, is that after it bails I can manually call mycursor.execute('An SQL Statement'), then call my insert statement in the Python Shell and it works fine. I just can't figure out how to reconcile this problem. Has anybody run into this before? Thanks Greg Corradini I suspect what's happening here is that you are presenting statements you have made up programmatically, and the values you are trying to insert include apostrophes that break the syntax of your SQL. However there isn't really enough evidence to decide unless you are prepared to show us the error traceback, possibly with a dump of the SQL statement you are actually trying to execute. I apologize in advance if you are using parameterized queries (as you should to avoid SQL injection vulnerabilities among other major problems) but this message is typical of Access when it sees words it can't parse. Steve, As always, thanks for your consistent help on matters big and small. I've managed to solve the problem, although I'm scared b/c the bug is still elusive. I dumped and deleted my separate Access DBs, created new ones and tried running the scripts on old data (that these scripts were able to digest successfully before) and new data (that they errored on to begin with). Everything works without me changing any code around. Hmm? I don't know much about Access or the JetEngine. Is it possible that .mdbs can go corrupt if overused? This seems unlikely, but I'm dumbfounded. Greg: No, there are no known cases of a database getting tired :-) It sounds like a data dependency of some sort, but if the error has gone away then I guess we no longer have anything to work with. This is somewhat annoying, as I hate to see an error go untraced. Take it from me, it does look like a SQL error - *are* you building your statements in the program, or are you using proper parameterization with ? in your statements where a parameter would go? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list Steve, Thanks for your reply. I used the proper parameterization with ? in my SQL statements and still the problem persisted (although now it's gone). I do agree, an untraced error is definately annoying. Next time, I'll be more patient despite the workflow pileing up in front of me. Marc-Andre Lemburg did offer a couple pieces of advice that I'll follow up on and read about. He mentioneded the connection pooling and Access driver version I'm working with. Thanks again Greg Corradini -- View this message in context: http://www.nabble.com/Help-Understanding-mx.ODBC-Error-tf3602497.html#a10077031 Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On 2007-04-19, Steve Holden [EMAIL PROTECTED] wrote: Michael Bentley wrote: On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: [...] The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. Mathematical absurdities aside, it's the common usage -- but perhaps you knew that. Perhaps in Belgium they prefer climbing mountains over walking up and down gentle hills? Or possibly they will simply pick any nit that is carelessly left within range? If it is just a nit, why don't you ignore my remark as I suggested? Now suppose I give you a graph that shows you how different people are making progress. Would you prefer the rather flat curves instead of the steep curves because the latter gives you the idea of someone having to conquer huge obstacles or would you choose the steep curve because they show you someone is getting results fast? -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Steven Howe wrote: Alan Isaac wrote: [type comparison stuff] I love scripting languages ... but sometimes an explicit evaluation that one would find in a compiled language is better. better in what sense? Which is why I suggested using the explicit type(x) == types.NoneType as opposed to x is None This seems to go entirely against the spirit of the language. It's about as sensible as writing (3 4) == True The language *guarantees* that there is only one instance of types.NoneType, so why not just test for it directly? Among other things this avoids the need for an explicit import of the types library just so you can access the namespace. For extra marks, please explain why you prefer type(x) == type(None) # or types.NoneType to type(x) is type(None) The canonical test is, as has already been explained, x is None and to use anything else hinders the readability of your code. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
Antoon Pardon wrote: On 2007-04-19, Steve Holden [EMAIL PROTECTED] wrote: Michael Bentley wrote: On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: [...] The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. Mathematical absurdities aside, it's the common usage -- but perhaps you knew that. Perhaps in Belgium they prefer climbing mountains over walking up and down gentle hills? Or possibly they will simply pick any nit that is carelessly left within range? If it is just a nit, why don't you ignore my remark as I suggested? Because I suffer from the quixotic urge to help stamp out obsessive compulsive behavior on c.l.py? This is self-defeating, of course, since it makes me appear obsessive compulsive in my own right ... Now suppose I give you a graph that shows you how different people are making progress. Would you prefer the rather flat curves instead of the steep curves because the latter gives you the idea of someone having to conquer huge obstacles or would you choose the steep curve because they show you someone is getting results fast? Suppose I should you a hill you have to climb? Would you rather don mountain boots and crampons to climb 3,000 feet up a vertical cliff or would you rather amble up, say, Ben Lomond with the other tourists? Clearly you have no wish to bow before common usage. be careful this doesn't put you in a universe with only one inhabitant. We all have to get along. obsessive-compulsive-ly y'rs - steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter canvas
[EMAIL PROTECTED] wrote: On Apr 18, 3:43 pm, Gigs_ [EMAIL PROTECTED] wrote: how to write text on canvas. i know that i need to use canvas.create_text, but how to write text than when i create_text? or how to access object ID in canvas and change some options? thanks in advance! All you need to do is canvas.create_text(x, y, text='Hello World') where x and y are coordinates on the canvas. You can also add fg and/ or bg to set foreground and background colors, respectively. Mike but is there any option to bind event? when i create text i want to write in text box on canvas so i think that i need to bind event -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and XML?
Hi, Leonard J. Reder wrote: Stefan Behnel wrote: http://codespeak.net/lxml/objectify.html Looks like this stuff might do what I want. Need to work through the example. Are you the author? Yup! :) Why is this better then using gnossis? lxml is faster and supports more XML standards. It's also more flexible in that it allows you to replace element classes at basically any granularity and thus add things to the Element API or even replace it as you see fit, without loosing the standard XML features. You can even do that at the C-level, in case you really need high-performance. See the extending lxml section in the side menu at http://codespeak.net/lxml/dev/ especially: http://codespeak.net/lxml/dev/element_classes.html Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
Teja wrote: how to generate CHM files in Boa(Python)??? http://www.rutherfurd.net/software/rst2chm/index.html TJG Can't I do it in Boa constructor ??? I have seen an option in Boa to create a new helpbook and compile it to CHm and help files, But no clue how to do it... Not that I know of. Which version are you using? Where in the application did you find it? Indicate the menu's you navigated to get to that option. MS HTML Help Workshop is the standard compiler for CHM files. There are some other freeware/shareware. The workshop is simple enough though. If u have Boa constructor 0.4.4, Go to File---New---helpbook Save it. After saving, click File menu option and you will find, make HTB and make CHM But I dont know how to add files and generate a complete CHM file. Right-click the file list view and select Add files. I didn't see this Helpbook feature before. However, I could not get it to compile after that. Unless, Boa Constructor is doing something while building CHMs that integrates with the app development, I recommend that you try a specialized tool for the job instead. Boa was an extremely promising tool when I saw it about 6 yrs ago or so at 0.0.1 (it already had a streamlined WYSIWYG GUI builder with a code aware editor back then, something we still don't have elsewhere for Python). But the development never seemed to gather steam since then. 0.4.4 is not even listed as a release on the home page and it is almost 2 yrs old. -- http://mail.python.org/mailman/listinfo/python-list
RE: Do other Python GUI toolkits require this?
I don't know how this whole things started, But it is funny on both sides. And hilarious from the outside. It sounds like university Banter really. And who can avoid getting their 2 cents in. Honestly And people say computers are all about science. You guys prove that we are all as much tech geeks and semantic geeks. From my own experiential education background, and currently trying to learn python I would say my exposure to python as a scripting language is a logical extension to my knowledge of DOS and BASH scripting so in that respect I am on a shallow learning curve. That is little effort (say 5 on the X axis) over a given time (say 10 y). Now, my goal is to take what I had learn about VB6 over the last number of months to modify a chunk of in-house software My learning curve was steeper. That is I had the same amount of time (10 y) but I had to put in some more effort, so a moderate curve using 10 X as my peak, or point where I plateau. However where I as a newbie am having a hard time is programming a GUI and full application using python (hence why I saw the topic), and understanding OOP. Therefore right now I feel as though I am on a steep learning curve. So maybe 20 or 30 on the X and I still have the same amount of time. To further support this I took the first result of google (of course the worlds most authoritative resource on randomness) and went to this BLOG (worlds best phenomena of random and unsubstantiated opinions). http://createwhatmattersmost.blogspot.com/2006/10/learning-curve-explain ed.html And found this I guess I'm approaching the knee of the learning curve, that magical transition point on the learning at which you begin to generate results far out of proportion to time and energy expended. This tells me my understanding is the common accepted one of X= Effort, Y= time or productivity ... But really productivity is a function of time. C'mon now folks, if this is university banter the least I should see is some referencing. Thanks for demonstrating my own lack of will power and propensity to engage in both of your OCB. Now I must get back to my steep learning curve or else I will be back on the street. Cheers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Holden Sent: April 19, 2007 08:25 To: python-list@python.org Subject: Re: Do other Python GUI toolkits require this? Antoon Pardon wrote: On 2007-04-19, Steve Holden [EMAIL PROTECTED] wrote: Michael Bentley wrote: On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: [...] The learning curve is rather steep IMO, but worth it. Just a throw in remark, that you may ignore if you wish, but a steep learning curve means that the subject is easily familiarized and that the learning period is short. You seem to use it as if it is the opposite. Mathematical absurdities aside, it's the common usage -- but perhaps you knew that. Perhaps in Belgium they prefer climbing mountains over walking up and down gentle hills? Or possibly they will simply pick any nit that is carelessly left within range? If it is just a nit, why don't you ignore my remark as I suggested? Because I suffer from the quixotic urge to help stamp out obsessive compulsive behavior on c.l.py? This is self-defeating, of course, since it makes me appear obsessive compulsive in my own right ... Now suppose I give you a graph that shows you how different people are making progress. Would you prefer the rather flat curves instead of the steep curves because the latter gives you the idea of someone having to conquer huge obstacles or would you choose the steep curve because they show you someone is getting results fast? Suppose I should you a hill you have to climb? Would you rather don mountain boots and crampons to climb 3,000 feet up a vertical cliff or would you rather amble up, say, Ben Lomond with the other tourists? Clearly you have no wish to bow before common usage. be careful this doesn't put you in a universe with only one inhabitant. We all have to get along. obsessive-compulsive-ly y'rs - steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about Tkinter MenuOption variable
Rob Wolfe wrote: Chad wrote: ... I have a menu option(code is below) I would like to have corresponding values of 01, 02, 03 and so on What about using dictionary? For example: OPTIONS = dict(Jan=1, Feb=2, Mar=3, Apr=4, May=5, June=6, July=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12) # or #OPTIONS = dict(Jan=01, Feb=02, Mar=03, Apr=04, May=05, June=06, July=07, # Aug=08, Sep=09, Oct=10, Nov=11, Dec=12) or OPTIONS = dict((m, n + 1) for n, m in enumerate( 'Jan Feb Mar Apr May June July Aug Sep Oct Nov Dec'.split())) -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI Script using Python
On Apr 19, 11:34 am, Ralf [EMAIL PROTECTED] wrote: Hello, is there anybody who can help me. I would like to use a Python Script to download Files from a Server to the Client, to update the Client. Downman is an example of a Python CGI which presents files for download. http://www.voidspace.org.uk/python/cgi.shtml#downman You will want to copy the part that sends the right headers (etc)... Fuzzyman Thanx Ralf -- http://mail.python.org/mailman/listinfo/python-list
Re: using tkinter to display html
On Apr 19, 6:29 am, Stephen M. Gava [EMAIL PROTECTED] wrote: Hi all, I prefer using tkinter to wxpython (so sue me :) and i need to display a lot of html in a particular app. does anyone know if one of the existing add on tk html widgets have been wrapped for tkinter already? TIA for any reply, Stephen The following thread has various ideas in it: http://mail.python.org/pipermail/python-list/2001-October/107989.html I know wxpython has widgets specifically made to display html or even wrap Internet Explorer, ActiveX and more. Good luck! Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
On Thu, 19 Apr 2007 08:18:30 -0400, Steve Holden wrote: Which is why I suggested using the explicit type(x) == types.NoneType as opposed to x is None This seems to go entirely against the spirit of the language. It's about as sensible as writing (3 4) == True Please! For extra certainty, you should write that as: ((int(3) int(4)) == True) == True Explicit is better than sensible, yes? *wink* -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
On Wed, 18 Apr 2007 15:19:26 -0700, Steven Howe wrote: I've read and found that 'None' comparisons is not always a good idea. You're probably thinking of testing against None with equality: if x == None: do_something() That can go wrong if x is a class that has an overly-broad concept of equality, e.g.: class FalseKlass: def __eq__(self, other): # equal to anything that is False return not other Better to: from types import NoneType x = None if type( x ) == NoneType: # true code else: # false; do something else. more code Not necessary. Since None is a guaranteed singleton, the only test you need to make is if x is None: But if you wanted to do extra work unnecessarily, a less unnecessary amount of extra work would be: if type(x) == type(None): ... You don't need to look up the type of None in the types module when you can easily get it from the type() function. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Byte-Array to String
Hello Guys, I have a byte array passed to me by dbus and I'm looking to convert it into a string? Is that possible? Sorry for seeming like a putts with these questions, I'm not used to all these complex data types :-D The byte array looks something like this when printed to screen. dbus.Array([dbus.Byte(54), dbus.Byte(0), dbus.Byte(24), dbus.Byte(9), dbus.Byte(0), dbus.Byte(0), dbus.Byte(10), dbus.Byte(0), dbu s.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(9), dbus.Byte(0), dbus.Byte(1), dbus.Byte(53), dbus.Byte(3), dbus.Byte(25), dbus. Byte(16), dbus.Byte(0), dbus.Byte(9), dbus.Byte(2), dbus.Byte(0), dbus.Byte(53), dbus.Byte(3), dbus.Byte(9), dbus.Byte(1), dbus.By te(1)], signature=dbus.Signature('y')) Thanks again, Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Byte-Array to String
Robert Rawlins - Think Blue wrote: I have a byte array passed to me by dbus and I'm looking to convert it into a string? Is that possible? Sorry for seeming like a putts with these questions, I'm not used to all these complex data types :-D dbus.Array([dbus.Byte(54), dbus.Byte(0), dbus.Byte(24), dbus.Byte(9), dbus.Byte(0), dbus.Byte(0), dbus.Byte(10), dbus.Byte(0), dbu s.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(9), dbus.Byte(0), dbus.Byte(1), dbus.Byte(53), dbus.Byte(3), dbus.Byte(25), dbus. Byte(16), dbus.Byte(0), dbus.Byte(9), dbus.Byte(2), dbus.Byte(0), dbus.Byte(53), dbus.Byte(3), dbus.Byte(9), dbus.Byte(1), dbus.By te(1)], signature=dbus.Signature('y')) No idea, but what happens when you iterate over it? for i in array_thingy: print i Or does it support the buffer interface? for i in buffer (array_thingy): print i If it did then you can at least get access to its innards and construct some kind of string representation. I've no idea what the numbers are supposed to represent, so I don't know what convert it to a string is likely to imply. This looks rather more like a dbus question than a strictly Python one. Is there a DBus mailing list or what-have-you? TJG -- http://mail.python.org/mailman/listinfo/python-list
RE: Byte-Array to String
Thanks for getting back to me on this Tim, *pauses pulling his hair out for a moment. I'm back on this damn API and its driving me crazy I get three options really for returning a service record from the API, they look like this. array{uint32} GetRemoteServiceHandles(string address, string match) This method will request the SDP database of a remote device and retrieve the service record handles. To request service browse send an empty match string. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.InProgress org.bluez.Error.ConnectionAttemptFailed org.bluez.Error.Failed array{byte} GetRemoteServiceRecord(string address, uint32 handle) This method will request the SDP database of a remote device for a service record and return the binary stream of it. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.InProgress org.bluez.Error.Failed string GetRemoteServiceRecordAsXML(string address, uint32 handle) This method will request the SDP database of a remote device for a service record and return its data in XML format. Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.InProgress org.bluez.Error.Failed The first method, when I print its results just gives me dbus.Array([dbus.UInt32(65547L)], signature=dbus.Signature('u')) the method gives me that byte array and the third doesn't appear to work at all :-D Unfortunately nowhere seems to document what exactly those arrays contain, so I'm trying to crack one open and find out, but as you can see, I'm not having much luck. Perhaps this is a DBus thing, they do have a mailing list so I'll give them a go in a while. If you have any brain waves let me know mate, I'll add another beer to the tab, Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Golden Sent: 19 April 2007 15:54 Cc: python-list@python.org Subject: Re: Byte-Array to String Robert Rawlins - Think Blue wrote: I have a byte array passed to me by dbus and I'm looking to convert it into a string? Is that possible? Sorry for seeming like a putts with these questions, I'm not used to all these complex data types :-D dbus.Array([dbus.Byte(54), dbus.Byte(0), dbus.Byte(24), dbus.Byte(9), dbus.Byte(0), dbus.Byte(0), dbus.Byte(10), dbus.Byte(0), dbu s.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(9), dbus.Byte(0), dbus.Byte(1), dbus.Byte(53), dbus.Byte(3), dbus.Byte(25), dbus. Byte(16), dbus.Byte(0), dbus.Byte(9), dbus.Byte(2), dbus.Byte(0), dbus.Byte(53), dbus.Byte(3), dbus.Byte(9), dbus.Byte(1), dbus.By te(1)], signature=dbus.Signature('y')) No idea, but what happens when you iterate over it? for i in array_thingy: print i Or does it support the buffer interface? for i in buffer (array_thingy): print i If it did then you can at least get access to its innards and construct some kind of string representation. I've no idea what the numbers are supposed to represent, so I don't know what convert it to a string is likely to imply. This looks rather more like a dbus question than a strictly Python one. Is there a DBus mailing list or what-have-you? TJG -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Byte-Array to String
Robert Rawlins - Think Blue wrote: [... snip ...] The first method, when I print its results just gives me dbus.Array([dbus.UInt32(65547L)], signature=dbus.Signature('u')) the method gives me that byte array and the third doesn't appear to work at all :-D Unfortunately nowhere seems to document what exactly those arrays contain, so I'm trying to crack one open and find out, but as you can see, I'm not having much luck. Perhaps this is a DBus thing, they do have a mailing list so I'll give them a go in a while. Have you tried doing the old help (xxx) or dir (xxx) on the array objects? It might at least point to some kind of properties or structural methods? TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling private base methods
You appear to have led a very sheltered life if the only libraries you ever use are ones where you can always get a change to the library api in a timely manner. The thing here is that we are not talking about my life. I may not have expressed my self correctly, but you are not understanding the point I am trying to make. You can say that you don't like C++ or Java because they put too much restriction when members are declared private. That you prefer Python's approach because in a time of need it will make your life easier. All that is fine with me. It is just a matter of taste. But the truth is that C++ and Java made a decision to do that for a reason, and the times when you have to work around those language features come once in a blue moon; they are the exception, not the rule, and you don't implement features in a language, or for that matter in an application, to simplify the exceptions; you try to implement the most common scenarios. Which features you add to your programs? The features your customers' ask for because they need them and they use them all the time or the ones that you like to implement even if they are not ever used? Thanks, - Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter canvas
On Apr 19, 7:24 am, Gigs_ [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Apr 18, 3:43 pm, Gigs_ [EMAIL PROTECTED] wrote: how to write text on canvas. i know that i need to use canvas.create_text, but how to write text than when i create_text? or how to access object ID in canvas and change some options? thanks in advance! All you need to do is canvas.create_text(x, y, text='Hello World') where x and y are coordinates on the canvas. You can also add fg and/ or bg to set foreground and background colors, respectively. Mike but is there any option to bind event? when i create text i want to write in text box on canvas so i think that i need to bind event I'm not sure what you mean. Do you want to type your text into a textbox and as you type, you want it displayed on the canvas itself as well? If that is the case, then yes, you'll need to bind an event. If you just want to type text in a textbox that is on a canvas, the textbox widget takes care of everything and binding an event is unnecessary. Here is some info on events: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm http://www.builderau.com.au/program/print.htm?TYPE=storyAT=339272995-339024614t-32000c http://www.bembry.org/technology/python/notes/tkinter_3.php Hope that points you in the right direction. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: multiremberco
Anton Vredegoor wrote: [EMAIL PROTECTED] wrote: Try it with def test(): L = 'a', 1, 2, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() The last print statement raises StopIteration... We, however, expected each iterator to contain two elements (one yielding 'a' then 'a', and the other yielding 1 then 2). Ouch! I never understood much about generators anyway. How about this one? from collections import deque class sentinel(object): pass class myiter(object): def __init__(self,seq): self.seq = seq self.index = -1 def __iter__(self): return self def next(self): self.index +=1 if self.index len(self.seq): return self.seq[self.index] else: return sentinel def mygen(seq): for x in seq: if x is sentinel: #way past bedtime raise StopIteration yield x def xsplitter(seq, pred): Q = deque(),deque() it = myiter(seq) def gen(p): for x in it: while Q[p]: yield Q[p].popleft() if pred(x) == p: yield x else: Q[~p].append(x) for x in gen(p): yield x return map(mygen,[gen(1),gen(0)]) def test(): L = 'a', 1, 2, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Byte-Array to String
Robert Rawlins - Think Blue wrote: Hello Guys, I have a byte array passed to me by dbus and I'm looking to convert it into a string? Is that possible? Sorry for seeming like a putts with these questions, I'm not used to all these complex data types :-D The byte array looks something like this when printed to screen. dbus.Array([dbus.Byte(54), dbus.Byte(0), dbus.Byte(24), dbus.Byte(9), dbus.Byte(0), dbus.Byte(0), dbus.Byte(10), dbus.Byte(0), dbu s.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(9), dbus.Byte(0), dbus.Byte(1), dbus.Byte(53), dbus.Byte(3), dbus.Byte(25), dbus. Byte(16), dbus.Byte(0), dbus.Byte(9), dbus.Byte(2), dbus.Byte(0), dbus.Byte(53), dbus.Byte(3), dbus.Byte(9), dbus.Byte(1), dbus.By te(1)], signature=dbus.Signature('y')) Thanks again, Rob * * When reading about array, I wondered what the hell it was good for. Now I see. It's a tool to build objects to pass to the Operating System or other applications. Something like ctypes. The OS might store data from left to right, or right to left, or not use IEEE standards (which VMS certainly doesn't). So the data you give/get from the system call must be massaged by the application before it's usable. python/lib/module-array.html (5.14 array -- Efficient arrays of numeric values) *array.tostring*( ) /Convert the array to an array of machine values and return the string representation (the same sequence of bytes that would be written to a file by the tofile() method.)/ I wonder if this is the method you are looking for. So you have an object dbus.Array, which, obviously is from a call to the dbus (another application's data) that contains 28 byte arrays. I would assume you know which you want, say the first one. myDbusString01 = dbus.Array[0].tostring() or to get the lot: myDbusStrings = [] #create a new empty list for array in dbus.Array: myDbusStrings.append( array.tostring() ) At this point you should have the array converted. But you will still need a reference as to what you have. The call to the dbus should have some documentation abut what it's returning. Also I'd expect the second example to be very bad programming, as some of the array elements are probably not going to be characters. They could be integers, floats or booleans. So creating a dictionary to handle specific array element handling is probably a better, less error prone, method of attack. Not have the contents and defination of your dbus.array handy, I can't test this, but the approach seems reasonable. Steven Howe -- http://mail.python.org/mailman/listinfo/python-list
Python un-plugging the Interpreter
Hi All, I was thinking about the feasbility of adjusting Python as a compiled language. Being said that I feel these are the following advantages of doing so -- 1) Using the powerful easy-to -use feature of Python programming language constructs. 2) Making the program to run at par with the compiled version of C/C++ program- this is the main benefit which can be derived out of this. 3) Highly re-use existing Python code for High performance application. 4) Acheive true parallelism and performance by getting rid of the middle-man Interpreter and GIL. I know this must be appearing like a foolish idea. But I would like to know the opinion of people who might have thought about it. Thanks Moin -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Steven D'Aprano wrote: On Thu, 19 Apr 2007 08:18:30 -0400, Steve Holden wrote: Which is why I suggested using the explicit type(x) == types.NoneType as opposed to x is None This seems to go entirely against the spirit of the language. It's about as sensible as writing (3 4) == True Please! For extra certainty, you should write that as: ((int(3) int(4)) == True) == True Explicit is better than sensible, yes? *wink* Your example, even with the *wink*, is stupid. The language requires 3 to be an integer, 4 to be an integer. The point I was show is with respect to a returned variable (like from a function or method? *wink* *wink*). For example, if you expect an open file handle, but get a NoneType because you didn't really open a file (having given a bad name or maybe didn't have permission to open a file), then it would be best to test the type of return object before using it. Then you program could handle the error gracefully (*wink* *wink* *wink*). As much as I love Python, it's ability to morph an object type can be a pain. Testing before using can prevent a program from Error-ing out. Steven Howe -- http://mail.python.org/mailman/listinfo/python-list
Re: Python un-plugging the Interpreter
S.Mohideen wrote: Hi All, I was thinking about the feasbility of adjusting Python as a compiled language. Being said that I feel these are the following advantages of doing so -- 1) Using the powerful easy-to -use feature of Python programming language constructs. 2) Making the program to run at par with the compiled version of C/C++ program- this is the main benefit which can be derived out of this. 3) Highly re-use existing Python code for High performance application. 4) Acheive true parallelism and performance by getting rid of the middle-man Interpreter and GIL. I know this must be appearing like a foolish idea. But I would like to know the opinion of people who might have thought about it. It's a great idea. Look at ShedSkin, PyPy, and Jython, all of which tried to do it, and none of which really became finished products. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: multiremberco
Anton Vredegoor wrote: Anton Vredegoor wrote: [EMAIL PROTECTED] wrote: Try it with def test(): L = 'a', 1, 2, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() The last print statement raises StopIteration... We, however, expected each iterator to contain two elements (one yielding 'a' then 'a', and the other yielding 1 then 2). Ouch! I never understood much about generators anyway. How about this one? No that can result in an infinite loop after yet another print it1.next() This one however ... from collections import deque class sentinel(object): pass class myiter(object): def __init__(self,seq): self.seq = seq self.index = -1 def __iter__(self): return self def next(self): self.index +=1 if self.index len(self.seq): return self.seq[self.index] else: return sentinel def xsplitter(seq, pred): Q = deque(),deque() it = myiter(seq) def gen(p): for x in it: while Q[p]: yield Q[p].popleft() if x is sentinel: break if pred(x) == p: yield x else: Q[~p].append(x) for x in gen(p): yield x return gen(1),gen(0) def test(): L = 'a', 1, 2, 'a' it1, it2 = xsplitter(L, lambda x: x == 'a') print it1.next() print it2.next() print it1.next() print it2.next() if __name__=='__main__': test() A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Iterate through a dictionary of lists one line at a time
wswilson a écrit : Here is my code: listing = {'id': ['a', 'b', 'c'], 'name': ['Joe', 'Jane', 'Bob']} I need to output: id name a Joe b Jane c Bob I could do: print 'id', 'name' for id, name in zip(listing['id'], listing['name']): print id, name but that only works if there are two entries in the dictionary, id and name, and I know what they are. My problem is I don't know how many of these entries there will be. Thanks for any help you can give! The most simple and generic I see, it could be even more simple if you don't care of memory usage : Let's fill a random dict : In [118]: d=dict(zip((str(e) for e in xrange(10)), ([i**e for e in xrange(5)] for i in xrange(10 In [119]: d Out[119]: {'0': [1, 0, 0, 0, 0], '1': [1, 1, 1, 1, 1], '2': [1, 2, 4, 8, 16], '3': [1, 3, 9, 27, 81], '4': [1, 4, 16, 64, 256], '5': [1, 5, 25, 125, 625], '6': [1, 6, 36, 216, 1296], '7': [1, 7, 49, 343, 2401], '8': [1, 8, 64, 512, 4096], '9': [1, 9, 81, 729, 6561]} go on : In [146]: sorted_keys = tuple(sorted(d.keys())) In [147]: from itertools import izip, chain In [148]: sorted_keys = tuple(sorted(d.keys())) In [149]: sorted_values = ( d[k] for k in sorted_keys ) In [150]: for vals in chain([sorted_keys], izip(*sorted_values)) : .: print '%5s'*len(d) % vals .: .: 0123456789 1111111111 0123456789 0149 16 25 36 49 64 81 018 27 64 125 216 343 512 729 01 16 81 256 625 1296 2401 4096 6561 -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 4 26 88 00 97 Mobile: +33 6 32 77 00 21 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python COM iterator
Carsten Haese wrote: [...] On Tue, 2007-04-17 at 16:54 -0500, Larry Bates wrote: Does anyone know if there is a way to make a Python COM object act like a proper iterator in VB/Delphi? [...] After more googling, staring at win32com's code, and a fair bit of trial and error, I've come up with the following working example: # server.py import pythoncom class HelloWorld: _reg_clsid_ = {CAB8BED1-9174-4AAD-ABC5-F377951CB71B} _reg_desc_ = Python Test COM Server _reg_progid_ = Python.TestServer _public_methods_ = ['Next'] _com_interfaces_ = [pythoncom.IID_IEnumVARIANT] def __init__(self): self.numbers=[1,2,3,4,5,6,7,8] def Next(self, count): assert count==1 try: return (self.numbers.pop(0),) except IndexError: return () def _NewEnum(self): import win32com.server.util return win32com.server.util.wrap(self) if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) # client.py import win32com.client comobj = win32com.client.Dispatch(Python.TestServer) for x in comobj: print x This works for me on Python 2.5 and pywin32 Build 210, but I don't know whether clients in VB or Delphi are able to use this iterator. -Carsten I tested in VB and by golly it works! What is odd is that this looks NOTHING like what we got from the docs earlier. No GetEnumerator method, no MoveNext method. I'm glad it works, but I'm a little puzzled as to why it works. Thanks loads. -Larry -- http://mail.python.org/mailman/listinfo/python-list
PythonD 2.4.2 for older Windows / DOS / DJGPP
Hello. There has been some confusion as to the current version of the python programming language available for DOS. This is partially due to incorrect information kept on python.org, that says python2.2.1 available for DOS. The actual version is currently 2.4.2. I am also happy to announce that a second release of PythonD. Additionally, there are many fine module libraries hat have been made available including Python-opengl and curses. The URL for PythonD has moved. It is now http://www.caddit.net/pythond not that this is NOT the same as http://www.caddit.net/pythond.php, which it was formerly. Please update your bookmarks. It would also be nice if someone else could raise a ticket to have python.org website updated. Regards, Ben Decker director caddit.net -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
On 4/19/07, Steven Howe [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Thu, 19 Apr 2007 08:18:30 -0400, Steve Holden wrote: Which is why I suggested using the explicit type(x) == types.NoneType as opposed to x is None This seems to go entirely against the spirit of the language. It's about as sensible as writing (3 4) == True Please! For extra certainty, you should write that as: ((int(3) int(4)) == True) == True Explicit is better than sensible, yes? *wink* Your example, even with the *wink*, is stupid. The language requires 3 to be an integer, 4 to be an integer. The point I was show is with respect to a returned variable (like from a function or method? *wink* *wink*). For example, if you expect an open file handle, but get a NoneType because you didn't really open a file (having given a bad name or maybe didn't have permission to open a file), This won't happen, because an exception will be thrown instead. But if it *did*, you'd test with is None, not by type comparison. then it would be best to test the type of return object before using it. Then you program could handle the error gracefully (*wink* *wink* *wink*). As much as I love Python, it's ability to morph an object type can be a pain. Testing before using can prevent a program from Error-ing out. This is contrary to the vast majority of Python philosophy. Embracing rather than fighting it will result in a much more pleasant Python experience. Steven Howe -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling python from soruce vs RPM ?
On 4月19日, 下午5時49分, Paul Boddie [EMAIL PROTECTED] wrote: On 19 Apr, 04:39, howa [EMAIL PROTECTED] wrote: One more question: How to uninstall using the source package? the source package doesn't come with `make uninstall`? Right. That's another pitfall of most source distributions (ie. the Python sources from python.org) compared to system packages (ie. the package built from a source RPM or equivalent system source package). If you want a really quick solution to this which seems to work much of the time, look at checkinstall: http://asic-linux.com.mx/~izto/checkinstall/ This tool will make system packages by taking control of the usual build process, and you can then install and uninstall those system packages. Paul but i have the source package being installed...so any method/script to remove them? since finally i want to install via RPM ... thanks anyway -- http://mail.python.org/mailman/listinfo/python-list
Re: Shebang or Hashbang for modules or not?
On Fri, 13 Apr 2007 22:46:03 +0200, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Jorgen Grahn a écrit : ... If you distribute a Python program to Unix users in that form, they may not want to know or care which language it's written in. Especially if you decide, a few releases later, that you want to switch to Perl or something. troll No one in it's own mind would decide to switch from Python to Perl !-) /troll I was trolling a bit, too ;-) Actually, it made sense in my case. It was a typical Perl task -- a filter regex-parsing a huge (a few hundred megabytes) text file. Rewriting it in Perl for speed was faster and more readable than rewriting it in Python for speed. More seriously, and as far as I'm concerned, when I want to make a python script (by opposition to a python 'module') available as a unix command, I either use a symlink or a shell script calling the python script. A symlink yes, but a shell script? Wouldn't it be easier to write a one-liner (well, two-liner) Python script in that case? I'm used to having a shebang in every .py file An encoding declaration might be more useful IMHO !-) ... I always use both. Even in modules ? Yes, for a few reasons: - file(1) can tell it's Python source - I tend to leave unit tests in my modules - I just started doing that when I first tried Python; it's part of my mental boilerplate I don't claim they are good reasons. And since I strongly dislike setting the execute bit on things that aren't executable, I should probably stop using the shebang everywhere, too ... /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python COM iterator
Larry Bates wrote: Carsten Haese wrote: [iterative acess to COM objects] I tested in VB and by golly it works! What is odd is that this looks NOTHING like what we got from the docs earlier. No GetEnumerator method, no MoveNext method. I'm glad it works, but I'm a little puzzled as to why it works. Presumably the magic of mark Hammond's wrapper classes providing adaptation between Python iteration and COM enumerable collection objects. win32all is *very* Pythonic. Jim Hugunin, the author of IronPython (and of J[P]ython before that) has commented that Microsoft users are frequently surprised by the small amount of code required in IronPython to manipulate .NET objects. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Relative import problem
Hi all, I want to structure my app so that I have two dirs like; obj/{object files} gui/{gui files} Here comes the catch. From the GUI dir, I would like to access the obj submodule path. I need to go one dir back.. I read there was something like from .. import x in python 2.5 so that I could access my obj dir from a lower level, but I have problems getting this to work. Example; In the main dir I have; main.py: import gui gui.gui.startme() In the obj dir I have; obj/obj.py - def start(): print 'Started OBJ' - In the GUI dir I have gui/gui.py - from .. import obj def start(): obj.obj.start() - This does not work. It gives me; D:\personal\src\GuitarPortfolio\tmppython start.py Traceback (most recent call last): File start.py, line 4, in module gui.gui.start() AttributeError: 'module' object has no attribute 'gui' Am I shooting myself in the foot by trying to structure? Or are there better more elegant ways? Regards, - Jorgen -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Steven Howe wrote: Alan Isaac wrote: [type comparison stuff] I love scripting languages ... but sometimes an explicit evaluation that one would find in a compiled language is better. Actually all that language is Steve Howe's, not mine. (Just to be clear.) Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Steven D'Aprano [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] You shouldn't expect comparisons between types to sort the same from one version of Python to another, although they may, and in the future (Python 3) it is likely to become an error to compare incomparable objects. Indeed, that was the basis of my original question. I wondered why no exception was raised. Thanks, Alan Isaac PS Note that the change you mention will conflict with currently documented behavior: objects of different types always compare unequal. So this seems like a large change. -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Steven Howe wrote: Steven D'Aprano wrote: On Thu, 19 Apr 2007 08:18:30 -0400, Steve Holden wrote: Which is why I suggested using the explicit type(x) == types.NoneType as opposed to x is None This seems to go entirely against the spirit of the language. It's about as sensible as writing (3 4) == True Please! For extra certainty, you should write that as: ((int(3) int(4)) == True) == True Explicit is better than sensible, yes? *wink* Your example, even with the *wink*, is stupid. The language requires 3 to be an integer, 4 to be an integer. It also requires the reader to have a sense of humor. Where did you misplace yours? Come on, it was clearly meant to be a light-hearted poke, don't take life so seriously. The point I was show is with respect to a returned variable (like from a function or method? *wink* *wink*). For example, if you expect an open file handle, but get a NoneType because you didn't really open a file (having given a bad name or maybe didn't have permission to open a file), then it would be best to test the type of return object before using it. Then you program could handle the error gracefully (*wink* *wink* *wink*). Here you are actually arguing for the is test without realizing it. Since is actually checks for object identity (do my two operands occupy the same memory?) it has no need to check the types of its operands. If there's any possibility that you might have a NoneType (of which, as I appear to have to keep reminding you, there is precisely ONE instance, so why not just say None, since it's the ONLY NoneType object in the known universe) the correct paradigm is to guard the code with if f: ... I am aware that this opens the gates to the hordes who will now pile in pointing out that this will technique will fail if f is zero (integer, real or complex) or one of the many other items that evaluates to false in a Boolean context. I merely point out that none of those things are a file, and that to allow f to be *either* a file *or* one of those other things is inviting trouble in a very big way. However, if the hordes *insist* (as the hordes tend to, especially when partial to salty snails), the very *most* you need is if f is None: ... and anything else is overkill that harms the readability of your program. It's that poor readability that Steven D'Aprano was making fun of in his remarks above, which in truth only echoes what I felt like but refrained from writing when I pointed out the redundancy in the expression (3 4) == True. As much as I love Python, it's ability to morph an object type can be a pain. Testing before using can prevent a program from Error-ing out. You still don't convince me that there is there is *any* value in checking the type of an object to determine whether the object is None. If its type is types.NoneType it *must* be None. If it isn't None then no harm can be done by an identity comparison with None, since the type of the operands is irrelevant to is. regards Steve PS: Revision question: How many objects of type NoneType are there? -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
RE: tkinter canvas
I want to when create text box with objid = self.canvas.create_text(x, y, width=event.x-x, text='') how can i bind KeyPress to objid? I want that text appear on canvas as i write it. dont know do I need to use self.canvas.create_window, and put in that window Tkinter Text widget. Or I can do it with canvas.create_text. thanks! sorry for bad english, hope you understand what i mean -- http://mail.python.org/mailman/listinfo/python-list
Re: Python un-plugging the Interpreter
John Nagle wrote: S.Mohideen wrote: Hi All, I was thinking about the feasbility of adjusting Python as a compiled language. Being said that I feel these are the following advantages of doing so -- 1) Using the powerful easy-to -use feature of Python programming language constructs. 2) Making the program to run at par with the compiled version of C/C++ program- this is the main benefit which can be derived out of this. 3) Highly re-use existing Python code for High performance application. 4) Acheive true parallelism and performance by getting rid of the middle-man Interpreter and GIL. I know this must be appearing like a foolish idea. But I would like to know the opinion of people who might have thought about it. It's a great idea. Look at ShedSkin, PyPy, and Jython, all of which tried to do it, and none of which really became finished products. That's not really fair. ShedSkin and PyPy are still works in progress. Jython was feature-complete, and has merely suffered from delayed maintenance - the current maintainers are getting closer to current language standards as we speak. Even CPython is a worl in progress eben though it's normally treated as the reference implementation. The one compiling implementation you don't mention, of course, is IronPython. This compiles to the .NET/Mono CLR, which in turn can use JIT techniques to generate machine code that the runtime will cache und er the right circumstances. Overall, then, I think the picture's a little rosier than you paint it even though there's always room for improvement. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Using the Python interpreter
On Apr 18, 8:32 pm, [EMAIL PROTECTED] wrote: Instead of starting IDLE as I normally do, I started the Python interpreter and tried to run a program. I got a Python prompt (), and then tried unsuccessfully to run a Python script named Script1.py that runs perfectly well in IDLE. Here's what I did: Script1.py Traceback (most recent call last): File stdin, line 1, in ? NameError: name Script1 is not defined python Script1.py File stdin, line 1 python Script1.py SyntaxError: invalid syntax I can load it (and have it execute) by typing import Script1 0 1 2 3 4 and if I edit it, I can then execute it by reloading it import Script1 0 1 2 3 4 module 'Script1' from 'Script1.pyc' But this seems contrived - is there no way to repeatedly run Script1 from the interpreter without reloading it? Thomas Philips You want execfile: execfile(Script1.py) See http://pyref.infogami.com/execfile -- http://mail.python.org/mailman/listinfo/python-list
Re: Python un-plugging the Interpreter
S.Mohideen wrote: I was thinking about the feasbility of adjusting Python as a compiled language. In addition to the Python compilers listed by Steve, there is also Pyrex, which translates a Python-like language to C, and allows one to interact with it from Python with very little difficulty. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list
Re: Relative import problem
On Apr 19, 11:54 am, Jorgen Bodde [EMAIL PROTECTED] wrote: Hi all, I want to structure my app so that I have two dirs like; obj/{object files} gui/{gui files} Here comes the catch. From the GUI dir, I would like to access the obj submodule path. I need to go one dir back.. I read there was something like from .. import x in python 2.5 so that I could access my obj dir from a lower level, but I have problems getting this to work. Example; In the main dir I have; main.py: import gui gui.gui.startme() In the obj dir I have; obj/obj.py - def start(): print 'Started OBJ' - In the GUI dir I have gui/gui.py - from .. import obj def start(): obj.obj.start() - This does not work. It gives me; D:\personal\src\GuitarPortfolio\tmppython start.py Traceback (most recent call last): File start.py, line 4, in module gui.gui.start() AttributeError: 'module' object has no attribute 'gui' Am I shooting myself in the foot by trying to structure? Or are there better more elegant ways? Regards, - Jorgen I'm not finding much info on this subject. But here's the most interesting links I've found as of yet: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456362 http://www.thescripts.com/forum/thread549516.html http://www.thescripts.com/forum/thread42319.html http://docs.python.org/tut/node8.html Dunno if any of these will help you though. Sorry. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Future Python Gui?
It shouldn't change at all. I use Frame for Tkinter frames and Tile.Frame for Tile frames, since a lot of the widgets have the same names. Here's a sample: from Tkinter import * import Tile Thanks for all the info. I'm a little confused about using both Tkinter and Tile at the same time. Do the calls to Tkinter now get themed? What is the benefit of calling similar widgets for both modules within the same code? Why wouldn't I call everything via Tile? (i.e. from Tile import * and not import Tkinter at all) Thanks! -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonD 2.4.2 for older Windows / DOS / DJGPP
caddit wrote: Hello. There has been some confusion as to the current version of the python programming language available for DOS. This is partially due to incorrect information kept on python.org, that says python2.2.1 available for DOS. The actual version is currently 2.4.2. I am also happy to announce that a second release of PythonD. Additionally, there are many fine module libraries hat have been made available including Python-opengl and curses. The URL for PythonD has moved. It is now http://www.caddit.net/pythond not that this is NOT the same as http://www.caddit.net/pythond.php, which it was formerly. Please update your bookmarks. It would also be nice if someone else could raise a ticket to have python.org website updated. Submitted as http://pydotorg.python.org/pydotorg/ticket/423 Please note: it would have been helpful if you'd given the URL of the offending page! There is a report website bug link on each page of the python.org web site, though at present you have to email someone to get posting privileges (this is an anti-spam measure). regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Feature Request: Explicit variable declarations
On 14 Apr 2007 03:21:18 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... I would like to have something like the option explicit statement in Visual Basic which turns on C-like checking for declaration of variables. This is highly helpful for people who are coming from C/C+ +, for people who are learning programming using Python, As a C and C++ programmer (not a C/C++ programmer), I have to say that it doesn't bother me much. An optional feature like this would just annoy me if I encountered code using it. ... where the user has inadvertantly typed g before n and will later wonder why his application is not working as expected. Well, he won't *wonder* -- Python will be rather explicit about it. Later is the key word here -- this bug may lay around waiting for ten years before someone triggers it. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling python from soruce vs RPM ?
On 19 Apr, 18:40, howa [EMAIL PROTECTED] wrote: but i have the source package being installed...so any method/script to remove them? since finally i want to install via RPM ... You could use checkinstall to make a package, install it (forcibly if necessary), then remove it. That might wipe away the things installed when you did make install since checkinstall should note which files were to be installed, add them to its manifest, then construct the package such that those files will be removed when the package is uninstalled. No promises, though... Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Future Python Gui?
[EMAIL PROTECTED] wrote: What is the benefit of calling similar widgets for both modules within the same code? Why wouldn't I call everything via Tile? (i.e. from Tile import * and not import Tkinter at all) Because Tile depends on Tkinter, and also, not everything from Tkinter is in Tile (text widget, menus, etc). -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Relative import problem
On Apr 19, 6:54 pm, Jorgen Bodde [EMAIL PROTECTED] wrote: Hi all, I want to structure my app so that I have two dirs like; obj/{object files} gui/{gui files} Here comes the catch. From the GUI dir, I would like to access the obj submodule path. I need to go one dir back.. I read there was something like from .. import x in python 2.5 so that I could access my obj dir from a lower level, but I have problems getting this to work. Example; In the main dir I have; main.py: import gui gui.gui.startme() In the obj dir I have; obj/obj.py - def start(): print 'Started OBJ' - In the GUI dir I have gui/gui.py - from .. import obj def start(): obj.obj.start() - This does not work. It gives me; D:\personal\src\GuitarPortfolio\tmppython start.py Traceback (most recent call last): File start.py, line 4, in module gui.gui.start() AttributeError: 'module' object has no attribute 'gui' Am I shooting myself in the foot by trying to structure? Or are there better more elegant ways? Regards, - Jorgen You need to add the path to where your files are located since they are not in any of the standard path directories where Python looks. To do this, you can add the following lines in your files: import sys sys.path.append(/path/to/obj) sys.path.append(/path/to/gui) import obj import gui #etc.. Hope this helps -- http://mail.python.org/mailman/listinfo/python-list
Re: Python COM iterator
On Thu, 2007-04-19 at 12:49 -0400, Steve Holden wrote: Larry Bates wrote: Carsten Haese wrote: [iterative acess to COM objects] I tested in VB and by golly it works! What is odd is that this looks NOTHING like what we got from the docs earlier. No GetEnumerator method, no MoveNext method. I'm glad it works, but I'm a little puzzled as to why it works. I'm glad, too. Presumably the magic of mark Hammond's wrapper classes providing adaptation between Python iteration and COM enumerable collection objects. win32all is *very* Pythonic. There is some magic, but it appears to be on the client side only. This magic is what allows you to stick the win32com.client.Dispatcher object into a for-loop. If there were magic on the server side, it shouldn't be necessary to declare that IID_IEnumVARIANT is exposed, and it shouldn't be necessary to implement the _NewEnum and Next methods; it should be enough to have __iter__ present and let the magic take care of the rest. It appears that the reason why my first completely uninformed guess didn't work and my second somewhat less uninformed guess did work is that there are two different enumeration protocols in the wonderfully confusing world of Win32. I'm guessing that GetEnumerator/MoveNext is the .NET enumeration protocol and IID_IEnumVARIANT/Next is the COM enumeration protocol. -Carsten -- http://mail.python.org/mailman/listinfo/python-list
Creating search engine in Python Good or Bad [in performance]
I am now creating IR engine in python which has its own database implementation . For nearly 2GB files it works fast. Can i expect the same speed when my database goes large. Else i have to chose other language[c/c++] for the speed. Please tell me the solution -- http://mail.python.org/mailman/listinfo/python-list
Re: Binary file output using python
Peter Otten [EMAIL PROTECTED] wrote: Chi Yin Cheung wrote: Is there a way in python to output binary files? I need to python to write out a stream of 5 million floating point numbers, separated by some separator, but it seems that all python supports natively is string information output, which is extremely space inefficient. I'd tried using the pickle module, but it crashed whenever I tried using it due to the large amount of data involved. A minimalistic alternative is array.tofile()/fromfile(), but pickle should handle a list, say, of 5 million floating point numbers just fine. What exactly are you doing to provoke a crash, and what does it look like? Please give minimal code and the traceback. cPickle worked fine when I tried it... L=map(float, range(500)) import cPickle out=file(z, wb) cPickle.dump(L, out, -1) out.close() inp=file(z, rb) K=cPickle.load(inp) inp.close() import os os.system(ls -l z) -rw-r--r-- 1 ncw ncw 45010006 Apr 19 18:43 z 0 Indicating each float took 9 bytes to store, which is 1 byte more than a 64 bit float would normally take. The pickle dump / load each took about 2 seconds. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
NFS Help
how to get the file from NFS share in python.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python COM iterator
Larry Bates wrote: I tested in VB and by golly it works! What is odd is that this looks NOTHING like what we got from the docs earlier. No GetEnumerator method, no MoveNext method. I'm glad it works, but I'm a little puzzled as to why it works. The documention Carsten Haese referenced earlier was for the .NET version of VisualBasic, and shows how to use .NET's IEnumerate and IEnumerable interfaces. Steve Holden [EMAIL PROTECTED] wrote: Presumably the magic of mark Hammond's wrapper classes providing adaptation between Python iteration and COM enumerable collection objects. win32all is *very* Pythonic. Maybe Mark Hammond's win32all provides such a magic wrapper, but Cartsen Haese's example didn't use it. Instead it provided it own implementation of the COM IEnumVARIANT interface, the OLE Automation (ie. VisualBasic 6 compatable) way implementing iteratable objects. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] [EMAIL PROTECTED] -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: NFS Help
Clement wrote: how to get the file from NFS share in python.. NFS share is mounted on your local directory, you get to it the same way you would any other file (e.g. go to the mount point and get the file). -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating search engine in Python Good or Bad [in performance]
Clement wrote: I am now creating IR engine in python which has its own database implementation . For nearly 2GB files it works fast. Can i expect the same speed when my database goes large. Else i have to chose other language[c/c++] for the speed. Please tell me the solution Your speed will be good if your database design is good. We don't have a crystal ball out here to see into your database design. It is also not clear what the bottlenecks to speed would be for you. If it is disk I/O or LAN bandwidth C won't help at all. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Steven Howe a écrit : (snip) I've read and found that 'None' comparisons is not always a good idea. Better to: from types import NoneType x = None if type( x ) == NoneType: # true code else: # false; do something else. more code Actually, None is garanteed to be a singleton, so the idiomatic way is to use an identity test: if x is None: # code here But this doesn't answer the OP... HTH -- http://mail.python.org/mailman/listinfo/python-list