Re: Use cases for del

2005-07-07 Thread Ron Adam
Steven D'Aprano wrote: > Ron Adam wrote: >> def count_records(record_obj, start=0, end=len(record_obj)): > > > That would work really well, except that it doesn't work at all. Yep, and I have to stop trying to post on too little sleep. Ok, how about... ?

Re: Use cases for del

2005-07-08 Thread Ron Adam
George Sakkis wrote: > > How about using the right way of comparing with None ? > > x = None > t = time.time() > for i in range(100): > if x is None: > pass > print 'is None:',time.time()-t > > I get: > > None: 0.54952316 > String: 0.498000144958 > is None: 0.450476

Re: Use cases for del

2005-07-08 Thread Ron Adam
George Sakkis wrote: > I get: > > None: 0.54952316 > String: 0.498000144958 > is None: 0.45047684 What do yo get for "name is 'string'" expressions? Or is that a wrong way too? On my system testing "if string is string" is slightly faster than "if True/ if False" expressions. But th

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Ron Adam
Kay Schluehr wrote: > > Leif K-Brooks schrieb: > >>Kay Schluehr wrote: >> >>>Well, I want to offer a more radical proposal: why not free squared >>>braces from the burden of representing lists at all? It should be >>>sufficient to write >>> >>> >>list() >>> >>>list() >> >>So then what would t

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Ron Adam
Leif K-Brooks wrote: > Kay Schluehr wrote: > >list.from_str("abc") >> >>list("a", "b", "c" ) > > > > I assume we'll also have list.from_list, list.from_tuple, > list.from_genexp, list.from_xrange, etc.? List from list isn't needed, nor list from tuple. That's what the * is for. And for t

Re: Use cases for del

2005-07-09 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: > >> George Sakkis wrote: >> >>> I get: >>> >>> None: 0.54952316 >>> String: 0.498000144958 >>> is None: 0.45047684 >> >> >> >> What do yo get for "na

Re: decorators as generalized pre-binding hooks

2005-07-09 Thread Ron Adam
Bengt Richter wrote: > ;-) > We have Have we? Looks like not a lot of interested takers so far. But I'll bite. ;-) > So why not > > @deco > foo = lambda:pass > equivalent to > foo = deco(lambda:pass) > > and from there, > @deco > = > being equivalent to > = deco(

Re: Use cases for del

2005-07-10 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam wrote: > > >>>>>> 'abc' is 'abcd'[:3] >>>False >> >>Well of course it will be false... your testing two different strings! >>And the resulting slice creates a third. >&g

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-10 Thread Ron Adam
Roy Smith wrote: > Thomas Lotze <[EMAIL PROTECTED]> wrote: > >>Basically, I agree with the "make it run, make it right, make it fast" >>attitude. However, FWIW, I sometimes can't resist optimizing routines that >>probably don't strictly need it. Not only does the resulting code run >>faster, but

Re: decorators as generalized pre-binding hooks

2005-07-10 Thread Ron Adam
Bengt Richter wrote: > On Sun, 10 Jul 2005 05:35:01 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>So far they are fairly equivalent. So there's not really any advantage >>over the equivalent inline function. But I think I see what you are >>going towards. Decora

Re: extend for loop syntax with if expr like listcomp&genexp ?

2005-07-11 Thread Ron Adam
Bengt Richter wrote: > E.g., so we could write > > for x in seq if x is not None: > print repr(x), "isn't None ;-)" > > instead of > > for x in (x for x in seq if x is not None): > print repr(x), "isn't None ;-)" > > just a thought. > > Regards, > Bengt Richter Is it n

Re: Ordering Products

2005-07-17 Thread Ron Adam
Kay Schluehr wrote: > Here might be an interesting puzzle for people who like sorting > algorithms ( and no I'm not a student anymore and the problem is not a > students 'homework' but a particular question associated with a > computer algebra system in Python I'm currently developing in my > spare

Re: Efficiently Split A List of Tuples

2005-07-17 Thread Ron Adam
Raymond Hettinger wrote: >>Variant of Paul's example: >> >>a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10)) >>zip(*a) >> >>or >> >>[list(t) for t in zip(*a)] if you need lists instead of tuples. > > > > [Peter Hansen] > >>(I believe this is something Guido considers an "abuse of *args", but I >>jus

Re: Ordering Products

2005-07-18 Thread Ron Adam
Kay Schluehr wrote: > > Ron Adam wrote: > >>Kay Schluehr wrote: >>On a more general note, I think a constrained sort algorithm is a good >>idea and may have more general uses as well. >> >>Something I was thinking of is a sort where instead of giving a

Re: Efficiently Split A List of Tuples

2005-07-18 Thread Ron Adam
Raymond Hettinger wrote: > [Ron Adam] > >>Currently we can implicitly unpack a tuple or list by using an >>assignment. How is that any different than passing arguments to a >>function? Does it use a different mechanism? > > > It is the same mechanism, so it

Re: Efficiently Split A List of Tuples

2005-07-18 Thread Ron Adam
Simon Dahlbacka wrote: > Oooh.. you make my eyes bleed. IMO that proposal is butt ugly (and > looks like the C++.NET perversions.) I haven't had the displeasure of using C++.NET fortunately. point = [5,(10,20,5)] size,t = point x,y,z = t size,x,y,z = point[0], point[1][0], poi

Re: Ordering Products

2005-07-18 Thread Ron Adam
Kay Schluehr wrote: > Here might be an interesting puzzle for people who like sorting > algorithms ( and no I'm not a student anymore and the problem is not a > students 'homework' but a particular question associated with a > computer algebra system in Python I'm currently developing in my > spare

Re: Ordering Products

2005-07-19 Thread Ron Adam
t really that different from what I suggested. And since my example is based on your first example. It has a lot in common but the arrangement (organization) is a bit different. > Regards, > Kay Here's the current version... It now handles more complex equations including exponents and

Re: Ordering Products

2005-07-20 Thread Ron Adam
Kay Schluehr wrote: > Ron Adam wrote: > >> Kay Schluehr wrote: >> BTW.. Usually when people say "I don't want to discourage...", They >> really want or mean the exact oppisite. > > Yes, but taken some renitence into account they will provoke the &g

Re: [path-PEP] Path inherits from basestring again

2005-07-25 Thread Ron Adam
Peter Hansen wrote: > Michael Hoffman wrote: > >> Reinhold Birkenfeld wrote: >> >>> Tony Meyer wrote: >>> Do people really like using __div__ to mean join? >>> >>> >>> I'm not too happy with it, too, but do we have alternatives? ... >>> Of course, one can use joinwith() if he doesn't like '

Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Toby Dickenson wrote: > On Wednesday 27 July 2005 05:37, Meyer, Tony wrote: > > >>I can see that this would make sense in some situations, but ISTM that it >>would make a great deal more sense (and be much more intuitive) to have >>concatenation include the separator character (i.e. be join). >

Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Michael Hoffman wrote: > Ron Adam wrote: > >> In all current cases, (that I know of), of differing types, '+' raises >> an error. > > > Not quite: > > >>> "hello " + u"world" > u'hello world' > >>

Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Peter Hansen wrote: > Ron Adam wrote: > >> Michael Hoffman wrote: >> >>> Ron Adam wrote: >>> >>>> In all current cases, (that I know of), of differing types, '+' >>>> raises an error. >>> >>> >>>

Re: PEP on path module for standard library

2005-07-30 Thread Ron Adam
Bengt Richter wrote: > > > > Say, how about > > if Pathobject('gui://message_box/yn/continue > processing?').open().read().lower()!='y': > raise SystemExit, "Ok, really not continuing ;-)" > > An appropriate registered subclass for the given platform, returned when the > Patho

Re: [path-PEP] Path inherits from basestring again

2005-08-01 Thread Ron Adam
Ivan Van Laningham wrote: >>People can subclass Path and add it if they really want it. They can use >>Jason's original module. My position is that the PEP without this use of >>__div__ is (a) better as a standard module, and (b) improves the chance of >>the PEP being accepted. >> > > > I dis

Path as a dictionary tree key? (was Re: PEP on path module for standard library)

2005-08-01 Thread Ron Adam
I'm wondering if a class that acts as a interface to a tree data structure stored in a dictionary could also be useful as a base class for accessing filesystems, urls, and zip (or rar) files. Then a path object could then be used as a dictionary_tree key. This idea seems much more useful to m

Re: Path as a dictionary tree key? (was Re: PEP on path module for standard library)

2005-08-01 Thread Ron Adam
Brian Beck wrote: > Ron Adam wrote: > >> This give a more general purpose for path objects. Working out ways >> to retrieve path objects from a dictionary_tree also would be useful I >> think. I think a Tree class would also be a useful addition as well. >> >

Re: Path as a dictionary tree key? (was Re: PEP on path module for standard library)

2005-08-01 Thread Ron Adam
t all if anyone posted improvements. (hint hint) ;-) Cheers, Ron Adam + output -- Define paths: path1 = ['hello', 'world'] path2 = ['hello', 'there', 'world'] path3 = ['hello', 'there', 'wide', &#x

Re: finding sublist

2005-08-02 Thread Ron Adam
giampiero mu wrote: > hi everyone Hi, you appear to be fairly new to Python, so you might want to take a look at the tutorial at Python.org Kents suggestion to use RE is good. This should be faster than your example by quite a bit if you don't want to use RE. def controlla(test, size=4):

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-09 Thread Ron Adam
[EMAIL PROTECTED] wrote: > I've heard 2 people complain that word 'global' is confusing. > > Perhaps 'modulescope' or 'module' would be better? > > Am I the first peope to have thought of this and suggested it? > > Is this a candidate for Python 3000 yet? > > Chris After reading though some o

Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Ron Adam
Simon Brunning wrote: > On 8/14/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: > >>After profiling a small python script I found that approximately 50% of >>the runtime of my script was consumed by one line: "import copy". >>Another 15% was the startup of the interpreter, but that is OK for an >>

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-16 Thread Ron Adam
Antoon Pardon wrote: > I disagree here. The problem with "global", at least how it is > implemented in python, is that you only have access to module > scope and not to intermediate scopes. > > I also think there is another possibility. Use a symbol to mark > the previous scope. e.g. x would be t

Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Ron Adam
Michael Hudson wrote: > Simon Brunning <[EMAIL PROTECTED]> writes: > > >>I think that copy is very rarely used. I don't think I've ever imported it. >> >>Or is it just me? > > > Not really. I've used it once that I can recall, to copy a kind of > generic "default value", something like: > > d

Re: pythonXX.dll size: please split CJK codecs out

2005-08-21 Thread Ron Adam
Martin v. Löwis wrote: >>Can we at least undo this unfortunate move in time for 2.5? I would be >>grateful >>if *at least* the CJK codecs (which are like 1Mb big) are splitted out of >>python25.dll. IMHO, I would prefer having *more* granularity, rather than >>*less*. > > If somebody would formu

Re: pythonXX.dll size: please split CJK codecs out

2005-08-21 Thread Ron Adam
Martin v. Löwis wrote: > Ron Adam wrote: > >>I would put the starting minimum boundary as: >> >> 1. "The minimum required to start the python interpreter with no >>additional required files." >> >>Currently python 2.4 (on windows) does not

Multiple (threaded?) connections to BaseHTTPServer

2005-08-23 Thread Adam Atlas
Is there any built-in way for BaseHTTPServer to handle multiple connections at once, e.g. with threads? If not, can this existing module be easily extended to do this, or will I have to do lower-level socket things (and probably thus have to write my own HTTP code)? Thanks. Adam -- http

Re: Multiple (threaded?) connections to BaseHTTPServer

2005-08-23 Thread Adam Atlas
is good enough for my current needs aside from its lack of threading, does PooledThreadedServer have any advantages over the method I linked above? - Adam -- http://mail.python.org/mailman/listinfo/python-list

Embedded python debug build crashing.

2005-08-27 Thread Adam Tomjack
roblems. Is there something simple I'm forgetting to do? I'm out of ideas. Does anybody have any ideas about how to attack this problem? Thanks, Adam Tomjack -- http://mail.python.org/mailman/listinfo/python-list

Re: py to exe: suggestions?

2005-08-28 Thread Ron Adam
chris patton wrote: > I need to convert a python file to an '.exe'. I've tried py2exe, and I > don't like it because you have to include that huge dll and libraries. > > Thanks for the Help!! Do you want to create an exe to give to others, or so that you can use it in windows easier just like a

Re: trictionary?

2005-08-28 Thread Adam Tomjack
elf.t = t bin = {} for a, b in foo: x = 42 - a bin_item = bin.setdefault(x, BinItem(1, 0)) bin_item.s += 1 for x, item in bin.iteritems(): print x, item.s, item.t Luck in battle, Adam Randy Bush wrote: > i have some code which looks kinda like > > bin = {} >

Re: trictionary?

2005-08-28 Thread Adam Tomjack
ou can say: bin_item = bin.setdefault(x, [0, 0]) bin_item[0] += 1 That should be equivalent. My example with the class is similarly broken. Adam Adam Tomjack wrote: > Randy, > > I'd probably use a two element list. > > Instead of using an if/else to check if

Re: Question

2005-08-28 Thread Adam Tomjack
why it disappears right away when you double click it), but it also doesn't open than extra window when you use it to run a gui application. Adam Beginner/Not Yet Programmer wrote: > I've never programmed before, so I thought I'd try and learn a bit by > using some Pytho

Re: trictionary?

2005-08-28 Thread Adam Tomjack
ach element, but for a block of code eight lines long, doing anything more descriptive would be too verbose. Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: trictionary?

2005-08-28 Thread Adam Tomjack
ith a class or a dict so that each element has a name. On the flip side, using such a heavy solution for such a simple problem also smells bad. The solution should should be as complicated as the problem -- no more, no less. Adam Randy Bush wrote: >>>bin = {} >>>for wh

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-31 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-08-31, Bengt Richter schreef <[EMAIL PROTECTED]>: > >>On 31 Aug 2005 07:26:48 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: >> >> >>>Op 2005-08-30, Bengt Richter schreef <[EMAIL PROTECTED]>: >>> On 30 Aug 2005 10:07:06 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrot

aggdraw for PIL

2005-08-31 Thread Adam Endicott
Does anyone know anything about the aggdraw module for PIL? I think I would like to use it because I need to do some drawing with semi-transparent pen styles (I'm simulating using a highlighter). It seems to be working great, but I think I'm running into a memory leak that's noted in the documentat

Re: aggdraw for PIL

2005-08-31 Thread Adam Endicott
You know, I tried doing it that way, and I must have done something wrong the first time because I was getting an error. It works now though, and it performs much better. Thanks! I'll keep an eye out for the new version, that kind of timeframe will be in plenty of time for the project I'm currentl

time.strptime() for different languages

2005-08-31 Thread Adam Monsen
e month name using a translation table for English to Dutch month names. -- Adam Monsen http://adammonsen.com/ (crossposted to Seattle Python Users List) -- http://mail.python.org/mailman/listinfo/python-list

Re: time.strptime() for different languages

2005-08-31 Thread Adam Monsen
quot;%d %B %Y om %H:%M") Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/_strptime.py", line 292, in strptime raise ValueError("time data did not match format: data=%s fmt=%s" % ValueError: time data did not match format: data=

"zoning" a naive datetime object / daylight savings

2005-08-31 Thread Adam Monsen
n August 10th, 2005 in the Europe/Paris timezone that daylight savings is in effect, and the equivalent UTC datetime object should contain a time two hours prior. At least, that's what I like to happen. Also, anyone know if there is a more appropriate choice for timezone than "Europe/Paris&q

Re: time.strptime() for different languages

2005-08-31 Thread Adam Monsen
Excellent! Thank you, Fredrik! -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: time.strptime() for different languages

2005-08-31 Thread Adam Monsen
last): File "", line 1, in ? File "/usr/lib/python2.4/_strptime.py", line 292, in strptime raise ValueError("time data did not match format: data=%s fmt=%s" % ValueError: time data did not match format: data=10 August 2005 at 17:26 fmt=%d %B %Y at %H:

Re: time.strptime() for different languages

2005-08-31 Thread Adam Monsen
ch back to previous locale locale.setlocale(locale.LC_TIME, old_loc) -->8-- If I try to do further date parsing in the same scope (with a different locale), it fails. Let me know if you have any ideas about why. -- Adam Monsen http

Re: "zoning" a naive datetime object / daylight savings

2005-08-31 Thread Adam Monsen
The 9-integer time tuple could be fetched using the code posted here: http://snipurl.com/hcvs same URL, not snipped: http://groups.google.com/group/comp.lang.python/msg/65d8f116dfd59dd1 -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in string.find

2005-09-01 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>The problem with negative index's are that positive index's are zero >>based, but negative index's are 1 based. Which leads to a non >>symmetrical situations. > > > indices point to the "gap&q

Re: Bug in string.find

2005-09-02 Thread Ron Adam
Terry Reedy wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Fredrik Lundh wrote: >> >>>Ron Adam wrote: >>> >>>>The problem with negative index's are that positive index'

Re: Bug in string.find

2005-09-03 Thread Ron Adam
Terry Reedy wrote: >>b[-1:] = ['Z']# replaces last item >>b[-1:-0] = ['Z'] # this doesn't work >> >>If you are using negative index slices, you need to check for end >>conditions because you can't address the end of the slice in a >>sequential/numerical way. > > OK, now I understand

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-09-03 Thread Ron Adam
Bengt Richter wrote: > IMO the problem is that the index sign is doing two jobs, which for zero-based > reverse indexing have to be separate: i.e., to show direction _and_ a _signed_ > offset which needs to be realtive to the direction and base position. Yes, that's definitely part of it. > A l

Possible improvement to slice opperations.

2005-09-04 Thread Ron Adam
y, it would be nice to get a few opinions at this point. So blast away... or hopefully tell me what you like about it instead. ;-) (Any suggestions or contributions to make it better would be appreciated.) Cheers, Ron Adam """ IMPROVED SLICING Slicing is one

Re: Possible improvement to slice opperations.

2005-09-04 Thread Ron Adam
Terry Reedy wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Slicing is one of the best features of Python in my opinion, but >>when you try to use negative index's and or negative step increments >>it can be

Re: Possible improvement to slice opperations.

2005-09-04 Thread Ron Adam
Patrick Maupin wrote: >>After considering several alternatives and trying out a few ideas with a >> modified list object Bengt Richter posted, (Thank You), I think I've >>found a way to make slice operation (especially far end indexing) >>symmetrical and more consistent. > > > I don't know that

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Scott David Daniels wrote: > Magnus Lycka wrote: > >> Ron Adam wrote: >> >>> ONES BASED NEGATIVE INDEXING > > > I think Ron's idea is taking off from my observation that if one's > complement, rather than negation, was used to specify measure

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Szabolcs Nagy wrote: > with the current syntax L[i:i+1] returns [L[i]], with nxlist it returns > L[i+1] if i<0. > > L=range(10) > L[1:2]==[L[1]]==[1] > L[-2:-1]==[L[-2]]==[8] > > L=nxlist(range(10)) > L[1:2]==[L[1]]==[1] > L[-2:-1]==[L[-1]]==[9] # not [L[-2]] > > IMHO in this case current list

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Magnus Lycka wrote: > Ron Adam wrote: > >> Slicing is one of the best features of Python in my opinion, but >> when you try to use negative index's and or negative step increments >> it can be tricky and lead to unexpected results. > > > Hm... Just as w

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Fredrik Lundh wrote: > Steve Holden wrote: > > >>Yes, I've been surprised how this thread has gone on and on. > > > it's of course a variation of > > "You can lead an idiot to idioms, but you can't make him > think ;-)" > > as long as you have people that insist that their original m

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Steve Holden wrote: > It's a common misconception that all ideas should be explainable simply. > This is not necessarily the case, of course. When a subject is difficult > then all sorts of people bring their specific misconceptions to the > topic, and suggest that if only a few changes were ma

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Bengt Richter wrote: > On Mon, 5 Sep 2005 18:09:51 +0200, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > OTOH, ISTM we must be careful not to label an alternate alpha-version > "way to model the real world" as a "misunderstanding" just because it is > alpha, > and bugs are apparent ;-) Thanks! I

Re: Possible improvement to slice opperations.

2005-09-05 Thread Ron Adam
Terry Reedy wrote: >>Ron Adam wrote: >> >> >>>However, I would like the inverse selection of negative strides to be >>>fixed if possible. If you could explain the current reason why it does >>>not return the reverse order of the selected ra

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Patrick Maupin wrote: > I previously wrote (in response to a query from Ron Adam): > > >>In any case, you asked for a rationale. I'll give you mine: >> >> >>>>>L = range(10) >>>>>L[3:len(L):-1] == [L[i] for i in range(3,len(L),-1)]

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: > >> Steve Holden wrote: >> >> What misconception do you think I have? >> > This was not an ad hominem attack but a commentary on many attempts to > "improve" the language. Ok, No problem. ;-) >> No o

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Patrick Maupin wrote: > Ron Adam wrote: > > >>>This should never fail with an assertion error. You will note that it >>>shows that, for non-negative start and end values, slicing behavior is >>>_exactly_ like extended range behavior. > > >>Yes,

Re: Possible improvement to slice opperations.

2005-09-06 Thread Ron Adam
Magnus Lycka wrote: > Ron Adam wrote: > >> Ok, lets see... This shows the problem with using the gap indexing >> model. >> >> L = range(10) >> >> [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] # elements >> 0 1 2 3 4 5 6 7 8 9

Re: Possible improvement to slice opperations.

2005-09-07 Thread Ron Adam
Bengt Richter wrote: > Then the question is, do we need sugar for reversed(x.[a:b]) > or list(reversed(x.[a:b])) for the right hand side of a statement, > and do we want to to use both kinds of intervals in slice assignment? > (maybe and yes ;-) Yes, I think this is the better way to do it, as th

disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
st disabling networking within that virtual machine would possibly work, too. -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: "grep" database

2005-09-09 Thread Adam Monsen
ctags indexes procedures/variables in source code, perhaps it would help: http://ctags.sf.net/ -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
I know very little about socket programming and even less about sockey.py... any idea what behavior would have to be modified? Further complicating matters (for me), it appears some of the socket programming code is in C, and my C skills are lacking. -- Adam Monsen http://adammonsen.com

using % operator to print possibly unitialized data attributes

2005-09-09 Thread Adam Monsen
_) return 'name="%(name)s" value="%(value)s' % vals j = J() j.name = "j object" print j >8 A couple of questions: * is there a simpler or more elegant way to do this? * how can I get this to work for new-style

Re: using % operator to print possibly unitialized data attributes

2005-09-09 Thread Adam Monsen
#x27; % vals > What's wrong with the obvious version: [...] Oh, that looks nice and clean. I like it. I also found a recipe in the Python cookbook that works great for "dumping" objects: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/137951 (shortened: http://snipurl.com/

Re: disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
Nice!! Since that works, this also works (any socket operations appear to raise an IOError): import socket socket.setdefaulttimeout(0) Thanks! -Adam -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
t f.read() >From this code I get the following exception: "IOError: [Errno socket error] timed out" ...and that fits my needs nicely. -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible improvement to slice opperations.

2005-09-09 Thread Ron Adam
Michael Hudson wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >>With current slicing and a negative step... >> >>[ 1 2 3 4 5 6 7 8 9 ] >> -9 -8 -7 -6 -5 -4 -3 -2 -1 -0 >> >>r[-3:] -> [7, 8, 9]# as expected >&

Re: encryption with python

2005-09-10 Thread Ron Adam
Kirk Job Sluder wrote: > The only way to keep confidential stuff secure is to shred it, burn it, > and grind the ashes. > > I think the fundamental problem is that that most customers don't want > actual security. They want to be able to get their information by > calling a phone number and sa

Re: encryption with python

2005-09-10 Thread Ron Adam
James Stroud wrote: > On Saturday 10 September 2005 15:02, Ron Adam wrote: > >>Kirk Job Sluder wrote: >>I would think that any n digit random number not already in the data >>base would work for an id along with a randomly generated password that >>the student

Re: encryption with python

2005-09-11 Thread Ron Adam
Kirk Job Sluder wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >>I would think that any n digit random number not already in the data >>base would work for an id along with a randomly generated password >>that the student can change if they want. The service provid

high performance hyperlink extraction

2005-09-13 Thread Adam Monsen
attr_matches = attrs_re.finditer(d.get('attrs', None)) for match in attr_matches: da = match.groupdict() name = da.get('name', None) a[name] = da.get('value', None) ancs.append(a) return ancs if __name__ == '__mai

Re: time.strptime() for different languages

2005-09-13 Thread Adam Monsen
o that bug. -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Create and display an email

2005-09-13 Thread Adam Endicott
I've got a wxPython based windows GUI application that takes some input and creates a PDF file output. At the end, I need to create an email message with this pdf file attached ready for the user to just hit "send". I don't want to actually send the email automatically, I just want to pop up a mess

strptime() doesn't recognize BST as a valid timezone

2005-09-14 Thread Adam Monsen
url: http://groups.google.com/group/comp.lang.python/browse_frm/thread/ce4909280561458b/ ). I did notice that the Python docs mention %Z is deprecated, so http://snipurl.com/hoqz is possibly the best solution available for now. Thoughts? -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Create and display an email

2005-09-15 Thread Adam Endicott
Thanks for the MAPI suggestion. I did a bit more googling, and combined a few things, along with some trial and error to come up with something that works. Here it is for posterity: import win32com.client olMailItem = 0x0 obj = win32com.client.Dispatch("Outlook.App

Re: Software bugs aren't inevitable

2005-09-16 Thread Ron Adam
Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >>But there is a difference: writing assembly is *hard*, which is why we >>prefer not to do it. Are you suggesting that functional programming is >>significantly easier to do than declarative? > > > I think you mean imperative. Y

Re: Software bugs aren't inevitable

2005-09-16 Thread Ron Adam
Terry Reedy wrote: > You cannot tell whether a function object will act > recursive or not just by looking at its code body. Trivial examples: I was thinking last night that maybe it would be useful to be able to define a function explicitly as a recursive object where it's frame is reused on

Re: strptime() doesn't recognize BST as a valid timezone

2005-09-16 Thread Adam Monsen
10, 17, 26, 0, 2, 222, 1) Works (unsuprisingly) as advertised at the bottom of this page: http://docs.python.org/lib/module-time.html And now I'm a little closer to understanding why. :) -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

style question: anything wrong with super(type(self), self).f() ?

2005-09-19 Thread Adam Monsen
;in A.f()" By "wrong" I mean, is there any reason why this is just a Bad Idea? Seems helpful to me, if I change the name of the 'B' class, I don't have to change super() calls as well. -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: time.strptime() for different languages

2005-09-19 Thread Adam Monsen
Brett Cannon fixed this bug last week. Thanks, Brett! -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

inspect getsource() minor fix?

2005-09-19 Thread Ron Adam
While playing around with the inspect module I found that the Blockfinder doesn't recognize single line function definitions. Adding the following two lines to it fixes it, but I'm not sure if it causes any problems anywhere else. elif self.indent == 0: raise EndOfBlock, self.las

Re: inspect getsource() minor fix?

2005-09-19 Thread Ron Adam
Delaney, Timothy (Tim) wrote: > Ron Adam wrote: > > >>While playing around with the inspect module I found that the >>Blockfinder doesn't recognize single line function definitions. >> >>Adding the following two lines to it fixes it, but I'm not sur

Re: Question About Logic In Python

2005-09-19 Thread Ron Adam
Steven D'Aprano wrote: > On Mon, 19 Sep 2005 12:16:15 +0200, sven wrote: > > >>to make sure that an operation yields a boolean value wrap a bool() >>around an expression. >>None, 0 and objects which's len is 0 yield False. >>so you can also do stuff like that: > > > Are there actually any usa

Re: Organising a python project

2005-09-20 Thread Ron Adam
[EMAIL PROTECTED] wrote: > Dear all, > > Can anyone point me to a resource that describes the best way of > organising a python project? My project (gausssum.sf.net) is based > around a class, and has a GUI that allows 'easy-access' to the methods > of the class. What is the best or typical direc

Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote: >>So.. >> >>bool(a and b) * value >> >>Would return value or zero, which is usually what I want when I do this >>type of expression. > That's all very interesting, and valuable advice for somebody who doesn't > understand how Python's logical operators work, but the qu

Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote: > Ah, that's a good example, thanks, except I notice you didn't actually > cast to bool in them, eg: (min < value < max) * value It wasn't needed in these particular examples. But it could be needed if several comparisons with 'and' between them are used. It just seems o

<    1   2   3   4   5   6   7   8   9   10   >