Re: SEC proposes the use of Python and XML
On 10Apr2010 23:05, Chris Rebert wrote: | On Sat, Apr 10, 2010 at 9:13 PM, Ted Larson Freeman | wrote: | > This week the SEC proposed new requirements for asset-backed | > securities that include the use of XML and Python: | > | > "The asset-level information would be provided according to proposed | > standards and in a tagged data format using eXtensible Markup Language | > (XML). In addition, we are proposing to require, along with the | > prospectus filing, the filing of a computer program of the contractual | > cash flow provisions expressed as downloadable source code in Python, | > a commonly used open source interpretive programming language." | | I guess we've now gone from "executable pseudocode" to "executable | legal code" :-) And not before time, either :-( But unless they require it to be usable as unit tests (eg running as validation of a live transaction stream, or in some audit mode) it may be less useful than one might hope. Of course, if they're gone as far as requiring python code, perhaps that's exactly what they hope to be able to do. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ One of the guys in my homebrew club is a mailman. He says that one of the requirements to work for the post office is to be able to work the slide on a 9mm while laughing. - Phillip J. Birmingham -- http://mail.python.org/mailman/listinfo/python-list
Re: [Possibly OT] Comments on PyPI
Steven D'Aprano wrote: > How do I leave comments on PyPI? There's a checkbox "Allow comments on > releases" which I have checked, but no obvious way to actually post a > comment. You need to login in order to rate or comment. A more specific place to ask PyPI questions is catalog-...@python.org. HTH, Martin -- http://mail.python.org/mailman/listinfo/python-list
doctests working both in Python 2.X and Python 3.X
I do not want to write two documentations for a module working both in Python 2.X and Python 3.X. To avoid that, I would need the ability to interpret doctests according to the used Python version. I mean something like that: """ Documentation of the module - If you are using Python 2.X you can check that >>> <2.X code> # doctest: <2.X output> whereas if you are using Python 2.X you can check that >>> <3.X code> # doctest: <3.X output> Is something like that possible? If not, what are the options? 2to3 theoretically can converts the doctests, but in practice I have seen that the doctests for my decorator module needs some manual tweaking. -- http://mail.python.org/mailman/listinfo/python-list
Re: doctests working both in Python 2.X and Python 3.X
On Sun, Apr 11, 2010 at 1:59 PM, Michele Simionato < michele.simion...@gmail.com> wrote: > I do not want to write two documentations for a module working both in > Python 2.X and Python 3.X. > There are modules which work in both 2.x and 3.x but still behave differently. How will you handle those ? IMHO the way as it is is correct > To avoid that, I would need the ability to interpret doctests > according to the used Python version. > > I mean something like that: > > """ > Documentation of the module > - > > If you are using Python 2.X you can check that > > >>> <2.X code> # doctest: > <2.X output> > > whereas if you are using Python 2.X you can check that > > >>> <3.X code> # doctest: > <3.X output> > > Is something like that possible? If not, what are the options? > 2to3 theoretically can converts the doctests, but in practice I have > seen that the doctests for my decorator module needs some manual > tweaking. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: [Possibly OT] Comments on PyPI
On Sun, 11 Apr 2010 10:13:16 +0200, Martin v. Loewis wrote: > Steven D'Aprano wrote: >> How do I leave comments on PyPI? There's a checkbox "Allow comments on >> releases" which I have checked, but no obvious way to actually post a >> comment. > > You need to login in order to rate or comment. I already am logged in. > A more specific place to ask PyPI questions is catalog-...@python.org. Another mailing list to subscribe too :( Thanks Martin. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: On Class namespaces, calling methods
Steven D'Aprano wrote: > On Sat, 10 Apr 2010 16:35:29 +, Duncan Booth wrote: > >> Anyway, the moral is never, ever to use old-style classes in Python >> 2.x. You will get weird and unexpected results. > > That's a bit strong. They're only weird and unexpected if you're not > expecting them and don't understand them. Which is exactly what will happen when some subclass tries to use a property not realising that it is actually an old style class. That kind of problem can be a real pain to track down. > > Why are we worrying about the exact error message? New style or old > style, they both raise TypeError, and testing for the exact error > message is a fragile, dangerous thing to do: error strings are not > part of the Python API, and are subject to change without notice, for > any reason. For all we know, Python runtimes compiled on a Tuesday > could use different error messages from runtimes compiled on > Wednesdays. > I'm intrigued by the exact error message because I'd like to know the answer to one of the questions Vicente asked: what object is being passed to 'm' on the system which complains "m() takes no arguments (1 given)" I'm sure it must just be an insignificant difference, but I hate unanswered questions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Striving for PEP-8 compliance
In message <87sk73jxl0@benfinney.id.au>, Ben Finney wrote: > What happens whe you're trying to reconcile two different > block-delimiter conventions? For example? -- http://mail.python.org/mailman/listinfo/python-list
Re: Striving for PEP-8 compliance
In message , Grant Edwards wrote: > On 2010-04-10, Lawrence D'Oliveiro > wrote: > >> In message , Grant Edwards wrote: >> >>> On 2010-04-10, Lawrence D'Oliveiro >>> wrote: >>> In message , Grant Edwards wrote: > Anybody who invents another brace-delimited language should be beaten. > You always end up with a big problem trying to make sure the braces > are consistent with the program logic. >>> Would you prefer “begin” and “end” word symbols, then? >>> >>> Nope, I categorize those as nothing more than verbose "braces". >> >> But since those symbols already, by definition, directly correspond to >> program logic, where exactly does the “big problem” arise trying to make >> sure they are “consistent with the program logic”? > > The same goes for indentation. In python it's not possible to write a > program to correctly indent code that isn't alaready correctly indented. The problem isn’t that it’s “incorrectly” indented, it’s two different pieces of code (correctly) indented according to two different conventions, and how you reconcile them without introducing logic errors into the code. > In a brace delimited language it's not possible to write a program to > correctly place braces in an "incorrectly braced" program. But with braces it’s easy enough to reconcile different indentation conventions without introducing logic errors into the code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Striving for PEP-8 compliance
Lawrence D'Oliveiro wrote: >> The same goes for indentation. In python it's not possible to write >> a program to correctly indent code that isn't alaready correctly >> indented. > > The problem isnât that itâs âincorrectlyâ indented, itâs two > different pieces of code (correctly) indented according to two > different conventions, and how you reconcile them without introducing > logic errors into the code. You use 'reindent.py' which a standard part of every Python release. Except that should shouldn't because it messes up the version history. > >> In a brace delimited language it's not possible to write a program to >> correctly place braces in an "incorrectly braced" program. > > But with braces itâs easy enough to reconcile different indentation > conventions without introducing logic errors into the code. > Except you shouldn't for the above mentioned reason. -- http://mail.python.org/mailman/listinfo/python-list
Re: ftp and python
On 8 Apr, 07:24, John Nagle wrote: > Tim Chase wrote: > > Matjaz Pfefferer wrote: > >> What would be the easiest way to copy files from one ftp > >> folder to another without downloading them to local system? > > > As best I can tell, this isn't well-supported by FTP[1] which doesn't > > seem to have a native "copy this file from server-location to > > server-location bypassing the client". There's a pair of RNFR/RNTO > > commands that allow you to rename (or perhaps move as well) a file which > > ftplib.FTP.rename() supports but it sounds like you want too copies. > > In theory, the FTP spec supports "three-way transfers", where the > source, destination, and control can all be on different machines. > But no modern implementation supports that. > > John Nagle pyftpdlib supports it: http://code.google.com/p/pyftpdlib/wiki/FAQ#What_is_FXP? ...but Python's ftplib.py module doesn't. --- Giampaolo http://code.google.com/p/pyftpdlib http://code.google.com/p/psutil -- http://mail.python.org/mailman/listinfo/python-list
Re: finding objects in a piece of functional code ?
PythoidC (http://pythoidc.googlecode.com or http://pythoidc.sf.net ) took the similar technique "finding objects in a piece of functional C code with Python" In the thread "Re: braceless and semicolonless", I discussed some details. May be of some help. - Original Message - From: Stef Mientki To: python-list@python.org Sent: Sunday, April 11, 2010 12:08 AM Subject: finding objects in a piece of functional code ? hello, I would like to translate some functional description into some standard class object, so it can be used as a basic building brick into a larger piece of code. Suppose the functional description is: Name = 'Test_Function' Out = 3 * In That's all I would like to write. So it should be translated into something : class Test_Function ( basic_buidling_brick ) : Orginal_Description = """ Name = 'Test_Function' Out = 3 * In """ def Run ( self, Inputs ) : Output = 3 * Input return Output One of the tasks is to find all "objects" in the functional code., so the translator can ask additional information for input/output/memory variables. The best I can think of is something like this: >>> my={} >>> my2=copy.copy(my) >>> exec('A=3; B=4; C=A*B; print A,B,C',my) 3 4 12 >>> for item in my : ... if item not in my2 : ... print item ... __builtins__ A C B But this doesn't work, if I use a not yet definied variable (like "In" in the example above). Are there better ways ? Or even better are there programs or libraries that can perfom such a translation ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Python does not allow a variable named "pass"
I am trying to automate access to a web page that has forms based authentication. The password field is named "pass" which python is not going to like. Other than asking the website owner to change the name of the field how can I go about passing that field in the form post? dev:~$ python Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib >>> params = urllib.urlencode(dict(past='foo')) >>> params = urllib.urlencode(dict(passs='foo')) >>> params = urllib.urlencode(dict(pass='foo')) File "", line 1 params = urllib.urlencode(dict(pass='foo')) ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list
Re: Python does not allow a variable named "pass"
On 11 Apr, 15:40, BJ Swope wrote: > I am trying to automate access to a web page that has forms based > authentication. The password field is named "pass" which python is > not going to like. > > Other than asking the website owner to change the name of the field > how can I go about passing that field in the form post? > > dev:~$ python > Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> > import urllib > >>> params = urllib.urlencode(dict(past='foo')) > >>> params = urllib.urlencode(dict(passs='foo')) > >>> params = urllib.urlencode(dict(pass='foo')) > > File "", line 1 > params = urllib.urlencode(dict(pass='foo')) > ^ > SyntaxError: invalid syntax >>> urllib.urlencode({'pass' : 'foo'}) 'pass=foo' >>> --- Giampaolo http://code.google.com/p/pyftpdlib http://code.google.com/p/psutil -- http://mail.python.org/mailman/listinfo/python-list
Re: Python does not allow a variable named "pass"
BJ Swope wrote: > Other than asking the website owner to change the name of the field > how can I go about passing that field in the form post? > > dev:~$ python > Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import urllib params = urllib.urlencode(dict(past='foo')) params = urllib.urlencode(dict(passs='foo')) params = urllib.urlencode(dict(pass='foo')) > File "", line 1 > params = urllib.urlencode(dict(pass='foo')) > ^ > SyntaxError: invalid syntax > > Create your dictionary without using keyword arguments: fields = {'pass':'foo'} params = urllib.urlencode(fields) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python does not allow a variable named "pass"
On Sun, Apr 11, 2010 at 11:40 PM, BJ Swope wrote: > Other than asking the website owner to change the name of the field > how can I go about passing that field in the form post? > How about: >>> urllib.urlencode({'pass' : 'foo'}) And so on? What is your problem in this context? Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list
Re: [Possibly OT] Comments on PyPI
On 09:24 am, st...@remove-this-cybersource.com.au wrote: On Sun, 11 Apr 2010 10:13:16 +0200, Martin v. Loewis wrote: Steven D'Aprano wrote: How do I leave comments on PyPI? There's a checkbox "Allow comments on releases" which I have checked, but no obvious way to actually post a comment. You need to login in order to rate or comment. I already am logged in. A more specific place to ask PyPI questions is catalog-...@python.org. Another mailing list to subscribe too :( Thanks Martin. You can't comment on your own packages. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Python does not allow a variable named "pass"
urllib.urlencode({'pass' : 'foo'}) > 'pass=foo' > > > --- Giampaolo > http://code.google.com/p/pyftpdlib > http://code.google.com/p/psutil > -- > http://mail.python.org/mailman/listinfo/python-list > Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Striving for PEP-8 compliance
On 2010-04-11, Lawrence D'Oliveiro wrote: > The problem isn?t that it?s ?incorrectly? indented, it?s two > different pieces of code (correctly) indented according to two > different conventions, and how you reconcile them without introducing > logic errors into the code. I've never run into that problem, but it shold be simple enough to do that in an automated way as well. Don't reindent and pindent work as advertised? >> In a brace delimited language it's not possible to write a program to >> correctly place braces in an "incorrectly braced" program. > But with braces it?s easy enough to reconcile different indentation > conventions without introducing logic errors into the code. Reconciling indention in an indention-delimited language doesn't correspond to reconciling indentation in a brace-delimited language, so comparing them doesn't really make sense. -- Grant -- http://mail.python.org/mailman/listinfo/python-list
universal newlines and utf-16
i am using python 2.6 on a linux box and i have some utf-16 encoded files with crlf line-endings which i would like to open with universal newlines. so far, i have been unable to get this to work correctly. for example: >>> open('test.txt', 'w').write(u'a\r\nb\r\n'.encode('utf-16')) >>> repr(open('test.txt', 'rbU').read().decode('utf-16')) "u'a\\n\\nb\\n\\n'" >>> import codecs >>> repr(codecs.open('test.txt', 'rbU', 'utf-16').read()) "u'a\\n\\nb\\n\\n'" of course, the output i want is: "u'a\\nb\\n'" i suppose it's not too surprising that the built-in open converts the line endings before decoding, but it surprised me that codecs.open does this as well. is there a way to get universal newlines to work properly with utf-16 files? (nb: i'm not interested in other methods of converting line endings - just whether universal newlines can be made to work correctly). -- http://mail.python.org/mailman/listinfo/python-list
Re: finding objects in a piece of functional code ?
Stef Mientki, 10.04.2010 18:08: I would like to translate some functional description into some standard class object, so it can be used as a basic building brick into a larger piece of code. Suppose the functional description is: Name = 'Test_Function' Out = 3 * In Ok, so you want to implement a domain specific language (DSL) for function post conditions. First thing to ask: how expressive do you want this language to be? If the answer is "as expressive as the code it describes", then you will end up needing a turing-complete programming language, in which case you may want to use plain Python code instead of writing your own language. See the doctest module. Implementing a language that can express "x*3" is relatively(!) easy, but I would guess that you want your post conditions to be a little more expressive than that. Could you describe why you want such a language in the first place? What feature do you need that cannot be expressed using doctests, for example? Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: universal newlines and utf-16
Baz Walter, 11.04.2010 16:12: i am using python 2.6 on a linux box and i have some utf-16 encoded files with crlf line-endings which i would like to open with universal newlines. so far, i have been unable to get this to work correctly. for example: >>> open('test.txt', 'w').write(u'a\r\nb\r\n'.encode('utf-16')) >>> repr(open('test.txt', 'rbU').read().decode('utf-16')) "u'a\\n\\nb\\n\\n'" >>> import codecs >>> repr(codecs.open('test.txt', 'rbU', 'utf-16').read()) "u'a\\n\\nb\\n\\n'" of course, the output i want is: "u'a\\nb\\n'" i suppose it's not too surprising that the built-in open converts the line endings before decoding, but it surprised me that codecs.open does this as well. The codecs module does not support universal newline parsing (see the docs). You need to use the new io module instead. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Apr 10, 11:51�pm, alex23 wrote: > Mensanator wrote: > > 3.x won't be adopted by WINDOWS developers WHO USE IDLE until it's fixed. > > I think you left your hyperbole level too high so I turned it down for > you. I don't know of _anyone_ who uses IDLE to run production code, > nor do I follow how one errant IDE shows that Python 3.x as a language > is broken. Planning to buy a Toyota? -- http://mail.python.org/mailman/listinfo/python-list
Re: universal newlines and utf-16
On 11/04/10 15:37, Stefan Behnel wrote: The codecs module does not support universal newline parsing (see the docs). You need to use the new io module instead. thanks. i'd completely overlooked the io module - i thought it was only in python 2.7/3.x. -- http://mail.python.org/mailman/listinfo/python-list
Twisted and txJSON-RPC
Hi all, I'm modifying a Twisted project and I'd like to implement the txJSON- RPC code show here: https://launchpad.net/txjsonrpc However, when I try to install this with this command line: sudo easy_install txJSON-RPC I get an error message: error: docs/PRELUDE.txt: No such file or directory I'm not sure what this is about, or how to fix it. Does anyone have any suggestions or help they can offer me? Thanks! Doug -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: >> > 3.x won't be adopted by developers until it's fixed. As of now, it's >> > seriously broken and unsuitable for production. >> >> In what ways do you consider it broken? > > Issue 8093. Remarkably, this apparently hasn't been noticed before. I think that tells you that it's an unimportant bug that doesn't really effect many people much, and a million miles from implying that Python 3.x is "seriously broken and unsuitable for production". > I expect 2.7 will be around for a long time. As reported on the bug tracker, this bug effects Python 2.7 as well. It's possible this bug goes back to, what? Python 2.5? 2.4? 2.3? Older? Who knows? http://bugs.python.org/issue8093#msg102818 In any case, IDLE is one IDE out of many, and not really up to professional quality -- it's clunky and ugly. It isn't Python, it is a tool written in Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On 4/11/2010 12:08 AM, Mensanator wrote: On Apr 10, 7:15�pm, Chris Rebert wrote: On Sat, Apr 10, 2010 at 4:47 PM, Mensanator wrote: 3.x won't be adopted by developers until it's fixed. As of now, it's seriously broken and unsuitable for production. Not. Many though will wait until 3.2 and greater library availability, which *is* coming. In what ways do you consider it broken? Issue 8093. IDLE is not Python. And are you really sure this is 3.x-only problem or that it is not a Windows-only problem. Remarkably, this apparently hasn't been noticed before. Because it requires somewhat rare circumstances. Start an infinite loop from IDLE, perhaps specifically on Windows. Try to restart. Patiently wait for restart to happen (several seconds, and iffy) instead of killing the runaway process from TaskManager. I expect 2.7 will be around for a long time. That was always expected independently of this issue. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
ACE RSA Authentication Manager
Hi, Anyone out there writing Jython for RSA Authentication Manager ? I'm fairly new to Python but I see it is possible to write Jython scripts for user administration. I'm also very interested in writing scripts for monitoring and basically everything else related to RSA but in Jython, i.e. instead of Java ? If you have resources, hints, links for doing this I'd very much appreciate it. Thanks in advance, Jerry -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.11.5
Hello! I'm pleased to announce version 0.11.5, a minor bugfix release of 0.11 branch of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.11.5 News and changes: http://sqlobject.org/News.html What's New == News since 0.11.4 - * Fixed a bug in replacing _connection in a case when no previous _connection has been set. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmanhttp://phd.pp.ru/p...@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.12.3
Hello! I'm pleased to announce version 0.12.3, a minor bugfix release of branch 0.12 of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.12.3 News and changes: http://sqlobject.org/News.html What's New == News since 0.12.2 - * Fixed a bug in replacing _connection in a case when no previous _connection has been set. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmanhttp://phd.pp.ru/p...@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
Re: SEC proposes the use of Python and XML
On 4/11/2010 12:13 AM, Ted Larson Freeman wrote: This week the SEC proposed new requirements for asset-backed securities that include the use of XML and Python: "The asset-level information would be provided according to proposed standards and in a tagged data format using eXtensible Markup Language (XML). In addition, we are proposing to require, along with the prospectus filing, the filing of a computer program of the contractual cash flow provisions expressed as downloadable source code in Python, a commonly used open source interpretive programming language." Thanks for posting this. More jobs for Python programmers. And perhaps better transparency in such investment vehicles. See: http://www.sec.gov/news/press/2010/2010-54.htm http://kelloggfinance.wordpress.com/2010/04/08/the-sec-gets-one-right To help anyone trying to verify this, the quote is a quote within the blog post which seems to attribute it to the SEC press release. However, it actually comes from http://www.sec.gov/rules/proposed/2010/33-9117.pdf the 'Additional Material' referenced within the press release. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: SEC proposes the use of Python and XML
On Apr 11, 3:12 am, Cameron Simpson wrote: > On 10Apr2010 23:05, Chris Rebert wrote: > | On Sat, Apr 10, 2010 at 9:13 PM, Ted Larson Freeman| > wrote: > > | > This week the SEC proposed new requirements for asset-backed > | > securities that include the use of XML and Python: > | > > | > "The asset-level information would be provided according to proposed > | > standards and in a tagged data format using eXtensible Markup Language > | > (XML). In addition, we are proposing to require, along with the > | > prospectus filing, the filing of a computer program of the contractual > | > cash flow provisions expressed as downloadable source code in Python, > | > a commonly used open source interpretive programming language." > | > | I guess we've now gone from "executable pseudocode" to "executable > | legal code" :-) > > And not before time, either :-( > > But unless they require it to be usable as unit tests (eg running as > validation of a live transaction stream, or in some audit mode) it may be > less useful than one might hope. Of course, if they're gone as far as > requiring python code, perhaps that's exactly what they hope to be able to > do. > > Cheers, > -- > Cameron Simpson DoD#743http://www.cskk.ezoshosting.com/cs/ > > One of the guys in my homebrew club is a mailman. He says that one of the > requirements to work for the post office is to be able to work the slide on a > 9mm while laughing. - Phillip J. Birmingham I would think there are two major reasons for this: 1) less wiggle room for the lawyers to argue about the terms of the contract. 2) it makes it easier for parties to the contract to assess their risks under different scenarios by plugging all their contracts into a single model. I don't know the SEC needs to define standards for unit-tests, etc. -- that might happen organically, because these are all big companies with their own in-house programming staffs. Getting the programmers involved before a contract is signed is a great thing. Once the lawyers are told "the program defines the contract" you can bet both sides are going to check out the program pretty carefully, and if a programmer says "hey, when this thing happens in the economy, we owe them 5 times the GDP of the planet", the contract probably won't happen. Regards, Pat -- http://mail.python.org/mailman/listinfo/python-list
Refresh Problem
Hi; I send variables to a script. The script adds appropriate lines into a database of an order to my shopping cart. When I refresh the screen, as no doubt some customers will do, it re-ads those orders. Now, I can delete them, but that's not the point. I don't want it to re-ad the orders. How do I skirt this problem? TIA, beno -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Apr 11, 6:53 pm, Steven D'Aprano wrote: > > In any case, IDLE is one IDE out of many, and not really up to > professional quality -- it's clunky and ugly. It isn't Python, it is a > tool written in Python. > > -- > Steven But this is a tool that is a part of the python distribution and often recommended to python beginners as their first IDE. So IDLE is responsible for the first impression on Python to many. If IDLE is considered as of low quality and ugly, after so many years, why it is not fixed or replaced?. I'm just wondering. joaquin -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating a rainbow?
Tobiah wrote: You should use different variables for the two loops. Actually it is closing the divs that makes it work in FireFox: Hah. I new that the rainbow wasn't complete and that it didn't work in Opera. I just fizzled on the closing of the divs. I also don't get why it worked at all when I was stomping on my x variable in the inside loop. It's better now. http://tobiah.org/rainbow.html Better than before ... Oy G. Bivr -- http://mail.python.org/mailman/listinfo/python-list
A 'foolproof' way to query inheritance tree? numbers.Real in 2.6)
Generally, if I want to know the inheritance tree of a class, I either use inspect.getmro or __bases__ However, after reading about the new numbers module / class tower in Python 2.6/3.0, I realized that both of these will fail to show that the 'float' type actually inherits from numbers.Real: >>> import inspect, numbers >>> issubclass(float, numbers.Real) True >>> inspect.getmro(float) (, ) >>> float.__bases__ (,) Is there a more foolproof way to query this information? Or is this simply some sort of bug with the new implementation of numbers in python 2.6? - Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Apr 11, 11:53�am, Steven D'Aprano wrote: > On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: > >> > 3.x won't be adopted by developers until it's fixed. As of now, it's > >> > seriously broken and unsuitable for production. > > >> In what ways do you consider it broken? > > > Issue 8093. Remarkably, this apparently hasn't been noticed before. > > I think that tells you that it's an unimportant bug that doesn't really > effect many people much, It affects me ... a LOT. > and a million miles from implying that Python > 3.x is "seriously broken and unsuitable for production". Maybe because I'm a user, not a developer. > > > I expect 2.7 will be around for a long time. > > As reported on the bug tracker, this bug effects Python 2.7 as well. It's > possible this bug goes back to, what? Python 2.5? 2.4? 2.3? Older? Who > knows? I can't imagine my not having noticed this before. It's plausible I might not have noticed the runaway processes, but the fact that I can't eject a USB drive would have been very obvious. > > http://bugs.python.org/issue8093#msg102818 > > In any case, IDLE is one IDE out of many, and not really up to > professional quality -- it's clunky and ugly. It isn't Python, it is a > tool written in Python. You have no idea what the cause is, yet you're certain that the symptom is confined to IDLE. That's the kind of thinking that leads to such bugs in the first place. > > -- > Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] [RELEASED] 2.7 beta 1
On Sat, Apr 10, 2010 at 20:52, Benjamin Peterson wrote: > On behalf of the Python development team, I'm merry > to announce the first beta release of Python 2.7. Cool! -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64 -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Apr 11, 12:00�pm, Terry Reedy wrote: > On 4/11/2010 12:08 AM, Mensanator wrote: > > > On Apr 10, 7:15 pm, Chris Rebert �wrote: > >> On Sat, Apr 10, 2010 at 4:47 PM, Mensanator �wrote: > >>> 3.x won't be adopted by developers until it's fixed. As of now, it's > >>> seriously broken and unsuitable for production. > > Not. Many though will wait until 3.2 and greater library availability, > which *is* coming. Which comes first, library availability or a working system? > > >> In what ways do you consider it broken? > > > Issue 8093. > > IDLE is not Python. The Task Manager doesn't say "IDLE", it says "pytonw". > And are you really sure this is 3.x-only problem No, I didn't say it was, just that that's where I noticed it. I haven't been using the latest 2.x upgrades because I switched to 3.x. > or > that it is not a Windows-only problem. Could very well be. But when YOU target a specific operating system, isn't the onus on YOU to make it work within that system? If you're not content to be a big fish in a small pond, then you better figure out a way to make it work. > > > Remarkably, this apparently hasn't been noticed before. > > Because it requires somewhat rare circumstances. Start an infinite loop > from IDLE, perhaps specifically on Windows. Try to restart. Patiently > wait for restart to happen (several seconds, and iffy) Not iffy at all. If it responds to the menu and I can click on Restart, it succeeds. > instead of > killing the runaway process from TaskManager. Why on earth would I want to do that? Then I lose the entire history of whats printed in the window. You've got a serious problem if you expect the TaskManager to be used for normal operations. > > > I expect 2.7 will be around for a long time. > > That was always expected independently of this issue. I hear 2.7 doesn't work either. I'll back off on that comment. > > Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Tough sorting problem: or, I'm confusing myself
On Apr 9, 8:03 am, david jensen wrote: > Hi all, > > I'm trying to find a good way of doing the following: > > Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding > value n-tuple (call them "scores" for clarity later). I'm currently > storing them in a dictionary, by doing: > > > res={} > for i in itertools.combinations( range( 2**m ) , n): > res[ i ] = getValues( i ) # getValues() is computationally > expensive > > > For each (n-1)-tuple, I need to find the two numbers that have the > highest scores versus them. I know this isn't crystal clear, but > hopefully an example will help: with m=n=3: > > Looking at only the (1, 3) case, assuming: > getValues( (1, 2, 3) ) == ( -200, 125, 75 ) # this contains the > highest "other" score, where 2 scores 125 > getValues( (1, 3, 4) ) == ( 50, -50, 0 ) > getValues( (1, 3, 5) ) == ( 25, 300, -325 ) > getValues( (1, 3, 6) ) == ( -100, 0, 100 ) # this contains the > second-highest, where 6 scores 100 > getValues( (1, 3, 7) ) == ( 80, -90, 10 ) > getValues( (1, 3, 8) ) == ( 10, -5, -5 ) > > I'd like to return ( (2, 125), (6, 100) ). > > The most obvious (to me) way to do this would be not to generate the > res dictionary at the beginning, but just to go through each > combinations( range( 2**m), n-1) and try every possibility... this > will test each combination n times, however, and generating those > values is expensive. [e.g. (1,2,3)'s scores will be generated when > finding the best possibilities for (1,2), (1,3) and (2,3)] > > What I'm doing now is ugly, and i think is where i'm confusing myself: > > > best2={} > for i in itertools.combinations( range( 2**m), n-1): > scorelist=[] > for j in range( 2**m ): > if j not in i: > k=list(i) > k.append(j) > k=tuple(sorted(k)) #gets the key for looking up the > scores in res > scorelist.append((j,res[k][k.index(j)])) > best2[i]=sorted(scorelist,key=lambda x: -x[1])[:2] > > > Am I missing an obviously better way? The overall algorithm looks about right. The inner-loop could be tighted-up a bit. And you could replace the outer sort with a heap. best2 = {} for i in itertools.combinations(range( 2**m), n-1): scorelist = [] for j in range( 2**m ): if j not in i: k = tuple(sorted(i + (j,))) scorelist.append((j, res[k][k.index(j)])) best2[i] = heapq.nlargest(2, scorelist, key=operator.itemgetter(1)) Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: Refresh Problem
Victor Subervi wrote: Hi; I send variables to a script. The script adds appropriate lines into a database of an order to my shopping cart. When I refresh the screen, as no doubt some customers will do, it re-ads those orders. Now, I can delete them, but that's not the point. I don't want it to re-ad the orders. How do I skirt this problem? When you click on the Submit button on the form it should post the data, ie use method="post", not method="get". If refreshing causes it to re-submit, then you're using the wrong method. This is basic stuff. -- http://mail.python.org/mailman/listinfo/python-list
Re: Refresh Problem
On 04/11/2010 02:53 PM, MRAB wrote: Victor Subervi wrote: Hi; I send variables to a script. The script adds appropriate lines into a database of an order to my shopping cart. When I refresh the screen, as no doubt some customers will do, it re-ads those orders. Now, I can delete them, but that's not the point. I don't want it to re-ad the orders. How do I skirt this problem? When you click on the Submit button on the form it should post the data, ie use method="post", not method="get". If refreshing causes it to re-submit, then you're using the wrong method. This is basic stuff. And if you do POST your data (which you should if you're attempting to change state on the server), you should use a post/redirect/get pattern[1]. This will prevent the browser from giving the "you've already submitted this data; do you want to resubmit it?" message that most should give you if you refresh a POST'ed page. And therein demonstrates the need to know HTTP as mentioned in my previous reply to you (VS, not MRAB). -tkc [1] http://en.wikipedia.org/wiki/Post/Redirect/Get -- http://mail.python.org/mailman/listinfo/python-list
[ANNC] pynguin-0.7 (python turtle graphics application)
Pynguin is a python-based turtle graphics application. It combines an editor, interactive interpreter, and graphics display area. It is meant to be an easy environment for introducing some programming concepts to beginning programmers. http://pynguin.googlecode.com/ This release changes the method of starting and stopping the separate code-running threads. It should be much less susceptible to lock-ups and crashes, though I am still experiencing occasional problems. Pynguin is tested with Python 2.6.4 and uses PyQt (4.6) for its GUI elements. Pynguin is released under GPLv3. Changes in pynguin-0.7: - fixed deadlock when running with many pynguins at instant speed - new threading model greatly reduces problems with lock-ups - added more multi-pynguin examples - added commands turnto('random') and lineto('random') - added more random color possibilities ('rlight', 'rmedium', 'rdark') - allow named colors and html-style colors - added command clear() - added equation plotting examples - cartesian and polar - re-center on (0, 0) when moving view splitter - added svg/pdf worksheets Changes in pynguin-0.6: - fixed crash when using new_pynguin() - fixed possible crash during startup (due to race condition) - added goto('random') and xy() to easily get coordinates - added keyword args for fill -- fill(color=..., rule=...) - added easier access for fillcolor 'random' - added examples using multiple pynguins - remove any added pynguins when using reset() - set window title when using Save As... - better error messages when loading file with errors - whitespace cleanup when saving files - render About image and title at runtime - more examples Changes in pynguin-0.5: - catch errors when processing graphic move queue - capture and hold stdout and stderr - call str() on argument to write - guard against sending non-int to color _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969 -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating a rainbow?
On 2010-04-11 12:54 , Peter Parker wrote: Tobiah wrote: You should use different variables for the two loops. Actually it is closing the divs that makes it work in FireFox: Hah. I new that the rainbow wasn't complete and that it didn't work in Opera. I just fizzled on the closing of the divs. I also don't get why it worked at all when I was stomping on my x variable in the inside loop. It's better now. http://tobiah.org/rainbow.html Better than before ... Oy G. Bivr Uh, the first color is #FF, pure red, not orange. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read file during module import?
I have had trouble with the __file__ attribute in the past, when using py2exe (i.e. on the windows platform) and using the bundle feature (which zips all files). Using os.path.realpath( __file__ ) resolves to something like .../ library.zip/packageName/fileName Then when trying to perform an open on a file, say .../library.zip/ packageName/supportingPackageName, the file can not be found. -- http://mail.python.org/mailman/listinfo/python-list
Confused by slash/escape in regexp
Is the third case here surprising to anyone else? It doesn't make sense to me... Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from re import compile >>> p1 = compile('a\x62c') >>> p1.match('abc') <_sre.SRE_Match object at 0x7f4e8f93d578> >>> p2 = compile('a\\x62c') >>> p2.match('abc') <_sre.SRE_Match object at 0x7f4e8f93d920> >>> p3 = compile('a\\\x62c') >>> p3.match('a\\bc') >>> p3.match('abc') >>> p3.match('a\\\x62c') >>> Curious/confused, Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Sun, 11 Apr 2010 10:34:50 -0700, Joaquin Abian wrote: > On Apr 11, 6:53 pm, Steven D'Aprano cybersource.com.au> wrote: >> >> In any case, IDLE is one IDE out of many, and not really up to >> professional quality -- it's clunky and ugly. It isn't Python, it is a >> tool written in Python. >> >> -- >> Steven > > But this is a tool that is a part of the python distribution and often > recommended to python beginners as their first IDE. So IDLE is > responsible for the first impression on Python to many. If IDLE is > considered as of low quality and ugly, after so many years, why it is > not fixed or replaced?. > I'm just wondering. Which toolset should the IDE target? Native Windows? QT? Gnome? Cocoa? Something else? That will require a widget library. How many widget libraries should Python ship with? Two? Three? Five? Which ones? wxPython? PythonCard? Something else? They tend to be very large. Do the Python developers then become responsible for fixing bugs in the widget libraries? Python ships with, at most, a single GUI toolset, tkinter, which targets the Tcl/Tk toolkit. Consider it the lowest common denominator of modern GUIs, although I hear that Tk now supports native widgets. But that still requires work. See here: http://stackoverflow.com/questions/349409/why-are-tk-guis-considered-ugly But what it really comes down to is time and effort. GUI design is hard, and unless somebody volunteers to make IDLE look and feel better, it isn't going to just upgrade itself. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Sun, 11 Apr 2010 11:54:04 -0700, Mensanator wrote: > On Apr 11, 11:53�am, Steven D'Aprano cybersource.com.au> wrote: >> On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: >> >> > 3.x won't be adopted by developers until it's fixed. As of now, >> >> > it's seriously broken and unsuitable for production. >> >> >> In what ways do you consider it broken? >> >> > Issue 8093. Remarkably, this apparently hasn't been noticed before. >> >> I think that tells you that it's an unimportant bug that doesn't really >> effect many people much, > > It affects me ... a LOT. I suspect you're exaggerating, but even if you're not, you are not the entire Python community. You stated that "3.x won't be adopted by developers until it's fixed". It sounds like what you really mean was "3.x won't be adopted by *me* until it's fixed". 3.x is already being adopted by developers. The two biggest factors slowing uptake of 3.x are: (1) lack of big libraries like numpy, and (2) that major Linux distros still ship with 2.6 or 2.5. >> and a million miles from implying that Python 3.x is "seriously broken >> and unsuitable for production". > > Maybe because I'm a user, not a developer. You write code. You use an Integrated DEVELOPMENT Environment. That makes you a developer. >> > I expect 2.7 will be around for a long time. >> >> As reported on the bug tracker, this bug effects Python 2.7 as well. >> It's possible this bug goes back to, what? Python 2.5? 2.4? 2.3? Older? >> Who knows? > > I can't imagine my not having noticed this before. It's plausible I > might not have noticed the runaway processes, but the fact that I can't > eject a USB drive would have been very obvious. Have you tried to reproduce it on 2.6 or 2.5? Unless you actively try to reproduce it, you can't assume it doesn't occur. >> http://bugs.python.org/issue8093#msg102818 >> >> In any case, IDLE is one IDE out of many, and not really up to >> professional quality -- it's clunky and ugly. It isn't Python, it is a >> tool written in Python. > > You have no idea what the cause is, yet you're certain that the symptom > is confined to IDLE. Certain? Of course not. But given an issue that is reported with a single application, which is more likely? That it is a bug in the language, or a bug in the application? Even if it is a bug in the language, some fundamental failure of the underlying Python virtual machine or built-in objects, there are dozens of standard library modules, and thousands of third-party modules, that it doesn't affect. > That's the kind of thinking that leads to such bugs in the first place. Rght. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused by slash/escape in regexp
On 04/12/10 08:43, andrew cooke wrote: > > Is the third case here surprising to anyone else? It doesn't make > sense to me... > > Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) > [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 > Type "help", "copyright", "credits" or "license" for more information. from re import compile p1 = compile('a\x62c') p1.match('abc') > <_sre.SRE_Match object at 0x7f4e8f93d578> p2 = compile('a\\x62c') p2.match('abc') > <_sre.SRE_Match object at 0x7f4e8f93d920> p3 = compile('a\\\x62c') p3.match('a\\bc') p3.match('abc') p3.match('a\\\x62c') It isn't so much about regex but about string: Python 2.6.4 (r264:75706, Mar 18 2010, 01:03:14) [GCC 4.3.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print 'a\x62c' abc >>> print 'a\\x62c' a\x62c >>> print 'a\\\x62c' a\bc In the first case, *python* will unescape the string literal '\x62' into letters 'b'. In the second case, python will unescape the double backslash '\\' into a single slash '\' and *regex* will unescape the single-slash-62 into 'b'. In the third case, *python* will unescape double backslash '\\' into single-slash '\' and byte-string-62 '\x62' to letter-b 'b', and regex received it as 'a\bc', which interpreted as a special character to regex: """ \b Matches the empty string, but only at the start or end of a word. """ -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused by slash/escape in regexp
On Apr 11, 8:12 pm, Lie Ryan wrote: > In the first case, *python* will unescape the string literal '\x62' into > letters 'b'. In the second case, python will unescape the double > backslash '\\' into a single slash '\' and *regex* will unescape the > single-slash-62 into 'b'. In the third case, *python* will unescape > double backslash '\\' into single-slash '\' and byte-string-62 '\x62' to > letter-b 'b', and regex received it as 'a\bc', which interpreted as a > special character to regex: > """ > \b Matches the empty string, but only at the start or end of a word. > """ ah, brilliant! yes. thank-you very much! andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused by slash/escape in regexp
On Apr 11, 5:43 pm, andrew cooke wrote: > Is the third case here surprising to anyone else? It doesn't make > sense to me... > > Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) > [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> > from re import compile > >>> p1 = compile('a\x62c') > >>> p1.match('abc') > > <_sre.SRE_Match object at 0x7f4e8f93d578 p2 = compile('a\\x62c') > >>> p2.match('abc') > > <_sre.SRE_Match object at 0x7f4e8f93d920> > > >>> p3 = compile('a\\\x62c') > >>> p3.match('a\\bc') > >>> p3.match('abc') > >>> p3.match('a\\\x62c') > > Curious/confused, > Andrew Here is your same session, but using raw string literals: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from re import compile >>> p1 = compile(r'a\x62c') >>> p1.match(r'abc') <_sre.SRE_Match object at 0x00A04BB8> >>> p2 = compile(r'a\\x62c') >>> p2.match(r'abc') >>> p3 = compile(r'a\\\x62c') >>> p3.match(r'a\\bc') >>> p3.match(r'abc') >>> p3.match(r'a\\\x62c') >>> So I would say the surprise isn't that case 3 didn't match, but that case 2 matched. Unless I just don't get what you were testing, not being an RE wiz. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused by slash/escape in regexp
On Apr 11, 7:18 pm, Paul McGuire wrote: [...] > > So I would say the surprise isn't that case 3 didn't match, but that > case 2 matched. > > Unless I just don't get what you were testing, not being an RE wiz. Case 2 is the regexp engine interpreting escapes that appear as literal strings. It's weird, because what's the point of Python would do it for you anyway, but it seems to be the correct behaviour. Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: Tough sorting problem: or, I'm confusing myself
On Apr 9, 10:03 am, david jensen wrote: > Hi all, > > I'm trying to find a good way of doing the following: > > Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding > value n-tuple (call them "scores" for clarity later). I'm currently > storing them in a dictionary, by doing: > > > res={} > for i in itertools.combinations( range( 2**m ) , n): > res[ i ] = getValues( i ) # getValues() is computationally > expensive > > > For each (n-1)-tuple, I need to find the two numbers that have the > highest scores versus them. I know this isn't crystal clear, but > hopefully an example will help: with m=n=3: > > Looking at only the (1, 3) case, assuming: > getValues( (1, 2, 3) ) == ( -200, 125, 75 ) # this contains the > highest "other" score, where 2 scores 125 > getValues( (1, 3, 4) ) == ( 50, -50, 0 ) > getValues( (1, 3, 5) ) == ( 25, 300, -325 ) > getValues( (1, 3, 6) ) == ( -100, 0, 100 ) # this contains the > second-highest, where 6 scores 100 > getValues( (1, 3, 7) ) == ( 80, -90, 10 ) > getValues( (1, 3, 8) ) == ( 10, -5, -5 ) > > I'd like to return ( (2, 125), (6, 100) ). > > The most obvious (to me) way to do this would be not to generate the > res dictionary at the beginning, but just to go through each > combinations( range( 2**m), n-1) and try every possibility... this > will test each combination n times, however, and generating those > values is expensive. [e.g. (1,2,3)'s scores will be generated when > finding the best possibilities for (1,2), (1,3) and (2,3)] > Add a memoizing decorator to getValues, so that repeated calls will do lookups instead of repeated calculations. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused by slash/escape in regexp
andrew cooke wrote: Is the third case here surprising to anyone else? It doesn't make sense to me... Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 Type "help", "copyright", "credits" or "license" for more information. from re import compile p1 = compile('a\x62c') 'a\x62c' is a string literal which is the same as 'abc', so re.compile receives the characters: abc as the regex, which matches the string: abc p1.match('abc') <_sre.SRE_Match object at 0x7f4e8f93d578> p2 = compile('a\\x62c') 'a\\x62c' is a string literal which represents the characters: a\x62c so re.compile receives these characters as the regex. The re module understands has its own set of escape sequences, most of which are the same as Python's string escape sequences. The re module treats \x62 like the string escape, ie it represents the character 'b', so this regex is the same as: abc p2.match('abc') <_sre.SRE_Match object at 0x7f4e8f93d920> p3 = compile('a\\\x62c') 'a\\\x62c' is a string literal which is the same as 'a\\bc', so re.compile receives the characters: a\bc as the regex. The re module treats the \b in a regex as representing a word boundary, unless it's in a character set, eg. [\b]. The regex will try to match a word boundary sandwiched between 2 letters, which can never happen. p3.match('a\\bc') p3.match('abc') p3.match('a\\\x62c') -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
Mensanator wrote: > Planning to buy a Toyota? Did we just start playing Questions? -- http://mail.python.org/mailman/listinfo/python-list
Re: universal newlines and utf-16
Le Sun, 11 Apr 2010 16:16:45 +0100, Baz Walter a écrit : > On 11/04/10 15:37, Stefan Behnel wrote: >> The codecs module does not support universal newline parsing (see the >> docs). You need to use the new io module instead. > > thanks. > > i'd completely overlooked the io module - i thought it was only in > python 2.7/3.x. To be precise, the 2.6 version is a slow one, written in pure Python (and it might be a bit less debugged too). But codecs.open() is slow, too. -- http://mail.python.org/mailman/listinfo/python-list
It's a fact not lost on the opportunity to see yourself
http://www.google.com/url?sa=D&q=http://osamah2000.jeeran.com/daauageralmuslmeen1.htm&usg=AFQjCNGQhhGz-1TGv9Y7gE8zKwHHustJCg -- http://mail.python.org/mailman/listinfo/python-list
Re: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application)
2010/4/11 Lee Harr : > > Pynguin is a python-based turtle graphics application. > It combines an editor, interactive interpreter, and > graphics display area. > I like the idea of using turtles to plot graphs. Replacing graphing calculators with Python is easier when there are simple plot functions available (yes, I know about matplotlib, Sage...) Curious how much of the Standard Library turtle model gets used here. Is the turtle stuff all rewritten from scratch. Kirby -- http://mail.python.org/mailman/listinfo/python-list
2010 Congress on Computer Applications and Computational Science, Singapore [EI Compendex,ISTP,IEEE Xplore]
[ Please forward to those who may be interested. Thanks. ] == 2010 International Congress on Computer Applications and Computational Science CACS 2010 http://irast.org/conferences/CACS/2010 4-6 December 2010, Singapore == CACS 2010 aims to bring together researchers and scientists from academia, industry, and government laboratories to present new results and identify future research directions in computer applications and computational science. Topics of interest include, but are not limited to: Agent and Autonomous Systems Computational Biology and Bioinformatics Computer-Aided Design and Manufacturing Computer Architecture and VLSI Computer Control and Robotics Computer Graphics, Animation and Virtual Reality Computers in Education & Learning technology Computer Modeling and Simulations Computer Networks and Communications Computer Security and Privacy Computer Vision and Pattern Recognition Data Mining and Data Engineering Distributed and Services Computing Energy and Power Systems Intelligent Systems Internet and Web Systems Nano Technologies Real-Time and Embedded Systems Scientific Computing and Applications Signal, Image and Multimedia Processing Software Engineering Test Technologies CACS 2010 conference proceedings will be published by CPS which will include the conference proceedings in IEEE Xplore and submit the proceedings to Ei Compendex and ISTP for indexing. Singapore's cultural diversity reflects its colonial history and Chinese, Malay, Indian and Arab ethnicities. English is the dominant official language, which is convenient for foreign visitors. Places of interest, such as the Orchard Road district, Singapore Zoo, Night Safari, and Sentosa, attract millions of visitors a year. Singapore is a paradise for shopping, dinning, entertainment, and nightlife, with two new integrated resorts. Conference Contact: c...@irast.org Paper Submission Deadline: 15 May 2010 Review Decision Notifications: 15 August 2010 Final Papers and Author Registration Deadline: 9 September 2010 -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating a rainbow?
Robert Kern wrote: On 2010-04-11 12:54 , Peter Parker wrote: Tobiah wrote: You should use different variables for the two loops. Actually it is closing the divs that makes it work in FireFox: Hah. I new that the rainbow wasn't complete and that it didn't work in Opera. I just fizzled on the closing of the divs. I also don't get why it worked at all when I was stomping on my x variable in the inside loop. It's better now. http://tobiah.org/rainbow.html Better than before ... Oy G. Bivr Uh, the first color is #FF, pure red, not orange. Ah, you're right, but it's only 1 pixel high so it's hard to see. The last one is also #FF, pure red ... Roy G. Bivr -- http://mail.python.org/mailman/listinfo/python-list
Re: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application)
2010/4/11 Lee Harr : > > Pynguin is a python-based turtle graphics application. > It combines an editor, interactive interpreter, and > graphics display area. > > It is meant to be an easy environment for introducing > some programming concepts to beginning programmers. > > > http://pynguin.googlecode.com/ Lee, are you familiar with the Turtle Art activity in Sugar for the OLPC XO, also written in Python? It provides blocks for integrating Python code. You might want to talk to Walter Bender of Sugar Labs about his plans for expanding TA, some of which match yours. I have been thinking about how to integrate all of this into a curriculum where we would apply turtle graphics to many subjects starting in first grade or perhaps earlier, and later teach programming and Computer Science within this environment rather than purely as text. > This release changes the method of starting and stopping > the separate code-running threads. It should be much > less susceptible to lock-ups and crashes, though I > am still experiencing occasional problems. > > > Pynguin is tested with Python 2.6.4 and uses PyQt (4.6) > for its GUI elements. Pynguin is released under GPLv3. > > > Changes in pynguin-0.7: > - fixed deadlock when running with many pynguins at instant speed > - new threading model greatly reduces problems with lock-ups > - added more multi-pynguin examples > - added commands turnto('random') and lineto('random') > - added more random color possibilities ('rlight', 'rmedium', 'rdark') > - allow named colors and html-style colors > - added command clear() > - added equation plotting examples - cartesian and polar > - re-center on (0, 0) when moving view splitter > - added svg/pdf worksheets > > > Changes in pynguin-0.6: > - fixed crash when using new_pynguin() > - fixed possible crash during startup (due to race condition) > - added goto('random') and xy() to easily get coordinates > - added keyword args for fill -- fill(color=..., rule=...) > - added easier access for fillcolor 'random' > - added examples using multiple pynguins > - remove any added pynguins when using reset() > - set window title when using Save As... > - better error messages when loading file with errors > - whitespace cleanup when saving files > - render About image and title at runtime > - more examples > > > Changes in pynguin-0.5: > - catch errors when processing graphic move queue > - capture and hold stdout and stderr > - call str() on argument to write > - guard against sending non-int to color > > > _ > Hotmail: Trusted email with Microsoft’s powerful SPAM protection. > https://signup.live.com/signup.aspx?id=60969 > ___ > Edu-sig mailing list > edu-...@python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application)
On Sun, Apr 11, 2010 at 21:52, kirby urner wrote: > 2010/4/11 Lee Harr : >> >> Pynguin is a python-based turtle graphics application. >> It combines an editor, interactive interpreter, and >> graphics display area. >> > > I like the idea of using turtles to plot graphs. Illustrated at http://wiki.sugarlabs.org/go/Activities/Turtle_Art#maths . I have done more examples. > Replacing graphing > calculators with Python is easier when there are simple plot functions > available (yes, I know about matplotlib, Sage...) > > Curious how much of the Standard Library turtle model gets used here. > Is the turtle stuff all rewritten from scratch. > > Kirby > ___ > Edu-sig mailing list > edu-...@python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On 04/12/10 04:54, Mensanator wrote: > On Apr 11, 11:53�am, Steven D'Aprano cybersource.com.au> wrote: >> On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: > 3.x won't be adopted by developers until it's fixed. As of now, it's > seriously broken and unsuitable for production. >> In what ways do you consider it broken? >> >>> Issue 8093. Remarkably, this apparently hasn't been noticed before. >> >> I think that tells you that it's an unimportant bug that doesn't really >> effect many people much, > > It affects me ... a LOT. > One way to fix it, dump tkinter and IDLE. C/C++ is not broken since they do not ship with an ugly GUI library or half-assed IDE called IDLE. Why should python ship with them? On a second thought, let me think about it again. -- http://mail.python.org/mailman/listinfo/python-list
Re: (a==b) ? 'Yes' : 'No'
In article , Steve Holden wrote: > >It exists because people nagged Guido mercilessly until, against his >better judgment, he capitulated. No, the ternary exists because he became convinced that it was the lesser evil compared with letting the abomination of A and B or C remain the "Pythonic" ternary and someone came up with a syntax that wasn't completely painful. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan -- http://mail.python.org/mailman/listinfo/python-list
Re: A 'foolproof' way to query inheritance tree? numbers.Real in 2.6)
On Sun, Apr 11, 2010 at 10:46 AM, wrote: > Generally, if I want to know the inheritance tree of a class, I either > use inspect.getmro or __bases__ > > However, after reading about the new numbers module / class tower in > Python 2.6/3.0, I realized that both of these will fail to show that > the 'float' type actually inherits from numbers.Real: Well, as your introspection shows, it doesn't *actually* inherit from numbers.Real. However, it does "implement" the numbers.Real Abstract Base Class (ABC) and this is reported via the results of issubclass(). Basically, `issubclass(x, y)` is no longer more-or-less just sugar for `y in x.__mro__` due to changes that have been made to accommodate ABCs. Quoting from the `abc` module docs (http://docs.python.org/library/abc.html): """[...] You can also register unrelated concrete classes (even built-in classes) [...] as “virtual subclasses” – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable.""" See also the relevant part of the ABC PEP (PEP 3119): http://www.python.org/dev/peps/pep-3119/#overloading-isinstance-and-issubclass Cheers, Chris -- http://blog.rebertia.com import inspect, numbers issubclass(float, numbers.Real) > True inspect.getmro(float) > (, ) float.__bases__ > (,) -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Apr 11, 11:33 pm, Lie Ryan wrote: > On 04/12/10 04:54, Mensanator wrote: > > > On Apr 11, 11:53 am, Steven D'Aprano > cybersource.com.au> wrote: > >> On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: > > 3.x won't be adopted by developers until it's fixed. As of now, it's > > seriously broken and unsuitable for production. > > In what ways do you consider it broken? > > >>> Issue 8093. Remarkably, this apparently hasn't been noticed before. > > >> I think that tells you that it's an unimportant bug that doesn't really > >> effect many people much, > > > It affects me ... a LOT. > > One way to fix it, dump tkinter and IDLE. Of course, that doesn't fix the problem, does it? You think the right thing to do is just quietly work around the problem and sit back and laugh knowing sooner or later someone else will get burned by it? And here I thought I was making a contribution by discovering something that no one else noticed. > > C/C++ is not broken since they do not ship with an ugly GUI library or > half-assed IDE called IDLE. Why do you guys think I'm talking about the language? I'm talking about a particular implementation. > Why should python ship with them? > > On a second thought, let me think about it again. Yeah, you certainly don't want to get yelled at by Mr. D'Aprano. -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On Apr 11, 6:08 pm, Steven D'Aprano wrote: > On Sun, 11 Apr 2010 11:54:04 -0700, Mensanator wrote: > > On Apr 11, 11:53 am, Steven D'Aprano > cybersource.com.au> wrote: > >> On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: > >> >> > 3.x won't be adopted by developers until it's fixed. As of now, > >> >> > it's seriously broken and unsuitable for production. > > >> >> In what ways do you consider it broken? > > >> > Issue 8093. Remarkably, this apparently hasn't been noticed before. > > >> I think that tells you that it's an unimportant bug that doesn't really > >> effect many people much, > > > It affects me ... a LOT. > > I suspect you're exaggerating, I'm not. I often use a USB drive to store my source programs, makes it easy to switch between computers. Not being able to eject the USB drive is annoying, but not a game breaker. Likewise, I usually don't shut down when I leave work, so I can't allow orphaned processes to accumulate eating up CPU and memory. > but even if you're not, you are not the entire Python community. This is probably happening to everyone, they just haven't noticed. > You stated that "3.x won't be adopted by developers until it's fixed". > It sounds like what you really mean was > "3.x won't be adopted by *me* until it's fixed" Not at all. The only 3rd party library I use is gmpy, and that's been updated, so I have more or less abandoned 2.x in favor of 3.x. I have not installed the latest 2.6 version and have no intention of ever installing 2.7 . > > 3.x is already being adopted by developers. Let's hope a little thing like this won't upset them. > The two biggest factors > slowing uptake of 3.x are: (1) lack of big libraries like numpy, and (2) > that major Linux distros still ship with 2.6 or 2.5. It was even worse with Mac OSX 10.6. Luckily, there's macports, so it all got resolved. > > >> and a million miles from implying that Python 3.x is "seriously broken > >> and unsuitable for production". > > > Maybe because I'm a user, not a developer. > > You write code. You use an Integrated DEVELOPMENT Environment. That makes > you a developer. Being a little pedantic here, aren't we? Would it help if I said "professional" developer? After all, just because I dabble in Collatz Conjecture research as a hobby, it doesn't give me the right to go around calling myself a mathematician. > > >> > I expect 2.7 will be around for a long time. > > >> As reported on the bug tracker, this bug effects Python 2.7 as well. > >> It's possible this bug goes back to, what? Python 2.5? 2.4? 2.3? Older? > >> Who knows? > > > I can't imagine my not having noticed this before. It's plausible I > > might not have noticed the runaway processes, but the fact that I can't > > eject a USB drive would have been very obvious. > > Have you tried to reproduce it on 2.6 or 2.5? No, all I can say is I haven't noticed it there. And given the symptoms, I can't see how I could have not noticed it. On the other hand, I can't see how it could have gone unnoticed on 3.x. You don't suppose I'm the only one actually using 3.1? > Unless you actively try to > reproduce it, you can't assume it doesn't occur. True, just as you can't assume I'm the only one it's happening to. > > >>http://bugs.python.org/issue8093#msg102818 > > >> In any case, IDLE is one IDE out of many, and not really up to > >> professional quality -- it's clunky and ugly. It isn't Python, it is a > >> tool written in Python. > > > You have no idea what the cause is, yet you're certain that the symptom > > is confined to IDLE. > > Certain? Of course not. But given an issue that is reported with a single > application, which is more likely? That it is a bug in the language, or a > bug in the application? *I* never said the LANGUAGE was broken. I specifically made reference to the Windows implementation of 3.1.2. > > Even if it is a bug in the language, some fundamental failure of the > underlying Python virtual machine or built-in objects, there are dozens > of standard library modules, and thousands of third-party modules, that > it doesn't affect. I assume you mean when not run in IDLE. And how do you know they're not affected? Didn't you just get done yelling at me for not testing it in 2.5 & 2.6? > > > That's the kind of thinking that leads to such bugs in the first place. > > Rght. You think these bugs are done deliberately? > > -- > Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.7 beta 1
On 04/12/10 06:57, Mensanator wrote: On Apr 11, 6:08 pm, Steven D'Aprano wrote: On Sun, 11 Apr 2010 11:54:04 -0700, Mensanator wrote: On Apr 11, 11:53 am, Steven D'Aprano wrote: On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote: Maybe because I'm a user, not a developer. You write code. You use an Integrated DEVELOPMENT Environment. That makes you a developer. Being a little pedantic here, aren't we? Would it help if I said "professional" developer? After all, just because I dabble in Collatz Conjecture research as a hobby, it doesn't give me the right to go around calling myself a mathematician. Well professional in IT context often just means that you do it for a living, doesn't necessarly say you are any good in what you are doing. I am especially wary to certified professionals by biased 'institutes' like Cisco and Microsoft. -- mph -- http://mail.python.org/mailman/listinfo/python-list
Re: Python question
Hello, Python and gtk are "ambulant" (portable plus intallable by mere copying without admin rights). gtk only needs to have the path to its / bin on the PATH . The latter could - and possibly should be - done by the Python scripts using it, for example: s = os.environ['PATH'] if s.find(gtkBinDir) == -1: os.putenv("PATH", os.getenv("PATH")+ os.pathsep + gtkBinDir) for gtkBinDir from some GlobalConstants.py. Pygtk breaks that "ambulance" - its parts use the registry, but only for finding Python during installation. Afterwards such a Python is ambulant again - that means with its pygtk (this little flaw is a minor reason for me to work on my depikt). I am on Windows normally, but never considered pywin. Good luck, Joost -- http://mail.python.org/mailman/listinfo/python-list
Re: Python question
Rereading my sent answer i wondered, what the variable s was used for besides that "find" and found nothing. Without it also the layout is better: if os.environ['PATH'].find(gtkBinDir) == -1: os.putenv("PATH", os.getenv("PATH")+ os.pathsep + gtkBinDir) -- http://mail.python.org/mailman/listinfo/python-list
Re: (a==b) ? 'Yes' : 'No'
On Sun, 11 Apr 2010 21:35:49 -0700, Aahz wrote: > In article , Steve > Holden wrote: >> >>It exists because people nagged Guido mercilessly until, against his >>better judgment, he capitulated. > > No, the ternary exists because he became convinced that it was the > lesser evil compared with letting the abomination of > > A and B or C > > remain the "Pythonic" ternary and someone came up with a syntax that > wasn't completely painful. As I recall, Guido himself got bitten by a subtle bug in the A and B or C idiom for ternary operator. Namely, if B is a false value, you get C even if A is true. -- Steven -- http://mail.python.org/mailman/listinfo/python-list