Re: Where can I find :
On Mar 29, 11:19 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Sat, 29 Mar 2008 20:15:59 -0700 (PDT), pythonnubie [EMAIL PROTECTED] declaimed the following in comp.lang.python: Hi All : Does anyone know where I can find either a book or a website that explains beginning python by actually building a project line by line and explaining it indepth . I am primarily interested in understading flowcontrol as well as syntax . Flow control, if I'm not misinterpreting your usage, is something that most common language books will not really cover -- that falls into the realms of software engineering... Or, at the simplest, structured design/programming (even if a language is OO, when one gets down to the actual logic of methods, one is back into structured programming). Syntax is covered in the Python language reference manual, and Python has a very simple vocabulary to learn. The two are disjoint concepts. Structured design applies to any language, one just has to map the constructs of the language (and since Python lacks a native GOTO, this becomes even simpler). That's weird. I feel like I could go on about an introductory program for days and days, la. I usually start (both times) with interpreted vs. compiled. It's a layer of abstraction. But it's very weird; the layers can't tell either of each other apart. I can hand you the machine instructions, the names of circuitry, that run Line 1 to Line 9 one time, but you can't tell the difference between the code and the data. Some of it lingers in post-perceptive operations: the memory system, for the record. Some lingers long times. So far it equates to different Pythons produce different Pythons, however, though, so I'll ask the spell checker. Python.get_back_in_skin(). Weird. I'm not sure if it makes any difference. The binary you run is Python.exe. It's already running, then you feed it a raw string, not on disk without loss of generality. The translation is a little hard to find too. Python :: mingw-c++ : Python.exe :: mingw-c++.exe : what? :: machine instructions.exe In Python there's a for-loop that's the exact same as one in machine instructions. 0101 b1= 1000 0110 if a b0 goto b1 0111 b2= b2+ 1 accumulates a number in register b2. You probably want interface and graphics primitives. Sometimes I feel like with a scroll bar suffices to specify all the detail you need; there's too many options. (I can do this and this and ... scroll bar, please.) You know the episode of Star Trek NG where Barclay takes over the Enterprise. I'd also like to be able to write (write) a series of instructions and have it loop, and debug in vivo, as though a BASIC program were running and I could edit lines in its doing so, maybe time Windows Media visualization codecs in time. You could tell story lines and have it refine, post-inspiration. You might be surprised how much repetition in instructions Lines 1 through 9 (of -code-) share, in both sides of the analogy. Anyone work with a VAX? -- http://mail.python.org/mailman/listinfo/python-list
( WWW.SNEAKERS-IN-CHINA.COM) Nike AF1 x Air Jordan 5. Nike Air Force Ones Shoes Air Jordan 5.
(www sneakers-in-china com) wholesale Air Jordan 1 Old Love/New Love Package (www sneakers-in-china com) Nike Air Jordan Retro 1 beginning moments BMP Package-Old Love New Love Edition (www sneakers-in-china com) selling Air Jordan DMP Defining Moments Package (www sneakers-in-china com) Air Jordan Retro XIII/X Collezione Package china outlet (www sneakers-in-china com) discount Air Jordan Collezione 13 10 Countdown Package cheap Air Jordan 1 Old Love/New Love Package discount Air Jordan 1 Old Love/New Love Package china customize custom shoes sneakers trainers outlet factory urban clothing,Hip Hop Clothes,urban wear distributor www.sneakers-in-china.com cheap Air Jordan DMP Defining Moments Package discount Air Jordan DMP Defining Moments Package china customize custom shoes sneakers trainers outlet factory urban clothing,Hip Hop Clothes,urban wear distributor www.sneakers-in-china.com cheap Air Jordan Retro XIII/X Collezione Package discount Air Jordan Countdown package Pack 10/13 X XIII china customize custom shoes sneakers trainers outlet factory urban clothing,Hip Hop Clothes,urban wear distributor www.sneakers-in-china.com Air Jordan Beginning Moments Package or Old Love New Love. The Air Jordan Old Love New Love Pack Retro 1 consists of two pairs of Air Jordan 1 (Retro White/Black-Varsity Red aka Black Toes Black/ Varsity-Maize/White).Comes with special slide out double box with many special moments with Michael Jordan and booklet. Air Jordan Beginning Moments Package or Old Love New Love. Sell Air Jordan 1 Retro-BMP Package Old Love New Love Edition The Air Jordan Old Love New Love Pack Retro 1 consists of two pairs of Air Jordan 1 (Retro White/Black-Varsity Red aka Black Toes Black/ Varsity-Maize/White). Size available: SIZE (US): 8 8.5 9.5 10 11 12,13 SIZE (UK): 7 7.5 8.5 9 10 11,12 SIZE (EURO): 41 42 43 44 45 46,47 Comes with special slide out double box with many special moments with Michael Jordan and booklet. we also sell and wholesale,retail air jordans,jordan sneakers shoes include: Air Jordan Retro womens shoes Air Jordan Retro kids shoes Air Jordan Spizikes Air Jordan Dub Zeros Air Jordan 4 Fusion Air Jordan 5 Fusion Air Jordan 12 Fusion Air Jordan 23 Fusion (www sneakers-in-china com)Wholesale New Air Jordan 12 Fusion,Air Jordan 12 X Air Force 1. Wholesale New Air Jordan 12 Fusion,Air Jordan 12 X Air Force 1 cheap Air Jordan 5 x Air Force one Fusion (www.sneakers-in-china.com) discount Air Jordan 5 and Air Force one Fusion(www.sneakers-in- china.com) Air Jordan 12 x Air Force One china online store(www sneakers-in-china com) (www sneakers-in-china com)Air Jordan V x Air Force 1 Fusion Air Jordan 12 x Air Force Ones Fusion (www sneakers-in-china com) (www sneakers-in-china com) Nike AF1 x Air Jordan 5. Nike Air Force Ones Shoes Air Jordan 5. wholesale Air Jordan 5 (V) x Air Force 1 Fusion (www sneakers-in-china com) Website: http://www sneakers-in-china com E-mail: sneakers_in_china @ yahoo com cn Msn: sneakers_in_china @ hotmail com -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with logic in reading a binary file
On Mar 30, 3:58 pm, hdante [EMAIL PROTECTED] wrote: On Mar 29, 3:44 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I am having trouble writing the code to read a binary string. I would like to extract the values for use in a calculation. Any help would be great. I'm too lazy to debug your binary string, but I suggest that you completely throw away the binary file and restart with a database or structured text. See, for example: http://pyyaml.org/wiki/PyYAML If you have some legacy binary file that you need to process, try creating a C program that freads the binary file and printfs a text equivalent. ... and that couldn't be done faster and better in Python?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python
On Mar 30, 12:34 am, [EMAIL PROTECTED] wrote: The screen is real (r-e-a-l): all manners intended. Real. Just bid and auction. Please leave the newbies alone. They have enough trouble just getting their Python environments running, without trying to decipher your pseudo-profound chatterbot-speak. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 29, 12:41 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Given that = is a comparison operator, not an assignment, why do you jump to the conclusion that != is an assignment? Why don't you argue that x = y means assign the value of xy to x? Yes, you are right, that could be confusing ;). Since you jump to an invalid conclusion about !=, the rest of your argument fails. No, you said = could be confusing, but we're talking about here, and there is no confusion about that :). -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 29, 6:34 pm, Lie [EMAIL PROTECTED] wrote: You're forcing your argument too much, both != and are NOT standard mathematics operators -- the standard not-equal operator is -- and I can assure you that both != and won't be comprehensible to non- programmers. What I meant was that both and are standard mathematics operators, and that by that knowledge one could deduce what means. But would also be fine by me :). -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 29, 9:48 pm, Dan Bishop [EMAIL PROTECTED] wrote: MOST of Python's operators are based on C's. Consider, for example, the bitwise operators | ^~ and the compound assignment operators += -= etc. The exceptions are ** (from Fortran), //, and the logical operators. Borrowing parts out of other languages (C in this case) is not a problem, but I don't think there is a need to try be consistent with C. It's Python, not C, so we should do things better ;). -- http://mail.python.org/mailman/listinfo/python-list
Re: Using QSystemTrayIcon with PyQt
On Sunday 30 March 2008, Alex Teiche wrote: Hello, I am pretty new to Python, and have never learned C++. I am trying to implement the following thing into my python application: http://doc.trolltech.com/4.3/qsystemtrayicon.html Through PyQt. I have been using PyQt for awhile and I know how do use it, but I could not get this specific thing to work. Can someone give me some hints as to get it working in Python? Thanks a ton, Alex Have you looked at PyQt's systray example? Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
En Sun, 30 Mar 2008 05:08:34 -0300, [EMAIL PROTECTED] escribió: On Mar 29, 12:41 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Since you jump to an invalid conclusion about !=, the rest of your argument fails. No, you said = could be confusing, but we're talking about here, and there is no confusion about that :). Yes, there is: looks like less or greater, and being equal or not is a different thing that being less or greater. Trichotomy law holds for real numbers (although some people don't even accept that) but not for floating point (NANs); and Python isn't about numbers only. For a lot of objects it makes sense to compare them for equality or not, but you can't say which one is greater than the other (the weather forecast, books in a bookstore) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Serial port error statistics - any comparable data?
Diez B. Roggisch wrote: if you have the chance, try attach a machine with legacy rs232 port, and see if the errors still remain. Additionally, what kind of buffers does your device have? I'm using pyserial to control a very sensitive device with nuttily implemented buffering strategy. It has a fast and a slow buffer which are filled in order, and no signalling to the outside sender on how full they are. If the fast buffer fills the slow buffer kicks in and requires less transmission rate. That may be how characters could be lost with you. Regards, Björn -- BOFH excuse #119: evil hackers from Serbia. -- http://mail.python.org/mailman/listinfo/python-list
Re: first interactive app
On Mar 27, 4:22 pm, Miki [EMAIL PROTECTED] wrote: Hello Tim, that looks nice, simple, and intuitive. thanks for thinking about it. Thanks, glad I could help. Now to dive into some gui coding! IMO you can pull it off as a web application and then you won't need to worry about cross-platform, upgrades and all that interesting stuff. Chapter 1 (001-200 200) Chapter 2 (200-300 100) -- 001-300 300 Does anyone want to see it under a graphics layer? -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
Lie wrote: Ah yes, that is also used (I completely forgot about that one, my math's aren't that sharp anymore) and I think it's used more frequently than . Where did you read that (I mean, which country)? I've never seen this sign in any german or english book on mathematics/physics/engineering I saw. but my argument was that no math book use != or (except in math for programmers). That's true. Personally, I don't ever use a!=b in favor of not a==b. Regards, Björn -- BOFH excuse #282: High altitude condensation from U.S.A.F prototype aircraft has contaminated the primary subnet mask. Turn off your computer for 9 days to avoid damaging it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Sun, 30 Mar 2008 01:13:04 -0700, dewitters wrote: On Mar 29, 6:34 pm, Lie [EMAIL PROTECTED] wrote: You're forcing your argument too much, both != and are NOT standard mathematics operators -- the standard not-equal operator is -- and I can assure you that both != and won't be comprehensible to non- programmers. What I meant was that both and are standard mathematics operators, and that by that knowledge one could deduce what means. But you would be wrong, because less than or greater than is not the same as not equal to. 3+2j != 2-3j True (3+2j 2-3j) or (3+2j 2-3j) Traceback (most recent call last): File stdin, line 1, in module TypeError: no ordering relation is defined for complex numbers -- Steven -- http://mail.python.org/mailman/listinfo/python-list
ANN: pygame 1.8 released
Hello, a new version of pygame is out. http://www.pygame.org/ Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system. http://www.pygame.org/wiki/about Silliness built in. Does not require OpenGL. Multi core CPUs can be used easily. Uses optimized C, and Assembly code for core functions. Comes with many Operating systems. Truly portable. It's Simple, and easy to use. Many games have been published. You control your main loop. Does not require a GUI to use all functions. Fast response to reported bugs. Small amount of code. Modular. http://pygame.org/whatsnew.shtml Some of the changes... * pygame.mask for pixel perfect collision detection * pygame.scrap for clipboard support * new and improved sprite groups, including layers, automatically selecting fastest update mode(full screen or dirty rect updates), and blend modes... * blending support for filling and blitting surfaces. ADD, SUB, MULT, DIV etc. * saving surfaces as jpeg and png * buffer access for Surface and Sound objects * numpy, and numeric support for pygame.surfarray and pygame.pixelarray * PixelArray, which can be used instead of numpy - without the dependency. * smooth scale function written in mmx assembly with C fallback. * More functions release the GIL for multithreaded use. * lots of speed ups to many functions via better python wrapping. * color thresholding, bounding box finding for images, and surface averaging. * massive documentation updates (which have been available on the website for a while already). * pygame.time.Clock.tick() is more cpu friendly. * updates to example programs. * new windows, and mac installers. * hardware acceleration updates for overlays and opengl. * porting work to different platforms. * heaps of bug fixes including SRCALPHA blitting fixes, 64bit fixes, sound system fixes. Plus there have been lots of changes to SDL itself since the last pygame release. http://www.libsdl.org/release/changes-1.2.html. * lots of stuff really... but those are some of the nice things. Read the what's new page for full details http://pygame.org/whatsnew.shtml cheers, -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
Hallöchen! Bjoern Schliessmann writes: Lie wrote: Ah yes, that is also used (I completely forgot about that one, my math's aren't that sharp anymore) and I think it's used more frequently than . Where did you read that (I mean, which country)? I've never seen this sign in any german or english book on mathematics/physics/engineering I saw. Maybe he means ≷. but my argument was that no math book use != or (except in math for programmers). That's true. Personally, I don't ever use a!=b in favor of not a==b. As a side note, I've always found == rather ugly. I'd prefer to have = for both purposes. The constructs that wouldn't work anymore are rare as far as I can see (and possibly there are even workarounds). Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing function objects to timeit
On Sun, 30 Mar 2008 01:27:18 -0300, Gabriel Genellina wrote: Second try: ... Horrible, I know. Those wrapper1,wrapper2,wrapper3... keep growing with each call. But it's the only way I could find, at least without changing the code template used by timeit. Eeek. Talk about namespace pollution. Thanks for the effort, but if that's the only solution, I think the solution is worse than the problem! Perhaps it's time for me to take a different approach. Since I can't call timeit, and I can't inherit from it (same problem with state being shared between instances), perhaps I should write my own timer. import timeit import gc import itertools def timeit2(func, args=[], kwargs={}, it=None, timer=timeit.default_timer): if it is None: it = itertools.repeat(None, timeit.default_number) save_gc = gc.isenabled() gc.disable() try: start = timer() for counter in it: func(*args, **kwargs) end = timer() finally: if save_gc: gc.enable() return end - start Now to go and test it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK localisation on Win32
On Thu, 2008-03-27 at 05:21 -0700, Sukhov Dmitry wrote: I have the same problem. I did all as you wrote. gettext translations do work fine. But translations in glade does not work. The only way to turn it on is to set environment variable LANG explicitly before program run: set LANG=ru_RU python test.py Yep, from python 2.4 on, os.environ changes only work within python and no longer apply to low level c stuff on win32. Luckily, it's still possible to force environment variables through the kernel32.SetEnvironmentVariableW and msvcrt._putenv functions. Put the attached locale module in a libi18n package and use like this: #!/usr/bin/env python from libi18n import locale locale.fix_locale() del locale hth, Dieter # -*- coding: utf-8 -*- # # locale.py - libi18n # Copyright (C) 2007-2008 Dieter Verfaillie [EMAIL PROTECTED] # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. import os import sys def _isofromlangid(langid): # ISO 639-1 #http://www.loc.gov/standards/iso639-2/ # List of existing mui packs: #http://www.microsoft.com/globaldev/reference/win2k/setup/Langid.mspx # List of known id's #http://www.microsoft.com/globaldev/reference/lcid-all.mspx lcid = {1078:'af',# Afrikaans - South Africa 1052:'sq',# Albanian - Albania 1118:'am',# Amharic - Ethiopia 1025:'ar',# Arabic - Saudi Arabia 5121:'ar',# Arabic - Algeria 15361: 'ar',# Arabic - Bahrain 3073:'ar',# Arabic - Egypt 2049:'ar',# Arabic - Iraq 11265: 'ar',# Arabic - Jordan 13313: 'ar',# Arabic - Kuwait 12289: 'ar',# Arabic - Lebanon 4097:'ar',# Arabic - Libya 6145:'ar',# Arabic - Morocco 8193:'ar',# Arabic - Oman 16385: 'ar',# Arabic - Qatar 10241: 'ar',# Arabic - Syria 7169:'ar',# Arabic - Tunisia 14337: 'ar',# Arabic - U.A.E. 9217:'ar',# Arabic - Yemen 1067:'hy',# Armenian - Armenia 1101:'as',# Assamese 2092:None,# Azeri (Cyrillic) 1068:None,# Azeri (Latin) 1069:'eu',# Basque 1059:'be',# Belarusian 1093:'bn',# Bengali (India) 2117:'bn',# Bengali (Bangladesh) 5146:'bs',# Bosnian (Bosnia/Herzegovina) 1026:'bg',# Bulgarian 1109:'my',# Burmese 1027:'ca',# Catalan 1116:None,# Cherokee - United States 2052:'zh',# Chinese - People's Republic of China 4100:'zh',# Chinese - Singapore 1028:'zh',# Chinese - Taiwan 3076:'zh',# Chinese - Hong Kong SAR 5124:'zh',# Chinese - Macao SAR 1050:'hr',# Croatian 4122:'hr',# Croatian (Bosnia/Herzegovina) 1029:'cs',# Czech 1030:'da',# Danish 1125:'dv',# Divehi 1043:'nl',# Dutch - Netherlands 2067:'nl',# Dutch - Belgium 1126:None,# Edo 1033:'en',# English - United States 2057:'en',# English - United Kingdom 3081:'en',# English - Australia 10249: 'en',# English - Belize 4105:'en',# English - Canada 9225:'en',# English - Caribbean 15369: 'en',# English - Hong Kong SAR 16393: 'en',# English - India 14345: 'en',# English - Indonesia 6153:'en',# English - Ireland 8201:'en',# English - Jamaica 17417: 'en',# English - Malaysia 5129:'en',# English - New Zealand 13321: 'en',# English - Philippines 18441: 'en',# English - Singapore 7177:'en',# English - South Africa 11273: 'en',# English - Trinidad 12297: 'en',# English -
Re: Why prefer != over for Python 3.0?
On Sat, 29 Mar 2008 22:11:33 -0700, hdante wrote: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) ;-) Back in the 1990s, Apple's Hypercard accepted ≠ for not equal. Of course, Macs made it easy to type such special characters. By memory you held down the Option key and typed an equals sign. For ≥ you used Option and less-than. That worked in *any* Mac application. Ah, glory days. But I digress. In Python we can write the above as: if x != 0: [f1(y) if y = 0 else f2(y) for y in s] which for those not trained in algebra is probably more readable. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
hdante: it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) Take a look at Fortress language, by Sun. A free (slow) interpreter is already available. (Mathematica too allows you to write those symbols, but it costs a lot, and (despite tons of good things it has) as *programming language* it's awful, IHMO). Steven D'Aprano: In Python we can write the above as: if x != 0: [f1(y) if y = 0 else f2(y) for y in s] Your code builds an actual array (Python list) of results, while I think the original code just calls f1/f2. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 2:35 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 30 Mar 2008 02:11:33 -0300, hdante [EMAIL PROTECTED] escribió: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) Fine if you have the right keyboard... Try to write APL with a standard keyboard :) -- Gabriel Genellina My sugestion considered using standard keyboards (hint: read again). -- http://mail.python.org/mailman/listinfo/python-list
License of Python
Hi guys, I'd like to use Python in a commercial application. In fact I would like to write the application entirely in Python. But I think I wouldn't like telling what language the application is written in. The problem is that including Python's license in the binary, which as I understand is a must do, reveals that the appliation is based on Python. I'll appreciate your advices about this Thanks iu2 -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with logic in reading a binary file
On Mar 30, 4:31 am, John Machin [EMAIL PROTECTED] wrote: On Mar 30, 3:58 pm, hdante [EMAIL PROTECTED] wrote: On Mar 29, 3:44 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I am having trouble writing the code to read a binary string. I would like to extract the values for use in a calculation. Any help would be great. I'm too lazy to debug your binary string, but I suggest that you completely throw away the binary file and restart with a database or structured text. See, for example: http://pyyaml.org/wiki/PyYAML If you have some legacy binary file that you need to process, try creating a C program that freads the binary file and printfs a text equivalent. ... and that couldn't be done faster and better in Python?? No. A C struct is done faster and better than python (thus, the correctness check is faster in C). Also, chances are high that there's already an include file with the binary structure. -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
iu2 [EMAIL PROTECTED] writes: The problem is that including Python's license in the binary, which as I understand is a must do, reveals that the appliation is based on Python. I'll appreciate your advices about this Expose Python as a user extension language, so it's obvious to everyone that Python is present. Just how present it is, you don't have to tell. -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with logic in reading a binary file
hdante schrieb: On Mar 30, 4:31 am, John Machin [EMAIL PROTECTED] wrote: On Mar 30, 3:58 pm, hdante [EMAIL PROTECTED] wrote: On Mar 29, 3:44 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I am having trouble writing the code to read a binary string. I would like to extract the values for use in a calculation. Any help would be great. I'm too lazy to debug your binary string, but I suggest that you completely throw away the binary file and restart with a database or structured text. See, for example: http://pyyaml.org/wiki/PyYAML If you have some legacy binary file that you need to process, try creating a C program that freads the binary file and printfs a text equivalent. ... and that couldn't be done faster and better in Python?? No. A C struct is done faster and better than python (thus, the correctness check is faster in C). Also, chances are high that there's already an include file with the binary structure. That is utter nonsense. There is no correctness check in C. and using printf thus creating strings that you then need to parse in python just doubles the effort needlessly. The standard-lib module struct is exactly what you need, nothing else. it sure is faster than any parsing of preprocessed data, doesn't introduce a language-mixture and is prototyped/tested much faster because of it being python - and not C-compiler and C-debugger. Alternatively, *IF* there were C-structure-declarations available for the binary format, the usage of ctypes would allow for roughly the same, even reducing the effort to create the structure definition a great deal. Diez -- http://mail.python.org/mailman/listinfo/python-list
python ODF library?
Do yo know any good OpenDocumentFormat library for python? I'm starting a project on wich I'll have to programatically modify ODF text documments, so, after reinventing the wheel, I'd like to know if already something exists. Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with logic in reading a binary file
On Mar 30, 9:23 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: hdante schrieb: On Mar 30, 4:31 am, John Machin [EMAIL PROTECTED] wrote: On Mar 30, 3:58 pm, hdante [EMAIL PROTECTED] wrote: On Mar 29, 3:44 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I am having trouble writing the code to read a binary string. I would like to extract the values for use in a calculation. Any help would be great. I'm too lazy to debug your binary string, but I suggest that you completely throw away the binary file and restart with a database or structured text. See, for example: http://pyyaml.org/wiki/PyYAML If you have some legacy binary file that you need to process, try creating a C program that freads the binary file and printfs a text equivalent. ... and that couldn't be done faster and better in Python?? No. A C struct is done faster and better than python (thus, the correctness check is faster in C). Also, chances are high that there's already an include file with the binary structure. That is utter nonsense. There is no correctness check in C. and using printf thus creating strings that you then need to parse in python just doubles the effort needlessly. The standard-lib module struct is exactly what you need, nothing else. it sure is faster than any parsing of preprocessed data, doesn't introduce a language-mixture and is prototyped/tested much faster because of it being python - and not C-compiler and C-debugger. Alternatively, *IF* there were C-structure-declarations available for the binary format, the usage of ctypes would allow for roughly the same, even reducing the effort to create the structure definition a great deal. Diez Whatever you say. -- http://mail.python.org/mailman/listinfo/python-list
Re: python ODF library?
Matias Surdi escribió: Do yo know any good OpenDocumentFormat library for python? I'm starting a project on wich I'll have to programatically modify ODF text documments, so, after reinventing the wheel, I'd like to know if already something exists. Thanks a lot. Found it: http://opendocumentfellowship.com/development/projects/odfpy :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with logic in reading a binary file
Whatever you say. Can't express what your approval means to me! Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: python ODF library?
On Mar 30, 9:29 am, Matias Surdi [EMAIL PROTECTED] wrote: Do yo know any good OpenDocumentFormat library for python? I'm starting a project on wich I'll have to programatically modify ODF text documments, so, after reinventing the wheel, I'd like to know if already something exists. Thanks a lot. Excellent question. I've found this (have no idea if it works). http://appyframework.org/pod.html It's possible that you could implement what you want by hand. There's this book: http://books.evc-cit.info/odbook/book.html which has a lot of code snippets. On the other hand, it may be easier to pick and editor and go with its scripting lanugage. -- http://mail.python.org/mailman/listinfo/python-list
Re: python ODF library?
Matias Surdi wrote: Do yo know any good OpenDocumentFormat library for python? I'm starting a project on wich I'll have to programatically modify ODF text documments, so, after reinventing the wheel, I'd like to know if already something exists. Probably this will help: http://wiki.services.openoffice.org/wiki/PyUNO_bridge Regards, Björn -- BOFH excuse #327: The POP server is out of Coke -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
hdante wrote: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: Could you please list some that do, and are also convenient? Regards, Björn -- BOFH excuse #288: Hard drive sleeping. Let it wake up on it's own... -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python
[EMAIL PROTECTED] wrote to me: (snip) OK thanks mate you're the man :) One more question though :P If I write a python script in a text editor (I use Programmers Notepad), how do I write indentations properly? e.g.: --- temperature = input(How hot is the spam? ) while temperature hot_enough: print Not hot enough... Cook it a bit more... sleep(30) temperature = input(OK. How hot is it now? ) print It's hot enough - You're done! (taken from hetland.org) --- Is it simply a case of hitting the spacebar until it looks right? Yep, it's just a matter of hitting spacebar until it looks right, but you should also be aware that the Python Interpreter doesn't like it if you mix tabs and spaces, so make sure you only use either one of them. As an additional note, Python's style guideline says you should use 4 spaces (additionally, most Python IDEs automatically convert tabs into 4 spaces for convenience and to avoid mixing tabs and cases). PS: I'll mirror this to comp.lang.python -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
Torsten Bronger wrote: Maybe he means ?. Haven't seen this either, nor do I think it's the same than . From afar, it looks more like . But this does more look like South Park style shut eyes than an operator. :) Regards, Björn -- BOFH excuse #407: Route flapping at the NAP. -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
On Mar 30, 6:42 pm, iu2 [EMAIL PROTECTED] wrote: Hi guys, I'd like to use Python in a commercial application. In fact I would like to write the application entirely in Python. But I think I wouldn't like telling what language the application is written in. Why is the reason for that? The problem is that including Python's license in the binary, which as I understand is a must do, reveals that the appliation is based on Python. I'll appreciate your advices about this Thanks iu2 You can just include it since most users never mess through their program files and most users doesn't even know what Python is, while advanced users could guess that you use Python by seeing the file extension being used (py, pyc, pyo). -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing function objects to timeit
On Sun, 30 Mar 2008 10:55:25 +, Steven D'Aprano wrote: Perhaps it's time for me to take a different approach. Since I can't call timeit, and I can't inherit from it (same problem with state being shared between instances), perhaps I should write my own timer. import timeit import gc import itertools def timeit2(func, args=[], kwargs={}, it=None, timer=timeit.default_timer): if it is None: it = itertools.repeat(None, timeit.default_number) save_gc = gc.isenabled() gc.disable() try: start = timer() for counter in it: func(*args, **kwargs) end = timer() finally: if save_gc: gc.enable() return end - start I've done some comparisons, and the times reported by this function are consistently almost double that of times reported by timeit. Now, I don't expect that my code and the timeit code should have the same overhead, and I realise that the variability of timer results is large. But I'm quite surprised that this seems to have so much more overhead. Can anyone offer some advice? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing function objects to timeit
Steven D'Aprano wrote: On Sun, 30 Mar 2008 01:27:18 -0300, Gabriel Genellina wrote: Second try: ... Horrible, I know. Those wrapper1,wrapper2,wrapper3... keep growing with each call. But it's the only way I could find, at least without changing the code template used by timeit. Eeek. Talk about namespace pollution. Thanks for the effort, but if that's the only solution, I think the solution is worse than the problem! Perhaps it's time for me to take a different approach. [snip] Maybe the following enhancement of timeit would be worthwhile? $ cat timeanyfunc.py from mytimeit import Timer def functionA(): print Function A def functionB(): print Function B T1 = Timer(f(), ns=dict(f=functionA)) T2 = Timer(f(), ns=dict(f=functionB)) T1.repeat(3, 1) T2.repeat(3, 1) $ python timeanyfunc.py Function A Function A Function A Function B Function B Function B $ diff -u /usr/lib/python2.5/timeit.py mytimeit.py --- /usr/lib/python2.5/timeit.py2008-03-07 05:35:55.0 +0100 +++ mytimeit.py 2008-03-30 14:40:58.0 +0200 @@ -77,7 +77,7 @@ # in Timer.__init__() depend on setup being indented 4 spaces and stmt # being indented 8 spaces. template = -def inner(_it, _timer): +def inner(_it, _timer, %(inject)s): %(setup)s _t0 = _timer() for _i in _it: @@ -106,15 +106,16 @@ multi-line string literals. -def __init__(self, stmt=pass, setup=pass, timer=default_timer): +def __init__(self, stmt=pass, setup=pass, timer=default_timer, ns=None): Constructor. See class doc string. +if ns is None: +ns = {} self.timer = timer stmt = reindent(stmt, 8) setup = reindent(setup, 4) -src = template % {'stmt': stmt, 'setup': setup} +src = template % {'stmt': stmt, 'setup': setup, 'inject': ','.join(%s=%s % (s, s) for s in ns)} self.src = src # Save for traceback display code = compile(src, dummy_src_name, exec) -ns = {} exec code in globals(), ns self.inner = ns[inner] By the way, haven't we been there before, two years ago? http://mail.python.org/pipermail/python-list/2006-February/368341.html Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
Hallöchen! Bjoern Schliessmann writes: hdante wrote: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: Could you please list some that do, and are also convenient? Define convenient. Emacs is generally not regarded as being convenient, however, it has very strong input methods. I type \gtrless and get ≷, or \forall and get ∀. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
[EMAIL PROTECTED] wrote: I don't know if this is the right place to discuss the death of in Python 3.0, or if there have been any meaningful discussions posted before (hard to search google with '' keyword), but why would anyone prefer the comparison operator != over ??? I've written an article about it to try and save this nice is not equal operator, located at http://dewitters.koonsolo.com/python_neq.html Please set it straight in 3.0, and if not, convince me with a good reason of doing so, so that I can live with it and don't have to spend the rest of my life in 2.x ;). Algol 60 had no such operator. Algol-W had (not)= [(not) was a negative symbol, not on our current keyboard] Simula 67 introduced Pascal uses [Pascal is still available - http://www.freepascal.org/] C uses != [http://cermics.enpc.fr/~ts/C/CONCEPT/expressions.html#rel] I prefer but I feel that it's better not to have two ways of representing not equal. The powers that be have chosen !=. I accept this on the grounds that current languages seem to have nade that choice. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Serial port error statistics - any comparable data?
Diez B. Roggisch wrote: RS232 is unfortunately as bad as a protocol as it can get. I've used it for communication with a microcontroller for just a few bytes every second. And it failed miserably, so I needed to implement a protocol on top of it. We normally do this anyway, except for stuff like menus that are intended for interactive use as setup - doing without on machine to machine comms feels a bit too cowboy... The machine spec is totally irrelevant - what is interesting is the serial hardware you use. Are you by any chance using a serial2usb-converter? I had nothing but troubles with these. I have also heard rumours about this, and you have just hardened my admittedly irrational attitude towards them. I have never used one in anger. if you have the chance, try attach a machine with legacy rs232 port, and see if the errors still remain. Diez Alas - the port in question is the native legacy motherboard port. If it were windows, it would be COM1... I had hoped that somebody would have done some similar work, so that we could compare notes on the error frequency. It does not seem likely though - If I was not testing the performance of the Lantronix xport device, I would not have kept stats either - it is kind of tedious to sit and watch the fox scroll up the screen for days on end.. It just surprised me to find that the errors were made in the PC's receive. I proved this by short circuiting the xport's receive and transmit at the RS-232 level and gave up after some ten million error free lines. (Most of an afternoon, overnight, and most of the next morning ;-( ) thanks Diez. Then Castironpi wrote: Transmit observed minus expected to cluster. The cluster in all the cases observed is the loss of exactly one character, somewhere from around more or less the middle of the string: The quick brown fox jumps over the lazy dog 0123456789 Why do you make the assertion that the errors would cluster? What kind of tables does the input device build? Whatever the kernel and the cpython implementation does to receive the string from a port unblocked with fcntl - and the throw away python script that does the echoing builds the string up with a read(1). And before I get flamed for wasting resources - The read(1) is necessary to be able to run a protocol, later. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 6:35 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 30 Mar 2008 02:11:33 -0300, hdante [EMAIL PROTECTED] escribió: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) Fine if you have the right keyboard... Try to write APL with a standard keyboard :) There was a version of APL for the Sinclair QL which replaced the standard APL symbols with keywords. -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing function objects to timeit
On Mar 30, 9:03 am, Peter Otten [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Sun, 30 Mar 2008 01:27:18 -0300, Gabriel Genellina wrote: Second try: ... Horrible, I know. Those wrapper1,wrapper2,wrapper3... keep growing with each call. But it's the only way I could find, at least without changing the code template used by timeit. Eeek. Talk about namespace pollution. Thanks for the effort, but if that's the only solution, I think the solution is worse than the problem! Perhaps it's time for me to take a different approach. [snip] Maybe the following enhancement of timeit would be worthwhile? [snip] That would be great. I sometimes avoid timeit altogether because setting up the environment is so cumbersome. Can you post the patch to bugs.python.org so it doesn't get lost ? George -- http://mail.python.org/mailman/listinfo/python-list
Re: Using QSystemTrayIcon with PyQt
On Mar 30, 2:08 am, Phil Thompson [EMAIL PROTECTED] wrote: On Sunday 30 March 2008, Alex Teiche wrote: Hello, I am pretty new to Python, and have never learned C++. I am trying to implement the following thing into my python application: http://doc.trolltech.com/4.3/qsystemtrayicon.html Through PyQt. I have been using PyQt for awhile and I know how do use it, but I could not get this specific thing to work. Can someone give me some hints as to get it working in Python? Thanks a ton, Alex Have you looked at PyQt's systray example? Phil No, where do I find the example? Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with sqlite
Ok regarding Gerhard's comment of the try, except, pass, i came to understand that it's really bad code. And i should have referred that i put that there be cause i was getting: Traceback (most recent call last): File C:\Python25\Projects\cp.py, line 48, in module db = db() File C:\Python25\Projects\cp.py, line 19, in __init__ self.cursor.execute( CREATE TABLE database (album,filepath) ) OperationalError: table database already exists But when i tried to handle the Operational error with : try: self.cursor.execute( CREATE TABLE database (album,filepath) ) except OperationalError: pass I would got: NameError: global name 'OperationalError' is not defined I searched the Internet and found that sqlite3.OperationalError was missing. Dumb me. Now even though i've been reading a bit about exceptions in python tutorial i've come to realize that my approach won't give me the results i want. To my understanding the try statement will still execute the statement within it until it produces the error. So even if i caught this OperationalError i wouldn't know what to do with it. What i'm going to study is whether it's possible to evaluate if a table already exists, and if so act accordingly. Duncan Booth wrote: Are you absolutely certain of that? If you use print to try to debug the value of an object you should usually use repr print repr(audio['album']) As Gerhard correctly guessed i'm a newbie and didn't know of the existence repr. I've been reading about it in python documentation but have yet to analyze it more carefully. I guess the parentheses are just some form of maniac stupidity. Will try to be more clean about them. Thanks for all the patience and hope i've been more forthcoming in this post. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with sqlite
Ok regarding Gerhard's comment of the try, except, pass, i came to understand that it's really bad code. And i should have referred that i put that there be cause i was getting: Traceback (most recent call last): File C:\Python25\Projects\cp.py, line 48, in module db = db() File C:\Python25\Projects\cp.py, line 19, in __init__ self.cursor.execute( CREATE TABLE database (album,filepath) ) OperationalError: table database already exists But when i tried to handle the Operational error with : try: self.cursor.execute( CREATE TABLE database (album,filepath) ) except OperationalError: pass I would got: NameError: global name 'OperationalError' is not defined I searched the Internet and found that sqlite3.OperationalError was missing. Dumb me. Now even though i've been reading a bit about exceptions in python tutorial i've come to realize that my approach won't give me the results i want. To my understanding the try statement will still execute the statement within it until it produces the error. So even if i caught this OperationalError i wouldn't know what to do with it. What i'm going to study is whether it's possible to evaluate if a table already exists, and if so act accordingly. Duncan Booth wrote: Are you absolutely certain of that? If you use print to try to debug the value of an object you should usually use repr print repr(audio['album']) As Gerhard correctly guessed i'm a newbie and didn't know of the existence repr. I've been reading about it in python documentation but have yet to analyze it more carefully. I guess the parentheses are just some form of maniac stupidity. Will try to be more clean about them. Thanks for all the patience and hope i've been more forthcoming in this post. -- http://mail.python.org/mailman/listinfo/python-list
Re: Serial port error statistics - any comparable data?
On Sunday 30 March 2008 12:19:58 Bjoern Schliessmann wrote: Diez B. Roggisch wrote: if you have the chance, try attach a machine with legacy rs232 port, and see if the errors still remain. Additionally, what kind of buffers does your device have? I'm using pyserial to control a very sensitive device with nuttily implemented buffering strategy. It has a fast and a slow buffer which are filled in order, and no signalling to the outside sender on how full they are. If the fast buffer fills the slow buffer kicks in and requires less transmission rate. That may be how characters could be lost with you. Regards, Bjoern That is a horrible device - have they not heard of RTS / CTS? or even XON / XOFF ? It is a wonder that you got that working without turning into an axe murderer. I don't think I could have. I have not been exactly forthcoming about the setup - the device in question sits on the LAN, so I connect to it via a TCP socket connection (in either client or server mode - seems to make no difference) . On the other side of the device, there is a serial port, and another PC is connected to the RS-232 side. This is the PC that runs a simple echo script that makes the occasional error, on its receive - I can see this because the transmission is paused when I see an error, and the two strings are identical on the two machines. As I mentioned in my reply to Diez and Castironpi - its not the device that is making the errors, as proved by a simple loopback. Another interesting statistic is that the number of lines in flight on the round trip machine1 xport machine2 xport machine 1 due to buffering varies between about 4 and about 26. So much for using it for real time control... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Build complete, now I just need to install it...
Hi, I'm going to be adding some features for a python-project with external modules written in C. However, if I build modules with my MSVS 2008 compiler (from the Windows SDK), they won't load in Python 2.5.2, which is built with MSVS 2003. Since I don't have access to MSVS 2003 I need to rebuild Python using MSVS 2008 in order for the binaries to go along. For starters, I cloned the PCbuild8 folder and made whatever changes needed to be able to build the core and executable. I then pulled down all the various external dependencies and made the same adjustments to those. After quite a while I've managed to build everything apart from the PGO config, since it requires a DLL which isn't included in the SDK. Not to worry, I can live with a less than 100% optimized version for now. But, my problem is that the install scripts, i.e. python setup.py install wants to go through the build steps again, but since those don't work on Windows, or at least not with my setup, I can't put together a complete package. The web pages have gotten me this far, but there doesn't seem to be anything on how to actually pull together the various bits and bobs into a complete package that I can use in place of my current Python 2.5.2 installation. Apparently someone has done it, since there is an installer to download, but those parts don't seem to be available anywhere. And it's unclear if the Windows installer contains exactly what's in the source package, or if I have to build a bunch of other modules as well in order to be completely replacing my old installation. Actually, I don't need an installer, I just want to know which parts of my 2.5.2 folder that need to go where. Grateful for any help, /axl -- http://mail.python.org/mailman/listinfo/python-list
Re: Using QSystemTrayIcon with PyQt
On Sunday 30 March 2008, Alex Teiche wrote: On Mar 30, 2:08 am, Phil Thompson [EMAIL PROTECTED] wrote: On Sunday 30 March 2008, Alex Teiche wrote: Hello, I am pretty new to Python, and have never learned C++. I am trying to implement the following thing into my python application: http://doc.trolltech.com/4.3/qsystemtrayicon.html Through PyQt. I have been using PyQt for awhile and I know how do use it, but I could not get this specific thing to work. Can someone give me some hints as to get it working in Python? Thanks a ton, Alex Have you looked at PyQt's systray example? Phil No, where do I find the example? Thanks, Alex Unsurprisingly in the PyQt source package. Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
On 30 מרץ, 15:55, Lie [EMAIL PROTECTED] wrote: On Mar 30, 6:42 pm, iu2 [EMAIL PROTECTED] wrote: Hi guys, I'd like to use Python in a commercial application. In fact I would like to write the application entirely in Python. But I think I wouldn't like telling what language the application is written in. Why is the reason for that? Due to Competitors... I don't want to expost the language I use You can just include it since most users never mess through their program files and most users doesn't even know what Python is, while advanced users could guess that you use Python by seeing the file extension being used (py, pyc, pyo). I intend to use pyinstaller, so there is no .pyc at all. The main problem is when I use small programs (as single EXE) sent to someone as a means of maintenance or debugging. Sending Python's license file together with one EXE seems to me too obvious Another thing, what should the Python's license file be called? -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing function objects to timeit
On Sun, 30 Mar 2008 15:03:21 +0200, Peter Otten wrote: Maybe the following enhancement of timeit would be worthwhile? [snip] Passing a namespace argument would be excellent. By the way, haven't we been there before, two years ago? http://mail.python.org/pipermail/python-list/2006-February/368341.html Two years huh? Gosh, how time flies. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
On Sun, 30 Mar 2008 08:16:39 -0700 (PDT) iu2 [EMAIL PROTECTED] wrote: I'd like to use Python in a commercial application. In fact I would like to write the application entirely in Python. But I think I wouldn't like telling what language the application is written in. Why is the reason for that? Due to Competitors... I don't want to expost the language I use You might hide it from many of your customers but don't count on hiding it from your competitors. Chances are, if they don't know it because they just don't care. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Create executable from executable with py2exe
On Sat, Mar 29, 2008 at 3:23 PM, [EMAIL PROTECTED] wrote: Hello, Is there any example how can I create executable ... with py2exe Check out PyBuilder's source code (http://pybuilder.sourceforge.net/). -- kv -- http://mail.python.org/mailman/listinfo/python-list
RE: Build complete, now I just need to install it...
On Behalf Of axl Since I don't have access to MSVS 2003 I need to rebuild Python using MSVS 2008 in order for the binaries to go along. Another option is to compile your extensions with gcc, and specify that it link to MSVCR71.dll as the C runtime. For MinGW, it's sufficient to edit the specs (e.g. in C:\MinGW\lib\gcc\mingw32\3.4.2) like so: *libgcc: %{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcr71 And tell distutils to use mingw, by putting this in lib/distutils/distutils.cfg: [build] compiler=mingw32 [build_ext] compiler=mingw32 Regards, Ryan Ginstrom -- http://mail.python.org/mailman/listinfo/python-list
Re: Build complete, now I just need to install it...
On 30 Mar, 17:40, Ryan Ginstrom [EMAIL PROTECTED] wrote: Another option is to compile your extensions with gcc, and specify that it link to MSVCR71.dll as the C runtime. For MinGW, it's sufficient to edit the specs (e.g. in C:\MinGW\lib\gcc\mingw32\3.4.2) like so: *libgcc: %{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcr71 True, I was hoping to avoid MinGW, since I've been using MSVC for ages and I know it well. Yet another package on the disk, etc... But as this seems like the simplest solution for now I'll try that. Cheers! /axl -- http://mail.python.org/mailman/listinfo/python-list
Re: Using QSystemTrayIcon with PyQt
On Sunday 30 March 2008, Phil Thompson wrote: On Sunday 30 March 2008, Alex Teiche wrote: On Mar 30, 2:08 am, Phil Thompson [EMAIL PROTECTED] wrote: On Sunday 30 March 2008, Alex Teiche wrote: Hello, I am pretty new to Python, and have never learned C++. I am trying to implement the following thing into my python application: http://doc.trolltech.com/4.3/qsystemtrayicon.html Through PyQt. I have been using PyQt for awhile and I know how do use it, but I could not get this specific thing to work. Can someone give me some hints as to get it working in Python? Thanks a ton, Alex Have you looked at PyQt's systray example? Phil No, where do I find the example? Thanks, Alex Unsurprisingly in the PyQt source package. Phil By which I mean the current snapshot - I'd forgotten that it is a recent addition. Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: regarding xml elements
Raj kumar wrote: document.createElement(abc) and i appeneded it by using append() method. But how i can reflect this change to my xml file? write it out again: http://python.org/doc/current/lib/dom-objects.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Soup Strainer for ElementSoup?
erikcw wrote: I'm parsing real-world HTML with BeautifulSoup and XML with cElementTree. I'm guessing that the only benefit to using ElementSoup is that I'll have one less API to keep track of, right? Or are there memory benefits in converting the Soup object to an ElementTree? It's purely an API thing: ElementSoup loads the entire HTML file with BeautifulSoup, and then uses the resulting BS data structure to build an ET tree. The ET tree doesn't contain cycles, though, so you can safely pull out the strings you need from ET and throw away the rest of the tree. Any idea about using a Soup Strainer with ElementSoup? The strainer is used when parsing the file, to control what goes into the BS tree; to add straining support to ES, you could e.g. add a parseOnlyThese option that's passed through to BS. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Buffer Overflow with Python 2.5 on Vista in import site
On Mar 30, 3:53 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 29 Mar 2008 17:34:27 -0300, Fuzzyman [EMAIL PROTECTED] escribió: A very odd error with Python 2.5 (both 2.5.1 and 2.5.2 from the official msi installers and running on Vista under Parallels on the Mac). It may be actually a Parallels issue - I've installed 2.5.1 on Vista (just once, on a real PC) and it worked fine. Anyway a better place for bug reports is bugs.python.org Mmm, maybe you should check all your .pth files - looks like this strange path comes from one of them. I think it comes from the '._something.pth' that Textmate created as a temporary file when I edited a 'pth' file. The 'macromates' text in their is from textmate. I'm not sure if it is Mac specific or Texmate specific, but those temp files are really annoying. Thanks. Michael http://www.ironpythoninaction.com/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
On Mar 30, 10:28 pm, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Sun, 30 Mar 2008 08:16:39 -0700 (PDT) iu2 [EMAIL PROTECTED] wrote: I'd like to use Python in a commercial application. In fact I would like to write the application entirely in Python. But I think I wouldn't like telling what language the application is written in. Why is the reason for that? Due to Competitors... I don't want to expost the language I use You might hide it from many of your customers but don't count on hiding it from your competitors. Chances are, if they don't know it because they just don't care. Even if you create your program in C, it is always possible (for an advanced user/determined competitor) to guess what language (compiler) you're using. And I haven't even mentioned that you can guess Windows Defender is created using Visual Basic Classic (VB6) because one of its windows still use VB6's default icon. There are cues that could hint what language is used to create a program: default icons (e.g. VB6's default icon), interface widgets (notoriously Java's Swing), PEID (which is quite reliable although you could manipulate it), the name (e.g. CPython), included libraries, libraries used (e.g. MSVCRT), etc. And I can't see any obvious advantage you could get by hiding the language you use from your competitors, it isn't like they would switch their language to your language if they can't catch up with you, and they can't anti-advertise you because of the language you used. I intend to use pyinstaller, so there is no .pyc at all. The main problem is when I use small programs (as single EXE) sent to someone as a means of maintenance or debugging. Sending Python's license file together with one EXE seems to me too obvious AFAIK (__someone please confirm this__) you don't need to include Python's license in your program, unless you distribute Python's binary/source code (i.e. The Python Interpreter and Friends) in your program. So if you're sending a small program for maintenance or debugging since you don't need to include the Python Interpreter (you assumed that there is already one in the machine) you don't need to include the license. You might need to include the license if the maintenance program is for updating the Python Interpreter though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 5:40 am, Torsten Bronger [EMAIL PROTECTED] wrote: Hallöchen! Bjoern Schliessmann writes: Lie wrote: Ah yes, that is also used (I completely forgot about that one, my math's aren't that sharp anymore) and I think it's used more frequently than . Where did you read that (I mean, which country)? I've never seen this sign in any german or english book on mathematics/physics/engineering I saw. Maybe he means ≷. but my argument was that no math book use != or (except in math for programmers). That's true. Personally, I don't ever use a!=b in favor of not a==b. As a side note, I've always found == rather ugly. I'd prefer to have = for both purposes. The earliest versions of Python *did* use = for both purposes. The constructs that wouldn't work anymore are rare as far as I can see (and possibly there are even workarounds). The construct a = b == c could be rewritten as a = (b = c). -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: pygame 1.8 released
This is good news, particularly the NumPy support for surface and pixel arrays. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 7:48 pm, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: Torsten Bronger wrote: Maybe he means ?. Haven't seen this either, nor do I think it's the same than . From afar, it looks more like . Actually I meant an X-like symbol that is made not by crossing but by . I retracted saying it is the standard, now that I think about it the last time I saw was in elementary school (although it stuck on my head better than a crossed =, which I first met in high school). But this does more look like South Park style shut eyes than an operator. :) lol, I agree, it looks too much like closed eye smiley. Forums might automatically convert them to graphic smileys so it is obviously a bad choice if it is to be used. -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
On 30 Mar, 17:16, iu2 [EMAIL PROTECTED] wrote: Due to Competitors... I don't want to expost the language I use Either your comepetitors will figure it out, or they don't care. Using Python can be a major competitive advance. If your competitors are smart enough to realise that, you are in trouble anyway. Most likely your competitors have managers who are technical retards (read: MBAs), who demand their engineers to use whichever technology is over hyped these days. You don't have to worry about those. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 5:25 pm, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: Lie wrote: Ah yes, that is also used (I completely forgot about that one, my math's aren't that sharp anymore) and I think it's used more frequently than . Where did you read that (I mean, which country)? I've never seen this sign in any german or english book on mathematics/physics/engineering I saw. It was in my elementary school at Indonesia (FYI, it is also used as antonym sign in languages (at least in my country)). And I think I'll retract that claim, wasn't the standard, a crossed = is the standard (btw, with a little imagination != looks like a crossed =). -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 12:11 pm, hdante [EMAIL PROTECTED] wrote: (snip) BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) That would be a nightmare. Programming language (or most computer-based texts) should only use basic ASCII characters, except if it can't be helped since typing non- ASCII characters is still unreliable. It'd also be a headache to memorize what keyboard combinations to use to type a character. Not to mention how much more complex would the keyboard design be. Also not mentioning how much more complex the language design would be to handle all those non-ASCII characters. -- http://mail.python.org/mailman/listinfo/python-list
Re: Licensing
On 29 Mar, 20:24, DS [EMAIL PROTECTED] wrote: I'm pretty sure this is the wrong place to ask, but I'm hoping someone will point me in the right direction. I'm getting ready to publish a first open-source project written in python. I am planning to use GPLas the license. However, in my code, there is a function that I like from Python Cookbook. I would like to use it, although I could certainly write a less elegant version that would do the same thing. Note that the Python Cookbook says this about licensing: Except where otherwise noted, recipes in the Python Cookbook are published under the Python license. The link is incorrect, but I presume they mean this licence: http://www.python.org/psf/license/ It's generally not recommended to use this licence for anything other than Python because it mentions the need to reproduce the Python copyright statement in derived works, which would be nonsense for anything which isn't the Python distribution. However, one can infer that the copyright notice specific to the software concerned should be reproduced, and this is what the original CWI licence says. Of course, if a different licence is mentioned on the specific recipe you're using, you have to observe the terms mentioned in that licence instead. So, my options appear to be: 1. Don't use it. 2. Use it with no comment -- that doesn't seem right. 3. Use it with remarks in the code that acknowledge the source. 4. Provide a separate licensing page for that function along with the GPL for my code. What is the appropriate course of action here? I'm thinking #3 is probably ok. How do others deal with this in an honorable way? In the book, it appears that they are saying they don't really care unless there is some massive use. You just need to do what's necessary to satisfy the licence applied to the code you're using. If that's the Python licence, I would imagine that reproducing the copyright statement and licence details would be sufficient, even if your own work is GPL-licensed. What I've done when I've released work which incorporates other work (itself available under a permissive licence) is to include the copyright statements and the licence text for that other work, but I've made it clear in the licensing information that the derived work (my code incorporating the other code) is available under the specific licence I've chosen, noting that the other work was made available under a different licence. So I suppose that #4 is the closest, but you should be able to assert that the entire work is GPL-licensed unless the recipe isn't licensed in a GPL-compatible way, which would open up a range of other issues that you hopefully won't have to deal with. ;-) Paul P.S. This isn't anything close to legal advice, so please take other opinions into account. ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: html DOM
On 30 Mar, 01:09, Sam the Cat [EMAIL PROTECTED] wrote: Is there a package that would allow me the same or similar functionality for modifying html code via the DOM model as I have in JavaScript ? I'd like to parse an html file, then modify it and save the result. You could try libxml2dom which has an HTML parsing mode (like lxml and other solutions based on libxml2): http://www.python.org/pypi/libxml2dom It attempts to provide a DOM API very much like that used by JavaScript implementations. Paul -- http://mail.python.org/mailman/listinfo/python-list
ANN: Py-Lib 0.9.1 released
py lib 0.9.1: bugfix release = The py lib team has just released version 0.9.1 of the py lib - a library aiming to support agile and test-driven python development on various levels. This is mostly a bugfix release, with a couple of new features sneaked in. Most important changes: * reduced the number of threads used in py.execnet * some new functionality (authentication, export, locking) in py.path's Subversion APIs * stability and segfault fixes in execnet * numerous small fixes in py.test's rsession (experimental pluggable session) and generative test features * some fixes in the py.test core * added py.misc.killproc, which allows killing processes on (some flavours of) Windows and UNIX For a complete list of changes, see doc/changes-0.9.1.txt in the source package. Download/Install: http://codespeak.net/py/0.9.1/download.html Documentation/API: http://codespeak.net/py/0.9.1/index.html Work on the py lib has been partially funded by the European Union IST programme and by http://merlinux.de within the PyPy project. best, have fun and let us know what you think! holger krekel, Maciej Fijalkowski, Carl Friedrich Bolz, Guido Wesdorp -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
En Sun, 30 Mar 2008 11:10:20 -0300, MRAB [EMAIL PROTECTED] escribió: On Mar 30, 6:35 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 30 Mar 2008 02:11:33 -0300, hdante [EMAIL PROTECTED] escribió: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) Fine if you have the right keyboard... Try to write APL with a standard keyboard :) There was a version of APL for the Sinclair QL which replaced the standard APL symbols with keywords. Wow, APL on 8 bits? Now there is (or perhaps there was) J, a reincarnation of APL by Iverson himself that uses ASCII characters only. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Py-Lib 0.9.1 released
great works, i will try it. Aster Jian. - Original Message - From: Carl Friedrich Bolz [EMAIL PROTECTED] To: python-list@python.org Sent: Monday, March 31, 2008 2:47 AM Subject: ANN: Py-Lib 0.9.1 released py lib 0.9.1: bugfix release = The py lib team has just released version 0.9.1 of the py lib - a library aiming to support agile and test-driven python development on various levels. This is mostly a bugfix release, with a couple of new features sneaked in. Most important changes: * reduced the number of threads used in py.execnet * some new functionality (authentication, export, locking) in py.path's Subversion APIs * stability and segfault fixes in execnet * numerous small fixes in py.test's rsession (experimental pluggable session) and generative test features * some fixes in the py.test core * added py.misc.killproc, which allows killing processes on (some flavours of) Windows and UNIX For a complete list of changes, see doc/changes-0.9.1.txt in the source package. Download/Install: http://codespeak.net/py/0.9.1/download.html Documentation/API: http://codespeak.net/py/0.9.1/index.html Work on the py lib has been partially funded by the European Union IST programme and by http://merlinux.de within the PyPy project. best, have fun and let us know what you think! holger krekel, Maciej Fijalkowski, Carl Friedrich Bolz, Guido Wesdorp -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 29, 12:34 pm, Lie [EMAIL PROTECTED] wrote: On Mar 29, 5:55 pm, [EMAIL PROTECTED] wrote: I don't know if this is the right place to discuss the death of in Python 3.0, or if there have been any meaningful discussions posted before (hard to search google with '' keyword), but why would anyone prefer the comparison operator != over ??? ...snip... You're forcing your argument too much, both != and are NOT standard mathematics operators -- the standard not-equal operator is -- and I can assure you that both != and won't be comprehensible to non- programmers. A lot of non-programmers use Microsoft Excel, which uses for the Not Equal operator. FWIW, the non-programmers on one forum I post on tend to use =/= . -- http://mail.python.org/mailman/listinfo/python-list
Vote for a New EuroPython Logo!
Earlier this year, the organisers of EuroPython (the annual European Python community conference) decided it was time to update the conference logo: the current logo has been in use since EuroPython began back in 2002. We asked for and received many great submissions for a new logo, and we've made these available on the EuroPython Web site. Now we need your help in deciding which logo shall be part of the EuroPython conference's updated image. Visit the EuroPython Web site to browse the submissions and to cast your votes on the ones you like the most: http://www.europython.org/community/Planning/ProposedLogo We intend to announce the winning logo on Friday 4th April at the latest, so hurry on over to the EuroPython site and cast your votes now! (And stay tuned for more updates on EuroPython 2008!) -- http://mail.python.org/mailman/listinfo/python-list
Re: License of Python
iu2 wrote: Hi guys, I'd like to use Python in a commercial application. In fact I would like to write the application entirely in Python. But I think I wouldn't like telling what language the application is written in. The problem is that including Python's license in the binary, which as I understand is a must do, reveals that the appliation is based on Python. I'll appreciate your advices about this Thanks iu2 My advice would be to create something of real value before you worry about issues like this. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
question
Say you have an auditory waveform. In dream hardware, positives would accumulate until something, which would trigger a small chain reaction. In software, with a function f of time t, f( t ), in constant space, what can you know at t? Presume. Silence first, then a broken triad vamps. How long til you recognize it? One sec., i'll attach a binary. -- http://mail.python.org/mailman/listinfo/python-list
socket error when loading the shell?
hi using python and wpython. when using run module or python shell on the run menu in the GUI i get socket error, connection refused. it worked before, what si wrong now? and i cant find where to start the shell directly. think i had an exe before but cant seem to find it now. -- http://mail.python.org/mailman/listinfo/python-list
Error Raised But dont know what it means
Well, I'm dealing with files in Pickle, I'm saving at the file a List of Objects from the same Class, When I try to retrive this information and try to iterate over them this error is raised: TypeError: 'instancemethod' object is not iterable But if I just print the method I get the 'real thing' what's the problem? -- http://mail.python.org/mailman/listinfo/python-list
Re: Summary of threading for experienced non-Python programmers?
Diez B. Roggisch [EMAIL PROTECTED] writes: Note that I said *file* input/output. Twisted and asyncore are about asynchronous socket programming that polls over nonblocking file descriptors such as found in socket programming, not about wrapping aio(3) and the equivalent Windows APIs. I admit glossing over the file-input - however this is available on posix-systems using the select-module. I believe you stil misunderstand. The select module doesn't provide an inteface to aio(3). It provides an interface to select() and poll() system calls, which don't provide asynchronous access to regular files. So if I were in nitpicking-mood, your assertion still would be false I invite constructive nitpicking, but you are completely missing the point. You are confusing aio(3) with select and poll. I'm pretty sure though that tiwsted asynchore don't poll, but instead use the select-module. Which at least for unix (and AFAIK for Windows as well) is asynchronous - you get notified if data arrives or has been transmitted, and otherwise your process sleeps. Unfortunately, this is not the case for files at all, even on Unix. (On Windows, select doesn't work on files at all, it only accepts sockets.) -- http://mail.python.org/mailman/listinfo/python-list
Creating a python c-module: passing double arrays to c functions. segmentation fault. swig
Hello everybody, I'm building a python module to do some heavy computation in C (for dynamic time warp distance computation). The module is working perfectly most of the time, which makes it so difficult to track down the error. and I finally figured out that the strange segmentation faults I get from time to time have something to do with the length of the vectors I'm looking at. (So in this minimal example I'm doing completely useless distance measures on vectors with the same entry in all dimensions, but the errors seem to have nothing to with the actual values in the vectors, only with the lengths.) But somehow I haven't quite gotten the essential ideas of what one has to do to debug this module and I hope someone can give me some advice. The main problem is probably somewhere around passing the double vectors to the c module or reserving and freeing memory. so, for example list1,list2 = [0.1 for i in range(555)],[0.2 for i in range(1874)] ctimewarp(list1,list2) # see python file below works perfectly fine and if the vector has one more element list1,list2 = [0.1 for i in range(555)],[0.2 for i in range(1875)] ctimewarp(list1,list2) it dies with a simple Segmentation fault nothing more said :-S For very small lists again, no problem: list1,list2 = [0.1 for i in range(3)],[0.2 for i in range(4)] ctimewarp(list1,list2) for intermediate size I get an error and more information: list1,list2 = [0.1 for i in range(22)],[0.2 for i in range(99)] ctimewarp(list1,list2) give: *** glibc detected *** python: free(): invalid next size (fast): 0x0804d090 *** === Backtrace: = /lib/i686/libc.so.6[0xb7bed4e6] /lib/i686/libc.so.6(cfree+0x90)[0xb7bf1010] /home/kim/Documents/pythonprojects/alignator/ _timewarpsimple.so[0xb7aadc0c] /home/kim/Documents/pythonprojects/alignator/ _timewarpsimple.so[0xb7aae0db] /usr/lib/libpython2.5.so.1.0(PyCFunction_Call+0x107)[0xb7d5d8e7] === Memory map: 08048000-08049000 r-xp 03:05 2344438/usr/bin/python 08049000-0804a000 rwxp 03:05 2344438/usr/bin/python 0804a000-080f3000 rwxp 0804a000 00:00 0 [heap] (truncated) When looping over these lengths of vectors, e.g. as I did in the python file below, it runs smooth for thousands of times before dying at 938 for the first list length and 1110 for the second. i noticed that the sum of the list lengths is 2048=2^11 and it often seems to die around that but that's just a guess... If anyone has a little advice or a code snippet on how to pass float lists to modules or anything of that kind, i would appreciate it very much! thanks a lot in advance cheers kim __ Below you can see the c file, the .i file for swig, and a little python script producing the errors: ___ .c file: /* File : timewarpsimple.c */ #include sys/param.h #include math.h #include stdlib.h double timewarp(double x[], int lenx, double y[], int leny) { // printf (%d ***\n, lenx); // printf (%d ***\n, leny); double prev; double recx[lenx+1]; double recy[leny+1]; double warp[lenx+2][leny+2]; int i,j; prev = 0.0; for (i = 0; i lenx; i++) { recx[i]=x[i]-prev; prev = x[i]; } recx[lenx]=1.0-prev; prev = 0.0; for (i = 0; i leny; i++) { recy[i]=y[i]-prev; prev = y[i]; } recy[leny]=1.0-prev; // recency vectors are done // let's warp warp[0][0]=0.0; for (i = 1; i lenx+2; i++) { warp[i][0]=1.0; } for (j = 1; j leny+2; j++) { warp[0][j]=1.0; } for (i = 1; i lenx+2; i++) { for (j = 1; j leny+2; j++) { warp[i][j]=fabs(recx[i-1]-recy[j-1]) + MIN(MIN(warp[i-1][j],warp[i] [j-1]),warp[i-1][j-1]); } } return warp[lenx+1][leny+1]; } .i file: %module timewarpsimple %include carrays.i %array_functions(double, doubleArray); %{ double timewarp(double x[], int lenx, double y[], int leny); %} double timewarp(double x[], int lenx, double y[], int leny); here's what I'm doing to compile: swig -python timewarpsimple.i gcc -c timewarpsimple.c timewarpsimple_wrap.c -I/usr/include/ python2.5/ ld -shared timewarpsimple.o timewarpsimple_wrap.o -o _timewarpsimple.so which goes thru without any problem. .py file: #!/usr/bin/python # -*- coding: UTF-8 -*- import timewarpsimple def ctimewarp(list1,list2): takes two lists of numbers between 0 and 1 and computes a timewarp distance print timewarping alen = len(list1) blen = len(list2) a = timewarpsimple.new_doubleArray(alen*4) # Create the first array # Why I have to reserve 4 times more space I don't know, but it's the
Re: Error Raised But dont know what it means
Here is the code: This one raises the error: def criaLista(self): self.listbox.Clear() for dupla in self.duplas: self.listbox.Append(dupla.__str__()) This one works well but doesn't raises error dupla1 = Duplas(2422, 2455) dupla2 = Duplas(454, 15) list = [] list.append(dupla1) list.append(dupla2) erros = ErrorMgr() erros.geraErro(1, erro idiota, 2.2) dic = {1:dupla1, 2:dupla2} a = Arquivos(batata.txt) a.saveFile(list, erros, dic) a.openFile() lista = a.getListaDuplas() e = a.getErrorsManager() d = a.getDicDuplas() for i in lista: print i print d[1] On Sun, Mar 30, 2008 at 5:03 PM, David Anderson [EMAIL PROTECTED] wrote: Well, I'm dealing with files in Pickle, I'm saving at the file a List of Objects from the same Class, When I try to retrive this information and try to iterate over them this error is raised: TypeError: 'instancemethod' object is not iterable But if I just print the method I get the 'real thing' what's the problem? -- http://mail.python.org/mailman/listinfo/python-list
Re: Error Raised But dont know what it means
I found the problem Topic closed On Sun, Mar 30, 2008 at 5:07 PM, David Anderson [EMAIL PROTECTED] wrote: Here is the code: This one raises the error: def criaLista(self): self.listbox.Clear() for dupla in self.duplas: self.listbox.Append(dupla.__str__()) This one works well but doesn't raises error dupla1 = Duplas(2422, 2455) dupla2 = Duplas(454, 15) list = [] list.append(dupla1) list.append(dupla2) erros = ErrorMgr() erros.geraErro(1, erro idiota, 2.2) dic = {1:dupla1, 2:dupla2} a = Arquivos(batata.txt) a.saveFile(list, erros, dic) a.openFile() lista = a.getListaDuplas() e = a.getErrorsManager() d = a.getDicDuplas() for i in lista: print i print d[1] On Sun, Mar 30, 2008 at 5:03 PM, David Anderson [EMAIL PROTECTED] wrote: Well, I'm dealing with files in Pickle, I'm saving at the file a List of Objects from the same Class, When I try to retrive this information and try to iterate over them this error is raised: TypeError: 'instancemethod' object is not iterable But if I just print the method I get the 'real thing' what's the problem? -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 9:45 am, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: hdante wrote: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: Could you please list some that do, and are also convenient? AFAICT there's none. This should be easy to implement on emacs, or in SCIM. Regards, Björn -- BOFH excuse #288: Hard drive sleeping. Let it wake up on it's own... -- http://mail.python.org/mailman/listinfo/python-list
Dispatching functions from a dictionary
To keep a simulation tidy, I created a dispatcher that generates random variables drawn from various distributions as follows: import random RVType = 1 #Type of random variable - pulled from RVDict RVDict= {'1': random.betavariate(1,1), '2': random.expovariate(1), '3': random.gammavariate(1,1), '4': random.gauss(0,1), '5': random.lognormvariate(1,1), '6': random.paretovariate(1), '7': random.uniform( -1,1), '8': random.weibullvariate(1,2) } x = [] y=[] rv = RVDict[str(RVType)] for i in range(N): x.append(rv) y.append(rv) Oddly, x and y get filled with a single value repeated N times. I expected to get a different random number appear each time I called rv ,but this does not happen. Instead, my first call to rv generates a random number from the appropriate distribution, while subsequent calls simply repeat the random number generated in the first call. Where am I going wrong? Thanks in advance for your help. Sincerely Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list
Newbie Question.. How to add python to system path in windows?
hi All, I have my Phitno 25 installed on the default directory, but How can I dd to the ubild path? Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a python c-module: passing double arrays to c functions. segmentation fault. swig
On 30 Mar, 22:21, [EMAIL PROTECTED] wrote: Hello everybody, I'm building a python module to do some heavy computation in C (for dynamic time warp distance computation). Why don't you just ctypes and NumPy arrays instead? # double timewarp(double x[], int lenx, double y[], int leny); import numpy import ctypes from numpy.ctypeslib import ndpointer from ctypes import c_int _timewarp = ctypes.cdll.timewarp.timewarp # timewarp.dll array_pointer_t = ndpointer(dtype=double) _timewarp.argtypes = [array_pointer_t, c_int, array_pointer_t, c_int] def timewarp(x, y): lenx, leny = x.shape[0], y.shape[0] return _timewarp(x, lenx, y, leny) -- http://mail.python.org/mailman/listinfo/python-list
standard input, for s in f, and buffering
One thing that has annoyed me for quite some time. I apologize if it has been discussed recently. If I run this program on Unix (Python 2.4.4, on Debian Linux) import sys for s in sys.stdin: print '', s , and type the input on the keyboard rather than piping a file into it, two annoying things happen: - I don't see any output until I have entered a lot of input (approximately 8k). I expect pure Unix filters like this to process a line immediately -- that is what cat, grep and other utilities do, and also what Perl's while() { ... } construct does. - I have to type the EOF character *twice* to stop the program. This is also highly unusual. If I saw this behavior in a program, as a long-time Unix user, I'd call it a bug. I realize this has to do with the extra read-ahead buffering documented for file.next() and that I can work around it by using file.readline() instead. The problem is, for s in f is the elegant way of reading files line by line. With readline(), I need a much uglier loop. I cannot find a better one than this: while 1: s = sys.stdin.readline() if not s: break print '', s , And also, for s in f works on any iterator f -- so I have to choose between two evils: an ugly, non-idiomatic and limiting loop, or one which works well until it is used interactively. Is there a way around this? Or are the savings in execution time or I/O so large that everyone is willing to tolerate this bug? BR, /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Dispatching functions from a dictionary
[EMAIL PROTECTED] writes: RVDict= {'1': random.betavariate(1,1), '2': random.expovariate(1), ...} This actually calls the functions random.betavariate, etc. when initializing RVDict. If you print out the contents of RVDict you'll see that each value in it is just a floating point number, not a callable. You want something like: RVDict = {'1': lambda: random.betavariate(1,1), '2': lambda: random.expovariate(1), etc. The lambda keyword creates a function that when called evaluates the expression that you gave it. For example, lambda x: x*x is a function that squares its argument, so saying y = (lambda x: x*x) (3) is similar to saying: def square(x): return x*x y = square(3) Both of them set y to 9. In the case of lambda: random.expovariate(1) you have made a function with no args, so you'd call it like this: rvfunc = RVDict[str(RVType)] for i in range(N): x.append(rvfunc()) y.append(rvfunc()) rvfunc (the retrieved dictionary item) is now a callable function instead of just a number. It takes no args, so you call it by saying rvfunc(). -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
Hallöchen! hdante writes: On Mar 30, 9:45 am, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: hdante wrote: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: Could you please list some that do, and are also convenient? AFAICT there's none. This should be easy to implement on emacs, It *is* implemented in Emacs. You can even choose from many input methods, optimised for differend areas/languages. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 3:14 pm, Lie [EMAIL PROTECTED] wrote: On Mar 30, 12:11 pm, hdante [EMAIL PROTECTED] wrote: (snip) BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: if x ≠ 0: ∀y ∈ s: if y ≥ 0: f1(y) else: f2(y) That would be a nightmare. Programming language (or most computer-based texts) should only use basic ASCII characters, except if it can't be helped since typing non- I completely disagree. Unicode should be used whenever the architecture doesn't have memory restrictions. For general (plain-)text there's no sense in talking about ASCII. The only language that fits in it that I can remember is Latin. ASCII characters is still unreliable. It'd also be a headache to memorize what keyboard combinations to use to type a character. Not to You'd have to memorize, for example != and =. mention how much more complex would the keyboard design be. Also not The keyboard would be the same. mentioning how much more complex the language design would be to handle all those non-ASCII characters. Wrong. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why prefer != over for Python 3.0?
On Mar 30, 6:08 pm, Torsten Bronger [EMAIL PROTECTED] wrote: Hallöchen! hdante writes: On Mar 30, 9:45 am, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: hdante wrote: BTW, my opinion is that it's already time that programmer editors have input methods advanced enough for generating this: Could you please list some that do, and are also convenient? AFAICT there's none. This should be easy to implement on emacs, It *is* implemented in Emacs. You can even choose from many input methods, optimised for differend areas/languages. I mean creating an input method specific for programming languages, not using the TeX one. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] (Seehttp://ime.webhop.orgfor further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding Full Path to Process EXE
That's not a problem - I'm only interested in Win2k+. Thanks for the caveat. On a similar note, is there a way (preferably using WMI) to get the full path to the executable that has a port open (the same thing that fport does, just implemented in Python)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pexpect question.
On Fri, 28 Mar 2008 08:12:36 -0700 (PDT), Paul Lemelle [EMAIL PROTECTED] wrote: I am trying separate a script that users pexpect into various functions within the same expect session. The problem is that the function does not return control back Main. I do not understand what that sentence means. Any insight into this issue would be greatly appreciated. Below is sample code of the problem. First, what is the purpose of this program? It seems to be a more tedious way to get an ssh login to some Unix host. Ssh can be configured to do many things; maybe you do not need Python at all? Second, it will fail as soon as you use the undefined object 'chk'. Third, if not return control back Main means sshcon() does not return, then it is by design. You call go.interact(), which hands over control to the user until he types an escape sequence. See the pexpect documentation. Fourth, sshcon() does not handle the full dialogue ssh can give you. If you get are you sure you want to connect etc, you will hang until pexpect.TIMEOUT is thrown. I have reformatted the source code to be more readable: import pexpect def sshcon(host, password): go = pexpect.spawn ('/usr/bin/ssh -l root %s ' % host) go.expect ('Password: ') go.sendline (password) go.interact() #get node info for both clusters. C1_node = raw_input(Enter the ip address for node on cluster 1: ) C1_pass = raw_input(Enter the password for the node on cluster 1: ) sshcon(C1_node, C1_pass) #go to the path chk.expect('# ') chk.sendline('ls') chk.interact() /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Tell ya' what:
On Fri, 28 Mar 2008 22:01:57 -, Grant Edwards [EMAIL PROTECTED] wrote: On 2008-03-28, Paul Rubin http wrote: [EMAIL PROTECTED] writes: Did everyone take the course on computer architecture? Yow! Does your SPEED QUEEN have CABLE? Ya know, I was thinking about trying to find an updated file of Zippy quotes for use in my .sig, but I decided that having all of the pop culture references be 30-years out of date was part of the charm. I hope the ''Eurythmics'' practice birth control ... More like 20--25 years. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Summary of threading for experienced non-Python programmers?
Hrvoje Niksic [EMAIL PROTECTED] writes: I believe you stil misunderstand. The select module doesn't provide an inteface to aio(3). It provides an interface to select() and poll() system calls, which don't provide asynchronous access to regular files. It occurred to me that I didn't provide an example of what I mean by select not providing asynchronous access to regular files. Using this code: import os, select fd = os.open('/mnt/custom/x.jpg', os.O_RDONLY) fd 3 # /mnt/custom is an SMB or NFS mount. At this point, kill -STOP the # SMB server. select.select([fd], [], [], 10)# test whether fd is readable ([3], [], []) # exits immediately, assume os.read(3, 1024) ... hangs until smb server continues ... The thing is, select() *always* returns immediately on regular files, even if they are in fact not readable or writable. In this case, select() claimed the file descriptor to be readable when in fact it wasn't. The same is the case with poll, but not with aio. In most cases this isn't a problem, but it does mean that an application that reads from a network-share-located file in a select/poll-driven event loop will stall until the file server responds. Threads, on the other hand, don't have this problem. A program that reads the file in a separate thread will not block even if the file is on a temporarily non-responding NFS server. -- http://mail.python.org/mailman/listinfo/python-list
Re: Licensing
Paul Boddie wrote: On 29 Mar, 20:24, DS [EMAIL PROTECTED] wrote: I'm pretty sure this is the wrong place to ask, but I'm hoping someone will point me in the right direction. I'm getting ready to publish a first open-source project written in python. I am planning to use GPLas the license. However, in my code, there is a function that I like from Python Cookbook. I would like to use it, although I could certainly write a less elegant version that would do the same thing. Note that the Python Cookbook says this about licensing: Except where otherwise noted, recipes in the Python Cookbook are published under the Python license. The link is incorrect, but I presume they mean this licence: http://www.python.org/psf/license/ It's generally not recommended to use this licence for anything other than Python because it mentions the need to reproduce the Python copyright statement in derived works, which would be nonsense for anything which isn't the Python distribution. However, one can infer that the copyright notice specific to the software concerned should be reproduced, and this is what the original CWI licence says. Of course, if a different licence is mentioned on the specific recipe you're using, you have to observe the terms mentioned in that licence instead. So, my options appear to be: 1. Don't use it. 2. Use it with no comment -- that doesn't seem right. 3. Use it with remarks in the code that acknowledge the source. 4. Provide a separate licensing page for that function along with the GPL for my code. What is the appropriate course of action here? I'm thinking #3 is probably ok. How do others deal with this in an honorable way? In the book, it appears that they are saying they don't really care unless there is some massive use. You just need to do what's necessary to satisfy the licence applied to the code you're using. If that's the Python licence, I would imagine that reproducing the copyright statement and licence details would be sufficient, even if your own work is GPL-licensed. What I've done when I've released work which incorporates other work (itself available under a permissive licence) is to include the copyright statements and the licence text for that other work, but I've made it clear in the licensing information that the derived work (my code incorporating the other code) is available under the specific licence I've chosen, noting that the other work was made available under a different licence. So I suppose that #4 is the closest, but you should be able to assert that the entire work is GPL-licensed unless the recipe isn't licensed in a GPL-compatible way, which would open up a range of other issues that you hopefully won't have to deal with. ;-) Paul P.S. This isn't anything close to legal advice, so please take other opinions into account. ;-) Thanks for taking the time to write. I was also wondering about what ramifications there are from mixing code from other licenses. So, I guess if I was going to do it, I'd have a second license file for this specific function with the license for it. I definitely don't want to be in a situation where credit for someone else's work is not adequately documented. It has happened to me, I know how I felt about it at the time. At this point, I'm thinking that it is not worth messing with. What I am going to do is write a separate function to accomplish the same thing. It's only a few lines long. Of course, having seen the other code I'm forever tainted... There is something a little humorous about reading through the Python Cookbook. You have submissions from all these incredibly smart people with little gems of functions. But, if you actually use them, it's kind of a hassle. On the other hand, I'm glad the book exists, and my memory of the specific details of a function fade over time, but it has/does give my a better understanding in general of how do things. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dispatching functions from a dictionary
On Mar 30, 5:06 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: RVDict= {'1': random.betavariate(1,1), '2': random.expovariate(1), ...} This actually calls the functions random.betavariate, etc. when initializing RVDict. If you print out the contents of RVDict you'll see that each value in it is just a floating point number, not a callable. You want something like: RVDict = {'1': lambda: random.betavariate(1,1), '2': lambda: random.expovariate(1), etc. In Python 2.5, you can also write this as: from functools import partial RVDict = {'1': partial(random.betavariate,1,1), '2': partial(random.expovariate,1), etc. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Summary of threading for experienced non-Python programmers?
On Mar 28, 11:52 am, [EMAIL PROTECTED] wrote: I'm having trouble explaining the benefits and tradeoffs of threads to my coworkers and countering their misconceptions about Python's threading model and facilities. They all come from C++ and are used to thinking of multithreading as a way to harness multiple CPU cores for compute-bound processing. I also encountered, Python doesn't really do threads today. *sigh* I don't need pointers to the relevant documentation sections. A bit of googling didn't turn up much about threading beyond tutorial introductions. I'm looking for something which will explain the rationale for using threads in Python to someone who is experienced with multithreading in other languages (like C/C++). Maybe a compare-and-contrast sort of document? Thanks, Skip I think you are having trouble because threads suck. They are the worst way of dealing with concurrency that exists (unfortunately they are the fastest also) :-). Threads are bad because, by construction, code may be subject to non- trivial hazards. There are other ways of dealing with concurrency that doesn't have this problem, like event-driven programming. I think threads are so bad, that when I left my job at a company that developed for PDAs, I told my team: whenever you have an argument about how to make multitasking, you may count my vote against using threads. If you really need to use threads, then use design patterns that make threads behave like message passing systems (I believe there were the monitor model or the actor model or something). If you need threads because you need speed, then use a recent JIT- compiled language, like Java or C#. In general, you may use C or C++ also, but there are a few obscure problems with them because they weren't defined with threads in mind. If you just would like to use multitasking as a programming paradigm, try Twisted, or switch to stackless python (then write an blog about your findings). :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Build complete, now I just need to install it...
En Sun, 30 Mar 2008 12:04:10 -0300, axl [EMAIL PROTECTED] escribió: I'm going to be adding some features for a python-project with external modules written in C. However, if I build modules with my MSVS 2008 compiler (from the Windows SDK), they won't load in Python 2.5.2, which is built with MSVS 2003. Since I don't have access to MSVS 2003 I need to rebuild Python using MSVS 2008 in order for the binaries to go along. For starters, I cloned the PCbuild8 folder and made whatever changes needed to be able to build the core and executable. I then pulled down all the various external dependencies and made the same adjustments to those. After quite a while I've managed to build everything apart from Which changes are those? I can build Python straight from the svn sources. But, my problem is that the install scripts, i.e. python setup.py install wants to go through the build steps again, but since those don't work on Windows, or at least not with my setup, I can't put together a complete package. The MSI package generation is at Tools\msi in the source tree. There are a few preliminary steps that must be done (only once) before successfully building the installer, you'll notice as you go (the script will tell you what's missing; a .rc file has to be compiled, as far as I remember). Would be nice if you take note of them so one can write down the proper build sequence. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Export data to OpenDocument Text
Hi! I'm trying to save data from sqlite to OpenDocument Text. Code: localtime = time.localtime(time.time()) try: odt_file = zipfile.ZipFile(file_name, w) except: print(Невозможно открыть файл для записи) return False buff_file = zipfile.ZipInfo(mimetype, localtime) odt_file.writestr(buff_file, application/ vnd.oasis.opendocument.text) buff_file = zipfile.ZipInfo(content.xml, localtime) buff_file.external_attr = 2179792896 buff_file.flag_bits = 8 buff_file.compress_type = zipfile.ZIP_DEFLATED odt_file.writestr(buff_file, \n.join(content_xml)) buff_file = zipfile.ZipInfo(styles.xml, localtime) buff_file.external_attr = 2179792896 buff_file.flag_bits = 8 buff_file.compress_type = zipfile.ZIP_DEFLATED odt_file.writestr(buff_file, \n.join(style_xml)) buff_file = zipfile.ZipInfo(meta.xml, localtime) buff_file.external_attr = 2179792896 buff_file.flag_bits = 8 buff_file.compress_type = zipfile.ZIP_DEFLATED odt_file.writestr(buff_file, \n.join(meta_xml)) buff_file = zipfile.ZipInfo(META-INF/manifest.xml, localtime) buff_file.external_attr = 2179792896 buff_file.flag_bits = 8 buff_file.compress_type = zipfile.ZIP_DEFLATED odt_file.writestr(buff_file, \n.join(manifest_xml)) odt_file.close() OpenOffice can't open this file, in what a problem ? sample file: http://omploader.org/vZjlo/test.odt -- http://mail.python.org/mailman/listinfo/python-list
Re: socket error when loading the shell?
En Sun, 30 Mar 2008 16:46:00 -0300, [EMAIL PROTECTED] escribió: using python and wpython. Soory, I don't know what wpython is when using run module or python shell on the run menu in the GUI i get socket error, connection refused. it worked before, what si wrong now? Try to detect what changed on your system between before and now. and i cant find where to start the shell directly. think i had an exe before but cant seem to find it now. python.exe? c: cd \ dir /s python.exe -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: socket error when loading the shell?
[EMAIL PROTECTED] wrote: using python and wpython. What's wpython? when using run module or python shell on the run menu in the GUI i get socket error, connection refused. it worked before, what si wrong now? There's no process listening for the port you try to connect to, so the target host refuses. and i cant find where to start the shell directly. Well, for me, ALT-F2 xterm[Enter] works. think i had an exe before but cant seem to find it now. You mean the Python interpreter? It's probably located on your system root in a directory called pythonversion. But I'd rather use IDLE. Regards, Björn -- BOFH excuse #338: old inkjet cartridges emanate barium-based fumes -- http://mail.python.org/mailman/listinfo/python-list
Re: Using QSystemTrayIcon with PyQt
On Mar 29, 11:02 pm, Alex Teiche [EMAIL PROTECTED] wrote: Hello, I am pretty new to Python, and have never learned C++. I am trying to implement the following thing into my python application: http://doc.trolltech.com/4.3/qsystemtrayicon.html Through PyQt. I have been using PyQt for awhile and I know how do use it, but I could not get this specific thing to work. Can someone give me some hints as to get it working in Python? What problems are you having? Thanks a ton, Alex -- http://mail.python.org/mailman/listinfo/python-list