Re: [OT] a little about regex

2006-10-18 Thread Ron Adam
Fulvio wrote: > *** > Your mail has been scanned by InterScan MSS. > *** > > > Hello, > > I'm trying to get working an assertion which filter address from some domain > but if it's prefixed by '.com'. > Even trying to put the result in a negate test I can

Re: Flexable Collating (feedback please)

2006-10-18 Thread Ron Adam
Fixed... Changed the collate() function to return None the same as sort() since it is an in place collate. A comment in _test() doctests was reversed. CAPS_FIRST option puts words beginning with capitals before, not after, words beginning with lower case of the same letter. It seems I alw

Flexable Collating (feedback please)

2006-10-17 Thread Ron Adam
ed this in *anything* yet, so don't plug it into production code of any type. I also haven't done any performance testing. See the doc tests below for examples of how it's used. Cheers, Ron Adam """ Collate.py A general purpose configurable collate

Re: Need a strange sort method...

2006-10-17 Thread Ron Adam
Ron Adam wrote: > Neil Cerutti wrote: >> On 2006-10-16, Tim Chase <[EMAIL PROTECTED]> wrote: >>> If you need it in a flat list, rather than as a list of >>> chunk_size lists (which are handy for iterating over in many >>> cases), there are ways of obtain

Re: Need a strange sort method...

2006-10-17 Thread Ron Adam
sequence as a list. """ def iterinner(seq): for s in seq: if hasattr(s, '__iter__'): for i in iterinner(s): yield i else: yield s return list(iterinner(sequence)) Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Alphabetical sorts

2006-10-17 Thread Ron Adam
Neil Cerutti wrote: > On 2006-10-17, Ron Adam <[EMAIL PROTECTED]> wrote: >> Neil Cerutti wrote: >>> On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote: >>>> I have several applications where I want to sort lists in >>>> alphabetical order.

Re: Alphabetical sorts

2006-10-16 Thread Ron Adam
Neil Cerutti wrote: > On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote: >> I have several applications where I want to sort lists in >> alphabetical order. Most examples of sorting usually sort on >> the ord() order of the character set as an approximation. But >

Alphabetical sorts

2006-10-16 Thread Ron Adam
I have several applications where I want to sort lists in alphabetical order. Most examples of sorting usually sort on the ord() order of the character set as an approximation. But that is not always what you want. The solution of converting everything to lowercase or uppercase is closer, but

Re: 3D Vector Type Line-Drawing Program

2006-10-12 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> Scott David Daniels wrote: >>> James Stroud wrote: >>>>> I'm looking for a program to do line-drawings in 3d, with output to >>>>> postscript or svg or pdf, etc. I would like to describe a scene

Re: 3D Vector Type Line-Drawing Program

2006-10-10 Thread Ron Adam
Scott David Daniels wrote: > James Stroud wrote: >>> I'm looking for a program to do line-drawings in 3d, with output to >>> postscript or svg or pdf, etc. I would like to describe a scene with >>> certain 1-3d elements oriented in 3d space with dashed or colored >>> lines and filled or transpar

Re: Painless way to do 3D visualization

2006-10-08 Thread Ron Adam
Peter Beattie wrote: > Hey folks, > > I need to do the following relatively simple 3D programming: > > I want to convert data from four-item tuples into 3D co-ordinates in a > regular tetrahedron. Co-ordinates come in sequences of 10 to 20, and the > individual dots in the tetrahedron need to be

Re: Makin search on the other site and getting data and writing in xml

2006-09-25 Thread Adam Jones
rch sites have the same requirement. Yes, it is possible to query a bunch of search sites and dump the results into an xml file. It is not even all that hard. In fact, I bet running a search on the relevant terms will probably produce something that almost does what you want. -Adam -- h

Re: How to get a Fix to an Abandoned Project?

2006-09-20 Thread Adam Jones
Granted, for something that has withered and died this may not be much of an issue, but it is good to know for future reference. -Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: pprint: "...thank small children who sleep at night."

2006-09-20 Thread Adam Jones
e or in-joke? Can someone > explain it? I don't get it. My guess is that he had to write a pretty printer so his cursing and general frustration and reading nasty nested tuples wouldn't wake the kids. -Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Building Python Based Web Application

2006-09-08 Thread Adam Jones
like it would be simple enough to use for what you are talking about. Without knowing more about your requirements that would be my suggestion. I am sure there are other people on this group with more experience here who could give more useful commentary. -Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Building Python Based Web Application

2006-09-08 Thread Adam Jones
James Stroud wrote: > Hello All, > > I am interested in setting up a modest invoicing system for some > consulting I am doing. I like the idea of managing this on the web and > creating invoices and printing them from a browser. However, I'm not > really sure where to start. I've played with some

Re: Using Beautiful Soup to entangle bookmarks.html

2006-09-07 Thread Adam Jones
Francach wrote: > Hi, > > I'm trying to use the Beautiful Soup package to parse through the > "bookmarks.html" file which Firefox exports all your bookmarks into. > I've been struggling with the documentation trying to figure out how to > extract all the urls. Has anybody got a couple of longer ex

Re: OO on python real life tutorial?

2006-09-02 Thread Ron Adam
filippo wrote: > Hello, > > I coded my +10k lines app using Perl/Tk. It is something like a hotel > software manager, it has a bunch of windows to manage the arrivals, > bills etc etc. I want to port this on Python/WxPython but I'd like to > get benefit of python, not just doing a row by row raw p

Re: SQLObject or SQLAlchemy?

2006-08-31 Thread Adam Jones
John Salerno wrote: > Adam Jones wrote: > > > I think SA's extra flexability > > is worth the effort. > > Thanks for the reply. Do you mean in the above quote that SA is a little > more complicated than SO? Yes, it is. To avoid the technical issues involved the c

Re: SQLObject or SQLAlchemy?

2006-08-31 Thread Adam Jones
John Salerno wrote: > Are there any major differences between these two? It seems they can > both be used with TurboGears, and SQLAlchemy with Django. I'm just > wondering what everyone's preference is, and why, and if there are even > more choices for ORM. > > Thanks. Currently most of my work i

Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Adam Jones
particular need, TG can absorb it in the next version. The TurboGears developers can spend most of their time working on additional code that makes the project more useful instead of bug fixes and minor feature upgrades to the core components. This philosophy is proven to work for most other open source

Re: Pros/Cons of Turbogears/Rails?

2006-08-29 Thread Adam Jones
Bruno Desthuilliers wrote: > Paul Boddie wrote: > > Ray wrote: > (snip) > >> We're a Java shop so > >> our developers are trained in Java, Struts, Tomcat, etc. Any switch to > >> a dynamic language will be a huge change. However it baffles me that > >> they are open to at least a PoC in Rails. but

Re: Pros/Cons of Turbogears/Rails?

2006-08-28 Thread Adam Jones
In my understanding, which relies completely on the judgements of co-workers regarding the rails side of the debate, TurboGears is more flexible. Tasks which fall inside the scope of Rails' "opinion" are probably easier there, but anything outside of what Rails was built to do is harder than equiva

Re: Add users to directory/folder and set permissions in Windows

2006-08-21 Thread Adam Jones
Gallagher, Tim (NE) wrote: > I was wondering if there was a way to add a user in active directory to > a folder and set the permissions. It should be possible. If you can use VBScript or JScript it will be easier to find resources for those. You will probably need, at the least, the win32 extensi

Easy Validators

2006-08-20 Thread Ron Adam
Sometimes it's good to check things while working on them. This seems like a good way to do that. You could probably put these in a module and just import them. from validators import * I'm interested if anyone can think of ways to improve this further. Each validator consists of an as

Re: String.digits help!!!

2006-08-09 Thread Ron Adam
[EMAIL PROTECTED] wrote: > Simon Forman: > >> accessing it from a >> module (perhaps math.. math.infinity, math.epsilon, etc., just like >> math.pi and math.e.) > > It too looks acceptable. > > >> I look forward to hearing your thoughts an the subject. > > Thank you, but I am not expert enoug

Re: ImportError raised in script, not interactive session.

2006-07-31 Thread Adam Blinkinsop
Jordan R McCoy wrote: > If this isn't the case, what are you using for TARGET_DIR? ${TARGET_DIR} = /home/blinks/projects/overwatch/target/lib/python I've started the interactive session from several different directories, and never had a problem. My make output (note the second item in sys.path):

ImportError raised in script, not interactive session.

2006-07-31 Thread Adam Blinkinsop
I'm writing a set of modules to monitor remote system services, and I'm having a problem running my test scripts. When I pass the scripts into python, like so: -- $ PYTHONPATH="${TARGET_DIR}" python test.py -- I get an ImportError: -- Traceback (most recent call last): File "./test.py", line

Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Ron Adam
Chaos wrote: > As my first attempt to loop through every pixel of an image, I used > > for thisY in range(0, thisHeight): > for thisX in range(0, thisWidth): > #Actions here for Pixel thisX, thisY > > But it takes 450-1000 milliseconds > > I want speeds less

newbie graphing recommendations ?

2006-07-02 Thread Adam
Where should a py newbie start to do some 2D graphs on screen ? PythonGraphApi, Gato, looks interesting pygraphlib, matplotlib, is there a best native Python place to start ? -- http://mail.python.org/mailman/listinfo/python-list

Re: What technologies should I use for my application manager?

2006-06-27 Thread Adam Jones
MrBlueSky wrote: > Thanks for the advice, Adam! > > Turbogears sounds like it does everything I want and looks like a > great... except you've made me nervous with your comment on the > instability of the Oracle API! It is not impossible to find a stable ORM for access to O

Re: What technologies should I use for my application manager?

2006-06-26 Thread Adam Jones
MrBlueSky wrote: > Hello! I've just finished working on my first Python app (a > Tkinter-based program that displays the content of our application log > files in graphical format). It was a great experience that's had a > very positive response from my colleagues. > > So I'd like to try somethi

Re: Regular expression for not-group

2006-06-15 Thread adam johnson
You want to use negative lookahead eg.\.(?!py)it matches only if the characters ahead in the regex don't match the pattern in the brackets. http://docs.python.org/lib/re-syntax.html (about halfway down the page)On 15 Jun 2006 14:11:39 -0700, Chris Lasher <[EMAIL PROTECTED]> wrote: Is it possible t

Re: Web framework comparison video

2006-05-24 Thread Adam Jones
Just as a note, TurboGears has added a lot that would change the scoring on this. The project has been moving pretty quickly towards 1.0 lately, and I would advise anyone interested in a comparison to check out the recent changes before making a final decision. The same will probably hold true for

Re: python vs perl lines of code

2006-05-17 Thread Adam Jones
Without any more information I would say the biggest contributor to this dissimilarity is your experience. Having spent an additional five years writing code you probably are better now at programming than you were then. I am fairly confident that if you were to take another crack at these same pro

Re: A critic of Guido's blog on Python's lambda

2006-05-07 Thread Adam Jones
Ken Tilton wrote: > Alexander Schmolck wrote: > > [trimmed groups] > > > > Ken Tilton <[EMAIL PROTECTED]> writes: > > > > > >>yes, but do not feel bad, everyone gets confused by the /analogy/ to > >>spreadsheets into thinking Cells /is/ a spreadsheet. In fact, for a brief > >>period I swore off th

Re: Swaying A Coder Away From Python

2006-05-04 Thread Adam Jones
Rony Steelandt wrote: > > "One problem is that python tools suck," he wrote. Wallace compared the > various IDEs and other developer tools available to Microsoft's freely > available Visual Studio Express and called them "toys." > > > > What s wrong with VI ??? :) User error, evidently. Someti

ILOG Server integration

2006-04-27 Thread adam
Does anybody have experiences of Python and ILOG Server (distribution framework) integration? I need to access to a server application "exposed" through ILOG Server. Thanks Vieri -- http://mail.python.org/mailman/listinfo/python-list

Passing Exceptions Across Threads

2006-04-25 Thread Adam Mullins
Hello, I'm writing a physics simulator back-end with a built-in, threaded server that for the moment is quite simple. I've faced a few problems in writing this code, however, as it's the first time I've played with threading. For the moment, everything works decently, but I need (or rather, want) a

Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Ron Adam
Alex Martelli wrote: > Ron Adam <[EMAIL PROTECTED]> wrote: >... >> I still get the following with the tinyurl link: >> >> ~~~ >> The download you requested is unavailable. If you continue to see this >> message when trying to access this download, go

Re: MS VC++ Toolkit 2003, where?

2006-04-24 Thread Ron Adam
Alex Martelli wrote: > "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > >> Alex Martelli wrote: >>> As suggested to me by David Rushby 10 hours ago, >>> >>> http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-4 >>> 9FD-9CB0-4BFA122FA91B&displaylang=en >>> >>> does work. >> Can you

Re: calculating system clock resolution

2006-04-08 Thread Ron Adam
Steven D'Aprano wrote: > On Fri, 07 Apr 2006 16:39:40 -0700, jUrner wrote: > >> Maybe it was not too clear what I was trying to point out. >> >> I have to calculate the time time.time() requires to return the next >> tick of the clock. >> Should be about 0.01ms but this may differ from os to os. >

Re: Appending Elements in Element Tree

2006-04-08 Thread Ron Adam
Ron Adam wrote: > > In my program I have a lot of statements that append elements, but > sometimes I don't want to append the element so it requres an if > statement to check it, and that requires assigning the returned element > from a function to a name or calli

Re: how you know you're a programming nerd

2006-04-08 Thread Ron Adam
John Salerno wrote: > Ron Adam wrote: >> When you are working on your programming project on Friday night >> instead of going out. > > Ok, you win. :) > > Oh wait, it's Friday night and I'm typing this message...dang it! Yep, Hah Hah... No

Re: how you know you're a programming nerd

2006-04-07 Thread Ron Adam
When you are working on your programming project on Friday night instead of going out. When you do go out, you look forward to getting home so you can work on your programming project some more. -- http://mail.python.org/mailman/listinfo/python-list

Appending Elements in Element Tree

2006-04-07 Thread Ron Adam
In my program I have a lot of statements that append elements, but sometimes I don't want to append the element so it requres an if statement to check it, and that requires assigning the returned element from a function to a name or calling the funtion twice. e = ET.Element('name') e

Re: good style guides for python-style documentation ?

2006-04-06 Thread Ron Adam
> (reposted from doc-sig, which seems to be mostly dead > these days). > > over at the pytut wiki, "carndt" asked: > > Are there any guidelines about conventions concerning > punctuation, text styles and language style (e.g. how > to address the reader)? > > any suggestions from this

Re: pre-PEP: The create statement

2006-04-06 Thread Ron Adam
> Abstract > > > This PEP proposes a generalization of the class-declaration syntax, > the ``create`` statement. The proposed syntax and semantics parallel > the syntax for class definition, and so:: > >create : > > > is translated into the assignment:: > > = ("", ,

Re: Python Module for Determining CPU Freq. and Memory?

2006-04-06 Thread Ron Adam
efrat wrote: > Hello, > > I'd like to determine at runtime the computer's CPU frequency and memory. > > Is there a module for these types of queries? platform.platform returns > the computer's CPU name and type, but not its frequency; nor does it > report how much memory the computer has. I

Re: using range() in for loops

2006-04-05 Thread Adam DePrince
On Tue, 2006-04-04 at 21:54 -0400, John Salerno wrote: > I'm reading Text Processing in Python right now and I came across a > comment that is helping me to see for loops in a new light. I think > because I'm used to the C-style for loop where you create a counter > within the loop declaration,

Re: xml element tree to html problem

2006-04-04 Thread Ron Adam
Fredrik Lundh wrote: > here's one way to do it: > > import cElementTree as ET > > tree = ET.XML(""" > > ball > > red > large > > > """) > > MAP = { > "object": ("dl", "object"), > "name": ("dt", "name"

xml element tree to html problem

2006-04-04 Thread Ron Adam
I'm new to element tree and haven't been able to find a simple solution to this problem yet. So maybe someone can point me in the right direction. I have an element tree structure of nested elements that I want to convert to html as nested definition and unordered lists in the following way.

Re: Best IDE for Python?

2006-04-03 Thread Adam DePrince
ductive in. What /I/ > > find useful may not be of interest to /you/. > > nonsense. emacs is the best tool for everyone! Emacs? Wait, I didn't post anything? Could this mean I'm not alone! - Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: splitting dictionary definition across two .py files

2006-04-03 Thread Adam DePrince
.o and also quickly fix any compilation errors. I don't want to > use the make infrastructure, as it takes a while to resolve the > dependencies. Dependencies for 100 files? - Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-04-03 Thread Adam DePrince
ch street he would look the wrong way, look the correct way and then stare the wrong way again. Upon noticing my inquisitorial expression, he answered "A good programmer always looks both ways when crossing a one way street." I'm uncertain that a quip about abstracting away the rain would

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Ron Adam wrote: > Steve R. Hastings wrote: >> This neatly replaces truecount(), and you can use it for other things as >> well. > > if True in talley(S): do_somthing() > > Works for me... ;-) > > > Cheers, > Ron Actulley talley isn&#

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote: > On Sat, 01 Apr 2006 14:35:58 -0300, Felipe Almeida Lessa wrote: >> Two changes: >> - Use "is None". >> - Use "try ... except" instead of "in" > > Yes. > > >> Maybe you don't like my version, and the gains aren't that much, but >> please use "is None" instead of "== N

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote: > Here is a function called "tally()". It reduces a list to a dictionary > of counts, with one key for each value from the list. The value for > each key is the count of how many times it appeared in the list. > > > def tally(seq, d=None): > if d == None: >

Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote: > On Fri, 31 Mar 2006 16:29:00 -0800, Paul Rubin wrote: >> I think "S and all(S)" is the right way to express that, if that's >> what's intended. > > I still would like a standard function, because "S and all(S)" does not > work with iterators. I proposed one possible fun

Re: proposed proposal: set.values()

2006-03-31 Thread Ron Adam
Paul Rubin wrote: > "Terry Reedy" <[EMAIL PROTECTED]> writes: >> 1. It is pure duplication that *adds* keystrokes. >> > Nobody says you shouldn't use list(s) if you know you're dealing with > a set. The idea of s.values() is so you can duck-type between dicts > and sets. You could just do the fol

Re: any() and all() on empty list?

2006-03-31 Thread Ron Adam
Carl Banks wrote: > Ron Adam wrote: >> Carl Banks wrote: >> >>> In Python, yes and no are the only possible answers. Probably the only >>> analogous thing you could do in Python would be for all() to raise >>> ValueError when passed an empty sequen

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Carl Banks wrote: > In Python, yes and no are the only possible answers. Probably the only > analogous thing you could do in Python would be for all() to raise > ValueError when passed an empty sequence. There is also 'None' which serves a similar purpose of indicating an invalid value when pas

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Ron Adam wrote: > > hasall(S, True, lambda n: n=42) > That was suppose to be: hasall(S, True, lambda n: n==42) -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Steven D'Aprano wrote: > Paul Rubin wrote: > >> Steven D'Aprano <[EMAIL PROTECTED]> writes: >> >>> Think of it this way: if all(seq) is true, shouldn't it be the case >>> that you can point to a specific element in seq that is true? >> >> >> No, all(seq) is true if you can't point to a specific el

Re: any() and all() on empty list?

2006-03-30 Thread Ron Adam
Duncan Booth wrote: > Ron Adam wrote: > >> Where we are assembling widgets in a manufacturing plant. Where we don't >> want to go to the next step until *all* the sub parts are present. >> >> if all(part.status == 'present' for part in unit): >

Re: Content Management System

2006-03-29 Thread Adam
s much MX cr*p as it can - but it's a tall order! I've [even] used Joomla for pretty simple non-"blog" sites simply for the remote admin and the search functions. It really is best suited for the more "newsy" community sites. It's definitely worth a look at, IMHO. Adam. -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-29 Thread Ron Adam
Carl Banks wrote: > Steve R. Hastings wrote: >> I'm completely on board with the semantics for any(). But all() bothers >> me. If all() receives an empty list, it will return True, and I don't >> like that. To me, all() should be a more restrictive function than any(), >> and it bothers me to se

Re: any() and all() on empty list?

2006-03-29 Thread Ron Adam
Paul Rubin wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >> Just thinking about things. I really just want what is best for >> Python in the long term and am not trying to be difficult. > > I'm sorry, maybe it's the math geek in me, but I just see all tho

Re: any() and all() on empty list?

2006-03-29 Thread Ron Adam
Paul Rubin wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >> In this view and empty set can be True for all(). Is it posible >> 'all([])' is undefined? Here, none() and all() return contradicting >> values. So maybe the correct version may be... > >

Re: any() and all() on empty list?

2006-03-28 Thread Ron Adam
Paul McGuire wrote: > "Paul Rubin" wrote in message > news:[EMAIL PROTECTED] > To my mind, the *meaning* of all() is that every element in the list asserts > True. But this is with an initial assumption that all() is False, unless I > test every value and find them to b

Re: freeze.py and GTK apps

2006-03-28 Thread Adam DePrince
On Mon, 2006-03-27 at 16:15 -0800, [EMAIL PROTECTED] wrote: > After freezing a PYGTK app, I am unable to run it. It this a common > problem, because I could not find any documentation on it at all. > > I tried freezing this example, which gets by the make as well, but > running it results in a fa

Re: 1.090516455488E9 / 1000000.000 ???

2006-03-28 Thread Adam DePrince
516455488' >>> Works for me. Code snippet? Print does seem to round at 12 digits. >>> print 1.090516455488E9/100 1090.51645549 >>> Cheers - Adam DePrince > > I know something with float and //... > > Anybody? > How do I get correct number? -- http://mail.python.org/mailman/listinfo/python-list

Re: in-place string reversal

2006-03-28 Thread Adam DePrince
;Abc" >> myfancy_structre.add_somehow( s ) >> t = s[::-1] >> print s Abc >> print t cbA Now if strings were mutable: >> s = "Abc" >> myfancy_structre.add_somehow( s ) >> s.reverseme() >> print s cbA Other users of s between assignment and reversal (like myfancy_structure) might not be happy that is was reversed when they next must use it. Cheers - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
Alex Martelli wrote: > Ron Adam <[EMAIL PROTECTED]> wrote: > >> A "Current" key word would fix this. Or possibly "This" which would be >> short for "This object". > > I think "This" would cause huge confusion, since in oth

Re: Accessing func_name from inside a function

2006-03-26 Thread Ron Adam
Alex Martelli wrote: > Personally, I'd rather have a 3.0 keyword referring to "the current > object" (module for module toplevel code, class for classbody toplevel > code, function for code within a function) -- say for the sake of > argument the keyword is 'current'; this would allow current.__na

Re: wired md5 hashing problem

2006-03-26 Thread Adam DePrince
t;rb" ) while 1: block = f.read(1024*1024) if not block: break # generate the hash m.update(block) f.close() fd = file(fname + ".md5", "w") fd.write(m.hexdigest()) fd.write(" " + fname + "\n") fd.close() [EMAIL PROTECTED] ~]$ python test2.py [EMAIL PROTECTED] ~]$ md5sum -c Python-2.4.2.tar.bz2.md5 Python-2.4.2.tar.bz2: OK - Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: wired md5 hashing problem

2006-03-26 Thread Adam DePrince
What do you get when you type md5sum backup.tar.bz2? - Adam On Sun, 2006-03-26 at 16:56 +0200, Matthias Güntert wrote: > Hello list-members > > i am in the process of writing a python script to backup my data. Now I > would like to implement md5/sha1 hashes. >

Re: Extending Methods Vs Delegates

2006-03-26 Thread Adam DePrince
ow, as I work on my mutable sequences PEP and implementation, I find myself annoyed without a good, non-overloaded, way of naming an iter friendly variant of a data store's normal __delitem__. Actually, this wasn't more than a minute long problem, but the rate of collisions within the English word space is a problem. At least English is pretty friendly about adopted and synthetic words. Cheers - Adam -- http://mail.python.org/mailman/listinfo/python-list

PEP for nondeterminism.

2006-03-24 Thread Adam DePrince
The first calls for core language changes, the second calls for a minor (and likely symbolic) change to list comprehension's semantics to better support future parallelism. PEP: XXX Title: Nondeterminism Version: $Revision$ Last-Modified: $Date$ Author: Adam DePrince <[EMAIL PROTECTED]&g

Re: New Python logo in high resolution format

2006-03-24 Thread Adam DePrince
On Fri, 2006-03-24 at 10:49 -0800, Robert Hicks wrote: > How about we all get tatoos? : ) ... still trying to scrape the old one off ... > > Robert > -- http://mail.python.org/mailman/listinfo/python-list

Re: Incremental Compression

2006-03-24 Thread Adam DePrince
ing its memory of what it saw in the past. 3. Z_FINISH. This is the default action, this is what is killing you. Good luck - Adam DePrince > > I cannot wait until the end of the stream and then flush, because I need to > flush after every packet. > > Another capability I requ

Re: Caching in memory for Apache

2006-03-24 Thread Adam DePrince
for me to store > values inside memory so I can look it up on the next GET request? Your database really is the best place for that. Good luck - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying all the values in a dictionary

2006-03-24 Thread Adam DePrince
Droppings from other timing tests; starbucks was kicking me out and I was in a hurry. Cheers - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Bitwise OR?

2006-03-24 Thread Adam DePrince
number ): return _sign[number<0] + ''.join( [_nibbles[d] for d in hex( number )] ).lstrip( '0' ) Now I know, my negative number sematincs are different than yours, I'll leave fixing that as an exercise to you. python2.4 -mtimeit -s 'from test_a import bitstring' 'bitstring(343890242);bitstring(-343890242)' 1 loops, best of 3: 27.1 usec per loop python2.4 -mtimeit -s 'from test_b import bitstring1' 'bitstring1(343890242);bitstring1(-343890242)' 10 loops, best of 3: 10.9 usec per loop python2.4 -mtimeit -s 'from test_b import bitstring2' 'bitstring2(343890242);bitstring2(-343890242)' 10 loops, best of 3: 11.2 usec per loop And if I use a map, well, its not a statistically significant difference. def bitstring_nibblemap( number ): return _sign[number<0] + ''.join( map( _nibbles.get, hex( number ))).lstrip( '0' ) python2.4 -mtimeit -s 'from test_b import bitstring_nibblemap' 'bitstring_nibblemap(343890242);bitstring_nibblemap(-343890242)' 10 loops, best of 3: 10.7 usec per loop Cheers - Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: overlapping sets

2006-03-23 Thread Adam DePrince
ut, but your biggest impediment is how you are looking at the problem. For reference http://www.python.org/doc/essays/graphs.html As for detecting neighboors, sure that's easy, but first you have to try to use a for loop first on your own to tell how many positional items any two lists differ by. Cheers and good luck - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying all the values in a dictionary

2006-03-23 Thread Adam DePrince
Excuse me, I mean python2.4 -mtimeit -s 'from numarray import array; d = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]}; x = dict(d);' 'for i in x.values(): i[0]*=1;i[1]*=1' 100 loops, best of 3: 1.72 usec per loop i[0]*=1, not j[0]*=1 ... -- http://mail.python.org/mailman/listinfo/p

Re: Multiplying all the values in a dictionary

2006-03-23 Thread Adam DePrince
Wait! It occured to me. Why are we touching the key at all. This is a dictionary with mutable values. [EMAIL PROTECTED] ~]$ python2.4 -mtimeit -s 'd = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]}; x = dict(d)' 'for i in x.values(): i[:]=[j*1 for j in i]' 10 loops, best of 3: 2.79 us

Re: Multiplying all the values in a dictionary

2006-03-23 Thread Adam DePrince
Yes, I cede that explicit indexing is faster by quite a bit. There is a somewhat philosophical decision for why I avoided that. I prefer to try to present python with as big of a picture of what I want as possiable. update tells python what I want to do, whereas the for-loop describes how to. I

Re: Getting a loop to activate a loop above it

2006-03-23 Thread adam . deprince
This is how python is supposed to work. I'm sure not what languages you have used ... it seems that you are expecting some sort rule based system like make, or prolog. Grab a cup of joe, pull up a chair and let me help you out here. Python is an imperative language, you can envision the presence

Re: Multiplying all the values in a dictionary

2006-03-23 Thread adam . deprince
>for key in d: > d[key] = [x*2 for x in d[key]] > Naw, if you are going to use list interpolation go all the way and save yourself all of that ugly indexing into the dict. >>> d = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]} >>> d.update( [[key,[x*2 for x in item]] for key,item in d.

Re: Confused: appending to a list

2006-03-23 Thread adam . bachman
You're wanting it to stop when the len(list) == 4, right? The easiest way to change the logic would be to say while len(list) != 4: but that could get you into trouble later on. The problem with the len(list) < 5 expression is that the loop will run "one more time" as long as len(list)

Re: TaskQueue

2006-03-21 Thread Ron Adam
Raymond Hettinger wrote: > I would like to get feedback on an idea I had for simplifying the use > of queues with daemon consumer threads > > Sometimes, I launch one or more consumer threads that wait for a task > to enter a queue and then work on the task. A recurring problem is that > I sometime

Re: ** Operator

2006-03-20 Thread Ron Adam
Christoph Zwerschke wrote: > Alex Martelli wrote: >> Sathyaish wrote: >> >>> I tried it on the interpreter and it looks like it is the "to the power >>> of" operator symbol/function. Can you please point me to the formal >>> definition of this operator in the docs? >> >> http://docs.python.org/ref/

Re: Is there such an idiom?

2006-03-19 Thread Ron Adam
Per wrote: > Thanks Ron, > surely set is the simplest way to understand the question, to see > whether there is a non-empty intersection. But I did the following > thing in a silly way, still not sure whether it is going to be linear > time. > def foo(): > l = [...] > s = [...] > dic =

Re: Is there such an idiom?

2006-03-19 Thread Ron Adam
Per wrote: > http://jaynes.colorado.edu/PythonIdioms.html > > """Use dictionaries for searching, not lists. To find items in common > between two lists, make the first into a dictionary and then look for > items in the second in it. Searching a list for an item is linear-time, > while searching a

Re: Initializing a list of lists

2006-03-19 Thread Ron Adam
[EMAIL PROTECTED] wrote: > I want to create a list of lists, each of which is identical, but which > can be modified independently i.e: > x = [ [0], [0], [0] ] x[0].append(1) x > [[0, 1], [0], [0]] > > The above construct works if I have only few items, but if I have many, > I'd pr

Re: Can I use a conditional in a variable declaration?

2006-03-19 Thread Ron Adam
[EMAIL PROTECTED] wrote: > I've done this in Scheme, but I'm not sure I can in Python. > > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" > > in this more compact form: > > > a = (if a == "yes": "go ahead": "stop") > > > is there such

Re: strange math?

2006-03-18 Thread Ron Adam
[EMAIL PROTECTED] wrote: f(01) > 43 f(02) > 44 f(010) > 50 42+010 > 50 > > The first f(01) was a mistake. I accidentally forgot to delete the > zero, but to my suprise, it yielded the result I expected. So, I tried > it again, and viola, the right answer. So, I decided to r

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
vbgunz wrote: > OK. I hope my understanding of the yield keyword and generators in a > general sense are now better understood. When a generator function is > assigned to an identifier, no code is executed and a generator is > immediately returned. When the next() method is called on the new > gene

Re: My Generator Paradox!

2006-03-17 Thread Ron Adam
Robert Kern wrote: > vbgunz wrote: >> I believe I understand now. the yield keyword is sort of like a cousin >> to return. return will bring back an object I can work with and so does >> yield *but* yield's object will most likely support the .next() method. > > No, that's not really how it works.

<    5   6   7   8   9   10   11   12   13   14   >