Re: Tkinter.event.widget: handler gets name instead of widget.
Terry Reedy wrote: > On 7/13/2012 4:24 PM, Frederic Rentsch wrote: >> On Fri, 2012-07-13 at 09:26 +0200, Peter Otten wrote: > >>> Another random idea: run your code on a more recent python/tcl >>> installation. > > That might have been clearer as python + tcl/tk installation. Yes, sorry; I meant that both the python and tcl/tk version matter. You can find out the latter with $ python -c 'import Tkinter as tk; print tk.TclVersion, tk.TkVersion' 8.5 8.5 >> I next spent a day with an attempt to upgrade to Python 2.7.3, >> figuring that that might simultaneously take care of upgrading tcl. > > No, two completely separate actions. > >> ... build finished, but the necessary bits to build these modules were >> not found: >> >> _bsddb >> _curses >> _curses_panel >> _sqlite3 >> _ssl >> _tkinter >> bsddb185 >> bz2 >> dbm >> gdbm >> readline >> sunaudiodev > > I believe _tkinter is the only one of those you need to run idle. > > You need tcl/tk installed/compiled first to compile python with > _tkinter. Easier on *nix than windows. Many *nix systems come with > tcl/tk or easily install it with their package managers (same with some > of the other prerequisites for other modules). If you don't want to compile tcl/tk yourself you need to install the tk-dev package. I recommend that you install libreadline-dev, too -- without readline it is painful to use the interactive interpreter. -- http://mail.python.org/mailman/listinfo/python-list
Re: lambda in list comprehension acting funny
On Fri, 13 Jul 2012 21:53:10 -0700, rusi wrote: > On Jul 14, 8:43 am, Steven D'Aprano [email protected]> wrote: >> On Fri, 13 Jul 2012 19:31:24 -0700, rusi wrote: >> > Consider the following >> >> > def foo(x): >> > i = 100 >> > if x: >> > j = [i for i in range(10)] >> > return i >> > else: >> > return i >> >> A simpler example: >> >> def foo(): >> i = 100 >> j = [i for i in range(10)] >> return i >> >> In Python 3, foo() returns 100; in Python 2, it returns 9. > > You did not get the point. I got the point. I just thought it was unnecessarily complex and that it doesn't demonstrate what you think it does. > Converting my example to your format: > > def foo_steven(n): > i = 100 > j = [i for i in range(n)] > return i > > $ python3 > Python 3.2.3 (default, Jun 26 2012, 00:38:09) [GCC 4.7.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. def foo_steven(n): > ... i = 100 > ... j = [i for i in range(n)] > ... return i > ... foo_steven(0) > 100 foo_steven(4) > 100 Yes, we know that in Python 3, list comprehensions create their own scope, and the loop variable does not leak. > $ python > Python 2.7.3rc2 (default, Apr 22 2012, 22:35:38) [GCC 4.6.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. def foo_steven(n): > ... i = 100 > ... j = [i for i in range(n)] > ... return i > ... foo_steven(0) > 100 foo_steven(3) > 2 Yes, we know that in Python 2, list comprehensions don't create their own scope, and consequently the list variable does leak. > Python 2: > When n>0 comprehension scope i is returned > When n=0 function scope i is returned Incorrect. In Python 2, *there is no comprehension scope*. There is only local scope. In Python 2, regardless of the value of n, the local variable i is ALWAYS returned. It just happens that sometimes the local variable i is modified by the list comprehension, and sometimes it isn't. In Python 2, this is no more mysterious than this piece of code: def example(n): i = 100 for i in range(n): pass return i py> example(0) 100 py> example(4) 3 If the loop doesn't execute, the loop variable isn't modified. In Python 2, it doesn't matter whether you use a for-loop or a list comprehension, the loop variable is local to the function. > Python 3: The return statement is lexically outside the comprehension > and so that outside-scope's i is returned in all cases. Correct. In Python 3, list comprehensions now match generator expressions and introduce their own scope which does not effect the local function scope. Some history: http://bugs.python.org/issue510384 http://bugs.python.org/issue1110705 -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: code review
On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote:
>
>> From now on, for each operator I would have to remember wether it
>> is a supposedly comparison operator or not.
>
>
> I believe the following rule is true: if a op b is True or False raises,
I don't follow. Raises what?
> then op is a potentially chained comparison operation. They are (not) equal
> (and (not) is), the 4 order comparisons, and (not) in. 'in' should be the
> only surprise and most confusing.
1 < 3 in {3,4}
> True
3 in {3,4} < {4}
> False
>
> 'and' and 'or' are not included because they do not always return a bool,
> and indeed, they are not binary operators in the usual sense because of
> short-circuiting.
The only one of those operators that can be said to always return a
bool is "is (not)". The others (apart from "and" and "or") all can be
overloaded to return anything you want (for example, sqlalchemy
overloads them to return expression objects that are later compiled
into SQL), and chaining still occurs regardless of the types they are
applied to.
--
http://mail.python.org/mailman/listinfo/python-list
Re: lambda in list comprehension acting funny
Alister於 2012年7月12日星期四UTC+8下午5時44分15秒寫道: > On Wed, 11 Jul 2012 08:43:11 +0200, Daniel Fetchinson wrote: > > >> funcs = [ lambda x: x**i for i in range( 5 ) ] > >> print funcs[0]( 2 ) > >> print funcs[1]( 2 ) > >> print funcs[2]( 2 ) > >> > >> This gives me > >> > >> 16 16 16 > >> > >> When I was excepting > >> > >> 1 > >> 2 > >> 4 > >> > >> Does anyone know why? > > > > And more importantly, what's the simplest way to achieve the latter? > :) > > Having read Steve's explanation in the other thread (which I think has > finally flipped the light switch on lambda for me) it only requires a > minor change > > funcs=[ lambda x,y=i:x**y for i in range(5) ] > > although I cant actually think why this construct would be needed in > practice, how are you actually using it > > > -- > * Simunye is so happy she has her mothers gene's >you better give them back before she misses them! Uhn, there are 5 objects in the list if not factored well to be executed in the run time. -- http://mail.python.org/mailman/listinfo/python-list
from octave to python
Hello everyone ! I used Octave for matrix computations, but looks like Python will be useful everywhere so it is good idea to migrate (imho ofc). But I am novice here and dont know how to get things that was easy in Octave, for example: [intersect iA iB] = intersect(a, b) To do this in Python I use numpy.intersect1d(numpy.array, numpy.array), but how to get indexces ? P.S. sry for my english, hope you can understand what I mean :) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to safely maintain a status file
Am 13.07.2012 03:52, schrieb Steven D'Aprano: > And some storage devices (e.g. hard drives, USB sticks) don't actually > write data permanently even when you sync the device. They just write to > a temporary cache, then report that they are done (liar liar pants on > fire). Only when the cache is full, or at some random time at the > device's choosing, do they actually write data to the physical media. > > The result of this is that even when the device tells you that the data > is synched, it may not be. Yes, that's another issue. Either you have to buy expensive enterprise hardware with UPS batteries or you need to compensate for failures on software level (e.g. Hadoop cluster). We have big storage devices with double redundant controllers, on board buffer batteries, triple redundant power supplies, special RAID disks, multipath IO fiber channel links and external backup solution to keep our data reasonable safe. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: from octave to python
суббота, 14 июля 2012 г., 15:27:24 UTC+4 пользователь invis написал: > Hello everyone ! > > I used Octave for matrix computations, but looks like Python will be useful > everywhere so it is good idea to migrate (imho ofc). > > But I am novice here and dont know how to get things that was easy in Octave, > for example: > [intersect iA iB] = intersect(a, b) > > To do this in Python I use numpy.intersect1d(numpy.array, numpy.array), but > how to get indexces ? > > P.S. sry for my english, hope you can understand what I mean :) Answer here: http://stackoverflow.com/questions/11483863/python-intersection-indices-numpy-array -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Qt4 Designer
On 07/13/2012 03:12 PM, Jean Dubois wrote: > Thanks for the extra docu references In this day and age, I think compiling ui files to code is probably on the way out. Instead you should consider using the ui files directly in your code. This has the advantage of letting you change the gui somewhat without having to recompile all the time. Here is are some links that gives one way of loading and parsing the ui file directly: http://www.riverbankcomputing.com/pipermail/pyqt/2007-April/015902.html http://bitesofcode.blogspot.ca/2011/10/comparison-of-loading-techniques.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Qt4 Designer
On Jul 14, 7:45 pm, Michael Torrie wrote: > On 07/13/2012 03:12 PM, Jean Dubois wrote: > > > Thanks for the extra docu references > > In this day and age, I think compiling ui files to code is probably on > the way out. Instead you should consider using the ui files directly in > your code. This has the advantage of letting you change the gui > somewhat without having to recompile all the time. > > Here is are some links that gives one way of loading and parsing the ui > file directly: > > http://www.riverbankcomputing.com/pipermail/pyqt/2007-April/015902.htmlhttp://bitesofcode.blogspot.ca/2011/10/comparison-of-loading-techniqu... I looked at the second link and find code like this: app = None if ( not app ): app = QtGui.QApplication([]) Maybe I'm dense but whats that if doing there? Frankly I seem to be a bit jinxed with gui stuff. A few days ago someone was singing the praises of some new themed tk stuff. I could not get the first two lines -- the imports -- to work and then gave up -- http://mail.python.org/mailman/listinfo/python-list
Re: howto do a robust simple cross platform beep
Steven D'Aprano writes: >> How do others handle simple beeps? >> >> I just want to use them as alert, when certain events occur within a >> very long running non GUI application. > > Why? Do you hate your users? I, too, would find it useful -- for me (although I do not hate myself). Surely, you know an alarm clock. Usually, it gives an audible signal when it is time to do something. A computer can in principle be used as a flexible alarm clock - but it is not so easy with the audible signal... An audible signal has the advantage (over a visual one) that you can recognize it even when you are not looking at the screen (because you are thinking). Unfortunately, I had to give up. My new computer lacks a working speaker... -- http://mail.python.org/mailman/listinfo/python-list
Re: howto do a robust simple cross platform beep
> How do others handle simple beeps? http://pymedia.org/ ? I *think* the "big" UI frameworks (Qt, wx ...) have some sound support. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto do a robust simple cross platform beep
On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer wrote: > I, too, would find it useful -- for me (although I do not hate myself). > > Surely, you know an alarm clock. Usually, it gives an audible signal > when it is time to do something. A computer can in principle be used > as a flexible alarm clock - but it is not so easy with the audible signal... > An audible signal has the advantage (over a visual one) that you can > recognize it even when you are not looking at the screen (because you > are thinking). > > Unfortunately, I had to give up. My new computer lacks a working > speaker... There's a simple cheat you can do. Just invoke some other application to produce the sound! My current alarm clock comes in two modes: it either picks a random MIDI file from Gilbert and Sullivan's "Ruddigore", or it plays the "Alice: Madness Returns" theme; in each case it just invokes the file with its default association (see the "start" command in Windows, or "gnome-open" in, well, GNOME). Of course, working speaker IS a prerequisite. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: code review
On 7/14/2012 5:26 AM, Ian Kelly wrote:
On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote:
I believe the following rule is true: if a op b is True or False raises,
Sorry, left out 'or' in 'or raises'
I don't follow. Raises what?
an Exception.
then op is a potentially chained comparison operation. They are (not) equal
(and (not) is), the 4 order comparisons, and (not) in. 'in' should be the
only surprise and most confusing.
1 < 3 in {3,4}
True
3 in {3,4} < {4}
False
'and' and 'or' are not included because they do not always return a bool,
and indeed, they are not binary operators in the usual sense because of
short-circuiting.
The only one of those operators that can be said to always return a
bool is "is (not)". The others (apart from "and" and "or") all can be
overloaded to return anything you want
OK, add 'by default, without over-rides ;-).
or 'for builtin classes'.
Python's flexibility makes it really hard to make any general statement.
In my book-in-progress, I am currently resorting to saying "In Python*,
..." whenever I know and remember that it is possibly to over-ride the
customary behavior described in '...'.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
Re: lambda in list comprehension acting funny
On Fri, 13 Jul 2012 12:54:02 -0600, Ian Kelly wrote: > On Fri, Jul 13, 2012 at 11:53 AM, Hans Mulder wrote: >> The function `function` refers to a variable `VERBOSE` that isn't >> local. In some programming langauages, the interpreter would then scan >> the call stack at run-time, looking for a scope where that name is >> defined. It would find the local one in `caller`. This is known as >> "dynamic binding". >> >> Other interpreters use the `VERBOSE` that was in scope at the point in >> the program text where `function` was defined. In this case, that would >> be the global one. This is called "lexical binding". >> >> Some programming languages allow you to indicate on a per- variable >> basis whether you want dynamic or lexical binding. >> >> Python is firmly in the lexical camp. Dynamic binding is not available >> in Python, and never will be. I don't remember whether it is Javascript or PHP that uses dynamic binding, but whichever it is, it is generally considered to be a bad idea, at least as the default or only behaviour. Bash is another language with dynamic binding. Some very old versions of Lisp use dynamic binding, because it was the easiest to implement. Most modern languages use lexical (also known as static) binding, because it is more sensible. Here is an illustration of the difference: suppose we have two modules, library.py and main.py: # library.py x = 23 def func(y): return x + y # main.py import library x = 1000 print func(1) If main.py prints 24 (and it does), then Python is using lexical scoping. But if it prints 1001 (which it doesn't), then it is using dynamic scoping. The obvious problem with dynamic binding is that the behaviour of a function may vary depending on where you call it. > I don't believe that dynamic vs. lexical binding is what rusi was > attempting to describe. If he was, then Python and Haskell would be a > bad comparison since both are lexical. Rather, I think what he was > trying to show was capture by reference vs. capture by value in the > context of closures. Python uses capture by reference, and so the > upvalue is the value of that reference at the time the closure is > called. Haskell uses capture by value, and the upvalue is the value at > the time of definition. I don't think "by reference" versus "by value" are good terms to use here, since they risk conflating the issue with "call by reference" versus "call by value" semantics. I prefer "late" versus "early", as you suggest below. > I've also seen the distinction described as "early" vs. "late" binding > on this list, but I'm not sure how precise that is -- I believe that > terminology more accurately describes whether method and attribute names > are looked up at compile-time or at run-time, Not necessarily *compile* time, but the distinction is between when the function is defined (which may at compile time, or it may be at run time) versus when the function is called. I think that gets to the heart of the issue, not whether the capture copies a value or a reference. At some point, the capture must make use of the value: whether it does so via a direct C-style memory location copy, or an object pointer, or some other mechanism, is irrelevant. What matters is whether that value is grabbed at the time the closure is created, or when the closure is called. > late binding being the > feature that makes duck typing possible. That is conflating two entirely distinct subjects. Python 1.5 had duck- typing but no closures, so the one certainly does not depend on the other. Duck-typing is more a philosophy than a language feature: the language must be typed, and the programmer must prefer to program to a protocol or a specification rather than to membership of a type. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Request for useful functions on dicts
Hi, everybody. I am trying to collect all the functions I've found useful for working with dicts into a library: https://github.com/leifp/dictutil If you have a favorite dict-related func / class, or know of similar projects, please let me know (or open an issue on github). Bear in mind that the functions don't even have to come from python; if you have a favorite PHP / APL / COBOL / etc associative array function, that's fair game. Thanks, Leif P. S. I'm participating in Julython [ http://www.julython.org/ ], and it's fun. You should all join and show everyone that your city has the most open source python activity. -- http://mail.python.org/mailman/listinfo/python-list
Re: lambda in list comprehension acting funny
On Sat, Jul 14, 2012 at 4:29 PM, Steven D'Aprano < [email protected]> wrote: > I don't remember whether it is Javascript or PHP that uses dynamic > binding, but whichever it is, it is generally considered to be a bad > idea, at least as the default or only behaviour. > > Bash is another language with dynamic binding. Some very old versions of > Lisp use dynamic binding, because it was the easiest to implement. Most > modern languages use lexical (also known as static) binding, because it > is more sensible. > > Here is an illustration of the difference: suppose we have two modules, > library.py and main.py: > > # library.py > x = 23 > def func(y): > return x + y > > # main.py > import library > x = 1000 > print func(1) > I've not heard this discussed in a while. ISTR it was "lexical scoping" vs "dynamic scoping", but I wouldn't be surprised at all if it's known by both pairs of names. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Simulation Results Managment
[email protected] wrote: > Hi, > This is a general question, loosely related to python since it will be the > implementation language. I would like some suggestions as to manage simulation > results data from my ASIC design. > > For my design, > - I have a number of simulations testcases (TEST_XX_YY_ZZ), and within each of > these test cases we have: > - a number of properties (P_AA_BB_CC) > - For each property, the following information is given > - Property name (P_NAME) > - Number of times it was checked (within the testcase) N_CHECKED > - Number of times if failed (within the testcase) N_FAILED > - A simulation runs a testcase with a set of parameters. > - Simple example, SLOW_CLOCK, FAST_CLOCK, etc > - For the design, I will run regression every night (at least), so I will have > results from multiple timestamps We have < 1000 TESTCASES, and < 1000 > PROPERTIES. > > At the moment, I have a script that extracts property information from > simulation logfile, and provides single PASS/FAIL and all logfiles stored in a > directory structure with timestamps/testnames and other parameters embedded in > paths > > I would like to be easily look at (visualize) the data and answer the > questions - When did this property last fail, and how many times was it > checked - Is this property checked in this test case. > > Initial question: How to organize the data within python? > For a single testcase, I could use a dict. Key P_NAME, data in N_CHECKED, > N_FAILED I then have to store multiple instances of testcase based on date > (and simulation parameters. > > Any comments, suggestions? > Thanks, > Steven One small suggestion, I used to store test conditions and results in log files, and then write parsers to read the results. The formats kept changing (add more conditions/results!) and maintenance was a pain. Now, in addition to a text log file, I write a file in pickle format containing a dict of all test conditions and results. Much more convenient. -- http://mail.python.org/mailman/listinfo/python-list
Re: lambda in list comprehension acting funny
On Sun, Jul 15, 2012 at 9:29 AM, Steven D'Aprano wrote: > Not necessarily *compile* time, but the distinction is between when the > function is defined (which may at compile time, or it may be at run time) > versus when the function is called. I'd treat the def/lambda statement as "compile time" and the () operator as "run time". ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: howto do a robust simple cross platform beep
On 14/07/12 20:49:11, Chris Angelico wrote: > On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer wrote: >> I, too, would find it useful -- for me (although I do not hate myself). >> >> Surely, you know an alarm clock. Usually, it gives an audible signal >> when it is time to do something. A computer can in principle be used >> as a flexible alarm clock - but it is not so easy with the audible signal... >> An audible signal has the advantage (over a visual one) that you can >> recognize it even when you are not looking at the screen (because you >> are thinking). >> >> Unfortunately, I had to give up. My new computer lacks a working >> speaker... > > There's a simple cheat you can do. Just invoke some other application > to produce the sound! My current alarm clock comes in two modes: it > either picks a random MIDI file from Gilbert and Sullivan's > "Ruddigore", or it plays the "Alice: Madness Returns" theme; in each > case it just invokes the file with its default association (see the > "start" command in Windows, or "gnome-open" in, well, GNOME). > > Of course, working speaker IS a prerequisite. The other prerequisite is that the use is physically near the compueter where your Python process is running. If, for exmple, I'm ssh'ed into my webserver, then sending a sound file to the server's speaker may startle someone in the data centre, but it won't attract my attention. If, OTOH, you do: print "\7" , then an ASCII bell will be sent across the network, and my terminal emulator will beep. It all depends. -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: howto do a robust simple cross platform beep
On Sun, Jul 15, 2012 at 10:39 AM, Hans Mulder wrote: > The other prerequisite is that the use is physically near the > compueter where your Python process is running. > > If, for exmple, I'm ssh'ed into my webserver, then sending a sound > file to the server's speaker may startle someone in the data centre, > but it won't attract my attention. If, OTOH, you do: > > print "\7" > > , then an ASCII bell will be sent across the network, and my > terminal emulator will beep. > Sure, though other of the OP's ideas preclude that too. But you could use any network protocol that acknowledges sound (MUDs use \7 following the terminal). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: howto do a robust simple cross platform beep
On Friday, July 13, 2012 8:00:05 PM UTC-5, gelonida wrote: > I just want to use a beep command that works cross platform. [...] I > just want to use them as alert, when certain events occur within a > very long running non GUI application. I can see a need for this when facing a non GUI interface. But even "IF" you do manage to play a sound in a cross platform manner; if the speaker volume is too low, or the speakers are turned off, or the computer does not have speakers connected, etc... your user will never hear the alert! In this case, beeping the built-in speaker has the fail-safe advantage. Why not wrap up the functionality and release a module yourself? If you are not sure how to access the speaker on one or more OSs then ask on the list. I would love to see some community effort behind this. PS: Better make sure this module does not exist though ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter.event.widget: handler gets name instead of widget.
On Thursday, July 12, 2012 1:53:54 PM UTC-5, Frederic Rentsch wrote: > The "hit list" is a table of investment titles (stock, funds, bonds) > that displays upon entry of a search pattern into a respective template. > The table displays the matching records: name, symbol, ISIN, CUSIP, Sec. > Any line can be click-selected. So they are to look like buttons. Hmm. If they "appear" like a button widget anyway, then why not just use a button widget? > Representing the mentioned names and id codes in Label widgets was the > simplest way I could come up with to align them in columns, admittedly > without the benefit of much experience. But it does look good. the > layout is fine. But is it really the "simplest"? :) ## START CODE ## import Tkinter as tk from Tkconstants import * colWidths = (5,10,30,5) N_COLS = len(colWidths) N_ROWS = 6 root = tk.Tk() for r in range(N_ROWS): # Create some imaginary text to display in each column. # Also try using string methods "center" and "rjust" to # see alternative justification of text. lst = [str(r).ljust(colWidths[r]) for r in range(N_COLS)] b=tk.Button(root, text=''.join(lst)) b.pack(padx=5, pady=5) root.mainloop() ## END CODE ## You could easily expand that into something reusable. Now. If you need to place fancy borders around the texts, or use multiple fonts, or use images, or blah blah blah... then you may want to use the "canvas items" provided by the Tkinter.Canvas widget INSTEAD of buttons. With the canvas, you can create a simple rectangle (canvas.create_rectangle) that represents a button's outside dimension and give it a "button styled" border. Then you can bind click events to mimic the button press action. Then you can place canvas_text items on top of that fake button and configure them to be invisible to click events. These text items will not interfer like the Tkinter.Label widgets are currently doing. However, i would suggest the Tkinter.Button solution is the easiest by far. > I find the Tkinter system quite challenging. Doing a layout isn't so > much a matter of dimensioning and placing things as a struggle to trick > a number of automatic dimensioning and placing mechanisms into > obliging--mechanisms that are rather numerous and hard to remember. I don't think i agree with that assessment. ## START TANGENTIAL MEANDERINGS ## I find the geometry management of Tkinter to be quite powerful whilst being simultaneously simplistic. You only have three main types of management: "Grid", "Place", and "Pack". Each of which has a very specific usage. One caveat to know is that you can NEVER mix "Grid" and "Pack" in the same container widget! I find myself using grid and pack the most, with grid being at the top of the list. Now, i will agree that grid can be confusing at first until you understand how to "rowconfigure" and "columnconfigue" the containing widget (be it a frame or a toplevel). There is also the "sticky" attribute to consider. ## END TANGENTIAL MEANDERINGS ## But all in all, i would say the most difficult part of the Tkinter geometry management API is coming to grips as to which of the three geometry managers is the best choice for the particular problem at hand -- and you will find yourself using more than one manager in a single GUI app! But i don't see you solving this problem by stacking one widget on another. I believe it's time to seek out a new solution. EASY: Using rows of Tkinter.Button coupled with a per-formatted text string. ADVANCED: Creating "pseudo buttons" on a canvas and stacking text objects (or whatever you like) on them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simulation Results Managment
On Jul 14, 10:50 am, [email protected] wrote: > Hi, > This is a general question, loosely related to python since it will be the > implementation language. > I would like some suggestions as to manage simulation results data from my > ASIC design. > > For my design, > - I have a number of simulations testcases (TEST_XX_YY_ZZ), and within each > of these test cases we have: > - a number of properties (P_AA_BB_CC) > - For each property, the following information is given > - Property name (P_NAME) > - Number of times it was checked (within the testcase) N_CHECKED > - Number of times if failed (within the testcase) N_FAILED > - A simulation runs a testcase with a set of parameters. > - Simple example, SLOW_CLOCK, FAST_CLOCK, etc > - For the design, I will run regression every night (at least), so I will > have results from multiple timestamps > We have < 1000 TESTCASES, and < 1000 PROPERTIES. > > At the moment, I have a script that extracts property information from > simulation logfile, and provides single PASS/FAIL and all logfiles stored in > a directory structure with timestamps/testnames and other parameters embedded > in paths > > I would like to be easily look at (visualize) the data and answer the > questions > - When did this property last fail, and how many times was it checked > - Is this property checked in this test case. > > Initial question: How to organize the data within python? > For a single testcase, I could use a dict. Key P_NAME, data in N_CHECKED, > N_FAILED > I then have to store multiple instances of testcase based on date (and > simulation parameters. > > Any comments, suggestions? > Thanks, > Steven Not sure if you are asking about: 1. Python data structure organization or 2. Organization of data outside python for conveniently getting in and out of python For 2. if the data is modestly sized and is naturally managed with builtin python types -- lists and dictionaries -- yaml gives a nice fit. I used pyyaml some years ago, today I guess json which is similar, is the way to go. For 1, you need to say what are your questions/issues. -- http://mail.python.org/mailman/listinfo/python-list
Re: Keeping the Console Open with IDLE
On Thursday, February 19, 2009 10:06:42 PM UTC-6, W. eWatson wrote: > I'm using IDLE for editing, but execute programs directly. If there are > execution or "compile" errors, the console closes before I can see what it > contains. How do I prevent that? Q: If you are in fact using IDLE to edit your code file, then why not just "run" the files directly from the IDLE menu (Menu->Run->Run Module)? If you select this command, IDLE will display a shell window containing all the stdout and stderr messages. I think this would be the easiest approach for a neophyte administrator like yourself. See this tutorial for more info: https://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html There are many methods of executing a python script. Using the IDLE "run" command is just one of them. Some others include: 1. Double clicking the file icon in a file browser 2. Typing the full path of the script into a windows Command Prompt. Considering i have a script in my "C drive" named "foo.py", i could type the command "C:\foo.py" to execute the script from a windows command prompt. But my fingers don't need any exercise, so i just double click the icon or use the "run" command of my IDE. Done deal. -- http://mail.python.org/mailman/listinfo/python-list
Re: help needed with subprocess, pipes and parameters
On Friday, July 13, 2012, nuffi wrote:
>
> If I copy and paste the following command into a command window, it does
> what I need.
>
> c:\Programs\bob\bob.exe -x -y "C:\text\path\to some\file.txt" |
> c:\Programs\kate\kate.exe -A 2 --dc "Print Media Is Dead" --da "Author"
> --dt "Title" --hf "Times" --bb "14" --aa "" --font "Ariel" -
> "C:\rtf\path\to some\file.rtf"
>
> My mission is to recreate this command within a python script, so that I
> can pass a bunch of different parameters into it, and use it as a batch
> over a bunch of different papers.
>
>
> The code I came up with looks like this:
>
> import os, glob, subprocess
>
> sourceDir = "c:\\text\\"
> destDir = "c:\\rtf\\"
> bobPath = "C:\\Programs\\bob\\bob.exe"
> katePath = "C:\\Programs\\kate\\kate.exe"
>
> def get_new_path(doc):
> blah = doc.replace(sourceDir, destDir)
> if not os.path.isdir(blah):
> os.makedirs(blah)
> rtf = blah.replace('.txt', '.rtf')
> pathString = '- "' + (os.path.join(rtf)) + '"'
> return(pathString)
>
>
> def convert_doc(doc):
> dc = '--dc "Print Media Is Dead"'
> da = '--da "Author"'
> dt = '--dt "Title"'
> hf = '--hf "Times"'
> fn = '--font "Ariel"'
> bb = '--bb "14"'
> docpath = '"' + (os.path.join(doc)) + '"'
> path = get_new_path(doc)
> A = '-A 2'
> bob = subprocess.Popen([bobPath, '-x', '-y', docpath], stdout =
> subprocess.PIPE,)
> kate = subprocess.Popen([katePath, A, dc, da, dt, hf, fn, bb, path],
> stdin = bob.stdout, stdout = subprocess.PIPE,)
Your tokenization of the command is wrong. Read the Note box in the
subprocess docs for guidance on how to get it right:
http://docs.python.org/library/subprocess.html#popen-constructor
Cheers,
Chris via iPhone
--
Cheers,
Chris
--
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Simulation Results Managment
On Sunday, July 15, 2012 2:42:39 AM UTC+2, Neal Becker wrote: > me wrote: > > > Hi, > > This is a general question, loosely related to python since it will be > the > > implementation language. I would like some suggestions as to manage > simulation > > results data from my ASIC design. > > > > For my design, > > - I have a number of simulations testcases (TEST_XX_YY_ZZ), and within > each of > > these test cases we have: > > - a number of properties (P_AA_BB_CC) > > - For each property, the following information is given > > - Property name (P_NAME) > > - Number of times it was checked (within the testcase) N_CHECKED > > - Number of times if failed (within the testcase) N_FAILED > > - A simulation runs a testcase with a set of parameters. > > - Simple example, SLOW_CLOCK, FAST_CLOCK, etc > > - For the design, I will run regression every night (at least), so I > will have > > results from multiple timestamps We have < 1000 TESTCASES, and < > 1000 > > PROPERTIES. > > > > At the moment, I have a script that extracts property information from > > simulation logfile, and provides single PASS/FAIL and all logfiles > stored in a > > directory structure with timestamps/testnames and other parameters > embedded in > > paths > > > > I would like to be easily look at (visualize) the data and answer the > > questions - When did this property last fail, and how many times was it > > checked - Is this property checked in this test case. > > > > Initial question: How to organize the data within python? > > For a single testcase, I could use a dict. Key P_NAME, data in N_CHECKED, > > N_FAILED I then have to store multiple instances of testcase based on > date > > (and simulation parameters. > > > > Any comments, suggestions? > > Thanks, > > Steven > > One small suggestion, > I used to store test conditions and results in log files, and then write > parsers > to read the results. The formats kept changing (add more > conditions/results!) > and maintenance was a pain. > > Now, in addition to a text log file, I write a file in pickle format > containing > a dict of all test conditions and results. Much more convenient. Hi Neal, We already store the original log files. Does pickle have any advantages over json/yaml? Thanks, Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Simulation Results Managment
On Sunday, July 15, 2012 5:25:14 AM UTC+2, rusi wrote: > On Jul 14, 10:50 am, [email protected] wrote: > > Hi, > > This is a general question, loosely related to python since it will be > the implementation language. > > I would like some suggestions as to manage simulation results data from > my ASIC design. > > > > For my design, > > - I have a number of simulations testcases (TEST_XX_YY_ZZ), and within > each of these test cases we have: > > - a number of properties (P_AA_BB_CC) > > - For each property, the following information is given > > - Property name (P_NAME) > > - Number of times it was checked (within the testcase) N_CHECKED > > - Number of times if failed (within the testcase) N_FAILED > > - A simulation runs a testcase with a set of parameters. > > - Simple example, SLOW_CLOCK, FAST_CLOCK, etc > > - For the design, I will run regression every night (at least), so I > will have results from multiple timestamps > > We have < 1000 TESTCASES, and < 1000 PROPERTIES. > > > > At the moment, I have a script that extracts property information from > simulation logfile, and provides single PASS/FAIL and all logfiles stored in > a directory structure with timestamps/testnames and other parameters embedded > in paths > > > > I would like to be easily look at (visualize) the data and answer the > questions > > - When did this property last fail, and how many times was it checked > > - Is this property checked in this test case. > > > > Initial question: How to organize the data within python? > > For a single testcase, I could use a dict. Key P_NAME, data in > N_CHECKED, N_FAILED > > I then have to store multiple instances of testcase based on date (and > simulation parameters. > > > > Any comments, suggestions? > > Thanks, > > Steven > > Not sure if you are asking about: > 1. Python data structure organization > or > 2. Organization of data outside python for conveniently getting in and > out of python > > For 2. if the data is modestly sized and is naturally managed with > builtin python types -- lists and dictionaries -- yaml gives a nice > fit. I used pyyaml some years ago, today I guess json which is > similar, is the way to go. > > For 1, you need to say what are your questions/issues. Hi Rusi, For (1), I guess that the only question I had was how to handle regression results. But I think that the most logical way for string this data is as a dict with key = datestamp, and entries being list of testcases/results. For (2), I will look at both these. Thanks for the help. Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Qt4 Designer
On 07/14/2012 11:13 AM, rusi wrote: > I looked at the second link and find code like this: > > app = None if ( not app ): app = QtGui.QApplication([]) > > Maybe I'm dense but whats that if doing there? > > Frankly I seem to be a bit jinxed with gui stuff. A few days ago > someone was singing the praises of some new themed tk stuff. I could > not get the first two lines -- the imports -- to work and then gave > up Since you haven't had any experience with gui development then probably loading ui files isn't the right place to start. First principles (creating gui widgets from scratch) would be it. In any case, the line in question is quite simple. It creates a QApplication object, which is basically the engine that drives all Qt applications. Once you call .run() on it, it takes over and handles all the mouse events and such for you. In fact you do not have any control over the program's execution from this point on, other than to define event call-back methods or functions that are called by the widgets when things happen, like mouse clicks. All gui toolkits operate this way. You set up the widgets, then you run the main engine or main event loop and control never returns to your main program until something triggers the end (like closing a window or the quit menu item is pressed). Probably a complete working example is what you need to see, that is documented. I primarily work with Gtk, but I'll whip up a Qt one tomorrow if I can. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Simulation Results Managment
[email protected] writes: > ... > Does pickle have any advantages over json/yaml? It can store and retrieve almost any Python object with almost no effort. Up to you whether you see it as an advantage to be able to store objects rather than (almost) pure data with a rather limited type set. Of course, "pickle" is a proprietary Python format. Not so easy to decode it with something else than Python. In addition, when you store objects, the retrieving application must know the classes of those objects -- and its knowledge should not be too different from how those classes looked when the objects have been stored. I like very much to work with objects (rather than with pure data). Therefore, I use "pickle" when I know that the storing and retrieving applications all use Python. I use pure (and restricted) data formats when non Python applications come into play. -- http://mail.python.org/mailman/listinfo/python-list
