Re: Tips to match multiple patterns from from a single file .

2017-07-23 Thread woooee
You want to find strings on multiple lines of a file, and possible multiple string groups within a file (you didn't say). So you will have to check each line and store anything you want to keep for each file, and you will have to add the code to cycle through the files, so it is something along

Re: error i m getting in line no 4

2017-05-29 Thread woooee
And you can simplify the code with something like this for all of the "grid=" statements new_grid = [[], [0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0], [2,0,2,0],[0,4,0,8],[0,16,0,128],[2,2,2,2], [0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]], [2,0,2,0],[0,4,0,8

Re: I need help with making my claculator

2017-05-24 Thread woooee
This is most likely using class objects instead of instance objects. Not a normal thing in Python. As stated above, it is difficult, as the responses in this thread show, to get assistance with some alternate coding style. It is better to use Python in the way that is intended. Otherwise, yo

Re: I need help with making my claculator

2017-05-24 Thread woooee
How do you then run the mainloop, i.e. get it to do something? -- https://mail.python.org/mailman/listinfo/python-list

Re: Concatenating files in order

2017-05-23 Thread woooee
It is very straight forward; split on "_", create a new list of lists that contains a sublist of [file ending as an integer, file name], and sort fnames=["XXX_chunk_0", "XXX_chunk_10", "XXX_chunk_1", "XXX_chunk_20", "XXX_chunk_2"] sorted_lis

Re: I need help with making my claculator

2017-05-21 Thread woooee
First, you have to have a Tk instance before you do anything else. Take a look at this example, and then expand upon it to create the calculator http://python-textbok.readthedocs.io/en/1.0/Introduction_to_GUI_Programming.html -- https://mail.python.org/mailman/listinfo/python-list

Re: Alternative to signals in threads

2017-03-08 Thread woooee
Use multiprocessing since you want to do multiple things at once https://pymotw.com/2/multiprocessing/basics.html If I understand you correctly, once the string is found you would terminate the process, so you would have to signal the calling portion of the code using a Manager dictionary or l

Re: correct way to catch exception with Python 'with' statement

2016-11-29 Thread woooee
If you want to do something only if the file exists (or does not), use os.path.isfile(filename) -- https://mail.python.org/mailman/listinfo/python-list

Re: csv into multiple columns using split function using python

2016-11-29 Thread woooee
Add some print statements to see what is happening, especially after the for elem in mylist1: statement -- https://mail.python.org/mailman/listinfo/python-list

Re: exit ThreadPoolExecutor immediately

2016-11-15 Thread woooee
Doug Hellmann has what looks like a similar example using a poison pill (2nd example at) https://pymotw.com/2/multiprocessing/communication.html#multiprocessing-queues Note that join() allows the processes to finish so it you don't care then don't "join()" them. You can also terminate a multi

Re: Removing matching items from a list?

2013-08-03 Thread woooee
Use a dictionary to count the number of times each first letter appears, then place any first letters==4 in a list or set and remove any items that have a first letter in the list/set (or keep items that are not in the set which is probably faster if using list comprehension). -- http://mail.

Re: 回复: FACTS: WHY THE PYTHON LANGUAGE FAILS.

2013-06-27 Thread woooee
Any programming language is only as good as the person who is using it. -- http://mail.python.org/mailman/listinfo/python-list

Re: python script is not running

2013-05-18 Thread woooee
The obvious question, do you have the shebang on the first line so the OS knows it's to be run as a Python program? Also I would change tryJson() to if __name__ == "__main__': tryJson() This probably won't make any difference but you will have the bases covered. -- http://mail.python.org/mai

Re: kbhit/getch python equivalent

2013-04-22 Thread woooee
> I'm looking for a kbhit/getch equivalent in python in order to be able to > stop my inner loop in a controlled way (communication with external hardware > is involved and breaking it abruptly may cause unwanted errors A curses example import curses stdscr = curses.initscr() curses.cbreak() s

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread woooee
> waiting = False > > > > def clicked(x, y): > > global waiting > > print('clicked at %f %f' % (x,y)) > > waiting = False > > return > > > > def wait_for_click(s): > > global waiting > > waiting = True > > s.listen() > > while waiting: > > time

Re: error

2012-11-06 Thread woooee
>From this line, "data" appears to be a class if 0 < ix < data.width and 0 < iy < data.height: >From this line, "data" appears to be a list, although a two dimensional list would be accessed as data[ix][iy]         point = data[ix, iy] Also, returning a list from a function is a matter of pref

Re: Tkinter how to access the widget by name

2012-10-16 Thread woooee
On Oct 14, 1:11 pm, Владимир Пылев wrote: > label = Label(frame, width = 40, text='text', name = 'name') > ... > name_='name' > configure(name_) > ... > def configure(name_) >         #And how can that be? >         # At least let the text you want to change I do not understand your question

Re: Unpaking Tuple

2012-10-07 Thread woooee
On Oct 6, 3:09 am, sajuptpm wrote: > I need a way to make following code working without any ValueError . > > >>> a, b, c, d = (1,2,3,4) > >>> a, b, c, d = (1,2,3). Why is it necessary to unpack the tuple into arbitrary variables. a_tuple=(1,2,3) for v in a_tuple: print v for ctr in range(le

Re: subprocess call is not waiting.

2012-09-13 Thread woooee
It possibly requires a "shell=True", but without any code on any way to test, we can not say. -- http://mail.python.org/mailman/listinfo/python-list

Re: submit jobs on multi-core

2012-09-11 Thread woooee
There is parallel python as well http://www.parallelpython.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: dictionary into desired variable....

2012-08-10 Thread woooee
On Friday, August 10, 2012 8:31:48 AM UTC-7, Tamer Higazi wrote: > let us say a would be x = [2,5,4] > > y = a[3] > > if I change y to [] > > I want the result to be x = [2,5,[]] and that's automaticly There is no such thing as a[3] if a=[2,4,5]. And this is a list not a dictionary, so I wo

Re: Blank TK Window

2012-07-17 Thread woooee
On Jul 17, 9:32 am, Shamefaced wrote: > Hi, > Any reason why a blank Tk() window opens up when I run my code: > Code: > for run in range(RUNS): >     waittime = Monitor2() >     checkouttime = Monitor2() >     totaltimeinshop = Monitor2() >     checkout_aisle = Simulation.Resource(AISLES) >     Si

Re: Question:Programming a game grid ...

2012-06-27 Thread woooee
On Wednesday, June 27, 2012 5:15:09 PM UTC-7, Steven D'Aprano wrote: > On Wed, 27 Jun 2012 16:24:30 -0700, David wrote: > > > First, you should be getting an error on > > vars()[var] = Button(f3, text = "00", bg = "white") > > as vars() has not been declared > > The Fine Manual says differently:

Re: problems with tkinter updates

2012-01-24 Thread woooee
if line is not None: probably does not work the way you expect. You might try if line.strip(): Take a look at this quick example test_lines = ["Number 1\n", "\n", ""] for ctr, line in enumerate(test_lines): print ctr, line if line is not None: print " not None" -- http://mai

Re: "+=" does not work correct all alogn

2012-01-18 Thread woooee
> def conc1(a, _list = []): >     _list = _list + [a] >     return _list > for i in range(4): >     _list = conc1(i) ## <- list not passed You don't pass the list to the conc1 function, so you start with the default, an empty list, each time. -- http://mail.python.org/mailman/listinfo/pyth

Re: Why widgets become 'NoneType'?

2011-12-21 Thread woooee
The error is with the labels not the canvas. All labels will have an id of "None" as that is what pack() returns.         lbl = Label(win, text=astr[i]).pack(side=LEFT )         labels.append(lbl) The error will come up in the config_labels function when the program tries to config a tuple of "N

Re: Question: How to Prevent Tkinter Menu from Taking Keyboard Focus

2011-10-04 Thread woooee
Sorry, I did not understand the question correctly, and so have added another focus_set for the entry after the menu's creation. You can still enter after the menu comes up, even though you can't see where you are entering. import Tkinter class demo: def __init__(self, parent): self.

Re: Question: How to Prevent Tkinter Menu from Taking Keyboard Focus

2011-10-04 Thread woooee
Adding focus_set seems to work for me. What do want to do differently? import Tkinter class demo: def __init__(self, parent): self._entry = Tkinter.Entry(width = 60) self._suggestions = Tkinter.Menu(parent, tearoff = 0, takefocus = 0) self._entry.pack(padx = 20, pady

Re: Text file with mixed end-of-line terminations

2011-09-01 Thread woooee
You can use f.read() to read the entire file's contents into a string, providing the file isn't huge. Then, split on "\r" and replace "\n" when found. A simple test: input_data = "abc\rdef\rghi\r\njkl\r\nmno\r\n" first_split = input_data.split("\r") for rec in first_split: rec = rec.replace("\

Re: about if __name == '__main__':

2011-08-28 Thread woooee
Two main routines, __main__ and main(), is not the usual or the common way to do it. It is confusing and anyone looking at the end of the program for statements executed when the program is called will find an isolated call to main(), and then have to search the program for the statements that sho

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread woooee
as the += notation seems to be a syntaxic sugar layer that has to be converted to i = i + 1 anyway. That has always been my understanding. The faster way is to append to a list as concatenating usually, requires the original string, accessing an intermediate block of memory, and the memory for th

Re: Can someone help please

2011-07-21 Thread woooee
On Jul 21, 10:02 am, Gary wrote: > For some reason it will not send me the first text file in the directory. You have to print an unsorted list of the directory to know the name or the first file in the directory. Files are not stored on disk in alphabetical order, but are many times sorted in a

Re: Pythonic way with more than one max possible

2011-07-19 Thread woooee
> 1. In this dict, if there is a UNIQUE max value, then its *key* is the > winner. > 2. If there are any TIES for max value, then the *key* 'b' is the > winner by default. This will store the max value(s) in a list. In case of a tie, you can take the first value in the list, but it may be differe

Re: Partial Function Application -- Advantages over normal function?

2011-07-18 Thread woooee
Partial can be used in a GUI program, like Tkinter, to send arguments to functions. There are other ways to do that as well as using partial. The following program uses partial to send the color to the change_buttons function. from Tkinter import * from functools import partial class App: def

Re: update of elements in GUI

2010-08-17 Thread woooee
On Aug 16, 9:07 pm, Jah_Alarm wrote: > hi, I've already asked this question but so far the progress has been > small. > > I'm running Tkinter. I have some elements on the screen (Labels, most > importantly) which content has to be updated every iteration of the > algorithm run, e.g. "Iteration ="

Re: update of elements in GUI

2010-08-16 Thread woooee
On Aug 16, 9:07 pm, Jah_Alarm wrote: I have some elements on the screen (Labels, most > importantly) which content has to be updated every iteration of the > algorithm The variable type is IntVar() You would use int_var_name.set(some_number) -- http://mail.python.org/mailman/listinfo/python-lis

Re: PyQT 4.6.2 question about radiobuttons

2010-01-17 Thread woooee
QT uses "toggled". I do not use QT much but it would be something like self.radioButton_one.setCheckable(True) QtCore.QObject.connect(self.radioButton_one, QtCore.SIGNAL("toggled ()"),self.button_one_function) If this doesn't work, you can probably find more with a Google for "toggled". -- http:

Re: read file with multiple data per line

2009-04-14 Thread woooee
If this is the record, then you can use split to get a list of the individual fields and then convert to int or float where necessary. rec = "2NHST1 C1 56 3.263 2.528 16.345 " rec_split = rec.split() print rec_split If you want to read two records at a time, then use all_data = open(name,

Re: python for loop

2009-03-31 Thread woooee
Counting from zero through n-1 is used because it is the memory offset and not any kind of counter. Simplified, if you are iterating through a list, using a for loop or anything else, the first element/number is at memory offset zero because it is at the beginning. And if this is a list of 4 byte