Re: How to detect a double's significant digits

2005-05-05 Thread Charles Krug
On 5 May 2005 10:37:00 -0700, mrstephengross <[EMAIL PROTECTED]> wrote: > Hi all... How can I find out the number of significant digits (to the > right of the decimal place, that is) in a double? At least, I *think* > that's what I'm asking for. For instance: > > 0.103 --> 3 > 0.0103 --> 4 > 0.001

Re: performance of Nested for loops

2005-05-20 Thread Charles Krug
On 20 May 2005 15:35:10 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Is there a better way to code nested for loops as far as performance is > concerned. > > what better way can we write to improve the speed. > for example: > N=1 > for i in range(N): >for j in range(N): >d

Re: ctypes: error passing a list of str to a fortran dll

2007-06-04 Thread Charles Sanders
may (but probably won't) have extensions that allow you to pass an array of character pointers. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing two lists and returning "position"

2007-06-21 Thread Charles Sanders
Paul Rubin wrote: > > from itertools import izip > pos = map(dict(izip(l2, count())).__getitem__, l1) or probably less efficiently ... >>> l1 = [ 'abc', 'ghi', 'mno' ] >>> l2 = [ 'abc', 'def', 'ghi', '

Re: comparing two lists and returning "position"

2007-06-25 Thread Charles Sanders
] should all take take running time proportional to (len(l1)+len(l2))*log(len(l2)) For len(l1)=4,000 and len(l2)=10,000,000 Paul's suggestion is likely to take about 1/100th of the time to run, ie be about 100 times as fast. I was trying to point out a somewhat clearer and simpler (but sl

Re: Strange terminal behavior after quitting Tkinter application

2007-04-18 Thread Charles Sanders
led to ensure (as far as possible) that the cleanup occurs if the process is killed. This also applies to vi and similar programs that take total control of the terminal. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare regular expressions

2007-04-19 Thread Charles Sanders
these algorithms are the basis of lex/flex and similar utilities, as well as the regular expression handling of many languages. Of course, I would like to emphasise that all this is based on memory of university courses more than 20 years ago, so the details could be wrong. Charles -- http://m

Re: Strange terminal behavior after quitting Tkinter application

2007-04-24 Thread Charles Sanders
indow (ie you call the destroy method on the main window) or if it has some special Tkinter meaning. Presumably this routine cleans things up before calling sys.exit or an equivalent. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Python not giving free memory back to the os get's me in real problems ...

2007-04-25 Thread Charles Sanders
top of the heap exceeds the threshold. > Asking on the gnu libc mailing list would probably provide a > more authoritative answer. I'd wager that they even know what > other non-Gnu libc implementations do. Agreed, they would be authoritative for GNU libc. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: scaling

2007-05-01 Thread Charles Sanders
-minvalue) yield min(top,max(0,scaled_value)) clearer, but I am aware that others disagree with this. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread Charles Sanders
v = y.eval() # Evaluates all elements, returning Xarray z = ((a+b)*(c+d)).eval() # Also evaluates all elements Whether it would be any faster is doubtful, but it would eliminate the temporaries. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: 4 quadrant atan

2007-05-03 Thread Charles Sanders
es. NaNs and infinities would add additional cases, as may the need to preserve accuracy near zero. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: interesting exercise

2007-05-08 Thread Charles Sanders
27;ca', 'cb', 'cc'] len(permute('13579',3)) = 125 or even this monstrosity ... def permute2( s, n ): return [ ''.join([ s[int(i/len(s)**j)%len(s)] for j in range(n-1,-1,-1)]) for i in range(len(s)**n) ] print "permute2(&#x

Re: Multiple regex match idiom

2007-05-09 Thread Charles Sanders
r,f) in re_list: matchob = r.match(line) if matchob: f( line, matchob ) break f(line,m) Probably better ways than this exist. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: interesting exercise

2007-05-09 Thread Charles Sanders
[EMAIL PROTECTED] wrote: > On May 9, 1:13 am, Charles Sanders <[EMAIL PROTECTED]> > wrote: [snip] >> or even this monstrosity ... >> >> def permute2( s, n ): >>return [ ''.join([ s[int(i/len(s)**j)%len(s)] >> for j in range(n-1,-1,-1)

Re: preferred windows text editor?

2007-05-10 Thread Charles Sanders
mmands can be used to reduce the typing if you are fanatical. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Regexes: How to handle escaped characters

2007-05-18 Thread Charles Sanders
rint "Guarded search text='%s' excluding %s %s matches" % (txt,exc,len(mtch)) for m in mtch: print m.group(), 'at', m.start() Guarded search text='axbycz' excluding [3] 2 matches x at 1 z at 5 Guarded search text='Hollo' excluding [4] 0 matches Simply finds all the (non-overlapping) matches and rejects any that include one of the excluded columns (the "y" in the first case and the final "o" in the second). Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: installing cx_Oracle.

2007-05-24 Thread Charles Sanders
>> doesn't matter. What matters is the value that the name has >> at the time the command is run: [snip] > Just tried on a FreeBSD 6.1 development box with stock /bin/sh and it > works there too... As far as I know, it has been like this since the introduction of the Bourne shel

Long double in Python

2007-05-25 Thread Charles Vejnar
mpiling Python, Python Float object becomes "long double" C type instead of "double" ? 2nd solution : Numpy. In memory, a "numpy.longdouble" is a C "long double" or a string ? Thank you. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Long double in Python

2007-05-26 Thread Charles Vejnar
n. I try to build a module with Swig but I didn't find the C function to use in the wrapper to have a "numpy.longdouble" (or the equivalent in gmpy). Is it something possible ? Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-30 Thread Charles Sanders
;t know if any still do it, but old unices used to detect on logon if you typed your user name and password in all caps and then turned on the iuclc and olcuc options, assuming that the reason for the all caps was a upper case only terminal - great fun if you hit caps lock by accident. Charles

newbie: self.member syntax seems /really/ annoying

2007-09-12 Thread Charles Fox
I've just started playing around with Python, as a possible replacement for a mix of C++, Matlab and Lisp. The language looks lovely and clean with one huge exception: I do a lot of numerical modeling, so I deal with objects (like neurons) described mathematically in papers, by equations like

Re: newbie: self.member syntax seems /really/ annoying

2007-09-12 Thread Charles Fox
Thanks guys -- yeah these two stategies (short s.varname; and explicit rescoping, a=self.a etc) are more or less what I was using. That's still kind of annoying though. The s.varname approach still makes numerical code much harder to read. I had a nasty bug with the boilerplate approach when for

Re: newbie: self.member syntax seems /really/ annoying

2007-09-13 Thread Charles Fox
hmm, I guess this is the difference between numerical programming and the rest -- sure, if I was writing a database server or something it would be great to have thisObject.veryLongName to know what everything is -- however when you are implementing a model from a published paper, the variables ten

How to tell easy_install that a package is already installed

2007-03-20 Thread Charles Sanders
installed, while still installing any other dependencies ? Would the best option be to just use the --no-deps option and see if it works ? Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with algorithm

2007-04-12 Thread Charles Sanders
z zx zy zz for y in m_from_n( [0,1], 3 ): print y [0, 0, 0] [0, 0, 1] [0, 1, 0] [0, 1, 1] [1, 0, 0] [1, 0, 1] [1, 1, 0] [1, 1, 1] for y in m_from_n( "abcdefghijklmnopqrstuvwxyz", 4 ): print ''.join(y) should more or less do what you want. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with algorithm

2007-04-12 Thread Charles Sanders
sion instead of iteration. I have yet to completely wean myself off Fortran style thinking. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: strange behaviour sys.argv

2007-04-16 Thread Charles Sanders
m $HOST) 'critical'(From $SEVERITY) '"192.168.1.101' (Leading '"' from \", rest from $TRAP, blank seperated) '192.168.1.101' (from $TRAP, blank seperated) 'SNMPv2-MIB::sysUpTime.0' and so on for the rest of the $TARP string, splitting it at white space. The last part of $TRAP, '"public"', has a double quote appended from the \". Python is giving exactly what the shell has given it in both cases. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: strange behaviour sys.argv

2007-04-16 Thread Charles Sanders
t; should pass TRAP as a single arg Charles -- http://mail.python.org/mailman/listinfo/python-list

Hide comments in emacs python mode?

2007-10-30 Thread Charles Fox
Hi guys, I'm playing with Python in emacs, with python mode. I'd like to be able to press a key to toggle the code comments on and off -- to switch between beautiful clean Python code, and the full text that tells me what's going in in English. Is this currently possible? I know there is a hide

Re: python in academics?

2007-11-01 Thread Charles Allen
"early" compared to most course sequences: <http://www4.ncsu.edu/~rwchabay/mi/> -- Charles Allen -- http://mail.python.org/mailman/listinfo/python-list

Games on ps2

2007-11-09 Thread Charles Tunley
Hi I need a list of games on ps2 and I'm in the united states, oklahoma <*Charli jo*> -- http://mail.python.org/mailman/listinfo/python-list

array.shape() gives TypeError: 'tuple' object is not callable

2007-12-10 Thread Charles Fox
ceback (most recent call last): File "", line 1, in ? TypeError: 'tuple' object is not callable >>> thanks charles -- http://mail.python.org/mailman/listinfo/python-list

Re: python vs perl lines of code

2006-05-16 Thread Charles DeRykus
uld devolve into a pissing contest. This subject thread may be of great interest but I think an language advocacy mailing list would be a better forum. -- Charles DeRykus -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with regex, how to conclude more than one character

2008-11-06 Thread Charles Yan
Really thanks for quickly reply Chris! Actually I tried BeautifulSoup and it's great. But I'm not very familiar with it and it need more codes to parse the html and get the right text. I think regexp is more convenient if there is a way to filter out the list just in one line:) I did this all the w

Problem with sqlite3 cursor and imbricated for loop

2008-11-11 Thread Charles V.
[0] c.execute("select * from stocks where price<20") for s in c: print ' '+s[0] c.close() - It is a adapted copy of the example in the Python documentation. But I was expecting the output as with MySQL engine but, here, I get only: 2006-01-05 2006-01-07 2006-01-08 It seems the second call to execute modify the first cursor. Is it normal ? How am I suppose to write this ? Thanks Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Charles V.
t ' '+sp[0] c.close() This solution gives the correct answer: 2006-01-05 2006-01-07 2006-01-08 2006-01-06 2006-01-07 2006-01-08 2006-01-07 2006-01-07 2006-01-08 2006-01-08 2006-01-07 2006-01-08 Do you think it is a good solution (any drawbacks ?) ? Thanks again. Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Charles V.
en for MySQLdb won't be compatible with sqlite3 (even if I am using standard SQL). In fact I don't really understand why the iterator isn't in some way "encapsulated". Does anybody tried to implemented this functionality ? Cheers, Charles -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-22 Thread Charles Hixson
On Thursday 22 May 2008 13:30:07 Nick Craig-Wood wrote: > ... > >From Armstrong's book: The expression Pattern = Expression causes > > Expression to be evaluated and the result matched against Pattern. The > match either succeeds or fails. If the match succeeds any variables > occurring in Pattern

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Charles Mason
And for such a behavior they've termed "monkeying" Thus, the coinage "Monkeypatching" for what you want to do: http://mail.python.org/pipermail/python-dev/2008-January/076194.html There are a group of people who think "monkeypatching is destroying ruby." You still probably should avoid it for p

Re: Data structure recommendation?

2008-04-07 Thread Charles Mason
If you can imply a partial order on your ranges then you can get O(n lg n) random access using a heap data structure. You'll have to implement your own heap, but heap search is easy to implement (it's Heapify that might require a little thinking). This will only work, of course, if your ranges ar

Want to re-pack() a Frame displaying a collection

2006-03-19 Thread Charles Krug
List, I'd like to do the following with Tkinter's Frame() object: 1. Display a collection of pack()-able objects. Easy. Done. I hold the objects in a dictionary, mostly so that the owning program can refer to them uniformly. 2. Whenever the collection is added to or deleted from, re-pack() th

Re: What's The Best Editor for python

2006-03-26 Thread Charles Krug
On 2006-03-26, Andrew Gwozdziewycz <[EMAIL PROTECTED]> wrote: > If you want something that won't get in your way, you should really > use /bin/ed. It's probably simpler to use then searching the archives. > /bin/ed will also run in cygwin for windows. > >>> Can one of you say to me what's the bes

Exception class documentation

2010-02-05 Thread Charles Yeomans
I am so far unable to find the information I want about the Exception class. Information like the signature of __init__ seems to be unavailable. Any suggestions where I might find such information? Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception class documentation

2010-02-05 Thread Charles Yeomans
On Feb 5, 2010, at 2:13 PM, Gerald Britton wrote: On Fri, Feb 5, 2010 at 12:55 PM, Charles Yeomans > wrote: I am so far unable to find the information I want about the Exception class. Information like the signature of __init__ seems to be unavailable. Any suggestions where I might f

Re: Exception class documentation

2010-02-06 Thread Charles Yeomans
On Feb 6, 2010, at 8:09 AM, Gerald Britton wrote: If you browse the Python source tree, you should be able to find it. http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045&view=markup Perfect (even if I have to read C). Thanks. Charles Yeomans --

TkTable and Python 3.1

2010-02-15 Thread Charles McKnight
HI All, I'm fiddling around with Python and I'm trying to get tktable to work with Python 3.1 on Apple OS X 10.6 (Snow Leopard). Has anyone successfully accomplished this task, and if so, can you share how that you got it working? I've got Darwin Ports installed (current version) and I'm using Pyt

Re: Algorithm for generating pitch-class sets in prime form

2011-02-04 Thread Charles Turner
Hi- Do you knowof Christopher Ariza's AthenaCL? <http://www.flexatone.net/athenaInfo.html#athenaFeatAnalytic> HTH, Charles -- http://mail.python.org/mailman/listinfo/python-list

Google job leads

2010-08-01 Thread Charles Jo
move in that direction) for career-defining opportunities. If there are individuals and organizations that I should reach out to, please do let me know -- my office contact information is below. Google office: Charles Jo Sales Recruiter, Google 650.253.0375 office 408.668.4226 cell charle

Re: preferring [] or () in list of error codes?

2009-06-08 Thread Charles Yeomans
he meaning of this: if a in (1,2,3): Actually, I might be -- I think of a tuple first as a single thing, as opposed to a list or map, which I see first as a collection of other things. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Measuring Fractal Dimension ?

2009-06-17 Thread Charles Yeomans
uniformly. On a closed interval, any continuous function is uniformly continuous. Isn't (-∞, ∞) closed? Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-17 Thread Charles Yeomans
ider this practice to be kludgy; my experience with RAII is pretty good. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-17 Thread Charles Yeomans
On Jun 17, 2009, at 9:43 PM, Steven D'Aprano wrote: On Wed, 17 Jun 2009 07:49:52 -0400, Charles Yeomans wrote: Even CPython doesn't rely completely on reference counting (it has a fallback gc for cyclic garbage). Python introduced the "with" statement to get away fro

Re: Measuring Fractal Dimension ?

2009-06-18 Thread Charles Yeomans
On Jun 18, 2009, at 2:19 PM, David C. Ullrich wrote: On Wed, 17 Jun 2009 07:37:32 -0400, Charles Yeomans wrote: On Jun 17, 2009, at 2:04 AM, Paul Rubin wrote: Jaime Fernandez del Rio writes: I am pretty sure that a continuous sequence of curves that converges to a continuous curve

Re: Measuring Fractal Dimension ?

2009-06-19 Thread Charles Yeomans
atters, but his defintion of "polygonal path" is, _if_ we're being very careful, self-contradictory. So I don't think we can count that paper as a suitable reference for what the _standard_ definitions are; the standard definitions are not self-contradictory this way. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Measuring Fractal Dimension ?

2009-06-20 Thread Charles Yeomans
ation. Ie, a curve in the plane _is_ a continuous function from an interval to the plane, and a subset of the plane is not a curve. Officially, anyway. This simply isn't true. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Measuring Fractal Dimension ?

2009-06-22 Thread Charles Yeomans
On Jun 22, 2009, at 8:46 AM, pdpi wrote: On Jun 19, 8:13 pm, Charles Yeomans wrote: On Jun 19, 2009, at 2:43 PM, David C. Ullrich wrote: Hmm. You left out a bit in the first definition you cite: "A simple closed curve J, also called a Jordan curve, is the image of a continuou

Re: Measuring Fractal Dimension ?

2009-06-22 Thread Charles Yeomans
On Jun 22, 2009, at 2:16 PM, David C. Ullrich wrote: On Mon, 22 Jun 2009 10:31:26 -0400, Charles Yeomans wrote: On Jun 22, 2009, at 8:46 AM, pdpi wrote: On Jun 19, 8:13 pm, Charles Yeomans wrote: On Jun 19, 2009, at 2:43 PM, David C. Ullrich wrote: Hmm. You left out a bit in the

Re: Python simple web development

2009-06-26 Thread Charles Yeomans
Or you could try my approach and write your own web app. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginning with Python; the right choice?

2009-06-27 Thread Charles Yeomans
is always evolving and there might be new tutorials out there. As an alternative to Python, I'd suggest REALbasic. Its main disadvantage is that it is not free. But you get a language, editor, and two application frameworks in one package. Charles Yeomans -- http://mail.python.org/mailman/

Re: Running Invisible console Application

2009-06-29 Thread Charles Yeomans
On Jun 29, 2009, at 7:28 AM, Elf Scripter wrote: Hi, i have a console application that i want to ran (invisible) as a daemon, how can i do that? Search the web for python + daemon. I found plenty of code, including mostly prewritten solutions, for my own work. Charles Yemans -- http

Re: Basic question from pure beginner

2009-07-01 Thread Charles Yeomans
ord: ") guess = str(guess) if guess != password: print "Access Denied" attemptcount = attemptcount + 1 else: print "Password Confirmed" correct_password_given = True break Charles Yeomans On Jul 1, 2009, at 3:58 AM, sato.ph...@gmail.com wro

Re: PEP 376

2009-07-02 Thread Charles Yeomans
, MD5 was intended to be a cryptographic hash function, not a checksum. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Charles Yeomans
I figured some sort of HTTP event / RPC type of would be a good idea? Are there any modules I should know about, or guidelines I could read, that could aid me in the design of the API? Thank you, :) I'd suggest the O'Reilly book "RESTful Web Services". Cha

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Charles Yeomans
code as data sanitizing, but rather as a precondition. And with that description, the use of an assert statement that might be compiled away is not unreasonable; indeed, it certainly is so in the context of design by contract. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Charles Yeomans
remove the first occurence. Doing that while no exception is raised is also uncool, right? Some suggestions? L = [0, 0, 0, 1, 1, 1, 0] M = [x for x in L if x !=0] Charles Yeomans-- http://mail.python.org/mailman/listinfo/python-list

Re: Clarity vs. code reuse/generality

2009-07-10 Thread Charles Yeomans
for enforcing pre-conditions and post- conditions, unless such conditions are mere "guidelines", because assert can be switched off at runtime. Unless, of course, you want to switch off such checking at runtime, as you might when using a design-by-contract approach. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming by Contract

2009-08-11 Thread Charles Yeomans
the input/output of functions; on the contrary, Bertrand Meyer, the inventor of DbC, claims that DbC allows one to eliminate such redundancy, and the resulting overhead. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming by Contract

2009-08-14 Thread Charles Yeomans
On Aug 14, 2009, at 12:09 AM, Scott David Daniels wrote: Charles Yeomans wrote: On Aug 11, 2009, at 3:30 PM, Ethan Furman wrote: Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http

Re: How to create functors?

2009-08-20 Thread Charles Yeomans
sorts of functions and types (strictly "categories") they can accept, presumably to make them mathematically well-behaved. Have I got it correct? I don't think so. Paul Rubin's square example was, I thought, particularly instructive. Charles Yeomans-- http://mail.python.org/mailman/listinfo/python-list

Re: why python got less developers ?

2009-08-28 Thread Charles Yeomans
faster all the time and languages like python or ruby are fast enough. any comment ? Many developers suffer from performance anxiety. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Re: Q on explicitly calling file.close

2009-09-09 Thread Charles Yeomans
nally: f = f.close() In addition to fixing the latent bug in the second simple template, I took the opportunity to correct your heinous violation of command- query separation. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list

Fwd: ftplib sending data out of order

2017-06-30 Thread Charles Wilt
still seeing data being sent out of order. Honestly, I suspect some sort of Windows issue; as Windows is the only thing that's changed recently. But I'm running Win10 and another developer that's seeing it is running Win8. I'd appreciate any guidance you may have. Thank you, Charles Wilt -- https://mail.python.org/mailman/listinfo/python-list

possible bug in while loop test

2017-09-02 Thread Charles Hixson
python3 --version Python 3.5.3 Running on Debian stretch In this code s is a string parameter while (j < k and \ (s[j].isalnum()) or \ (s[j] in seps and s[j+1].isalnum()) ): j = j + 1 print ("i = {0}, j = {1}, k = {2}, len[s] = {3}". \ format(i,

Multiprocessing interactive processes with connections

2016-09-06 Thread nospam . Charles Hixson
I want to process a bunch of processes that all talk to each other. I've figured out how to do this using queues with the main process as the mail handler, but I'd rather have them talk directly. If I use connections, then I can pass the pipes to the processes, but there doesn't seem to be anythin

recursive methods require implementing a stack?

2016-04-06 Thread Charles T. Smith
I just tried to write a recursive method in python - am I right that local variables are only lexically local scoped, so sub-instances have the same ones? Is there a way out of that? Do I have to push and pop my own simulated stack frame entry? -- https://mail.python.org/mailman/listinfo/python

Re: recursive methods require implementing a stack?

2016-04-06 Thread Charles T. Smith
On Wed, 06 Apr 2016 20:28:47 +, Rob Gaddi wrote: > Charles T. Smith wrote: > >> I just tried to write a recursive method in python - am I right that local >> variables are only lexically local scoped, so sub-instances have the same >> ones? Is there a way out of that

how to get names of attributes

2015-12-30 Thread Charles T. Smith
Hi, How can I get *all* the names of an object's attributes? I have legacy code with mixed new style classes and old style classes and I need to write methods which deal with both. That's the immediate problem, but I'm always running into the need to understand how objects are linked, in par

Re: how to get names of attributes

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 11:51:19 +, Charles T. Smith wrote: > Hi, > > How can I get *all* the names of an object's attributes? I have legacy > code with mixed new style classes and old style classes and I need to > write methods which deal with both. That's the imm

Re: how to get names of attributes

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 11:51:19 +, Charles T. Smith wrote: > Hi, > > How can I get *all* the names of an object's attributes? I have legacy > code with mixed new style classes and old style classes and I need to > write methods which deal with both. That's the imm

using __getitem()__ correctly

2015-12-30 Thread Charles T. Smith
Hello, I thought __getitem__() was invoked when an object is postfixed with an expression in brackets: - abc[n] and __getattr__() was invoked when an object is postfixed with an dot: - abc.member but my __getitem__ is being invoked at this time, where there's no subscript (going into a s

Re: how to get names of attributes

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 23:50:03 +1100, Chris Angelico wrote: > On Wed, Dec 30, 2015 at 11:40 PM, Charles T. Smith > wrote: >> Oh! >> >> Although the referenced doc says: >> >> "For compatibility reasons, classes are still old-style by default." >

Re: using __getitem()__ correctly

2015-12-30 Thread Charles T. Smith
On Thu, 31 Dec 2015 00:11:24 +1100, Chris Angelico wrote: > On Wed, Dec 30, 2015 at 11:57 PM, Charles T. Smith > wrote: >> Hello, >> >> I thought __getitem__() was invoked when an object is postfixed with an >> expression in brackets: >> >> - abc[n] &

Re: how to get names of attributes

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 14:10:14 +, Mark Lawrence wrote: > On 30/12/2015 11:51, Charles T. Smith wrote: >> Hi, >> >> Does anyone know *why* the __members__ method was deprecated, to be >> replaced by dir(), which doesn't tell the truth (if only it took an &

Re: using __getitem()__ correctly

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 08:35:57 -0700, Ian Kelly wrote: > On Dec 30, 2015 7:46 AM, "Charles T. Smith" > wrote: >> As is so often the case, in composing my answer to your question, I >> discovered a number of problems in my class (e.g. I was calling >> __getitem__()

Re: using __getitem()__ correctly

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 13:40:44 -0700, Ian Kelly wrote: > On Wed, Dec 30, 2015 at 9:58 AM, Charles T. Smith >> The problem is that then triggers the __getitem__() method and I don't >> know how to get to the attributes without triggering __getattr__(). >> >> It&#

Re: using __getitem()__ correctly

2015-12-30 Thread Charles T. Smith
On Wed, 30 Dec 2015 22:54:44 +, Charles T. Smith wrote: > But I concede I must be doing something fundamentally wrong because this > assert is triggering: > def __getattr__ (self, name): > print "attrdict:av:__getattr__: entered for ", name > ass

Re: using __getitem()__ correctly

2015-12-30 Thread Charles T. Smith
On Thu, 31 Dec 2015 10:13:53 +1100, Ben Finney wrote: > "Charles T. Smith" writes: > >> I don't understand this distinction between an "attribute" and a "dict >> item". > > When did you most recently work through the Python tutorial &

Re: how to get names of attributes

2015-12-31 Thread Charles T. Smith
On Thu, 31 Dec 2015 10:58:17 +1100, Steven D'Aprano wrote: (some very good information) Thank you. -- https://mail.python.org/mailman/listinfo/python-list

Re: using __getitem()__ correctly

2015-12-31 Thread Charles T. Smith
On Thu, 31 Dec 2015 10:50:53 +1100, Steven D'Aprano wrote: > I'm not sure what distinction you're referring to, can you explain? Ian Kelly had said: >> How precisely are you trying to store these: as an attribute, or as a >> dict item? If it's supposed to be in the dict, then why is your >> __ge

Re: using __getitem()__ correctly

2015-12-31 Thread Charles T. Smith
On Thu, 31 Dec 2015 11:21:59 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thu, 31 Dec 2015 10:13 am, Ben Finney wrote: >> >> > You may be familiar with other languages where the distinction >> > between “attribute of an object” is not distinct from “item in a >> > dictionary”. Pyth

Re: using __getitem()__ correctly

2015-12-31 Thread Charles T. Smith
On Wed, 30 Dec 2015 17:31:11 -0700, Ian Kelly wrote: >> In any case, I thought that class attributes were, in fact, items of >> __dict__? > > That's correct, but as I said in my previous message, self.attrs and > self.attrs.__dict__ are two different dicts, and you're confusing one > for the othe

Re: using __getitem()__ correctly

2015-12-31 Thread Charles T. Smith
On Thu, 31 Dec 2015 12:12:43 +, Oscar Benjamin wrote: > When you write x.attr the name 'attr' is looked up on the object x. This > calls x.__getattribute__('attr'). In turn this checks the dict > associated with the object x i.e. x.__dict__['attr']. This in turn calls > x.__dict__.__getitem__

Powerful perl paradigm I don't find in python

2016-01-15 Thread Charles T. Smith
while ($str != $tail) { $str ~= s/^(head-pattern)//; use ($1); } -- https://mail.python.org/mailman/listinfo/python-list

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Charles T. Smith
On Fri, 15 Jan 2016 11:42:24 +0100, Wolfgang Maier wrote: > On 15.01.2016 10:43, Peter Otten wrote: >> Charles T. Smith wrote: >> >>> while ($str != $tail) { >>> $str ~= s/^(head-pattern)//; >>> use ($1); >>> } >> >

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Charles T. Smith
On Fri, 15 Jan 2016 11:04:32 +, Charles T. Smith wrote: > capability, somehow, but that was apparently overlooked. For example, > by storing string state in the match object and having a *sub* method without > a string parameter. -- https://mail.python.org/mailman/listinfo/python-list

Re: Powerful perl paradigm I don't find in python

2016-01-18 Thread Charles T. Smith
On Fri, 15 Jan 2016 14:20:17 +0100, Wolfgang Maier wrote: > pattern = pattern_str.compile() > try: > matches = pattern.findall(some_str, endpos=some_str.index(tail)) > except ValueError: > # do something if tail is not found > pass Oh! I think that's it! matches = findall (patte

When is an int not an int? Who can explain this?

2016-01-18 Thread Charles T. Smith
$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> type(0) is int True ... (PDB)type(0) is int False (PDB)type(1) is int False (PDB)p 5 + 0 5 (PDB)class c (object): pass (PDB)type (c()) is c T

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Charles T. Smith
On Tue, 19 Jan 2016 03:19:59 +1100, Chris Angelico wrote: > On Tue, Jan 19, 2016 at 3:11 AM, Charles T. Smith > wrote: >> $ python >> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 >> Type "help", "copyright", "credits&quo

importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
What does "from (module) import (func)" do? Please don't tell me that I shouldn't ask because real programmers know not to have circular dependencies ... I have no idea what was imported before. I just want to import hexdump(). Unfortunately, this does not work: from utilities import hexdump

<    1   2   3   4   >