ANNOUNCE: twill 0.8.4
ANNOUNCING twill v0.8.4. twill is a simple language for browsing the Web. It's designed for automated testing of Web sites, but it can be used to interact with Web sites in a variety of ways. In particular, twill supports form submission, cookies, redirects, and HTTP authentication. A twill script to use the I'm feeling lucky button on Google looks like this: setlocal query twill Python go http://www.google.com/ fv 1 q $query submit btnI # use the I'm feeling lucky button show (Note that using this script abuses Google's Terms of Service. So don't.) This is the ninth public release of twill, version 0.8.4. You can install twill with easy_install, or download this release at http://darcs.idyll.org/~t/projects/twill-0.8.4.tar.gz Documentation is included in the .tar.gz and is also online at http://www.idyll.org/~t/www-tools/twill/ Miscellaneous details: twill is implemented in Python and uses pyparsing and mechanize. In addition to the existing simple command language, twill can easily be extended with Python. twill also provides a fairly simple and well-documented wrapper around mechanize. twill does not understand JavaScript, I'm sorry to say. --- Significant changes with 0.8.4: * improved installation docs and simplified installation; * added link checking, requirements processing, and arguments parsing extension modules. * improved extension module handling; added extension module documentation. * fixed memory leaks. * fixed tidy problem on Windows. * line number of scripts printed on traceback. * fixed file:// URLs. * added option for debugging HTTP-EQUIV REFRESH code. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: Python Enthought Edition Version 0.9.3 Released
Enthought is pleased to announce the release of Python Enthought Edition Version 0.9.3 (http://code.enthought.com/enthon/) -- a python distribution for Windows. 0.9.3 Release Notes: Version 0.9.3 of Python Enthought Edition includes an update to version 1.0.3 of the Enthought Tool Suite (ETS) Package-- you can look at the release notes for this ETS version here. Other major changes include: * upgrade to VTK 5.0 * addition of docutils * addition of numarray * addition of pysvn. Also, MayaVi issues should be fixed in this release. Full Release Notes are here: http://code.enthought.com/release/changelog-enthon0.9.3.shtml About Python Enthought Edition: --- Python 2.3.5, Enthought Edition is a kitchen-sink-included Python distribution for Windows including the following packages out of the box: Numeric SciPy IPython Enthought Tool Suite wxPython PIL mingw f2py MayaVi Scientific Python VTK and many more... More information is available about all Open Source code written and released by Enthought, Inc. at http://code.enthought.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
IAF Release 0.01
The IAF Release 0.01 is now available. This is the initial release of IAF. IAF (=Interaction Framework) is a framework for reactive and distributed systems. It provides high-level message passing services based on group communication. It is also very useful for integrating component-based systems. It is freely available for personal and commercial use. Proceed to http://www.gil-mueller.com/freecorner.html for more information and for downloading the IAF. -- Gil Müller Felgergasse 5, D-70372 Stuttgart Tel. +49(0)711-5091785 Fax +49(0)711-5091711 E-Mail: [EMAIL PROTECTED] WWW: http://www.gil-mueller.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
wxPython in Action
Hi All, Just a quick note to let you know that our book, wxPython in Action is now officially available for sale. The book is currently only available at Manning's website but will slowly become available through retail stores over the next few weeks. Anyone in a hurry can order it at the publisher's website and get a free e-book with the print edition (the e-book is not sold anywhere else). http://www.manning.com/books/rappin -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Bitwise OR?
Why is 3500 | -67 equal to 3500 instead of -3567? -- http://mail.python.org/mailman/listinfo/python-list
Re: Strings and % sign fails - Help Please
[EMAIL PROTECTED] wrote: heh.. It works except I am using psycopg.Binary(somebinarystructure), and I am not really doing it by hand to just add the extra %, and psycopg.Binary doesn't do it. I'd imagine it's a bug with psycopg package. or a bug in your use of Binary. what exactly are you applying Binary to, and how do you pass the resulting adapter to execute ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: doctest, unittest, or if __name__='__main__'
Marc 'BlackJack' Rintsch wrote: I see it this way: `unittest` is for testing code and `doctest` is for testing examples in docstrings. If you put all your tests in the docstrings there will be much code that's quite irrelevant for documenting the function/method/class. so put the tests in your test program instead, and use doctest to make sure that the test program works as advertised. (or use doctest on separate test scenario documents) if you prefer the doctest approach, there's no reason to use unittest for anything. /F -- http://mail.python.org/mailman/listinfo/python-list
RE: pydoc does not like this file
I'm not trying to run py2exe I'm trying to generate a html file with documentation (hence pydoc -w) (python -w doesn't even exist) I have a directory whith 4 files: checkvalue.py -- the actual source with documentation helperfunctions.py -- some extra functions setup.py-- settings file for py2exe build.bat -- batch file to do the actual build when trying to build the documentation for the whole directory (and not run it 2 times for the 2 py files that need documentation) pydoc choces on the setup.py file joram -Original Message- From: Jesus Rivero - (Neurogeek) [mailto:[EMAIL PROTECTED] Sent: Thursday, 23 March, 2006 19:47 To: Joram Agten Cc: python-list@python.org Subject: Re: pydoc does not like this file -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hmmm guess -w should be after python and not after pydoc: python -w c:\python24\Lib\pydoc.py .\setup.py And i also guess you are missing a command after setup.py (if you are using py2exe, that must be the command you are looking for.) so try this: $ python -w c:\python24\Lib\pydoc.py .\setup.py py2exe Best Regards, Jesús Rivero - (Neurogeek) Joram Agten wrote: Hello please put me in CC I'm trying pydoc as documentation for my projects but I have the following problem when runnig pydoc on my whole project there is also a file setup.py (from py2exe) but pydoc gives me the following for that file: [D:\programming\trunk\tecap\joag\checkvalue]python c:\python24\Lib\pydoc.py -w .\setup.py problem in .\setup.py - SystemExit: usage: pydoc.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: pydoc.py --help [cmd1 cmd2 ...] or: pydoc.py --help-commands or: pydoc.py cmd --help error: option -w not recognized there are no statements or functions in that file, and also no documentation anybody has any idea? joram -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEIu09dIssYB9vBoMRAmfOAJ4h9mb5PgD/ZTWdh1VDu6GMvAb5DgCfTpPz 4UgOQcwkH6VhPQpjZI15nW0= =W2ZS -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange metaclass behaviour
After 5 years of Python, I still find it impressive how much vodoo and mojo one can do here :-) True ;) However, I should point out that I never use this stuff in production code. I have found out that for my typical usages metaclasses are too much: a class decorator would be enough and much less fragile. At the present, we do not have class decorators, but we can nearly fake them with a very neat trick: def thisclass(proc, *args, **kw): Example: def register(cls): print 'registered' ... class C: ...thisclass(register) ... registered # basic idea stolen from zope.interface, which credits P.J. Eby frame = sys._getframe(1) assert '__module__' in frame.f_locals # inside a class statement def makecls(name, bases, dic): try: cls = type(name, bases, dic) except TypeError, e: if can't have only classic bases in str(e): cls = type(name, bases + (object,), dic) else: # other strange errors, such as __slots__ conflicts, etc raise del cls.__metaclass__ proc(cls, *args, **kw) return cls frame.f_locals[__metaclass__] = makecls Figured you would like this one ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
xkenneth schrieb: Why is 3500 | -67 equal to 3500 instead of -3567? It isn't - its -67. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: overlapping sets
kpp9c wrote: I have a question... and ... whew ... i am gonna be honest, i haven't the slightest clue how to even start ... i am not sure if i used up all my good will here or can take a mulligan.. i love to try to at least post some lame broken code of my own at first... but like i said, not being a math person i am not even sure how to start or if it is even possible. here's the deal... i have a dictionary that defines some collections.. like so: sets = { ('one') : [0, 4, 7, 9 ], ('two') : [0, 3, 7, 9 ], ('three') : [0, 4, 7, 11], ('four') : [0, 3, 7, 10 ], ('five') : [0, 4, 7, 10 ], ('six') : [0, 4, 8, 10 ], ('seven') : [0, 3, 6, 10], ('eight') : [0, 3, 6, 9 ], ('nine') : [0, 3, 7, 11 ], ('ten') : [0, 5, 7, 10 ] } I every time i call this function i would like like it to return a collection at random, any collection, so long as it has all but one element that is the same. So if i grab [0, 4, 7, 9 ] as my first set my next set could be: [0, 3, 7, 9 ], or [0, 4, 8, 9 ], or [0, 4, 7, 10], or [1, 4, 7, 9 ], since all these sets contain 3 elements in common with the first, and only one that is new or different... but if my first run give me: [0, 4, 7, 9 ] i would not get [0, 5, 7, 10 ], since this is set has 2 elements that are unique. The goal it to move from set to set to set to set always with a maximum of overlap common elements. I wonder, if this is even possible, *and* if it can be done with sets that have as many as 7, 8, or even 9 elements or if this would be too slow to even attempt. cheers, kp8 [for the record using python 2.3 on a macintosh at the moment] Here's an example of a possible approach. It uses a naive search algorithm, but it should illustrate the general idea: # Search for a path through the nodes that changes only one member per step nodes = [[0, 3, 6, 10], [0, 5, 7, 10], [0, 3, 7, 11], [0, 4, 8, 10], [0, 4, 7, 11], [0, 3, 7, 9], [0, 3, 7, 10], [0, 4, 7, 10], [0, 3, 6, 9], [0, 4, 7, 9]] try: frozenset except NameError: # 2.3 compatibility, untested from sets import ImmutableSet as frozenset def get_graph(nodes): From a list of sequences, return a graph, mapping each node to its neighbors - defined as nodes with all but one common element graph = dict.fromkeys([frozenset(s) for s in nodes]) for s in graph: neighbor_len = len(s)-1 graph[s] = [t for t in graph if len(st)==neighbor_len] return graph def walk_nodes(nodes, walk_length = None): if walk_length is None: walk_length = len(nodes) graph = get_graph(nodes) def add_move(history): for path in history: last_move = path[-1] # remove the last_move from the graph: we can't go there again possible_next = graph.pop(last_move) # look in sequence at the possible neighbors # this is a naive - a better heuristic would perhaps be to # visit neighbors with fewer exits first for next in possible_next: if next in graph: # if the node is still in the paths dict, we haven't # visited it yet, so let's go yield path + [next] # Pick a starting point - naive! history = [graph.keys()[0]], # set up n nested generators, each representing one move depth for move in range(walk_length-1): history = add_move(history) # yield a generator of all paths through the graph of length walk_length # by trial and error, you can find the longest path return history Apparently, there is no path through all 10 nodes: list(walk_nodes(nodes)) [] But there are a couple of 7-node paths: list(walk_nodes(nodes,7)) [[frozenset([0, 9, 3, 6]), frozenset([0, 9, 3, 7]), frozenset([0, 11, 3, 7]), frozenset([0, 11, 4, 7]), frozenset([0, 10, 4, 7]), frozenset([0, 10, 3, 7]), frozenset([0, 10, 3, 6])], [frozenset([0, 9, 3, 6]), frozenset([0, 9, 3, 7]), frozenset([0, 11, 3, 7]), frozenset([0, 11, 4, 7]), frozenset([0, 10, 4, 7]), frozenset([0, 10, 3, 7]), frozenset([0, 10, 5, 7])]] HTH, Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
xkenneth wrote: Why is 3500 | -67 equal to 3500 instead of -3567? Well that's funny... On my computer, python says it's -67. Java also says it's -67. Haven't yet looked at the actual bits of both values. What Python implementation and what machine do you have? --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about raw string and regex
classfix.py is not an *example* script. It is (was!) a *tool* script. I see. 2.4.2 includes a tool for modifying 0.9.8 python classes to 1.1 somthing format using a now-defunct regex module. Oh, okay. Very useful, I can see why it would still be included as part of the distribution. I was using 'regex' as the general term for regular expressions, not the module. I hadn't realized the (old, decrepit) script was using something other than 're' (r standing for 'regular', and e for 'expressions' [I'm guessing]). Pylint (with everything switched on) doesn't flag anything as deprecated, or at least I didn't notice that it did. Maybe it was because the method for deprecation hadn't been devised yet? -- I don't know, as I'm not a Python archivist. I don't think I missed line 3, but just interpeted it to apply to the purpose of the script, not the script itself. And, BTW, people will look at the source that's distributed with Python for purposes of writing their own code, be it in tools, libs, or whatever. They (should) serve as examples of current practice, IM(H)O. Old cruft should go in a source archive to dwell in the shadows forevermore. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about raw string and regex
I understood the comment, just misinterpreted the meaning of the first statement. And speaking of my attitude, it's just as bad as anyone else's here. Double check the membership of the comp.lang.python set... -- http://mail.python.org/mailman/listinfo/python-list
Re: Why class exceptions are not deprecated?
[EMAIL PROTECTED] wrote: The OP points out an ambiguity in the docs, and as usual, gets told he can't read, etc. How typical. where did anyone tell the OP that he can't read? it's pretty clear that you have trouble reading things without mixing them up with your own preconceptions, but we already knew that. Maybe if comments like this were encouraged and acted upon do you think your posts would look any different if we replaced you with a markov generator and fed it with your old posts ? if you want to contribute, contribute. a new tutorial would be great. get to work! /F -- http://mail.python.org/mailman/listinfo/python-list
Problem binding to Active Directory
I use the following script:from win32com.client import GetObject, Dispatchuser=''password=''default_naming_context = GetObject(LDAP://rootDSE).Get(defaultNamingContext)ad = GetObject(LDAP:).OpenDSObject(LDAP://%s % default_naming_context, user, password, 1 + 512) If user password contain a correct value the script works. According to the ADSI documentation, replacing user and password with NULLstrings should use the credentials of the currently logged on user. In _vbscript_ this works, but in Python I get different errormessages depending on what I pass as value to these parameters. Can somebody tell me how to do this? How can I pass a NULL-string hereThanks in advance,Rudy -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
Actually, following up to my own reply: 3500 | 67 = 3567. So perhaps that sets your expectations for 3500 | -67. But try -3500 | -67 for fun: it is -3 Bitwise or is no arithmetic and if you want to predict something about the resulting integers, you should know something about how they are stored. Negative integers are stored in 2-complement format: minus 1 is all bits set to 1. Turning bits off makes it a more negative number (as long as you don't touch the sign-bit) and turning more bits on makes it a smaller negative number. Doing bitwise-OR for the positive numbers 3500 and 67 results in 3567: proof that they don't have any overlapping bits. Know it turns out that 3500 and -67 have only overlapping bits: therefore the result is -67. (adding the bits from 3500 to the bits of -67 doesn't turn on any extra bits). Use bit operators to manipulate bits, and think of the operands as sets of bits. Bitwise OR is the union of 2 sets of bits. Don't think of the operands to bit operators as numbers, and don't try to do your sums using bitwise or! :-) --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems (� and
Peter Otten wrote: You can replace ALL of this upshifting and accent removal in one blow by using the string translate() method with a suitable table. Only if you convert to unicode first or if your data maintains 1 byte == 1 character, in particular it is not UTF-8. There's a nice little codec from Skip Montaro for removing accents from latin-1 encoded strings. It also has an error handler so you can convert from unicode to ascii and strip all the accents as you do so: http://orca.mojam.com/~skip/python/latscii.py import latscii import htmlentitydefs print u'\u00c9'.encode('ascii','replacelatscii') E So Bussiere could replace a large chunk of his code with: ligneA = ligneA.decode(INPUTENCODING).encode('ascii', 'replacelatscii') ligneA = ligneA.upper() INPUTENCODING is 'utf8' unless (one possible explanation for his problem) his files are actually in some different encoding. Unfortunately, just as I finished writing this I discovered that the latscii module isn't as robust as I thought, it blows up on consecutive accented characters. :( -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiplying all the values in a dictionary
Em Qui, 2006-03-23 às 21:23 -0800, Adam DePrince escreveu: Wait! It occured to me. Why are we touching the key at all. This is a dictionary with mutable values. This idea occured to me but I always forget about the [:] trick, so I didn't try it :). Now, we *know* that all of the values are lists of length 2, so why not say this instead: python2.4 -mtimeit -s 'from numarray import array; d = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]}; x = dict(d);j=[0,0]' 'for i in x.values(): j[0]*=1;j[1]*=1' 100 loops, best of 3: 1.7 usec per loop Why do you import numarray? o.O Nice approach, though. -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list
About Image Size
Finally I found that getSize()can be used to show the size of the image. but here I got another problem. dtml-let images=objectItems('Image') dtml-in images reverse sort=bobobase_modification_time size=1 orphan=0 dtml-let item=sequence-item name=item.id() dtml-var name.getSize() /dtml-let /dtml-in /dtml-let these code is used to show the last uploaded picture's size. But when I run the method it says Error Type: AttributeError Error Value: 'str' object has no attribute 'getSize' Could anyone help me out? Thanks a lot. Cheng -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
Dirk Thierbach wrote: Dinko Tenev [EMAIL PROTECTED] wrote: I don't see immediately how exactly this is going to work. Unless I'm very much mistaken, a FSA in the classical sense will accept or reject only after the whole sequence has been consumed, and this spells exponential times. Exponential in respect to what? With respect to sequence length. But you cannot get rid of this. Consider S = {a, b}, W = {a}. Then there are |S|^n result elements for n 1, and you have to enumerate all of them. Yes, but then, they are in the target set. The point here is whether you can generate S^n - W in Theta( n * |S^n - W| ), which may be dramatically different from Theta( n * |S^n| ). The best thing one can hope for is to just actually process those elements that are really in the result set. With the FSM, you're getting at least close to that. If the FSA has to consume the whole sequence, you're only impoving performace by a constant factor. The automaton is: S: a - A, b - B A: a - A B: b - B The target set is specified as S^n - W, where W is everything matching (.*a.*b|.*b.*a). Following the construction procedure in point, this exclusion set is matched exactly by my DFA with S initial and F final. Then, swapping final and non-final states makes {S, A, B} final, and F non-final. Your DFA above may be equivalent, but to me it is far from clear exactly what algorithm would build it from the given data. Looking at the minimal DFA for the above example, it may be more appropriate to detect being in a state from which there's no path to a final state: This cannot happen, because minimizing removes all those states. (Or, in case you have a different definition of automaton in mind: There'll be just one stuck state, where all transitions that never go to a final state end up. Remove this state, and you'll end up with the other definition). I have to admit that I've never considered this before, but as I'm thinking of it now, a block of such states will never split by minimization, so they're bound to end up together as a single state, which can then be eliminated. I can see your point now. I guess one could even optimize on that: In the minimal automaton, every state has some transition sequence that will end up in a final state. Annotate each state with the minimum number of steps for such a sequence. While walking the automaton, keep the maximum number of letters to produce in a variable. If this number is small then the number in the annotation, stop and backtrace. I don't think this could cut efficiently for patterns like *a*b. The point is not to cut efficiently, the point is to enumerate only those words that are actually in the result set. No, this is not the point. Naive filtering already does that. By cutting efficiently I mean skipping over search sub-trees that don't contain any results from the target set. If you can do this, you can enumerate the target set in time proportional to its size, not to the size of the search space, which is the point. Cheers, Dinko -- http://mail.python.org/mailman/listinfo/python-list
Re: About Image Size
Problem was solved thanks Cheng -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
[EMAIL PROTECTED] wrote: Call a wc 'free' if it satisfies the propery that every letter 'a' in it appears only in the form '*a*', and 'anchored' otherwise. What if all wc's are free? How does this affect the DFA? Does it minimize nontrivially? Keep in mind I'm new to DFA theory. There would be no difference for single patterns, but I'm not sure into how large a DFA a set of those would combine. Cheers, Dinko -- http://mail.python.org/mailman/listinfo/python-list
Re: Linear regression in NumPy
Robert Kern wrote: Both functions are described in the full book. Were you just looking at the sample chapter? No, I've got the full PDF by mail a few days ago, numpybook.pdf, 261 pages (I hope we're talking about the same thing). I entered linear_least_squares and polyfit in acrobat's find text box, but neither one could be found. -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems (é and è)
Duncan Booth wrote: There's a nice little codec from Skip Montaro for removing accents from latin-1 encoded strings. It also has an error handler so you can convert from unicode to ascii and strip all the accents as you do so: http://orca.mojam.com/~skip/python/latscii.py import latscii import htmlentitydefs print u'\u00c9'.encode('ascii','replacelatscii') E So Bussiere could replace a large chunk of his code with: ligneA = ligneA.decode(INPUTENCODING).encode('ascii', 'replacelatscii') ligneA = ligneA.upper() INPUTENCODING is 'utf8' unless (one possible explanation for his problem) his files are actually in some different encoding. Unfortunately, just as I finished writing this I discovered that the latscii module isn't as robust as I thought, it blows up on consecutive accented characters. :( You made me look into it -- and I found that reusing the decoding map as the encoding map lets you write uÉlève ééé.encode(latscii) 'Eleve eee' without relying on the faulty error handler. I tried to fix the handler, too: uÉlève ééé.encode(ascii, replacelatscii) 'Eleve eee' g = u\N{GREEK CAPITAL LETTER GAMMA} (umöglich ähnlich üblich ááá + g*3).encode(ascii, replacelatscii) 'moglich ahnlich ublich aaa???' No real testing was performed. Peter --- latscii_old.py 2006-03-24 11:45:22.580588520 +0100 +++ latscii.py 2006-03-24 11:48:13.191651696 +0100 @@ -141,7 +141,7 @@ ### Encoding Map -encoding_map = codecs.make_identity_dict(range(256)) +encoding_map = decoding_map ### From Martin Blais @@ -166,9 +166,9 @@ ## ustr.encode('ascii', 'replacelatscii') ## def latscii_error( uerr ): -key = ord(uerr.object[uerr.start:uerr.end]) +key = ord(uerr.object[uerr.start]) try: -return unichr(decoding_map[key]), uerr.end +return unichr(decoding_map[key]), uerr.start + 1 except KeyError: handler = codecs.lookup_error('replace') return handler(uerr) -- http://mail.python.org/mailman/listinfo/python-list
Re: imap folder scanner
A very simple example... import imaplib m = imap.IMAP4(myserver ip or host) m.login(username,password) m.select('myfolder') status, data = m.search(None,'(SUBJECT BIKES)') assert status=='OK', Error. Message: %s%data data = data[0] #you get your results in a list and search returns only one result assert data,No results #cool, we have results, but IMAP's search command only returns IDs so we have to fetch #msgs now status,senders = m.fetch(data.replace(' ',','),'(BODY.PEEK[HEADER.FIELDS (FROM)])') assert status=='OK', Error. Message: %s%data Now you just have to parse the senders data. There are many examples about sending emails with python, like this one: def send_notice(): import smtplib msg = 'we got your mail, indeed' from email.MIMEText import MIMEText mail = MIMEText(msg, 'plain', 'utf-8') mail['From'] =fro='[EMAIL PROTECTED]' mail['Subject'] = Spam machine mail['To'] = to = '[EMAIL PROTECTED]' server = smtplib.SMTP('localhost') errors = server.sendmail(fro, to, mail.as_string()) server.quit() That other program should be very simple to make now. Sebastjan On 3/24/06, Kun [EMAIL PROTECTED] wrote: Hey guys, I would like to have a code in python (as simple as possible) to scan a specific folder in my mailbox and if the subject is equal to, say, 'BIKES', I would like to have the code automatically send the SENDER an email saying something like We have received your Email. Furthermore, I would also like to somehow save the sender's email into a list which would be compiled by another python program into an html file that would show a list of email addresses whose subject matched 'BIKE' I know i am asking for a lot but since i am new to python, can someone help me out with this? Whether its tips or code, i'll be very excited to hear your answer. Thanks. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
To look at the bit-structure i've implemented a little function: def bitstring(number, digits=32): lsb--msb result = for a in xrange(digits): if number 1: result += '1' else: result += '0' number = 1 return result I wonder if there is something like sizeof() for int numbers. mfg - eth -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems (é and è)
On 24/03/2006 8:11 PM, Duncan Booth wrote: Peter Otten wrote: You can replace ALL of this upshifting and accent removal in one blow by using the string translate() method with a suitable table. Only if you convert to unicode first or if your data maintains 1 byte == 1 character, in particular it is not UTF-8. There's a nice little codec from Skip Montaro for removing accents from For the benefit of those who may read only this far, it is NOT nice. latin-1 encoded strings. It also has an error handler so you can convert from unicode to ascii and strip all the accents as you do so: http://orca.mojam.com/~skip/python/latscii.py import latscii import htmlentitydefs print u'\u00c9'.encode('ascii','replacelatscii') E So Bussiere could replace a large chunk of his code with: Could, but definitely shouldn't. ligneA = ligneA.decode(INPUTENCODING).encode('ascii', 'replacelatscii') ligneA = ligneA.upper() INPUTENCODING is 'utf8' unless (one possible explanation for his problem) his files are actually in some different encoding. Unfortunately, just as I finished writing this I discovered that the latscii module isn't as robust as I thought, it blows up on consecutive accented characters. :( Some of the transformations are a little unfortunate :-( 0x00d0: ord('D'), # Ð 0x00f0: ord('o'), # ð Icelandic capital eth becomes D, OK; but the small letter becomes o!!! The Icelandic thorn letters become P p (based on physical appearance), when they should become Th and th. The German letter Eszett (00DF) becomes B (appearance) when it should be ss. Creating alphabetics out of punctuation is scarcely something that bussiere should be interested in: 0x00a2: ord('c'), # ¢ 0x00a4: ord('o'), # ¤ 0x00a5: ord('Y'), # ¥ 0x00a7: ord('S'), # § 0x00a9: ord('c'), # © 0x00ae: ord('R'), # ® 0x00b6: ord('P'), # ¶ -- http://mail.python.org/mailman/listinfo/python-list
Re: New development windows, IronPython or PythonWin
IronPython is currently nowhere near production quality. I would not recommend it. I realise its in beta. But long term, do you think that the win32com, win32gui etc... will have no support because everyone jumps on the Microsoft bandwagon? Aren't the windows support extensions supported primarily by one guy, Mark Hammond? As a developer, this seams to leave me with a vulnerability long term. Thanks for the advise. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
Hello, I've written a little (optimized) method to get a bit-string: def bitstringneg(number, digits=32): optimized for negative numbers result = for a in xrange(digits): if number 1: result += '1' else: result += '0' number = 1 return result def bitstringpos(number): optimized for positive numbers result = while number: if number 1: result += '1' else: result += '0' number = 1 return result def bitstring(number, digits=32): lsb--msb result = if number 0: return bitstringneg(number, digits) else: return bitstringpos(number) BTW: Is there something like a sizeof() method for int numbers? mfg - eth -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange metaclass behaviour
Michele Simionato wrote: snip There is a minor bug in your code: def thisclass(proc, *args, **kw): Example: def register(cls): print 'registered' ... class C: ...thisclass(register) ... registered # basic idea stolen from zope.interface, which credits P.J. Eby frame = sys._getframe(1) assert '__module__' in frame.f_locals # --- here def makecls(name, bases, dic): try: cls = type(name, bases, dic) except TypeError, e: if can't have only classic bases in str(e): cls = type(name, bases + (object,), dic) else: # other strange errors, such as __slots__ conflicts, etc raise del cls.__metaclass__ proc(cls, *args, **kw) return cls frame.f_locals[__metaclass__] = makecls Figured you would like this one ;) Michele Simionato See this example: import sys def in_class_statement1(): ... frame = sys._getframe(1) ... return '__module__' in frame.f_locals ... def in_class_statement2(): ... frame = sys._getframe(1) ... return '__module__' in frame.f_locals and not \ ...'__module__' in frame.f_code.co_varnames ... class A(object): ... print in_class_statement1() ... print in_class_statement2() ... True True def f(): ... __module__ = 1 ... print in_class_statement1() ... print in_class_statement2() ... f() True False -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems (é and è)
John Machin wrote: 0x00d0: ord('D'), # Ð 0x00f0: ord('o'), # ð Icelandic capital eth becomes D, OK; but the small letter becomes o!!! I see information flow from Iceland is a bit better than from Armenia :-) Some of the transformations are a little unfortunate :-( The OP, as you pointed out in your first post in this thread, has more pressing problems with his normalization approach. Lastly, even if all went well, turning a list of French addresses into an ascii-uppercase graveyard would be a sad thing to do... Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange metaclass behaviour
Well, I would not call it a bug, I would call it to cheat ;) The assert is there I just wanted to prevent accidents, not to *really* ensure that 'thisclass' is called inside a class statement. Do you know of any reliable method to enforce that restriction? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: mydate.strftime('%x') and cgi script
Marc 'BlackJack' Rintsch schrieb: In [EMAIL PROTECTED], Sibylle Koczian wrote: The web server is on my machine - doesn't it use its regional settings? The settings are per user and stored in environment variables. Apache clears most of them at start. `setlocale()` is executed but if there are no environment variables (LANG, LC_*) then the default locale `C` is chosen. And these environment variables aren't there because Apache has cleared them at start - right? Thank you, Koczian -- Dr. Sibylle Koczian Universitaetsbibliothek, Abt. Naturwiss. D-86135 Augsburg e-mail : [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple assignment
Anand wrote: Suppose i have a big list and i want to take tke the first one and rest of the list like car/cdr in lisp. is there any easy way to do this in python? It seems like overkill to me to make the syntax more complex just to avoid writing a one-line function. def first_rest(seq): return seq[0], seq[1:] -- http://mail.python.org/mailman/listinfo/python-list
Upload and Resize image problem HELP!!!
I use following Python Script to upload file and image's but I can not specify a folder to store image. can any one help me? And I want to resize all the pictures, What shall I do? dtml-call REQUEST.set('file_type', file.headers['Content-Type'] ) dtml-let destination=context.restrictedTraverse('/cheng/test/image') dtml-if file_type.find('image')!=-1 dtml-call destination.manage_addImage(REQUEST['id'], file, REQUEST['title']) dtml-else dtml-call destination.manage_addFile(REQUEST['id'], file, REQUEST['title']) /dtml-if /dtml-let Finished thanks Cheng -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
I wonder what causes one version to be faster for positive, and the other faster for negative numbers? I can see that the pos-version doesn't make as many iterations as the neg version, but it doesn't pad the length of the result to the requested number of digits and potentially produces more digits. I also wonder if it wouldn't be faster to put the numbers into a list and join the list into a string -- did you test with that? Cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange metaclass behaviour
Ziga Seilnacht wrote: def in_class_statement2(): ... frame = sys._getframe(1) ... return '__module__' in frame.f_locals and not \ ...'__module__' in frame.f_code.co_varnames On second thought, to break this check is less easy than I expected, so maybe it is reliable enough. BTW, if you are interested, you can check the original code in zope.interface.advice. -- http://mail.python.org/mailman/listinfo/python-list
Re: raw_input
Tim Williams (gmail) wrote: The following will accept any subset of carmel in upper, lower or mixed case EG Carmel, carmel, Carm, mel etc if raw_input (hello what's your name? ).lower() in 'carmel': print Ahh the boss's wife It's so powerful, it accepts even the empty string... try typing just the ENTER key... -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Python has a new Logo
Xah Lee wrote: Python has a new logo! So does the bakery around the corner! Oh ... and by the way, our butcher now has a new till. 'thought you'd like to know. -- josef punkt moellers bei gmx punkt de -- http://mail.python.org/mailman/listinfo/python-list
RE: Remove integer from float number
Sorry about the Top Posting that I did before. It is just the style I am used to using, and I didn't realize that it was different here. I won't do it again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Remove integer from float number
kpp9c wrote: okay... out of curiousity... how would you then seperate the interger value from the fractional part do something to one side and then put it back together... like if you had 8.01 and you want to add to the '8' part in one way (ordinary decimal) and add to the .01 part modulo something .. like say modulo 12 so that adding .11 to 8.01 would give you 9.0 ... I believe math.modf() may be what you're looking for. -- http://mail.python.org/mailman/listinfo/python-list
Re: overlapping sets
kpp9c wrote: I have a question... and ... whew ... i am gonna be honest, i haven't the slightest clue how to even start ... i am not sure if i used up all my good will here or can take a mulligan.. i love to try to at least post some lame broken code of my own at first... but like i said, not being a math person i am not even sure how to start or if it is even possible. here's the deal... i have a dictionary that defines some collections.. like so: sets = { ('one') : [0, 4, 7, 9 ], ('two') : [0, 3, 7, 9 ], ('three') : [0, 4, 7, 11], ('four') : [0, 3, 7, 10 ], ('five') : [0, 4, 7, 10 ], ('six') : [0, 4, 8, 10 ], ('seven') : [0, 3, 6, 10], ('eight') : [0, 3, 6, 9 ], ('nine') : [0, 3, 7, 11 ], ('ten') : [0, 5, 7, 10 ] } I every time i call this function i would like like it to return a collection at random, any collection, so long as it has all but one element that is the same. So if i grab [0, 4, 7, 9 ] as my first set my next set could be: [0, 3, 7, 9 ], or [0, 4, 8, 9 ], or [0, 4, 7, 10], or [1, 4, 7, 9 ], since all these sets contain 3 elements in common with the first, and only one that is new or different... but if my first run give me: [0, 4, 7, 9 ] i would not get [0, 5, 7, 10 ], since this is set has 2 elements that are unique. The goal it to move from set to set to set to set always with a maximum of overlap common elements. probably not very efficient but I think it roughly does what you want. (maybe add a boolean 'sort' parameter, to select sorted output or not): # k is the length of the required output lists, 0kn # n is the number of lists to output import random alphabet = [ 0, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] def randomiser( a_list, n, k ): d = len( a_list ) choice = range(d) vector = [] for i in range(k): vector.append( choice.pop(random.randint(0,d-i-1)) ) yield [ a_list[s] for s in vector ] #yield sorted( a_list[s] for s in vector ) for _ in range(n): rand_vector_idx = random.randint(0,k-1) rand_choice_idx = random.randint(0,d-k-1) rand_vector_val = vector[rand_vector_idx] #remember old value vector[rand_vector_idx] = choice.pop( rand_choice_idx ) choice.append( rand_vector_val ) #add old value back to choice yield [ a_list[t] for t in vector ] #yield sorted( a_list[t] for t in vector ) print for item in randomiser(alphabet, 10, 4): print item [3, 6, 9, 8] [3, 6, 9, 0] [3, 11, 9, 0] [3, 11, 10, 0] [9, 11, 10, 0] [9, 11, 7, 0] [9, 4, 7, 0] [9, 3, 7, 0] [9, 11, 7, 0] [9, 11, 7, 8] [9, 11, 10, 8] Gerard -- http://mail.python.org/mailman/listinfo/python-list
Suggestion for Web App
I want to make a recommendation to a group of internal customers where I work concerning a Python web framework. They are seeking to build a portal that can handle around 5000 total users but probably no more than 100-200 simultaneous users. This is supposed to serve mainly static content - the content will hold references, tutorials and examples for different technologies, a forum (similar probably to phpbb) and podcasts (rss and mp3 files). Also I believe it will definitely need a decent DB server for this. They have some other suggestions ranging from Websphere/JSP's to PHP. I personally don't think the PHP will scale well for growth and I also think that using Java/JSPs will be too slow for this sort of thing. I normally work as system and application admin and use Python in a number of ways to get the job done. Naturally, I am naturally inclined to suggest something that uses Python or something Pythonic. I wanted to suggest Zope but there are also other ones I'm thinking of as well like CherryPy and Karrigell. Which one of these (or other ones you guys know of) would do the best job in this situation? Also do you guys know if MySQL would work with this or should they use something more robust like DB2 (IBM shop)? Any suggestions are welcome. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
Dinko Tenev [EMAIL PROTECTED] wrote: Dirk Thierbach wrote: [One cannot escape exponential behaviour] But you cannot get rid of this. Consider S = {a, b}, W = {a}. Then there are |S|^n result elements for n 1, and you have to enumerate all of them. Yes, but then, they are in the target set. Which is the point. If they are in the target set, you have to enumerate them. If the target set is of exponential size with respect to n, then you'll need exponential time to do that. The point here is whether you can generate S^n - W in Theta( n * |S^n - W| ), which may be dramatically different from Theta( n * |S^n| ). Exactly. Hence, you use a construction that guarantees that the time needed is proportional to n*|S^n - W|: Every step you do will be enecessary to produce at least one word in the output set. Now, if |S^n - W| is still exponential, then you'll still need exponential time. But nevertheless, that's the best you can hope for. The automaton is: S: a - A, b - B A: a - A B: b - B The target set is specified as S^n - W, where W is everything matching (.*a.*b|.*b.*a). Following the construction procedure in point, this exclusion set is matched exactly by my DFA with S initial and F final. Then, swapping final and non-final states makes {S, A, B} final, and F non-final. Your DFA above may be equivalent, but to me it is far from clear exactly what algorithm would build it from the given data. Well, it's just the result from the minimazation algorithm, where my variant of the algorithm just prunes away the stuck state which can never produce any output. The point is not to cut efficiently, the point is to enumerate only those words that are actually in the result set. No, this is not the point. Naive filtering already does that. No, it doesn't. Naive filtering always will look at the complete input set, so, no matter what size |S^n - W| actually is, it will always take time in proportion to |S^n|. By cutting efficiently I mean skipping over search sub-trees that don't contain any results from the target set. Yes. Consider a different example: With the wildcard expressions W = { b*, aa*, ab* }, you'll get S^* - W = { a }. The resulting minimum FSM will just accept 'a' (start state, one final state, and the stuck state if you insist on it), so you skip over every other subtree when enumerating results from that automaton. And for the previous example, you'll need something like 2*n time to enumerate the output set instead of 2^n, because once you're in the a-branch, you're producing only a's, and you're pruning away all the subtrees that start with a b. Similarly in the b-branch. Now clearer? - Dirk -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
Tim N. van der Leeuw wrote: I also wonder if it wouldn't be faster to put the numbers into a list and join the list into a string -- did you test with that? It will be faster - the naive string concatenation is quadratic, whereas the list-based approach is linear. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: COM callbacks in Python
Looked at the makepy, code now looks like this: import win32com.client import win32gui import time import pythoncom finished = 0 defaultNamedNotOptArg=pythoncom.Empty class ADOEvents: def OnRecordsetChangeComplete(self, adReason=defaultNamedNotOptArg, pError=defaultNamedNotOptArg, adStatus=pythoncom.Missing, pRecordset=defaultNamedNotOptArg): print recordset has changed global finished finished=1 connect = win32com.client.Dispatch(ADODB.Connection) recordset = win32com.client.DispatchWithEvents(ADODB.Recordset,ADOEvents) connect.Open(Driver={SQL Server};Server=devserver;Database=VidVisitation;UID=sa;PWD=;) datestring = time.strftime(%m/%d/%Y) sql = Select * from VisSchedule where SDATE=' + datestring +' recordset.Open(sql,connect) while not finished: win32gui.PumpMessages() pass any idea why it doesn't work? Ive not really seen much on this in the newsgroups so any help would be greatly appreciated. I came upon a post by Paul Moore and and angusm describing code like this. angusm suggested that all of the interfaces must be implemented within the Events class, while Paul Moore suggested they didn't. Who is right? Here is the link to the thread: http://groups.google.com/group/comp.lang.python/browse_frm/thread/96cb2174570d92a1/b52f9ce9ac6403f4?lnk=stq=paul+moore+angusmrnum=1hl=en#b52f9ce9ac6403f4 -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
On Fri, 2006-03-24 at 12:55 +0100, Clemens Hepper wrote: Hello, I've written a little (optimized) method to get a bit-string: def bitstringneg(number, digits=32): optimized for negative numbers result = for a in xrange(digits): if number 1: result += '1' else: result += '0' number = 1 return result def bitstringpos(number): optimized for positive numbers result = while number: if number 1: result += '1' else: result += '0' number = 1 return result def bitstring(number, digits=32): lsb--msb result = if number 0: return bitstringneg(number, digits) else: return bitstringpos(number) BTW: Is there something like a sizeof() method for int numbers? import struct help( strict.calcsize ) Why one bit at a time? If I rewrite your functions as: _octets = {0:000, 1:001,2:010, 3:011, 4:100,5:101, 6:110, 7:111, -: } _sign = {True:'-',False:''} def bitstring1( number ): return _sign[number0] + ''.join( [_nibbles[d] for d in hex( number )] ).lstrip( '0' ) _nibbles = {0:, 1:0001, 2:0010, 3:0011, 4:0100, 5:0101, 6:0110, 7:0111, 8:1000, 9:1001, a:1010, b:1011, c:1100, d:1101, e:1110, f:, -:, x:} def bitstring2( number ): return _sign[number0] + ''.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[number0] + ''.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
Caching in memory for Apache
Dear All, I have decided to take the big plunge and drop the Microsoft platform and use Mod_Python and Apache in it's place. I've never used Linux before this project so it's a really big learning curve, but so far it's going well. I've managed to create some simple pages using the basic of Python. One of the questions I have is: How do you cache stuff in memory? Say I've got a bunch of stuff I need to create from a set of database rows. Obviously, I do not want to consult the database each time I have a request for my page. Is there anyway in Mod_python for me to store values inside memory so I can look it up on the next GET request? Simon. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiplying all the values in a dictionary
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: COM callbacks in Python
Ok, seems to fire at least once now, had to implement OnWillChangeRecordset as well. Definitely don't have to implement all the events though. Still not sure why its not acting like it should. Maybe I am looking at the wrong event? I want to know if the database has changed when someone else enters, edits etc... a record from another application. Ill investigate, if anyone knows, please help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Caching in memory for Apache
Pickle (http://www.network-theory.co.uk/docs/pytut/tut_58.html) comes to mind when anyone mentions wanting to save a value, method, object, etc without writing to storage (file or db). Is it possible for you to post some code? There may be an alternative algorithm so you can avoid writing to memory. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
What's the best way to learn perl for a python programmer?
I've been given a project which requires writing scripts that need to be run on over 3000 servers. Only about 15% of them have python installed on them. While all/most of them will have perl. I'll try and do as much as possible in pexpect but am sure I'll have do some significant perl. Any suggestions on what is the best way to get upto speed on perl? -- http://mail.python.org/mailman/listinfo/python-list
Re: Upload and Resize image problem HELP!!!
ChengGong wrote: I use following Python Script to upload file and image's but I can not specify a folder to store image. can any one help me? And I want to resize all the pictures, What shall I do? YOu should go for the ZOPE mailing list: http://mail.zope.org/mailman/listinfo/zope Your problems are ZOPE-related, not python. You will get better help there. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: path to modules per import statement
[EMAIL PROTECTED] wrote: For instance: import my.path.module would load module from ./my/path/module.py? Yeah, just do that. I don't understand the question, it works just like this today. I work on rather big set of Python applications: something like 100 .py files divided into libs and separate sub-applications. For now I keep almost everything in one directory but I wish following structure to be in place: app1/ app2/ lib1/ lib2/ lib3/ and be able to import from each app[12] all the libs. I do not want to touch existing code to prefix all the import places with lib[123] nether I want to play with sys.path.append too much. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: UML from py sources
Ravi Teja [EMAIL PROTECTED] writes: Not to interrupt the valuable lesson with Google :-) Boa Constructor. dia and dia2code Florian -- Es gibt Leute, die von sich behaupten wenn ich Kaffee trinke, kann ich nicht schlafen!. Bei mir ist das umgekehrt: Wenn ich schlafe, kann ich keinen Kaffee trinken. [Juergen Ilse in de.alt.folklore.urban-legends] -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to learn perl for a python programmer?
vj [EMAIL PROTECTED] writes: I've been given a project which requires writing scripts that need to be run on over 3000 servers. Only about 15% of them have python installed on them. While all/most of them will have perl. I'll try and do as much as possible in pexpect but am sure I'll have do some significant perl. Any suggestions on what is the best way to get upto speed on perl? Writing to c.l.perl is a good start... Perl has very good docs. IMHO, they're better than Python's, specially for the examples. Also, starting with a book like Learning Perl is not bad and it might save you a lot of time with the basics and the semantics of the language. c.l.perl is very receptive and helpful. -- Jorge Godoy [EMAIL PROTECTED] Quidquid latine dictum sit, altum sonatur. - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
image reduction script
Hi, I need to write a script to reduce the resolution/color depth of an image (ex: .jpg) based on a target size. The point is for the target picture to still be understandable - yet I target getting down to 5K. Are there libraries out there that could help me start ? Thanks Philippe -- http://mail.python.org/mailman/listinfo/python-list
New Python logo in high resolution format
Is the new Python logo (i.e. http://python.org/images/python-logo.gif) available someone in a high-resolution format? That would be nice to integrate into websites, T-shirts, etc. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiplying all the values in a dictionary
As long as you are optimizing, addition is slightly faster than multiplication: $ python2.4 -mtimeit 'h=1;h*=2' 100 loops, best of 3: 0.286 usec per loop $ python2.4 -mtimeit 'h=1;h=h+h' 100 loops, best of 3: 0.23 usec per loop Of course, that's only a 20% decrease, so it might not be worth the trouble. -- http://mail.python.org/mailman/listinfo/python-list
Re: path to modules per import statement
AndyL wrote: [EMAIL PROTECTED] wrote: For instance: import my.path.module would load module from ./my/path/module.py? Yeah, just do that. I don't understand the question, it works just like this today. I work on rather big set of Python applications: something like 100 .py files divided into libs and separate sub-applications. For now I keep almost everything in one directory but I wish following structure to be in place: app1/ app2/ lib1/ lib2/ lib3/ There are several approaches. One is to add each of these directories to your sys.path : sys.path.extend(map(os.path.abspath, ['app1/', 'app2/', 'lib1/', 'lib2/', 'lib3/'])) This is a perfectly normal thing to do - so I wouldn't be shy of it. Another is to add an empty file called ``__init__.py`` to each of these directories. This makes each directory a 'package'. You can then do : import app1.module My module `pathutils http://www.voidspace.org.uk/python/pathutils.html`_ contains a third approach that *does* allow you to specify the location of your module. It's a less suitable approach in your case however. HTH Fuzzyman http://www.voidspace.org.uk/python/index.shtml and be able to import from each app[12] all the libs. I do not want to touch existing code to prefix all the import places with lib[123] nether I want to play with sys.path.append too much. A. -- http://mail.python.org/mailman/listinfo/python-list
Re: overlapping sets
Gerard Flanagan wrote: kpp9c wrote: I have a question... and ... whew ... i am gonna be honest, i haven't the slightest clue how to even start ... i am not sure if i used up all my good will here or can take a mulligan.. i love to try to at least post some lame broken code of my own at first... but like i said, not being a math person i am not even sure how to start or if it is even possible. here's the deal... i have a dictionary that defines some collections.. like so: sets = { ('one') : [0, 4, 7, 9 ], ('two') : [0, 3, 7, 9 ], ('three') : [0, 4, 7, 11], ('four') : [0, 3, 7, 10 ], ('five') : [0, 4, 7, 10 ], ('six') : [0, 4, 8, 10 ], ('seven') : [0, 3, 6, 10], ('eight') : [0, 3, 6, 9 ], ('nine') : [0, 3, 7, 11 ], ('ten') : [0, 5, 7, 10 ] } I every time i call this function i would like like it to return a collection at random, any collection, so long as it has all but one element that is the same. So if i grab [0, 4, 7, 9 ] as my first set # k is the length of the required output lists, 0kn # n is the number of lists to output import random alphabet = [ 0, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] def randomiser( a_list, n, k ): d = len( a_list ) choice = range(d) vector = [] for i in range(k): vector.append( choice.pop(random.randint(0,d-i-1)) ) yield [ a_list[s] for s in vector ] #yield sorted( a_list[s] for s in vector ) for _ in range(n): rand_vector_idx = random.randint(0,k-1) rand_choice_idx = random.randint(0,d-k-1) rand_vector_val = vector[rand_vector_idx] #remember old value vector[rand_vector_idx] = choice.pop( rand_choice_idx ) choice.append( rand_vector_val ) #add old value back to choice yield [ a_list[t] for t in vector ] #yield sorted( a_list[t] for t in vector ) Sorry, I realise this doesn't answer your question - it is the collections themselves which are your 'alphabet', not the set of their elements. Looks like it's Graph Theory for you! Apologies. Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for Web App
Harlin Seritt wrote: I want to make a recommendation to a group of internal customers where I work concerning a Python web framework. They are seeking to build a portal that can handle around 5000 total users but probably no more than 100-200 simultaneous users. This is supposed to serve mainly static content - the content will hold references, tutorials and examples for different technologies, a forum (similar probably to phpbb) and podcasts (rss and mp3 files). Also I believe it will definitely need a decent DB server for this. Django. :-) Why not just use static HTML for the static content ? You can serve RSS and mp3s as static content too. Do you need CMS capabilities via the web interface ? Then you can just use a separate forum program. Fuzzyman http://www.voidspace.org.uk/python/index.shtml They have some other suggestions ranging from Websphere/JSP's to PHP. I personally don't think the PHP will scale well for growth and I also think that using Java/JSPs will be too slow for this sort of thing. I normally work as system and application admin and use Python in a number of ways to get the job done. Naturally, I am naturally inclined to suggest something that uses Python or something Pythonic. I wanted to suggest Zope but there are also other ones I'm thinking of as well like CherryPy and Karrigell. Which one of these (or other ones you guys know of) would do the best job in this situation? Also do you guys know if MySQL would work with this or should they use something more robust like DB2 (IBM shop)? Any suggestions are welcome. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems (X and X)
Duncan Booth wrote: [...] Unfortunately, just as I finished writing this I discovered that the latscii module isn't as robust as I thought, it blows up on consecutive accented characters. :( Replace the error handler with this (untested) and it should work with consecutive accented characters: def latscii_error( uerr ): v = [] for c in uerr.object[uerr.start:uerr.end] key = ord(c) try: v.append(unichr(decoding_map[key])) except KeyError: v.append(u?) return (u.join(v), uerr.end) codecs.register_error('replacelatscii', latscii_error) Bye, Walter Dörwald -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
On Fri, 24 Mar 2006 15:40:17 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Tim N. van der Leeuw wrote: I also wonder if it wouldn't be faster to put the numbers into a list and join the list into a string -- did you test with that? It will be faster - the naive string concatenation is quadratic, whereas the list-based approach is linear. It won't be any faster in CPython 2.4 or newer. This kind of string concatenation is optimized so as to be linear: $ python -m timeit -s x = '' for i in xrange(1000): x += 'x' 1000 loops, best of 3: 335 usec per loop $ python -m timeit -s x = '' for i in xrange(1): x += 'x' 100 loops, best of 3: 3.35 msec per loop $ python -m timeit -s x = '' for i in xrange(10): x += 'x' 10 loops, best of 3: 33.2 msec per loop $ python -m timeit -s x = '' for i in xrange(100): x += 'x' 10 loops, best of 3: 347 msec per loop $ python -m timeit -s x = '' for i in xrange(1000): x += 'x' 10 loops, best of 3: 3.48 sec per loop $ Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: path to modules per import statement
AndyL wrote: [EMAIL PROTECTED] wrote: I work on rather big set of Python applications: something like 100 .py files divided into libs and separate sub-applications. For now I keep almost everything in one directory but I wish following structure to be in place: app1/ app2/ lib1/ lib2/ lib3/ and be able to import from each app[12] all the libs. I do not want to touch existing code to prefix all the import places with lib[123] nether I want to play with sys.path.append too much. You should use Fuzzyman's solution of __init__.py files (look in the Python documentation for information about packages... I believe it's even covered adequately in the tutorial, so maybe rereading that would help), but also look into the use of .pth files. This is documented in the online help for the site standard library module, or in the helpful comments in the source in python's lib/site.py file. Basically to find the packages in lib1/ and friends regardless of what the current directory is, you need to use either the PYTHONPATH environment variable, modify sys.path directly (and it is acceptable to do that in various circumstances), or use .pth files as documented to get the desired effect. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Terminating a subprocess '.exe'
Fredrik Lundh wrote: Ernesto wrote: I launch a Windows executable and wish to close it from Python. The code is below. Normally, my program waits for rib.exe to finish, but I'd like to be able to close it from python if possible. (I suppose if I was going to do this, I wouldn't use .wait() ) Any ideas ? # Launch a program without launching a whole new cmd prompt def launchWithoutConsole(command, args): Launches 'command' windowless and waits until finished startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW return subprocess.Popen([command] + args, startupinfo=startupinfo).wait() ribHandle = launchWithoutConsole(rib.exe,[recovery]) # Is there a way to close rib.exe using ribHandle ? for 2.4 and earlier, see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347462 for 2.5 (upcoming) and later, you can use either the ctypes method or the _subprocess.TerminateProcess() call. /F Works EXACTLY the way I want it to. Thanks Fredrik ! -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to learn perl for a python programmer?
vj wrote: I've been given a project which requires writing scripts that need to be run on over 3000 servers. Only about 15% of them have python installed on them. While all/most of them will have perl. I'll try and do as much as possible in pexpect but am sure I'll have do some significant perl. Any suggestions on what is the best way to get upto speed on perl? There's lots of resources on the web, like http://llama.med.harvard.edu/~fgibbons/PerlPythonPhrasebook.html http://perl.active-venture.com/Porting/pumpkin-gotchas.html Maybe get 1 or 2 books, recommended: Perl Debugged (scott/wright) Effective Perl (Hall/ Schwartz) Debugging Perl (brown) o-o perl books (really well-written but I'm not going to represent that these books are easy to read), O-O Perl (Conway) Learnign Perl O-O (Randall schwartz) -- http://mail.python.org/mailman/listinfo/python-list
Re: don't understand popen2
Kent Johnson [EMAIL PROTECTED] wrote: Sion Arrowsmith wrote: (and please avoid the abuse of raw strings for Windows paths). Why do you consider that abuse of raw strings? I consider it abuse because it's not what they were invented for. I consider discouraging it to be a good thing in order to reduce the chances of people being bitten by, for instance: os.listdir(rC:\) File stdin, line 1 os.listdir(rC:\) ^ SyntaxError: EOL while scanning single-quoted string and getting all confused on this group. -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
property docstrings
I am trying to work with properties, using python 2.4.2. I can't get the docstrings to work, can someone suggest what I'm doing wrong? I think the following script should print This is the doc string., but instead it prints: float(x) - floating point number Convert a string or number to a floating point number, if possible. Thanks, Darren class Example(object): _myattr = 0.0 @apply def myattr(): doc = This is the doc string. def fget(self): return self._myattr def fset(self, value): self._myattr = value def fdel(self): del self._myattr return property(**locals()) _foo = 1.0 def foo(): doc = This is the doc string. def fget(self): This is the doc string. return self._foo def fset(self, value): This is the doc string. self._foo = value def fdel(self): This is the doc string. del self._foo return locals() foo = property(**foo()) _bar = 1.0 doc = This is the doc string. def get_bar(self): return self._bar def set_bar(self, value): self._bar = value def del_bar(self): del self._bar bar = property(get_bar, set_bar, del_bar, doc) a=Example() print 'myattr docstring:\n', a.myattr.__doc__ print 'foo docstring:\n', a.foo.__doc__ print 'bar docstring:\n', a.bar.__doc__ -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
It won't be any faster in CPython 2.4 or newer. This kind of string concatenation is optimized so as to be linear: $ python -m timeit -s x = '' for i in xrange(1000): x += 'x' 1000 loops, best of 3: 335 usec per loop $ python -m timeit -s x = '' for i in xrange(1): x += 'x' 100 loops, best of 3: 3.35 msec per loop $ python -m timeit -s x = '' for i in xrange(10): x += 'x' 10 loops, best of 3: 33.2 msec per loop $ python -m timeit -s x = '' for i in xrange(100): x += 'x' 10 loops, best of 3: 347 msec per loop $ python -m timeit -s x = '' for i in xrange(1000): x += 'x' 10 loops, best of 3: 3.48 sec per loop Interesting. I wasn't aware of that optimization. diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Call a wc 'free' if it satisfies the propery that every letter 'a' in it appears only in the form '*a*', and 'anchored' otherwise. Would '*ab*' be free or anchored? What if all wc's are free? How does this affect the DFA? I don't know. The important point here is the interaction of all the wc's. I don't think properties like this do reduce the complexity of interaction in an obvious way. Does it minimize nontrivially? I am not sure what you mean by this. Every DFA minimizes to some other DFA, which is unique up to renaming of states. Now the question is if that minimization reduces the complexity enough to be noticeable (maybe that's what you mean by nontrivially). In general, I don't think one can say much about that without looking at concrete examples. - Dirk -- http://mail.python.org/mailman/listinfo/python-list
Re: image reduction script
Philippe Martin wrote: Hi, I need to write a script to reduce the resolution/color depth of an image (ex: .jpg) based on a target size. The point is for the target picture to still be understandable - yet I target getting down to 5K. Are there libraries out there that could help me start ? Thanks Philippe Python Imaging Library (PIL). http://www.pythonware.com/products/pil/ -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: Python has a new Logo
That's not constructive. I'd like to quote Rich Teer on this subject: ___ /| /| | | ||__|| | Please do | / O O\__ NOT | / \ feed the| / \ \ trolls | / _\ \ __| /|\\ \ || / | | | |\/ || / \|_|_|/ \__|| / / \|| || / | | /|| --| | | |// | --| * _| |_|_|_| | \-/ *-- _--\ _ \ // | / _ \\ _ // |/ * / \_ /- | - | | * ___ c_c_c_C/ \C_c_c_c /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list
What's The Best Editor for python
Hi, Can one of you say to me what's the best editor for editing the python programs ( for linux or windows ), and if you can send it to me to the adresse [EMAIL PROTECTED] Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
PythonStudent wrote: Hi, Can one of you say to me what's the best editor for editing the python programs ( for linux or windows ), and if you can send it to me to the adresse [EMAIL PROTECTED] `SPE http://pythonide.stani.be`_ :-) Fuzzyman http://www.voidspace.org.uk/python/index.shtml Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitwise OR?
Diez B. Roggisch [EMAIL PROTECTED] writes: Interesting. I wasn't aware of that optimization. It's better not count on it. It's not there for Jython, IronPython, previous versions of Python, etc. It is just there for the new cPython. And the fix is so simple that it isn't worth disregarding all those other versions. -- Jorge Godoy [EMAIL PROTECTED] Quidquid latine dictum sit, altum sonatur. - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: Linear regression in NumPy
nikie wrote: Robert Kern wrote: Both functions are described in the full book. Were you just looking at the sample chapter? No, I've got the full PDF by mail a few days ago, numpybook.pdf, 261 pages (I hope we're talking about the same thing). I entered linear_least_squares and polyfit in acrobat's find text box, but neither one could be found. The version I have in front of me is a bit shorter, 252 pages, but describes polyfit in section 5.3 on page 91 along with the other polynomial functions. lstsq (linear_least_squares is a backwards-compatibility alias that was recently moved to numpy.linalg.old) is described in section 10.1 on page 149. -- Robert Kern [EMAIL PROTECTED] I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Experienced UI programmers: help me decide (please ;)
Ok, so i've whipped up this GUI with wxPython but I realize that it might hinder the sort of thing I wantto do. What do I want to do? Basically its a note taking app that should present little boxes of text to the user. Also the boxes can be interconnected which is signified by arrows between the boxes. Yes, a little like cmaptools (http://cmap.ihmc.us/). So wxPython makes it easy to use the usual widgets (esp. textviews and treeviews) which I need, but its rather hard on the graphical side (for example: I also like the idea of continous zooming *shudder*). I've found that maybe pygame could give me the java swing like expressivenes I want; however I'm unshure whether it supports easy text editing facilities (I'll be needing syntax highlighting featues soon) and the above mentioned general widgets? There seem to be several packages providing this for pygame; whcih do you recommend and why (and which not and why). Also, feel free to suggest other toolkits with respect to the above. thx wildemar -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Can one of you say to me what's the best editor for editing the python programs ( for linux or windows ), and if you can send it to me to the adresse Hmmm...it's been almost a week since this topic came up on the list. Good to see the topic is undead :) For plenty of reading, check out the list archives: http://groups.google.com/group/comp.lang.python/search?group=comp.lang.pythonq=editor+%28best+OR+perfect+OR+ideal%29 Pretty much any text editor will do. If you're developing on both Linux and Windows, it's an advantage to have an editor that you can use on both. I happen to use vim/vi which is available pretty much wherever you go. About the same sorta thing can be said for emacs, though I'm not a user, so I can't comment on it. I'll grant that vi/vim has a learning curve like a brick wall, but once you're over the initial learning hurdle, it reaps heaps of rewards. Check out http://www.python.org/moin/PythonEditors Try 'em out and see what *you* like. In a pinch, there's always ed: http://www.gnu.org/jokes/ed.msg.html http://www.gnu.org/software/ed/ed.html Or edlin if you're on Dos/Win32 :) Though I think in such an event on Dos/Win32, I'd almost rather use copy con as my editor... -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
PythonStudent [EMAIL PROTECTED] writes: Can one of you say to me what's the best editor for editing the python programs ( for linux or windows ), and if you can send it to me to the adresse [EMAIL PROTECTED] Emacs runs on both. So do Eclipe and a lot of other... What is best? The one that solves your problems without getting in your way. -- Jorge Godoy [EMAIL PROTECTED] Quidquid latine dictum sit, altum sonatur. - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
http://www.pspad.com/en/It supports Python plugins! :)Sebastjanhttp://www.trepca.si/blog On 24 Mar 2006 08:50:15 -0800, Fuzzyman [EMAIL PROTECTED] wrote: PythonStudent wrote: Hi, Can one of you say to me what's the best editor for editing the python programs ( for linux or windows ), and if you can send it to me to the adresse [EMAIL PROTECTED] `SPE http://pythonide.stani.be`_ :-) Fuzzyman http://www.voidspace.org.uk/python/index.shtml Thanks -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: __slots__
In article [EMAIL PROTECTED], David Isaac [EMAIL PROTECTED] wrote: Ziga Seilnacht [EMAIL PROTECTED] wrote: If you want to restrict attribute asignment, you should use the __setattr__ special method, see: http://docs.python.org/ref/attribute-access.html That should is what I am asking about. If I understand, in the simplest case, you want me to say something like def __setattr__(self,name,value): if name in myattrlist: object.__setattr__(self,name,value) else: raise AttributeError instead just saying __slots__ = myattrlist I understand that this *is* the prevailing advice. But why? Because __slots__ breaks with inheritance. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: Caching in memory for Apache
Simon Johnson wrote: I have decided to take the big plunge and drop the Microsoft platform and use Mod_Python and Apache in it's place. Congratulations! ;-) [...] One of the questions I have is: How do you cache stuff in memory? Say I've got a bunch of stuff I need to create from a set of database rows. Obviously, I do not want to consult the database each time I have a request for my page. Is there anyway in Mod_python for me to store values inside memory so I can look it up on the next GET request? I suppose that you probably need to use sessions in your application in order to achieve what you're aiming for. If you're not familiar with the concept of a session in the context of Web applications, sessions are just things which associate a particular user or client with persistent information stored on the server: when sending responses (ie. Web pages) to users/clients, you include a token which those users/clients then submit back to you with each request; you use these tokens to look up any information that you've stored for quick retrieval; the method of transmitting tokens is most often a cookie which is automatically sent back by browsers unless configured otherwise. I know that mod_python does support sessions, including in-memory sessions, as do a number of different frameworks. It should be fairly convenient to take database rows and store them in a session, and in most cases the framework (eg. mod_python) will manage the low-level details (such as the sending of cookies, and so on). Sometimes, there are restrictions on what the persistent information in sessions can actually look like: some implementations use things like pickle, and you can run into unpickleable objects; some implementations recommend that you only store things like strings or text. Whether sessions are ultimately the right answer rests upon a number of technical considerations, and some people have stated that they believe them to be generally inappropriate. However, they're probably the most immediately appropriate thing for you to use in this case. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: property docstrings
Darren Dale wrote: I am trying to work with properties, using python 2.4.2. I can't get the docstrings to work, can someone suggest what I'm doing wrong? I think the following script should print This is the doc string., but instead it prints: float(x) - floating point number Convert a string or number to a floating point number, if possible. Thanks, Darren snip a=Example() print 'myattr docstring:\n', a.myattr.__doc__ print 'foo docstring:\n', a.foo.__doc__ print 'bar docstring:\n', a.bar.__doc__ change this part to: print 'myattr docstring:\n', Example.myattr.__doc__ print 'foo docstring:\n', Example.foo.__doc__ print 'bar docstring:\n', Example.bar.__doc__ What happens is that when property is accessed from an instance, it returns whatever the fget function returns, and the __doc__ attribute is then looked up on that object. To get to the actual property object (and its __doc__ attribute) you have to access it from a class. Ziga -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming challenge: wildcard exclusion in cartesian products
Dirk Thierbach wrote: [A lot of stuff] Now clearer? - Dirk Actually, it's getting all the messier, and we seem to be running around in circles. I've already lost track of the point you're trying to make, and it seems that you're missing most of my points. Let's leave it there, and take a break. -- http://mail.python.org/mailman/listinfo/python-list
Re: Experienced UI programmers: help me decide (please ;)
On 3/24/06, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Ok, so i've whipped up this GUI with wxPython but I realize that it might hinder the sort of thing I wantto do. What do I want to do? Basically its a note taking app that should present little boxes of text to the user. Also the boxes can be interconnected which is signified by arrows between the boxes. Yes, a little like cmaptools (http://cmap.ihmc.us/). So wxPython makes it easy to use the usual widgets (esp. textviews and treeviews) which I need, but its rather hard on the graphical side (for example: I also like the idea of continous zooming *shudder*). I've found that maybe pygame could give me the java swing like expressivenes I want; however I'm unshure whether it supports easy text editing facilities (I'll be needing syntax highlighting featues soon) and the above mentioned general widgets? There seem to be several packages providing this for pygame; whcih do you recommend and why (and which not and why). Also, feel free to suggest other toolkits with respect to the above. thx wildemar -- http://mail.python.org/mailman/listinfo/python-list The native text controls in wxPython don't support zooming (although wx.stc does - you could use that). Aside from that, all the available tools I'm aware of for this sort of thing are raster-based, so you'll lose a lot of performance and/or image quality. If you decide to write an SVG renderer for wx based on your needs, let me know - it's something thats been on my todo eventually list for ages. However, I suspect that what you need is more likely to exist already in the other toolkits you mentioned. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
PythonStudent wrote: Hi, Can one of you say to me what's the best editor for editing the python programs ( for linux or windows ), and if you can send it to me to the adresse [EMAIL PROTECTED] Why don´t you try the editor wich comes with Pythoncard. Or Notepad++ Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Food for thought... I admit it would be best if you could use the same editor for both *nix and Windows -- in that case, I'd say Scite would be best as it is almost identical in both environments. However, my own personal favorites are: Crimson Editor for Windows and Kate for Linux. Yes, I know... strange choices (especially Kate) but they both do what I need them to do. :-) Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for Web App
Why not just use static HTML for the static content ? Makes sense... now, what about for having the portal capabilities (users log in, save profiles, etc)... what would be best for that? I really don't think though that a CMS is necessary. Does anyone know of a Python forum package similar to phpBB? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
I agree, Kate is a great linux editor! On windows, I'd have to say notepad2- kate for windows -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
just to bloat this thread some more: Am I the only one using jEdit? (really, I never see it mentioned anywhere ...) wildemar -- http://mail.python.org/mailman/listinfo/python-list
Help: Creating condensed expressions
Here's the problem: Given a list of item names like: apple1 apple2 apple3_SD formA formB formC kla_MM kla_MB kca_MM which is a subset of a much larger list of items, is there an efficient algorithm to create condensed forms that match those items, and only those items? Such as: apple[12] apple3_SD form[ABC] kla_M[MB] kca_MM The condensed expression syntax only has [...] and * as operators. [...] matches a set of individual characters, * matches any string. I'd be satisfied with a solution that only uses the [...] syntax, since I don't think it's possible to use * without potentially matching items not explicitly in the given list. I'm not sure what this condensed expression syntax is called (looks a bit like shell name expansion syntax), and I'm not even sure there is an efficient way to do what I'm asking. Any ideas would be appreciated. Thanks, -David -- Presenting: mediocre nebula. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Been using PyDev plugin for Eclipse for a week now... works pretty good, and integrates well with PyLint. Has some context-sensitive help, but not much. I wonder if writing a script to convert Python HTML docs to Javadoc format would help? H maybe I'll ask. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Was actually going to throw in jEdit for the category of what's good on both platforms... For someone who despises Java, I actually like it. :-) Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems (é and è)
On 24/03/2006 11:44 PM, Peter Otten wrote: John Machin wrote: 0x00d0: ord('D'), # Ð 0x00f0: ord('o'), # ð Icelandic capital eth becomes D, OK; but the small letter becomes o!!! I see information flow from Iceland is a bit better than from Armenia :-) No information flow needed. Capital letter BLAH - D and small letter BLAH - o should trigger one's palpable nonsense detector for *any* BLAH. Some of the transformations are a little unfortunate :-( The OP, as you pointed out in your first post in this thread, has more pressing problems with his normalization approach. Lastly, even if all went well, turning a list of French addresses into an ascii-uppercase graveyard would be a sad thing to do... Oh indeed. Not only sad, but incredibly stupid. I fervently hope and trust that such a normalisation is intended only for fuzzy matching purposes. I can't imagine that anyone would contemplate writing the output to storage for any reason other than logging or for regression testing. Update it back to the database? Do you know anyone who would do that?? -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python logo in high resolution format
How about we all get tatoos? : ) Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Wildemar Wildenburger wrote: just to bloat this thread some more: Am I the only one using jEdit? I've yet to find better for developing in jython -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiplying sequences with floats
Christoph Zwerschke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Anyway this would be an argument only against the variant of typecasting a float with a fractional part. But what about the other variant which raises an error if there is a fractional part, but works if the float is actually an exact integer, like the result of 4.0//2. I think that's a really bad idea, because of the possibility that the result might happen to be an exact integer on one implementation but not another. In such situations, the fact that it might fail on implementation X may well be impossible to detect by any amount of testing on implementation Y. Such untestable errors are such a nuisance that it would better for the language to encourage programmers to give them a wide berth. -- http://mail.python.org/mailman/listinfo/python-list
Re: New development windows, IronPython or PythonWin
Dan a écrit : IronPython is currently nowhere near production quality. I would not recommend it. I realise its in beta. But long term, do you think that the win32com, win32gui etc... will have no support because everyone jumps on the Microsoft bandwagon? Aren't the windows support extensions supported primarily by one guy, Mark Hammond? As a developer, this seams to leave me with a vulnerability long term. Thanks for the advise. Well, from what we've seen so far, I'd rather rely on open source software than on proprietary one. An oss project lives as long as someone is willing to maintain it, and anyone can pick it up. And I wouldn't count on every one jumping on MS wagon neither. Just my cents... -- http://mail.python.org/mailman/listinfo/python-list