ANN: ChiPy Thurs. September 14, 2006. 7pm @ Google, Chicago
Chicago Python User Group = Come join us for our best meeting ever! Topics -- * Google Code (Brian Fitzpatrick and Ben Collins-Sussman) * Trac + Subversion + doctests (Garrett Smith) * Special method names for operator overloading (Brian Ray) Location Google's Chicago office 20 West Kinzie Street, 9th Floor Chicago, IL 60610 Location description: 18 story glass and steel building on the Northwest corner of Dearborn and Kinzie. Across the street from Harry Carey's Upstairs from Keefer's restaurant * Map http://tinyurl.com/ee8my Enter via the lobby on the South side of the building, between Keefer's restaurant and Keefer's cafe. Street (meter) parking is kinda sorta available in the area. Garage and lot parking is also available Southwest and East of our building. 1. The closest L stop is Grand on the Red Line and Clark/Lake on the Blue/Green/Orange/Brown/Purple Line. (All are about an 8 minute walk from Google) 2. The closest Metra station is the Ogilvie Transportation Center (in the Citibank building) (about 20 minutes walk or take the Riverbus) 3. The closest River Bus stop is at Michigan Avenue (By the Wrigley Building at 2 North Riverside Plaza. (http://www.wendellariverbus.com/rbdock.htm) ;-) 4. The nearest helipad is at the mouth of the river, near Navy Pier. Obtain security clearance before landing. *** A Special Note from Fitz:: I'm going to need a list of all people attending to give to building security, so if you're thinking of coming, please send me your name (just to me--use my fitz at google dot com address please). About ChiPy --- ChiPy is a group of Chicago Python Programmers, l33t, and n00bs. Meetings are held monthly at various locations around Chicago. Also, ChiPy is a proud sponsor of many Open Source and Educational efforts in Chicago. Stay tuned to the mailing list for more info. ChiPy website: http://chipy.org ChiPy Mailing List: http://mail.python.org/mailman/listinfo/chicago Python website: http://python.org Forward this on. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: pyXSD 0.1 released
pyXSD v.0.1 has been released! pyXSD is a tool to map XML and XSD (XML Schema) into Python. It can validate an XML file against an XSD file. It also contains a feature to allow users to easily transform an XML file, using small python classes that are easy to use and are easy and fast for users to write. The program uses a simple, non-DOM interface in the transforms with the XML data tree. It can be used as a library or command-line program. The program includes a decent amount of documentation on how to use the program and on how to use and write transforms. A more thorough description of its functionality and features can be found on the projects website: http://pyxsd.org/The program was designed for material science modeling applications, so some of the included transform classes are for this specific use. The program includes more general transforms and transform libraries to assist users write these classes. The program uses ElementTree and cElementTree (the ElementTree and cElementTree included in python 2.5 should work), and requires Python 2.3 or greater.The pyXSD project's website: http://pyxsd.org/Release 0.1 download: http://pyxsd.org/download-area/release-0.1Mailing List: http://mail.kanorben.net/mailman/listinfo/pyxsd_kanorben.net -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: wxPython, how to autoresize a frame?
Il Sun, 10 Sep 2006 19:15:40 +0200, David ha scritto: The problem is that, when sizer2 containig hidden controls collapses to zero dimensions, the panel resizes, but sizer1 and sizer0 don't! Consequently the frame does not want to autoresize. You con dowload the code here: http://www.box.net/public/evfxs7cp5j Someone con help me? Best help came from mysef: the problem was in .SetSizeHints() statement that prevented resizind of objects. D. -- R: Perche' incasina l'ordine con cui la gente normalmente legge un messaggio D: Perche' quotare sotto da' cosi' fastidio? R: Quotare sotto. D: Qual e' la cosa piu' seccante su usenet e in e-mail? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Licheng Fang wrote: Oh, please do have a look at the second link I've posted. There's a table comparing the regexp engines. The engines you've tested probably all use an NFA implementation. Sorry! *blush* I admit I skipped over your links. I'll have a look now. BTW, just an idea that may or may not work. What about finding all matches that meet the absolute baseline pattern, then taking the longest of them...something like this mabye: def matcher(strings, pattern): out = '' reg = re.compile(pattern) for string in strings: match = reg.match(string).group() if (len(match) = len(out)): # should this use or = ? out = match return out # empty is no matches, else longest match p = ['dodad', 'dolittle', 'dodaday'] print matcher(p, r'do.*') # dolittle Just a thought... Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Thank you very much, Tim and Monkee. In fact, what I'm doing is handle a lot of regular expressions. I wanted to build VERY LONG regexps part by part and put them all into a file for easy modification and maintenance. The idea is like this: (*INT) = \d+ (*DECIMAL) = (*INT)\.(*INT) (*FACTION) = (*DECIMAL)/(*DECIMAL) (*NUMERALS) = (*FACTION)|(*DECIMAL)|(*INT) ... ... What's inside the sytactically wrong (* and ) is something to be replaced, and then I wrote a little script to do the string substitution, to get very long regexps to be compiled. I thought that might be a way to handle long and complex regexps, and in this course I encountered the problem with the semantics of '|'. My approach may sound desperate and funny, but please, do you have any good idea as to how to handle long and complex regexps? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Or mabye something like this is better: def matcher(string, pattern): out = '' for match in re.findall(r'\S*%s\S*' % pattern, string): if (len(match) = len(out)): out = match return out p1 = 'dodad donkeykong dolittle dodaday' p2 = 'oneself self-serving selfsufficient oneselfsufficient' print matcher(p1, 'do') # donkeykong print matcher(p2, 'self') # oneselfsufficient -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the package, file, and line of a method/function invocant?
In [EMAIL PROTECTED], metaperl wrote: # Of course I could cheat and pass it, but I don't want to: directories = data.storage.logic(__file__) Why do you consider a plain and simple solution cheating? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Gabriel Genellina wrote: At Tuesday 5/9/2006 16:23, [EMAIL PROTECTED] wrote: I would be surprised if they had never used ANY database. A little thing like dynamic field typing will simply make it impossible to migrate your Sqlite data to a *real* database. Why not? Because it breaks the relational model rules? That's part of it. That model certainly was great 30 years ago, but now things are different. Different only in lite databases. (In fact, you didn't menction the word relational, but I presume you were thinking of that). Even what you call *real* databases have a lot of incompatibilities among them (e.g. ORACLE does not provide an autoincrement type, but has sequences, and so on...). But it was stated in the sqlite docs that ALL SQL databases use static types implying that sqlite will be incompatible with any heavy database should the need arise to migrate upwards. The issue is not that there will be compatibilty problems with any data migration but that the truth is exactly opposite of what's claimed in Section 13.13. I'm not saying sqlite can't be used, what I'm asking for is that the documentation lay the facts out and I'll decide whether I can make this work in my application. Lying about it makes you sound like Microsoft. Of course you could restrict yourself to, by example, SQL92 entry level and be a lot more compatible. But if I'm using a nice OO language like Python which lets me bind *any* object to *any* name, why should be wrong to bind *any* object to *any* database column? But SQL isn't OO, it's relational. That means JOINing tables together on a common field. In theory, due to the comparison hierarchy, it is impossible to do JOINs with dynamic typing since different types can never be equal. In practice, the type affinity kluge trys to work around this but can't do anything if the string doesn't look like an integer when a text field attempts to JOIN to an interger field. Looks a lot more pythonic for me. If all you have is a hammer, everything looks like a nail. Of course, a true object database (like ZODB) is better. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the package, file, and line of a method/function invocant?
I am looking for something like the caller() routine in Perl: http://perldoc.perl.org/functions/caller.html Look at the inspect module in Python's standard library. Or is you're feeling lazy, have a look at the here function found in http://www.unixreview.com/documents/s=9133/ur0404e/ur0404e_listing1.htm -- Miki http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
[Licheng Fang[ ... In fact, what I'm doing is handle a lot of regular expressions. I wanted to build VERY LONG regexps part by part and put them all into a file for easy modification and maintenance. The idea is like this: (*INT) = \d+ (*DECIMAL) = (*INT)\.(*INT) (*FACTION) = (*DECIMAL)/(*DECIMAL) (*NUMERALS) = (*FACTION)|(*DECIMAL)|(*INT) ... ... What's inside the sytactically wrong (* and ) is something to be replaced, and then I wrote a little script to do the string substitution, to get very long regexps to be compiled. I thought that might be a way to handle long and complex regexps, and in this course I encountered the problem with the semantics of '|'. My approach may sound desperate and funny, but please, do you have any good idea as to how to handle long and complex regexps? My best advice is to find a different approach entirely. For example, build a parser using parser technology, and use regexps in that /only/ to do gross tokenization (string of digits, decimal point, ...): build the rest with a grammar. Regexps are a brittle tool, best tolerated in small doses. For an NFA implementation like Python's, you're likely to experience poor speed when combining many complex regexps, and /especially/ when alternatives are ambiguous wrt prefixes (and yours are, else you wouldn't have a problem with longest match versus some shorter match to begin with. OTOH, under a DFA implementation such as POSIX grep's, you're likely to experience exponential memory requirements (DFA implementations can need to build enormous state machines, tracing out in advance all possible paths through all the regexps applied to all possible input strings). Just sounds to me like the wrong tool for the job. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Licheng Fang wrote: Oh, please do have a look at the second link I've posted. There's a table comparing the regexp engines. The engines you've tested probably all use an NFA implementation. Unfortunately, the stuff about NFA's is wrong. Friedl's awful book was the first time I saw this confusion about what NFA is; I don't know if he originated the mess or just propagated it. Nondeterministic finite automata is well defined in theory of computation. The set of languages accepted by NFA's is exactly the same as the set accepted by DFA's. What Python uses is search-and-backtrack. Unfortunately such engines don't have much theory behind them, and it's hard to reason generally about what they do. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
A Comparison of Python Class Objects and Init Files for Program Configuration
A Comparison of Python Class Objects and Init Files for Program Configuration = Terrence Brannon [EMAIL PROTECTED] http://www.livingcosmos.org/Members/sundevil/python/articles/a-comparison-of-python-class-objects-and-init-files-for-program-configuration/view Abstract Init files serve as a convenient mini-language for configuring applications. The advantages of such a mini-language are * non-technical people can edit them. * program behavior can be configured without modifying the source The author `has always been suspicious of mini-languages http://perlmonks.org/?node_id=428053`_, initially in the context of dynamic HTML generation. This document provides a comparison of two approaches to program development, the use of `a popular Python mini-language http://www.voidspace.org.uk/python/configobj.html`_ and the use of `Python class objects http://www.mired.org/home/mwm/config.html`_. The Problem Space - I work for a company that takes data in various formats (e.g., CSV, XML, Filemaker) and integrates them all into our database. The 30 or so scripts that did this were written in Perl. I was told to rewrite them and elected to use Python. The Initial Rewrite Using Init Files In the initial version using config files, I used a generic config file and specialized/overwrote its values with a local one:: gconfig = ConfigObj(../generic.ini) cnf = ConfigObj(local.ini) cnf.merge(gconfig) I then proceeded to login to an FTP server and check for a certain file and download it if it existed:: host = ftputil.FTPHost(cnf['ke_ftp']['host'], cnf['ke_ftp']['user'], cnf['ke_ftp']['pass']) host.chdir(cnf['ke_ftp']['cwd']) found = for f in host.listdir(host.curdir): if f.endswith( cnf['ke_ftp']['filepattern'] ): found = f print Downloading, found host.download(f, f, 'b') if found == : print No file with pattern, cnf['ke_ftp']['filepattern'], on server sys.exit() Now lets see the object-oriented configuration -- Instead of generic and specialized config files, one would initially think of using inheritance when going for an OO approach. However, each program can get configuration information from a number of places. As a result, HAS-A will work better than IS-A in this case:: class config(object): # best to use has-a because we need config info from all over the place import data.config.ke ke = data.config.ke.ftp() ke.user = 'dmsdatasystems' ke.password = 'sredna?' ke.cwd = 'DMS/companies' ke.filepattern = 'companies.csv.gz' import data.config.snap snap = data.config.snap.ftp() import data.storage storage = data.storage.logic() print dir(storage) sys.exit() class proc(object): def __init__(self): self.cnf = config() def fetch_file(self): host = ftputil.FTPHost(self.cnf.ke.host, self.cnf.ke.user, self.cnf.ke.password) host.chdir(self.cnf.ke.cwd) self.downloaded_file = for f in host.listdir(host.curdir): if f.endswith( self.cnf.ke.filepattern ): self.downloaded_file = f print Downloading, f host.download(f, f, 'b') print Downloaded, f if self.downloaded_file == : print No file with pattern, self.cnf.ke.filepattern, on, self.cnf.ke.host sys.exit() Evaluation == Appearance -- Accessing object attributes, IMHO, is much cleaner looking. Compare:: config['munger']['outfile'] with:: config.munger.outfile One takes less characters to type and lacks the noisy quote marks (that's one of the things I miss from Perl hashes - the ability to index into hashes using bare words without quotes). Power - A mini-language is a moving target. They tend to grow and grow over time, adding more and more ad hoc semantics and peculiarities. I'm on the ConfigObj mailing list and they are currently discussing how to handle multi-line config values. In Python, one simply needs to break out and you are done. This epitomizes why I prefer the shortcut of library over mini-language. The library has the full power of a widely used, widely debugged language while the mini-language has a smaller user community and less man hours of development behind it. Learning Curve -- Again, once you learn Python, you can use it for configuration as well as programming. And Python is a very readable, clean and regular language - it doesn't look very different from a configuration language. The merits of studying the syntax and semantics of a configuration language can possibly outweigh the benefits. Maintenance --- It is harder to hire people with a good background in object oriented programming than it is
Re: How to get the longest possible match with Python's RE module?
[Licheng Fang] Oh, please do have a look at the second link I've posted. There's a table comparing the regexp engines. The engines you've tested probably all use an NFA implementation. [Bryan Olson] Unfortunately, the stuff about NFA's is wrong. Friedl's awful book Strongly disagree: it's an excellent book about the /pragmatics/ of using regular expressions as most widely implemented. It's not at all about regular expressions in the CompSci sense of the term, which appears to be your complaint. was the first time I saw this confusion about what NFA is; I don't know if he originated the mess or just propagated it. As far as I could tell at the time, he originated it. I'm not happy about that either. Nondeterministic finite automata is well defined in theory of computation. The set of languages accepted by NFA's is exactly the same as the set accepted by DFA's. And which has very little to do with regular expressions as most widely implemented -- gimmicks like backreferences are wholly outside the DFA formalism. What Python uses is search-and-backtrack. Unfortunately such engines don't have much theory behind them, and it's hard to reason generally about what they do. Yup X 3, and the last is precisely why Friedl's book is valuable for people using NFA implementations: Friedl does a good job of explaining when and why you're likely to trigger atrocious runtime performance, and gives practical general techniques for avoiding those problems. None of that has anything to do with CompSci regexps either, but is vital knowledge for people hoping to make happy non-trivial use of Python/Perl/etc regexps. -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
Mike Owens wrote: And if you say SQLite misrepresents itself, then what do you say about MySQL, which until version 5 didn't have views or triggers? In fact, it didn't even have subselects until version 4. For a period of years, SQLite had more mainstream SQL features than MySQL. Yet you don't see people going around claiming that MySQL is not an SQL database -- that it's misrepresenting itself. Just to be fair... You do hear many people claiming exactly that, and the primary complaint is often exactly the same one that's being levelled against sqlite here (it's incredibly lax with types and does sometimes mystifying conversions rather than pointing out programmer errors--and yes that's intentionally loaded language that I don't necessarily agree with, it's a common argument though.). The lack of subselects was also a major sticking point for a lot of people, as are other major missing SQL features. Not having used sqlite I can't comment on it in particular. -- http://mail.python.org/mailman/listinfo/python-list
Re: auto upgrade scripts?
Auto-upgrade from what to what? -Larry Bates Interesting question. In my case I want my program to check for (e.g.) bug-fix releases on some location (network drive or ftp), and if available, allow to automatically download and install them. Kind of like the AutoUpgrade functionality in .net (*shudder*) ;) Best regards, Stefaan. -- http://mail.python.org/mailman/listinfo/python-list
Re: 4 Simple Questions About Python/IDLE
At Thursday 7/9/2006 13:44, Omar wrote: I'm working through a tutorial, http://swaroopch.info/text/Byte_of_Python:Control_Flow, and I sorta can't get through the tutorial without overcoming these little speedbumps. This is why I'm asking these questions. Have you read the Python tutorial which comes with the documentation? You can read it online at http://docs.python.org/tut/tut.html Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
[EMAIL PROTECTED] wrote: But it was stated in the sqlite docs that ALL SQL databases use static types implying that sqlite will be incompatible with any heavy database should the need arise to migrate upwards. The issue is not that there will be compatibilty problems with any data migration but that the truth is exactly opposite of what's claimed in Section 13.13. I'm not saying sqlite can't be used, what I'm asking for is that the documentation lay the facts out and I'll decide whether I can make this work in my application. Lying about it makes you sound like Microsoft. I thought your qualm was with the pysqlite docs, not the sqlite docs (which apparently do make it plain how the database handles typing)? Also, as others have mentioned, there are a number of ways to ensure type safety, as long as you know how the database works (which as I understand was your original point -- that it should be better documented how it works in the pysqlite docs; and I am inclined to agree -- at least a mention with link to the sqlite docs would be helpful). But given that type safety is not an issue if you use those ways of ensuring it, then the move to a fuller database _will_ be relatively easy. If you don't want to change anything in your database creation/update code ala check constraints, you can always explicitly validate from python, which can be done programatically (very simple example -- you could also use regexp patterns to validate; e.g., string fields not only must be type str, but must not match '^\d+$', c): rows = [ ['1', 'fred', '0051', '/home/fred'], ['2', 'bob', '0054', '/home/bob'], ['3', 'bork', '056', '/home/bork'] ] def validate(row): return [int(row[0]), str(row[1]), int(row[2]), str(row[3])] for i in xrange(len(rows)): rows[i] = validate(rows[i]) # - throws an exception on the third row # database stuff here... Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list
Re: PILGraph Upgrade or Alternative Suggestion
At Thursday 7/9/2006 22:35, Roger wrote: Anyone have an updated version of PILGraph beyond 0.1a7 or a suggestion for a light-weight alternative? pychart Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
Oops! Sorry for the top-post! -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial problem. script stops reading.
"Frederic Wenzel" [EMAIL PROTECTED] Wrote:On 9/9/06, Frederic Wenzel [EMAIL PROTECTED] wrote: On 9/9/06, Hendrik van Rooyen [EMAIL PROTECTED] wrote: | I wrote a script on Linux that uses pyserial to read status messages | from a serial line using readlines(). For now, it just displays what | it gets on stdout: | (...) | ser = serial.Serial(port=1, | baudrate=1200, | rtscts=1, | | If the script does not time out there, I am not sure what else it is | doing. It seems to be in a wait state it does not get out of.When it stopped working again (unfortunately) I pressed ctrl c and got thefollowing outputÖ14:53 | 0008 | 02 | | 5 |Rack Abs.| - | --75214:53 | 0005 | 02 | | 2 |Rack Abs.| - | 0075214:53 | 0008 | 02 |Traceback (most recent call last): File "serialhandler.py", line 34, in ? lines = sh.readLines() File "serialhandler.py", line 29, in readLines return self.ser.readlines() File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 78, inreadlines line = self.readline(eol=eol) File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 60, inreadline c = self.read(1) File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line 269, inread ready,_,_ = select.select([self.fd],[],[], self._timeout)KeyboardInterruptApparently this is the place where it gets stuck. The select.selectline does not return, not even for a timeout.FredThis seems a real PITA - it looks normal to me - it is as if the device hassimply stopped sending for some reason. Can you:1) set the external device up to ignore flow control?2) check the cable for loose connections - wriggling it around while thetransmission is running might point at something - but be gentle - else you caneasily draw false conclusions, or break something that is in fact ok...does anybody else know how to check the value of the time out, what its for andwhat happens when it times out?- hth - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers wrote: Chris Withers wrote: print msg.as_string() MIME-Version: 1.0 Content-Type: text/plain; charset; charset=utf-8 ^^^ Actually, even this isn't correct as you can see above... charset = Charset('utf-8') msg = MIMEText('','plain',None) msg.set_payload(u'Some text with chars that need encoding:\xa3',charset) Has no-one ever successfully generated a correctly formatted email with email.MIMEText where the message includes non-ascii characters?! What is the problem with encoding the message as utf-8 before setting the payload? That has always worked for me. pl = u'Some text with chars that need encoding:\xa3'.encode('utf-8') msg.set_payload(pl ,charset) From the docs: The payload is either a string in the case of simple message objects or a list of Message objects for MIME container documents (e.g. multipart/* and message/rfc822) Message objects are always encoded strings. I don't remember seeing that it should be possible to use a unicode string as a message. The charset passed in set_payload(pl ,charset) is the charset the the string *is* encoded in. Not the charset it *should* be encoded in. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list
Re: egg and modpython
Paul Boddie wrote: Bruno Desthuilliers wrote: Wensheng a écrit : I installed pysqlite2 using easy_install. and got this when using it from modpython: -- Mod_python error: PythonHandler etc.modpython [...] I applaud you for studying the traceback in more depth than I can find the motivation for, Bruno. ;-) However, this looks like a program using some package installed by setuptools/easy_install needs to unpack that package when running. Yes, this is explained in the doc. Pure Python eggs can run from zipped files, but when there's a binary extension it has to be unzipped. The OP's problem is that the PYTHON_EGG_CACHE env points to a directory not writable for the user account. The two obvious solutions are to change this env variable or reinstall the egg with the appropriate flag to avoid installing it as a zipped egg. ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/var/www/.python-eggs' And this wants to happen apparently in the home directory of the Web server user, whose rights may be somewhat limited. Or perhaps one has to initialise setuptools for any particular user by running it first as that user: No, it's just a matter of specifying another value for the PYTHON_EGG_CACHE. [...] Can peak developers fix this please? Why should they fix something that's 1/ documented - http://peak.telecommunity.com/DevCenter/EggFormats#zip-file-issues The Internal Structure of Python Eggs / STOP! This is not the first document you should read! That doesn't mean you should not read it. A case of Beware of the Leopard perhaps? !-) 2/ not a an egg specific issue In my experience, most other package managers actually unpack their resources when invoked, rather than leaving the programs to attempt such things when running. eggs are the Python's equivalent to Java's JAR, not a RPM-like. I said it was not an egg-specific issue (which is not totally accurate) because it mostly have to do with loading dynamic libs (.so, .dll etc) from zipped files. Debian packages even compile the bytecode files to ensure that nothing tries (and fails) to write them to privileged locations afterwards. So does eggs. But once again, eggs are *not* a general-purpose package management system like apt, RPM, emerge etc... (snip) This situation looks either a lot like a use case whose popularity has been underestimated by the developers - intriguing given the number of people supposedly using setuptools for their Web application deployments - or a packaging mistake with the pysqlite2 .egg file. My VHO is that eggs needing to extract some of their content should not be packaged as zip-safe. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Tim Golden [EMAIL PROTECTED] wrote: if os.path.isfile (filepath): print filepath You might get a more accurate result using os.access(filepath, os.X_OK) instead of os.path.isfile(filepath) Which checks the file is executable -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
kondal wrote: This is the way the regexp works python doesn't has anything to do with it. It starts parsing the data with the pattern given. It returns the matched string acording the pattern and doesn't go back to find the other combinations. I've recently had the same problem in Java, using automatically generated regular expressions to find the longest match; I failed on cases like matching the whole of Abcdefg, but also the whole of AbCdefg or ABcdefg, with ([A-Z][a-z])?([A-Z][A-Za-z]{1,10})? . No systematic way to deal with these corner cases was available, and unsystematic ways (with greedy and reluctant quantifiers) were too complex. I ended up eliminating regular expressions completely and building a dynamic programming parser that returns the set of all match lengths; it wasn't hard and it should be even easier in Python. Lorenzo Gatti -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
Marty wrote: On 9/11/06, Mike Owens [EMAIL PROTECTED] wrote: I coworker pointed me to this thread. Joy for us. snipped good information In all seriousness, the information you present here is great, and much appreciated. Your sarcastic, condescending tone kind of gets in the way of the message, though. What about jokes on waterheadretard then ? -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
RE: best way of testing a program exists before using it?
[Nick Craig-Wood] | Tim Golden [EMAIL PROTECTED] wrote: | if os.path.isfile (filepath): | print filepath | | You might get a more accurate result using | | os.access(filepath, os.X_OK) | | instead of | | os.path.isfile(filepath) | | Which checks the file is executable Sadly, not under Win32, hence the shenanigans with the PATHEXT variable :) TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Bryan Olson wrote: Licheng Fang wrote: Oh, please do have a look at the second link I've posted. There's a table comparing the regexp engines. The engines you've tested probably all use an NFA implementation. Unfortunately, the stuff about NFA's is wrong. Friedl's awful book was the first time I saw this confusion about what NFA is; I don't know if he originated the mess or just propagated it. Nondeterministic finite automata is well defined in theory of computation. The set of languages accepted by NFA's is exactly the same as the set accepted by DFA's. What Python uses is search-and-backtrack. Unfortunately such engines don't have much theory behind them, and it's hard to reason generally about what they do. -- --Bryan Thanks for the valuable information. Indeed, when I read the pages, I was a little confused about what it meant by 'NFA'. But I faintly felt, there might be an indirect, and not not very exact mapping from the search-and-backtrack strategy to NFAs in the sense of computer science, e.g. a state machine with the capability to be in several states at one time. Say, when reading 'oneselfsufficient', the engine goes along the NFA first to state 1, and then faces the choice between one self, noneselfsufficient, none (start)---((1))((2))---((3)) 1) matching 'self', 2) going on to state 2 without matching anything, or 3) just give 'one' as the matching result because state 1 is already a terminal state In such situations it always chooses the greedy way. To match more, it goes to the state 2, munching 'self'. And now it's left with only 'sufficient'. Here it's choices are: 1) matching nothing and going to state 3 2) just give 'oneself' as result because state 2 is also a terminal state Again it's greedy, going on to state 3, in hope of matching more. But here the pattern comes to an end, represented by state 3 as a terminal state. So the engine gives 'oneself' as result and forgets about its previously unexplored possibilities, because it only performs backtrack when a match cannot be found. I think if the backtrack is carried out in an exaustive way, we may say the engine trys every possibility on the NFA, though it's not an NFA itself. -- http://mail.python.org/mailman/listinfo/python-list
Re: BaseHTTPServer weirdness
Ron Garret wrote: In article [EMAIL PROTECTED], Kent Johnson [EMAIL PROTECTED] wrote: Steve Holden wrote: Ron Garret wrote: In article [EMAIL PROTECTED], Steve Holden [EMAIL PROTECTED] wrote: But basically, you aren't providing a CGI environment, and that's why cgi.parse() isn't working. Clearly. So what should I be doing? Surely I'm not the first person to have this problem? I have managed to work around this for now by copying and modifying the code in cgi.parse, but this still feels like a Horrible Hack to me. Let me get this right. You are aware that CGIHTTPServer module exists. But you don't want to use that. Instead you want to use your own code. So you have ended up duplicating some of the functionality of the cgi library. And it feels like a hack. Have I missed anything? :-) Hey, be nice. Wanting to write a request handler that actually handles a POST request doesn't seem so unreasonable. Except...when there are about a bazillion Python web frameworks to choose from, why start from BaseHTTPServer? Why not use one of the simpler frameworks like Karrigell or Snakelets or CherryPy? It may come to that. I just thought that what I'm trying to do is so basic that it ought to be part of the standard library. I mean, what do people use BaseHTTPServer for if you can't parse form input? Here is the query-handling code from Karrigell's CustomHTTPServer.py, good at least for a second opinion: def do_POST(self): Begin serving a POST request. The request data must be readable on a file-like object called self.rfile ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) self.body = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ = {'REQUEST_METHOD':'POST'}, keep_blank_values = 1, strict_parsing = 1) # throw away additional data [see bug #427345] while select.select([self.rfile._sock], [], [], 0)[0]: if not self.rfile._sock.recv(1): break self.handle_data() Here is CherryPy's version from CP 2.1: # Create a copy of headerMap with lowercase keys because # FieldStorage doesn't work otherwise lowerHeaderMap = {} for key, value in request.headerMap.items(): lowerHeaderMap[key.lower()] = value # FieldStorage only recognizes POST, so fake it. methenv = {'REQUEST_METHOD': POST} try: forms = _cpcgifs.FieldStorage(fp=request.rfile, headers=lowerHeaderMap, environ=methenv, keep_blank_values=1) where _cpcgifs.FieldStorage is cgi.FieldStorage with some extra accessors. Here's what I actually ended up doing: def parse(r): ctype = r.headers.get('content-type') if not ctype: return None ctype, pdict = cgi.parse_header(ctype) if ctype == 'multipart/form-data': return cgi.parse_multipart(r.rfile, pdict) elif ctype == 'application/x-www-form-urlencoded': clength = int(r.headers.get('Content-length')) if maxlen and clength maxlen: raise ValueError, 'Maximum content length exceeded' return cgi.parse_qs(r.rfile.read(clength), 1) else: return None which is copied more or less directly from cgi.py. But it still seems to me like this (or something like it) ought to be standardized in one of the *HTTPServer.py modules. But what do I know? I wouldn't necessarily say you are wrong here, It's just that the cgi module has sort of just growed, so it isn't conveniently factyored for reusability in other contexts. Several people (including me) have taken a look at it with a view to possible re-engineering and backed away because of the difficulty of maintaining compatibility. Python 3K will be an ideal oppoertunity to replace it, but until then it's probably going to stay in the same rather messy but working state. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers wrote: Okay, more out of desperation than anything else, lets try this: from email.Charset import Charset,QP from email.MIMEText import MIMEText from StringIO import StringIO from email import Generator,Message Generator.StringIO = Message.StringIO = StringIO charset = Charset('utf-8') charset.body_encoding = QP msg = MIMEText(u'Some text with chars that need encoding: \xa3','plain') msg.set_charset(charset) print repr(msg.as_string()) u'MIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\nContent-Type: text/plain; charset=utf-8\n\nSome text with chars that need encoding: \xa3' Yay! No unicode error, but also no use: File c:\python24\lib\smtplib.py, line 692, in sendmail (code,resp) = self.data(msg) File c:\python24\lib\smtplib.py, line 489, in data self.send(q) File c:\python24\lib\smtplib.py, line 316, in send self.sock.sendall(str) File string, line 1, in sendall UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 297: ordinal not in range(128) Yes, it seemed to work with your original example, but of course you have to encode unicode somehow before sending it through a wire. A severe case of peephole debugging, sorry. I've looked into the email package source once more, but I fear to understand the relevant parts you have to understand it wholesale. As Max suggested, your safest choice is probably passing in utf-8 instead of unicode. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Max M wrote: From the docs: The payload is either a string in the case of simple message objects or a list of Message objects for MIME container documents (e.g. multipart/* and message/rfc822) Where'd you find that? I must have missed it in my digging :-S Message objects are always encoded strings. I don't remember seeing that it should be possible to use a unicode string as a message. Yes, I guess I just find that surprising in today's everything should be unicode world. The charset passed in set_payload(pl ,charset) is the charset the the string *is* encoded in. Not the charset it *should* be encoded in. Indeed, although there's still the bug that while set_payload can accept a Charset instance for its _charset parameter, the __init__ method for MIMENonMultipart cannot. Incidentally, here's the class I finally ended up with: from email.Charset import Charset from email.MIMEText import MIMEText as OriginalMIMEText from email.MIMENonMultipart import MIMENonMultipart class MTText(OriginalMIMEText): def __init__(self, _text, _subtype='plain', _charset='us-ascii'): if not isinstance(_charset,Charset): _charset = Charset(_charset) if isinstance(_text,unicode): _text = _text.encode(_charset.input_charset) MIMENonMultipart.__init__(self, 'text', _subtype, **{'charset': _charset.input_charset}) self.set_payload(_text, _charset) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
[EMAIL PROTECTED] wrote: kondal wrote: This is the way the regexp works python doesn't has anything to do with it. It starts parsing the data with the pattern given. It returns the matched string acording the pattern and doesn't go back to find the other combinations. I've recently had the same problem in Java, using automatically generated regular expressions to find the longest match; I failed on cases like matching the whole of Abcdefg, but also the whole of AbCdefg or ABcdefg, with ([A-Z][a-z])?([A-Z][A-Za-z]{1,10})? . No systematic way to deal with these corner cases was available, and unsystematic ways (with greedy and reluctant quantifiers) were too complex. I ended up eliminating regular expressions completely and building a dynamic programming parser that returns the set of all match lengths; it wasn't hard and it should be even easier in Python. Lorenzo Gatti Thanks. I think make use of the expresiveness of CFG may be better idea. Another question: my task is to find in a given string the substrings that satisfies a particular pattern. That's why the first tool that came to my mind is regular expression. Parsers, however, only give a yes/no answer to a given string. To find all substrings with a particular pattern I may have to try every substring, which may be an impossible task. How can I solve this problem? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Licheng Fang [EMAIL PROTECTED] writes: I think if the backtrack is carried out in an exaustive way, we may say the engine trys every possibility on the NFA, though it's not an NFA itself. The backtracking engine really can recognize languages that are not describable by classical regexps, by using backreferences, negation, etc. But exactly what it can do is nowhere near as well-understood as what classical regexps can do. I seem to remember that the fully general problem of recognizing regexps with negation is very hard, so the backtracking matcher either has to reject some strings it should really match, or else it has to bog down horribly with certain kinds of patterns. -- http://mail.python.org/mailman/listinfo/python-list
Re: Get CPU usage of a single process in Windows
Tim Golden wrote: ...snip... This should be possible as Taskmanager tracks CPU usage for every process... Anyone know how this can be done? WMI can probably do the trick. If you can find something on Google for wmi cpu usage (or something similar) then translation to Python's usually quite easy. I'm fairly sure I've got an example somewhere, but I can't lay my hands on it at the mo. TJG Tim Golden's general documentation/examples about WMI are at: http://tgolden.sc.sabren.com/python/wmi.html. If you have a working example of CPU usage could you post the result? I would be interested. kind regards, Gerrit Muller -- Gaudi systems architecting: http://www.gaudisite.nl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Licheng Fang wrote: Another question: my task is to find in a given string the substrings that satisfies a particular pattern. That's why the first tool that came to my mind is regular expression. Parsers, however, only give a yes/no answer to a given string. To find all substrings with a particular pattern I may have to try every substring, which may be an impossible task. You can collect all successful parser results beginning from each index in the string; this gives you all matches with that first index. You could extend to multiple results general bottom-up context-free language parsing like Earley or Tomita's algorithms; for reasonable languages most locations can be excluded for most rules at the beginning, with great performance improvements over trying over and over again. Lorenzo Gatti -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Mike Owens [EMAIL PROTECTED] writes: No it doesn't. If you don't like SQLite's design decisions, write your own embedded relational database, and stop yapping about something you didn't lift a finger to create, but are clearly trying to benefit from. That's silly. The sqlite developers are making all kinds of claims on their web site, in order to attract users and build mindshare and gain the benefits thereof. If the claims aren't valid, it's completely appropriate for others to call attention to it, whether or not they feel like doing anything to fix it. It's just like anything else. If you think your Congressperson is misleading the public about something or pursuing a bad policy, you should speak out about it. That doesn't mean you need to run for Congress yourself. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the longest possible match with Python's RE module?
Licheng Fang wrote: The idea is like this: (*INT) = \d+ (*DECIMAL) = (*INT)\.(*INT) (*FACTION) = (*DECIMAL)/(*DECIMAL) (*NUMERALS) = (*FACTION)|(*DECIMAL)|(*INT) ... ... What's inside the sytactically wrong (* and ) is something to be replaced, and then I wrote a little script to do the string substitution what's hiding under those ellipses? things like TERM and FACTOR and EXPRESSION, perhaps? /F -- http://mail.python.org/mailman/listinfo/python-list
deprecated python 2.5
DeprecationWarning: struct integer overflow masking is deprecated return struct.pack('H', ~value) i didn't understand if someone have some explanation and what uses instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] markup.py 1.5 - a lightweight HTML/XML generator
Daniel Nogradi wrote: A new release of markup.py is available at http://markup.sourceforge.net/ The markup module is an intuitive, lightweight, easy-to-use, customizable and pythonic HTML/XML generator. [...] It's more than only a bit confusing that there's also Markup: A toolkit for stream-based generation of markup for the web at http://markup.edgewall.org/ - basically a replacement for the Kid XHTML templating solution. At first I was confusing your project with the other package, which I was planning to give a try sooner or later. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated python 2.5
bussiere maillist wrote: DeprecationWarning: struct integer overflow masking is deprecated return struct.pack('H', ~value) i didn't understand if someone have some explanation and what uses instead. Which 2.5 are you using? Mine (2.5c1, win32) gives me *TWO* messages, the second of which hints at the obvious remedy: | DOS prompt\python25\python | Python 2.5c1 (r25c1:51305, Aug 17 2006, 10:41:11) [MSC v.1310 32 bit (Intel)] on | win32 | Type help, copyright, credits or license for more information. | import struct | struct.pack('H', 1) | '\x00\x01' | struct.pack('H', ~1) | __main__:1: DeprecationWarning: struct integer overflow masking is deprecated | __main__:1: DeprecationWarning: 'H' format requires 0 = number = 65535 | '\xff\xfe' | ^Z | | DOS prompt\python25\python | Python 2.5c1 (r25c1:51305, Aug 17 2006, 10:41:11) [MSC v.1310 32 bit (Intel)] on | win32 | Type help, copyright, credits or license for more information. | import struct | struct.pack('H', (~1) 0x) | '\xff\xfe' | HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated python 2.5
bussiere maillist wrote: DeprecationWarning: struct integer overflow masking is deprecated return struct.pack('H', ~value) i didn't understand if someone have some explanation and what uses instead. the value doesn't fit in 16 bits. try masking off the extra bits on the way in: struct.pack(H, (~value) 0x) /F -- http://mail.python.org/mailman/listinfo/python-list
RE: Get CPU usage of a single process in Windows
[Gerrit Muller] | | Tim Golden wrote: | WMI can probably do the trick. I'm fairly sure I've got an example | somewhere, but I can't lay my hands on it at the mo. | If you have a working example of CPU usage could you post the | result? I | would be interested. I haven't time to revisit it just at the moment, but here's an earlier thread in which I posted a version: http://mail.python.org/pipermail/python-win32/2006-April/004536.html (If it's not readable because of formatting, drop me a private email and I'll send you a copy) TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: egg and modpython
Bruno Desthuilliers wrote: eggs are the Python's equivalent to Java's JAR, not a RPM-like. I said it was not an egg-specific issue (which is not totally accurate) because it mostly have to do with loading dynamic libs (.so, .dll etc) from zipped files. True. It is notable that various Java application servers (to consider the questioner's original problem) do unpack .war files, which probably share more properties with .egg files than .jar files do. Indeed, I don't recall a single occasion where I've ever needed to unpack .jar files to have them successfully used by Java programs. Debian packages even compile the bytecode files to ensure that nothing tries (and fails) to write them to privileged locations afterwards. So does eggs. But once again, eggs are *not* a general-purpose package management system like apt, RPM, emerge etc... However, it seems to me that the setuptools and EasyInstall ecosystem, whilst a remarkable achievement, has grown in scope sufficiently to confuse such comparisons. Some .egg files are more than just being like .jar files, as I note above, and with additional dependency information included (as seems to be encouraged), one is suddenly required to deal with a system that resembles a Python-centric package and dependency management system rolled into one, operating in parallel with whatever native package manager and whatever dependency management system (they're typically separate things) that may be in operation. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Mike Owens wrote: Crackpot? And now we get to why I took the flamebait -- wonderfully constructive comments such as this. I know SQLite's author. Besides being a nice and clearly very intelligent person, he also holds a master's degree in electrical engineering from Georgia Tech and a PhD in computer science from Duke University. His crackpot software is used by Sun, Apple, Symbian, Google, AOL, Philips, DLink, and I don't know how many other companies, not to mention countless open source projects such as Mozilla, PHP, and now Python. but is he a member of Mensa? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Steve Holden wrote: Sure. But if you go back to the start of the thread you'll remember the OP was originally complaining that SQLite was being promoted in the Python docs as SQL compliant. It clearly isn't if its response to the insertion of a data value that conflicts with the declared column type is to store a value whose type is something else. the standard actually says If the value of any input parameter provided by the SQL-agent falls outside the set of allowed values of the data type of the parameter /.../ the effect is implementation-defined so that's perfectly SQL92 compliant. in fact, the phrases is implementation-defined and is implementation- dependent occurs hundreds of times in the SQL92 standard. it's far from obvious to me that SQL92 would rule out storing everything as strings (The physical representation of a value is implementation- dependent.) and leaving it to the language binding to map things back to the host language types in whatever way it wants (Each host language has its own data types, which are separate and distinct from SQL data types, the above quotation, and so on). looks like the real problem here is that some people think that implementation-defined means works as it did in that other database I'm using, and not specified by the implementor for each particular SQL-implementation. that's not how standards work; if something's explicitly left undefined, it's not something you can rely on. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Paul Rubin wrote: Mike Owens [EMAIL PROTECTED] writes: No it doesn't. If you don't like SQLite's design decisions, write your own embedded relational database, and stop yapping about something you didn't lift a finger to create, but are clearly trying to benefit from. That's silly. The sqlite developers are making all kinds of claims on their web site, in order to attract users and build mindshare and gain the benefits thereof. If the claims aren't valid, it's completely appropriate for others to call attention to it, whether or not they feel like doing anything to fix it. It's just like anything else. If you think your Congressperson is misleading the public about something or pursuing a bad policy, you should speak out about it. That doesn't mean you need to run for Congress yourself. Though it might improve the country's politics if wanting to be a Congressperson was an absolute disqualification from the job. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers wrote: Max M wrote: From the docs: The payload is either a string in the case of simple message objects or a list of Message objects for MIME container documents (e.g. multipart/* and message/rfc822) Where'd you find that? I must have missed it in my digging :-S End of third paragraph: http://docs.python.org/lib/module-email.Message.html -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list
Re: deprecated python 2.5
thks Regards Bussiere On 9/12/06, Fredrik Lundh [EMAIL PROTECTED] wrote: bussiere maillist wrote: DeprecationWarning: struct integer overflow masking is deprecated return struct.pack('H', ~value) i didn't understand if someone have some explanation and what uses instead. the value doesn't fit in 16 bits. try masking off the extra bits on the way in: struct.pack(H, (~value) 0x) /F -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
filtered view upon lists?
Hi there :) I don't know how else to call what I'm currently implementing: An object that behaves like a list but doesn't store it's own items but rather pulls them from a larger list (if they match a certain criterion). Changes to the filter are instantly reflected in the underlying list. Clear enough? Ok, so I figured that this is generic enough to be found in some standard module already (I've had this often enough: Painfully implementing s/th and then finding it in the libs some weeks later.). Any pointers? c.u. wildemar -- http://mail.python.org/mailman/listinfo/python-list
FW: Re: [Spambayes] How to create a valid RPM?
ls, On 09/12/2006 11:48:10 AM, [EMAIL PROTECTED] wrote: when I download python-spambayes-1.0rc2-2.src.rpm, install it and run rpmbuild -ba ../SPECS/python-spambayes.spec, I get a lot of error messages. It complains about a lot of installed but unpackaged files. How can I create a valid RPM? Dunno. Did you try python setup.py bdist_rpm? This is a bit more This gives the same errors. In fact it calls rpmbuild... general than just SpamBayes. You might get some useful help from comp.lang.python (aka python-list@python.org). can anyone of you guys help me? It seems that the spec-file does not contain a valid %files section. Thanks, cu l8r, Edgar. -- \|||/ (o o) Just curious... ooO-(_)-Ooo--- -- http://mail.python.org/mailman/listinfo/python-list
Clarify Regex in Python.
After may frustrated attempts I came to know that match function in python re package actually start the matchs at the begining of the subject, where search will find the given pattern any where in the subject. My Problem is, I want to know how can I force match functions to match the pattern any location in the subject. i.e I want to turn off before said behaviour. Thanks In advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Running python from a usb drive
Jason: Thanks! That worked...in fact, almost everything is now working as expected (so far). Here is my batch file: echo Making changes to path and file associations... path = %PATH%;%CD%Python24;%CD%Python24\libs;%CD%Python24\Scripts;%CD%Python24\Lib\site-packages;%CD%Python24\DLLs set PYTHONPATH=%CD%Python24 ASSOC .py=Python.File ASSOC .pyc=Python.CompiledFile ASSOC .pyo=Python.CompiledFile ASSOC .pyw=Python.NoConFile FTYPE Python.File=%CD%Python24\python.exe %%1 %%* FTYPE Python.CompiledFile=%CD%Python24\python.exe %%1 %%* FTYPE Python.NoConFile=%CD%Python24\pythonw.exe %%1 %%* set PATHTEXT=.py;%PATHTEXT% CMD I'm still having a problem with setting PATHTEXT...I should be able to now type django-admin at the cmd prompt and have it work, but I need to still type django-admin.py ... I'm not sure what's wrong with my setting of pathtext. Any ideas? Thanks again, CJL -- http://mail.python.org/mailman/listinfo/python-list
RE: Get CPU usage of a single process in Windows
[Gerrit Muller] | If you have a working example of CPU usage could you post the | result? I would be interested. OK. Here's a workingish example, cut down from the link I posted earlier. This one was designed to work with Win2K which I was using at the time. For WinXP and later, there's a new counter with the ungainly name of Win32_PerfFormattedData_PerfProc_Process which should give you the number straight off without having to do the take-and-diff-and-divide dance. However, it doesn't seem to do anything useful on my (XP) system. Haven't tried that hard, I admit. As ever, if you can find any example around the Web -- and there are loads -- converting it to Python should be a breeze. TJG code import time import wmi c = wmi.WMI () process_info = {} while True: for process in c.Win32_Process (): id = process.ProcessID for p in c.Win32_PerfRawData_PerfProc_Process (IDProcess=id): n1, d1 = long (p.PercentProcessorTime), long (p.Timestamp_Sys100NS) n0, d0 = process_info.get (id, (0, 0)) try: percent_processor_time = (float (n1 - n0) / float (d1 - d0)) * 100.0 except ZeroDivisionError: percent_processor_time = 0.0 process_info[id] = (n1, d1) if percent_processor_time 0.01: print %20s - %2.3f % (process.Caption, percent_processor_time) print time.sleep (5) /code This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
RE: Running python from a usb drive
[cjl] [... snip ...] | set PATHTEXT=.py;%PATHTEXT% | I'm still having a problem with setting PATHTEXT... That would be because it's PATHEXT not PATHTEXT (it's sort of like a PATH but for EXTensions). TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Clarify Regex in Python.
On 12 Sep 2006 05:07:03 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: My Problem is, I want to know how can I force match functions to match the pattern any location in the subject. i.e I want to turn off before said behaviour. Use search() instead; that's why the method is there. (Or put .* at the beginning of all your patterns, though that will be slightly slower.) --amk -- http://mail.python.org/mailman/listinfo/python-list
Re: Clarify Regex in Python.
[EMAIL PROTECTED] wrote: After may frustrated attempts I came to know that match function in python re package actually start the matchs at the begining of the subject, where search will find the given pattern any where in the subject. My Problem is, I want to know how can I force match functions to match the pattern any location in the subject. i.e I want to turn off before said behaviour. Thanks In advance. Erm, is there some specific reason why you can't just use the search method? Why does it *have* to be match()? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
variable update
Hi all Is there any handy untility for checking if a variable is populated at runtime ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Help me use my Dual Core CPU!
I've just bought a new notebook, which has a dual core CPU. I write cross platform games in Python, and I'd really like to be able to use this second core (on my machine, and on user's machines) for any new games I might write. I know threads won't help (in CPython at least) so I'm investigating other types of concurrency which I might be able to use. I really like the PyLinda approach, however I need to be able to pass around all the simple python types, which PyLinda won't help me with. Also, PyLinda is more focused on distributing computing; I really only want to have 2 processes cooperating (or 4, if I had 4 CPUs/cores etc). Is there any cross platform way to share python objects across processes? (I've found POSH, but it's old, and doesn't appear to be maintained). I could implement my own object space using shared memory, but from what I can see, this is not available on Win32. Are there any other concurrency options I've not discovered yet? -Sw. -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Tim Williams wrote: Alternatively there is os.path.exists which works for files or directories, but calling it every time you use the wrapper is probably more expensive than using the try statement when the program *does* exist. import os.path if not os.path.exists('/dir1/dir2/filename'): print_something_and_exit(filename) :) problem with that is that the path may change between installations on different machine and I can't guarantee /dir1/dir2 which is why a test of all dirs in the path is more portable. -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: Running python from a usb drive
Tim: That would be because it's PATHEXT not PATHTEXT (it's sort of like a PATH but for EXTensions). Doh. Me fail English? That's unpossible. Thanks, I think everything is working with my poor man's movable python. Last on my todo list is to restore the assoc and ftype settings when I'm done, and I found: http://portableapps.com/node/121 Which seems to show how to do that. CJL -- http://mail.python.org/mailman/listinfo/python-list
Re: markup.py 1.5 - a lightweight HTML/XML generator
A new release of markup.py is available at http://markup.sourceforge.net/ The markup module is an intuitive, lightweight, easy-to-use, customizable and pythonic HTML/XML generator. [...] It's more than only a bit confusing that there's also Markup: A toolkit for stream-based generation of markup for the web at http://markup.edgewall.org/ - basically a replacement for the Kid XHTML templating solution. At first I was confusing your project with the other package, which I was planning to give a try sooner or later. Apparently markup.edgewall.org is redirected now to genshi.edgewall.org and the name of that project became Genshi recently, maybe exactly to avoid the confusion. Well, then this problem has been taken care of :) Thanks for the info anyway I quite frankly didn't know about this other project. Perhaps I should add a note to the webpage clarifying this. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Clarify Regex in Python.
Erm, is there some specific reason why you can't just use the search method? Why does it *have* to be match()? regards Steve I know there r many more methods to do the job, I just wonder can we turnoff the default behaviour of match method. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
error
Hi, Today is my first day of working on python. I want to execute python script through C++ program. I found one very good article with example at http://docs.python.org/ext/pure-embedding.html. I followed the procedure as given, the code is compiled but while running it is giving error like: ImportError: No module named multiply Failed to load multiply Here are the steps I followed, please suggest where I am wrong and how can I remove the above error. Step 1: Copied the given C program into a file called test.cpp (using vi editor) Step 2: Compiled it using : g++ test.cpp /usr/lib/libpython2.4.so (created a.out) Step 3: Wrote the given script of multipication in a file named as multiply (using vi editor) Step 4: But while running the program using :./a.out multiply multiply 3 2 Getting this error: ImportError: No module named multiply Failed to load multiply Please help me out. Thanks Regards, Prashant Burghate Project Engineer, Embedded Systems, Wipro Technologies, Pune. Tel: +91-20-22933700 Extn: 51570 Mob. # 9850428252 Email: [EMAIL PROTECTED] The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Get CPU usage of a single process in Windows
[Tim Golden] nice answer snipped now I only have to find some time to play around... thanks, Gerrit -- Gaudi systems architecting: http://www.gaudisite.nl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Clarify Regex in Python.
[EMAIL PROTECTED] wrote: Erm, is there some specific reason why you can't just use the search method? Why does it *have* to be match()? regards Steve I know there r many more methods to do the job, I just wonder can we turnoff the default behaviour of match method. Don't wonder. Read the documentation. There is a whole section devoted to match versus search. If you believe there are undocumented keyword arguments to the match method and we are wantonly withholding the information, then you should check out your theory by downloading the source code and reading that. HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Running python from a usb drive
cjl wrote: Tim: That would be because it's PATHEXT not PATHTEXT (it's sort of like a PATH but for EXTensions). Doh. Me fail English? That's unpossible. Thanks, I think everything is working with my poor man's movable python. Last on my todo list is to restore the assoc and ftype settings when I'm done, and I found: http://portableapps.com/node/121 Which seems to show how to do that. Congratulations. Now: how much time have you spent, and how much per hour are you worth? hours * dollars_per_hour GBP_to_USD(4.99) ??? -- http://mail.python.org/mailman/listinfo/python-list
Re: filtered view upon lists?
Wildemar Wildenburger [EMAIL PROTECTED] writes: I don't know how else to call what I'm currently implementing: An object that behaves like a list but doesn't store it's own items but rather pulls them from a larger list (if they match a certain criterion). Changes to the filter are instantly reflected in the underlying list. Clear enough? It looks like you're implementing a callable to me. This is a method that returns results based on some input -- here your original list and filter. Then you'll use this method wherever you need that filtered list. Ok, so I figured that this is generic enough to be found in some standard module already (I've had this often enough: Painfully implementing s/th and then finding it in the libs some weeks later.). I don't believe it is generic. Nobody knows your data specs or filtering needs. Any pointers? Use of list comprehension might make it easier to code this: def myCallable(my_list, filter): filtered_list = [(item) for item in my_list if filter(item)] return filtered_list Example of full code: test_list = range(10) filter = lambda x: not x%2 def myCallable(list, filter): ... filtered_list = [(item) for item in list if filter(item)] ... return filtered_list ... myCallable(test_list, filter) [0, 2, 4, 6, 8] for item in myCallable(test_list, filter): ... print See? I'm, item ... See? I'm 0 See? I'm 2 See? I'm 4 See? I'm 6 See? I'm 8 -- Jorge Godoy [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Clarify Regex in Python.
[EMAIL PROTECTED] wrote: I know there r many more methods to do the job, I just wonder can we turnoff the default behaviour of match method. that's not the default behaviour, that's how match works. if you want search, use search instead. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: variable update
km wrote: Is there any handy untility for checking if a variable is populated at runtime ? access it, and catch the NameError: try: variable except NameError: print not defined else: print defined leaving variables undefined is usually bad style, though; if you can, assign some value to it, and test for that value instead: variable = None ... lots of code that may assign to variable ... if variable is not None: print not defined /F -- http://mail.python.org/mailman/listinfo/python-list
RE: Help me use my Dual Core CPU!
[Simon Wittber] | I write cross platform games in Python, and I'd really like to be able | to use this second core (on my machine, and on user's | machines) for any new games I might write. | I know threads won't help (in CPython at least) so I'm investigating | other types of concurrency which I might be able to use. I really like | the PyLinda approach I find it very elegant. I only wish I had some real-world use for it! | Is there any cross platform way to share python objects across | processes? (I've found POSH, but it's old, and doesn't appear to be | maintained). I could implement my own object space using | shared memory, but from what I can see, this is not available on Win32. There is a bunch of Python sub-industries dedicated to inter-process cooperation. But I don't know if that's what you're after. Setting aside the strict shared-memory option (for which I don't know of a cross-platform solution), you have -- in particular order: + Pyro - http://pyro.sf.net + Corba - eg omniorb http://omniorb.sourceforge.net/ + SPyRO - http://lsc.fie.umich.mx/~sadit/spyro/spyro.html + mmap - (built-in module) http://docs.python.org/lib/module-mmap.html + twisted - (because it can do everything), esp. http://twistedmatrix.com/projects/core/spread + Spread - http://www.spread.org/ + Roll-your-own sockets - http://docs.python.org/lib/module-SocketServer.html etc. etc. etc. But I have the feeling I'm teaching my grandmother... Is that the kind of thing you were after? Or not? TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the package, file, and line of a method/function invocant?
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], metaperl wrote: # Of course I could cheat and pass it, but I don't want to: directories = data.storage.logic(__file__) Why do you consider a plain and simple solution cheating? Hmm, I dont know the proper software engineering term, but just on the basis of instinct, it seems wrong for a function to use something that it can get on its own. It's kind of like being at a 5-star hotel. It might be very possible for you to bring your own pop tarts and toast them, but they go to great lengths to have a continental buffet ready for you without you doing anything. Good question, airheaded answer :) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the package, file, and line of a method/function invocant?
Miki wrote: I am looking for something like the caller() routine in Perl: http://perldoc.perl.org/functions/caller.html Look at the inspect module in Python's standard library. Or is you're feeling lazy, have a look at the here function found in http://www.unixreview.com/documents/s=9133/ur0404e/ur0404e_listing1.htm Thanks for the link. I would've never figured out how to use inspect on my own. -- http://mail.python.org/mailman/listinfo/python-list
Re: error
[EMAIL PROTECTED] wrote: Hi, [...] Step 3: Wrote the given script of multipication in a file named as multiply (using vi editor) The name of module should be multiply.py HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list
I wish I could add docstrings to vars.
I build a lot of elaborate dictionaries in my interpreter, and then I forget exactly how they work. It would be really nice to be able to add notes to the dictionary. Is there some way to do this now? Matt -- A better way of running series of SAS programs: http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me use my Dual Core CPU!
Simon Wittber [EMAIL PROTECTED] writes: Are there any other concurrency options I've not discovered yet? I've been wondering about the different Python MPI bindings that are out there, and whether they might make sense for general purpose concurrency when they were designed mostly for parallel numerical computation. Better MPI libraries should at least be able to communicate by shared memory--I don't know if Pylinda does that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing String, Dictionary Lookups, Writing to Database Table
On Mon, 11 Sep 2006, [EMAIL PROTECTED] wrote: No, if you're going to insert into sqlite3, you don't want a csv string, you want a list of values (see example code below). Thank you very much. It makes solid sense and I can see the differences and where I was not on track. I greatly appreciate the time and effort you put into helping me. Rich -- Richard B. Shepard, Ph.D. |The Environmental Permitting Applied Ecosystem Services, Inc.(TM)|Accelerator http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 -- http://mail.python.org/mailman/listinfo/python-list
Re: error
[EMAIL PROTECTED] wrote: Hi, Today is my first day of working on python. I want to execute python script through C++ program. I found one very good article with example at http://docs.python.org/ext/pure-embedding.html. I followed the procedure as given, the code is compiled but while running it is giving error like: ImportError: No module named multiply Failed to load multiply Here are the steps I followed, please suggest where I am wrong and how can I remove the above error. Step 1: Copied the given C program into a file called test.cpp (using vi editor) Step 2: Compiled it using : g++ test.cpp /usr/lib/libpython2.4.so (created a.out) Step 3: Wrote the given script of multipication in a file named as multiply (using vi editor) Try naming your source file multiply.py but continue to use the module name (multiply) in the command line. [Note: you could have a binary extension module called multiply in a binary file called multiply.so] I guess the author of that manual section didn't contemplate somebody on their first day with Python doing some embedding :-) HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: error
Rob Wolfe wrote: [EMAIL PROTECTED] wrote: Hi, [...] Step 3: Wrote the given script of multipication in a file named as multiply (using vi editor) The name of module should be multiply.py module != source_file module don't have no ferschlugginer dots in its name -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me use my Dual Core CPU!
Tim Golden wrote: + Pyro - http://pyro.sf.net + Corba - eg omniorb http://omniorb.sourceforge.net/ + SPyRO - http://lsc.fie.umich.mx/~sadit/spyro/spyro.html + mmap - (built-in module) http://docs.python.org/lib/module-mmap.html + twisted - (because it can do everything), esp. http://twistedmatrix.com/projects/core/spread + Spread - http://www.spread.org/ + Roll-your-own sockets - http://docs.python.org/lib/module-SocketServer.html For game programming purposes, I was hoping someone could point me to a technique for sharing objects across Python processes, preferably without any kind of marshal/unmarshal steps. It's a long shot, I know. To be viable, I'll need to be able to pass messages between processes very quickly. For example, It would be simple to paralellize some graphics calculations over two processors with each process sharing a common read-only scene data structure; however, a marshalling step in this kind of process would be too costly. I've used three of the libraries you mention, however, they are not very usable for the task I had in mind, but are of course excellent for other server based programming tasks. But I have the feeling I'm teaching my grandmother... Is that the kind of thing you were after? Or not? I'm not familiar with the expression 'teaching my grandmother'. What exactly does it mean? -Sw. -- http://mail.python.org/mailman/listinfo/python-list
RE: Help me use my Dual Core CPU!
| But I have the feeling I'm teaching my grandmother... Is that | the kind of thing you were after? Or not? | | I'm not familiar with the expression 'teaching my grandmother'. What | exactly does it mean? Teaching my grandmother to suck eggs (and probably several variants with other relatives): to teach someone something they've known far better and for far longer. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: error
John Machin wrote: Rob Wolfe wrote: [EMAIL PROTECTED] wrote: Hi, [...] Step 3: Wrote the given script of multipication in a file named as multiply (using vi editor) The name of module should be multiply.py module != source_file module don't have no ferschlugginer dots in its name Ooops... sorry. I meant name of python source file, of course. Regards, Rob -- http://mail.python.org/mailman/listinfo/python-list
Validation of email
Hello, What is the best way to generate a long authentication string and email this so that the user can reply and verify that the email address they have provided is authentic, similar I guess to the way Bugzilla works? Should this be server side or client? How would one tackle an expiry limit on this - i.e. set the string a time limit? Any useful links of implementations in python are most welcomed. Cheers Norman -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the package, file, and line of a method/function invocant?
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], metaperl wrote: # Of course I could cheat and pass it, but I don't want to: directories = data.storage.logic(__file__) Why do you consider a plain and simple solution cheating? Ok now I figured it out. The reason is that this function will be used by many client classes. If we use the plain and simple solution, our codebase increases in size, because each client class will supply the function. Not only that, but they might make an error in what they send. By having the server class do the work, the code base decreases in size and the amount of errors drops. -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
On 12 Sep 2006 00:15:41 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Just to be fair... You do hear many people claiming exactly that, and the primary complaint is often exactly the same one that's being levelled against sqlite here (it's incredibly lax with types and does sometimes mystifying conversions rather than pointing out programmer errors--and yes that's intentionally loaded language that I don't necessarily agree with, it's a common argument though.). True enough. Yet not a single conversion is undocumented in SQLite, nor is its type affinity. It works exactly as advertised. And MySQL's chief type conversion gotchas -- primarily dates/times I think -- were also clearly addressed in the documentation, and where changed in later versions of MySQL. Then there is, as I think another person pointed out on this thread, Oracle's silent conversion of empty strings to NULLs in VARCHAR fields -- talk about mystifying. What about Oracle's native date format, which also has no relation to the standard? I have little experience with Oracle, but from what I can tell, to get it to display dates in standard (ISO) format, you have to set the NLS_DATE_FORMAT at the session or database level, which requires either additional SQL commands, or administrative intervention. More so-called non-SQL compliant behavior, although hardly a surprise (or even a problem) to someone who is experienced with Oracle. The bottom line: to use *any* database effectively, big or small, one has to read its documentation, not the SQL standard. -- http://mail.python.org/mailman/listinfo/python-list
Re: question about including something like sqlite in python
Dan Sommers wrote: It's difficult to imagine any one developer (or development shop) using the entire library, so at least one module must be extraneous. That's a good point. I guess I am just trying to figure out why I'm a little surprised sqlite was included, but at the same time I'm excited to use it and the fact that it will now be standard has caused me to look into more than otherwise. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Running python from a usb drive
John: Congratulations. Now: how much time have you spent, and how much per hour are you worth? hours * dollars_per_hour GBP_to_USD(4.99) ??? Since you mention it, I am currently earning about $200 an hour (when I'm working), and I spent about 3 hours on this, so this cost me about $600. I think 4.99 GBP (the price of movable python) translates to about 9 or 10 dollars. So all told this cost me about $590. Well worth it at twice the price, because I did it myself, I learned from doing it, others my learn from it, and it is open, unlike movable python. Any ideas about how to set file type associations without writing to the registry? Thanks again, CJL -- http://mail.python.org/mailman/listinfo/python-list
RE: Running python from a usb drive
[cjl] | Any ideas about how to set file type associations without writing to | the registry? Well, yes. Just the same as was in the article you pointed to... or have I missed something? assoc .py=python.file ftype python.file=c:\python24\python.exe %1 %* (or whatever version of Python). Obviously switching like this is prone to the difficulties outlined there: if something crashes and you don't change back, you're stuck until you change it back manually. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Secure XMLRPC Server / PEM Files
Daniel Crespo írta: Hi Laszlo, I have read that. It's the wrapper for the usage of OpenSSL, so I have to install it. I have downloaded the Borland C++ compiler, and I'm doing so right now, but I'm not getting good results yet. You do not need any compiler. You just need to install the openssl binaries and the wrapper. I tried to import OpenSSL, it seems to work. Great. Now, I want to try the code I submited earlier, but I need the .pem files. You told me to change generate.sh to generate.bat. How can I do that? Basically, use del instead of rm and use move instead of mv. Use yourdomain.com instead of $1. Moreover, openssl.exe must be on your path. That's all. Try this (untested): openssl req -config openssl.cnf -new -out my-server.csr openssl rsa -in privkey.pem -out my-server.key openssl x509 -in my-server.csr -out my-server.cert -req -signkey my-server.key -days 1500 openssl x509 -in my-server.cert -out my-server.der.crt -outform DER move my-server.csr yourdomain.com.csr move my-server.cert yourdomain.com.cert.pem move my-server.key yourdomain.com.key.pem move my-server.der.crt yourdomain.com.der.crt del privkey.pem Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: I wish I could add docstrings to vars.
On 2006-09-12, Matthew Wilson [EMAIL PROTECTED] wrote: I build a lot of elaborate dictionaries in my interpreter, and then I forget exactly how they work. It would be really nice to be able to add notes to the dictionary. Is there some way to do this now? Writing a thin wrapper around the dictionary might be beneficial, and would also furnish a place for the docstrings. Actually, the wrapper would probably prevent you from needing the docstring very often. ;) -- Neil Cerutti Eddie Robinson is about one word: winning and losing. --Eddie Robinson's agent Paul Collier -- http://mail.python.org/mailman/listinfo/python-list
Re: filtered view upon lists?
Jorge Godoy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Wildemar Wildenburger [EMAIL PROTECTED] writes: I don't know how else to call what I'm currently implementing: An object that behaves like a list but doesn't store it's own items but rather pulls them from a larger list (if they match a certain criterion). Changes to the filter are instantly reflected in the underlying list. Clear enough? It looks like you're implementing a callable to me. This is a method that returns results based on some input -- here your original list and filter. Then you'll use this method wherever you need that filtered list. Ok, so I figured that this is generic enough to be found in some standard module already (I've had this often enough: Painfully implementing s/th and then finding it in the libs some weeks later.). I don't believe it is generic. Nobody knows your data specs or filtering needs. Any pointers? Use of list comprehension might make it easier to code this: def myCallable(my_list, filter): filtered_list = [(item) for item in my_list if filter(item)] return filtered_list Example of full code: test_list = range(10) filter = lambda x: not x%2 def myCallable(list, filter): ... filtered_list = [(item) for item in list if filter(item)] ... return filtered_list ... myCallable(test_list, filter) [0, 2, 4, 6, 8] for item in myCallable(test_list, filter): ... print See? I'm, item ... See? I'm 0 See? I'm 2 See? I'm 4 See? I'm 6 See? I'm 8 -- Jorge Godoy [EMAIL PROTECTED] Functionally-speaking, there is the filter built-in that does this same thing: data = range(10) odds = filter(lambda x : x % 2, data) evens = filter(lambda x : x % 2 != 1, data) odds [1, 3, 5, 7, 9] evens [0, 2, 4, 6, 8] -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
Mike Owens wrote: The bottom line: to use *any* database effectively, big or small, one has to read its documentation, not the SQL standard. note that the SQL standard tells you to read the documentation for the database you're using, in at least 149 places (*). /F *) See Annex B. I only have a draft edition; the number of items in the final version may differ. -- http://mail.python.org/mailman/listinfo/python-list
RE: Running python from a usb drive
| [cjl] | | | Any ideas about how to set file type associations without writing to | | the registry? | [Tim Golden] | Well, yes. Just the same as was in the article you pointed | to... or have I missed something? Ah, I see. Presumably the FTYPE / ASSOC commands write things to the registry behind the scenes. So I assume you mean: without writing anything away permanently which might then be held there in the case of a crash. Well, I don't think so. You could, I supposed have a script which reset any associations to their default which could then set up to run on startup, but I don't know how viable that is for your situation. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me use my Dual Core CPU!
Simon Wittber [EMAIL PROTECTED] writes: For game programming purposes, I was hoping someone could point me to a technique for sharing objects across Python processes, preferably without any kind of marshal/unmarshal steps. It's a long shot, I know. To be viable, I'll need to be able to pass messages between processes very quickly. For example, It would be simple to paralellize some graphics calculations over two processors with each process sharing a common read-only scene data structure; however, a marshalling step in this kind of process would be too costly. If it's for some specific calculation in the game, the bluntest approach is probably to write a C extension that releases the GIL to do the calculation, and then use ordinary threads for concurrency. Put appropriate locks in the object to synchronize on. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
On 11 Sep 2006 21:35:28 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Mike Owens wrote: On 11 Sep 2006 18:23:50 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Can you run your car on diesel fuel? Why not? Because your car's specification says to use gasoline? If your car has been designed to run on diesel, you shouldn't be saying it has gasoline engine. Duh. No but you can still call it a car with an engine, just as SQLite is a SQL database, with an SQL engine. Seperate the data from the engine and what have you got? Data with dynamic typing. Data that can't be migrated to a real SQL database because you'll get type mismatches when strings are inserted into numeric fields. The type affinity kluge won't help there, will it? Did you even read my original post? Or did you just completely miss the point? It's not the job of the System Test Engineer to design things. It's his job to find fault with everything. I just happen to be very good at finding faults with things. And apparently not very good at providing any constructive solutions. But no one appreciates my finding those faults. No one appreciates the tone in which you report these alleged faults, necessarily agrees with the faults that you find, nor elected you system test engineer of the SQLite project. It calls for other things that many databases don't implement or altogether violate as well, so what? Show me how both MS SQL's T-SQL and Oracle's PL/SQL procedure languages are so standards compliant that you can use the same procedure code in both databases. You can't -- precisely because they ignore or outright violate parts of the standard as well. What's your position on that? Do some Googling and you can easily find 18 ways that Oracle's PL/SQL deviates from the standard. And T-SQL is plainly nowhere close. And how many of those systems use dynamic typing? And how many conform to the standard? Name one where the documentation claims the SQL Language Specification is a bug. Name one that conforms to the standard. And a lot of people go to chiropractors. And chiropractors are nice intelligent people with degrees. And the therapy provided does good. Nevertheless, the theory on which it's based is quackery. To use your specious analogy, it represents another way of doing things, which you admit yourself works. That's your justification for calling Richard Hipp a crackpot? It's clear. You're just way too smart for SQLite. Did you see my solution to Rick Shepard's problem in the thread Parsing String, Dictionary Lookups, Writing to Database Table? The point being? -- you can write Python code and feel entitled to condescending and rude? -- http://mail.python.org/mailman/listinfo/python-list
Re: variable update
Fredrik Lundh wrote: km wrote: Is there any handy untility for checking if a variable is populated at runtime ? access it, and catch the NameError: try: variable except NameError: In a function when accessing a not-yet-bound local variable you may also (as Fredrik knows but didn't bother to say) see an UnboundLocalError exception, print not defined else: print defined leaving variables undefined is usually bad style, though; if you can, assign some value to it, and test for that value instead: variable = None ... lots of code that may assign to variable ... if variable is not None: print not defined regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Tim Golden [EMAIL PROTECTED] wrote: [Nick Craig-Wood] | Tim Golden [EMAIL PROTECTED] wrote: | if os.path.isfile (filepath): | print filepath | | You might get a more accurate result using | | os.access(filepath, os.X_OK) | | instead of | | os.path.isfile(filepath) | | Which checks the file is executable Sadly, not under Win32, hence the shenanigans with the PATHEXT variable :) Make a patch for os.access()? It says in the docs it works on Windows! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
From bags to default dicts
Hello all, I was curious if anyone has transitioned some code from using Raymond Hettinger's bag class: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/259174 to using 2.5's collections.defaultdict. Any pitfalls to watch out for? It seems we should be able to do slightly better than creating a bag class that has a defaultdict as a member. So, inheriting from defaultdict and defining some of the nice utility methods that Hettinger's class defines seems like the way to go. Comments? Regards, Mark -- http://mail.python.org/mailman/listinfo/python-list
Are Python's reserved words reserved in places they dont need to be?
-- python -i class = algebra File stdin, line 1 class = algebra ^ SyntaxError: invalid syntax Why isn' t the parser smart enough to see that class followed by an identifier is used for class definition but class followed by equals is a simple assignment? Also, I had a bug where I tried to set the attributes user and pass in an object but pass would not work because it is a reserved word. Again pass should be reserved in certain contexts but not others. Is Python 3k going to fix this sort of thing? -- http://mail.python.org/mailman/listinfo/python-list
RE: best way of testing a program exists before using it?
| Tim Golden [EMAIL PROTECTED] wrote: | [Nick Craig-Wood] | | | Tim Golden [EMAIL PROTECTED] wrote: | | if os.path.isfile (filepath): | | print filepath | | | | You might get a more accurate result using | | | | os.access(filepath, os.X_OK) | | | | instead of | | | | os.path.isfile(filepath) | | | | Which checks the file is executable | | Sadly, not under Win32, hence the shenanigans with | the PATHEXT variable :) [Nick Craig-Wood] | Make a patch for os.access()? It says in the docs it works on | Windows! I suspect it might end up being a doc patch. AFAICR the os-specific stuff is implemented in C; I'll try downloading the source at some point and having a look. The existing docs do say, though: Note: I/O operations may fail even when access() indicates that they would succeed, particularly for operations on network filesystems which may have permissions semantics beyond the usual POSIX permission-bit model. Don't know if this covers the case meanwhile. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need to be?
metaperl schrieb: -- python -i class = algebra File stdin, line 1 class = algebra ^ SyntaxError: invalid syntax Why isn' t the parser smart enough to see that class followed by an identifier is used for class definition but class followed by equals is a simple assignment? Also, I had a bug where I tried to set the attributes user and pass in an object but pass would not work because it is a reserved word. Again pass should be reserved in certain contexts but not others. Most parsers are written in a way that makes keywords reserved, regardless of their occurrence. That is because it is way easier to do so. And the few reserved words won't matter usually. Is Python 3k going to fix this sort of thing? Don't think so. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need to be?
metaperl [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Why isn' t the parser smart enough to see that class followed by an identifier is used for class definition but class followed by equals is a simple assignment? Because it's simpler to reserve words than worry about possible ambiguities in all past and future use cases. If you could use it as an identifier, it wouldn't be a reserved word by the normal definition of the term. -- http://mail.python.org/mailman/listinfo/python-list