pdb: How to use the 'break' parameter?

2024-08-21 Thread Kevin M. Wilson via Python-list
break (Old_MacDonald:23 | name[indx] == 'd', indx = 4), based on the doc spec in python.org (https://docs.python.org/3/library/pdb.html#debugger-commands) Cell In[1], line 20 break (Old_MacDonald:23 | name[indx] == 'd', indx = 4) ^ SyntaxError: invalid syntax I got one blan

Fw: Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Kevin M. Wilson via Python-list
sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."      Isaiah 43:2 - Forwarded Message - From: Kevin M. Wilson via Python-list To: python-list@python.org Sent: Tuesday, May 28, 2024 at 10:35:23 PM MDTSubject: Fl

Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Kevin M. Wilson via Python-list
The following is my effort to understand how to process a string, letter, by letter: def myfunc(name):        index = 0    howmax = len(name)    # while (index <= howmax):    while (index < howmax):        if (index % 2 == 0):            print('letter to upper = {}, index {}!'.format(name[index]

Re: Invalid literal for int() with base 10?

2023-05-25 Thread Kevin M. Wilson via Python-list
e."      Isaiah 43:2 On Thursday, May 25, 2023 at 05:55:06 PM MDT, Kevin M. Wilson via Python-list wrote: Ok, I'm not finding any info. on the int() for converting a str to an int (that specifies a base parameter)?! The picture is of the code I've written... And the

From geeksforgeeks.org, on converting the string created by the input() to an INT

2023-05-25 Thread Kevin M. Wilson via Python-list
We can first convert the string representation of float into float using  float() function and then convert it into an integer using int().So, why can't a string of an integer be converted to an integer, via  print(int(str('23.5')))??? Perplexed | print(int(float('23.5'))) | "When you pas

Invalid literal for int() with base 10?

2023-05-25 Thread Kevin M. Wilson via Python-list
Ok, I'm not finding any info. on the int() for converting a str to an int (that specifies a base parameter)?! The picture is of the code I've written... And the base 10 paradigm involved?? years = int('y') # store for calculationValueError: invalid literal for int() with base 10: 'y'What is mean

Three (3) >>> in the debug screen of PyCharm... Que Es over?!!

2023-05-04 Thread Kevin M. Wilson via Python-list
"When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."      Isaiah 43:2 | | Virus-free.www.avg.com | -- https://mail.python.org/m

Disable 'style PEP' messages

2023-05-04 Thread Kevin M. Wilson via Python-list
Hi... How do I set Pycharm to find only syntax errors?!! "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."      Isaiah 43:2 | |

Editing PEP-8, in particular "expected 2 blanks, found 1

2023-05-02 Thread Kevin M. Wilson via Python-list
Folks, help please! What the @#$! are these doing popping up. Code styles are personal, and not subject to debate.Where can I edit these out of my IDE? Kevin "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk th

PyCharm's strict PEP and not so strict?

2023-04-19 Thread Kevin M. Wilson via Python-list
Greetings,     I'm in a bit of a quandary, I want some strict syntax errors to be flagged, but the use of single quotes vs double quotes! NOT what I need from the 'checker', you dig? As I've recently returned to the IDE, and no longer have the "stones" for bull, how do I set up the kind of "

Re: Pycharm IDE

2023-04-18 Thread Kevin M. Wilson via Python-list
u: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."      Isaiah 43:2 On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list wrote: print (f'

Re: Pycharm IDE

2023-04-18 Thread Kevin M. Wilson via Python-list
aze."      Isaiah 43:2 On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost wrote: On 4/18/23 19:18, Kevin M. Wilson wrote: >Why complain about a 'comma', or a ')'??? >      print (f'"I am thinking of a number between 1 to {LIMIT}\n") my

Pycharm IDE

2023-04-18 Thread Kevin M. Wilson via Python-list
Greetings... Kevin here:I need help, as you have guessed!I have this line: The Print Statement... Why complain about a 'comma', or a ')'???def play_game(): number = random.randint(1, LIMIT) print (f'"I am thinking of a number between 1 to {LIMIT}\n")Or is this a setting in the IDE, I need

Help, PyCharm fails to recognize my tab setting...See attached picture of the code.

2022-10-10 Thread Kevin M. Wilson via Python-list
C:\Users\kevin\PycharmProjects\Myfuturevalue\venv\Scripts\python.exe C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py   File "C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py", line 31    elif (years > 50.0) or (years < 1.0) :    ^IndentationError: expected an indent

F-string usage in a print()

2022-05-24 Thread Kevin M. Wilson via Python-list
future_value = 0 for i in range(years): # for i in range(months): future_value += monthly_investment future_value = round(future_value, 2) # monthly_interest_amount = future_value * monthly_interest_rate # future_value += monthly_interest_amount # display the result print(f"Year =

python-list@python.org

2022-04-13 Thread Kevin M. Wilson via Python-list
MS Edge settings are displayed in the first picture, the error I encountered is the second picture...not sure how I get around this!I reloaded the browser after checking the settings for JavaScript...confused. Kevin Good sense makes one slow to anger, and it is his glory tooverlook an off

Pycharm IDE: seeking an assist!

2022-03-21 Thread Kevin M. Wilson via Python-list
Greetings Python coders,     I have installed the Pycharm IDE, and upon successfully auto install of the path/environment statements. The IDE opened and displayed (bottom right corner):  The use of Java options environment variables detected. Such variables override IDE configuration files

Inkscape

2022-01-10 Thread Mandy and Michael Wilson via Python-list
message saying that I require Python 3.6 or greater. I have downloaded and installed Python 3.10.1 but I am still receiving the same message. Can you please tell me what I am doing wrong ? I look forward to hearing from you. regards Mandy Wilson m. 07739 263 234 -- https

a simple question

2021-07-26 Thread Glenn Wilson via Python-list
I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong.      thanks

Tkinter needed as a legacy version 2.7 imports the module...

2021-02-26 Thread Kevin M. Wilson via Python-list
Hey Community,    Is there a site where I might/can download a version of Tkinter for Python 2.7? Seriously, KMW John 1:4  "In him was life; and the life was the light of men." -- https://mail.python.org/mailman/listinfo/python-list

Python 2.7 and 3.9

2021-02-16 Thread Kevin M. Wilson via Python-list
My employer has hundreds of scripts in 2.7, but I'm writing new scripts in 3.9! I'm running into 'invalid syntax' errors.I have to maintain the 'Legacy' stuff, and I need to mod the path et al., to execute 3.7 w/o doing damage to the 'Legacy' stuff...IDEA' are Welcome! KMW John 1:4  "In him was

Re: Mutable defaults

2021-02-10 Thread Ross Wilson
On Thu, 11 Feb 2564 BE at 12:52 Grant Edwards wrote: > On 2021-02-11, J. Pic wrote: > > > I just meant removing the whole "default value mutating" story, not > > removing mutable variables. Really, I was wondering if there was a use > case > > where this actually turns to an advantage, > > I've

Re: Python cannot count apparently

2021-02-07 Thread Kevin M. Wilson via Python-list
Set i = 0 at the begin of the code, that way each entry starts at Logical 0 of the array/container/list... "The only way to have experience is by having the experience"! On Sunday, February 7, 2021, 12:56:40 PM MST, Karsten Hilbert wrote: Am Sun, Feb 07, 2021 at 07:47:03PM + schr

For example: Question, moving a folder (T061RR7N1) containing a Specific file (ReadCMI), to folder: C:\\...\DUT0

2021-01-27 Thread Kevin M. Wilson via Python-list
for path, dir, files in os.walk(myDestinationFolder): # for path, dir, files in os.walk(destfolder): print('The path is %s: ', path) print(files) os.chdir(mySourceFolder) if not os.path.isfile(myDestinationFolder + file): # if not os.path.isfile(destfolder + file): prin

Re: Wind Rose Plotting in Python

2019-09-05 Thread Ross Wilson
On Thu, 5 Sep 2562 at 22:00 Madhavan Bomidi wrote: > Hi, > > Can someone help me on how to make the wind rose plotting (similar to the > figure 2 in the paper: > https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/2011JD016386) in > Python? > > The input file contains the data in 4 columns:

Re: How to start gnuradio

2018-07-31 Thread Ross Wilson
I had a paddle through the manual at https://www.gnuradio.org/doc/doxygen/page_python_blocks.html and apparently some DSP operations use numpy. Ross On Wed, 1 Aug 2018 at 11:56 wrote: > > > After some research I found out that "sudo apt-get install python-numpy" > solved the problem. > > Can an

Re: Meaning of abbreviated terms

2018-05-12 Thread Ross Wilson
The "plist" abbreviation goes back to at least 1958 as it was used in the Lisp implementation [0].  And it may even predate Lisp.  I'm very sure that what actually went into a plist has often changed over the years, but the name persists. Lisp also used "association lists" [1] which were a key

Re: can't add variables to instances of built-in classes

2016-07-17 Thread Wilson Ong
> Use this feature sparingly, only when you know that there are going to be > many (millions rather than thousands) of Test instances. Why use it sparingly? Is it for extensibility? What if I'm pretty sure that my class is going to have exactly these attributes only? -- https://mail.python.org

Client support automation and self service

2016-05-03 Thread musoke wilson
avoid re-inventing the wheel regards Wilson -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-11 Thread Mel Wilson
On Tue, 12 May 2015 02:35:23 +1000, Steven D'Aprano wrote: > On Mon, 11 May 2015 11:37 pm, Mel Wilson wrote: > >> On Sun, 10 May 2015 14:12:44 -0500, boB Stepp wrote: >> >>> I have to admit being surprised by this, too. I am just now studying >>> on h

Re: anomaly

2015-05-11 Thread Mel Wilson
On Sun, 10 May 2015 14:12:44 -0500, boB Stepp wrote: > I have to admit being surprised by this, too. I am just now studying on > how to write my own classes in Python, and have come to realize that > doing this is *possible*, but the *surprise* to me is why the language > design allowed this to ac

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-10 Thread Mel Wilson
On Sun, 10 May 2015 13:43:03 -0700, Chris Seberino wrote: > Instead of learning only Scheme or only Python for a one semester intro > course, what about learning BOTH? Maybe that could somehow get the > benefits of both? > > I'm thinking that for the VERY beginning, Scheme is the fastest languag

Re: functions, optional parameters

2015-05-08 Thread Mel Wilson
On Sat, 09 May 2015 03:49:36 +1000, Chris Angelico wrote: > Yes, but can you *distinguish* them in terms of default argument versus > code object creation? How do you know that the function's code object > was created when compile() happened, rather than being created when the > function was defin

Re: How to properly apply OOP in the bouncing ball code

2015-05-08 Thread Mel Wilson
On Fri, 08 May 2015 08:40:34 -0700, Tommy C wrote: > I'm trying to apply OOP in this bouncing ball code in order to have > multiple balls bouncing around the screen. The objective of this code is > to create a method called settings, which controls all the settings for > the screen and the bouncin

Re: New to Python - block grouping (spaces)

2015-04-19 Thread Mel Wilson
On Mon, 20 Apr 2015 03:53:08 +1000, Steven D'Aprano wrote: > On Mon, 20 Apr 2015 02:03 am, Rustom Mody wrote: >> Well evidently some people did but fortunately their managers did not >> interfere. > > You are assuming they had managers. University life isn't exactly the > same as corporate cultu

Re: New to Python - block grouping (spaces)

2015-04-19 Thread Mel Wilson
On Sun, 19 Apr 2015 09:03:23 -0700, Rustom Mody wrote: > Now if Thomson and Ritchie (yeah thems the guys) could do it in 1970, > why cant we revamp this 45-year old archaic program=textfile system > today? Dunno. Why not? There's half of you right there. -- https://mail.python.org/mailman/lis

Re: Best search algorithm to find condition within a range

2015-04-08 Thread Mel Wilson
On Wed, 08 Apr 2015 07:56:05 -0700, jonas.thornvall wrote: > There is no need for inventing a new set of characters representing > 32-bit numbers. You will not be able to learn them by heart anyway, > unless they build on a interpretation system binaries, decimals. See Jorge Luis Borges, _Funes t

Re: Best search algorithm to find condition within a range

2015-04-08 Thread Mel Wilson
On Tue, 07 Apr 2015 23:19:49 -0700, jonas.thornvall wrote: > And you have just created 429496729 unique symbols ;), in a pencil > stroke. No. You did that, when you said base 429496729. Representing the symbols in a computer is no problem, any Python long int can do that. To display the symb

Re: parsing RSS XML feed for item value

2013-11-20 Thread Larry Wilson
Thank you folks, now I know what I don't know and have a solution. -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing RSS XML feed for item value

2013-11-20 Thread Larry Wilson
>>> feed.entries[0].w_current {'temperature': u'20.3', 'dewpoint': u'18.6', 'windgusts': u'29.6', 'rain': u'0.6', 'humidity': u'90', 'pressure': u'0.0', 'windspeed': u'22.2', 'winddirection': u'SSW'} >>> in the above I get the subitem as shown. How do I extract the label, values pairs? -- http

parsing RSS XML feed for item value

2013-11-19 Thread Larry Wilson
Wanting to parse out the the temperature value in the "http://rss.weather.com.au/nsw/newcastle"; === http://rss.weather.com.au/w.dtd";> Weather.com.au - Newcastle Weather http://www.weather.com.au/nsw/newcast

Re: file I/O and arithmetic calculation

2013-05-23 Thread Keira Wilson
not exactly for the homework, but as my starting point of learning thank you so much. -- http://mail.python.org/mailman/listinfo/python-list

Re: file I/O and arithmetic calculation

2013-05-23 Thread Keira Wilson
Dear all who involved with responding to my question - Thank you so much for your nice code which really helped me. -- http://mail.python.org/mailman/listinfo/python-list

file I/O and arithmetic calculation

2013-05-22 Thread Keira Wilson
Dear all, I would appreciate if someone could write a simple python code for the purpose below: I have five text files each of 10 columns by 10 rows as follows: file_one = 'C:/test/1.txt' file_two = 'C:/test/2.txt' . . . file_five = 'C:/test/5.txt' I want to calculate the mean of first row (10

Re: Missing logging output in Python

2013-03-12 Thread W. Matthew Wilson
NFO messages to sys.stderr > console = logging.StreamHandler() > console.setLevel(logging.INFO) > # set format that is cleaber for console use > formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') > # tell the handler to use this format >

Any logger created before calling logging.config.dictCOnfig is not configured

2013-03-06 Thread W. Matthew Wilson
t "log.root.level: {0}".format(log1.root.level) print "log.root.handlers: {0}".format(log1.root.handlers) print "log1.parent.level: {0}".format(log1.parent.level) print "log1.parent.handlers: {0}".format(log1.parent.handlers) print "log1.level: {0}".format(log1.level) print "log1.handlers: {0}".format(log1.handlers) print "log1.propagate: {0}".format(log1.propagate) print "log1.getEffectiveLevel(): {0}".format(log1.getEffectiveLevel()) ### SCRIPT END -- W. Matthew Wilson m...@tplus1.com http://tplus1.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Book for a C Programmer?

2012-05-24 Thread Jim Wilson
On 05/23/2012 07:45 PM, hsa...@gmail.com wrote: > I am trying to join an online class that uses python. I need to brush up on > the language quickly. Is there a good book or resource that covers it well > but does not have to explain what an if..then..else statement is? > > Thanks. My opinion:

Re: Programming D. E. Knuth in Python with the Deterministic Finite Automaton construct

2012-03-17 Thread Mel Wilson
Antti J Ylikoski wrote: > > In his legendary book series The Art of Computer Programming, > Professor Donald E. Knuth presents many of his algorithms in the form > that they have been divided in several individual phases, with > instructions to GOTO to another phase interspersed in the text of th

Re: Python is readable

2012-03-16 Thread Mel Wilson
Steven D'Aprano wrote: > On Fri, 16 Mar 2012 17:53:24 +, Neil Cerutti wrote: > >> On 2012-03-16, Steven D'Aprano >> wrote: >>> Ah, perhaps you're talking about *prescriptivist* grammarians, who >>> insist on applying grammatical rules that exist only in their own >>> fevered imagination. Sor

Re: A 'Python like' language

2012-03-03 Thread Mel Wilson
Paul Rubin wrote: > dreamingforw...@gmail.com writes: >>> hanging out on the Prothon list now and then, at least until we get >>> the core language sorted out? >> >> Haha, a little late, but consider this a restart. > > It wasn't til I saw the word "Prothon" that I scrolled back and saw you > wer

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-03-02 Thread Mel Wilson
Terry Reedy wrote: > The problem was another subtle bug in the current example": > self.hi_there["text"] = "Hello", > > The spurious comma at the end makes the value of the 'text' attribute a > one-elememt tuple and not just a string. I presume tcl-based tk handles > that in the manner a

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Mel Wilson
Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! Easily

Re: atexit.register in case of errors

2012-02-15 Thread Mel Wilson
Andrea Crotti wrote: > I have the following very simplified situation > > from atexit import register > > > def goodbye(): > print("saying goodbye") > > > def main(): > while True: > var = raw_input("read something") > > > if __name__ == '__main__': > register(goodby

Re: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Den wrote: > I disagree. In a bubble sort, one pointer points to the top element, > while another descents through all the other elements, swapping the > elements at the pointers when necessary. 'When I use a word,' Humpty Dumpty said, in rather a scornful tone, 'it means just what I choose it

RE: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Prasad, Ramit wrote: >> > for i in xrange (N-1): > for j in xrange (i, N): > if a[j] < a[i]: > a[i], a[j] = a[j], a[i] >> It's what Wikipedia says a selection sort is: put the least element in >> [0], the least of the remaining elements in [1], etc. > > If your only requi

Re: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Jabba Laci wrote: > Could someone please tell me what the following sorting algorithm is > called? > > Let an array contain the elements a_1, a_2, ..., a_N. Then: > for i in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > > It's so simple t

Re: M2crypto

2012-02-12 Thread Mel Wilson
zigi wrote: > Hello, > M2crypto > > __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > salt='12345678', i=1, padding=1) > > I wont write app, using M2crypto and I can not understand what are the > arguments: > key, iv, op, salt ? > What they do ? I assume you're reading in

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Mel Wilson
Steven D'Aprano wrote: > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Biting the bullet would mean supplying your own PRNG, under your control

Re: python reliability with EINTR handling in general modules

2012-02-02 Thread Mel Wilson
Dennis Lee Bieber wrote: > On Wed, 1 Feb 2012 23:25:36 -0800 (PST), oleg korenevich > wrote: > > >>Thanks for help. In first case all vars is python integers, maybe >>math.floor is redundant, but i'm afraid that same error with math >>module call will occur in other places of app, where math is

Re: Question about name scope

2012-02-01 Thread Mel Wilson
Dave Angel wrote: > I tried your experiment using Python 2.7 and Linux 11.04 > > > def f(a): > from math import sin, cos > return sin(a) + cos(a) > > print f(45) > > Does what you needed, and neatly. The only name added to the global > namspace is f, of type function. > > I was a b

Re: except clause syntax question

2012-01-31 Thread Mel Wilson
Chris Angelico wrote: > On Wed, Feb 1, 2012 at 9:03 AM, Duncan Booth > wrote: >> Abitrarily nested tuples of exceptions cannot contain loops so the code >> simply needs to walk through the tuples until it finds a match. > > Is this absolutely guaranteed? The C API for CPython provides: > (Py2) h

Re: except clause syntax question

2012-01-31 Thread Mel Wilson
Charles Yeomans wrote: > To catch more than one exception type in an except block, one writes > > except (A, B, C) as e: > > I'm wondering why it was decided to match tuples, but not lists: > > except [A, B, C] as e: > > The latter makes more sense semantically to me -- "catch all exception >

Re: except clause syntax question

2012-01-30 Thread Mel Wilson
Charles Yeomans wrote: > To catch more than one exception type in an except block, one writes > > except (A, B, C) as e: > > I'm wondering why it was decided to match tuples, but not lists: > > except [A, B, C] as e: > > The latter makes more sense semantically to me -- "catch all exception >

Re: verify the return value of a function

2012-01-20 Thread Mel Wilson
Jean-Michel Pichavant wrote: > isinstance is fine, if you could find the source where it is > discouraged... Could be a consequence of some specific context. > However, checking types in OOP is in general a failure. Unitary tests > are possibly an exception. I think it's discouraged when people t

Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Mel Wilson
Adam Funk wrote: > (Warning: this question obviously reflects the fact that I am more > accustomed to using Java than Python.) > > Suppose I'm creating a class that represents a bearing or azimuth, > created either from a string of traditional bearing notation > ("N24d30mE") or from a number indi

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-23 Thread Mel Wilson
Steven D'Aprano wrote: > On Fri, 23 Dec 2011 13:13:38 +, Neil Cerutti wrote: >> On 2011-12-23, Neil Cerutti wrote: >> ...you know, assuming it wouldn't break existing code. ;) > > It will. Python's default argument strategy has been in use for 20 years. > Some code will rely on it. I know min

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-22 Thread Mel Wilson
Chris Angelico wrote: > On Fri, Dec 23, 2011 at 1:13 AM, Hans Mulder wrote: >> How about: >> >> >> ... >> >> >> More more readable! And it's a standard! > > Unfortunately it's not Pythonic, because indentation is insignificant. Easy-peasy: Mel. > We need to ado

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Mel Wilson
Chris Angelico wrote: > It's no more strange than the way some people omit the u from colour. :) Bonum Petronio Arbiteri, bonum mihi. Mel. -- http://mail.python.org/mailman/listinfo/python-list

Re: correct usage of a generator?

2011-11-28 Thread Mel Wilson
Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 >

Re: Close as Many Files/External resourcs as possible in the face of exceptions

2011-11-21 Thread Mel Wilson
GZ wrote: > Here is my situation. A parent object owns a list of files (or other > objects with a close() method). The close() method can sometimes fail > and raise an exception. When the parent object's close() method is > called, it needs to close down as many files it owns as possible, even >

Re: Use and usefulness of the as syntax

2011-11-12 Thread Mel Wilson
candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo > > > > Now, I was wondering about the usefulness in everyday programming of the > as syntax within an import statement. [ ... ] It gives you an out in a case like

Re: indexing lists/arrays question

2010-05-13 Thread Matthew Wilson
On Thu 13 May 2010 10:36:58 AM EDT, a wrote: > this must be easy but its taken me a couple of hours already > > i have > > a=[2,3,3,4,5,6] > > i want to know the indices where a==3 (ie 1 and 2) > > then i want to reference these in a > > ie what i would do in IDL is > > b=where(a eq 3) > a1=a(b)

Need help using callables and setup in timeit.Timer

2010-05-12 Thread Matthew Wilson
I want to time some code that depends on some setup. The setup code looks a little like this: >>> b = range(1, 1001) And the code I want to time looks vaguely like this: >>> sorted(b) Except my code uses a different function than sorted. But that ain't important right now. Anyhow, I

How to measure speed improvements across revisions over time?

2010-05-10 Thread Matthew Wilson
I know how to use timeit and/or profile to measure the current run-time cost of some code. I want to record the time used by some original implementation, then after I rewrite it, I want to find out if I made stuff faster or slower, and by how much. Other than me writing down numbers on a piece o

How do I begin debugging a python memory leak?

2009-09-16 Thread Matthew Wilson
I have a web app based on TurboGears 1.0. In the last few days, as traffic and usage has picked up, I noticed that the app went from using 4% of my total memory all the way up to 50%. I suspect I'm loading data from the database and somehow preventing garbage collection. Are there any tools that

Re: os.execv Overhead

2009-09-16 Thread Jim Wilson
On 09/16/2009 11:12 AM, mark.mcdow...@gmail.com wondered about: > overhead of [fork/exec]: An alternative might be os.spawn?(), etal. It might run a tiny bit faster because it combines the two operations, but I think you're pretty close to the metal. Jim -- http://mail.python.org/mailman/list

Question about unpickling dict subclass with custom __setstate__

2009-09-10 Thread Matthew Wilson
I subclassed the dict class and added a __setstate__ method because I want to add some extra steps when I unpickle these entities. This is a toy example of what I am doing: class Entity(dict): def __setstate__(self, d): log.debug("blah...") Based on my experiments, the

Re: How to refer to data files without hardcoding paths?

2009-09-08 Thread Matthew Wilson
On Mon 07 Sep 2009 10:57:01 PM EDT, Gabriel Genellina wrote: > I prefer > to use pkgutil.get_data(packagename, resourcename) because it can handle > those cases too. I didn't know about pkgutil until. I thought I had to use setuptools to do that kind of stuff. Thanks! Matt -- http://mail.pyth

Re: Soap with python?

2009-09-08 Thread Jim Wilson
On 09/08/2009 08:40 AM, Otto Hellwig wrote: > reccommend [sic ...] the best soap library ... Client side only? Suds (https://fedorahosted.org/suds/). Accept no subsitute! -- http://mail.python.org/mailman/listinfo/python-list

How to refer to data files without hardcoding paths?

2009-09-05 Thread Matthew Wilson
When a python package includes data files like templates or images, what is the orthodox way of referring to these in code? I'm working on an application installable through the Python package index. Most of the app is just python code, but I use a few jinja2 templates. Today I realized that I'm

supported versions policy?

2009-07-31 Thread Gary Wilson
Does Python have a formal policy on the support lifetime (bug fixes, security fixes, etc.) for major and minor versions? I did a bit of searching on the Python web site and this group, but didn't find anything. If there is a policy posted somewhere (and I just didn't dig deep enough), would someo

Does cProfile include IO wait time?

2009-07-04 Thread Matthew Wilson
I have a command-line script that loads about 100 yaml files. It takes 2 or 3 seconds. I profiled my code and I'm using pstats to find what is the bottleneck. Here's the top 10 functions, sorted by internal time: In [5]: _3.sort_stats('time').print_stats(10) Sat Jul 4 13:25:40 2009

Where does setuptools live?

2009-07-04 Thread David Wilson
I'm trying to create a patch for a diabolical issue I keep running into, but I can't seem to find the setuptools repository. Is it this one? http://svn.python.org/view/sandbox/trunk/setuptools/ It's seen no changes in 9 months. The issue in question is its (ab)use of .svn to directly read wo

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 03:02:44 PM EDT, Gustavo Narea wrote: > Hello, everyone. > > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements

Re: Is this pylint error message valid or silly?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 02:55:52 AM EDT, Terry Reedy wrote: >> if c == "today": >> c = datetime.today() > > Now I guess that you actually intend c to be passed as a datetime > object. You only used the string as a type annotation, not as a real > default value. Something li

Is this pylint error message valid or silly?

2009-06-18 Thread Matthew Wilson
Here's the code that I'm feeding to pylint: $ cat f.py from datetime import datetime def f(c="today"): if c == "today": c = datetime.today() return c.date() And here's what pylint says: $ pylint -e f.py No config file found, using defau

Re: itertools.intersect?

2009-06-10 Thread David M. Wilson
On Jun 10, 11:24 pm, David Wilson wrote: > Hi, > > During a fun coding session yesterday, I came across a problem that I > thought was already solved by itertools, but on investigation it seems > it isn't. > > The problem is simple: given one or more ordered sequences,

Re: itertools.intersect?

2009-06-10 Thread David M. Wilson
On Jun 11, 12:59 am, Jack Diederich wrote: > On Wed, Jun 10, 2009 at 6:24 PM, David Wilson wrote: > > During a fun coding session yesterday, I came across a problem that I > > thought was already solved by itertools, but on investigation it seems > > it isn't. > >

Re: itertools.intersect?

2009-06-10 Thread David M. Wilson
On Jun 11, 3:05 am, Chris Rebert wrote: > On Wed, Jun 10, 2009 at 5:53 PM, Mensanator wrote: > > On Jun 10, 5:24 pm, David Wilson wrote: > >> Hi, > > >> During a fun coding session yesterday, I came across a problem that I > >> thought was already solve

itertools.intersect?

2009-06-10 Thread David Wilson
Hi, During a fun coding session yesterday, I came across a problem that I thought was already solved by itertools, but on investigation it seems it isn't. The problem is simple: given one or more ordered sequences, return only the objects that appear in each sequence, without reading the whole se

Where should I store docs in my project?

2009-06-09 Thread Matthew Wilson
I used paster to create a project named pitz. I'm writing a bunch of user documentation. Where should I put it? The project looks a little like this: /home/matt/projects/pitz setup.py pitz/ __init__.py # has my project code docs/ # has my reST files

How to test python snippets in my documents?

2009-05-26 Thread Matthew Wilson
I'm using a homemade script to verify some code samples in my documentation. Here it is: #! /usr/bin/env python2.6 # vim: set expandtab ts=4 sw=4 filetype=python: import doctest, os, sys def main(s): "Run doctest.testfile(s, None)" return doctest.testfile(s, No

How can I get access to the function called as a property?

2009-05-24 Thread Matthew Wilson
I use a @property decorator to turn some methods on a class into properties. I want to be able to access some of the attributes of the original funtion, but I don't know how to get to it. Any ideas? Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: I need help building a data structure for a state diagram

2009-05-24 Thread Matthew Wilson
On Sun 24 May 2009 03:42:01 PM EDT, Kay Schluehr wrote: > > General answer: you can encode finite state machines as grammars. > States as non-terminals and transition labels as terminals: > > UNSTARTED: 'start' STARTED > STARTED: 'ok' FINISHED | 'cancel' ABANDONED > ABANDONED: 'done' > FINISHED: 'd

I need help building a data structure for a state diagram

2009-05-24 Thread Matthew Wilson
I'm working on a really simple workflow for my bug tracker. I want filed bugs to start in an UNSTARTED status. From there, they can go to STARTED. >From STARTED, bugs can go to FINISHED or ABANDONED. I know I can easily hard-code this stuff into some if-clauses, but I expect to need to add a lo

Re: How should I use grep from python?

2009-05-07 Thread Matthew Wilson
On Thu 07 May 2009 09:25:52 AM EDT, Tim Chase wrote: > While it doesn't use grep or external processes, I'd just do it > in pure Python: Thanks for the code! I'm reluctant to take that approach for a few reasons: 1. Writing tests for that code seems like a fairly large amount of work. I think I

Re: How should I use grep from python?

2009-05-07 Thread Matthew Wilson
On Thu 07 May 2009 09:09:53 AM EDT, Diez B. Roggisch wrote: > Matthew Wilson wrote: >> >> As of May 2009, what is the recommended way to run an external process >> like grep and capture STDOUT and the error code? > > subprocess. Which becomes pretty clear when readi

How should I use grep from python?

2009-05-07 Thread Matthew Wilson
I'm writing a command-line application and I want to search through lots of text files for a string. Instead of writing the python code to do this, I want to use grep. This is the command I want to run: $ grep -l foo dir In other words, I want to list all files in the directory dir that contain

Re: How to walk up parent directories?

2009-05-04 Thread Matthew Wilson
On Sun 03 May 2009 09:24:59 PM EDT, Ben Finney wrote: > Not every simple function belongs in the standard library :-) Thanks for the help with this! Maybe I'm overestimating how often people need this walkup function. Matt -- http://mail.python.org/mailman/listinfo/python-list

How to walk up parent directories?

2009-05-03 Thread Matthew Wilson
Is there already a tool in the standard library to let me walk up from a subdirectory to the top of my file system? In other words, I'm looking for something like: >>> for x in walkup('/home/matt/projects'): ... print(x) /home/matt/projects /home/matt /home / I know I

  1   2   3   >