Re: interactive mode in python with ctypes???
On 12月27日, 下午10�r05分, [EMAIL PROTECTED] wrote: On 12月27日, 下午4�r40分, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 26 Dec 2007 12:57:44 -0300, [EMAIL PROTECTED] escribió: libdll.dll is a third-party library. The below code segment will run well under the batch mode(ie. python test.py 11060) but when I type sequencially it doesn't work as usual. Can any give me a hand?? Define doesn't work as usual; at least describe what actually happens and what you expected to happen instead. If you get an exception, post the full traceback. run(string.atoi(sys.argv[1])) string.atoi is deprecated eons ago; use int() instead -- Gabriel Genellina doesn't work means there is no result without exception. The python interpretter still run without complains; but when running under batch mode it run as the expectation. Are there difference for python interpretter between batch mode andinteractivemode ? Thanks for Gabriel. sorry, I explain more precisely. No result means the callback function evCB will not be called as it in batch mode. For callback function, are there difference for python interpretter between batch and interactive mode ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Remove namespace declaration from ElementTree in lxml
Zero Piraeus wrote: I want to remove an unused namespace declaration from the root element of an ElementTree in lxml. There doesn't seem to be any documented way to do this, so at the moment I'm reduced to sticking the output through str.replace() ... which is somewhat inelegant. And also a bit error prone (unless you are sure the replaced string really only occurs where you want to replace it). You can try this: root = etree.parse(...).getroot() new_root = etree.Element(root.tag, root.attrib) new_root[:] = root[:] Note, however, that this will not copy root-level PIs or internal DTD subsets. But you can copy PIs and comments by hand. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
Robert Kern wrote: The problem is that for SQL databases, there is a substantial API that they can all share. The implementations are primarily differentiated by other factors like speed, in-memory or on-disk, embedded or server, the flavor of SQL, etc. and only secondarily differentiated by their extensions to the DB-API. With parallel processing, the API itself is a key differentiator between toolkits and approaches. Different problems require different APIs, not just different implementations. Well, there is one parallel processing API that already *is* part of stdlib: the threading module. So the processing module would fit just nicely into the idea of a standard library. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: how to generate html table from table data?
Ricardo Aráoz a écrit : Bruno Desthuilliers wrote: (snip) FWIW, I just wrote a function generating an html table from a list of header and a list of rows. I wrote the most QD, straightforward, braindead way, it's 17 lines long, doesn't even need an import statement, and took me less than 2 minutes to write - that is, far less work than reading your post and answering it. Hi. Bruno, could you please post those 17 lines? I'm not actually doing HTML work but I would find it interesting going through your code. I'm afraid I throw that code away - as I said, this was braindead QD code, and certainly not even worth the time you'd spend reading it. But I can rewrite it if you want: def generate_html_table(headers, rows): html = [] if headers: html.append(tr) for header in headers: html.append(th%s/th % header) html.append(/tr) if rows: for row in rows: html.append(tr) for cell in row: html.append(td%s/td % cell) html.append(/tr) if html: html = [table] + html + [/table] return \n.join(html) Nothing interesting here, as you can see. And if you're going to do anything serious in web development, you'll be better using a templating system anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: convert pdf to png
Seeing these options, I think it is much better to serve the PDFs directly, it's very simple, and very efficient on the server. If you're afraid that not everyone have PDF readers, direct them to Adobe's site or serve the installation files on the server. The installation for the reader is a one-off download, so it should only choke the server for the first several weeks. AFAIK the OP wants to render previews for display on the site - certainly a nice feature. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Happy Christmas Pythoneers
On Thu, 27 Dec 2007 22:38:44 -0800, Aahz wrote: In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED] wrote: On Wed, 26 Dec 2007 21:32:54 -0800, [EMAIL PROTECTED] wrote: Hey, my version of the person module doesn't have an is_appropriate_sex attribute, but an is_opposite_sex attribute instead. Is this a new version? Generally instances use: person.is_appropriate_sex = person.is_opposite_sex but some instances define it as: person.is_appropriate_sex = not person.is_opposite_sex It's an implementation detail, you shouldn't worry about it. Then again, some instances define it as person.is_appropriate_sex = True And sometimes it's not that simple but a property and connected with the caller's history of `champagne.drink()` calls. The `person.is_pretty` property is most definitely linked to that call history in many instances. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Python DLL in Windows Folder
As I said before, I know how futile it is to argue that Python should change it's behaviour. I'm not going to waste my time telling you what to do. If you really want to know how side-by-side installation works, you can try reading the Windows SDK documentation. I did, and determined that it's not possible. We would have to use assembly manifests, and can't, as the tool chain doesn't support them. No, simply by changing the name you've prevented backwards compatiblity with the old DLL. First, the requirement for backwards compatibility is not normative. Section 2.6 is entitled Install any shared files that are not side-by-side to the correct locations. python25.dll, as a matter of fact, *is* a shared file that is not side-by-side; the *only* location I can install in according to 2.6 is the System folder. You can't argue you're trying to maintain backwards compatibilty with an old DLL when you've already broken compatibility with it. Furthermore, it says to ensure backward compatibility with those applications, not to ensure backward compatibility with the old DLL. I'm not trying to maintain compatibility with the binaries of those applications, but with their source. Since the existing applications have to be rebuilt to use the new DLL they also can be changed to use it from a new shared location. No, they can't, because there is not enough manpower available to change them. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(s, enc).encode(enc) == s ?
On Dec 27, 7:37 pm, Martin v. Löwis [EMAIL PROTECTED] wrote: Certainly. ISO-2022 is famous for having ambiguous encodings. Try these: unicode(Hallo,iso-2022-jp) unicode(\x1b(BHallo,iso-2022-jp) unicode(\x1b(JHallo,iso-2022-jp) unicode(\x1b(BHal\x1b(Jlo,iso-2022-jp) or likewise unicode([EMAIL PROTECTED],iso-2022-jp) unicode(\x1b$BBB,iso-2022-jp) In iso-2022-jp-3, there are even more ways to encode the same string. Wow, that's not easy to see why would anyone ever want that? Is there any logic behind this? In your samples both of unicode(\x1b(BHallo,iso-2022-jp) and unicode(\x1b(JHallo,iso-2022-jp) give uHallo -- does this mean that the ignored/lost bytes in the original strings are not illegal but *represent nothing* in this encoding? I.e. in practice (in a context limited to the encoding in question) should this be considered as a data loss, or should these strings be considered equivalent? Thanks! mario -- http://mail.python.org/mailman/listinfo/python-list
comparing dictionaries to find the identical keys
hi everybody , i need to compare two dictionary's key. I have written a script gene_symbol = {} probe_id = {} result = {} def getGene(fname): fh = open(fname , 'r') for line in fh: yield line fh.close() for line in getGene(symbol_hu133): data1= line.strip().split('#') probe_give = data1[0].strip() gene_give = data1[1].strip() gene_symbol[probe_give] = gene_give #print gene_symbol.keys() for line in getGene(gds1428.csv): data = line.strip().split(',') probe_get = data[0].strip() probe_id[probe_get] = data if gene_symbol.keys() == probe_id.keys(): print gene_symbol.keys(), probe_id.values() can anybody show me the error I make here ,while comparing the keys of two dictionaries so that i print the values of the dictionaries whoes Keys are Identical -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
Scott David Daniels ha scritto: [in the .png] ... Callable types ... User-definet methods I personally prefer User-defined methods That's a typo, thank you. ... Class instances I'd try: Class instances with a __call__ method. Yes, it's more clear now. ... Classes Classes Instances This probably wants to be Class Instances Whoops, I'm sorry :) file objects are generally supposed to be built with the open function, not instantiated as shown. Since open() is just an alias for file(), changing the name should be enough, right? Also note iterating on a file gets the lines. What do you think about adding a line like this to the examples? for line in open(filename,r): pass #iterate over lines Do you know about seq[i:] and seq[::-1]? Yes I know. I'll try to add them (together with seq[:] and seq[:j]). Thank you very much indeed :) -- GreyFox -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(s, enc).encode(enc) == s ?
On Fri, 28 Dec 2007 03:00:59 -0800, mario wrote: On Dec 27, 7:37 pm, Martin v. Löwis [EMAIL PROTECTED] wrote: Certainly. ISO-2022 is famous for having ambiguous encodings. Try these: unicode(Hallo,iso-2022-jp) unicode(\x1b(BHallo,iso-2022-jp) unicode(\x1b(JHallo,iso-2022-jp) unicode(\x1b(BHal\x1b(Jlo,iso-2022-jp) or likewise unicode([EMAIL PROTECTED],iso-2022-jp) unicode(\x1b$BBB,iso-2022-jp) In iso-2022-jp-3, there are even more ways to encode the same string. Wow, that's not easy to see why would anyone ever want that? Is there any logic behind this? In your samples both of unicode(\x1b(BHallo,iso-2022-jp) and unicode(\x1b(JHallo,iso-2022-jp) give uHallo -- does this mean that the ignored/lost bytes in the original strings are not illegal but *represent nothing* in this encoding? They are not lost or ignored but escape sequences that tell how the following bytes should be interpreted '\x1b(B' switches to ASCII and '\x1b(J' to some roman encoding which is a superset of ASCII, so it doesn't matter which one you choose unless the following bytes are all ASCII. And of course you can use that escape prefix as often as you want within a string of ASCII byte values. http://en.wikipedia.org/wiki/ISO-2022-JP#ISO_2022_Character_Sets I.e. in practice (in a context limited to the encoding in question) should this be considered as a data loss, or should these strings be considered equivalent? Equivalent I would say. As Unicode they contain the same characters. Just differently encoded as bytes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
OOP: How to implement listing al 'Employees'.
I was just wondering. What if you have a 'Employees' class and you want to list all the employees. Currenlty i'm seeing to possibilities: - create a 'listAll' function inside the class which returns all the employees in a array. - create multiple instances, putting them in a array, by calling the Employees class multiple times in a loop (thus not creating a listAll function in the class). What is the better way of doing this? And should a class always reference only on 'item'? Thank in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: fiber(cooperative multi-threading)
Hi! Since your interest in fibers/coroutines is related to writing simulators, you should try the SimPy package (simpy.sf.net), which is a process-based discrete event simulator that uses generators as processes. On 22 dez, 09:10, Akihiro KAYAMA [EMAIL PROTECTED] wrote: Hi all. I found cooperative multi-threading(only one thread runs at once, explicit thread switching) is useful for writing some simulators. With it, I'm able to be free from annoying mutual exclusion, and make results deterministic. For this purpose, and inspired by Ruby(1.9) fiber, I wrote my own version of fiber in Python. It just works, but using native Python threads for non-preemptive threading is not cost-effective. Python has generator instead but it seemed to be very restricted for general scripting. I wish I could write nested (generator) functions easily at least. Is there any plan of implementing real (lightweight) fiber in Python? import threading class Fiber(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.semaphore_running = threading.Semaphore(0) self.semaphore_finish = None self.val = None self.setDaemon(True) self.start() self.start = self.start_fiber def start_fiber(self): self.semaphore_finish = threading.Semaphore(0) self.semaphore_running.release() self.semaphore_finish.acquire() def run(self): # override self.semaphore_running.acquire() self.main() if self.semaphore_finish is not None: self.semaphore_finish.release() def switchto(self, fiber, val=None): fiber.val = val fiber.semaphore_running.release() self.semaphore_running.acquire() return self.val def main(self): # should be overridden pass class F1(Fiber): def main(self): print f1 start self.switchto(f2) print f1 foo v = self.switchto(f2) print f1 v=%s world % v self.switchto(f2, OK) print f1 end class F2(Fiber): def main(self): print f2 start self.switchto(f1) print f2 bar result = self.switchto(f1, Hello, ) print f2 result=%s % result print f2 end self.switchto(f1) f1 = F1() f2 = F2() print start f1.start() print end -- kayama -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP: How to implement listing al 'Employees'.
Petar wrote: What is the better way of doing this? And should a class always reference only on 'item'? It fully depends on what you want to do in your program. If you just want to have a list of employees, a list or dict will suffice. If you need a full-fledged employee database, an Employees class may be a good API. Regards, Björn -- BOFH excuse #83: Support staff hung over, send aspirin and come back LATER. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python DLL in Windows Folder
Ross Ridge writes: As I said before, I know how futile it is to argue that Python should change it's behaviour. I'm not going to waste my time telling you what to do. If you really want to know how side-by-side installation works, you can try reading the Windows SDK documentation. [EMAIL PROTECTED] wrote: I did, and determined that it's not possible. We would have to use assembly manifests, and can't, as the tool chain doesn't support them. Your choice to use a tool chain that doesn't support side-by-side assemblies does not make it impossible. No, simply by changing the name you've prevented backwards compatiblity with the old DLL. First, the requirement for backwards compatibility is not normative. Section 2.6 is entitled Install any shared files that are not side-by-side to the correct locations. python25.dll, as a matter of fact, *is* a shared file that is not side-by-side; the *only* location I can install in according to 2.6 is the System folder. No, the only thing that the guidelines require to be installed in the system directory are services and drivers. The only exception for other kinds of applications is when necessary for backwards compatibility. You can't argue you're trying to maintain backwards compatibilty with an old DLL when you've already broken compatibility with it. Furthermore, it says to ensure backward compatibility with those applications, not to ensure backward compatibility with the old DLL. Now you're just trying play pointless semantic games. If you change the DLL's name, the DLL is no longer compatibile with those applications. Since the existing applications have to be rebuilt to use the new DLL they also can be changed to use it from a new shared location. No, they can't, because there is not enough manpower available to change them. And that's what this all really comes down to. Because neither you nor anyone else is willing to do the work necessary to do the Right Thing, you have chosen not to follow Microsoft's recommended best practices for installing Windows applications. It's not because it's impossible, it's because you're unwilling. Is that really all that hard to admit? Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] [EMAIL PROTECTED] -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing dictionaries to find the identical keys
Hi On Dec 28, 2007 4:55 PM, Beema shafreen [EMAIL PROTECTED] wrote: hi everybody , i need to compare two dictionary's key. I have written a script gene_symbol = {} probe_id = {} result = {} def getGene(fname): fh = open(fname , 'r') for line in fh: yield line fh.close() for line in getGene(symbol_hu133): data1= line.strip().split('#') probe_give = data1[0].strip() gene_give = data1[1].strip() gene_symbol[probe_give] = gene_give #print gene_symbol.keys() for line in getGene(gds1428.csv): data = line.strip().split(',') probe_get = data[0].strip() probe_id[probe_get] = data if gene_symbol.keys() == probe_id.keys(): print gene_symbol.keys(), probe_id.values() can anybody show me the error I make here ,while comparing the keys of two dictionaries so that i print the values of the dictionaries whoes Keys are Identical Remember that ur looking for commonly occuring keys between the two dictionaries. And dictionary.keys() generates a 'list' of keys in that dictionary. So, u r comparing a list with another in an if construct and printing the same which is not what u want to do. Ideally u should iterate over a list of items and check out if it is present or not in the other list and then print corresponding values. Alternately this can also be done with sets module by converting the list into a set object and do a simple intersection of the two sets, by which u get the commonly occuring items. HTH KM -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP: How to implement listing al 'Employees'.
On 28 dec, 13:40, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: Petar wrote: What is the better way of doing this? And should a class always reference only on 'item'? It fully depends on what you want to do in your program. If you just want to have a list of employees, a list or dict will suffice. If you need a full-fledged employee database, an Employees class may be a good API. Regards, Björn -- BOFH excuse #83: Support staff hung over, send aspirin and come back LATER. It's a pure hypothetical question about where to put the function for the list of employees when already having a Employee class. Do I make it a method of the class, or do i create a instance of the class for every employee (sitting inside a list)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Extracting images from a PDF file
On Dec 27, 10:13 am, writeson [EMAIL PROTECTED] wrote: On Dec 27, 1:12 am, Carl K [EMAIL PROTECTED] wrote: Doug Farrell wrote: Hi all, Does anyone know how to extract images from aPDFfile? What I'm looking to do is use pdflib_py to open largePDFfiles on our Linux servers, then use PIL to verify image data. I want to do this in order to find corrupt images in thePDFfiles. If anyone could help me out, or point me in the right direction, it would be most appreciated! If you are ok shelling out to a binary: pdfimages - Portable Document Format (PDF) image extractor (version 3.00)http://packages.ubuntu.com/gutsy/text/xpdf-utils I am trying to convert thepdfto a png, but without having to run external commands. so I will understand if you arn't happy with pdfimages. Carl K Carl, Thanks for the feedback, and I don't mind shelling out to an external command if it gets the job done. Thanks for the link to xpdf-utils, I'm going to look into it this morning. Doug Hi, Our linux servers run CentOS (4.X) I believe, and the repositories for this version doesn't have xpdf-utils available. I'm going to look into editing the sources.list file in order to get yum to install the necessary dependencies for me as xpdf-utils looks very useful! Doug -- http://mail.python.org/mailman/listinfo/python-list
Re: Python DLL in Windows Folder
Ross Ridge wrote: I did, and determined that it's not possible. We would have to use assembly manifests, and can't, as the tool chain doesn't support them. Your choice to use a tool chain that doesn't support side-by-side assemblies does not make it impossible. I'm looking forward to your contribution to solve the problem. Our new tool chain for Python 2.6 and 3.0 on Windows is VS 2008. Christian -- http://mail.python.org/mailman/listinfo/python-list
Compiler or stg. to get exe!
Hy! I have question. After short goggling, I haven't found anything good. So my question is: I wrote a program in python and i Get .py files and some .pyc in working folder. Now i want program tu run under windows, so i need to get exe files or something. And what do i need to do to make program for linux. (stg. like .deb package) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pivot Table/Groupby/Sum question
Wow, I did not realize it would be this complicated! I'm fairly new to Python and somehow I thought I could find a simpler solution. I'll have to mull over this to fully understand how it works for a bit. Thanks a lot! On Dec 28, 4:03 am, John Machin [EMAIL PROTECTED] wrote: On Dec 28, 11:48 am, John Machin [EMAIL PROTECTED] wrote: On Dec 28, 10:05 am, [EMAIL PROTECTED] wrote: If you have any ideas about how to solve this pivot table issue, which seems to be scant on Google, I'd much appreciate it. I know I can do this in Excel easily with the automated wizard, but I want to know how to do it myself and format it to my needs. Watch this space. Tested as much as you see: 8--- class SimplePivotTable(object): def __init__( self, row_order=None, col_order=None, # see example missing=0, # what to return for an empty cell. Alternatives: '', 0.0, None, 'NULL' ): self.row_order = row_order self.col_order = col_order self.missing = missing self.cell_dict = {} self.row_total = {} self.col_total = {} self.grand_total = 0 self.headings_OK = False def add_item(self, row_key, col_key, value): self.grand_total += value try: self.col_total[col_key] += value except KeyError: self.col_total[col_key] = value try: self.cell_dict[row_key][col_key] += value self.row_total[row_key] += value except KeyError: try: self.cell_dict[row_key][col_key] = value self.row_total[row_key] += value except KeyError: self.cell_dict[row_key] = {col_key: value} self.row_total[row_key] = value def _process_headings(self): if self.headings_OK: return self.row_headings = self.row_order or list(sorted(self.row_total.keys())) self.col_headings = self.col_order or list(sorted(self.col_total.keys())) self.headings_OK = True def get_col_headings(self): self._process_headings() return self.col_headings def generate_row_info(self): self._process_headings() for row_key in self.row_headings: row_dict = self.cell_dict[row_key] row_vals = [row_dict.get(col_key, self.missing) for col_key in self.col_headings] yield row_key, self.row_total[row_key], row_vals def get_col_totals(self): self._process_headings() row_dict = self.col_total row_vals = [row_dict.get(col_key, self.missing) for col_key in self.col_headings] return self.grand_total, row_vals if __name__ == __main__: data = [ ['Bob', 'Morn', 240], ['Bob', 'Aft', 300], ['Joe', 'Morn', 70], ['Joe', 'Aft', 80], ['Jil', 'Morn', 100], ['Jil', 'Aft', 150], ['Bob', 'Aft', 40], ['Bob', 'Aft',5], ['Dozy', 'Aft', 1], # Dozy doesn't show up till lunch-time ] NAME, TIME, AMOUNT = range(3) print ptab = SimplePivotTable( col_order=['Morn', 'Aft'], missing='uh-oh', ) for s in data: ptab.add_item(row_key=s[NAME], col_key=s[TIME], value=s[AMOUNT]) print ptab.get_col_headings() for x in ptab.generate_row_info(): print x print 'Tots', ptab.get_col_totals() 8--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Extracting images from a PDF file
On Dec 27, 2:17 pm, Max Erickson [EMAIL PROTECTED] wrote: Doug Farrell [EMAIL PROTECTED] wrote: Hi all, Does anyone know how to extract images from aPDFfile? What I'm looking to do is use pdflib_py to open largePDFfiles on our Linux servers, then use PIL to verify image data. I want to do this in order to find corrupt images in thePDFfiles. If anyone could help me out, or point me in the right direction, it would be most appreciated! Also, does anyone know of a way to validate aPDFfile? Thanks in advance, Doug There is some discussion here: http://nedbatchelder.com/blog/200712.html#e20071210T064608 max Max, That's a very interesting snippet of code, thanks for posting the link! Much appreciated! Doug -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing dictionaries to find the identical keys
Beema shafreen wrote: hi everybody , i need to compare two dictionary's key. I have written a script Use sets. Sets are easier to use and much faster: d1 = {'a': 1, 'b': 2, 'c': 3} d2 = {'b': 2, 'c': 3, 'd': 4} d1.keys() ['a', 'c', 'b'] d2.keys() ['c', 'b', 'd'] s1 = set(d1) s2 = set(d2) s1 set(['a', 'c', 'b']) s2 set(['c', 'b', 'd']) s1.intersection(s2) set(['c', 'b']) s1.union(s2) set(['a', 'c', 'b', 'd']) s1.difference(s2) set(['a']) Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP: How to implement listing al 'Employees'.
Bjoern Schliessmann a écrit : Petar wrote: What is the better way of doing this? And should a class always reference only on 'item'? It fully depends on what you want to do in your program. If you just want to have a list of employees, a list or dict will suffice. If you need a full-fledged employee database, an Employees class may be a good API. If you need a full-fledged employee database, a RDBMS may be a good API. And if you insist on having it the OO way, have a look at SQLAlchemy. My 2 cents... -- http://mail.python.org/mailman/listinfo/python-list
Re: Building Python statically on linux
Micah Elliott wrote: Doing that (or CFLAGS=-static, or LDFLAGS=-static, or other Makefile tweaks) gets me linker errors. Sounds like there's not a simple prescribed means to do this (that anyone has documented). So now I'm open to hearing about other hacks people have done to get this to work. (Hopefully a config weenie heard my plea for --enable-all- static) Can you work on the topic and write a small howto for your wiki (http://wiki.python.org/moin/)? You have to modify Modules/Setup.local, too. Read Modules/Setup for more information. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
Stefan Behnel wrote: Well, there is one parallel processing API that already *is* part of stdlib: the threading module. So the processing module would fit just nicely into the idea of a standard library. Don't you forget the select module and its siblings for I/O bound concurrency? Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler or stg. to get exe!
SMALLp wrote: Hy! I have question. After short goggling, I haven't found anything good. So my question is: I wrote a program in python and i Get .py files and some .pyc in working folder. Now i want program tu run under windows, so i need to get exe files or something. And what do i need to do to make program for linux. (stg. like .deb package) py2exe can bundle your files, the Python dll and all its dependencies into a distributable executable. It does *not* convert the Python code into an exe. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
On Dec 28, 12:40 pm, Riccardo T. [EMAIL PROTECTED] wrote: file objects are generally supposed to be built with the open function, not instantiated as shown. Since open() is just an alias for file(), changing the name should be enough, right? It depends on the Python version: Python 2.4.4 (#2, Oct 4 2007, 22:02:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type help, copyright, credits or license for more information. file is open True Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type help, copyright, credits or license for more information. file is open False Nowadays file is no more an alias for open. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler or stg. to get exe!
SMALLp schrieb I have question. After short goggling, I haven't found anything good. So my question is: I wrote a program in python and i Get .py files and some .pyc in working folder. Now i want program tu run under windows, so i need to get exe files or something. If python is installed on the target machine (Windows or Linux or ...) you do not need an exe, just copy the py file. And what do i need to do to make program for linux. (stg. like .deb package) a .deb package is more than a program. You'll have to look at the .deb developer documentation. Again, for simple programs, just copying the .py file is sufficient, provided that Python (and all the modules your .py needs) is installed. HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
documentation
Which website would you recommend for a great documentation about Python? I am looking for a list of methods and properties of all the Python elements with syntax examples. -- http://mail.python.org/mailman/listinfo/python-list
Re: Impure Python modules
James, In Python extension parlance, it means that the extension was not written completely in Python. Example include the mySQL module, wxPython, and one of the openGL modules. All of those have some C/C++ dependencies. I think numpy does too, now that I think about it. Anyway, I hope that answers your question. Mike On Dec 27, 2007 4:47 PM, James Matthews [EMAIL PROTECTED] wrote: I don't quite understand what the word impure means here! On Dec 27, 2007 10:53 PM, [EMAIL PROTECTED] wrote: Hi, Is there some way to get a list of impure Python modules/extensions from PyPI? I know the mySQL module is a good example, but I am working on creating some decent instructions on how to create Windows installers from impure modules and am having a hard time finding them. Thanks! Mike -- http://mail.python.org/mailman/listinfo/python-list -- http://search.goldwatches.com/?Search=Movado+Watches http://www.jewelerslounge.com http://www.goldwatches.com -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
Christian Heimes wrote: Stefan Behnel wrote: Well, there is one parallel processing API that already *is* part of stdlib: the threading module. So the processing module would fit just nicely into the idea of a standard library. Don't you forget the select module and its siblings for I/O bound concurrency? Hmm, when I think of parallel processing, it's usually about processing, not about I/O. If it starts getting I/O bound, it's rather worth considering single-threaded processing instead. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Impure Python modules
On Dec 27, 5:38 pm, Martin v. Löwis [EMAIL PROTECTED] wrote: Is there some way to get a list of impure Python modules/extensions from PyPI? Not easily. To create a full list, you will have to download all packages, and check their respective setup.py files for occurrences of Extension. I figured as much. I thought about writing some kind of script based on the way Easy Setup downloads modules and just doing that, but there's upwards of 2000 extensions on there. A subset can probably be found by looking at all packages classified as Programming Language :: C http://pypi.python.org/pypi?:action=browsec=181 or Programming Language :: C++ http://pypi.python.org/pypi?:action=browseshow=allc=183 Of course, some of those may only generate C, or deal with C in some other sense than being written in it. HTH, Martin Thanks, Martin. Those links will be helpful. I'll start looking at them this weekend. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: list in a tuple
On Dec 28, 1:34 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 27 Dec 2007 16:38:07 -0300, [EMAIL PROTECTED] escribió: On Dec 27, 8:20 pm, Wildemar Wildenburger [EMAIL PROTECTED] wrote: From that post: Ok, I do admit that doing a = ([1], 2) a[0].append(2) also doesn't throw an error, but this only confuses me more. Why? You mutate thelist, but thetupledoes not change. It is still atupleof alistand an int. At least that's how I think about it, and I seem to recall reading that beavior justified like this (don't ask me where though (might have been Dive Into Python, but maybe not)). That part is ok, I mean it doesn't confuse me I just wanted to say that this is somewhat confusing behavior. I agree that its not best put... But I was thinking about the last part of the post, the part that talks about trying to print a tuple and getting an error. Instead of trying to explain it myself, I'll refer you to this little essay [1] by Michael Hudson including some nice ASCII art, and a long reply from Alex Martelli from which I'll quote just a few memorable paragraphs. (Just replace dictionary with tuple in your example) There is [...] a huge difference between changing an object, and changing (mutating) some OTHER object to which the first refers. In Bologna over 100 years ago we had a statue of a local hero depicted pointing forwards with his finger -- presumably to the future, but given where exactly it was placed, the locals soon identified it as the statue that points to Hotel Belfiore. The one day some enterprising developer bought the hotel's building and restructured it -- in particular, where the hotel used to be was now a restaurant, Da Carlo. So, the statue that points to Hotel Belfiore had suddenly become the statue that points to Da Carlo...! Amazing isn't it? Considering that marble isn't very fluid and the statue had not been moved or disturbed in any way...? This is a real anecdote, by the way (except that I'm not sure of the names of the hotel and restaurant involved -- I could be wrong on those), but I think it can still help here. The dictionary, or statue, has not changed at all, even though the objects it refers/points to may have been mutated beyond recognition, and the name people know it by (the dictionary's string-representation) may therefore change. That name or representation was and is referring to a non-intrinsic, non-persistent, happenstance characteristic of the statue, or dictionary... [1]http://python.net/crew/mwh/hacks/objectthink.html -- Gabriel Genellina Thank you very much for this discussion and reference [1] and other pointers in [1]. This has definitely helped my understanding of such matters. -- http://mail.python.org/mailman/listinfo/python-list
Re: documentation
cf29 wrote: Which website would you recommend for a great documentation about Python? I am looking for a list of methods and properties of all the Python elements with syntax examples. Any problem with the main source, URL:http://docs.python.org/? /W -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
Riccardo T. wrote: I wrote a little cheat sheet for this wonderful language, but because of my still little experience with it, I would like to have a feedback Could you have a look at it and tell me what do you think about, please? http://greyfox.imente.org/index.php?id=73 -- GreyFox On the svg version, as viewed on firefox, the sections Simple statements, Definations and Comments; there appears to be a problem with text wrapping. -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
On Dec 27, 2007 4:13 PM, Robert Kern [EMAIL PROTECTED] wrote: Emin.shopper Martinian.shopper wrote: If not, is there any hope of something like the db-api for coarse grained parallelism (i.e, a common API that different toolkits can support)? The problem is that for SQL databases, there is a substantial API that they can all share. The implementations are primarily differentiated by other factors like speed, in-memory or on-disk, embedded or server, the flavor of SQL, etc. and only secondarily differentiated by their extensions to the DB-API. With parallel processing, the API itself is a key differentiator between toolkits and approaches. Different problems require different APIs, not just different implementations. I disagree. Most of the implementations of coarse-grained parallelism I have seen and used share many features. For example, they generally have a notion of spawning processes/tasks, scheduling/load-balancing, checking tasks on a server, sending messages to/from tasks, detecting when tasks finish or die, logging the results for debugging purposes, etc. Sure they all do these things in slightly different ways, but for coarse-grained parallelism the API difference rarely matter (although the implementation differences can matter). I suspect that one of the smaller implementations like processing.py might get adopted into the standard library if the author decides to push for it. That would be great. My recommendation to you is to pick one of the smaller implementations that solves the problems in front of you. Read and understand that module so you could maintain it yourself if you had to. Post to this list about how you use it. Blog about it if you blog. Write some Python Cookbook recipes to show how you solve problems with it. That is a good suggestion, but for most of the coarse grained parallelism tasks I've worked on it would be easier to roll my own system than do that. To put it another way, why spend the effort to use a particular API if I don't know its going to be around for a while? Since a lot of the value is in the API as opposed to the implementation, unless there is something special about the API (e.g., it is an official or at least de factor standard) the learning curve may not be worth it. If there is a lively community around it, that will help it get into the standard library. Things get into the standard library *because* they are supported, not the other way around. You make a good point and in general I would agree with you. Isn't it possible, however, that there are cases where inclusion in the standard library would build a better community? I think this is the argument for many types of standards. A good example is wireless networking. The development of a standard like 802.11 provided hardware manufacturers the incentive to build devices that could communicate with each other and that made people want to buy the products. Still, I take your basic point to heart: if I want a good API, I should get off my but and contribute to it somehow. How would you or the rest of the community react to a proposal for a generic parallelism API? I suspect the response would be show us an implementation of the code. I could whip up an implementation or adapt one of the existing systems, but then I worry that the discussion would devolve into an argument about the pros and cons of the particular implementation instead of the API. Even worse, it might devolve into an argument of the value of fine-grained vs. coarse-grained parallelism or the GIL. Considering that these issues seem to have been discussed quite a bit already and there are already multiple parallel processing implementations, it seems like the way forward lies in either a blessing of a particular package that already exists or adoption of an API instead of a particular implementation. Thanks for your thoughts, -Emin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python DLL in Windows Folder
Ross Ridge wrote: Your choice to use a tool chain that doesn't support side-by-side assemblies does not make it impossible. Christian Heimes [EMAIL PROTECTED] wrote: I'm looking forward to your contribution to solve the problem. I find that highly unlikely. Regardless, as I said twice before I'm not interested in changing Python's behaviour. I don't have a problem with the fact that Python isn't following Microsoft's guidelines. My problem is only with the false claim that it is following them. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] [EMAIL PROTECTED] -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Choosing a new language
Hi. First let me start by saying, please don't let this become a flame-thing. Second, I need some advice. I am a 35 year old programmer, who program in C/C++, PHP and Bourne Shell almost daily. I am currently going to start focusing on becoming more skilled at a few key languages, rather than knowing many (which I do on a more superficial level). My key languages are C, PHP and SH (Bourne Shell), and I have stopped using C++ because I find that its a C-hack rather than a good design choice. I have made the following decision: To study Ada and use it instead of C++. I come from a Pascal background and I love the Ada syntax and wide area of usage. I am also attracted to Ada because of its usage in the industry. Now I have three more languages that I am very attracted to, but I prefer to focus on just one of them: Python, Haskell and Lisp. I have been doing some reading and some coding, and I am mainly attracted towards Lisp because of its ability to fix a running program. But I find that Haskell is a more powerful language. Yet again Python has a huge user base and many libraries, and it is implemented everywhere, where Haskell and Lisp on the other hand hasn't. I like the syntax of all three, and I have gotten beyond the confusion stage of Lisp parentheses, so they don't bother me at all. I need advice from people who have been coding in all three, and who can share some views and experiences. Please, if you don't know ALL three by deep experience, don't respond to this thread! Thanks and best regards! Rico. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python DLL in Windows Folder
On Dec 28, 2007 6:41 AM, Ross Ridge [EMAIL PROTECTED] wrote: Ross Ridge writes: As I said before, I know how futile it is to argue that Python should change it's behaviour. I'm not going to waste my time telling you what to do. If you really want to know how side-by-side installation works, you can try reading the Windows SDK documentation. [EMAIL PROTECTED] wrote: I did, and determined that it's not possible. We would have to use assembly manifests, and can't, as the tool chain doesn't support them. Your choice to use a tool chain that doesn't support side-by-side assemblies does not make it impossible. It's worth pointing out that when the choice was made,Windows didn't support SxS at all and there was no toolchain for it. No, simply by changing the name you've prevented backwards compatiblity with the old DLL. First, the requirement for backwards compatibility is not normative. Section 2.6 is entitled Install any shared files that are not side-by-side to the correct locations. python25.dll, as a matter of fact, *is* a shared file that is not side-by-side; the *only* location I can install in according to 2.6 is the System folder. No, the only thing that the guidelines require to be installed in the system directory are services and drivers. The only exception for other kinds of applications is when necessary for backwards compatibility. You're not reading the document correctly. The backwards compatability is supporting non SxS libraries. You can't argue you're trying to maintain backwards compatibilty with an old DLL when you've already broken compatibility with it. Furthermore, it says to ensure backward compatibility with those applications, not to ensure backward compatibility with the old DLL. Now you're just trying play pointless semantic games. If you change the DLL's name, the DLL is no longer compatibile with those applications. Python 2.5 already exists and has shipped. Since the existing applications have to be rebuilt to use the new DLL they also can be changed to use it from a new shared location. No, they can't, because there is not enough manpower available to change them. And that's what this all really comes down to. Because neither you nor anyone else is willing to do the work necessary to do the Right Thing, you have chosen not to follow Microsoft's recommended best practices for installing Windows applications. It's not because it's impossible, it's because you're unwilling. You're persisting in calling Python an application, which it clearly isn't. How relevant these guidelines are at all, since they're targeted toward end-user boxed software and not toward developers of third party libraries, is questionable, but lets see what it says. Section 2.6 *clearly* states that non side by side dlls (which Python is) can (and, in fact *must*) be placed in the System directory. Note that making your libraries SxS is *not* a requirement. So if we're going to follow this (questionable) document at all, Python is absolutely compliant. -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
c james ha scritto: On the svg version, as viewed on firefox, the sections Simple statements, Definations and Comments; there appears to be a problem with text wrapping. I see, it has already been signaled by mail. I'm not sure about how to fix that, I'll have to ask someone who knows Inkscape. Thanks. I'm working at the next release now, it should be available quite soon. -- GreyFox -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
I think we are a ways off from the point where any of the solutions are well used, matured, and trusted to promote as a Python standard module. I'd love to see it happen, but even worse than it never happening is it happening too soon. On Dec 27, 2007 8:52 AM, Emin.shopper Martinian.shopper [EMAIL PROTECTED] wrote: Dear Experts, Is there any hope of a parallel processing toolkit being incorporated into the python standard library? I've seen a wide variety of toolkits each with various features and limitations. Unfortunately, each has its own API. For coarse-grained parallelism, I suspect I'd be pretty happy with many of the existing toolkits, but if I'm going to pick one API to learn and program to, I'd rather pick one that I'm confident is going to be supported for a while. So is there any hope of adoption of a parallel processing system into the python standard library? If not, is there any hope of something like the db-api for coarse grained parallelism (i.e, a common API that different toolkits can support)? Thanks, -Emin -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Multiple keys?
while repeat: for event in pygame.event.get(): if event.type == (QUIT): pygame.quit() if (event.type == KEYDOWN): if (event.key == K_ESCAPE): pygame.quit() if (event.key == K_UP): Refresh() when I make an event with keys I use that model above. I have no idea how to do multiple keys at a time. I would like to make it so if i hold down and left the character moves down in left. Does anyone have any idea how to do that? Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs-- http://mail.python.org/mailman/listinfo/python-list
Re: Building Python statically on linux
On Dec 28, 5:44 am, Christian Heimes [EMAIL PROTECTED] wrote: Can you work on the topic and write a small howto for your wiki (http://wiki.python.org/moin/)? Good idea. I've created a placeholder (with what I know so far, not much) to track this: http://wiki.python.org/moin/BuildStatically I'll plan to be updating it today if I can get it working. Anyone else is welcome to add their knowledge/experience. -- http://mail.python.org/mailman/listinfo/python-list
Re: Choosing a new language
I don't know all three languages, but I know you won't get a useful answer unless you say what purpose you want to learn any of these languages for. To expand your mental scope? To improve your CV? To use as a new workhorse for your daily work? If it's the latter: what kind of work do you do? Regards, Jo -- http://mail.python.org/mailman/listinfo/python-list
i18n questions
Hi, A soon-to-be happy new year to everyone! I'm 100% new to this i18n lark and my approach so far has been to create a .mo file per module in my app. My thinking was, why load one huge .mo file when a single module only needs a few strings? Since then, it seems, I have made the wrong decision. For example I have module A that imports module B. Each one does this: gettext.install( domain, localedir, unicode = True ) lang = gettext.translation(domain, localedir, languages = [ loc ] ) lang.install(unicode = True ) (where doman is the name of the module, so A and B) The problem is that domain A loads and then import B happens and so the lang reference (I think) gets replaced by domain B -- the result is that module A can only translate strings that are in domain B. How does one 'merge' gettext.translations objects together? Or is that insane? What's the best way to handle a project with multiple domain.mo files? I hope someone can give me some advice. \d -- http://mail.python.org/mailman/listinfo/python-list
distutils: troubles with install
Hello! I've written a small app, succesfully packaged it and trying to install. I'm getting following error: # python setup.py install -n running install running build running build_py running build_scripts running install_lib creating /usr/lib/python2.4/site-packages/logmanager creating /usr/lib/python2.4/site-packages/logmanager/core copying build/lib/logmanager/core/logfile.py - /usr/lib/python2.4/site-packages/logmanager/core copying build/lib/logmanager/core/logfiles.py - /usr/lib/python2.4/site-packages/logmanager/core copying build/lib/logmanager/core/config.py - /usr/lib/python2.4/site-packages/logmanager/core copying build/lib/logmanager/core/fs.py - /usr/lib/python2.4/site-packages/logmanager/core copying build/lib/logmanager/core/__init__.py - /usr/lib/python2.4/site-packages/logmanager/core copying build/lib/logmanager/__init__.py - /usr/lib/python2.4/site-packages/logmanager byte-compiling /usr/lib/python2.4/site-packages/logmanager/core/logfile.py to logfile.pyc byte-compiling /usr/lib/python2.4/site-packages/logmanager/core/logfiles.py to logfiles.pyc byte-compiling /usr/lib/python2.4/site-packages/logmanager/core/config.py to config.pyc byte-compiling /usr/lib/python2.4/site-packages/logmanager/core/fs.py to fs.pyc byte-compiling /usr/lib/python2.4/site-packages/logmanager/core/__init__.py to __init__.pyc byte-compiling /usr/lib/python2.4/site-packages/logmanager/__init__.py to __init__.pyc running install_scripts copying build/scripts-2.4/logmanager.py - /usr/bin changing mode of /usr/bin/logmanager.py to 755 running install_data error: can't copy 'f': doesn't exist or not a regular file What the 'f'??? Here is my setup.py: #!/usr/bin/env python bla-bla-bla from distutils.core import setup setup(name='logmanager', version='0.1.0', description='Log Management tool', author='Vladimir Rusinov', author_email='[EMAIL PROTECTED]', url='http://greenmice.info/', packages=[ 'logmanager', 'logmanager.core' ], scripts=['logmanager.py'], data_files=[ ('/etc/', 'files/etc/logmanager.conf'), ('/etc/logmanager.d/', 'files/etc/logmanager.d/portage.py') ], long_description= bla-bla-bla , classifiers=[ 'many' ] ) File structure: $ ls -R .: AUTHORS CHANGELOG dist files LICENSE logmanager logmanager.e3p logmanager.e3t logmanager.py make_distribution.sh MANIFEST MANIFEST.in setup.py ./dist: logmanager-0.1.0.tar.bz2 ./files: etc ./files/etc: logmanager.conf logmanager.d ./files/etc/logmanager.d: portage.py ./logmanager: core __init__.py __init__.pyc ./logmanager/core: config.py config.pyc fs.py fs.pyc __init__.py __init__.pyc logfile.py logfile.pyc logfiles.py logfiles.pyc $ tar tf dist/logmanager-0.1.0.tar.bz2 logmanager-0.1.0/ logmanager-0.1.0/PKG-INFO logmanager-0.1.0/logmanager/ logmanager-0.1.0/logmanager/core/ logmanager-0.1.0/logmanager/core/logfile.py logmanager-0.1.0/logmanager/core/logfiles.py logmanager-0.1.0/logmanager/core/config.py logmanager-0.1.0/logmanager/core/fs.py logmanager-0.1.0/logmanager/core/__init__.py logmanager-0.1.0/logmanager/__init__.py logmanager-0.1.0/files/ logmanager-0.1.0/files/etc/ logmanager-0.1.0/files/etc/logmanager.conf logmanager-0.1.0/files/etc/logmanager.d/ logmanager-0.1.0/files/etc/logmanager.d/portage.py logmanager-0.1.0/LICENSE logmanager-0.1.0/setup.py logmanager-0.1.0/AUTHORS logmanager-0.1.0/CHANGELOG logmanager-0.1.0/logmanager.py Please, help. -- Vladimir Rusinov GreenMice Solutions: IT-решения на базе Linux http://greenmice.info/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler or stg. to get exe!
SMALLp a écrit : Hy! I have question. After short goggling, I haven't found anything good. So my question is: I wrote a program in python and i Get .py files and some .pyc in working folder. Now i want program tu run under windows, so i need to get exe files or something. Strictly speaking, you don't *need* this. Now depending on the target audience of your app, you may want to provide a black-box bundle of your app and all the dependencies, including the python runtime. AFAICT (not being a Window user), py2exe might be what you're looking for. And what do i need to do to make program for linux. (stg. like .deb package) A debian package (or any other similar stuff) is not a program, it's distribution system format. You'll find relevant doc on the related distribution system. Note that almost each linux distro has it's own system... Anyway, since part of your audience may include power users, don't forget to also provide either a simpler distrib using either distutils and/or setuptools (Python Egg): http://docs.python.org/dist/dist.html http://peak.telecommunity.com/DevCenter/setuptools http://peak.telecommunity.com/DevCenter/PythonEggs HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: convert pdf to png
Diez B. Roggisch wrote: Seeing these options, I think it is much better to serve the PDFs directly, it's very simple, and very efficient on the server. If you're afraid that not everyone have PDF readers, direct them to Adobe's site or serve the installation files on the server. The installation for the reader is a one-off download, so it should only choke the server for the first several weeks. AFAIK the OP wants to render previews for display on the site - certainly a nice feature. Exactly. As far as pre-processing goes: the pdf is generated from data the user just entered into a web page. it may not even be saved to the DB yet. the new ImageMagick bindings should do what I need: http://www.procoders.net/?p=39 Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP: How to implement listing al 'Employees'.
Petar a écrit : On 28 dec, 13:40, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: Petar wrote: What is the better way of doing this? And should a class always reference only on 'item'? It fully depends on what you want to do in your program. If you just want to have a list of employees, a list or dict will suffice. If you need a full-fledged employee database, an Employees class may be a good API. (snip) It's a pure hypothetical question about where to put the function for the list of employees when already having a Employee class. The problem with pure hypothetical questions is that they usually have no single good answer, and sometimes even no answer at all. Now since you're talking database, the most common patterns seems to have either some YourDomainClassNameHere methods to query instances, or some module/singleton object providing such querying interfaces for the whole app (or FWIW to provide both, the first calling on the second...). Do I make it a method of the class, or do i create a instance of the class for every employee (sitting inside a list)? If you have an Employee class, I don't get how you would avoid creating an instance for each and every, well, instance ? Unless you're thinking about something like MS recordsets ? But then, you don't need any domain class at all... -- http://mail.python.org/mailman/listinfo/python-list
Re: OOP: How to implement listing al 'Employees'.
Petar a écrit : (snip) should a class always reference only on 'item'? ??? I'm afraid I didn't get this part of the question. -- http://mail.python.org/mailman/listinfo/python-list
os.system question
Hi All, I am porting Perl script to Python script. Everything works fines until calling os.system(). In my script, a number of DOS-commands will be executed. for new_folder, old_folder in folder_array: os.system('MD ' + new_folder + ''); os.system('XCOPY ' + old_folder + ' ' + new_folder + ''); In Perl, all outputs will be printed in console directly. But in Python, outputs will be printed in separated cmd-windows. Is it possible to prevent so many cmd-windows to be opened and let all output be printed direct in Python shell? best regards ^^) -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/python-list
Re: fiber(cooperative multi-threading)
Bjoern Schliessmann wrote: Michael Sparks wrote: All that said, my personal primary aim for kamaelia is to try and make it into a general toolkit for making concurrency easy natural (as well as efficient) to work with. If full blown coroutines turn out to be part of that c'est le vie :-) I must admit I mostly didn't follow this thread, but it sparked my interest in Kamaelia. I already did the MiniAxon tutorial and I plan to try out Kamaelia with a project I had discussed here a while ago (which I had to suspend until recently because of not enough spare time; it's about simulating complex relais circuits). Please continue the great work. Many thanks for your kind words - the work is continuing :-) Also, I'd be interested in hearing how your project gets on - it sounds like the sort of thing that Kamaelia should be able to help with. (If it doesn't/can't, then it's a bug IMO :) Regards merry christmas everyone, Björn P.S.: In the MiniAxon tutorial, I noticed a formatting problem and a bunch of typos on one page but the feedback link doesn't work; are you interested in a list? I'm always interested in feedback! The fact the feedback link doesn't work for you is particularly useful - I'll look into that! Best Regards, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
Riccardo T. wrote: Scott David Daniels ha scritto: [in the .png] ... Callable types ... User-definet methods I personally prefer User-defined methods That's a typo, thank you. Hope I didn't offend (I was simply trying to be cute). Some from a bit further along. I know I didn't say so explicitly, but I don't spend much effort in pointing out errors in useless things. --- lambda is an expression, not a statement. Might include callable-invocation in operators? divmod, pow, int, long, float are in __builtin__, not math. Note pow(base, exponent[, modulus] is good for crypto stuff. Useful modules to read actually should include __builtin__, os, and os.path -- maybe include os.walk and os.path.join. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils: troubles with install
Vladimir Rusinov wrote: Hello! I've written a small app, succesfully packaged it and trying to install. I'm getting following error: # python setup.py install -n running install_data error: can't copy 'f': doesn't exist or not a regular file What the 'f'??? data_files=[ ('/etc/', 'files/etc/logmanager.conf'), ('/etc/logmanager.d/', 'files/etc/logmanager.d/portage.py') ], These need to be lists. data_files = [ ('/etc/', ['files/etc/logmanager.conf']), ('/etc/logmanager.d/', ['files/etc/logmanager.d/portage.py']), ], Since distutils is expecting a sequence, it tries to iterate over the string yielding individual characters, like 'f'. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
On Dec 28, 12:57 pm, stanleyxu [EMAIL PROTECTED] wrote: To note this problem occurs when debugging script in IDLE editor. When I double click on my_script.py, all outputs will be printed in one console. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ Why are you using os.system for these commands in the first place? You should be using the os and shutil modules instead as they would be more cross-platform friendly. Something like this: # untested for new_folder, old_folder in folder_array: os.mkdir(new_folder) shutil.copytree(old_folder, new_folder) Adjust the path as needed in the mkdir call. See shutil's docs for more info: http://docs.python.org/lib/module-shutil.html And here's some folder manipulation docs: http://effbot.org/librarybook/os.htm By the by, the subprocess module is supposed to be used in place of the os.system and os.popen* calls: http://docs.python.org/lib/module-subprocess.html Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
To note this problem occurs when debugging script in IDLE editor. When I double click on my_script.py, all outputs will be printed in one console. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
[EMAIL PROTECTED] wrote: On Dec 28, 12:57 pm, stanleyxu [EMAIL PROTECTED] wrote: To note this problem occurs when debugging script in IDLE editor. When I double click on my_script.py, all outputs will be printed in one console. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ Why are you using os.system for these commands in the first place? You should be using the os and shutil modules instead as they would be more cross-platform friendly. Something like this: # untested for new_folder, old_folder in folder_array: os.mkdir(new_folder) shutil.copytree(old_folder, new_folder) Adjust the path as needed in the mkdir call. See shutil's docs for more info: http://docs.python.org/lib/module-shutil.html And here's some folder manipulation docs: http://effbot.org/librarybook/os.htm By the by, the subprocess module is supposed to be used in place of the os.system and os.popen* calls: http://docs.python.org/lib/module-subprocess.html Mike Thanks Mike, you have provided another option. But my question has not been answered yet. The reason, why I use os.system(), is that I want to avoid accident file deletion by writing a script. My real script looks like: # 1. Funtion to execute a command in DOS-console def execCommand(cmd): if DEBUG_MODE: print 'DOS ' + cmd; else: os.system(cmd); # 2.1 Creates temp folder. Removes it first, if it exists. if os.path.exists(tmp_folder): execCommand('RD ' + tmp_folder + ' /S /Q'); execCommand('MD ' + tmp_folder + ''); # 2.2 Copies all files to the temp folder, that are going to be put in package. for source_folder, dest_folder in folders_array: if not os.path.exists(dest_folder): execCommand('MD ' + dest_folder + ''); execCommand('XCOPY \' + source_folder + ' ' + dest_folder + ' /Y'); The benefit is that, when I set DEBUG_MODE=True, I can see what will be executed. So that I can make sure that my script will not delete any other important files by accident. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/python-list
Re: fiber(cooperative multi-threading)
Duncan Booth wrote: There are also problems where full blown coroutines are appropriate. The example I quoted earlier of turning a parser from one which generates a lot of callbacks to one which 'yields' tokens is the usual example given. For completeness, I looked at the other half of the thread at the expat parser, and decided to write that in the style we use for Kamaelia - it ends up looking like this: import xml.parsers.expat import Axon from Kamaelia.Chassis.Pipeline import Pipeline from Kamaelia.Util.Console import ConsoleEchoer class Parser(Axon.ThreadedComponent.threadedcomponent): data = h1 Default /h1 # Can be overridden by kwargs as normal def start_element(self, name, attrs): self.send((START, name, attrs), outbox) def end_element(self, name): self.send((END, name), outbox) def char_data(self, data): data = data.strip() self.send((DATA, data), outbox) def main(self): p = xml.parsers.expat.ParserCreate() p.StartElementHandler = self.start_element p.EndElementHandler = self.end_element p.CharacterDataHandler = self.char_data p.Parse(self.data, 1) self.send(Axon.Ipc.producerFinished(), signal) Pipeline( Parser(data=bodyh1Hello/h1 world pWoo/p/body), ConsoleEchoer(), ).run() You'll note we don't use generators for Parser in this context. This also isn't 100% identical to form you use since we don't turn this into an iterator (obviously :). We do also use 1 more thread than the greenlet approach though. Pipeline ConsoleEchoer are generator based though, as is the scheduler that runs them :-) Have fun :-) Michael. -- http://yeoldeclue.com/blog http://kamaelia.sourceforge.net/Developers/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Remove namespace declaration from ElementTree in lxml
: I want to remove an unused namespace declaration from the root element of an ElementTree in lxml. [...] I'm reduced to sticking the output through str.replace() ... which is somewhat inelegant. And also a bit error prone (unless you are sure the replaced string really only occurs where you want to replace it). Nada es seguro ... but it does seem unlikely that ' xmlns:someprefix=urn:foo:bar' will appear in the content. Not impossible though, I suppose. If I want to try and make sure I only catch it as an element's attribute, that leads me to a regex, which seems an even less clever idea. You can try this: root = etree.parse(...).getroot() new_root = etree.Element(root.tag, root.attrib) new_root[:] = root[:] Note, however, that this will not copy root-level PIs or internal DTD subsets. But you can copy PIs and comments by hand. Thanks. I considered copying the tree, but didn't bother trying it as I would expect it to be fairly expensive. Maybe no more expensive than a regex though. I'll take a look ... -[]z. -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
Scott David Daniels ha scritto: Riccardo T. wrote: Scott David Daniels ha scritto: [in the .png] ... Callable types ... User-definet methods I personally prefer User-defined methods That's a typo, thank you. Hope I didn't offend (I was simply trying to be cute). Some from a bit further along. I know I didn't say so explicitly, but I don't spend much effort in pointing out errors in useless things. No, you did't :) --- lambda is an expression, not a statement. I'll remove that from the expression list. Might include callable-invocation in operators? divmod, pow, int, long, float are in __builtin__, not math. Yes I know, it has already been signaled by mail. They will be removed in the next version, except pow (the version with two arguments that is in my list belongs to math, while pow(b,e,m) is from __builtin__). Note pow(base, exponent[, modulus] is good for crypto stuff. Useful modules to read actually should include __builtin__, os, and os.path -- maybe include os.walk and os.path.join. Maybe I'll add __builtin__ and os in place of the type hierarchy, but I'm not sure about that. However, not in the next release. What do you think about? -- GreyFox -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
On Dec 28, 1:52 pm, stanleyxu [EMAIL PROTECTED] wrote: Hi All, I am porting Perl script to Python script. Everything works fines until calling os.system(). In my script, a number of DOS-commands will be executed. for new_folder, old_folder in folder_array: os.system('MD ' + new_folder + ''); os.system('XCOPY ' + old_folder + ' ' + new_folder + ''); In Perl, all outputs will be printed in console directly. But in Python, outputs will be printed in separated cmd-windows. Is it possible to prevent so many cmd-windows to be opened and let all output be printed direct in Python shell? Consider using the subprocess module instead. It has more options available than os.system, including I/O redirection, which seems to be what you need. In IDLE, you'll have to capture the output of the programs and print it yourself, since you can't (AFAIK) run a DOS shell in an IDLE window. Untested: import subprocess output = subprocess.Popen('MD ' + new_folder + '', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] print output Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding tempfile.TemporaryFile
On Dec 27, 7:36 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Thu, 27 Dec 2007 21:17:01 -0600, Shane Geiger wrote: import tempfile tmp = tempfile.mktemp() import os os.remove(tmp) Not only does that not answer the Original Poster's question, but I don't think it does what you seem to think it does. tmp = tempfile.mktemp() tmp '/tmp/tmpZkS0Gj' type(tmp) type 'str' import os os.remove(tmp) Traceback (most recent call last): File stdin, line 1, in module OSError: [Errno 2] No such file or directory: '/tmp/tmpZkS0Gj' You might like to read help(tempfile.mktemp). (By the way... the whole point of using tempfile is to avoid needing to delete the file by hand afterwards.) FWIW tempfile.mkstemp needs explicit user deletion. And tempfile.mkstemp is recommended over tempfile.mktemp due to security reasons. Help on function mkstemp in module tempfile: mkstemp(suffix='', prefix='tmp', dir=None, text=False) mkstemp([suffix, [prefix, [dir, [text) User-callable function to create and return a unique temporary file. The return value is a pair (fd, name) where fd is the file descriptor returned by os.open, and name is the filename. If 'suffix' is specified, the file name will end with that suffix, otherwise there will be no suffix. If 'prefix' is specified, the file name will begin with that prefix, otherwise a default prefix is used. If 'dir' is specified, the file will be created in that directory, otherwise a default directory is used. If 'text' is specified and true, the file is opened in text mode. Else (the default) the file is opened in binary mode. On some operating systems, this makes no difference. The file is readable and writable only by the creating user ID. If the operating system uses permission bits to indicate whether a file is executable, the file is executable by no one. The file descriptor is not inherited by children of this process. Caller is responsible for deleting the file when done with it. --- Karthik -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Choosing a new language
Rico Secada wrote: Hi. First let me start by saying, please don't let this become a flame-thing. Second, I need some advice. I am a 35 year old programmer, who program in C/C++, PHP and Bourne Shell almost daily. I am currently going to start focusing on becoming more skilled at a few key languages, rather than knowing many (which I do on a more superficial level). My key languages are C, PHP and SH (Bourne Shell), and I have stopped using C++ because I find that its a C-hack rather than a good design choice. I have made the following decision: To study Ada and use it instead of C++. I come from a Pascal background and I love the Ada syntax and wide area of usage. I am also attracted to Ada because of its usage in the industry. Now I have three more languages that I am very attracted to, but I prefer to focus on just one of them: Python, Haskell and Lisp. I've used every language mentioned except Haskell. I'm somewhat fed up with C++ myself. I've used it for years; I've written large systems in it, and I have to face that it has a fundamental problem. C++ is the only major language with hiding but without memory safety. C has neither hiding or safety; Java and Ada have both hiding and safety. No language since C++ repeats that mistake. Ada has its advantages, but outside the DoD world, it's more or less dead. If you have a security clearance and are interested in real time avionics programming, maybe. LISP has a cult problem. It's not used much any more, even in the AI community. LISP users tend to be too wierd. The language itself is OK, but few commercial applications use it. Viamall, which became Yahoo Store, is one of the very few major commercial LISP apps. I've written about 20,000 lines of LISP, but I'll never use it again. Actually, the ability to fix a running program isn't that useful in real life. It's more cool than useful. Editing a program from a break was more important back when computers were slower and just rerunning from the beginning was expensive. Python suffers from a slow implementation. Numbers vary, but 10x to 60x slower than C is typical. The language is quite powerful, but is held back by the CPython implementation, the lack of a language standard independent of any implementation, and a clunky mechanism for linking to external non-Python libraries. There's no fundamental reason that Python couldn't be made to run at least as fast as Java, but with the language spec tied to CPython, the other implementations are always playing catch-up and run far behind the CPython implementation. As languages, C# and Java are reasonably good. They tend to come with too much excess baggage in the form of frameworks, run-time systems, and packagers, but as languages they're fast, safe, and expressive. Can't speak for Haskell. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
http proxy question
I am tryin to grab a file from a site, however, this site limits me to one file per 15 minutes. What im tryin to do is use http profies in my script to just grab the file then change proxies so i can do it again back to back so that site site does not block me. This possible any example code out there? Thank you in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
On Dec 28, 1:32 pm, stanleyxu [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Dec 28, 12:57 pm, stanleyxu [EMAIL PROTECTED] wrote: To note this problem occurs when debugging script in IDLE editor. When I double click on my_script.py, all outputs will be printed in one console. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ Why are you using os.system for these commands in the first place? You should be using the os and shutil modules instead as they would be more cross-platform friendly. Something like this: # untested for new_folder, old_folder in folder_array: os.mkdir(new_folder) shutil.copytree(old_folder, new_folder) Adjust the path as needed in the mkdir call. See shutil's docs for more info: http://docs.python.org/lib/module-shutil.html And here's some folder manipulation docs: http://effbot.org/librarybook/os.htm By the by, the subprocess module is supposed to be used in place of the os.system and os.popen* calls:http://docs.python.org/lib/module-subprocess.html Mike Thanks Mike, you have provided another option. But my question has not been answered yet. The reason, why I use os.system(), is that I want to avoid accident file deletion by writing a script. My real script looks like: Technically speaking, the shutil module's copytree function will not delete ANYTHING if the destination already exists. It will just fail. You could catch the failed copy with a try/except that prints an appropriate message detailing the error. # 1. Funtion to execute a command in DOS-console def execCommand(cmd): if DEBUG_MODE: print 'DOS ' + cmd; else: os.system(cmd); # 2.1 Creates temp folder. Removes it first, if it exists. if os.path.exists(tmp_folder): execCommand('RD ' + tmp_folder + ' /S /Q'); execCommand('MD ' + tmp_folder + ''); # 2.2 Copies all files to the temp folder, that are going to be put in package. for source_folder, dest_folder in folders_array: if not os.path.exists(dest_folder): execCommand('MD ' + dest_folder + ''); execCommand('XCOPY \' + source_folder + ' ' + dest_folder + ' /Y'); The benefit is that, when I set DEBUG_MODE=True, I can see what will be executed. So that I can make sure that my script will not delete any other important files by accident. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ Carl Banks mentioned the subprocess module too and he pointed out its output redirection capabilities. I recommend checking those out too. You may be able to do some redirection by changing where stdout and stderr print to. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: i18n questions
On Dec 28, 12:01 pm, Donn Ingle [EMAIL PROTECTED] wrote: Hi, A soon-to-be happy new year to everyone! I'm 100% new to this i18n lark and my approach so far has been to create a .mo file per module in my app. My thinking was, why load one huge .mo file when a single module only needs a few strings? Since then, it seems, I have made the wrong decision. For example I have module A that imports module B. Each one does this: gettext.install( domain, localedir, unicode = True ) lang = gettext.translation(domain, localedir, languages = [ loc ] ) lang.install(unicode = True ) (where doman is the name of the module, so A and B) The problem is that domain A loads and then import B happens and so the lang reference (I think) gets replaced by domain B -- the result is that module A can only translate strings that are in domain B. How does one 'merge' gettext.translations objects together? Or is that insane? What's the best way to handle a project with multiple domain.mo files? I hope someone can give me some advice. \d I've never messed with .mo files, but a little googling turned up this interesting module on PyPI: http://cheeseshop.python.org/pypi?%3Aaction=searchterm=polib If you're messing with unicode in general, I've heard this is a good article to read: http://kevino.theolliviers.com/python-unicode.html This article looks related, although the author is using .po instead of .mo files: http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/ Finally, I found a wxPython specific one that looks like it might be general enough for you: http://wiki.wxpython.org/Internationalization I hope that gives you some ideas anyway. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: fiber(cooperative multi-threading)
Michael Sparks wrote: Also, I'd be interested in hearing how your project gets on - it sounds like the sort of thing that Kamaelia should be able to help with. (If it doesn't/can't, then it's a bug IMO :) That was also my impression. :) My last tries had similarities to Axon, but I never was able to formulate it this consistently (no generators, no microthreads, very very basic scheduler). Quite recently, I felt a little lost in the documentation. The docs shipped with Axon seem to be slightly out of date (e. g. pydoc Component says I mustn't override Component.main). The newer docs (http://kamaelia.sourceforge.net/Docs/Axon/) don't seem to be shipped with it at all (they help much though ;) ). I'm always interested in feedback! The fact the feedback link doesn't work for you is particularly useful - I'll look into that! It says Authorisation DENIED ! Sorry, guest - you are not allowed to perform this action : Do something undefined ! Regards, Björn -- BOFH excuse #111: The salesman drove over the CPU board. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
Thanks again for your kindly tips. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system question
import subprocess output = subprocess.Popen('MD ' + new_folder + '', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] print output Carl Banks Thanks Carl, it works ^^) -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/ stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/python-list
Re: Choosing a new language
Rico Secada wrote: Hi. First let me start by saying, please don't let this become a flame-thing. Second, I need some advice. I am a 35 year old programmer, who program in C/C++, PHP and Bourne Shell almost daily. I am currently going to start focusing on becoming more skilled at a few key languages, rather than knowing many (which I do on a more superficial level). My key languages are C, PHP and SH (Bourne Shell), and I have stopped using C++ because I find that its a C-hack rather than a good design choice. I have made the following decision: To study Ada and use it instead of C++. I come from a Pascal background and I love the Ada syntax and wide area of usage. I am also attracted to Ada because of its usage in the industry. Now I have three more languages that I am very attracted to, but I prefer to focus on just one of them: Python, Haskell and Lisp. I have been doing some reading and some coding, and I am mainly attracted towards Lisp because of its ability to fix a running program. But I find that Haskell is a more powerful language. Yet again Python has a huge user base and many libraries, and it is implemented everywhere, where Haskell and Lisp on the other hand hasn't. I like the syntax of all three, and I have gotten beyond the confusion stage of Lisp parentheses, so they don't bother me at all. I need advice from people who have been coding in all three, and who can share some views and experiences. Please, if you don't know ALL three by deep experience, don't respond to this thread! Thanks and best regards! Rico. And the good old standbys Fortran 95/2003 and REXX. -- Gary Scott mailto:[EMAIL PROTECTED] dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do the impossible, don't hire an expert because he knows it can't be done. -- Henry Ford -- http://mail.python.org/mailman/listinfo/python-list
Tab indentions on different platforms?
All, I seem to be having problems with running my python code, written on a Mac, on Linux and Windows boxes. It seems like the problem has to do with tab indention, particularly I've noticed that my code will completely ignore try statements. Has anyone had a similar problem? Regards, Ken -- http://mail.python.org/mailman/listinfo/python-list
Re: Choosing a new language
On Fri, 28 Dec 2007 12:54:57 -0800, John Nagle [EMAIL PROTECTED] wrote: Actually, the ability to fix a running program [in Lisp] isn't that useful in real life. It's more cool than useful. Editing a program from a break was more important back when computers were slower and just rerunning from the beginning was expensive. Speak for yourself. The ability to patch a running program is very useful for certain types of embedded applications. Not every program having high availability requirements can be restarted quickly, or can be implemented reasonably using multiple servers or processes to allow rolling restarts. I worked with real time programs that required external machinery to operate and several minutes to reinitialize and recover from a cold restart. Debugging non-trivial code changes could take hours or days without the ability to hot patch and continue. I know not everyone works in RT, but I can't possibly be alone in developing applications that are hard to restart effectively. That all said, online compilation such as in Lisp is only one of several ways of replacing running code. Whether it is the best way is open for debate. George -- for email reply remove / from address -- http://mail.python.org/mailman/listinfo/python-list
Re: Pivot Table/Groupby/Sum question
What about to let SQL to work for you. HTH Petr Jakes Tested on Python 2.5.1 8-- #!/usr/bin/env python # -*- coding: utf-8 -*- import sqlite3 con = sqlite3.connect(:memory:) cur = con.cursor() inputData=( ('Bob', 'Morn', 240), ('Bob', 'Aft', 300), ('Joe', 'Morn', 70), ('Joe', 'Aft', 80), ('Jil', 'Morn', 100), ('Jil', 'Aft', 150), ('Jil', 'Aft', 150), ('Jil', 'Aft', 150)) def data_generator(dataSet): for dataSetRow in dataSet: yield dataSetRow pivotSelect=''' SELECT NAME, sum (AMOUNT) as TOTAL, sum (case when (TIME_OF_DAY) = 'Morn' then AMOUNT else 0 END) as MORN, sum (case when (TIME_OF_DAY) = 'Aft' then AMOUNT else 0 END) as AFT FROM MY_NAMES GROUP BY 1''' cur.execute(create table MY_NAMES(NAME, TIME_OF_DAY, AMOUNT)) cur.executemany(insert into MY_NAMES(NAME, TIME_OF_DAY, AMOUNT) values (?,?,?), data_generator(inputData)) cur.execute(pivotSelect) for row in cur.fetchall(): print row -- http://mail.python.org/mailman/listinfo/python-list
Re: Tab indentions on different platforms?
On Dec 29, 9:51 am, xkenneth [EMAIL PROTECTED] wrote: I seem to be having problems with running my python code, written on a Mac, on Linux and Windows boxes. So *what* problems do you seem to be having? More to the the point, what problems are you *actually* having? It seems like the problem has to do with tab indention, particularly I've noticed that my code will completely ignore try statements. Has anyone had a similar problem? Yes. Set up your text editor to (a) recognise Tab and Shift-Tab keyboard inputs as indent/dedent respectively and (b) to insert 4 spaces and zero tab characters per indent. IOW, don't have tab characters at all in your source files. If after that you still have a problem, ask here again, with the following information: 1. The shortest possible script file that reproduces the problem -- use print open('problemdemo.py', 'rb').read() to show the contents (a) as it appears on the Mac (b) after transferring [how?] to Linux (c) after transferring [how?] to Windows 2. The results of executing the code in each of the three environments -- copy/paste of the actual output, not a description. -- http://mail.python.org/mailman/listinfo/python-list
Very strange caching problem with python script run from apache
I'm running a python script via the apache ExtFilterDefine directive, it works basically as expected *except* that when I change the script apache/firefox continue to run the old version of the python script until I remove the script completely and then replace it. I.e. my script is called tl2html.py, if I change it to (say) add several lines of output the added lines don't appear on firefox. I can restart firefox and I can restart apache and *still* it runs the old version of tl2html.py. If I 'mv tl2html.py fred' and then redisplay the page I get an error (because the script isn't there) and if I then 'mv fred tl2html.py' the new version of the script is run and I get my expected extra lines. This makes dubugging/development *exceedingly* difficult! Where is this python being cached? -- Chris Green -- http://mail.python.org/mailman/listinfo/python-list
Re: Pivot Table/Groupby/Sum question
On Dec 29, 9:58 am, [EMAIL PROTECTED] wrote: What about to let SQL to work for you. The OP is trying to learn how to make pivot tables from some excel sheets. You had better give him a clue on how to use ODBC on an excel sheet :-) [snip] SELECT NAME, sum (AMOUNT) as TOTAL, sum (case when (TIME_OF_DAY) = 'Morn' then AMOUNT else 0 END) as MORN, sum (case when (TIME_OF_DAY) = 'Aft' then AMOUNT else 0 END) as AFT This technique requires advance knowledge of what the column key values are (the hard-coded 'Morn' and 'Aft'). rant It is the sort of thing that one sees when %SQL% is the *only* language used to produce end-user reports. Innocuous when there are only 2 possible columns, but bletchworthy when there are more than 20 and the conditions are complex and the whole thing is replicated several times in the %SQL% script because either %SQL% doesn't support temporary procedures/functions or the BOsFH won't permit their use... not in front of the newbies, please! /rant -- http://mail.python.org/mailman/listinfo/python-list
Re: i18n questions
Thanks for taking the time to post those links. I have read most of them before. They don't seem to cover the basic issue in my OP, but i18n on Python is a dark art and maybe there's something I missed. \d -- http://mail.python.org/mailman/listinfo/python-list
Re: Very strange caching problem with python script run from apache
[EMAIL PROTECTED] wrote: I'm running a python script via the apache ExtFilterDefine directive, it works basically as expected *except* that when I change the script apache/firefox continue to run the old version of the python script until I remove the script completely and then replace it. I.e. my script is called tl2html.py, if I change it to (say) add several lines of output the added lines don't appear on firefox. I can restart firefox and I can restart apache and *still* it runs the old version of tl2html.py. If I 'mv tl2html.py fred' and then redisplay the page I get an error (because the script isn't there) and if I then 'mv fred tl2html.py' the new version of the script is run and I get my expected extra lines. This makes dubugging/development *exceedingly* difficult! Where is this python being cached? It's OK, I have found the problem, it's Firefox's cache. Since the file/URL *doesn't* change when I change the filter (tl2html.py) Firefox simply redisplays its cached copy of the page. It makes no difference if you restart Firefox or restart apache the cache is still there and Firefox will use it. Simple workaround is to hold Shift down when reloading the page, this forces Firefox to get a new copy even if it thinks it hasn't changed. Phew, that took a long time to work out! :-) -- Chris Green -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
Riccardo T. wrote: Scott David Daniels ha scritto: Riccardo T. wrote: Scott David Daniels ha scritto: [in the .png] ... Callable types ... User-definet methods I personally prefer User-defined methods That's a typo, thank you. Hope I didn't offend (I was simply trying to be cute). Some from a bit further along. I know I didn't say so explicitly, but I don't spend much effort in pointing out errors in useless things. No, you did't :) --- lambda is an expression, not a statement. I'll remove that from the expression list. Might include callable-invocation in operators? divmod, pow, int, long, float are in __builtin__, not math. Yes I know, it has already been signaled by mail. They will be removed in the next version, except pow (the version with two arguments that is in my list belongs to math, while pow(b,e,m) is from __builtin__). Note pow(base, exponent[, modulus] is good for crypto stuff. Useful modules to read actually should include __builtin__, os, and os.path -- maybe include os.walk and os.path.join. Maybe I'll add __builtin__ and os in place of the type hierarchy, but I'm not sure about that. However, not in the next release. What do you think about? How about: top line w/ __builtin__, os, os.path (and no contents -- inspire further reading). On left for numbers: Numbers long (big integers e.g. 9876543210L) int (plain integers e.g. 123) bool (booleans 0==False, 1==True) float (floating point) complex (e.g. 9j) Similarly str, unicode, tuple, list [that is, the precise type name] int (plain integers like 12) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python DLL in Windows Folder
[EMAIL PROTECTED] wrote: I did, and determined that it's not possible. We would have to use assembly manifests, and can't, as the tool chain doesn't support them. Ross Ridge writes: Your choice to use a tool chain that doesn't support side-by-side assemblies does not make it impossible. Chris Mellon [EMAIL PROTECTED] wrote: It's worth pointing out that when the choice was made,Windows didn't support SxS at all and there was no toolchain for it. Python 2.5 was released on September 16, 2006, Python 2.4 on November 30, 2004, and Python 2.3 on July 29, 2003. Windows first supported assembly manifests in Windows XP, which was released on October 25, 2001. There have been plenty of opportunities to add assembly manifests to the Python installer, if the developers were willing. Note also that private side-by-side DLL installation using .local files has been supported since Windows 98SE. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] [EMAIL PROTECTED] -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: Pivot Table/Groupby/Sum question
Petr, thanks for the SQL suggestion, but I'm having enough trouble in Python. John would you mind walking me through your class in normal speak? I only have a vague idea of why it works and this would help me a lot to get a grip on classes and this sort of particular problem. The next step is to imagine if there was another variable, like departments and add up the information by name, department, and time, and so on...that will come another day. Thanks. On Dec 29, 1:00 am, John Machin [EMAIL PROTECTED] wrote: On Dec 29, 9:58 am, [EMAIL PROTECTED] wrote: What about to let SQL to work for you. The OP is trying to learn how to make pivot tables from some excel sheets. You had better give him a clue on how to use ODBC on an excel sheet :-) [snip] SELECT NAME, sum (AMOUNT) as TOTAL, sum (case when (TIME_OF_DAY) = 'Morn' then AMOUNT else 0 END) as MORN, sum (case when (TIME_OF_DAY) = 'Aft' then AMOUNT else 0 END) as AFT This technique requires advance knowledge of what the column key values are (the hard-coded 'Morn' and 'Aft'). rant It is the sort of thing that one sees when %SQL% is the *only* language used to produce end-user reports. Innocuous when there are only 2 possible columns, but bletchworthy when there are more than 20 and the conditions are complex and the whole thing is replicated several times in the %SQL% script because either %SQL% doesn't support temporary procedures/functions or the BOsFH won't permit their use... not in front of the newbies, please! /rant -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(s, enc).encode(enc) == s ?
Wow, that's not easy to see why would anyone ever want that? Is there any logic behind this? It's the pre-Unicode solution to the we want to have many characters encoded in a single file problem. Suppose you have pre-defined characters sets A, B, C, and you want text to contain characters from all three sets, one possible encoding is switch-to-ACharactersInAswitch-to-BCharactersFromBand-so-on Now also suppose that A, B, and C are not completely different, but have slight overlap - and you get ambiguous encodings. ISO-2022 works that way. IPSJ maintains a registry of character sets for ISO, and assigns escape codes to them. There are currently about 200 character sets registered. Somebody decoding this would have to know all the character sets (remember it's a growing registry), hence iso-2022-jp restricts the character sets that you can use for that particular encoding. (Likewise, iso-2022-kr also restricts it, but to a different set of sets). It's a mess, sure, and one of the primary driving force of Unicode (which even has the unification - ie. lack of ambiguity - in its name). In your samples both of unicode(\x1b(BHallo,iso-2022-jp) and unicode(\x1b(JHallo,iso-2022-jp) give uHallo -- does this mean that the ignored/lost bytes in the original strings are not illegal but *represent nothing* in this encoding? See above, and Marc's explanation. ESC ( B switches to ISO 646, USA Version X3.4 - 1968; ESC ( J to ISO 646, Japanese Version for Roman Characters JIS C6220-1969 These are identical, except for the following differences: - The USA version has reverse solidus at 5/12; the Japanese version Yen sign - The USA version has Tilde (overline; general accent) at 7/14 (depicted as tilde); the Japanese version Overline (depicted as straight overline) - The Japanese version specifies that you can switch between roman and katakana mode by sending shift out (SO, '\x0e') and shift-in (SI, '\x0F') respectively; this switches to the JIS KATAKANA character set. (source: http://www.itscj.ipsj.or.jp/ISO-IR/006.pdf http://www.itscj.ipsj.or.jp/ISO-IR/014.pdf ) I.e. in practice (in a context limited to the encoding in question) should this be considered as a data loss, or should these strings be considered equivalent? These particular differences should be considered as irrelevant. There are some cases where Unicode had introduced particular compatibility characters to accommodate such encodings (specifically, the full-width latin (*) and half-width Japanese characters). Good codecs are supposed to round-trip the relevant differences to Unicode, and generate the appropriate compatibility characters. Bad codecs might not, and in some cases, users might complain that certain compatibility characters are lacking in Unicode so that correct round-tripping is not possible. I believe the Unicode consortium has resolved all these complaints by adding the missing characters; but I'm not sure. Regards, Martin (*) As an example for full-width characters, consider these two strings: Hello Hello Should they be equivalent, or not? They are under NFKD, but not NFD. -- http://mail.python.org/mailman/listinfo/python-list
Strange Behavior: csv module IDLE
I've noticed an oddity when running a program, using the csv module, within IDLE. I'm new to Python so am confused by what is happening. Here is what I'm doing: 1) Open the IDLE Shell. 2) Select File | Open... 3) Choose my file, foo.py, opening it in a window. 4) From that window, I hit F5 to run the module. Within the program, the snippet where I use the csv module is below: == csvfile = open('foo.csv', 'w') writer = csv.writer(csvfile) for row in rows: writer.writerow(row[0:3]) csvfile.close == The rows object is returned from a database query and is a list of tuples. Now here is the strange thing. If I run this program directly from the command line, i.e., D:\test D:\python25\python foo.py It runs fine, foo.csv is created and all is well. However, when I run it through the IDLE shell as described above, the foo.csv file is created but remains empty at 0 bytes. When I try to delete the file, Windows says it is in use. The only way I can break out of this is by restarting the IDLE shell. In other words, it appears that the shell is hanging. This will run through Task Scheduler, so shouldn't be a problem, but I'm worried that I'm coding this wrong for it to be acting this way under IDLE. Any help or explanation would be appreciated. Best Regards, Tom -- http://mail.python.org/mailman/listinfo/python-list
[no subject]
I'm having a problem similar to the query below, the problem being that the suggested method doesn't work because the win32gui.CreateFileDialog method seems produce a dialog with a read only attribute set, with no evident way to change it, in Python 2.4. Setting the 4th argument to zero, for example, does not change the behavior. SetOFNInitialDir is a method: pd.SetOFNInitialDir(r'D:\Documents and Settings\John') hth Roger EricP fordphoto2020NOSPAM at yahoo.comNOSPAM wrote in message news:1Dknb.31818$mZ5.158181 at attbi_s54... I get the following error when I run this script to open a file dialog. I've searched the web and news groups for this issue and have not found any references. I get the same behavior when I run it from Python or Pythonwin. I'm new to win32... and would appreciate any help I can get. If I comment out the following line it works fine but I have to navigate to my initial directory. pd.SetOFNInitialDir = r'D:\Documents and Settings\John' # File Dialog Example import win32ui import win32con pd = win32ui.CreateFileDialog(1) pd.SetOFNInitialDir = r'D:\Documents and Settings\John' pd.DoModal() print 'filename =',pd.GetFileName() print 'path =', pd.GetPathName() pd=None Traceback (most recent call last): File filedialog.py, line 4, in ? pd.SetOFNInitialDir = 'D:\Documents and Settings\Eric' TypeError: PyCFileDialog has read-only attributes Also is there a way to open the XP file dialog that has the navigation shortcuts on the left side of the dialog window? Thanks Eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior: csv module IDLE
On Fri, 28 Dec 2007 18:12:58 -0800, t_rectenwald wrote: Within the program, the snippet where I use the csv module is below: == csvfile = open('foo.csv', 'w') writer = csv.writer(csvfile) for row in rows: writer.writerow(row[0:3]) csvfile.close == The rows object is returned from a database query and is a list of tuples. Now here is the strange thing. If I run this program directly from the command line, i.e., D:\test D:\python25\python foo.py It runs fine, foo.csv is created and all is well. However, when I run it through the IDLE shell as described above, the foo.csv file is created but remains empty at 0 bytes. When I try to delete the file, Windows says it is in use. The only way I can break out of this is by restarting the IDLE shell. In other words, it appears that the shell is hanging. This will run through Task Scheduler, so shouldn't be a problem, but I'm worried that I'm coding this wrong for it to be acting this way under IDLE. Any help or explanation would be appreciated. You are not closing the file so the buffered data is not written to disk. To call a function you need the parenthesis, otherwise you are just referencing it without any effect. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior: csv module IDLE
On Dec 29, 1:12 pm, t_rectenwald [EMAIL PROTECTED] wrote: I've noticed an oddity when running a program, using the csv module, within IDLE. I'm new to Python so am confused by what is happening. Here is what I'm doing: 1) Open the IDLE Shell. 2) Select File | Open... 3) Choose my file, foo.py, opening it in a window. 4) From that window, I hit F5 to run the module. Within the program, the snippet where I use the csv module is below: Forget snippet, show us a *whole* program. Cut out the database stuff; just use some simple made-up value for rows. == csvfile = open('foo.csv', 'w') Always use 'wb' -- not the cause of the current problem but it will bite you later. writer = csv.writer(csvfile) for row in rows: writer.writerow(row[0:3]) Adding del writer may help csvfile.close The above statement does nothing. You meant csvfile.close(), I presume. == The rows object is returned from a database query and is a list of tuples. Now here is the strange thing. If I run this program directly from the command line, i.e., D:\test D:\python25\python foo.py It runs fine, foo.csv is created and all is well. However, when I run it through the IDLE shell as described above, the foo.csv file is created but remains empty at 0 bytes. When I try to delete the file, Windows says it is in use. The only way I can break out of this is by restarting the IDLE shell. In other words, it appears that the shell is hanging. No it's not hanging, it's just that the file is still open; you haven't closed it. It won't be closed until you exit IDLE. This will run through Task Scheduler, so shouldn't be a problem, but I'm worried that I'm coding this wrong for it to be acting this way under IDLE. Any help or explanation would be appreciated. Do these things inside a function, so that the objects get garbage- collected on exit. -- http://mail.python.org/mailman/listinfo/python-list
pipes python cgi and gnupg
I think this is more a GnuPG issue than a Python issue, but I wanted to post it here as well in case others could offer suggestions: I can do this from a python cgi script from a browser: os.system(gpg --version gpg.out) However, I cannot do this from a browser: os.system(echo %s | gpg --batch --password-fd 0 -d %s d.out %(pass, filename)) The output file is produced, but it's zero byte. I want the decrypted file's content, but the pipe seems to mess things up. The script works fine when executed from command line. The output file is produced as expected. When executed by a browser, it does not work as expected... only produces a zero byte output file. Any tips? I've googled a bit and experimented for a few nights, still no go. Thanks, Brad Here's the entire script: #!/usr/local/bin/python import cgi import cgitb; cgitb.enable() import os import tempfile print Content-Type: text/html print print TITLET/TITLE print H1H/H1 form = cgi.FieldStorage() if not form.has_key(pass): print Enter password filename = test.gpg pass = form.getvalue(pass).strip() os.system(gpg --version gpg.out) os.system(echo %s | gpg --batch --password-fd 0 --decrypt %s d.out %(pass,filename)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior: csv module IDLE
On Dec 28, 9:43 pm, John Machin [EMAIL PROTECTED] wrote: On Dec 29, 1:12 pm, t_rectenwald [EMAIL PROTECTED] wrote: I've noticed an oddity when running a program, using the csv module, within IDLE. I'm new to Python so am confused by what is happening. Here is what I'm doing: 1) Open the IDLE Shell. 2) Select File | Open... 3) Choose my file, foo.py, opening it in a window. 4) From that window, I hit F5 to run the module. Within the program, the snippet where I use the csv module is below: Forget snippet, show us a *whole* program. Cut out the database stuff; just use some simple made-up value for rows. == csvfile = open('foo.csv', 'w') Always use 'wb' -- not the cause of the current problem but it will bite you later. writer = csv.writer(csvfile) for row in rows: writer.writerow(row[0:3]) Adding del writer may help csvfile.close The above statement does nothing. You meant csvfile.close(), I presume. == The rows object is returned from a database query and is a list of tuples. Now here is the strange thing. If I run this program directly from the command line, i.e., D:\test D:\python25\python foo.py It runs fine, foo.csv is created and all is well. However, when I run it through the IDLE shell as described above, the foo.csv file is created but remains empty at 0 bytes. When I try to delete the file, Windows says it is in use. The only way I can break out of this is by restarting the IDLE shell. In other words, it appears that the shell is hanging. No it's not hanging, it's just that the file is still open; you haven't closed it. It won't be closed until you exit IDLE. This will run through Task Scheduler, so shouldn't be a problem, but I'm worried that I'm coding this wrong for it to be acting this way under IDLE. Any help or explanation would be appreciated. Do these things inside a function, so that the objects get garbage- collected on exit. Thanks for all of the help. I'm still learning Python so dorked up here and didn't add the empty parenthesis around csvfile.close as I should have. So, it never called the close() function, but just referenced it as was noted in your responses. After doing that, everything works fine and the file is closed properly. I do have this in a function in the actual script I'm writing, just sort of made a dummy, foo.py, to do some testing and didn't have it in a function there. I'll research wb now to figure out what that does. Thanks again for the help! Tom -- http://mail.python.org/mailman/listinfo/python-list
sqlobject issue/question...
hi i'm playing around, researching sqlobject, and i notice that it appears to require the use of id in each tbl it handles in the database. if i already have a db schema, and it doesn't use 'id' as an auto-generated field, does that mean that i can't use/implement sqlobject. is there a way to overide this function/behavior... thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat sheet
Riccardo T. wrote: I wrote a little cheat sheet for this wonderful language, but because of my still little experience with it, I would like to have a feedback Could you have a look at it and tell me what do you think about, please? http://greyfox.imente.org/index.php?id=73 -- GreyFox Nicely done! I would suggest you put your website address on it and a revision number so that as it gains use on te web, people can find the latest version. -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
Stefan Behnel wrote: Robert Kern wrote: The problem is that for SQL databases, there is a substantial API that they can all share. The implementations are primarily differentiated by other factors like speed, in-memory or on-disk, embedded or server, the flavor of SQL, etc. and only secondarily differentiated by their extensions to the DB-API. With parallel processing, the API itself is a key differentiator between toolkits and approaches. Different problems require different APIs, not just different implementations. Well, there is one parallel processing API that already *is* part of stdlib: the threading module. So the processing module would fit just nicely into the idea of a standard library. True. I suspect that if any of them get into the standard library, it will be that one. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: i18n questions
Is there a group better suited to gettext/i18n questions of this sort? Just wondering because I have little time left to finish my December project! How does one 'merge' gettext.translations objects together? Or is that insane? What's the best way to handle a project with multiple domain.mo files? \d -- http://mail.python.org/mailman/listinfo/python-list
Re: parallel processing in standard library
Emin.shopper Martinian.shopper wrote: On Dec 27, 2007 4:13 PM, Robert Kern [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: My recommendation to you is to pick one of the smaller implementations that solves the problems in front of you. Read and understand that module so you could maintain it yourself if you had to. Post to this list about how you use it. Blog about it if you blog. Write some Python Cookbook recipes to show how you solve problems with it. That is a good suggestion, but for most of the coarse grained parallelism tasks I've worked on it would be easier to roll my own system than do that. To put it another way, why spend the effort to use a particular API if I don't know its going to be around for a while? Since a lot of the value is in the API as opposed to the implementation, unless there is something special about the API ( e.g., it is an official or at least de factor standard) the learning curve may not be worth it. And you think that you will encounter no learning curve writing your own code? At least take the opportunity to see how other people have solved your problem. Some of the implementations floating around now fit into one module. Surely, it would take less time to understand one of them than write your own. And let's not forget testing your module. The initial writing is never the timesink; it's the testing! If there is a lively community around it, that will help it get into the standard library. Things get into the standard library *because* they are supported, not the other way around. You make a good point and in general I would agree with you. Isn't it possible, however, that there are cases where inclusion in the standard library would build a better community? Not inclusion by itself, no. The standard library's APIs are only as supported as there exists people willing to support them. *Their being in the standard library does not create people out of thin air*. That's why the python-dev team now have a hard requirement that new contributions must come with a guarantee of support. Asking for inclusion without offering the corresponding guarantee will be met with rejection, and rightly so. How would you or the rest of the community react to a proposal for a generic parallelism API? I suspect the response would be show us an implementation of the code. I could whip up an implementation or adapt one of the existing systems, but then I worry that the discussion would devolve into an argument about the pros and cons of the particular implementation instead of the API. Even worse, it might devolve into an argument of the value of fine-grained vs. coarse-grained parallelism or the GIL. Considering that these issues seem to have been discussed quite a bit already and there are already multiple parallel processing implementations, it seems like the way forward lies in either a blessing of a particular package that already exists or adoption of an API instead of a particular implementation. Well, you can't design a good API without having an implementation of it. If you can't use the API in real problems, then you won't know what problems it has. Preferably, for an API that's intended to have multiple vendors, you should have 2 implementations taking different approaches so you can get some idea of whether the API generalizes well. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: getting n items at a time from a generator
Kugutsumen [EMAIL PROTECTED] wrote: I am relatively new the python language and I am afraid to be missing some clever construct or built-in way equivalent to my 'chunk' generator below. I have to say that I have found this to be a surprisingly common need as well. Would this be an appropriate construct to add to itertools? -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
[issue1705] trace module does not annotate global statement
New submission from Wummel: Hi, the trace module does not properly count the global statement. So coverage tests of functions that use the global statement always file. To reproduce write a simple function using the global statement and store it in mytest.py (which is attached). Then run python -m trace -c mytest.py. You'll see that the global statement line will not be covered (ie. there is no 1: at the beginning of the line). I tested with Python 2.5 and 2.4. -- components: Extension Modules files: mytest.py messages: 59021 nosy: calvin severity: normal status: open title: trace module does not annotate global statement type: behavior Added file: http://bugs.python.org/file9033/mytest.py __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1705 __# coverage test for the trace module # run with: python -m trace -c mytest.py t = 1 def f(): global t t = 2 if __name__ == '__main__': f() ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1706] Force WINVER 0x0500 (Windows 2000)
New submission from Christian Heimes: Do you think it's a good idea to force Win2k compatibility by defining WINVER 0x0500 in PC/pyconfig.h? It fixed the problem with Tcl/Tk, #1601. http://msdn2.microsoft.com/en-us/library/aa383745.aspx #define WINVER 0x0500 #define _WIN32_WINNT 0x0500 -- assignee: loewis components: Windows messages: 59022 nosy: loewis, tiran severity: normal status: open title: Force WINVER 0x0500 (Windows 2000) versions: Python 2.6, Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1706 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1607] Patch for TCL 8.5 support
Tal Einat added the comment: I say close it, but start a discussion on switching to Tcl/Tk8.5 on the appropriate list(s). __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1607 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1607] Patch for TCL 8.5 support
Christian Heimes added the comment: Can you start a discussion on python-dev please? Tcl/Tk support should be added to Python trunk (2.6) and ported to 3.0. Is it possible to keep compatibility with Tcl/Tk 8.4, too? -- resolution: - rejected status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1607 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1778443] robotparser.py fixes
Aristotelis Mikropoulos added the comment: Also, I would like to tell you that my new account name is Indy, and not indy90 anymore (I changed since this issue tracker moved from SourceForge to here). So, thanks again and I hope this patch will be helpful. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1778443 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com