Announce: Linux Desktop Testing Project (LDTP) 0.9.0 released
Hi, We are proud to announce the release of LDTP 0.9.0. This release features number of important breakthroughs in LDTP as well as in the field of Test Automation. This release note covers a brief introduction on LDTP followed by the list of new features and major bug fixes which makes this new version of LDTP the best of the breed. Useful references have been included at the end of this article for those who wish to hack / use LDTP. About LDTP == Linux Desktop Testing Project is aimed at producing high quality test automation framework (C / Python) and cutting-edge tools that can be used to test Linux Desktop and improve it. It uses the Accessibility libraries to poke through the application's user interface. The framework also has tools to record test-cases based on user events in the interface of the application which is under testing. We strive to help in building a quality desktop. Whats new in this release... * Kartik Mistry fixed build issue in Alpha machines * Rewrote the recording framework and it completely uses pyatspi / orca-atspi (when pyatspi is missing) * Added new accessibility roles required for Firefox automation * Other major bug fixes * LDTP documentation has been majorly updated - http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf Download source tarball - http://download.freedesktop.org/ldtp/0.x/0.9.x/ldtp-0.9.0.tar.gz LDTP news = * Harishankar did a wonderful job of doing Firefox automation using LDTP as part of Google Summer of Code 2007 under Mozilla organization - http://nagappanal.blogspot.com/2007/08/summer-of-code-2007-firefox-automation.html References == For detailed information on LDTP framework and latest updates visit http://ldtp.freedesktop.org For information on various APIs in LDTP including those added for this release can be got from http://ldtp.freedesktop.org/user-doc/index.html To subscribe to LDTP mailing lists, visit http://ldtp.freedesktop.org/wiki/Mailing_20list IRC Channel - #ldtp on irc.freenode.net For suggestions to improve this newsletter, please write to anagappan at novell.com Thanks Nagappan -- -- Nagappan A [EMAIL PROTECTED] Linux Desktop Testing Project - http://ldtp.freedesktop.org http://nagappanal.blogspot.com Novell, Inc. SUSE* Linux Enterprise 10 Your Linux is ready* http://www.novell.com/linux -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
[ANN] Only 3 days left for early bird rate - Python-Workshop in Leipzig, Germany, September 7, 2007
The following announcement is in German. Despite this we would like to post it here, because many German speaking Python users read this group/list. Bis zum 31. August gilt noch die ermäßigte Anmeldegebühr. Also am Besten gleich anmelden unter: http://www.python-academy.de/workshop/anmeldung.html === Workshop Python im deutschsprachigen Raum === Am 7. September 2007 findet in Leipzig der zweite Workshop Python im deutschsprachigen Raum statt. Der erste Workshop 2006 war erfolgreich, so dass es auch dieses Jahr einen geben wird. Der Workshop ist als Ergänzung zu den internationalen und europäischen Python-Zusammenkünften gedacht. Die Themen- palette der Vorträge ist sehr weit gefasst und kann alles einschließen, was mit Python im deutschsprachigen Raum zu tun hat. Eine ausführliche Beschreibung der Ziele des Workshops, der Workshop-Themen sowie Details zu Organisation und Anmeldung sind unter http://www.python-academy.de/workshop zu finden. === Wichtige Termine === 31.08.2007 Letzter Termin für Frühbucherrabatt 07.09.2007 Workshop 15.09.2007 Letzter Termin für die Einreichung der publikationsfähigen Beiträge Dezember 2007 Veröffentlichung des Tagungsbandes === Bitte weitersagen === Der Workshop soll auch Leute ansprechen, die bisher nicht mit Python arbeiten. Wer mithelfen möchte, den Workshop bekannt zu machen, kann einen Link auf http://www.python-academy.de/workshop setzen. Auch außerhalb des Internets kann der Workshop durch den Flyer http://www.python-academy.de/download/workshop_call_for_papers.pdf oder das Poster http://www.python-academy.de/download/poster_python_workshop_2007.pdf bekannt gemacht werden. Den Flyer einfach doppelseitig ausdrucken oder kopieren. Das Poster möglichst auf A3 ausdrucken oder von A4 auf A3 kopieren. Gern schicken wir auch die gewünschte Menge Flyer oder Poster im A3-Format per Post zu. Dann ein Poster zusammen mit ein paar Flyern am Schwarzen Brett von Universitäten, Firmen, Organisationen usw. aushängen. Ideen, wie wir auch Leute erreichen, die Python-Websites oder -Listen nicht frequentieren, sind immer willkommen. Wir freuen uns auf eine rege Teilnahme, Mike Müller Stefan Schwarzer -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Biased random?
En Mon, 27 Aug 2007 17:42:45 -0300, Ivan Voras [EMAIL PROTECTED] escribi�: I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of probability looks like at this point - can be linear). I see that there are several functions in Python standard libraries for various distribution, but is there an easy pythonic way to make them do what I need? Using a linear (or triangular) distribution: --- begin --- from random import randint def biased_choice(values): Choose a random element from values; first elements are chosen more frequently than later ones. Weights are linearly assigned; given n elements, the first has weight n, second has n-1, ... last has weight 1. n = len(values) sumw = ((n + 1) * n) // 2 x = randint(1, sumw) F = 0 for i in xrange(1, n+1): F += i if x=F: return values[-i] # test from collections import defaultdict values = [a, b, c, d, e] stats = defaultdict(int) for i in xrange(15): stats[biased_choice(values)] += 1 for key in sorted(stats): print key, stats[key] --- end --- Output: a 50023 b 39869 c 30256 d 19784 e 10068 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Suitability?
On 28 Aug., 02:28, [EMAIL PROTECTED] (Michael R. Copeland) wrote: Note that I'm not considering using the existing C/C++ code in my Web application, because I don't know how to write a C/C++ Windows application - and I'm sure the learning curve here is greater than Python's. I'm a very old procedural-based application developer (47+ years of programming experience), and developing Windows applications is beyond me. As I see it you might separate the console frontend from your database/ model backend and reuse your database code. The next step would be selecting a webframework that allows you to plugin your own database driver which has to be wrapped into a Python module. For wrapping into a Python module there are several alternatives. SWIG and BOOST.Python are most natural solutions for wrapping C++ code and exposing its functionality to Python. Other options are writing a C interface to your database and use ctypes, Pythons stdlib FFI ( see Python 2.5 docs ). Not sure if there are tools yet to derive a C interface automatically from C++ classes. If so I would prefer the FFI approach. For database plugins: a framework like Pylons [1] seems to be particularly suited for this option but I would recommend requesting answers by the Pylons community directly. [1] http://pylonshq.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: SCF released to GPL
hg a écrit : 2) I'm desperately searching for the French NG from my client but cannot find it ... any clue ? Maybe you can pass the message ? Done. See http://groups.google.com/group/fr.comp.lang.python/browse_frm/thread/fa4474921f77b1be/8d6150d502447510#8d6150d502447510 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to free memory ( ie garbage collect) at run time with Python 2.5.1(windows)
On 8/27/07, Peter Otten [EMAIL PROTECTED] wrote: Peter Otten wrote: Alex Martelli wrote: Integer objects that are once generated are kept around in a free list against the probability that they might be needed again in the future (a Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type help, copyright, credits or license for more information. x = 1000 y = 1000 x is y False Why don't x and y point to the same object then? Peter Oops, I think I got it now. The actual objects are freed, only the memory is kept around for reuse with other ints... On my (windows) machine, only integer up to 256 are cached... I made two dictionaries with mapping from i to id(i) and then compared. They were equal up to 256. In short, try your example with 256 and 257 and see what happens :-) francesco -- http://mail.python.org/mailman/listinfo/python-list
Re: How to parse this line of code manually
On 2007-08-28, Davy [EMAIL PROTECTED] wrote: On Aug 28, 11:00 am, Davy [EMAIL PROTECTED] wrote: Hi all, It is well known that Python is appreciated for its merit of concise. However, I found the over concise code is too hard to understand for me. Consider, for instance, def known_edits2(word): return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS) Shall I understand the code in set() as for e2 in edits1(e1) { if e2 in NWORDS { for e1 in edits1(word) { e2 } } } [SNIP] Hi all, I figured it myself. It is left to righ parse, right? So the above one is like for e1 in edits1(word) { for e2 in edits1(e1) { if e2 in NWORDS { push e2 to set } } } This is correct, although I am not sure what language you are using here, it looks like a strange mix of Python and C to me. Any suggestions are welcome! The idea is known as List comprehension (for lists, obviously), and comes from functional programming, Bird Wadler used it in their book. The notation is very close to mathematics: { e2 | e1: edits(word), e2: edits(e1) in NWORDS } or in LaTeX: $\{ e_2 | \forall e_1: \mathrm{edits}(\mathrm{words}), \forall e_2: \mathrm{edits}(e_1) \in \mathrm{NWORDS} \}$ :-) (which in words is something like: collect values e2, where e1 comes from 'edits(word)', e2 comes from 'edits(e1)', and e2 in NWORDS) Sincerely, Albert -- http://mail.python.org/mailman/listinfo/python-list
Re: How to free memory ( ie garbage collect) at run time with Python 2.5.1(windows)
Alex Martelli a écrit : rfv-370 [EMAIL PROTECTED] wrote: (snip) So how can I force Python to clean the memory and free the memory that is not used? On Windows, with Python 2.5, I don't know of a good approach (on Linux and other Unix-like systems I've used a strategy based on forking, doing the bit that needs a bazillion ints in the child process, ending the child process; but that wouldn't work on Win -- no fork). IIRC, Windows has it's own way to let you launch other processes, so a similar strategy might apply here... -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
I saw your article is very good, I like it very much. I will continue to pay attention to your article, the following are the points I hope that I have similar concerns. http://www.game-win.com http://www.game-win.com/wow-powerleveling.html http://www.game-win.com/faq.html http://www.game-win.com/power-leveling.html http://www.game-win.com/World-of-Warcraft-power-leveling.html http://www.paper-cup-machine.com http://www.sinceremachine.com http://www.clickra.com http://www.clickra.com/NewsList_2.htm http://www.east163.com http://www.ruian2machine.cn http://www.rajayj.cn http://www.mycvcv.com http://www.dgajm.com http://www.icansee.cn http://www.icansee.cn/chanpin.htm http://www.pjwsdyb.com http://www.shdyf.com http://www.nonwoven-bags.cn http://www.plastic-thermoforming-machine.com http://www.gopowerlevel.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Chaining programs with pipe
On 28 ago, 02:11, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: In message [EMAIL PROTECTED], Gabriel Genellina wrote: En Mon, 27 Aug 2007 05:35:51 -0300, Lawrence D'Oliveiro [EMAIL PROTECTED] escribi?: In message [EMAIL PROTECTED], Gabriel Genellina wrote: On 22 ago, 11:08, Grant Edwards [EMAIL PROTECTED] wrote: but I'm a Unix guy who occasionally tries to ship a Windows version of a Python app: the concept of a process defaulting to having a stderr or stdout that wasn't writable was utterly foreign to me. Ah, that explains your previous post telling that things on Windows don't work as they should. They work, but not necesarily as a foreigner would expect. So what's the good reason for Windows having unusable defaults for stderr and stdout, then? You should ask the wxPython/wxWidgets guys why they choose to do things that way. But I assumed you knew, since you were the one who used to term foreigner to describe Grant Edwards' mystification at why things worked this way. So in fact you are equally a foreigner to the way Windows works? I do know how to create console applications, but that is not relevant. If a wxPython application crashes when something is written to stdout/stderr, this is either the programmer fault or the framework fault, *not* Windows fault. As I said, a Tk application doesn't crash in those circunstances, by example. Many other applications don't crash either. The default behavior for a GUI application is to simply discard the output. (And my comment was not referring to that specific problem - this thread is too broad now). Tk programs don't have that problem, by example: you have a GUI *and* a console, if you want. A simple print statement with no console just goes into void space - no error, no crash, no GPF... You get what you ask for: if you pass /SUBSYSTEM:WINDOWS as an option to the linker (or put equivalent flags in the executable) you don't get a console by default. That's fine for most GUI programs that don't use stdout/stderr. If you want a console, create one using AllocConsole. But why should I need to do that? Because the distinction IS relevant on Windows? On Unix/Linux systems, there is no distinction between GUI and non-GUI programs--_all_ processes can (and usually do) have stdin, stdout and stderr. On Windows, windowed applications (as opposed to console applications) start with no stdin/stdout/stderr by default. The application developer can modify that if desired, of course - I've menctioned some ways to do that. This fact simply means that those OS's *are* different - most of the time one can ignore the differences, but not always. Neither of them is doing the absolute Right Thing. stderr is particularly important for GUI programs, so the desktop environment typically captures this to a file, commonly called .xsession-errors. This is very useful when things go wrong (programs crash etc), to see what error messages were reported. There are plenty of logging systems to choose. Redirecting stderr to a file can be done either by the app itself or by its caller (for a well behaved application, of course; the crashing wxPython app menctioned earlier appears not to be one of those). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Does shuffle() produce uniform result ?
Thanks to everyone who replied, (and special thanks to Alex Martelli,) I was able to accomplish what I originally asked for: a shuffle() which is both fast and without bias. It is the first time I try to optimize python code, and it is definitely a very rewarding experience. To bring closure to this thread, I will provide below some statistics obtained from cProfile: 1. using random.SystemRandom ncalls tottime percall cumtime percall filename:lineno(function) 4182879 35.1540.000 211.0060.000 os.py:724(urandom) 4182879 31.9810.000 248.2910.000 random.py:767(random) 40578 17.9770.000 266.3000.007 random.py:250(shuffle) 4182879 29.4870.000 29.4870.000 {posix.close} 4182879 99.4600.000 99.4600.000 {posix.open} 4182879 41.7940.000 41.7940.000 {posix.read} 2. my original optimization 82680.1330.0002.5770.000 os.py:724(urandom) 4134322 15.0940.000 21.6060.000 baccarat.py:70(get2bytes) 4131441 17.2210.000 41.7220.000 baccarat.py:85(randrange) 405907.0590.000 48.7950.001 baccarat.py:112(shuffle) 3. using Alex's generator with string 41170.0580.0002.0480.000 os.py:724(urandom) 4214795 10.1860.000 14.8800.000 baccarat.py:93(rand2) 42117908.8830.000 23.7630.000 baccarat.py:106(randrange) 407396.1010.000 29.8780.001 baccarat.py:131(shuffle) 4. using Alex's generator with array 20810.0290.0001.7360.001 os.py:724(urandom) 41615691.7240.0003.4730.000 baccarat.py:100(rand2new) 41584748.3150.000 11.7880.000 baccarat.py:113(randrange) 405145.7260.000 17.5280.000 baccarat.py:138(shuffle) -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
On Aug 27, 11:28 pm, [EMAIL PROTECTED] wrote: On Aug 27, 3:21 pm, geoffbache [EMAIL PROTECTED] wrote: Hi, As part of my efforts to write a test tool that copes with GUIs nicely, I'm trying to establish how I can start a GUI process on Windows that will not bring up the window. So I try to hide the window as follows: info = subprocess.STARTUPINFO() info.dwFlags |= subprocess.STARTF_USESHOWWINDOW info.wShowWindow = subprocess.SW_HIDE proc = subprocess.Popen(..., startupinfo=info) This works, in a way, but doesn't work recursively. I.e. if the started process itself starts a window, that second window will not be hidden. This even applies to dialog boxes within the application. So instead of a lot of windows popping up I now get a lot of disembodied dialogs appearing, which is a slight improvement but not much. Also, certain processes (e.g. tkdiff) seem to ignore the directive to be hidden altogether. This is dead easy on UNIX with virtual displays like Xvfb. Can someone shed any light if it's possible on Windows from python? Regards, Geoff Bache I'm confused. Why would you create a GUI if you're not going to actually display it? Isn't that the point of a GUI? Or are you talking about the command window popping up? Mike Only in the context of testing it. If I run lots of GUI tests on my computer I want the tested GUIs to remain hidden so I can still use my computer in the meantime... Though if you can tell me how to stop the command window popping up on Windows I'll be grateful for that too (though it wasn't the original question). Geoff -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting a list of lists
Thanks guys, dirty hack was what I needed to get a job done quickly. Nick -- http://mail.python.org/mailman/listinfo/python-list
Re: XML File -- dictionary edit/search
On 8/28/07, Nagarajan [EMAIL PROTECTED] wrote: A simple yaml file might just do the trick. Your yaml file shall look like the following: Word-def.yaml word1: word1's definition word2: word2's definition .. .. .. Use pyyaml to handle yaml files. import yaml worddefs = yaml.load( open( word-def.yaml, r ).read() ) print worddefs I agree with the suggestion for yaml! Since definitions are to be inputed by the users, it could be better to use yaml.safe_load() to reduce the risks... francesco -- http://mail.python.org/mailman/listinfo/python-list
National grid to lat long conversion
Hi, I have a load of British National Grid references that I want to convert to decimal degrees so I can create a google KML file. Does anyone know of a module to do this? I've looked at http://pygps.org/#LatLongUTMconversion but am not really up to speed with projections and all this other mapping stuff. I want to take something like x = 417512 y = 315098 (SK 17570 15100) and convert it to a google compatible decimal degrees lat: 52.733255N Long: -1.741239 Any help would be great -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
On Mon, 27 Aug 2007 22:42:45 +0200, Ivan Voras wrote: I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of probability looks like at this point - can be linear). I see that there are several functions in Python standard libraries for various distribution, but is there an easy pythonic way to make them do what I need? If you really just want to tend towards the beginning of the list, and don't care what the envelope looks like, how about this: def biasedselection(thelist): index = random.random() * random.random() * len(thelist) # or index random.random() ** 2 * len(thelist) return thelist[index] Dan -- Dan Sommers A death spiral goes clock- http://www.tombstonezero.net/dan/ wise north of the equator. Atoms are not things. -- Werner Heisenberg -- Dilbert's PHB -- http://mail.python.org/mailman/listinfo/python-list
Dead lock in pymat after using threading?
Hi, I'm having problems using the package pymat after using threading, e.g. the line: # h = pymat.open() # is not possible to fully execute after the lines: # import threading from time import sleep def SlpFcn(): sleep(5) print end of sleep trd = threading.Thread(target=SlpFcn) trd.start() # MATLAB is started as it should, but the python interpreter does not answer and has to be shut down using CTRL+ALT+DEL. After restarting the interpreter it is possible to use pymat again without problems (seems to be some kind of memory issue). What differences between before and after threading are there, that could cause these problems? (del trd or gc.collect after the threading, does not solve my problem.) I'm using Python 2.2 in ControlDesk, Windows XP. Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: SCF released to GPL
hg a écrit : 2) I'm desperately searching for the French NG from my client but cannot find it ... any clue ? Maybe you can pass the message ? Contact Michel Claveau ( [EMAIL PROTECTED] ) for a solution via his Usenet relay. A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list
Re: an eval()-like exec()
On Aug 27, 6:06 pm, Matt McCredie [EMAIL PROTECTED] wrote: A python interactive interpreter works by having the user type in some code, compiling and running that code, then printing the results. For printing, the results are turned into strings. I would like make an interpreter which does this, without the last part: i.e. where the results are returned as objects, instead of as strings. I.e. have I would like to see something that behaves like this: ip = MyInterpreter() # this started a new interpreter ip.run(import math) is None True ip.run(math.pi) is math.pi True Neither exec() or eval() is usable for this, as far as I see, because eval can't handle arbitrary python code (eval(import math) ), and exec() doesn't return the results. Subclassing an code.InteractiveInterpreter or code.InteractiveConsole seems like a usable idea, but I couldn't find out what to do to get the results before they are turned into strings. Using compile() and then eval() didn't seem usable either. Any ideas? Well, my first thought is that exec and eval serve two different purposes, and you should just have both of them and use the appropriate one based on the situation. However, I think it is possible to enable the behavior you want: [code] def myeval(statement, globals_=None, locals_=None): try: return eval(statement, globals_, locals_) except SyntaxError: if locals_ is None: import inspect locals_ = inspect.currentframe().f_back.f_locals exec statement in globals_, locals_ [/code] It seems to work for me. Matt Unless it's something like: raise_(SyntaxError) where raise_ is a function equivalent to the corresponding statement. -- http://mail.python.org/mailman/listinfo/python-list
Re: Let's Unite Against Jews and Mongrels!
On Aug 27, 2:13 am, Nenad Milicevic - The Aryan Serb [EMAIL PROTECTED] wrote: Let's break the chains of Jewish and black domination! A) Why? B) What chains? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to parse this line of code manually
On Aug 28, 2:59 am, A.T.Hofkamp [EMAIL PROTECTED] wrote: On 2007-08-28, Davy [EMAIL PROTECTED] wrote: On Aug 28, 11:00 am, Davy [EMAIL PROTECTED] wrote: Hi all, It is well known that Python is appreciated for its merit of concise. However, I found the over concise code is too hard to understand for me. Consider, for instance, def known_edits2(word): return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS) Shall I understand the code in set() as for e2 in edits1(e1) { if e2 in NWORDS { for e1 in edits1(word) { e2 } } } [SNIP] Hi all, I figured it myself. It is left to righ parse, right? So the above one is like for e1 in edits1(word) { for e2 in edits1(e1) { if e2 in NWORDS { push e2 to set } } } This is correct, although I am not sure what language you are using here, it looks like a strange mix of Python and C to me. Any suggestions are welcome! The idea is known as List comprehension (for lists, obviously), and comes from functional programming, Bird Wadler used it in their book. The notation is very close to mathematics: { e2 | e1: edits(word), e2: edits(e1) in NWORDS } or in LaTeX: $\{ e_2 | \forall e_1: \mathrm{edits}(\mathrm{words}), \forall e_2: \mathrm{edits}(e_1) \in \mathrm{NWORDS} \}$ :-) (which in words is something like: collect values e2, where e1 comes from 'edits(word)', e2 comes from 'edits(e1)', and e2 in NWORDS) For more examples: http://docs.python.org/tut/node7.html#SECTION00714 A 'list comprehension' with parentheses instead of square-brackets creates a generator instead of a list, which can be more memory- efficient and allows for lazy evaluation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Let's Unite Against Jews and Mongrels!
Dustan wrote: On Aug 27, 2:13 am, Nenad Milicevic - The Aryan Serb [EMAIL PROTECTED] wrote: Let's break the chains of Jewish and black domination! A) Why? B) What chains? Posting such as the one that started this thread are best ignored! Unless, of course, someone has a working Killbot. If anyone has such a thing, please kill that MI5victim moron as well! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Suitability?
Michael R. Copeland [EMAIL PROTECTED] wrote: I have some questions about the suitability of Python for some applications I've developed in C/C++. These are 32 bit Console applications, but they make extensive use of STL structures and functions (Lists, Maps, Vectors, arrays) - primarily because the data volume is high (2,500,000+ records). This is all bread and butter stuff to python and 10 times easier to do in python than C++! The main thing I'd like to do is port one part of the system that has a series of user menus and works with several text data files (one _very_ large). I'm not using any database system, just my home-grown indexed sequential file database. There's nothing but volume that precludes this application from running from almost any text file- processing language system (e.g. Perl, BASIC, etc.). From what little I've seen of Python, it appears I could port this application to Python code, but I'd do so only if I could: 1. Integrate it into a Web application in such a way that the user could select it as an option from a main page and have it execute as a WEB GUI application. Currently, the application's interface is only a crude DOS window. A web application is possible. You can start your application which would run its own embedded web server which the user could then control. Python has a web server in the standard library. I've done exactly this using cherrypy as a simple web application framework. The asynchronous nature of web applications are often a pain. You could write a windows GUI using TKinter (which comes with python) or WxPython (which doesn't). Those toolkits make it very easy to make GUI applications. 2. Assure that the performance isn't totally crippled by using Python, an interpretted language. While I don't expect native C/C++ performance, I don't want to be embarrassed... Depends exactly what you are doing. If you are IO limited then Python is just as fast as C++. If you are doing lots of calculation on the data then python can be slow. You can use the numpy library which is a library of scientific maths routines all coded in C for speed which is very quick. http://numpy.scipy.org http://sourceforge.net/projects/numpy 3. Make sure that the volume of stored data (2.5+ million records) can be accommodated in Python structures (I don't know enough about Python to answer this question...). I wouldn't have thought that would be a problem. Note that I'm not considering using the existing C/C++ code in my Web application, because I don't know how to write a C/C++ Windows application - and I'm sure the learning curve here is greater than Python's. You could always use ctypes from python to interface with your C code. If you can export your code in a DLL then ctypes can use it. (Not sure about C++ though) I'm a very old procedural-based application developer (47+ years of programming experience), and developing Windows applications is beyond me. So, I only (?) want to take an existing application that uses a large text file (and several smaller text indexing files) and put it into a Web system I already have. I feel Python (or Perl) is(are) my best option(s), and here I'm only looking for some initial guidance from the Python users. TIA Go for it! Python is such an easy language to write stuff in (escpecially compared to C++) that you'll have the prototype done very quickly and you can evaluate the rest of your concerns with working code! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: Under the spell of Leibniz's dream
In message [EMAIL PROTECTED], Albert Y. C. Lai wrote: Twisted wrote: A link to a copy in a non-toxic format would be nice. http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1298.html Not a mention of Gödel. -- http://mail.python.org/mailman/listinfo/python-list
Re: Chaining programs with pipe
On 2007-08-28, Gabriel Genellina [EMAIL PROTECTED] wrote: On Windows, windowed applications (as opposed to console applications) start with no stdin/stdout/stderr by default. The application developer can modify that if desired, of course - I've menctioned some ways to do that. This fact simply means that those OS's *are* different - most of the time one can ignore the differences, but not always. Neither of them is doing the absolute Right Thing. We're never going have any good flames with that sort of attitude. ;) -- Grant Edwards grante Yow! I know how to do at SPECIAL EFFECTS!! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: expat error, help to debug?
Aloha, Andreas Lobinger wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Andreas Lobinger wrote: Anyone any idea where the error is produced? ... to share my findings with you: def ex(self,context,baseid,n1,n2): print x,context,n1,n2 return 1 The registered Handler has to return a (integer) value. Would have been nice if this had been mentioned in the documentation. Wishing a happy day, LOBI -- http://mail.python.org/mailman/listinfo/python-list
Re: expat error, help to debug?
Aloha, Andreas Lobinger wrote: Andreas Lobinger wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Andreas Lobinger wrote: Anyone any idea where the error is produced? The registered Handler has to return a (integer) value. Would have been nice if this had been mentioned in the documentation. Delete last line, it is mentioned in the documentation. -- http://mail.python.org/mailman/listinfo/python-list
Embedding the python interpreter
Hey, Do you know an easy way to embed the python interpreter in a python program (so a non-technical user, which has no idea how to install the python interpreter would be able to run the script as an executable) ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding the python interpreter
Hi, Do you mean something like py2exe? http://www.py2exe.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
On Aug 27, 4:42 pm, Ivan Voras [EMAIL PROTECTED] wrote: Hi, I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of probability looks like at this point - can be linear). I see that there are several functions in Python standard libraries for various distribution, but is there an easy pythonic way to make them do what I need? Not sure how pythonic it is...but a simple(?) way to increase the chances for particular elements is to introduce copies. For example given [1,2,3], you can increase the chances of selecting '1' by changing the list to [1,1,2,3]. Cheers Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding the python interpreter
On Aug 28, 8:45 pm, Tom Gur [EMAIL PROTECTED] wrote: Hey, Do you know an easy way to embed the python interpreter in a python program (so a non-technical user, which has no idea how to install the python interpreter would be able to run the script as an executable) ? py2exe does this very well for windows executables: http://www.py2exe.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding the python interpreter
On 2007-08-28, Tom Gur [EMAIL PROTECTED] wrote: Hey, Do you know an easy way to embed the python interpreter in a python program (so a non-technical user, which has no idea how to install the python interpreter would be able to run the script as an executable) ? Hey, This question is asked at least once a week. I'm surprised you didn't see the threads. [It probably should be int he FAQ, but isn't.] http://www.py2exe.org/ http://sourceforge.net/projects/cx-freeze/ http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi http://cheeseshop.python.org/pypi/py2app/ -- Grant Edwards grante Yow! Could I have a drug at overdose? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Table update
I am trying to use python script to update a table by incremental value based on struc_No but having problem to get right result on the value field for the 3rd and 4th same number of struc_no. I need to update the Value field only with the incremental value of 15 or so Any help is highly appreciated. Thanks Shak Input table or source table ID struc_idStruc_NoValue 1 ABC 100110 2 EFJ 100515 3 HIK 100310 4 ILK 100510 5 PIO 10018 6 TIN 100112 7 MNO 100111 8 POW 100318 Output Table ID struc_idStruc_NoValue Added value 1 ABC 100125 15 2 EFJ 100530 15 3 HIK 100325 15 4 ILK 100540 30 5 PIO 100138 30 6 TIN 100157 45 7 MNO 100171 60 8 POW 100348 30 -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ Binding with Threads
I've found a workaround for me project that I'll share. The solution is to release the interpreter lock when a function of my wapper is called, I mean from Python a function of C++ is called so I released the interpreter lock and take it before returning to Python. It's important to provide Sleep functions in your C++ code. Otherwise, multi-threading will not work at all. If most of the work is done in your C++ code, using this workaround will solve the issue. To make it easier I've wrote a class to create an instance at the beginning of each wrapped function. Here is the constructor / destructor: PythonAutoLock::PythonAutoLock() { PythonMgr *mgr = PythonMgr::instance(); _state = PyThreadState_Get(); PyThreadState_Swap(NULL); PyEval_ReleaseLock(); } PythonAutoLock::~PythonAutoLock() { PythonMgr *mgr = PythonMgr::instance(); PyEval_AcquireLock(); PyThreadState_Swap(_state); } Pablo Yabo -- http://www.nektra.com On 8/13/07, Pablo Yabo [EMAIL PROTECTED] wrote: Hello, I want to embed Python in an application and use an API of the application from Python. The application uses a library that creates several threads and I the users of the application will write Python scripts handling this events. The problem is that I having problems with threads. I saw that I have to PyEval_InitThreads and then PyThreadState_New and PyThreadState_Swap from the new thread but this way to solve the problem doesn't work for me because I need to let 2 or more threads run at the SAME time. The interpreter lock doesn't let them run at the same time so I'm looking for another solution. I saw Py_NewInterpreter and I tried to use it but it doesn't work if I don't keep the lock. Can anyone help me to solve this issue or tell me 'Forget it!'? Thanks on advance, Pablo Yabo -- http://www.nektra.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Table update
On Aug 28, 2:57 pm, Ahmed, Shakir [EMAIL PROTECTED] wrote: I am trying to use python script to update a table by incremental value based on struc_No but having problem to get right result on the value field for the 3rd and 4th same number of struc_no. I need to update the Value field only with the incremental value of 15 or so Any help is highly appreciated. Thanks Shak Input table or source table ID struc_idStruc_NoValue 1 ABC 100110 2 EFJ 100515 3 HIK 100310 4 ILK 100510 5 PIO 10018 6 TIN 100112 7 MNO 100111 8 POW 100318 Output Table ID struc_idStruc_NoValue Added value 1 ABC 100125 15 2 EFJ 100530 15 3 HIK 100325 15 4 ILK 100540 30 5 PIO 100138 30 6 TIN 100157 45 7 MNO 100171 60 8 POW 100348 30 Well you certainly won't learn anything if you don't at least try to solve the problem. file = open('Somefile', 'r').readlines() for line in file: ... x = line.split() ... if not x[3] == Value: ... print int(x[3]) + 15 I'm sure you can take it from here. Hope it helps. Best regards Jeffrey van Aswegen -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
On Aug 28, 4:08 am, geoffbache [EMAIL PROTECTED] wrote: On Aug 27, 11:28 pm, [EMAIL PROTECTED] wrote: On Aug 27, 3:21 pm, geoffbache [EMAIL PROTECTED] wrote: Hi, As part of my efforts to write a test tool that copes with GUIs nicely, I'm trying to establish how I can start a GUI process on Windows that will not bring up the window. So I try to hide the window as follows: info = subprocess.STARTUPINFO() info.dwFlags |= subprocess.STARTF_USESHOWWINDOW info.wShowWindow = subprocess.SW_HIDE proc = subprocess.Popen(..., startupinfo=info) This works, in a way, but doesn't work recursively. I.e. if the started process itself starts a window, that second window will not be hidden. This even applies to dialog boxes within the application. So instead of a lot of windows popping up I now get a lot of disembodied dialogs appearing, which is a slight improvement but not much. Also, certain processes (e.g. tkdiff) seem to ignore the directive to be hidden altogether. This is dead easy on UNIX with virtual displays like Xvfb. Can someone shed any light if it's possible on Windows from python? Regards, Geoff Bache I'm confused. Why would you create a GUI if you're not going to actually display it? Isn't that the point of a GUI? Or are you talking about the command window popping up? Mike Only in the context of testing it. If I run lots of GUI tests on my computer I want the tested GUIs to remain hidden so I can still use my computer in the meantime... Though if you can tell me how to stop the command window popping up on Windows I'll be grateful for that too (though it wasn't the original question). Geoff Which GUI toolkit are you using? Tkinter, wxPython, pyQt? As for losing the command window on Windows, the best way that I know of is to just change the extension of the python file itself from *.py to *.pyw . I'm pretty sure you can suppress command windows if you're calling them from the command line using a flag, but I can't recall the flag off the top of my head. One way to test while still being able to use your computer is to install a virtual machine with VMWare or some similar product. I use VMWare's free software for testing some of my scripts, but I've heard that Microsoft's got a free virtual product that isn't half bad. Mike -- http://mail.python.org/mailman/listinfo/python-list
HP-UX IA: Python 2.4 (64bits gcc)
Hello, Please, Could you kindly tell me how to build Python 2.4 in HP-UX 11i v2 (Itanium) in 64 bits using gcc/g++? Thanks in advance for your attention. With best regards, Julio Garvía Honrado Sé un Mejor Amante del Cine ¿Quieres saber cómo? ¡Deja que otras personas te ayuden! http://advision.webevents.yahoo.com/reto/entretenimiento.html-- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
On Aug 28, 8:59 am, geoffbache [EMAIL PROTECTED] wrote: Which GUI toolkit are you using? Tkinter, wxPython, pyQt? Primarily PyGTK, but I was hoping it wouldn't matter. I hope to be able to start the process as indicated in the original post from within my test tool and instruct the subprocess to be hidden (or minimized? would that be easier?), irrespective of what it was (it might be a Java GUI or anything for all I care...) As for losing the command window on Windows, the best way that I know of is to just change the extension of the python file itself from *.py to *.pyw . I'm pretty sure you can suppress command windows if you're calling them from the command line using a flag, but I can't recall the flag off the top of my head. Thanks, that seemed to work. One way to test while still being able to use your computer is to install a virtual machine with VMWare or some similar product. I use VMWare's free software for testing some of my scripts, but I've heard that Microsoft's got a free virtual product that isn't half bad. OK. If all else fails I might try that. But if there is a solution to the original problem it would be nice not to have to install VMWare everywhere for convenient testing... Geoff I did a quick google and found the following, which probably only applies to Windows: http://www.tech-recipes.com/windows_tips512.html I know that with wxPython, you can tell it to whether or not to show the frame. Maybe pyGTK has the same functionality? This link seems to suggest that that maybe a valid option, but it doesn't detail how to accomplish it: http://www.daa.com.au/pipermail/pygtk/2000-August/000300.html This might be better: http://linuxgazette.net/issue78/krishnakumar.html Looks to me like you could just omit the show method. However, I have never used that particular toolkit. When you run stuff hidden like that, it can be difficult to kill them. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
Which GUI toolkit are you using? Tkinter, wxPython, pyQt? Primarily PyGTK, but I was hoping it wouldn't matter. I hope to be able to start the process as indicated in the original post from within my test tool and instruct the subprocess to be hidden (or minimized? would that be easier?), irrespective of what it was (it might be a Java GUI or anything for all I care...) As for losing the command window on Windows, the best way that I know of is to just change the extension of the python file itself from *.py to *.pyw . I'm pretty sure you can suppress command windows if you're calling them from the command line using a flag, but I can't recall the flag off the top of my head. Thanks, that seemed to work. One way to test while still being able to use your computer is to install a virtual machine with VMWare or some similar product. I use VMWare's free software for testing some of my scripts, but I've heard that Microsoft's got a free virtual product that isn't half bad. OK. If all else fails I might try that. But if there is a solution to the original problem it would be nice not to have to install VMWare everywhere for convenient testing... Geoff -- http://mail.python.org/mailman/listinfo/python-list
int/long bug in locale?
To pretty up some numbers stored as strings, I used locale to format them with commas. I then found the following error: import locale locale.setlocale(locale.LC_ALL, 'English_United States.1252') 'English_United States.1252' locale.format('%d', float('2244012500.'), grouping = True) Traceback (most recent call last): File pyshell#28, line 1, in module locale.format('%d', float('2244012500.'), grouping = True) File C:\Python25\lib\locale.py, line 145, in format formatted = percent % value TypeError: int argument required However, if the number is = 2**31-1, it works just fine: locale.format('%d', float('224401250.'), grouping = True) '224,401,250' Interestingly, if I first convert the floats to ints, , the function works just fine, even if the numbers exceed 2**31-1: locale.format('%d', int(float('2244012500.')), grouping = True) '2,244,012,500' Is there an int/long related bug lurking in locale? Sincerely Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list
wxpython:how to minimize to taskbar
I'm kinda newbie to python and wxPython. Now I'm confronting a thorny problem: how can I make my program minimize to the taskbar represented as an ico, and when there is some message from network coming, it will pop out? -- http://mail.python.org/mailman/listinfo/python-list
Check for dict key existence, and modify it in one step.
Im using this construct a lot: if dict.has_key(whatever): dict[whatever] += delta else: dict[whatever] = 1 sometimes even nested: if dict.has_key(whatever): if dict[whatever].has_key(someother): dict[whatever][someother] += delta else: dict[whatever][someother] = 1 else: dict[whatever]={} dict[whatever][someother] = 1 there must be a more compact, readable and less redundant way to do this, no? Thanks, Rodrigo -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython:how to minimize to taskbar
On Aug 28, 9:10 am, Jimmy [EMAIL PROTECTED] wrote: I'm kinda newbie to python and wxPython. Now I'm confronting a thorny problem: how can I make my program minimize to the taskbar represented as an ico, and when there is some message from network coming, it will pop out? Look at the wxPython demo source code. I found the code I needed in the main.py file under the DemoTaskBarIcon class, which is a subclass of wx.TaskBarIcon. You can't view it by running the demo. You have to open the main.py file itself. On my Windows box, it's found here: C:\Program Files\wxPython2.8 Docs and Demos\demo You'll have to call a handler when you receive a message from the network that basically calls your program's show command. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython:how to minimize to taskbar
On Aug 28, 9:10 am, Jimmy [EMAIL PROTECTED] wrote: I'm kinda newbie to python and wxPython. Now I'm confronting a thorny problem: how can I make my program minimize to the taskbar represented as an ico, and when there is some message from network coming, it will pop out? Warning. I have not tested this. I happened to have some old code that would iconify to the system tray. Here's what I think you need to do. (If it does not work, just yell and I'll try to hack something together for you.) Inside the ctor of your mainframe, you'll need to construct a wxTaskBarIcon (I derive from it). This is my code that derives from wxTaskBarIcon. The comments should give you a good idea of how this thing works. I *think* this will shove the icon in the system tray, even if you're not `iconified` -- so only create it if you want to show up in the system tray. ## My wxTaskBarIcon derived object... Taskbar icon. Not much functionality here, not even a menu. In the future, this will be a good place to allow dclient functionality from the systray. from wx import TaskBarIcon, EVT_TASKBAR_LEFT_DCLICK class ddTaskBarIcon(TaskBarIcon): def __init__(self, icon, tooltip, frame): TaskBarIcon.__init__(self) self.SetIcon(icon, tooltip) self.frame = frame # # At the very least, restore the frame if double clicked. Add other # events later. # self.Bind(EVT_TASKBAR_LEFT_DCLICK, self.on_left_dclick) def on_left_dclick(self, e): if self.frame.IsIconized(): self.frame.Iconize(False) if not self.frame.IsShown(): self.frame.Show(True) self.frame.Raise() def CreatePopupMenu(self): Override with menu functionality, later. return None Next is where I use it in my wxFrame derived object. This is the code in my ctor. # ddTaskBarIcon is defined above... self.trayicon = ddTaskBarIcon(self.frame_icon, Dap Daemon, self) # Handle the window being `iconized` (err minimized) self.Bind(wx.EVT_ICONIZE, self.on_iconify) # This is the event handler referenced in the ctor above def on_iconify(self, e): Being minimized, hide self, which removes the program from the taskbar. self.Hide() So how does this work? Well, the ddTaskBarIcon (err, i realize this is a misnomer) is constructed, which puts an icon in the system tray. The icon has a dbl-click event handler that will `raise` and show the window if necessary. The iconify event handler will hide the window if a minimize event occurs. This keeps the window from showing up in the windows taskbar. Thats the magic. YMMV. FWIW - the code I reference is over 5 years old and still runs with wxPython 2.8ish... Kudos to Robin Dunn and crew. Great job. jw -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Classes
On Aug 28, 2007, at 12:04 AM, Lamonte Harris wrote: How come you have to set the initialized created variables to equal the parameters, shouldn't that be default? class testing: def __init__(self,testing): self.testing = testing x = testing(testing) print x.testing How come self.testing = testing Can someone explain that in more detail, just confused on why you have to set it up like that. -- Simple Answer: Because language should never set variable values by default. That's what programmers are for. There may be application domains where *some* defaulting behavior makes sense, but that's what frameworks and DSLs are for. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython:how to minimize to taskbar
On Aug 28, 9:50 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Aug 28, 9:10 am, Jimmy [EMAIL PROTECTED] wrote: I'm kinda newbie to python and wxPython. Now I'm confronting a thorny problem: how can I make my program minimize to the taskbar represented as an ico, and when there is some message from network coming, it will pop out? Warning. I have not tested this. I happened to have some old code that would iconify to the system tray. Here's what I think you need to do. (If it does not work, just yell and I'll try to hack something together for you.) Inside the ctor of your mainframe, you'll need to construct a wxTaskBarIcon (I derive from it). This is my code that derives from wxTaskBarIcon. The comments should give you a good idea of how this thing works. I *think* this will shove the icon in the system tray, even if you're not `iconified` -- so only create it if you want to show up in the system tray. ## My wxTaskBarIcon derived object... Taskbar icon. Not much functionality here, not even a menu. In the future, this will be a good place to allow dclient functionality from the systray. from wx import TaskBarIcon, EVT_TASKBAR_LEFT_DCLICK class ddTaskBarIcon(TaskBarIcon): def __init__(self, icon, tooltip, frame): TaskBarIcon.__init__(self) self.SetIcon(icon, tooltip) self.frame = frame # # At the very least, restore the frame if double clicked. Add other # events later. # self.Bind(EVT_TASKBAR_LEFT_DCLICK, self.on_left_dclick) def on_left_dclick(self, e): if self.frame.IsIconized(): self.frame.Iconize(False) if not self.frame.IsShown(): self.frame.Show(True) self.frame.Raise() def CreatePopupMenu(self): Override with menu functionality, later. return None Next is where I use it in my wxFrame derived object. This is the code in my ctor. # ddTaskBarIcon is defined above... self.trayicon = ddTaskBarIcon(self.frame_icon, Dap Daemon, self) # Handle the window being `iconized` (err minimized) self.Bind(wx.EVT_ICONIZE, self.on_iconify) # This is the event handler referenced in the ctor above def on_iconify(self, e): Being minimized, hide self, which removes the program from the taskbar. self.Hide() So how does this work? Well, the ddTaskBarIcon (err, i realize this is a misnomer) is constructed, which puts an icon in the system tray. The icon has a dbl-click event handler that will `raise` and show the window if necessary. The iconify event handler will hide the window if a minimize event occurs. This keeps the window from showing up in the windows taskbar. Thats the magic. YMMV. FWIW - the code I reference is over 5 years old and still runs with wxPython 2.8ish... Kudos to Robin Dunn and crew. Great job. jw I've been dinking around with getting one of my programs to minimize to the system tray for quite a while. I could get the icon, but I could not get an event to fire when I minimized. Thanks for the code. Now it works. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Classes
Ok thanks I'll try remembering it. On 8/28/07, Erik Jones [EMAIL PROTECTED] wrote: On Aug 28, 2007, at 12:04 AM, Lamonte Harris wrote: How come you have to set the initialized created variables to equal the parameters, shouldn't that be default? class testing: def __init__(self,testing): self.testing = testing x = testing(testing) print x.testing How come self.testing = testing Can someone explain that in more detail, just confused on why you have to set it up like that. -- Simple Answer: Because language should never set variable values by default. That's what programmers are for. There may be application domains where *some* defaulting behavior makes sense, but that's what frameworks and DSLs are for. Erik Jones Software Developer | Emma(r) [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Asking all python programmers.
On 8/27/07, Lamonte Harris [EMAIL PROTECTED] wrote: Okay, I know you've guys told me millions of times to read the manual I've read a lot of it. What do you recommend studying the most? Python is my goal for the next year in the half. :) -- http://mail.python.org/mailman/listinfo/python-list Some notes on your question: You've guys is nonsensical. Your first sentence is a run-on sentence. Your e-mail address identifies you as an immature script-kiddie. Year in the half is nonsensical. Okay, so why am I picking on you? Because I want to help. Present yourself in this way, and you're not going to get as much help from intelligent people as you would if they saw you were worth their time. You are either going to get angry at me or you're going to think about this. If you're angry then I can't help you. If you actually care how people see you, you will get further in life in general. To answer the question I think you were trying to ask, a combination of The Python Cookbook and Dive Into Python should get you started in doing amazing things with Python. The latter is available for free online. Take some pride in the way you write. It will pay off. Shawn -- http://mail.python.org/mailman/listinfo/python-list
Re: Check for dict key existence, and modify it in one step.
rodrigo a écrit : Im using this construct a lot: if dict.has_key(whatever): ot Avoid using builtin names as identifiers (it shadows the builtin name). /ot Unless you're using an old Python version, you'd be better using if whatever in my_dict: # do something here dict[whatever] += delta else: dict[whatever] = 1 sometimes even nested: if dict.has_key(whatever): if dict[whatever].has_key(someother): dict[whatever][someother] += delta else: dict[whatever][someother] = 1 else: dict[whatever]={} dict[whatever][someother] = 1 there must be a more compact, readable and less redundant way to do this, no? There are other ways, yes. With Python = 2.4.x, you can use dict.setdefault, with Python 2.5.x you can use a defaultdict (cf http://docs.python.org/whatsnew/modules.html). HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Check for dict key existence, and modify it in one step.
On Aug 28, 8:36 am, rodrigo [EMAIL PROTECTED] wrote: Im using this construct a lot: if dict.has_key(whatever): dict[whatever] += delta else: dict[whatever] = 1 sometimes even nested: if dict.has_key(whatever): if dict[whatever].has_key(someother): dict[whatever][someother] += delta else: dict[whatever][someother] = 1 else: dict[whatever]={} dict[whatever][someother] = 1 there must be a more compact, readable and less redundant way to do this, no? Thanks, Rodrigo As Bruno said, don't shadow the built-in objects. When things inevitably go south because the dict class has been replaced by your dictionary, it will be difficult for you to find out what went wrong. Under Python 2.5, you have the defaultdict class in the collections module [1]. (This class is trivial to implement in prior versions of Python, too.) from collections import defaultdict myDict = defaultdict(lambda: 1) myDict['spam'] = 5 myDict['spam'] += 10 myDict['vikings'] += 20 myDict defaultdict(function lambda at 0x00AAC970, {'vikings': 21, 'spam': 15}) --Jason [1] The module documentation is at http://docs.python.org/lib/module- collections.html -- http://mail.python.org/mailman/listinfo/python-list
in design time activeX properties
Hello, Does anybody know how to modify the property of a design-time activeX property ? using win32com thank you for your help, regards, Victor -- http://mail.python.org/mailman/listinfo/python-list
Re: int/long bug in locale?
On 2007-08-28, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: import locale locale.setlocale(locale.LC_ALL, 'English_United States.1252') 'English_United States.1252' locale.format('%d', float('2244012500.'), grouping = True) Traceback (most recent call last): File pyshell#28, line 1, in module locale.format('%d', float('2244012500.'), grouping = True) File C:\Python25\lib\locale.py, line 145, in format formatted = percent % value TypeError: int argument required However, if the number is = 2**31-1, it works just fine: locale.format('%d', float('224401250.'), grouping = True) '224,401,250' Interestingly, if I first convert the floats to ints, , the function works just fine, even if the numbers exceed 2**31-1: locale.format('%d', int(float('2244012500.')), grouping = True) '2,244,012,500' Is there an int/long related bug lurking in locale? If it is a bug, it is not in the locale code. '%d' % float('22440125.') Traceback (most recent call last): File stdin, line 1, in module TypeError: int argument required The documentation for the string formating operation doesn't specify what happens when you convert a non-int with specifier '%d'. In defense of your code, there's also no explicit requirement to do that. http://docs.python.org/lib/typesseq-strings.html -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Asking all python programmers.
I completely understand, I've sent this email when I was tired sorry for the misunderstanding, yes I completely understand what you mean how professionals won't take me serious in situations like this. How about I readdress my question for you? Hello everyone on python mailing list. I would like your input on what information about python programming language that I should study the most. Some tutorials are good, but the manual is main resource even if it isn't well documented J. On a friendly note I would like to hear what you guys would have to recommend if that is ok. From a python starter, I don't like the word noob because it sounds very unprofessional. -Lamonte On 8/28/07, Shawn Milochik [EMAIL PROTECTED] wrote: On 8/27/07, Lamonte Harris [EMAIL PROTECTED] wrote: Okay, I know you've guys told me millions of times to read the manual I've read a lot of it. What do you recommend studying the most? Python is my goal for the next year in the half. :) -- http://mail.python.org/mailman/listinfo/python-list Some notes on your question: You've guys is nonsensical. Your first sentence is a run-on sentence. Your e-mail address identifies you as an immature script-kiddie. Year in the half is nonsensical. Okay, so why am I picking on you? Because I want to help. Present yourself in this way, and you're not going to get as much help from intelligent people as you would if they saw you were worth their time. You are either going to get angry at me or you're going to think about this. If you're angry then I can't help you. If you actually care how people see you, you will get further in life in general. To answer the question I think you were trying to ask, a combination of The Python Cookbook and Dive Into Python should get you started in doing amazing things with Python. The latter is available for free online. Take some pride in the way you write. It will pay off. Shawn -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Check for dict key existence, and modify it in one step.
On Tue, 2007-08-28 at 14:36 +, rodrigo wrote: Im using this construct a lot: if dict.has_key(whatever): dict[whatever] += delta else: dict[whatever] = 1 In Python 2.5 there's a defaultdict class, otherwise you can subclass dict like this: class CountingDictionary(dict): def increment(self, key, delta=1): self[key] = self.get(key, 0) + delta Hope this helps! -- Evan Klitzke [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Asking all python programmers.
On 8/28/07, Lamonte Harris [EMAIL PROTECTED] wrote: From a python starter, I don't like the word noob because it sounds very unprofessional. Touche`...haha I second the motion for Dive Into Python. It's an excellent book, and you really can't beat the price (free online as Shawn has pointed out). I've also discovered that learning python is easier when you have a defined goal (learn xyz language has never cut it for me...I have to have a much more specific goal in mind to accomplish anything). For instance, during my senior project in college, my team lead was worried we wouldn't get enough data gathered in time to present our work. I took that opportunity to write a few Python scripts that would hunt the internet for the data we were looking for and insert it into our database (after scrubbing/etc...). Having that specific task (rather, having the specific problem to solve) accelerated my learning because I was focused on a *real* issue, not a vague learn xyz. Tutorials and challenges, while useful, can't take the place of learning a language to solve a problem *you* want to solve. Look for a task that would make your life easier, then see how you can apply Python to it... -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
geoffbache wrote: Hi, As part of my efforts to write a test tool that copes with GUIs nicely, I'm trying to establish how I can start a GUI process on Windows that will not bring up the window. So I try to hide the window as follows: info = subprocess.STARTUPINFO() info.dwFlags |= subprocess.STARTF_USESHOWWINDOW info.wShowWindow = subprocess.SW_HIDE proc = subprocess.Popen(..., startupinfo=info) This works, in a way, but doesn't work recursively. I.e. if the started process itself starts a window, that second window will not be hidden. This even applies to dialog boxes within the application. So instead of a lot of windows popping up I now get a lot of disembodied dialogs appearing, which is a slight improvement but not much. Also, certain processes (e.g. tkdiff) seem to ignore the directive to be hidden altogether. This is dead easy on UNIX with virtual displays like Xvfb. Can someone shed any light if it's possible on Windows from python? Regards, Geoff Bache While I'm not entirely sure I understand what you want, I think you can accomplish it by using win32CreateProcess instead of subprocess. You can run the application minimized or perhaps in a REALLY small window. If you have modal dialog boxes, I don't think you can do anything as they don't run in the parent windows frame but rather outside (I could be wrong about this). -Larry -- http://mail.python.org/mailman/listinfo/python-list
localhost, ?!
Three machines, one at my home, other two at my job, in every machine there is Win XP SP2 and Python 2.5 At home: urllib2.urlopen(http://localhost;), everything is ok At job: urllib2.urlopen(http://localhost;) raise BadStatusLine(line), after half a minute. urllib2.urlopen(http://127.0.0.1;) HTTP Error 503: Service Unavailable, immediately. Anybody have slightest clue wthat is going on? :-/ If I use urllib, then localhost works on every machine, and urllib2 works on every machine when retreiving URLs outside localhost. -- http://mail.python.org/mailman/listinfo/python-list
sys.setdefaultencoding
Can someone explain the rationale of making the default encoding a sitewide setting? I could live with the the default being set on a per process basis, but it baffles me why even that possibility is taken away as site.py removes sys.setdefaultencoding. Is there a way to allow the process to specify that unicode--str should use 'utf8' rather than 'ascii' in all non-specific cases? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Jython 2.2 on Ubuntu
Hi all, I am a novice Python/Jython programmer, and Ubuntu user. Ubuntu still only supports only version 2.1 of Jython. I have used the GUI installer of Jython 2.2, and installed it to the default /root/jython2.2 directory. The install went without issues. However, typing jython --version in a teminal still gives me Jython 2.1 on java (JIT: null) What else do I need to do? regards Neil. p.s. I posted this to the jython group hosted by sourceforge, but it bounced. :-( -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.setdefaultencoding
Is there a way to allow the process to specify that unicode--str should use 'utf8' rather than 'ascii' in all non-specific cases? No. Things might break if you change the default encoding to anything but ASCII, and more so if you do that at runtime. For example, dictionaries with Unicode keys may stop working, and the cached byte-oriented version of a Unicode string may become incorrect. In general, programs and libraries should not rely on the default encoding for anything. Instead, they should convert explicitly, either from an explicitly specified encoding, or one derived from the context. Experience has shown that this is possible in nearly every case (and in all cases if an appropriate refactoring is made). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
help needed on PyLink
Hi, Everyone, Is there anybody who know how to programming for eye-tracker with PyLink? I just started learning it and need some help. Your help will be appreciated from the bottom of my heart. My email is : [EMAIL PROTECTED], and my MSN is [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: int/long bug in locale?
On Aug 28, 10:03 am, [EMAIL PROTECTED] wrote: Is there an int/long related bug lurking in locale? Looks like this has already been reported: See http://bugs.python.org/issue1742669 Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: National grid to lat long conversion
I have a load of British National Grid references that I want to convert to decimal degrees so I can create a google KML file. Does anyone know of a module to do this? I should probably have added that you can get a number of the variables you start off with from : http://www.ordnancesurvey.co.uk/oswebsite/gps/information/ coordinatesystemsinfo/guidecontents/guidea.html and http://www.ordnancesurvey.co.uk/oswebsite/gps/information/ coordinatesystemsinfo/guidecontents/index.html might be useful to read around the subject. It might look complex, but don't let it put you off. Also, you can get JavaScript code to do just this from the URL below, which would be a good starting point. http://www.movable-type.co.uk/scripts/latlong-gridref.html Regards, Carl. -- http://mail.python.org/mailman/listinfo/python-list
Re: National grid to lat long conversion
I have a load of British National Grid references that I want to convert to decimal degrees so I can create a google KML file. Does anyone know of a module to do this? If there isn't a module available, you could roll your own. The equations are to be found at : http://www.ordnancesurvey.co.uk/oswebsite/gps/docs/ convertingcoordinatesEN.pdf They shouldn't be too hard to Pythonise. Regards, Carl. -- http://mail.python.org/mailman/listinfo/python-list
Compiling Source with alternate Openssl lib
Hi All - I'm trying to compile Python on a Centos machine (RHEL) 3.8 for a hosting account that I just set up and I'm having 2 issues: 1. I ran into an issue with the hashlib module [I think] because it bumps it up against an *OLD* openssl lib (like, Feb. 2003). So I installed a newer openssl lib, but when I recompiled python it still used the old library. So I tried ./configure again with the flag: - with-openssl-libs=/new/directory but it still didn't work. Any idea how I might be able to remedy this? I have a working solution right now: I've commented out the last 2 lines of hashlib.py, but I'd rather not do that if I didn't have to. 2. As part of this process, I installed easy_install and I was trying to download psycopg2 but I got the error: PyDateTimeAPI defined but not used when trying to compile. I've had this problem before when trying to compile psycopg2 and it was because I didn't have the postgres header libs installed (libpq-dev) ... but that's on a debian box, and I can't figure out how to fix it on the RHEL one. I know the 2nd question might not belong in this group, but I thought I'd ask just in case someone ran into this before or might have any suggestions. Thanks in advance (as always!) for your help! Kevin -- http://mail.python.org/mailman/listinfo/python-list
Re: Check for dict key existence, and modify it in one step.
evan, yes, it does help. Works like it should: class CountingDictionary(dict): def increment(self, key, delta=1): self[key] = self.get(key, 0) + delta d = CountingDictionary() d.increment('cat') d.increment('dog',72) print d {'dog': 72, 'cat': 1} Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
OK, more background needed. I develop the TextTest tool which is a generic test tool that starts tested applications from the command line. The idea is that it can handle any system under test at all, whatever language it's written in. Preferably without requiring a bunch of changes to the tested code before starting. I'd like to be able to pass some sort of flag to ensure that the system under test *and everything it starts* remain hidden. I can do as you suggest in my PyGTK GUI, of course, but that's only one system under test. A generic solution, if there is one, would be much better. I felt like there ought to be one because : a) It's easy on UNIX and b) I managed to hide the system under test fairly easily, just not its child windows and dialogs. Thanks for the help, anyway, it's another fallback if I can't find a solution. -- http://mail.python.org/mailman/listinfo/python-list
tempfile.mkstemp and os.fdopen
Hi there. I'm trying to generate a brand new file with a unique name by using tempfile.mkstemp(). In conjunction I used os.fdopen() to get a wrapper around file properties (write read methods, and so on...) but 'name' attribute does not contain the correct file name. Why? import os import tempfile fileno, name = tempfile.mkstemp(prefix='ftpd.', dir=os.getcwd()) fd = os.fdopen(fileno, 'wb') fd.name fdopen Moreover, I'd like to know if I'm doing fine. Does this approach avoid race conditions or other types of security problems? Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: Jython 2.2 on Ubuntu
you need to ensure that the correct jython executable is in a directory which is on your on your path. I've just successfully test-subscribed to https://lists.sourceforge.net/lists/listinfo/jython-users. Maybe you could try again. Tim Dr Tim Couper CTO, SciVisum Ltd www.scivisum.com Neil Wallace wrote: Hi all, I am a novice Python/Jython programmer, and Ubuntu user. Ubuntu still only supports only version 2.1 of Jython. I have used the GUI installer of Jython 2.2, and installed it to the default /root/jython2.2 directory. The install went without issues. However, typing jython --version in a teminal still gives me Jython 2.1 on java (JIT: null) What else do I need to do? regards Neil. p.s. I posted this to the jython group hosted by sourceforge, but it bounced. :-( -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting subprocesses to be hidden on Windows
On 28 Aug, 18:18, Larry Bates [EMAIL PROTECTED] wrote: geoffbache wrote: Hi, As part of my efforts to write a test tool that copes with GUIs nicely, I'm trying to establish how I can start a GUI process on Windows that will not bring up the window. So I try to hide the window as follows: info = subprocess.STARTUPINFO() info.dwFlags |= subprocess.STARTF_USESHOWWINDOW info.wShowWindow = subprocess.SW_HIDE proc = subprocess.Popen(..., startupinfo=info) This works, in a way, but doesn't work recursively. I.e. if the started process itself starts a window, that second window will not be hidden. This even applies to dialog boxes within the application. So instead of a lot of windows popping up I now get a lot of disembodied dialogs appearing, which is a slight improvement but not much. Also, certain processes (e.g. tkdiff) seem to ignore the directive to be hidden altogether. This is dead easy on UNIX with virtual displays like Xvfb. Can someone shed any light if it's possible on Windows from python? Regards, Geoff Bache While I'm not entirely sure I understand what you want, I think you can accomplish it by using win32CreateProcess instead of subprocess. You can run the application minimized or perhaps in a REALLY small window. If you have modal dialog boxes, I don't think you can do anything as they don't run in the parent windows frame but rather outside (I could be wrong about this). -Larry Hi Larry, I don't know if that would help. I've tried running minimized from the command line as suggested by Mike and that has the same issue (child windows and dialogs don't get minimized) So the question is moving away from how to technically achieve this in Python to whether Windows even supports it... Geoff -- http://mail.python.org/mailman/listinfo/python-list
Re: Check for dict key existence, and modify it in one step.
You're right of course, I was unclear. I wasn't using 'dict' to override the dict clas, but just as a standin for the example (the actual dictionary names are varied). Thanks, Rodriog -- http://mail.python.org/mailman/listinfo/python-list
RE: Filemaker interactions
filemaker 8.0 (Pro I think) has a web page generator. That's all I know, since I didn't really need it. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of M.-A. Lemburg Sent: Saturday, August 25, 2007 4:36 PM To: Ian Witham Cc: python-list@python.org Subject: Re: Filemaker interactions On 2007-08-01 23:41, Ian Witham wrote: Hello, I'm hoping someone here can put me on the right track with some broad concepts here. What I am hoping to achieve is a simple HTML page to be served over our company LAN, into which the users (Real Estate Agents) can enter a property address or reference number. My next thought was to have a Python CGI script query our filemaker database of property listings, construct a PDF from the relevant information, and finally return this PDF to the user. At no stage do I want the user to have unfettered access to the database or the ability to alter/delete records. My question is: what is the most appropriate way for my script to interact with Filemaker? Can this be done with Filemaker Pro 6? According to the Filemaker Help, the Local Data Access Companion shares the FileMaker Pro database with ODBC-compliant applications on the same computer. Is this the right option? Can my CGI script be an ODBC client? How? Would it need to be Filemaker specific code or does ODBC have a standardised format? I'm grateful for any advice and a nudge in the right direction. You could try our mxODBC extension for Python which will likely just work out of the box: https://www.egenix.com/products/python/mxODBC/ with the Filemaker ODBC driver. Or give this module a try (if you have more time at hand and can do without a DB-API interface): http://www.lfd.uci.edu/~gohlke/code/filemaker.py.html It uses Filemaker's XML interface. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Aug 25 2007) Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ __ __ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: localhost, ?!
Il Tue, 28 Aug 2007 18:27:31 +0200, Boris Ozegovic ha scritto: Three machines, one at my home, other two at my job, in every machine there is Win XP SP2 and Python 2.5 At home: urllib2.urlopen(http://localhost;), everything is ok At job: urllib2.urlopen(http://localhost;) raise BadStatusLine(line), after half a minute. urllib2.urlopen(http://127.0.0.1;) HTTP Error 503: Service Unavailable, immediately. Anybody have slightest clue wthat is going on? :-/ I think to have http://localhost working you need a web server (like apache). maybe you have it at your home. bye Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: localhost, ?!
Fabio Z Tessitore wrote: I think to have http://localhost working you need a web server (like apache). maybe you have it at your home. I do have Apache. You can see that urllib, older module, works correctly. -- http://mail.python.org/mailman/listinfo/python-list
extending of adding method?
Hi all. I have a question about design. The general question would be: Where is the line beteween extending a class and adding new methods to that class? And the particular case im involved is: I have a class (say USERCLASS) who implements a user interface. One of his methods is called `login'. Later on i got the order of implementing a `single login', which off course means a single user cant login if a session is already started for that user. Extending comes to my mind at first (it works good, actually). But now im thinikng if there some problem in adding a method to the USERCLASS class named single_login(), who will take care of applying the rules of single sign on. Which one you guys will pick up? USERCLASS().single_login() or SINGLELOGINUSERCLASS().login() Thanks for your oppinions! Gerardo -- http://mail.python.org/mailman/listinfo/python-list
Is it reasonably easy easy to something like this with python?
This is made with a php5 framework called qcodo. http://examples.qcodo.com/examples/dynamic/inline_editing.php With qcodo it's easy to make grids that are sortable and inline editable. Qcodo grids work from the database - not an xml table or array. Qcodo handles complex data relations, and fairly large datadabes. I like python better than php, but I don't know of any python tools to create these sorts of grids. -- http://mail.python.org/mailman/listinfo/python-list
Re: tempfile.mkstemp and os.fdopen
On Aug 28, 1:55 pm, billiejoex [EMAIL PROTECTED] wrote: In conjunction I used os.fdopen() to get a wrapper around file properties (write read methods, and so on...) but 'name' attribute does not contain the correct file name. Why? import os import tempfile fileno, name = tempfile.mkstemp(prefix='ftpd.', dir=os.getcwd()) fd = os.fdopen(fileno, 'wb') fd.name fdopen Moreover, I'd like to know if I'm doing fine. Does this approach avoid race conditions or other types of security problems? Thanks in advance There seems to be a feature request for this: http://bugs.python.org/issue1625576 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it reasonably easy easy to something like this with python?
walterbyrd wrote: This is made with a php5 framework called qcodo. http://examples.qcodo.com/examples/dynamic/inline_editing.php With qcodo it's easy to make grids that are sortable and inline editable. Qcodo grids work from the database - not an xml table or array. Qcodo handles complex data relations, and fairly large datadabes. I like python better than php, but I don't know of any python tools to create these sorts of grids. The one who make that table sorteable is AJAX. Not php. The php part is kind of trivial (so it would be `trivial' in python too). It just reads some data and format it in an html table. Cheers. Gerardo -- http://mail.python.org/mailman/listinfo/python-list
Image manipulation
I need to add dynamic text to animated GIF images. What is a best way to do it? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: extending of adding method?
Gerardo Herzig wrote: Hi all. I have a question about design. The general question would be: Where is the line beteween extending a class and adding new methods to that class? What do you mean by extending? The Java extends, which is really inheritance? And the particular case im involved is: I have a class (say USERCLASS) who implements a user interface. One of his methods is called `login'. Later on i got the order of implementing a `single login', which off course means a single user cant login if a session is already started for that user. Extending comes to my mind at first (it works good, actually). But now im thinikng if there some problem in adding a method to the USERCLASS class named single_login(), who will take care of applying the rules of single sign on. Which one you guys will pick up? USERCLASS().single_login() or SINGLELOGINUSERCLASS().login() Depends. Inheritance is, IMHO, only good if it makes code reusal and/or maintainability easier. I've once read that inheritance often only is wise in is a relationships, e. g. car is a vehicle, which means class car should inherit from class vehicle. Regards, Björn -- BOFH excuse #304: routing problems on the neural net -- http://mail.python.org/mailman/listinfo/python-list
Re: localhost, ?!
Boris Ozegovic wrote: At job: urllib2.urlopen(http://localhost;) raise BadStatusLine(line), after half a minute. Looks like name resolving problems. urllib2.urlopen(http://127.0.0.1;) HTTP Error 503: Service Unavailable, immediately. Definitely a problem with the web server (503 means service unavailable). Anybody have slightest clue wthat is going on? :-/ Try using wireshark or a similar tool to see what's going on on protocol level. Regards, Björn -- BOFH excuse #103: operators on strike due to broken coffee machine -- http://mail.python.org/mailman/listinfo/python-list
Re: tempfile.mkstemp and os.fdopen
In article [EMAIL PROTECTED], billiejoex [EMAIL PROTECTED] wrote: Hi there. I'm trying to generate a brand new file with a unique name by using tempfile.mkstemp(). In conjunction I used os.fdopen() to get a wrapper around file properties (write read methods, and so on...) but 'name' attribute does not contain the correct file name. Why? import os import tempfile fileno, name = tempfile.mkstemp(prefix='ftpd.', dir=os.getcwd()) fd = os.fdopen(fileno, 'wb') fd.name fdopen Moreover, I'd like to know if I'm doing fine. Does this approach avoid race conditions or other types of security problems? Thanks in advance In brief, since os.fdopen() only has access to the file descriptor, it does not have a convenient way to obtain the file's name. However, you might also want to look at the TemporaryFile and NamedTemporaryFile classes in the tempfile module -- these expose a file-like API, including a .name attribute. Assuming tempfile.mkstemp() is implemented properly, I think what you are doing should be sufficient to avoid the obvious file-creation race condition. Cheers, -M -- Michael J. Fromberger | Lecturer, Dept. of Computer Science http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA -- http://mail.python.org/mailman/listinfo/python-list
Re: Image manipulation
In article [EMAIL PROTECTED], Slava [EMAIL PROTECTED] wrote: I need to add dynamic text to animated GIF images. What is a best way to do it? Thanks. One possibility is the GD library, which supports animated GIF. There is a Python binding: http://newcenturycomputers.net/projects/gdmodule.html I do not know, however, whether or not the Python wrapper supports the animated GIF portions of the library. You'll probably have to do some digging. Cheers, -M -- Michael J. Fromberger | Lecturer, Dept. of Computer Science http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA -- http://mail.python.org/mailman/listinfo/python-list
Re: localhost, ?!
Bjoern Schliessmann wrote: Definitely a problem with the web server (503 means service unavailable). I did try on two servers, Apache and simple python server. There was identically error on both servers. Anybody have slightest clue wthat is going on? :-/ Try using wireshark or a similar tool to see what's going on on protocol level. Ok. -- http://mail.python.org/mailman/listinfo/python-list
Tix HList missing at least one method
According to the Tix documentation online, HList has an info_bbox() method which returns the bounding box of a given item in the HList. However, when I try to call this method, I get an attribute error. Looking at Tix.py I see that info_bbox() is not implemented. Hazarding a chance (mostly by looking at the other method implementation) I see if I can define it myself. def info_bbox( self, entry ): return [ int(pos) for pos in self.tk.call( self._w, 'info', 'bbox', entry).split() ] When I use this implementation it works. Why's info_bbox() been left out of HList? I can't formulate a work-around for what I'm trying to do. I need info_bbox(). Here's why: I'm currently working on a project which involves some fairly complex GUIs. It displays data in the form of an outline which the user can edit, it also generates web pages. To allow a natural feel to editing the order of the items in the outline, I decided to make use of the Tkinter drag and drop module: Tkdnd. To do this correctly, I need to do a bit of arithmetic with screen coordinates while in a drag operation (so I can change the cursor during the drag) so that I can determine if my current drag position (potential drop position) is above, below or as a child of some other item in the outline. The easiest way to do this is to get the bounding box of the nearest items. Thanks, Ron-- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
Ivan Voras wrote: Hi, I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of probability looks like at this point - can be linear). I see that there are several functions in Python standard libraries for various distribution, but is there an easy pythonic way to make them do what I need? If you take the difference between two uniformly distributed random variables, the probability density function forms an isosceles triangle centered at 0. Take the absolute value of that variable and the pdf is a straight line with maximum value at 0 tapering to 0 at max. Thus, z = abs(randint(0, max) - randint(0, max)) ought to do the trick. -- Jeffrey Barish -- http://mail.python.org/mailman/listinfo/python-list
Re: tempfile.mkstemp and os.fdopen
billiejoex [EMAIL PROTECTED] wrote: I'm trying to generate a brand new file with a unique name by using tempfile.mkstemp(). Moreover, I'd like to know if I'm doing fine. Does this approach avoid race conditions This is a reasonably secure way of doing things. It can't race under unix at least (dunno about windows) unless your dir is on NFS. If you want more security then make sure dir isn't publically writeable. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Okay learning python is somewhat hard.
Since I can't really focus on PROJECTS[since I don't know much python I can't do any projects because all my projects are BIG], So I decided to work on some problems I've gotten from school from started geometry, So I attempted to make a script to get the midpoint of a line segment using the formula giving: [1 and 2 are subscripts] X1 + X2 --- = mid pt. (x) 2 Y1 + Y2 --- = mid pt. (y) 2 So i tried coding the following script. #MIDPOINT OF A LINE class midpoint: def __init__(self,x1,x2,y1,y2): self.x1 = x1 self.x2 = x2 self.y1 = y1 self.y2 = y2 self.dictionary = {'x' : '','y' : ''} self.calculate_mid_point() def calculate_mid_point(self): X = self.x1 + self.x2 X = X/2 self.dictionary['x'] = X Y = self.y1 + self.y2 Y = Y/2 self.dictionary['y'] = Y c_x = -2 c_y = -2 d_x = 4 d_y = 3 midpoint_ = midpoint(c_x,d_x,c_y,d_y) print midpoint_.dictionary It works and all, but I can't get the fraction or decimal from the output :S Output: {'y': 0, 'x': 1} On my paper the real output is: x = 1 y = 1/2 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it reasonably easy easy to something like this with python?
On Aug 28, 1:31 pm, Gerardo Herzig [EMAIL PROTECTED] wrote: walterbyrd wrote: The one who make that table sorteable is AJAX. Not php. The php part is kind of trivial (so it would be `trivial' in python too). It just reads some data and format it in an html table. Thank you, that is great to know. What if there were 1000 records, and the table was paginated? I suppose, ajax would sort the front end, and backend language, and database, would soft behind the scene, or something? -- http://mail.python.org/mailman/listinfo/python-list
Haskell like (c:cs) syntax
Hi, sorry that I'm relatively new to Python. But the syntax and semantics of Python already fascinate me, because I'm familiar with functional languages like Haskell. Is there a pattern matching construct in Python like (head : tail), meaning 'head' matches the first element of a list and 'tail' matches the rest? I could not find this in the Python documentation. Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: localhost, ?!
Boris Ozegovic wrote: Bjoern Schliessmann wrote: Definitely a problem with the web server (503 means service unavailable). I did try on two servers, Apache and simple python server. There was identically error on both servers. Also try to look at the logs, you're bound find something there too. Try using wireshark or a similar tool to see what's going on on protocol level. Ok. And don't forget to report back :) Regards, Björn -- BOFH excuse #307: emissions from GSM-phones -- http://mail.python.org/mailman/listinfo/python-list
Re: Haskell like (c:cs) syntax
On 8/28/07, Stefan Niemann [EMAIL PROTECTED] wrote: Hi, sorry that I'm relatively new to Python. But the syntax and semantics of Python already fascinate me, because I'm familiar with functional languages like Haskell. Is there a pattern matching construct in Python like (head : tail), meaning 'head' matches the first element of a list and 'tail' matches the rest? I could not find this in the Python documentation. Regards, Stefan Python does not have haskell like pattern matching. Things are written and done in a different way. When working with lists, Python has a slice syntax (which is rather more powerful than Haskells limited head-tail linked list syntax) that you can use to chop a sequence up into various parts. -- http://mail.python.org/mailman/listinfo/python-list
Re: Okay learning python is somewhat hard.
Yep I'll keep hacking at it aye :D. Also I'll do some searching on the new styled classes. On 8/28/07, J. Cliff Dyer [EMAIL PROTECTED] wrote: A couple thoughts: First, your class looks like it describes the line, not just the midpoint. Your method calculates the midpoint of that line, so let the class be a line class. That way you can add other useful methods to it: Line.midpoint() Line.length() Line.slope() etc. Second, you're losing fractions because all of your code deals with integers. Integer division rounds down. So instead of dividing by 2, divide by 2.0, to force the calculation into floating point. Better yet (conceptually speaking), explicitly cast your input to floating point variables: self.x1 = float(x1), etc. Third. ALWAYS use new style classes. class Line(object): not class Line: Otherwise, it looks like you're on your way. Keep hacking at it. Cheers, Cliff Lamonte Harris wrote: Since I can't really focus on PROJECTS[since I don't know much python I can't do any projects because all my projects are BIG], So I decided to work on some problems I've gotten from school from started geometry, So I attempted to make a script to get the midpoint of a line segment using the formula giving: [1 and 2 are subscripts] X1 + X2 --- = mid pt. (x) 2 Y1 + Y2 --- = mid pt. (y) 2 So i tried coding the following script. #MIDPOINT OF A LINE class midpoint: def __init__(self,x1,x2,y1,y2): self.x1 = x1 self.x2 = x2 self.y1 = y1 self.y2 = y2 self.dictionary = {'x' : '','y' : ''} self.calculate_mid_point() def calculate_mid_point(self): X = self.x1 + self.x2 X = X/2 self.dictionary['x'] = X Y = self.y1 + self.y2 Y = Y/2 self.dictionary['y'] = Y c_x = -2 c_y = -2 d_x = 4 d_y = 3 midpoint_ = midpoint(c_x,d_x,c_y,d_y) print midpoint_.dictionary It works and all, but I can't get the fraction or decimal from the output :S Output: {'y': 0, 'x': 1} On my paper the real output is: x = 1 y = 1/2 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it reasonably easy easy to something like this with python?
walterbyrd wrote: On Aug 28, 1:31 pm, Gerardo Herzig [EMAIL PROTECTED] wrote: walterbyrd wrote: The one who make that table sorteable is AJAX. Not php. The php part is kind of trivial (so it would be `trivial' in python too). It just reads some data and format it in an html table. Thank you, that is great to know. What if there were 1000 records, and the table was paginated? I suppose, ajax would sort the front end, and backend language, and database, would soft behind the scene, or something? Im not an AJAX expert (not even close actually. In fact i just used it once), but seems like you will have to reload all the page (all the table at least). Because now is a different scenario. If the table is paginated, it looks like you will send, say 50 results at one time, then (when pressing 'next 50'), anhoter 50, and so on. So AJAX only will have THOSE 50 for ordering. Another approach would be returning de entire recordset, and implement all the 'next' and 'previous' links via AJAX. And i dont think you will like to send the entire result. I dont. What will i do (at least from WIK for now), is having a set of `hrefs' (maybe with some nice arrows) in all of the table headers, to indicate the desired order you want to get. And, if you have a column table named 'age', you will make those href like 'a href=showmethetable.py?columnorder=ageordertype=ascnice_arrow_graphic' then your cgi python script will take that mess after the ? sign, parse it (via cgi module perhaps), and make a new query, with the 'order by age asc' clause, wich are the 'arguments' in the url. There is allways a lot of ways to do some stuff. I will check into de AJAX list too! Cheers. Gerardo -- http://mail.python.org/mailman/listinfo/python-list
Re: Haskell like (c:cs) syntax
Stefan Niemann wrote: Hi, sorry that I'm relatively new to Python. But the syntax and semantics of Python already fascinate me, because I'm familiar with functional languages like Haskell. Is there a pattern matching construct in Python like (head : tail), meaning 'head' matches the first element of a list and 'tail' matches the rest? I could not find this in the Python documentation. Regards, Stefan L = ['one', 'two', 'three', 'four', 'five'] print L[0]# This would be 'head' print L[1:] # This would be 'tail' Caution : L[0] and L[1:] are COPIES of the head and tail of the list. -- http://mail.python.org/mailman/listinfo/python-list
Re: Haskell like (c:cs) syntax
Stefan Niemann [EMAIL PROTECTED] writes: Is there a pattern matching construct in Python like (head : tail), meaning 'head' matches the first element of a list and 'tail' matches the rest? I could not find this in the Python documentation. Python's lists are actually linear arrays. You can subscript them, i.e. x[0] is the first element, and slice them, i.e. x[1:] is all elements after the first. Note that x[1:] actually makes a new array and copies all the elements of x. Normally in Python one writes iterative loops rather than recursing or folding over a list: for a in x: print a so slicing isn't that common. Python also has something called generators which are sort of like Haskell's lazy-evaluation lists. They often make it possible to program in a Haskell-like style. Note however that they are mutable objects, i.e. using g.next() to get the next element of a generator actually updates the generator's internal state. This can lead to a bunch of subtle pitfalls if you're not careful, but overall they are a very useful feature. -- http://mail.python.org/mailman/listinfo/python-list
Re: Haskell like (c:cs) syntax
On Aug 28, 2007, at 5:12 PM, Chris Mellon wrote: On 8/28/07, Stefan Niemann [EMAIL PROTECTED] wrote: Hi, sorry that I'm relatively new to Python. But the syntax and semantics of Python already fascinate me, because I'm familiar with functional languages like Haskell. Is there a pattern matching construct in Python like (head : tail), meaning 'head' matches the first element of a list and 'tail' matches the rest? I could not find this in the Python documentation. Regards, Stefan Python does not have haskell like pattern matching. Things are written and done in a different way. When working with lists, Python has a slice syntax (which is rather more powerful than Haskells limited head-tail linked list syntax) that you can use to chop a sequence up into various parts. That is extremely arguable (in fact, Haskell's list semantics are extremely powerful as they are not limited to just head/tail). But, rather than debate the merits of one language over the other, to the OP: no, Python doesn't have any pattern matching facilities. Binding statements must be explicit, so you could do something along the lines of (using parallel assignment): head, tail = l[0], l[1:] or, front, last = l[:len(l) - 1], l[len(l) - 1] Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list
New style classes
Whats the point of object? How do I actually use it. I'm not understanding correctly from the python site located: http://www.python.org/download/releases/2.2.3/descrintro/ class C(object): def __init__(self): self.__x = 0 def getx(self): return self.__x def setx(self, x): if x 0: x = 0 self.__x = x -- http://mail.python.org/mailman/listinfo/python-list
Re: Check for dict key existence, and modify it in one step.
rodrigo [EMAIL PROTECTED] writes: Im using this construct a lot: if dict.has_key(whatever): dict[whatever] += delta else: dict[whatever] = 1 I'd prefer: foo.setdefault(whatever, 0) foo[whatever] += delta sometimes even nested: if dict.has_key(whatever): if dict[whatever].has_key(someother): dict[whatever][someother] += delta else: dict[whatever][someother] = 1 else: dict[whatever]={} dict[whatever][someother] = 1 foo.setdefault(whatever, {}) foo[whatever].setdefault(someother, 0) foo[whatever] += delta there must be a more compact, readable and less redundant way to do this, no? Hope that helps. -- \I took a course in speed waiting. Now I can wait an hour in | `\ only ten minutes. -- Steven Wright | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Gmane's been quiet ...
... so I was wondering if it's just me who hasn't seen any postings today? regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list