Davy's Ironpython Editor 00.01.71
DIE 00.01.71 Released Davy's Ironpython Editor (DIE) is a clutter free IronPython editor written in IronPython with some basic IDE features. http://code.google.com/p/davysironpythoneditor/ Here's the detail in what has changed in 00.01.71: + Mobile Version which stores options in same dir. + Installed version stores in User Profile. (Existing Settings files don't transfer over - sorry). + 'Find in Files' feature added. + Much much Improved Capture of output from running Python scripts. + Click on error output now opens file and goes to line. + Resources - MSDN links area now low bandwith versions, Python links and Powershell launch menu. + Added CheckBox and Listbox control to gen_GUI. + Syntax Box -Exposed new property to get Caret Screen position. + Autocomplete option added - default to OFF. Experimental parsing for strings, lists and dictionaries. + Bug fixes and performance updates. Thanks Davy M -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
PyPy Europython Sprint Announcement
== Birmingham (UK) EuroPython PyPy Sprints 28-29 June/ 3-4 July 2009 == The PyPy team is sprinting at EuroPython again. This year there are `sprint days`_ before (28-29 June) and after (3-4 July) the conference. Some PyPy core people should be present during both periods. .. _`sprint days`: http://wiki.europython.eu/Sprints If you plan to attend the sprints after the conference we recommend you to listen to the PyPy technical talk (`EuroPython schedule`_) during the conference since it will give you a good overview of the status of development. Goals and topics of the sprint -- There are many possible and interesting sprint topics to work on - here we list some possible task areas: - trying out software on PyPy's Python interpreter: the CPython test suite is not all that complete, therefore the fact that we pass most tests is no real indication of bug-freeness. We have tried and know that frameworks like Django and Twisted work with PyPy. Therefore we would like to try running more real applications on top of the Python interpreter (ideally ones that have a good test suite themselves and that don't need unusual extension modules). Running things on Windows is also interesting, we know our coverage there is not as good as on Linux. - check and improve Mac OS X support - starting to work on porting 2.6 features to PyPy's Python interpreter - ongoing JIT generator work - of course we are open to other ideas for what to work on. Examples could be working on other language interpreters, sandboxing, ... Registration If you'd like to come, please subscribe to the `pypy-sprint mailing list`_ and drop a note about your interests and post any questions. More organisational information will be sent to that list. Please register by adding yourself on the following list (via svn): http://codespeak.net/svn/pypy/extradoc/sprintinfo/ep2009/people.txt or on the pypy-sprint mailing list if you do not yet have check-in rights: http://codespeak.net/mailman/listinfo/pypy-sprint --- Preparation (if you feel it is needed): --- - read the `getting-started`_ pages on http://codespeak.net/pypy, especially also the `development of PyPy itself part`_ . - for inspiration, overview and technical status you are welcome to read `the technical reports available and other relevant documentation`_ - please direct any technical and/or development oriented questions to pypy-dev at codespeak.net and any sprint organizing/logistical questions to pypy-sprint at codespeak.net - if you need information about the conference, potential hotels, directions etc we recommend to look at http://www.europython.eu. We are looking forward to meet you at the EuroPython PyPy sprints! The PyPy team .. See also .. .. _getting-started: http://codespeak.net/pypy/dist/pypy/doc/getting-started.html .. _`development of PyPy itself part`: http://codespeak.net/pypy/dist/pypy/doc/getting-started-dev.html .. _`pypy-sprint mailing list`: http://codespeak.net/mailman/listinfo/pypy-sprint .. _`the technical reports available and other relevant documentation`: http://codespeak.net/pypy/dist/pypy/doc/docindex.html .. _`EuroPython schedule`: http://europython.eu/talks/timetable -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python-URL! - weekly Python news and links (May 29)
QOTW: Death To Wildcard Imports - Lawrence D'Oliveiro http://groups.google.com/group/comp.lang.python/msg/835cf7f35ed f4897 How to ask questions having a chance of being answered: http://groups.google.com/group/comp.lang.python/t/17b15282d07770d1/ Multiprocessing and memory usage: http://groups.google.com/group/comp.lang.python/t/4c9c5805aadd833d/ Of backslashes and raw string literals: http://groups.google.com/group/comp.lang.python/t/dd18130f9f379974/ How does OOP feel in Python? http://groups.google.com/group/comp.lang.python/t/2cf2e3c9c1df4e8b/ Sockets: how to reuse the same port quickly http://groups.google.com/group/comp.lang.python/t/82204fb9d10d38aa/ Tools to optmize math functions: http://groups.google.com/group/comp.lang.python/t/2b34fd6c43be79d6/ Replacing module with a stub for unit testing: http://groups.google.com/group/comp.lang.python/t/023dff1ec533f101/ Sometimes it's better to use delegation instead of inheritance: http://groups.google.com/group/comp.lang.python/t/86674e06fc14c6a6/ Inserting NULL values in a database: http://groups.google.com/group/comp.lang.python/t/3c3ccdbfe1bc5a45/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish the efforts of Python enthusiasts: http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/group/comp.lang.python.announce/topics Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donations/ The Summary of Python Tracker Issues is an automatically generated report summarizing new bugs, closed ones, and patch submissions. http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.comp.python.develsort=date Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://code.activestate.com/recipes/langs/python/ Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available, see: http://www.python.org/channews.rdf For more, see: http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all The old Python To-Do List now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470group_id=5470func=browse http://www.python.org/dev/peps/pep-0042/ del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python Enjoy the *Python Magazine*. http://pymag.phparch.com/ *Py: the Journal of the Python Language* http://www.pyzine.com Dr.Dobb's Portal is another source of Python
Re: How can 'type' be an instance of itself?
LittleGrasshopper wrote: On May 28, 4:37 pm, Christian Heimes li...@cheimes.de wrote: LittleGrasshopper wrote: This is probably trivial, but it's driving me mad somehow. All (new style) classes are instances of 'type' by default, unless a custom metaclass is specified. I take this to mean that when a class type(ob) simply looks up ob.__class__. For built-in classes, that is all it means. declaration is found in the code, an instance of 'type' representing that class is created by calling type.__init__. What really gets me is how can 'type' be an instance of itself. In order to create 'type' we would need to call type.__init__, but it seems at this point it wouldn't exist. Probably a dumb question, which I hope someone can explain in some detail. Actually, it is type.__new__ that creates the new object (as is true of all classes). .__init__, when present, initializes mutable objects already created by .__new__. This is a perceptive, not a dumb question. The classes 'type' and 'object' are written in C. You can do things in C code that aren't possible from pure Python code. The circular dependencies between 'type' and 'object' are created during the boot strapping phase of the interpreter. In other words, the interpreter is god with respect to built-in objects. For instance, the interpreter has to mutate 'immutable' objects in order to give then their immutable (thereafter) values. So setting type.__class__ to type itself is no more of a big deal than the above, or setting any builtin.__class__ to type. type(type) type 'type' type.__bases__ (type 'object',) object.__bases__ () type(object) type 'type' Christian And just to clarify that I do really understand what this means, I gather that what it entails is that 'type' is an instance of itself just from a conceptual point of view. In regard to their creation, yes. But thereafter, isinstance(type, type) is as concretely True as for anything. tjr In other words, the code for the (meta)class 'type' is created statically by object code (compiled C code) before the python runtime is initiated (you referred to it as the interpreter bootstrapping phase.) I also guess that this code sets __class__ and __metaclass__ to the 'type' object itself (I am guessing a self-referencial pointer in C.) While I just am hypothesizing on the details, please let me know if you sense that I have misunderstood any essential part of your explanation. Thanks, Lukas -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Tkinter and popen problem
norseman wrote: The direct question comes back to: How does one force a sync or flush() to take effect in Python with Tkinter in use? Or just in Python period. The keyword being force. Here's some truly minimal code which shows the same buffering behaviour: $ cat master.py #!/usr/bin/env python import os for line in os.popen(./child.py): print --, line.strip() $ cat child.py #!/usr/bin/env python import time for i in range(5): print i time.sleep(.2) On Linux you can work around it with pexpect: $ cat master2.py #!/usr/bin/env python import pexpect for line in pexpect.spawn(./child.py): print --, line.strip() On Windows, I don't know. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: How can 'type' be an instance of itself?
On May 28, 11:07 pm, Terry Reedy tjre...@udel.edu wrote: LittleGrasshopper wrote: On May 28, 4:37 pm, Christian Heimes li...@cheimes.de wrote: LittleGrasshopper wrote: This is probably trivial, but it's driving me mad somehow. All (new style) classes are instances of 'type' by default, unless a custom metaclass is specified. I take this to mean that when a class type(ob) simply looks up ob.__class__. For built-in classes, that is all it means. declaration is found in the code, an instance of 'type' representing that class is created by calling type.__init__. What really gets me is how can 'type' be an instance of itself. In order to create 'type' we would need to call type.__init__, but it seems at this point it wouldn't exist. Probably a dumb question, which I hope someone can explain in some detail. Actually, it is type.__new__ that creates the new object (as is true of all classes). .__init__, when present, initializes mutable objects already created by .__new__. This is a perceptive, not a dumb question. The classes 'type' and 'object' are written in C. You can do things in C code that aren't possible from pure Python code. The circular dependencies between 'type' and 'object' are created during the boot strapping phase of the interpreter. In other words, the interpreter is god with respect to built-in objects. For instance, the interpreter has to mutate 'immutable' objects in order to give then their immutable (thereafter) values. So setting type.__class__ to type itself is no more of a big deal than the above, or setting any builtin.__class__ to type. type(type) type 'type' type.__bases__ (type 'object',) object.__bases__ () type(object) type 'type' Christian And just to clarify that I do really understand what this means, I gather that what it entails is that 'type' is an instance of itself just from a conceptual point of view. In regard to their creation, yes. But thereafter, isinstance(type, type) is as concretely True as for anything. tjr In other words, the code for the (meta)class 'type' is created statically by object code (compiled C code) before the python runtime is initiated (you referred to it as the interpreter bootstrapping phase.) I also guess that this code sets __class__ and __metaclass__ to the 'type' object itself (I am guessing a self-referencial pointer in C.) While I just am hypothesizing on the details, please let me know if you sense that I have misunderstood any essential part of your explanation. Thanks, Lukas Terry, Thanks a lot for clarifying this further. I believe I understand exactly what is going on now. What you say about the C compiler being god (which is basically saying what Christian said in an even more emphatic way) really puts things in perspective. Regards, Lukas -- http://mail.python.org/mailman/listinfo/python-list
Re: python list pattern matching?
Terry Reedy wrote: a,b,*rest = list(range(10)) The list() call is superfluous. -- http://mail.python.org/mailman/listinfo/python-list
Re: DB-API execute params, am I missing something?
Diez B. Roggisch wrote: Gabriel Rossetti wrote: Hello everyone, I am trying to use dbapi with mysql and I get this error: Traceback (most recent call last): File stdin, line 1, in module File stdin, line 2, in getUnitParams File /var/lib/python-support/python2.5/MySQLdb/cursors.py, line 151, in execute query = query % db.literal(args) TypeError: int argument required with this code : import MySQLdb def getParams(curs): curs.execute(select * from param where id=%d, 1001) return curs.fetchall() cp = MySQLdb.connect(host=localhost, port=3306, user=root, passwd=123, db=test) curs = cp.cursor() result = getParams(curs) I checked MySQLdb.paramstyle and it uses format. I also tried passing (1001,) instead of just 1001 as the param but this changes nothing. What am I doing wrong? AFAIK you need to use %s, regardless of what type you pass. Diez Ok, thank you, that was the problem. I also learned not to put the quotes in the SQL statement (e.g. SELECT * FROM toto WHERE toto.name='%s') since the call to literal() adds them :-) Thank you, Gabriel -- http://mail.python.org/mailman/listinfo/python-list
Re: DB-API execute params, am I missing something?
Paul Boddie wrote: On 26 Mai, 13:46, Gabriel Rossetti gabriel.rosse...@arimaz.com wrote: def getParams(curs): curs.execute(select * from param where id=%d, 1001) First of all, you should use the database module's parameter style, which is probably %s - something I've thought should be deprecated for a long time due to the confusion with string substitution that this causes, regardless of whether that mechanism is actually used internally by the module (as seen in your traceback). You also have to provide a sequence of parameters: unlike string substitution, you cannot provide a single parameter value and expect the execute method to do the right thing. Some database modules seem to insist on either lists or tuples of parameters, but I think any sequence type should work. Try this: curs.execute(select * from param where id=%s, (1001,)) Paul Thank you for the explanation Paul! Gabriel -- http://mail.python.org/mailman/listinfo/python-list
Re: What text editor is everyone using for Python
Hi guys, I would like to reflect this issue for the last time, though I found this thread to be quite inspiring. In one the last postings about this topic Steven D'Aprano has written: As a general rule, menus are discoverable, while keyboard commands aren't. There's nothing inherent to text editing functions which makes then inherently undiscoverable, and KDE apps like kate and kwrite do a reasonable job of making them so. I agree with this assumption if, and only if we are speaking about outsider users. This is a Python mailing list, which supposed to be a forum of people using the Python programming language. So Python source is a plain text, so Python interpreter should be a command-driven application. With no other UI than the plain old Command Line Intreface. MOre than that, all we are supposed to be techmen, who does acknowledge and appreciate the conceot of wrtitten User Manual or Reference. All we have learned Python from tutorials and not from the menues. As a summary, any open source editor should be perfect, which is extensible, optionally language-sensitive, portable, basically independent of any OS features. THat cuts the list drammatically. Gabor -- http://mail.python.org/mailman/listinfo/python-list
Re: What text editor is everyone using for Python
Gabor Urban urbang...@gmail.com writes: This is a Python mailing list, which supposed to be a forum of people using the Python programming language. Agreed so far. As a summary, any open source editor should be perfect, which is extensible, optionally language-sensitive, portable, basically independent of any OS features. THat cuts the list drammatically. With this paragraph I can agree. So Python source is a plain text, so Python interpreter should be a command-driven application. Huh? The Python interpreter should be a command-line application, true. But the fact that Python source code is text has nothing to do with that. With no other UI than the plain old Command Line Intreface. This doesn't follow at all. I am convinced that I'm far more productive in my full-window editing environment over needing to use a command-line to do everything. Where does “should” come into that, and why is a full-window environment excluded? If, instead of “command-line”, you actually mean “text-mode full-window console”, I'm still calling you on your non sequitur. There's nothing about editing text that excludes using a graphical interface rendered in pixels instead of text characters. The closest I get to agreement with any of the above is that a full-window text editing environment should never *require* any graphical pixellated interface. But to *exclude* it is too much. MOre than that, all we are supposed to be techmen, who does acknowledge and appreciate the conceot of wrtitten User Manual or Reference. All we have learned Python from tutorials and not from the menues. You seem to have a rather exclusionist idea of the Python community, that does not match my experience at all. Python programmers are women as well as men. Many Python programmers would not describe themselves as “technical” people. And I know for a fact many of the good ones learned by example, not from tutorials. -- \ “Courage is resistance to fear, mastery of fear — not absence | `\of fear. —Mark Twain, _Pudd'n'head Wilson_ | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: What text editor is everyone using for Python
On Fri, 29 May 2009 08:57:18 +0200, Gabor Urban wrote: In one the last postings about this topic Steven D'Aprano has written: As a general rule, menus are discoverable, while keyboard commands aren't. There's nothing inherent to text editing functions which makes then inherently undiscoverable, and KDE apps like kate and kwrite do a reasonable job of making them so. I agree with this assumption if, and only if we are speaking about outsider users. It's not an assumption, it's a conclusion. My assumption is that everybody, no matter how experienced they are, will *at some time* be looking for some editor functionality without knowing whether or not it exists. I've never needed to (say) strip out all comments from a document, but if I ever do, if the editor makes functions discoverable, I've got a better chance of finding the command I need, rather than wasting my time programming something that's been done before. We all know of experienced system admins who have built-up an amazingly detailed amount of knowledge about the systems they've used. They can tell you about the most obscure features and functions of a system. But put them in a system which is *not quite the same* (say, Ubuntu instead of Redhat, or FreeBSD instead of Linux), and they often flounder. All the functions they're used to are in a different place, so to speak. And there's no easy way to learn that command ABC on one system is precisely the same as command XYZ on another. Only two sorts of people don't benefit from ease of discoverablity: those who know everything, and those who never do anything new. This is a Python mailing list, which supposed to be a forum of people using the Python programming language. So Python source is a plain text, so Python interpreter should be a command-driven application. With no other UI than the plain old Command Line Intreface. That Python is command-driven doesn't have *any* implications for the editor you use to write Python code. Photo-editing software is mouse- driven. That doesn't mean that you should be forced to write photo- editing programs by point-and-click. MOre than that, all we are supposed to be techmen, who does acknowledge and appreciate the conceot of wrtitten User Manual or Reference. All we have learned Python from tutorials and not from the menues. We're probably better at reading manuals than average people, but that doesn't mean we *like* it. That's one of the reasons we use Python: nearly everything is discoverable from inside the Python runtime environment. We have a wealth of tools for inspecting objects. If you want to know what methods an object has, you don't have to look it up in the manual, you can inspect it with dir(). Besides, once you've been in the tech industry for long enough, you'll learn that the Python documentation is *remarkably* good compared to the average technical documentation. As a summary, any open source editor should be perfect, which is extensible, optionally language-sensitive, portable, basically independent of any OS features. THat cuts the list drammatically. (1) Closed source editors have the same functional requirements as open source editors. (2) If you're waiting for perfection, you'll be waiting forever. (3) Why independent of the OS? When is the last time you've used a system without an OS? Forth programmers in the 1970s used an editor that was OS independent -- it managed files using its own unique file structure, managed memory itself, etc. Why do you want to go back there? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: AOPython Question
Roastie schrieb: I installed the AOPython module: % easy_install aopython That left an aopython-1.0.3-py2.6.egg at C:\mystuff\python\python_2.6.2\Lib\site-packages. I entered the interpreter: import aopython All is well. But I was uncomfortable, since I was used to seeing directories of Python code for modules in site-packages, so I decided to read about eggs: http://mrtopf.de/blog/python_zope/a-small-introduction-to-python-eggs/ The article told me to run: % easy_install aopython-1.0.3-py2.6.egg Did you run that in the site-packages-directory? If yes, that was a mistake. The above command is supposed to work on downloaded eggs that lie around somewhere. The result was a long list of error messages and removal of my egg, and Python could no longer use the AOPython module. So, I'm looking for a better reference for telling me about eggs and modules in site-packages. You did everything alright the first time. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: What text editor is everyone using for Python
norseman wrote: jeffFromOz wrote: On May 26, 10:07 pm, Lacrima lacrima.ma...@gmail.com wrote: I am new to python. And now I am using trial version of Wing IDE. But nobody mentioned it as a favourite editor. So should I buy it when trial is expired or there are better choices? No one mentioned textmate either . a brilliant text editor with python templates, and bundles, syntax highlighting, etc. We use wingIDE for debugging and it seems fine, except for the weird way it corrupts the displayed text. === BOTTOM LINES: Whatever they learned on. Whatever they are trying out at the moment (for the adventurous types) Suggestion: Take a look at the top two most used OS you use and learn the default (most often available) text editors that come with them. Which means Notepad on Windows? -- http://mail.python.org/mailman/listinfo/python-list
Global variables from a class
I usually use a class to access to global variables. So, which would be the correct way to set them --since the following classes--: class Foo: var = 'lala' class Bar: def __init__(self): self.var = 'lele' Or is it the same? -- http://mail.python.org/mailman/listinfo/python-list
Re: What text editor is everyone using for Python
In message 003b3d8c$0$9673$c3e8...@news.astraweb.com, Steven D'Aprano wrote: On Fri, 29 May 2009 14:00:19 +1200, Lawrence D'Oliveiro wrote: In message 003af57e$0$9673$c3e8...@news.astraweb.com, Steven D'Aprano wrote: On Fri, 29 May 2009 09:04:39 +1200, Lawrence D'Oliveiro wrote: In message 003a5518$0$9673$c3e8...@news.astraweb.com, Steven D'Aprano wrote: On Thu, 28 May 2009 20:58:07 +1200, Lawrence D'Oliveiro wrote: In message 0039e83c$0$9673$c3e8...@news.astraweb.com, Steven D'Aprano wrote: A good UI standard should mean that: * all functionality should be discoverable without reading the manual; Which means no scripting languages are allowed? Should, not must. If you meant may or may not, why don't you say may or may not? Should does not mean may or may not. I'm not sure how there is supposed to be a difference in this context. All people should fly by flapping their arms, except where this is physically impossible. You're asking for something that is infeasible with most current editors, if not all of them. On the remote chance that you're not trolling, I deny that discoverablity is infeasible ... On the remote chance you're not trolling, let me point out politely that it is for scriptability. -- http://mail.python.org/mailman/listinfo/python-list
Re: DB-API execute params, am I missing something?
In message mailman.867.1243574504.8015.python-l...@python.org, Dennis Lee Bieber wrote: On Thu, 28 May 2009 20:57:13 +1200, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand declaimed the following in gmane.comp.python.general: db.literal((... %wildcard% ...)) (... '%wildcard%' ...) Doesn't look like it worked, does it? If the problem is that you have /user/ input that may have a % sign that should NOT be treated as a wildcard, the solution is to train said user... Sounds like a good solution to SQL-injection vulnerabilities, isn't it? Wonder why no-one thought of that before? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Tkinter and popen problem
norseman norse...@hughes.net (n) wrote: n I have tried both and Popen2.popen2(). n os.popen runs both way, contrary to docs. What do you mean `os.popen runs both way'? n # master.py n import os n #both lines work same Of course, because 'r' is the default, and the bufsize for reading the pipe only influences the performance. n #xx= os.popen(/mnt/mass/py/z6.py).readlines() n xx= os.popen(/mnt/mass/py/z6.py,'r',1).readlines() n #I had hoped small buffer would force a sync (flush()) n #No such luck. First, there is a difference between sync and flush. flush is writing out any output that is buffered in the application program for that file. Sync is writing out buffers (cache) in the operating system (to the disc, network connection or similar). We are talking here about flushing, not syncing. As we deal with a pipe, sync is not applicable. Furthermore, whatever you do in the master program, such as setting the buffer size has nothing to do with what happens in the child, so it will not influence the flushing behaviour of the child. The only way to influence that would be to use a pty instead of a pipe, because most code uses a different buffering strategy for ttys and ptys compared to files and pipes. The next error in your program is that you use readlines() This reads ALL input from your pipe before it proceeds. So essentially it waits until the child process is finished and therefore gives you the impression that it doesn't flush(). But it is not the child that is the problem it is your master. What you should do is take the pipe and do a readline()/print loop. #xx= os.popen(/mnt/mass/py/z6.py) # popen is deprecated. Replace with subprocess: from subprocess import Popen, PIPE xx = Popen([/mnt/mass/py/z6.py], stdout=PIPE).stdout while True: line = xx.readline() if not line: break print \t + line, The obvious: for l in xx: print \t + l, doesn't work as the iterator for a file, including pipes, does a read ahead (see the doc on file.next()) and therefore is not suitable for interactive use. n The direct question comes back to: n How does one force a sync or flush() to take effect in Python with n Tkinter in use? Or just in Python period. The keyword being force. So it should be clear by now that the answer is to use flush(). And make sure you read AND process the flushed output in a proper way. By the way, you have a nasty habit of using very unclear language to pose your problems in this newsgroup/mailing list, instead of writing a concise description and giving small examples of what code causes the problem. This makes it extremely difficult to help you. I had to read your messages at least 5 times to get an idea of what you were doing and what the problem was that you wanted to solve. Maybe you are dyslectic or something similar, in which case I apologize. But anyway, I think you should learn to express yourself more clearly. There are also courses for that. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
FILE object in Python3.0 extension modules
In Python2.x, I used PyFile_Check(obj) to check if a parameter was a file object. Now, in Python3.0 the same object (obtained as open('file.bin','wb')) is an io.BufferedWriter object. How do I perform type checking for such an object in the extension module, and how do I extract a FILE * object from it? I browsed the C API documentation, but couldn't find an answer. The purpose is to dump the contents of a Python extension type to disk as binary data using C's fwrite() function. -- http://mail.python.org/mailman/listinfo/python-list
Re: Global variables from a class
Kless jonas@googlemail.com (K) wrote: K I usually use a class to access to global variables. So, which would K be the correct way to set them --since the following classes--: K K class Foo: Kvar = 'lala' K class Bar: Kdef __init__(self): K self.var = 'lele' K K Or is it the same? I don't see any global variable in your code. var is a class variable (attribute) in Foo, whereas in Bar var is an instance variable (attribute). These are two different things. However a class variable acts as a kind of default for an instance variable. If all your instances have the same value for var, Foo is a good way to accomplish this. If they are all different, the Bar is the way to go. You can also mix them if several of the instances use the same value 'lala' but some need 'lele' or sometime later in the life of the instance the value will be changed to 'lele' class Bletch: var = 'lala' def update(self): self.var = 'lele' In this case it is a matter of taste whether you use the Foo or the Bar way. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Unpack less values from function's return values
Chris Rebert wrote: On Thu, May 28, 2009 at 3:19 AM, dudeja.ra...@gmail.com wrote: Hi, I'm using Python 2.5.2. I'm getting this error whenever I try to unpack less values from a function. ValueError: too many values to unpack I want to know if there is a way I can unpack less values returning from a function? Unpack them into throwaway variables: def foo(): return 1,2,3,4 a, b, _, _ = foo() In very new Python, you can also do: a, b, *_ = foo() Or: a, b = foo()[ : 2] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Tkinter and popen problem
norseman wrote: [snip] I have tried both and Popen2.popen2(). os.popen runs both way, contrary to docs. # master.py import os #both lines work same #xx= os.popen(/mnt/mass/py/z6.py).readlines() xx= os.popen(/mnt/mass/py/z6.py,'r',1).readlines() readlines() returns only when all the lines have been read, which is when the child quits and the pipe closes. Try reading only one line at a time. When the pipe closes the readline() will return ''. #I had hoped small buffer would force a sync (flush()) #No such luck. for i in xx: print \t+i[:-1] # # end of file The \t is to prove where the screen output came from. From Peter __pete...@web.de Nonsense. The minimal Tkinter program is from Tkinter import Tk root = Tk() root.mainloop() Just to be clear, that's as much a minimal program as [snip] # child.py import os import sys import array from array import * import Tkinter from Tkinter import * from Tkconstants import * # def AttPanel(): def PlaceIt(): sys.stdout.write( Switching to ESRI for placement\n) sys.stdout.flush() sys.stdout.flush() No need to flush twice in a row. #print Switching to ESRI for placement ##zatt= bl_x+bl_y+acrs+c1+c2[2:]+c3[2:]+'\n' zatt='123456\n' #print zatt sys.stdout.write(zatt) sys.stdout.flush() #set system variable to zatt root.withdraw() #root.iconify() while raw_input() != ' ': pass root.deiconify() def CRASH(): print \nCRASH Initiated\n exit(1) # root = Tk() LU = Frame(root) LU.pack(fill=both, expand=1) f1 = Frame(LU, relief = GROOVE, bd = 2) f1.grid(row = 0, column = 0) Button(f1, width= 45, state= DISABLED).grid(row= 0, column= 0) Button(f1, text= Place Attribute, fg= black, bg= green, anchor= N, command = PlaceIt).grid(row = 0, column = 1) Button(f1, width= 45, state= DISABLED).grid(row= 0, column= 2) Button(f1, text= Cancel Attributing, fg= white, bg= red, anchor= E, command= CRASH).grid(row = 0, column = 3) f1.pack() # root.mainloop() #---# if __name__ == __main__: while TRUE: AttPanel() -- http://mail.python.org/mailman/listinfo/python-list
How do you serve Cheetah in production? webpy+cheetah
How do you serve *Cheetah* in *production*? Guys can you share the setup on how to precompile and serve cheetah in production Since we dont compile templates in webpy it is getting upstream time out errors. If you could share a good best practise it would help * Jeremy jeremy.ja...@gmail.com wrote: For a production site, I use Cheetah with pre-compiled templates - it's very fast (the templates import especially quickly when python compiled and optimised). A bit of magic with the imp module takes a template name and a base directory (configured in a site-specific config) and loads up that template, taking care of #extends and import directives as appropriate. I don't use the built-in support for Cheetah, however. The new template library is also only imported to display the debugerror page -- Bidegg worlds best auction site http://bidegg.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python list pattern matching?
On Thu, May 28, 2009 at 3:57 PM, Terry Reedy tjre...@udel.edu wrote: guthrie wrote: I want to do a functional like pattern match to get teh first two elements, and then the rest of an array return value. For example, assume that perms(x) returns a list of values, and I want to do this: seq=perms(x) a = seq[0] b = seq[1] rest = seq[2:] Of course I can shorten to: [a,b] = seq[0:2] rest = seq[2:] Can I find use some notation to do this? [a,b,more] = perms(x) or conceptually: [a,b,more..] = perms(x) a,b,*rest = list(range(10)) a,b,rest (0, 1, [2, 3, 4, 5, 6, 7, 8, 9]) a,*rest,b = 'abcdefgh' a,rest,b ('a', ['b', 'c', 'd', 'e', 'f', 'g'], 'h') Note that this snazzy new syntax requires Python 3.0+ Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter file dialog
On Thu, May 28, 2009 at 7:48 PM, Ronn Ross ronn.r...@gmail.com wrote: I'm using Tkinter file selector to get a direcotry path. I'm using: self.file = tkFileDialog.askdirectory(title=Please select your directory) print file but all it prints out is: type 'file' How would I print the directory path? print self.file Your forgot the self. in your version. Without it, Python assumes you're talking about built-in `file` type. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
PYTHONPATH var
Hi guys. I have a question regarding runtime definition of the variable PYTHONPATH. Do you know how without modifying of source code change the value for this var. Value stores in the system var sys.path, but the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. We need to change this value which allows to us import scripts first from directory containing newest hotfix scripts without replacing original project scripts. One of the variant is to create script which will modify this var and insert line with import this script into each project script. So the question does another way exist? For example, parameter or argument for python launcher. -- http://mail.python.org/mailman/listinfo/python-list
PYTHONPATH var
Hi guys. I have a question regarding runtime definition of the variable PYTHONPATH. Do you know how without modifying of source code change the value for this var. Value stores in the system var sys.path, but the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. We need to change this value which allows to us import scripts first from directory containing newest hotfix scripts without replacing original project scripts. One of the variant is to create script which will modify this var and insert line with import this script into each project script. So the question does another way exist? For example, parameter or argument for python launcher. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter file dialog
Ronn Ross wrote: I'm using Tkinter file selector to get a direcotry path. I'm using: self.file = tkFileDialog.askdirectory(title=Please select your directory) print file but all it prints out is: type 'file' How would I print the directory path? try doing: self.filename = tkFileDialog.askopenfilename(title = 'this is a message',initialdir='./' ) and see what happens - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter file dialog
Ronn Ross wrote: I'm using Tkinter file selector to get a direcotry path. I'm using: self.file = tkFileDialog.askdirectory(title=Please select your directory) print file but all it prints out is: type 'file' How would I print the directory path? Perhaps you meant: self.file = tkFileDialog.askdirectory(title=Please select your directory) print self.file -- http://mail.python.org/mailman/listinfo/python-list
Re: extract to dictionaries
Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron gher...@islandtraining.comwrote: Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same for parameters2. I would appreciate any help that could help me solve this. Thank you This looks like a homework problem. It's not. I'm passed homework age. But even if it's not, you are not likely to find someone who is willing to put more work into this problem than you have. So why don't you show us what you've tried, and see if someone is willing to make suggestions or answer specific question about your attempt at a solution? I don't now if posting a code that gets into a while loop and never stops would demonstrate to you that I've tried. Be assured that before posting to the list I did try to solve it myself, because I knew that I might get an answer like RTFM or similar. Maybe I'm not smart enough, but I can't make python to start reading after the parameter1 line and stop at the end line. That's all I want a small piece of pseudocode to do just that. Thanks Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: Global variables from a class
Hello, First thing is a class variable (one for every instance) and second one an instance variable (one per instance). For further information, please take a look at: http://diveintopython.org/object_oriented_framework/class_attributes.html Best regards, Javier 2009/5/29 Kless jonas@googlemail.com: I usually use a class to access to global variables. So, which would be the correct way to set them --since the following classes--: class Foo: var = 'lala' class Bar: def __init__(self): self.var = 'lele' Or is it the same? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: FILE object in Python3.0 extension modules
Joachim Dahl dahl.joachim at gmail.com writes: How do I perform type checking for such an object in the extension module, and how do I extract a FILE * object from it? I browsed the C API documentation, but couldn't find an answer. You use PyObject_IsInstance to test if the object is an instance of io.IOBase. -- http://mail.python.org/mailman/listinfo/python-list
Re: extract to dictionaries
On Fri, 29 May 2009 11:44:30 +0100, Marius Retegan marius.s.rete...@gmail.com wrote: Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron gher...@islandtraining.comwrote: Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same for parameters2. I would appreciate any help that could help me solve this. Thank you This looks like a homework problem. It's not. I'm passed homework age. But even if it's not, you are not likely to find someone who is willing to put more work into this problem than you have. So why don't you show us what you've tried, and see if someone is willing to make suggestions or answer specific question about your attempt at a solution? I don't now if posting a code that gets into a while loop and never stops would demonstrate to you that I've tried. It would have. At the very least, it would have told us that you've missed a common idiom. Be assured that before posting to the list I did try to solve it myself, because I knew that I might get an answer like RTFM or similar. Not posting code (or code snippets at least) makes it more likely that you'll be told to RTFM, you do realise! Maybe I'm not smart enough, but I can't make python to start reading after the parameter1 line and stop at the end line. That's all I want a small piece of pseudocode to do just that. I'd be tempted to do it like this dict_of_dicts = {} current_dict = {} current_name = dummy f = open(filename) for line in f: # Do something to skip blank lines if line == '\n': continue # A normal 'key value' pair? if line.startswith(' '): # Yup. Split apart the key and value, # and add them to the current dictionary current_dict.update([line.split()]) elif line == 'end': # Wrap up what we've got and save the dictionary dict_of_dicts[current_name] = current_dict current_name = dummy current_dict = {} else: # New section. Really ought to whinge if # we haven't ended the old section. current_name = line.strip() current_dict = {} You can then pull the parameter sets you want out of dict_of_dicts (you can probably think of a more meaningful name for it, but I don't know the context you're working in). In real code I would use regular expressions rather than `startswith` and the equality because they cope more easily with tabs, newlines and other 'invisible' whitespace. -- Rhodri James *-* Wildebeeste Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Re: extract to dictionaries
On Fri, 29 May 2009 13:10:47 +0100, Rhodri James rho...@wildebst.demon.co.uk wrote: current_name = dummy Gah! I meant, of course, current_name = 'dummy' -- Rhodri James *-* Wildebeeste Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem building 64-bit python 2.6.2 on Solaris 10
On May 28, 6:03 pm, Martin v. Löwis mar...@v.loewis.de wrote: I think the problem is it should be built with v9.S for 64-bit, not v8.S. Is that correct? If so, how do I get it to use the right one? The Solaris dynamic loader can't find it. Set LD_LIBRARY_PATH or LD_RUN_PATH appropriately, or use crle(8). Regards, Martin Hi Martin, I'm not sure I understand. It appears that cc is compiling the wrong module, v8.S. It should be compiling v9.S. The errors are being reported by fbe, the Sun Studio assembler, not ld. I think there must be a place to specify which I want to use, but I don't understand the python build environment well enough to know where to do it. You may be right about the first error. It's being reported by ld, but -L/opt/openssl/lib/sparcv9 -R/opt/openssl/lib/sparcv9 are being passed to cc. It is able to find -lssl -lcrypto, but I think python itself doesn't use the openssl libraries. Since I see the chain ld.so.1: python: fatal: libssl.so.0.9.8: open failed: No such file or directory, which I think means python itself doesn't know where they are at. I checked python libpython.so with ldd neither uses libssl.so. It seems to me there should be another way to tell python where to find it to build the module. Does this make sense? Thanks for your help. -John -- http://mail.python.org/mailman/listinfo/python-list
Re: Global variables from a class
On Fri, 29 May 2009 12:04:53 +0200, Javier Collado wrote: Hello, First thing is a class variable (one for every instance) and second one an instance variable (one per instance). One of these things don't belong: A string variable is a variable holding a string. A float variable is a variable holding a float. An int variable is a variable holding an int. A list variable is a variable holding a list. A class variable is an attribute of a class object, holding an object of arbitrary type, which is shared by all instances of the class. Please don't use the term class variable to mean class attribute. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: formating query with empty parameter
In article mailman.717.1243258005.8015.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: To stave off this problem, I often use: values = [ data['a'], data['b'], data['c'], data['d'], data['e'], data['f'], data['g'], ] params = ', '.join('%s' for _ in values) query = BEGIN; INSERT INTO table (a,b,c,d,e,f,g) VALUES (%s); COMMIT; % params self.db.execute(query, values) How do you handle correct SQL escaping? -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ my-python-code-runs-5x-faster-this-month-thanks-to-dumping-$2K- on-a-new-machine-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list
Syntax highlighting, round 42 (was Re: What text editor is everyone using for Python)
In article gvg5d7$38...@lust.ihug.co.nz, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message pan.2009.05.26.06.39...@remove.this.cybersource.com.au, Steven D'Aprano wrote: On Tue, 26 May 2009 18:31:56 +1200, Lawrence D'Oliveiro wrote: In message d6d05d39-98e7-4c28- b201-4b2445732...@v35g2000pro.googlegroups.com, LittleGrasshopper wrote: ... I am looking for suitable syntax files for [editor of choice] ... I don't understand why people need syntax files to use a text editor. Do you want syntax highlighting? Why? Didn't we have this discussion just a few weeks ago, when I said that highlighting made my eyes bleed? [] Oh, Gooja sez that we did it at the beginning of February, so almost four months. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ my-python-code-runs-5x-faster-this-month-thanks-to-dumping-$2K- on-a-new-machine-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Global variables from a class
Kless wrote: I usually use a class to access to global variables. So, which would be the correct way to set them --since the following classes--: class Foo: var = 'lala' class Bar: def __init__(self): self.var = 'lele' Or is it the same? This form is the most suited for what your doing: class Foo: var = 'lala' It is a good practice to place your globals into a class (making them non global by the way). It helps also writing good documentation in docstrings. I would add: class Foo: Hold the secrets of eternity var = 'lala' One variable ANY_CONSTANT = 14 The universal answer to all questions Having strong naming convention also helps a lot. Jean-Michel PS: FYI, in the second form, var is an instance variable, and you need to create an instance to access it = Bar().var while Foo.var is enough for the first form. -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHONPATH var
On Fri, 29 May 2009 03:50:54 -0700, insfor wrote: Hi guys. I have a question regarding runtime definition of the variable PYTHONPATH. Do you know how without modifying of source code change the value for this var. Syntax error: sentence seems to be a question, but is missing a question mark. To answer your question, PYTHONPATH is an environment variable. You set it in your shell. For example, I use the bash shell under Linux, and in my .bashrc file I have this line: export PYTHONPATH=/home/steve/python/ Every time I log in, the shell sets the environment variable to the pathname /home/steve/python/, and then when Python runs, it appends that path to sys.path. I don't have to modify any Python source code. Value stores in the system var sys.path, but the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. We need to change this value which allows to us import scripts first from directory containing newest hotfix scripts without replacing original project scripts. One of the variant is to create script which will modify this var and insert line with import this script into each project script. So the question does another way exist? For example, parameter or argument for python launcher. I don't understand what you are actually trying to say here. Perhaps you can explain a little bit more carefully? However, trying to guess what you want, PYTHONPATH doesn't *replace* sys.path, it appends to the end of it. This is usually the right thing to do. However, sys.path is an ordinary list. If you want to modify it, you can do so: import sys sys.path[0] = '/some/other/path' -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Parsing DTDs
Hello! I would like to parse XML DTDs. The goal is to be able to validate XML-like object structures against DTDs in a fairly flexible way, although i can get from a parsed DTD to a validation engine myself, so that's not an essential feature of the parser (although it would be nice!). What should i do? A bit of googling revealed that the xmlproc package contains a DTD parser that looks like it does just what i want, and that xmlproc became PyXML, and that PyXML is no longer maintained. Is there a DTD parser that is being maintained? Or does it not really matter that PyXML is no longer maintained, given that it's not like the DTD spec has changed very much? Thanks, tom -- Many of us adopted the File's slang as our own, feeling that we'd found a tangible sign of the community of minds we'd half-guessed to be out there. -- http://mail.python.org/mailman/listinfo/python-list
pygame error: file is not a windows bmp file
Hello, all! pygame error: file is not a windows bmp file I couldn't found a solution for this problem. My python script run fine in local machine using cxfreeze, but don't work when copied to my live linux system. If I put bmp image, works fine, but png don't. Can you help me? (and sorry my terrible english). -- Djames Suhanko LinuxUser 158.760 -- http://mail.python.org/mailman/listinfo/python-list
Re: Deletion/record visibility error in PG with Python...
Hi! Sorry for rtfm mail... I forgot to remove max_usage param in my real application... This parameter is limiting the number of cursor usage, and if max reached, the DBUtils is automatically open a new cursor in the background! This is break out of the actual transaction context... Uh I wasted 2 hours to found the bug in another source... :-( dd 2009/5/28 Durumdara durumd...@gmail.com Hi! PGSQL makes me crazy... I port my apps to PGSQL, and I near to finish - but I got this problem... Params: PGSQL 8.3, Windows, Pylons, PGDB, DBUTILS... What happened? How I can avoid the cursor changing? How to fix it in my transaction? I never ask for new cursor, I used same variable in all of my context (self.Cur)... :-( So what is the solution? Drop DBUtils? Or what? Thanks for your help: dd -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHONPATH var
Sergey Dikovitsky wrote: Hi guys. I have a question regarding runtime definition of the variable PYTHONPATH. Do you know how without modifying of source code change the value for this var. Value stores in the system var sys.path, but the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. We need to change this value which allows to us import scripts first from directory containing newest hotfix scripts without replacing original project scripts. One of the variant is to create script which will modify this var and insert line with import this script into each project script. So the question does another way exist? For example, parameter or argument for python launcher. I have to guess much of what you're talking about. So if this is way off, try responding with a clearer wording. PYTHONPATH is an environment variable. You change that using your operating system's scripting language (shell script). But you're talking about changing the first entry in sys.path, a Python list, which is generated from PYTHONPATH and a few other sources. So it must be changed as Python is starting, not in the shell. It is an ordinary list, and may be changed in the usual way. So a script could start with: import sys sys.path = [newpath] + sys.path (although you'd probably want to use a variable, not a literal) But you say without modifying of source code. Not clear what that means, without you qualifying just which source code is sacrosanct. It seems you're trying to change the search order for the initial script. But there is no search order. You give an actual filename to the interpreter, and it does not search at all. So perhaps what you really want is to modify the PATH variable before running the script. Then the operating system will search for it before trying to execute it. This should work as long as you don't need any other switches on the python.exe command line. You need to specify your system environment (Windows, Linux, ...), and probably your Python version. And make it clearer what your real goal is. -- http://mail.python.org/mailman/listinfo/python-list
Re: Global variables from a class
You're right. I agree on that it's important to use proper words. Thanks for the correction. Best regards, Javier 2009/5/29 Steven D'Aprano st...@remove-this-cybersource.com.au: On Fri, 29 May 2009 12:04:53 +0200, Javier Collado wrote: Hello, First thing is a class variable (one for every instance) and second one an instance variable (one per instance). One of these things don't belong: A string variable is a variable holding a string. A float variable is a variable holding a float. An int variable is a variable holding an int. A list variable is a variable holding a list. A class variable is an attribute of a class object, holding an object of arbitrary type, which is shared by all instances of the class. Please don't use the term class variable to mean class attribute. -- Steven -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: what I would like python.el to do (and maybe it does)
Piet van Oostrum p...@cs.uu.nl writes: J Kenneth King ja...@agentultra.com (JKK) wrote: JKK I find that it does work, but unlike SLIME for lisp, it just imports the statement. JKK It confused me at first, but basically the interpreter doesn't provide JKK any feedback to emacs. JKK Try opening a python source file (start python-mode if you don't have JKK an autoload hook) and do C-c C-z to bring up the Python JKK interpreter. Type in a simple assignment statement (like a = 1 + 2 JKK without the quotes) into the source file. Then just C-c C-c as JKK usual. I never get any feedback. Just C-x o to the interpreter and JKK print out the variable you just defined. It should be there. What kind of feedback do you expect? Well, that's the thing -- type a statement into a python interpreter and you just get a new prompt. LISP has a REPL, so you get some sort of feedback printed. However, some sort of visual cue on the emacs side would be nice. Either just flash the block of code being sent or a minibuffer message would be nice. Look for some SLIME tutorial videos on youtube to see some great interpreter - editor interaction. The stock Python interpreter probably wouldn't cut it close to something like SLIME in terms of features, but the iPython package might be a start. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to change response code in CGIHTTPServer.py
On May 28, 2:23 pm, Daniel daniel.watr...@gmail.com wrote: Hello, Python 2.5.2 WinXP I'm using CGIHTTPServer.py and want to return a response code of 400 with a message in the event that the cgi script fails for some reason. I notice that run_cgi(self): executes this line of code, self.send_response(200, Script output follows) which overwrites any headers that I print in my cgi. Is there some way to modify the response code without having to override CGIHTTPServer.py? Thanks, help (CGIHTTPServer) ... Note that status code 200 is sent prior to execution of a CGI script, so scripts cannot send other status codes such as 302 (redirect). ... It sets that header before it even fires off the CGI script and just pipes the following response to the client. -- http://mail.python.org/mailman/listinfo/python-list
Re: try except inside exec
On May 29, 8:21 am, Michele Petrazzo michele.petra...@remove_me_unipex.it wrote: Hi all, I want to execute a python code inside a string and so I use the exec statement. The strange thing is that the try/except couple don't catch the exception and so it return to the main code. Is there a solution to convert or make this code work? Thanks, Michele My code: STR = err = 0 try: def a_funct(): 1/0 except: import traceback err = traceback.format_exc() env = {} exec STR in env env[a_funct]() print env[err] My error: File tmp/test_exec.py, line 14, in module env[a_funct]() File string, line 5, in a_funct ZeroDivisionError: integer division or modulo by zero The code you posted defines a function, and if the definition of it raises an exception, it will enter your except clause. By the way, you generally should avoid 'bare' except clauses, and specify the type of error you want to catch, in this case, 'ZeroDivisionError', as you see (just good practice stuff). It's not clear from your attempt what your exact goal was. You probably mean: STR = class Globals: err = 0 def a_funct(): try: 1/0 except ZeroDivisionError: import traceback Globals.err = traceback.format_exc() Note that the formatted exception will be available in 'env [Globals].err'. But you could also mean: exec STR in env try: env[a_funct]() except ZeroDivisionError: import traceback err = traceback.format_exc() Then the formatted exception will be available in 'err'. Do you want the exception-handling to be part of the function you are entering into 'env'? -- http://mail.python.org/mailman/listinfo/python-list
Re: extract to dictionaries
Marius Retegan wrote: Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron gher...@islandtraining.com mailto:gher...@islandtraining.com wrote: Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same for parameters2. I would appreciate any help that could help me solve this. Thank you This looks like a homework problem. It's not. I'm passed homework age. But even if it's not, you are not likely to find someone who is willing to put more work into this problem than you have. So why don't you show us what you've tried, and see if someone is willing to make suggestions or answer specific question about your attempt at a solution? I don't now if posting a code that gets into a while loop and never stops would demonstrate to you that I've tried. Be assured that before posting to the list I did try to solve it myself, because I knew that I might get an answer like RTFM or similar. Maybe I'm not smart enough, but I can't make python to start reading after the parameter1 line and stop at the end line. That's all I want a small piece of pseudocode to do just that. OK. Assuming you are open a file with something like: f = open('data', 'r') Then this will read lines up to the first parameters line for line in f: if line.startswith('parameters'): break At this point, line contains 'parameters1\n'. Do with it as you will. Then read and process lines until an end line is reached for line in f: if line.beginswith('end'): break # Here line contains 'key1 value1\n'. # Perhaps use line.strip to remove the white space on each end # and k,v =line.split() to split out the two values on the line. You'll need more: A loop to keep the above two going until the end of file A way to recognize the end of the file. Gary Herron Thanks Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: Network programming ?
In article ce229a0d-4ebe-4e42-8638-4b1ee1dbd...@z5g2000vba.googlegroups.com, thushiantha...@gmail.com wrote: I am planning to develop a chatting software in Python, for my college project. I am using Windows Vista. Is it possible to do sockets programming in Python ? Any books or websites ? Also, i want to develop a gui for that program. What are the gui tool kits available for windows? I already knew about PyGtk and PyQT, but will they work properly in Windows platform? Any suggestions? You likely want to use Twisted, you should at least investigate it. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ my-python-code-runs-5x-faster-this-month-thanks-to-dumping-$2K- on-a-new-machine-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list
Re: formating query with empty parameter
In article mailman.892.1243603377.8015.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: Aahz wrote: Tim Chase python.l...@tim.thechases.com wrote: To stave off this problem, I often use: values = [ data['a'], data['b'], data['c'], data['d'], data['e'], data['f'], data['g'], ] params = ', '.join('%s' for _ in values) query = BEGIN; INSERT INTO table (a,b,c,d,e,f,g) VALUES (%s); COMMIT; % params self.db.execute(query, values) How do you handle correct SQL escaping? If you dump query, you see that params (possibly a better name would be place_holders) is merely a list of %s, %s, %s, ..., %s allowing the execute(query, ***values***) to properly escape the values. The aim is to ensure that count(placeholders) == len(values) which the OP mentioned was the problem. Right, that's what I get for reading code early in the morning. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ my-python-code-runs-5x-faster-this-month-thanks-to-dumping-$2K- on-a-new-machine-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list
Re: extract to dictionaries
On 5/28/2009 4:03 PM Marius Retegan said... Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same for parameters2. I woud appreciate any help that could help me solve this. Thank you Assuming you've read the above into paramFile... for dictvals in [xx.split() for xx in paramFile.split(end) if xx]: locals()[dictvals[0]]=dict(zip(dictvals[1::2],dictvals[2::2])) You-can't-really-call-this-helping-ly yrs, Emile -- http://mail.python.org/mailman/listinfo/python-list
PyPy Europython Sprint Announcement
== Birmingham (UK) EuroPython PyPy Sprints 28-29 June/ 3-4 July 2009 == The PyPy team is sprinting at EuroPython again. This year there are `sprint days`_ before (28-29 June) and after (3-4 July) the conference. Some PyPy core people should be present during both periods. .. _`sprint days`: http://wiki.europython.eu/Sprints If you plan to attend the sprints after the conference we recommend you to listen to the PyPy technical talk (`EuroPython schedule`_) during the conference since it will give you a good overview of the status of development. Goals and topics of the sprint -- There are many possible and interesting sprint topics to work on - here we list some possible task areas: - trying out software on PyPy's Python interpreter: the CPython test suite is not all that complete, therefore the fact that we pass most tests is no real indication of bug-freeness. We have tried and know that frameworks like Django and Twisted work with PyPy. Therefore we would like to try running more real applications on top of the Python interpreter (ideally ones that have a good test suite themselves and that don't need unusual extension modules). Running things on Windows is also interesting, we know our coverage there is not as good as on Linux. - check and improve Mac OS X support - starting to work on porting 2.6 features to PyPy's Python interpreter - ongoing JIT generator work - of course we are open to other ideas for what to work on. Examples could be working on other language interpreters, sandboxing, ... Registration If you'd like to come, please subscribe to the `pypy-sprint mailing list`_ and drop a note about your interests and post any questions. More organisational information will be sent to that list. Please register by adding yourself on the following list (via svn): http://codespeak.net/svn/pypy/extradoc/sprintinfo/ep2009/people.txt or on the pypy-sprint mailing list if you do not yet have check-in rights: http://codespeak.net/mailman/listinfo/pypy-sprint --- Preparation (if you feel it is needed): --- - read the `getting-started`_ pages on http://codespeak.net/pypy, especially also the `development of PyPy itself part`_ . - for inspiration, overview and technical status you are welcome to read `the technical reports available and other relevant documentation`_ - please direct any technical and/or development oriented questions to pypy-dev at codespeak.net and any sprint organizing/logistical questions to pypy-sprint at codespeak.net - if you need information about the conference, potential hotels, directions etc we recommend to look at http://www.europython.eu. We are looking forward to meet you at the EuroPython PyPy sprints! The PyPy team .. See also .. .. _getting-started: http://codespeak.net/pypy/dist/pypy/doc/getting-started.html .. _`development of PyPy itself part`: http://codespeak.net/pypy/dist/pypy/doc/getting-started-dev.html .. _`pypy-sprint mailing list`: http://codespeak.net/mailman/listinfo/pypy-sprint .. _`the technical reports available and other relevant documentation`: http://codespeak.net/pypy/dist/pypy/doc/docindex.html .. _`EuroPython schedule`: http://europython.eu/talks/timetable -- http://mail.python.org/mailman/listinfo/python-list
Re: try except inside exec
On Fri, May 29, 2009 at 11:55 AM, Michele Petrazzo michele.petra...@remove_me_unipex.it wrote: My goal is to execute a function received from a third-part, so I cannot modify as you made in your first piece of code. I want a clean exception with the real line code/tb so I can show a real error message. This means that the try/execpt has to include the passed function and catch every possible exception. Do you have any ideas on how can I figure this out? Is the thirdparty function the entire STR or just the a_funct part? -- David blog: http://www.traceback.org twitter: http://twitter.com/dstanek -- http://mail.python.org/mailman/listinfo/python-list
Re: What text editor is everyone using for Python
I am a long time VIM user, and I likely will not change that. The speed, ease of use and functionality, for me, is worth the time spent learning how to use it. My secondary editor on the desktop is UltraEdit, which does a fine job as a text editor and has all the same functionality of VIM - yet despite 2 years on it (they won't allow me GVIM at work), I can't get to the same level of productivity with it as I can with VIM. Ditto Eclipse... I spent more time figuring out how to get a program to run properly than coding. The limited autocomplete and function jump-list were not worth the pain of getting it working, IMO. On May 29, 2:01 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: (1) Closed source editors have the same functional requirements as open source editors. (2) If you're waiting for perfection, you'll be waiting forever. (3) Why independent of the OS? When is the last time you've used a system without an OS? Forth programmers in the 1970s used an editor that was OS independent -- it managed files using its own unique file structure, managed memory itself, etc. Why do you want to go back there? As to your points, Steven: 1) I would agree with this point. VI and it's children were written to a different interpretation of said rules, however. They were built around the speed at which a human can use a keyboard with natural finger movements, at the expense of discoverability and intuitiveness. 2) VIM may not be perfect, but it's really darned close. ;-) 3) OS independence, IMO, is related more to the ability to use the tool on every OS, rather than on the lack of an OS. -- http://mail.python.org/mailman/listinfo/python-list
Python-URL! - weekly Python news and links (May 29)
QOTW: Death To Wildcard Imports - Lawrence D'Oliveiro http://groups.google.com/group/comp.lang.python/msg/835cf7f35ed f4897 How to ask questions having a chance of being answered: http://groups.google.com/group/comp.lang.python/t/17b15282d07770d1/ Multiprocessing and memory usage: http://groups.google.com/group/comp.lang.python/t/4c9c5805aadd833d/ Of backslashes and raw string literals: http://groups.google.com/group/comp.lang.python/t/dd18130f9f379974/ How does OOP feel in Python? http://groups.google.com/group/comp.lang.python/t/2cf2e3c9c1df4e8b/ Sockets: how to reuse the same port quickly http://groups.google.com/group/comp.lang.python/t/82204fb9d10d38aa/ Tools to optmize math functions: http://groups.google.com/group/comp.lang.python/t/2b34fd6c43be79d6/ Replacing module with a stub for unit testing: http://groups.google.com/group/comp.lang.python/t/023dff1ec533f101/ Sometimes it's better to use delegation instead of inheritance: http://groups.google.com/group/comp.lang.python/t/86674e06fc14c6a6/ Inserting NULL values in a database: http://groups.google.com/group/comp.lang.python/t/3c3ccdbfe1bc5a45/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish the efforts of Python enthusiasts: http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/group/comp.lang.python.announce/topics Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donations/ The Summary of Python Tracker Issues is an automatically generated report summarizing new bugs, closed ones, and patch submissions. http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.comp.python.develsort=date Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://code.activestate.com/recipes/langs/python/ Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available, see: http://www.python.org/channews.rdf For more, see: http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all The old Python To-Do List now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470group_id=5470func=browse http://www.python.org/dev/peps/pep-0042/ del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python Enjoy the *Python Magazine*. http://pymag.phparch.com/ *Py: the Journal of the Python Language* http://www.pyzine.com Dr.Dobb's Portal is another source of Python
Trying to get cleaner XML output from a text file
I'm using Python2.5 to try and convert some text files into XML using xml.minidom. I'm currently doing some plays which have a structure like Scene 1 Act 1 blah blah Act2 blah blah Scene 2 Act 1 and so on. I'm trying to turn it into div type=scene1 div type=act1 speech / /div div type=act2 speech / /div /div (or ideally div type=scene id=1 bit I can always come back to this later) I've currently got: div id= type=scene div id= type=act speech II /speech /div /div div id= type=scene div id= type=act speech II /speech /div /div div id= type=scene div id= type=act The code I'm currently working with is: from itertools import groupby from xml.dom.minidom import Document import re text = open('\\texts\\midsummer_nights_dream_gut.txt').read() def paragraphs(lines, is_separator=str.isspace, joiner=''.join): for separator_group, lineiter in groupby(lines, key=is_separator): if not separator_group: yield joiner(lineiter) def scene_node(scene): global docText docText = doc.createElement(div) #need to set the type to book, verse, drama docText.setAttribute(type, scene) #need set the id to what ever break name or id: i.e. chapter 1 or act 1 docText.setAttribute(id, '') tei.appendChild(docText) for acts in actTxt.split(scene): act_node(acts) def act_node(act): global actText actText = doc.createElement(div) #need to set the type to book, verse, drama actText.setAttribute(type, act) #need set the id to what ever id: 1 or I actText.setAttribute(id, ' ') docText.appendChild(actText) for p in paragraphs(act.splitlines(True)): speech_node(p) def speech_node(speech): para = doc.createElement(speech) actText.appendChild(para) ptext = doc.createTextNode(speech) para.appendChild(ptext) doc = Document() tei = doc.createElement(body) doc.appendChild(tei) sideTxt = re.compile(rScene\s+([1-9]), re.I) actTxt = re.compile(rAct\s+([1-9]), re.I) for textStr in sideTxt.split(text): scene_node(textStr) print doc.toprettyxml(indent = ) I'd be grateful for some pointers about getting a cleaner output. Thanks, Iain -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing DTDs
Tom Anderson t...@urchin.earth.li (TA) wrote: TA Hello! TA I would like to parse XML DTDs. The goal is to be able to validate XML-like TA object structures against DTDs in a fairly flexible way, although i can get TA from a parsed DTD to a validation engine myself, so that's not an essential TA feature of the parser (although it would be nice!). What should i do? TA A bit of googling revealed that the xmlproc package contains a DTD parser TA that looks like it does just what i want, and that xmlproc became PyXML, TA and that PyXML is no longer maintained. TA Is there a DTD parser that is being maintained? Or does it not really TA matter that PyXML is no longer maintained, given that it's not like the DTD TA spec has changed very much? http://codespeak.net/lxml/validation.html#dtd -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: python list pattern matching?
Peter Otten wrote: Terry Reedy wrote: a,b,*rest = list(range(10)) The list() call is superfluous. Agreed, even in Py3 when range() returns a range object rather than a list. -- http://mail.python.org/mailman/listinfo/python-list
Re: try except inside exec
On May 29, 9:55 am, Michele Petrazzo michele.petra...@remove_me_unipex.it wrote: Aaron Brady wrote: STR = class Globals: err = 0 def a_funct(): try: 1/0 except ZeroDivisionError: import traceback Globals.err = traceback.format_exc() exec STR in env try: env[a_funct]() except ZeroDivisionError: import traceback err = traceback.format_exc() Then the formatted exception will be available in 'err'. Do you want the exception-handling to be part of the function you are entering into 'env'? My goal is to execute a function received from a third-part, so I cannot modify as you made in your first piece of code. I want a clean exception with the real line code/tb so I can show a real error message. This means that the try/execpt has to include the passed function and catch every possible exception. Do you have any ideas on how can I figure this out? Thanks, Michele Exceptions are only caught when raised in a 'try' statement. If you don't raise the exception in a try statement, it won't be caught. The function you posted will raise an exception. If you are making the call yourself, that is, if only the definition is foreign, then simply catch exceptions when so. Otherwise, my only idea so far is to use the 'ast' module to inject an exception handler into the third-party function. That is quite advanced and may be error-prone, though I think it would look something like this: for every 'def' statement in STR: def_statement.body= try_statement + def_statement.body I expect it would be more reliable than hand-parsing the text and concatenating a string exception statement. Any interest in this, or do you make the call yourself? -- http://mail.python.org/mailman/listinfo/python-list
Questions about regex
Hello, I'm new to python and I'm having problems with a regular expression. I use textmate as my editor and when I run the regex in textmate it works fine, but when I run it as part of the script it freezes. Could anyone help me figure out why this is happening and how to fix it. Here is the script: == # regular expression search and replace import sys, os, re, string, csv #Open the file and taking its data myfile=open('Steve_query3.csv') #Steve_query_test.csv #create an error flag to loop the script twice #store all file's data in the string object 'text' myfile.seek(0) text = myfile.read() for i in range(2): #def textParse(text, reRun): print 'how many times is this getting executed', i #Now to create the newfile 'test' and write our 'text' newfile = open('Steve_query3_out.csv', 'w') #open the new file and set it with 'w' for write #loop trough 'text' clean them up and write them into the 'newfile' #sub( pattern, repl, string[, count]) #sub((?i)b+, x, ) returns 'x x'. text = re.sub('(\(/?[^\]+)\)', , text)#remove the HTML text = re.sub('/!--(.|\s)*?--/', , text) #remove comments !--[^ \-]+-- text = re.sub('\/\*(.|\s)*?;}', , text) #remove css formatting #remove a bunch of word formatting yuck text = re.sub(nbsp;, , text) text = re.sub(lt;, , text) text = re.sub(gt;, , text) text = re.sub(quot;|rquot;|ldquo;, \', text) #=== #The two following lines are the ones giving me the problems text = re.sub(w:(.|\s)*?\n, , text) text = re.sub(UnhideWhenUsed=(.|\s)*?\n, , text) #=== text = re.sub(re.compile('^\r?\n?$', re.MULTILINE), '', text) #remove the extra whitespace #now write out the new file and close it newfile.write(text) newfile.close() #open the newfile and run the script again #Open the file and taking its data myfile=open('Steve_query3_out.csv') #Steve_query_test.csv #store all file's data in the string object 'text' myfile.seek(0) text = myfile.read() Thanks for the help, -Jared -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Praxis
Phil Bewig escreveu: Please visit my blog, Programming Praxis, which presents a collection of programming etudes. Newbies will find exercises that extend their programming abilities. Savvy programmers can use the exercises to sharpen their skills or learn a new language. Brave programmers can submit their code to the review of their colleagues. Programming Praxis isn't a contest. No points are awarded, no scores are kept. The exercises simply provide an opportunity to hone your skills; the effort is its own reward. Programming Praxis is available on the web at http://programmingpraxis.wordpress.com. Come join us! It's very good, yes. :) -- a game sig: http://tinyurl.com/d3rxz9 -- http://mail.python.org/mailman/listinfo/python-list
DrPython (Windows) problems
Running DrPython under Linux works great. However, when I run it under Windows: 1) I need to Open programs twice. That's right, File, Open, and select the program. First time, nothing. Repeat, and there's the program! 2) Run I run a program, the execution box comes-up and shows the program output, but it never goes-away. I cannot figure-out how to close this window. -- http://mail.python.org/mailman/listinfo/python-list
NameError function not found
Hey everyone, I am extremely stumped on this. I have 2 functions.. def _determinant(m): return m[0][0] * m[1][1] - m[1][0] * m[0][1] def cofactor(self): Returns the cofactor of a matrix. newmatrix = [] for i, minor in enumerate(self.minors()): newmatrix.append(_determinant(minor.matrix) * ((i%2) * -1)) return newmatrix And I get the following error when I try to run a.cofactor()... NameError: global name '_determinant' is not defined When I put the _determinant function nested within the cofactor function it works fine. Normally I would do this, but a lot of other methods use the _determinant method. They are both in the same class, and they are at the same level, they are even in that order so I know it should be able to see it. I have a lot of functions that call other functions in this class and everything is fine. [Also for the picky, I know my cofactor method isn't mathematically correct yet ;-) ] Am I missing something obvious here? Also if it helps the rest of the code is here http://github.com/dlocpuwons/pymath/blob/d1997329e4473f8f6b5c7f11635dbd719d4a14fa/matrix.py though it is not the latest. -- http://mail.python.org/mailman/listinfo/python-list
Re: NameError function not found
On Fri, 2009-05-29 at 15:13 -0400, Cameron Pulsford wrote: def _determinant(m): return m[0][0] * m[1][1] - m[1][0] * m[0][1] Given that this has no self argument, I'm assuming this is not a class method. def cofactor(self): Returns the cofactor of a matrix. Given that this does, I assume this _is_ a class method. So are you putting _determinant() inside the class? If so, you should either make it method, and invoke it as self._determinant(), or bring it outside the class into the global scope, in which case your code should work. Cheers, Jason. -- http://mail.python.org/mailman/listinfo/python-list
CRLF when doing os.system(ls -l) while using curses !!!
Here is the code and as you can see for yourself, the output is not coming out on the screen with CRLF like it should. How do I fix this? import curses, os screen = curses.initscr() os.system(ls -l) curses.endwin() -- http://mail.python.org/mailman/listinfo/python-list
Re: Replacing module with a stub for unit testing
Try import sys import ExpensiveModuleStub sys.modules['ExpensiveModule'] = ExpensiveModuleStub sys.modules['ExpensiveModule'].__name__ = 'ExpensiveModule' Should do the trick -- Vyacheslav -- http://mail.python.org/mailman/listinfo/python-list
Re: CRLF when doing os.system(ls -l) while using curses !!!
On 5/29/2009 1:34 PM lkenne...@gmail.com said... Here is the code and as you can see for yourself, the output is not coming out on the screen with CRLF like it should. Mine did: [r...@falcon]# python2 Python 2.3.3 (#1, May 11 2004, 14:44:08) [GCC 2.96 2731 (Red Hat Linux 7.1 2.96-85)] on linux2 Type help, copyright, credits or license for more information. import curses, os screen = curses.initscr() os.system(ls -l) total 8 drwxr-xr-x4 root root 4096 Apr 28 14:42 fal drwxr-xr-x4 root root 4096 Apr 28 14:43 home How do I fix this? Provide details on your environment so others can duplicate the error. Emile import curses, os screen = curses.initscr() os.system(ls -l) curses.endwin() -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-mode] What text editor is everyone using for Python
On May 28, 2009, at 7:09 AM, Andreas Roehler wrote: python-mode.el was its bloody-minded determination to regard '_' as a word character, something which caused me more typing that it ever saved. Its just one line to comment in python-mode.el, like this: ;; (modify-syntax-entry ?\_ w py-mode-syntax-table) This one is ancient and I remember that Guido and I talked about this for a long time before settling on the behavior. -Barry PGP.sig Description: This is a digitally signed message part -- http://mail.python.org/mailman/listinfo/python-list
Re: try except inside exec
On May 29, 7:21 am, Michele Petrazzo michele.petra...@remove_me_unipex.it wrote: Hi all, I want to execute a python code inside a string and so I use the exec statement. The strange thing is that the try/except couple don't catch the exception and so it return to the main code. Is there a solution to convert or make this code work? Thanks, Michele My code: STR = err = 0 try: def a_funct(): 1/0 except: import traceback err = traceback.format_exc() env = {} exec STR in env env[a_funct]() print env[err] My error: File tmp/test_exec.py, line 14, in module env[a_funct]() File string, line 5, in a_funct ZeroDivisionError: integer division or modulo by zero -- http://mail.python.org/mailman/listinfo/python-list
[JOB] Plone Developer, Washington, D.C. - Relo OK | 55-75k
Plone Developer, Washington, D.C. - Relo OK | 55-75k shiverat** Government security clearance required ** ** Relocation assistance provided ** My client is seeking a full-time Plone Developer for work with the federal government. The applicant will be responsible for standardizing web formats already in place, ensuring 508 compliance, and deploying content and making both routine and complex changes to the website. In addition, the applicant should have expertise in developing web architectures capable of facilitating complex technical updates as well as managing voluminous materials. The applicant must have substantial experience with developing or enhancing websites in a Web 2.0 environment. Government security clearance required. Required Skills: * High level skills creating and managing application servers * High level skills in the Plone base programming language Python, CPython, and C * Expert skills building Plone content management systems; preferably with government experience Nice to have skills: JavaScript, CSS, HTML, XML, XHTML, Flash, Dreamweaver To be considered, please submit your resume along with your salary requirements to beau at open-source-staffing.com Thank you, Beau J. Gould Open Source Staffing www.open-source-staffing.com beau at open-source-staffing.com http://groups.yahoo.com/group/pythonzopejobs -- http://mail.python.org/mailman/listinfo/python-list
Re: try except inside exec
On May 29, 7:21 am, Michele Petrazzo michele.petra...@remove_me_unipex.it wrote: Hi all, I want to execute a python code inside a string and so I use the exec statement. The strange thing is that the try/except couple don't catch the exception and so it return to the main code. Is there a solution to convert or make this code work? Thanks, Michele My code: STR = err = 0 try: def a_funct(): 1/0 except: import traceback err = traceback.format_exc() The exception isn't being raised because you haven't called the function. It's not an exception to define a function that does a divide by zero, only to execute such a function. env = {} exec STR in env env[a_funct]() Here is where you call the function, thus the exception occurs here. print env[err] This line isn't actually being executed. I'm not sure if you realize that My error: File tmp/test_exec.py, line 14, in module env[a_funct]() File string, line 5, in a_funct ZeroDivisionError: integer division or modulo by zero In general you can't know ahead of time what exceptions a function might raise, so what you are trying to do can't be done. You have to handle the exception at the point where it is called. And from another post: My goal is to execute a function received from a third-part, The only time it's not a gaping security hole to run code supplied by a thrid-party as-is is if the program is running on the third-party's own computer. If you're execing code on your computer that you didn't write or thoroughly verify yourself--and you're obviously not doing that--then you might as well just post your password publicly and say, have at it evil hackers. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: CRLF when doing os.system(ls -l) while using curses !!!
lkenne...@gmail.com (l) wrote: l Here is the code and as you can see for yourself, the output is not l coming out on the screen with CRLF like it should. How do I fix this? Don't use curses. Curses puts the terminal in raw mode (more or less) which doesn't translate the newline character into CRLF. If you use curses you are supposed to do all output through curses. But the os.system goes directly to the screen, outside of curses (because it is another process). You could catch the output of ls -l with a PIPE and then write the output to the curses screen with addstr. But a curses screen has a limited length, whereas your ls -l output may be larger so then you must implement some form of scrolling. l import curses, os l screen = curses.initscr() l os.system(ls -l) l curses.endwin() -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: [JOB] Plone Developer, Washington, D.C. - Relo OK | 55-75k
OSS wrote: Plone Developer, Washington, D.C. - Relo OK | 55-75k You should post this to the Python Jobs board, and not here. http://www.python.org/community/jobs/ --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: extract to dictionaries
On Thu, 28 May 2009 16:03:45 -0700 (PDT) Marius Retegan marius.s.rete...@gmail.com wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same for parameters2. You can use iterators to efficiently parse no-matter-how-large file. Following code depends on line breaks and 'end' statement rather than indentation. import itertools as it, operator as op, functools as ft from string import whitespace as spaces with open('test.src') as src: lines = it.ifilter(bool, it.imap(lambda x: x.strip(spaces), src)) sections = ( (lines.next(), dict(it.imap(str.split, lines))) for sep,lines in it.groupby(lines, key=lambda x: x == 'end') if not sep ) data = dict(sections) print data # { 'parameters2': {'key2': 'value2', 'key1': 'value1'}, # 'parameters1': {'key2': 'value2', 'key1': 'value1'} } To save namespace and make it a bit more unreadable you can write it as a one-liner: with open('test.src') as src: data = dict( (lines.next(), dict(it.imap(str.split, lines))) for sep,lines in it.groupby(it.ifilter(bool, it.imap(lambda x: x.strip(spaces), src)), key=lambda x: x == 'end') if not sep ) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Tkinter and popen problem
Piet van Oostrum wrote: norseman norse...@hughes.net (n) wrote: n I have tried both and Popen2.popen2(). n os.popen runs both way, contrary to docs. What do you mean `os.popen runs both way'? It reads from child while console writes directly to child - thus eliminating the problem of coding a pass through from master. n # master.py n import os n #both lines work same Of course, because 'r' is the default, and the bufsize for reading the pipe only influences the performance. n #xx= os.popen(/mnt/mass/py/z6.py).readlines() n xx= os.popen(/mnt/mass/py/z6.py,'r',1).readlines() n #I had hoped small buffer would force a sync (flush()) n #No such luck. First, there is a difference between sync and flush. flush is writing out any output that is buffered in the application program for that file. Sync is writing out buffers (cache) in the operating system (to the disc, network connection or similar). We are talking here about flushing, not syncing. As we deal with a pipe, sync is not applicable. Furthermore, whatever you do in the master program, such as setting the buffer size has nothing to do with what happens in the child, so it will not influence the flushing behaviour of the child. The only way to influence that would be to use a pty instead of a pipe, because most code uses a different buffering strategy for ttys and ptys compared to files and pipes. The next error in your program is that you use readlines() This reads ALL input from your pipe before it proceeds. So essentially it waits until the child process is finished and therefore gives you the impression that it doesn't flush(). But it is not the child that is the problem it is your master. What you should do is take the pipe and do a readline()/print loop. #xx= os.popen(/mnt/mass/py/z6.py) # popen is deprecated. Replace with subprocess: from subprocess import Popen, PIPE xx = Popen([/mnt/mass/py/z6.py], stdout=PIPE).stdout while True: line = xx.readline() if not line: break print \t + line, The obvious: for l in xx: print \t + l, doesn't work as the iterator for a file, including pipes, does a read ahead (see the doc on file.next()) and therefore is not suitable for interactive use. n The direct question comes back to: n How does one force a sync or flush() to take effect in Python with n Tkinter in use? Or just in Python period. The keyword being force. So it should be clear by now that the answer is to use flush(). And make sure you read AND process the flushed output in a proper way. By the way, you have a nasty habit of using very unclear language to pose your problems in this newsgroup/mailing list, instead of writing a concise description and giving small examples of what code causes the problem. This makes it extremely difficult to help you. I had to read your messages at least 5 times to get an idea of what you were doing and what the problem was that you wanted to solve. Maybe you are dyslectic or something similar, in which case I apologize. But anyway, I think you should learn to express yourself more clearly. There are also courses for that. === ... doesn't work as the iterator for a file, including pipes, does a read ahead (see the doc on file.next()) and therefore is not suitable for interactive use. ... If I understand you the above can be stated as: The above does not work as an iterator for any file type, including pipes, but it does do read aheads and therefore is not suitable for interactive use. If that is correct then read ahead is simply buffered file reads (grab a chunk, parcel it out on demand) - yes? As for ... not suitable for interactive ... Really? Except for special purpose use the current interactive components are all buffered for read ahead use. Check the actual code for your keyboard, your mouse and so forth. It's the read ahead that allows faster time to completion. It's why C-code has the putch function. Yes - Sync IS the bigger hammer! If that is what is needed - so be it. All character readers (byte at a time) should obey a flush(). Depending on type, code for the reader controls whether or not it flushes incomplete lines in the in-buffer(s). Proper implementation limits lost data on system crash. In trying to use flush at the master side I keep getting messages indicating strings (completed or not) are not flushable. Strange practice. --- from subprocess import Popen, PIPE xx = Popen([z6.py], stdout=PIPE).stdout while True: line = xx.readline() if not line: break print \t + line, --- DOES WORK on Python 2.5.2 on Slackware 10.2 - THANK YOU VERY MUCH!!! Isn't working on Windows. error message comes as one of two forms. 1- %1 not found #as shown above 2- file not found #as ...[python z6.py]... same#as #2 even with full paths given I get the impression subprocess ignores system things on Windows. The routines it
Re: DrPython (Windows) problems
En Fri, 29 May 2009 16:11:17 -0300, chrisv chr...@nospam.invalid escribió: Running DrPython under Linux works great. However, when I run it under Windows: Better to ask questions specific to a certain program, in its specific forum/mailing list/whatever. In this case, try http://drpython.sourceforge.net/help.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
MySQLdb 1.2.2 + python 2.6.2
Hi all, Are MySQLdb 1.2.2 and python 2.6.2 compatible? I went to http://sourceforge.net/project/showfiles.php?group_id=22307, it doesn't say it is compatible or not. When trying to install MySQLdb 1.2.2 on my machine which is running python 2.6.2 and windows XP, I get this error below. I am able to install MySQLdb 1.2.2 successfully on another machine which is running python 2.5.4 and windows XP. Please help if you have any idea. C:\tempeasy_install MySQL_python-1.2.2-py2.5-win32.egg Processing MySQL_python-1.2.2-py2.5-win32.egg Removing c:\python26\lib\site-packages\MySQL_python-1.2.2-py2.5- win32.egg Copying MySQL_python-1.2.2-py2.5-win32.egg to c:\python26\lib\site- packages MySQL-python 1.2.2 is already the active version in easy-install.pth Installed c:\python26\lib\site-packages\mysql_python-1.2.2-py2.5- win32.egg Processing dependencies for MySQL-python==1.2.2 Searching for MySQL-python==1.2.2 Reading http://pypi.python.org/simple/MySQL-python/ Reading http://sourceforge.net/projects/mysql-python Reading http://sourceforge.net/projects/mysql-python/ Best match: MySQL-python 1.2.2 Downloading http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz Processing MySQL-python-1.2.2.tar.gz Running MySQL-python-1.2.2\setup.py -q bdist_egg --dist-dir c: \docume~1\jchan\locals~1\temp\easy_install-d_b36i\MySQL- python-1.2.2\egg-dist-tmp-w0_u2d error: The system cannot find the file specified Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Questions about regex
On May 29, 1:26 pm, jared.s.ba...@gmail.com wrote: Hello, I'm new to python and I'm having problems with a regular expression. I use textmate as my editor and when I run the regex in textmate it works fine, but when I run it as part of the script it freezes. Could anyone help me figure out why this is happening and how to fix it. Here is the script: == # regular expression search and replace import sys, os, re, string, csv #Open the file and taking its data myfile=open('Steve_query3.csv') #Steve_query_test.csv #create an error flag to loop the script twice #store all file's data in the string object 'text' myfile.seek(0) text = myfile.read() for i in range(2): #def textParse(text, reRun): print 'how many times is this getting executed', i #Now to create the newfile 'test' and write our 'text' newfile = open('Steve_query3_out.csv', 'w') #open the new file and set it with 'w' for write #loop trough 'text' clean them up and write them into the 'newfile' #sub( pattern, repl, string[, count]) #sub((?i)b+, x, ) returns 'x x'. text = re.sub('(\(/?[^\]+)\)', , text)#remove the HTML text = re.sub('/!--(.|\s)*?--/', , text) #remove comments !--[^ \-]+-- text = re.sub('\/\*(.|\s)*?;}', , text) #remove css formatting #remove a bunch of word formatting yuck text = re.sub(nbsp;, , text) text = re.sub(lt;, , text) text = re.sub(gt;, , text) text = re.sub(quot;|rquot;|ldquo;, \', text) #=== #The two following lines are the ones giving me the problems text = re.sub(w:(.|\s)*?\n, , text) text = re.sub(UnhideWhenUsed=(.|\s)*?\n, , text) #=== text = re.sub(re.compile('^\r?\n?$', re.MULTILINE), '', text) #remove the extra whitespace #now write out the new file and close it newfile.write(text) newfile.close() #open the newfile and run the script again #Open the file and taking its data myfile=open('Steve_query3_out.csv') #Steve_query_test.csv #store all file's data in the string object 'text' myfile.seek(0) text = myfile.read() Thanks for the help, -Jared Can you give a string that you would expect the regex to match and what the expected result would be? Currently, it looks like the interesting part of the regex (.|\s)*? would match any character of any length once. There seems to be some redundancy that makes it more confusing then it needs to be. I'm pretty sure that . will also match anything that \s will match or maybe you just need to escape . because you meant for it to be a literal. -- http://mail.python.org/mailman/listinfo/python-list
Re: DB-API execute params, am I missing something?
In message 0dcfcb4a-8844-420b-b2e2- c8e684197...@p6g2000pre.googlegroups.com, John Machin wrote: If you need to escape % or _ in a LIKE argument, do whatever the host convention is. E.g. you are searching for text that contains literally 5% discount, with SQLite you could do: [avoiding backslashes and concomitant confusion] LIKE '%5~% discount%' ESCAPE '~' on the command line, so using DB-API: like_expr = user_input.replace(~, ~~).replace(%, ~%).replace (etc etc) Sounds like an amazingly complicated, roundabout and not even reliable way of doing it. -- http://mail.python.org/mailman/listinfo/python-list
Re: FILE object in Python3.0 extension modules
En Fri, 29 May 2009 06:52:15 -0300, Joachim Dahl dahl.joac...@gmail.com escribió: In Python2.x, I used PyFile_Check(obj) to check if a parameter was a file object. Now, in Python3.0 the same object (obtained as open('file.bin','wb')) is an io.BufferedWriter object. How do I perform type checking for such an object in the extension module, I don't know which is the preferred way to check for a file object in 3.x - I hope someone can answer this more precisely. In principle, a file inherits from io.IOBase, but this class is defined in io.py and probably isn't intended to be used in C code. Other alternatives are _io._IOBase, PyIOBase_Type, and io.FileIO/_io.FileIO and how do I extract a FILE * object from it? I browsed the C API documentation, but couldn't find an answer. I'd use PyObject_AsFileDescriptor http://docs.python.org/dev/py3k/c-api/file.html (Notice that the documentation is outdated; the PyFileObject type does not exist anymore, and a file isn't a wrapper around a FILE struct either) The purpose is to dump the contents of a Python extension type to disk as binary data using C's fwrite() function. From the above, I'd use write() with the file descriptor obtained from PyObject_AsFileDescriptor. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How does Python's OOP feel?
Ikon wrote: I'm rather new to Python. I have PHP for my main language and I do some Java. They all have a very strict OO schema. As I red through Python's tutorial it seams it has nothing of those rules. No statical, abstract classes, functions, or variables. I wish someone, who has experience in both Java/PHP/C# and Python would tell me how mush better/worse is it to program in a language that misses most of the OO parts! import antigravity -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie: popen question
thebiggestbangthe...@gmail.com wrote: On May 28, 5:31 am, Sebastian Wiesner basti.wies...@gmx.net wrote: Sean DiZazzo – Donnerstag, 28. Mai 2009 10:11 Your best bet is to make sudo not ask for a password. :) If you don't have the rights, then you can use pexpect to do what you want to do. http://pexpect.sourceforge.net/pexpect.html See the second example on that page. child = pexpect.spawn('scp foo myn...@host.example.com:.') child.expect ('Password:') child.sendline (mypassword) The sudo password prompt is very configurable, so changing the configuration to allow execution without password input is really the best option. -- Freedom is always the freedom of dissenters. (Rosa Luxemburg) Thanks guys for helping out! very good answers :-) Before I saw your answers, I tried the following, output = subprocess.Popen([sudo,-b, code.sh, arg1], stdout=subprocess.PIPE).communicate()[0] This seemed to push the shell execution process to the background and because my python program was invoked initially with sudo, it seems I did not need to enter a passwd again. Any comments about this..any issues that you see will crop up? Thanks a ton again. Is using gksu or kdesu feasible? Or maybe you could run sudo -v which activates sudo then immediately run your sudo command. This relies on sudo not configured to not use timestamp though. -- http://mail.python.org/mailman/listinfo/python-list
Re: FILE object in Python3.0 extension modules
En Fri, 29 May 2009 08:48:26 -0300, Benjamin Peterson benja...@python.org escribió: Joachim Dahl dahl.joachim at gmail.com writes: How do I perform type checking for such an object in the extension module, and how do I extract a FILE * object from it? I browsed the C API documentation, but couldn't find an answer. You use PyObject_IsInstance to test if the object is an instance of io.IOBase. But you have to import the io module first, don't you? That's not usually necesary for most built in types -- e.g. PyFloat_Check just checks for a float object. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Programming Praxis
Please visit my blog, a href=programmingpraxis.wordpress.comProgramming Praxis/a, which presents a collection of programming etudes. Newbies will find exercises that extend their programming abilities. Savvy programmers can use the exercises to sharpen their skills or learn a new language. Brave programmers can submit their code to the review of their colleagues. a href=programmingpraxis.wordpress.comProgramming Praxis/a isn't a contest. No points are awarded, no scores are kept. The exercises simply provide an opportunity to hone your skills; the effort is its own reward. Come join us! -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to get cleaner XML output from a text file
En Fri, 29 May 2009 14:09:10 -0300, iainemsley iainems...@googlemail.com escribió: I'm using Python2.5 to try and convert some text files into XML using xml.minidom. I'm currently doing some plays which have a structure like Scene 1 Act 1 blah blah Act2 blah blah Scene 2 Act 1 and so on. (I think you get the hierarchy wrong: usually a play contains some Acts; each act contains several Scenes) I'm trying to turn it into div type=scene1 div type=act1 speech / /div div type=act2 speech / /div /div (or ideally div type=scene id=1 bit I can always come back to this later) Using ElementTree is a lot easier than minidom: import sys from itertools import groupby, count import xml.etree.ElementTree as ET import re class Seq: Automatic sequencer for acts/scenes def __init__(self): self.act_nr = count(1) self.scene_nr = count(1) def next_scene(self): return self.scene_nr.next() def next_act(self): self.scene_nr = count(1) return self.act_nr.next() seq = Seq() def add_act(body, act_text): act = ET.SubElement(body, div, type=act, id=a%s % seq.next_act()) for scene_text in scene_sep.split(act_text): add_scene(act, scene_text) def add_scene(act, scene_text): scene = ET.SubElement(act, div, type=scene, id=%ss%s % (act.get(id), seq.next_scene())) for p in paragraphs(scene_text.splitlines(True)): add_speech(scene, p) def add_speech(scene, p): speech = ET.SubElement(scene, speech) speech.text = p body = ET.Element(body) scene_sep = re.compile(rScene\s+[1-9]+, re.I) act_sep = re.compile(rAct\s+[1-9]+, re.I) for act_text in act_sep.split(text): add_act(body, act_text) doc = ET.ElementTree(body) doc.write(sys.stdout) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: FILE object in Python3.0 extension modules
En Fri, 29 May 2009 23:24:32 -0300, Benjamin Peterson benja...@python.org escribió: Gabriel Genellina gagsl-py2 at yahoo.com.ar writes: But you have to import the io module first, don't you? That's not usually necesary for most built in types -- e.g. PyFloat_Check just checks for a float object. Well, in 3.x, file is not longer a builtin type. Ok, seems the old file type has been demoted and atomized... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How does Python's OOP feel?
On Fri, May 29, 2009 at 9:41 PM, Lie Ryan lie.1...@gmail.com wrote: Ikon wrote: I'm rather new to Python. I have PHP for my main language and I do some Java. They all have a very strict OO schema. As I red through Python's tutorial it seams it has nothing of those rules. No statical, abstract classes, functions, or variables. I wish someone, who has experience in both Java/PHP/C# and Python would tell me how mush better/worse is it to program in a language that misses most of the OO parts! import antigravity You forgot the link. http://www.xkcd.com/353/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[issue6131] test_modulefinder leaks when run after test_distutils
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: I can reproduce refleaks with only test_distutils now. E:\python-dev\py3k\Lib\testpy3k regrtest.py -R3:2: test_distutils test_distutils beginning 5 repetitions 12345 . test_distutils leaked [280, 280] references, sum=560 1 test failed: test_distutils I think this refleaks can be solved by using super() for setUp() and tearDown() everywhere. -- Added file: http://bugs.python.org/file14109/fix_distutils_refleak.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6131 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6097] Encoded surrogate characters on command line not escaped in sys.argv
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6097 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5274] sys.exc_info()[1] - different handling from str() and unicode() - py 2.6
Georg Brandl ge...@python.org added the comment: Duplicate of #6108. -- nosy: +georg.brandl resolution: - duplicate status: open - closed superseder: - unicode(exception) behaves differently on Py2.6 when len(exception.args) 1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5274 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6131] test_modulefinder leaks when run after test_distutils
Tarek Ziadé ziade.ta...@gmail.com added the comment: Thanks, it fixed it. Applied in the trunk. Can you guys merge r73008 into Py3k please ? I have a problem today, I can't build py3k on Mac OS X anymore, I am trying to figure out why. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6131 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6131] test_modulefinder leaks when run after test_distutils
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Done in r73010. I think it would be better to patch release26maint.patch for release26-maint (and same patch for release30-maint) to complete super() issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6131 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6131] test_modulefinder leaks when run after test_distutils
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Added file: http://bugs.python.org/file14110/release26maint.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6131 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4829] confusing error for file(foo, w++)
John Szakmeister j...@szakmeister.net added the comment: On trunk, it seems that it's perfectly happy if you specify more than one '+': Python 2.7a0 (trunk, May 29 2009, 05:57:26) [GCC 4.0.1 (Apple Inc. build 5470) (Aspen 5470.3)] on darwin Type help, copyright, credits or license for more information. open('foo.txt', 'w++') open file 'foo.txt', mode 'w++' at 0x39b2a0 Is this still really an issue then? The current trunk also allows multiple mode letters too, so it seems like a decision has been made. -- nosy: +jszakmeister ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4829 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6141] missing first argument on subprocess.Popen w/ executable
New submission from Lie Ryan lie.1...@gmail.com: Following from http://comments.gmane.org/gmane.comp.python.tutor/55576 import subprocess subprocess.Popen(['a', 'b', 'c', 'd'], executable='echo') subprocess.Popen object at 0x7fdf7bb2bd50 b c d instead of the (what I) expected result a b c d I suggests two possible change: 1. add another optional argument called displayed_executable (or something similar) and make the arg argument contains only arguments 2. it is made clear in the documentation that the first argument is used as executable display name Since the first alternative is behavioral change, it couldn't possibly go through already released version; therefore if it is the chosen solution it would have to go to Python 2.7 and Python 3.2. Changing the documentation should be easier, although the problem will persist for unsuspecting users; and even if the first alternative is taken, perhaps documentation change should still be done retrospectively (I don't know the policy on doc change on old python version) It should be noted that I tested this only with Python 2.5 on Gentoo (although from the discussion, I presumed this is considered a feature and would have persisted in later versions). And at the time of this writing, I have no idea how it behaves in Windows. -- assignee: georg.brandl components: Documentation, Library (Lib) messages: 88504 nosy: georg.brandl, lieryan severity: normal status: open title: missing first argument on subprocess.Popen w/ executable type: behavior versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3329] API for setting the memory allocator used by Python
Changes by John Szakmeister j...@szakmeister.net: -- nosy: +jszakmeister ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3329 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6131] test_modulefinder leaks when run after test_distutils
Tarek Ziadé ziade.ta...@gmail.com added the comment: done thx for the help. Do you happen to know the exact reason why using super rather than an explicit call avoids the leaking ? -- status: open - closed versions: +Python 2.6, Python 2.7, Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6131 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4618] print_function and unicode_literals don't work together
Changes by John Szakmeister j...@szakmeister.net: -- nosy: +jszakmeister ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4618 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6131] test_modulefinder leaks when run after test_distutils
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Well, I don't know... But probably mixing super() and non super() caused too many call of setUp() or tearDown(). I saw such case before. To track down this, probably this info helps. 1. Revert to previous revision of distutils 2. Remove distutils tests except for test_archive_util.py and test_bdist_dumb.py 3. Run regrtest.py -R2:3: test_distutils test_distutils beginning 5 repetitions 12345 . test_distutils leaked [280, 280] references, sum=560 1 test failed: test_distutils -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6131 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com