From wcdolphin at gmail.com Wed Feb 6 10:13:39 2013 From: wcdolphin at gmail.com (wcdolphin at gmail.com) Date: Wed, 6 Feb 2013 07:13:39 -0800 (PST) Subject: Compiling native extensions with Visual Studio 2012? In-Reply-To: References: Message-ID: On Saturday, January 12, 2013 2:45:38 AM UTC-5, Alec Taylor wrote: > There have been various threads for MSVC 2010[1][2], but the most > > recent thing I found for MSVC 2012 was [3]? from 6 months ago. > > > > Basically I want to be able to compile bcrypt?and yes I should be > > using Keccak?x64 binaries on Windows x64. > > > > There are other packages also which I will benefit from, namely I > > won't need to use the unofficial setup files and will finally be able > > to use virtualenv. > > > > So anyway, can I get an update on the status of MSVC 2010 and MSVC > > 2012 compatibility? > > > > Thanks, > > > > Alec Taylor > > > > [1] http://bugs.python.org/issue13210 > > [2] http://webcache.googleusercontent.com/search?q=cache:xPaU9mlCBNEJ:wiki.python.org/moin/VS2010+&cd=1&hl=en&ct=clnk > > [3] https://groups.google.com/d/topic/dev-python/W1RpFhaOIGk Besides the deep technicality of potential conflicts, two changes will allow you to compile your C extension. msvc9compiler.py is written only looking for VS2010, and even if you have vs2010 installed, it will still fail on Windows 7, Windows 8 with silly manifest errors. The fix is simple: In: Python27/Lib/distutils/msvc9compiler.py, line#648 in definition of "link", before the call to "ld_args.append('/MANIFESTFILE:' + temp_manifest)",insert: ld_args.append('/MANIFEST') line#178 in the definition of "get_build_version", insert: return 11.0 From wcdolphin at gmail.com Wed Feb 6 10:13:39 2013 From: wcdolphin at gmail.com (wcdolphin at gmail.com) Date: Wed, 6 Feb 2013 07:13:39 -0800 (PST) Subject: Compiling native extensions with Visual Studio 2012? In-Reply-To: References: Message-ID: On Saturday, January 12, 2013 2:45:38 AM UTC-5, Alec Taylor wrote: > There have been various threads for MSVC 2010[1][2], but the most > > recent thing I found for MSVC 2012 was [3]? from 6 months ago. > > > > Basically I want to be able to compile bcrypt?and yes I should be > > using Keccak?x64 binaries on Windows x64. > > > > There are other packages also which I will benefit from, namely I > > won't need to use the unofficial setup files and will finally be able > > to use virtualenv. > > > > So anyway, can I get an update on the status of MSVC 2010 and MSVC > > 2012 compatibility? > > > > Thanks, > > > > Alec Taylor > > > > [1] http://bugs.python.org/issue13210 > > [2] http://webcache.googleusercontent.com/search?q=cache:xPaU9mlCBNEJ:wiki.python.org/moin/VS2010+&cd=1&hl=en&ct=clnk > > [3] https://groups.google.com/d/topic/dev-python/W1RpFhaOIGk Besides the deep technicality of potential conflicts, two changes will allow you to compile your C extension. msvc9compiler.py is written only looking for VS2010, and even if you have vs2010 installed, it will still fail on Windows 7, Windows 8 with silly manifest errors. The fix is simple: In: Python27/Lib/distutils/msvc9compiler.py, line#648 in definition of "link", before the call to "ld_args.append('/MANIFESTFILE:' + temp_manifest)",insert: ld_args.append('/MANIFEST') line#178 in the definition of "get_build_version", insert: return 11.0 From cs at zip.com.au Wed Feb 6 18:06:32 2013 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 7 Feb 2013 10:06:32 +1100 Subject: urllib2 FTP Weirdness In-Reply-To: <5100b4a0$0$29877$c3e8da3$5496439d@news.astraweb.com> References: <5100b4a0$0$29877$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20130206230632.GA19046@cskk.homeip.net> On 24Jan2013 04:12, Steven D'Aprano wrote: | On Thu, 24 Jan 2013 01:45:31 +0100, Hans Mulder wrote: | > On 24/01/13 00:58:04, Chris Angelico wrote: | >> Possibly it's some kind of race condition?? | > | > If urllib2 is using active mode FTP, then a firewall on your box could | > explain what you're seeing. But then, that's why active mode is hardly | > used these days. | | Explain please? You do know the difference between active and passive FTP, yes? | I cannot see how the firewall could possible distinguish between using a | temporary variable or not in these two snippets: | | # no temporary variable hangs, or fails | urllib2.urlopen("ftp://ftp2.census.gov/").read() | | # temporary variable succeeds | response = urllib2.urlopen("ftp://ftp2.census.gov/") | response.read() Timing. (Let me say I consider this scenario unlikely, very unlikely. But...) If the latter is consistently slightly slower then the firewall may be an issue if active FTP is being used. "Active" FTP requires the FTP server to connect to you to deliver the data: your end opens a listening TCP socket and says "get", supplying the socket details. Really the TCP protocol is suppose to be plenty robust enough for this not to be timing - the opening SYN packet will get resent if the first try doesn't elicit a response. For this to work over a firewall the firewall must (1) read your FTP control connection to see the port announcements and then (2) open a firewall hole to let the FTP server connect in, probably including a NAT or RDR arrangement to catch the incoming connection and deliver it to your end. Let us not even consider other NATting firewalls further upstream with your ISP. Active FTP (the original FTP mode) is horrible. Passive FTP is more conventional: the server listens and you connect to fetch the file. But it still requires the server to accept connections on multiple ports; ugh. I hate FTP and really don't understand why it is still in common use. -- Cameron Simpson To be positive: To be mistaken at the top of one's voice. Ambrose Bierce (1842-1914), U.S. author. The Devil's Dictionary (1881-1906). From steve+comp.lang.python at pearwood.info Wed Feb 6 21:43:24 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Feb 2013 02:43:24 GMT Subject: urllib2 FTP Weirdness References: <5100b4a0$0$29877$c3e8da3$5496439d@news.astraweb.com> Message-ID: <511314cb$0$21812$c3e8da3$76491128@news.astraweb.com> On Thu, 07 Feb 2013 10:06:32 +1100, Cameron Simpson wrote: > | I cannot see how the firewall could possible distinguish between using > | a temporary variable or not in these two snippets: > | > | # no temporary variable hangs, or fails > | urllib2.urlopen("ftp://ftp2.census.gov/").read() > | > | # temporary variable succeeds > | response = urllib2.urlopen("ftp://ftp2.census.gov/") > | response.read() > > Timing. (Let me say I consider this scenario unlikely, very unlikely. > But...) > > If the latter is consistently slightly slower On my laptop, the difference is of the order of 10 microseconds. About half a million times smaller than the amount of time it takes to open the connection in the first place. > then the firewall may be > an issue if active FTP is being used. "Active" FTP requires the FTP > server to connect to you to deliver the data: your end opens a listening > TCP socket and says "get", supplying the socket details. If you are thinking that the socket gets closed if the read is delayed too much, that doesn't explain the results you are getting. The read succeeds when there is a delay, not when there is no delay. Almost as if something is saying "oh, the read request came in too soon after the connection was made, must block". What can I say? I cannot reproduce the issue you are having. If you can reproduce it, try again without the firewall. If bypassing the firewall makes the issue go away, then go and yell at your network admins until they fix it. -- Steven From cs at zip.com.au Thu Feb 7 16:49:48 2013 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 8 Feb 2013 08:49:48 +1100 Subject: urllib2 FTP Weirdness In-Reply-To: <511314cb$0$21812$c3e8da3$76491128@news.astraweb.com> References: <511314cb$0$21812$c3e8da3$76491128@news.astraweb.com> Message-ID: <20130207214947.GA19251@cskk.homeip.net> On 07Feb2013 02:43, Steven D'Aprano wrote: | On Thu, 07 Feb 2013 10:06:32 +1100, Cameron Simpson wrote: | > Timing. (Let me say I consider this scenario unlikely, very unlikely. | > But...) | > If the latter is consistently slightly slower | | On my laptop, the difference is of the order of 10 microseconds. Like I said, I do not consider this likely. | > then the firewall may be | > an issue if active FTP is being used. "Active" FTP requires the FTP | > server to connect to you to deliver the data: your end opens a listening | > TCP socket and says "get", supplying the socket details. | | If you are thinking that the socket gets closed if the read is delayed | too much, that doesn't explain the results you are getting. The read | succeeds when there is a delay, not when there is no delay. Almost as if | something is saying "oh, the read request came in too soon after the | connection was made, must block". Exactly so. For active FTP the firewall must accept an _inbound_ connection from the server. If that connection's opening SYN packet comes in _before_ the firewall has set up the special purpose rule to accept this (remember, the fw is not the FTP client) then the firewall will quite possibly _reject_ the inbound SYN packet, causing the server to see "connection refused". client: open listening socket for data say "GET foo" to server, with socket details server: connect to the socket send data... The firewall's in the middle, watching for the socket details. When it sees them it must create an inbound forwarding rule to let the server's inbound DATA connection through to the client. But the server believes the socket is already available (because it is - the client makes it before supplying the socket details) and may dispatch the DATA connection before the firewall gets its rule in place. | What can I say? I cannot reproduce the issue you are having. If you can | reproduce it, try again without the firewall. If bypassing the firewall | makes the issue go away, then go and yell at your network admins until | they fix it. If it is a speed thing, it may not be fixable. The fix is to use PASV mode FTP or better still to avoid FTP entirely. I certainly don't support active FTP on the firewalls I administer. Cheers, -- Cameron Simpson Symbol? What's a symbol? This is a rose. - R.A. MacAvoy, _Tea with the Black Dragon_ From jsf80238 at gmail.com Sun Feb 3 12:18:42 2013 From: jsf80238 at gmail.com (Jason Friedman) Date: Sun, 3 Feb 2013 09:18:42 -0800 Subject: Formatting a column's value output In-Reply-To: References: <6ad78df4-0ec0-4760-8f5a-5ecf129c5e65@googlegroups.com> <03036f30-ec7a-4992-9494-4c3372a4e02e@ui9g2000pbc.googlegroups.com> Message-ID: > One of the difficulties on this list is that we don't have > two-dimensional people. Even our worst trolls have some redeeming > features. I can't just dismiss Ferrous out of hand... Indeed, and that is a "problem" with humanity in general. It is proof that God (or the universe) has a sense of humor. You and the others on this list who answer questions are earning a _lot_ of good karma. From steve+comp.lang.python at pearwood.info Mon Feb 4 01:39:10 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Feb 2013 06:39:10 GMT Subject: Formatting a column's value output References: <6ad78df4-0ec0-4760-8f5a-5ecf129c5e65@googlegroups.com> <03036f30-ec7a-4992-9494-4c3372a4e02e@ui9g2000pbc.googlegroups.com> Message-ID: <510f578e$0$29866$c3e8da3$5496439d@news.astraweb.com> On Sun, 03 Feb 2013 09:18:42 -0800, Jason Friedman wrote: >> One of the difficulties on this list is that we don't have >> two-dimensional people. Even our worst trolls have some redeeming >> features. I can't just dismiss Ferrous out of hand... > > Indeed, and that is a "problem" with humanity in general. It is proof > that God (or the universe) has a sense of humor. If so, it's a vicious, nasty sense of humour. Imagine how simpler the world would be if there were no shades of grey, and we could easily, objectively and accurately divide people into two groups with no overlap: - useful, nice, friendly people - trolls and other low-lives But no, even the worst scum have some redeeming features, and so we're left with difficult subjective judgements, and nobody can agree whether or not Person X should be pushed into a wood-chipper. -- Steven From kwpolska at gmail.com Sat Feb 2 11:49:36 2013 From: kwpolska at gmail.com (Kwpolska) Date: Sat, 2 Feb 2013 17:49:36 +0100 Subject: pip and distutils In-Reply-To: References: Message-ID: On Mon, Jan 28, 2013 at 10:31 PM, Vraj Mohan wrote: > I have created a source distribution using distutils which specifies > external packages using: > > setup( > ..., > requires = ['Foo (>= 0.7)', 'Bar (>= 2.4.5)'], > ... > ) > > When I use pip to install this distribution, I find that it does not > automatically install the packages Foo and Bar. What extra step do I > need to perform to have pip automatically install the "required" > packages? > > I am using Python 3.2.3. > > --Vraj > -- > http://mail.python.org/mailman/listinfo/python-list You should put your requirements in the requirements.txt, replaced by newlines. Example: Foo >= 0.7 Bar >= 2.4.5 Or something like that. -- Kwpolska | GPG KEY: 5EAAEA16 stop html mail | always bottom-post http://asciiribbon.org | http://caliburn.nl/topposting.html From rantingrickjohnson at gmail.com Sun Feb 3 00:20:48 2013 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 2 Feb 2013 21:20:48 -0800 (PST) Subject: Please provide a better explanation of tuples and dictionaries In-Reply-To: References: Message-ID: <36061bf4-2a65-4ac2-91a1-30f8348f4b0d@googlegroups.com> ############################################################ # Quote: Daniel Rouse Jr. # ############################################################ # To me, this looks like an array. Is tuple just the # # Python name for an array? # ############################################################ The problem with understanding Python collections is directly due to improper naming. First let's consider the sequence types "list" and "tuple". For the most part lists and tuples are exactly the same. They are both containers for holding values. GvR wisely choose to borrow the English word "list" over the esoteric CS term "array", but he /unwisely/ choose to borrow the maths term "tuple" over something more self-documenting to describe what is basically an immutable list. Even someone who has no programming experience could most probably intuit what a "Python list" /is/. Everyone has made a grocery list, or a "to-do" list. The transformation from a tangible object like: *a linear list of items written on paper* to an intangible object like: *a Python list holding N objects* is not very difficult fathom. HOWEVER, then along comes the "seemingly" innocent tuple with fiery red hair and that devilish little grin intent on screwing up the whole logical flea circus! Now you may ask yourself: WHAT THE HELL IS A TUPLE? AND WHERE DID THIS ESOTERIC TERM ORIGINATE! And if you ask the oracle (aka: Google) you might get this answer: *Google Said:* /"""In mathematics and computer science, a tuple is an ordered list of elements. In set theory, an (ordered) n-tuple is a sequence (or ordered list) of n elements, where n is a non-negative integer. """"/ Okay google, so a tuple is an /ordered set/ and a list is an /ordered collection/, got it, (and thanks GvR for the mental overload!) however the names fail to convey this VERY important piece of information For the fix, it would seem logical to simply extend the term "list" in a manner that will convey a "set" relationship. "DynamicList" and "StaticList" fit the bill HOWEVER these terms are FAR to verbose to use on a daily basis! Now, we could naively use "list" for an ordered collection, and "staticlist" for an ordered set, HOWEVER even this is a foolish choice! The final solution is NOT two different types with verbose names, NO, the solution is ONE ordered collection type with a method to convert it into an ordered set. Observe: py> list = list() py> list.extend([1,2,3]) [1,2,3] py> list.append('logical') [1,2,3,'logical'] py> staticList = list.freeze() py> staticList[-1] 'logical' py> staticList.append('error') Traceback (most recent call last): File "", line 1, in staticList.append('error') AttributeError: 'StaticList' object has no attribute 'append' *school-bell* From torriem at gmail.com Sun Feb 3 02:14:30 2013 From: torriem at gmail.com (Michael Torrie) Date: Sun, 03 Feb 2013 00:14:30 -0700 Subject: Please provide a better explanation of tuples and dictionaries In-Reply-To: <36061bf4-2a65-4ac2-91a1-30f8348f4b0d@googlegroups.com> References: <36061bf4-2a65-4ac2-91a1-30f8348f4b0d@googlegroups.com> Message-ID: <510E0E56.8030007@gmail.com> On 02/02/2013 10:20 PM, Rick Johnson wrote: > *school-bell* I'm already regretting typing this, but really? The term, "tuple," was used rather consistently all through my university years. And Python's use of it is consistent with how it is used all through computer science. And for that matter it is consistent with how other languages, including LISP(!), use the term. As you say, we borrow it from Math. And for good reason. Now I know they say that foolish consistency is the hobgoblin of little minds, but using the word, "tuple," in this consistent way is hardly foolish. In this case, as is usually the case with your strange criticisms of well-established practice, there are good reasons for it. TL;DR: I find your list freezing proposal to be needlessly complicated. No the burden of proof is not on me to explain why tuples are so. From rosuav at gmail.com Sun Feb 3 02:21:46 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 3 Feb 2013 18:21:46 +1100 Subject: Please provide a better explanation of tuples and dictionaries In-Reply-To: <510E0E56.8030007@gmail.com> References: <36061bf4-2a65-4ac2-91a1-30f8348f4b0d@googlegroups.com> <510E0E56.8030007@gmail.com> Message-ID: On Sun, Feb 3, 2013 at 6:14 PM, Michael Torrie wrote: > TL;DR: I find your list freezing proposal to be needlessly complicated. > No the burden of proof is not on me to explain why tuples are so. We have a list-freezing mechanism already. >>> list=[1,2,3,'logical'] >>> staticList=tuple(list) Et voila! Looks fine to me. ChrisA From dihedral88888 at googlemail.com Fri Feb 1 06:26:27 2013 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 1 Feb 2013 03:26:27 -0800 (PST) Subject: confusion with decorators In-Reply-To: References: Message-ID: Jason Swails? 2013?1?31????UTC+8??8?34?03???? > Hello, > > > I was having some trouble understanding decorators and inheritance and all that. ?This is what I was trying to do: > > > > # untested > class A(object): > ? ?def _protector_decorator(fcn): > > ? ? ? def newfcn(self, *args, **kwargs): > ? ? ? ? ?return fcn(self, *args, **kwargs) > ? ? ? return newfcn > > > > ? ?@_protector_decorator > ? ?def my_method(self, *args, **kwargs): > ? ? ? """ do something here """ > > > > class B(A): > ? ?def _protector_decorator(fcn): > ? ? ? def newfcn(self, *args, **kwargs): > > ? ? ? ? ?raise MyException('I do not want B to be able to access the protected functions') > ? ? ? return newfcn > > > > The goal of all that was to be able to change the behavior of my_method inside class B simply by redefining the decorator. Basically, what I want is B.my_method() to be decorated by B._protector_decorator, but in the code I'm running it's decorated by A._protector_decorator. > > > > I presume this is because once the decorator is applied to my_method in class A, A.my_method is immediately bound to the new, 'decorated' function, which is subsequently inherited (and not decorated, obviously), by B. > > > > Am I correct here? ?My workaround was to simply copy the method from class A to class B, after which B._protector_decorator decorated the methods in B. ?While this doesn't make the use of decorators completely pointless (the decorators actually do something in each class, it's just different), it does add a bunch of code duplication which I was at one point hopeful to avoid. > > > > I'm still stumbling around with decorators a little, but this exercise has made them a lot clearer to me. > > > Thanks! > Jason It sounds that you need a decorator mapper to perform the functionality of your designs. From dihedral88888 at googlemail.com Fri Feb 1 06:26:27 2013 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 1 Feb 2013 03:26:27 -0800 (PST) Subject: confusion with decorators In-Reply-To: References: Message-ID: Jason Swails? 2013?1?31????UTC+8??8?34?03???? > Hello, > > > I was having some trouble understanding decorators and inheritance and all that. ?This is what I was trying to do: > > > > # untested > class A(object): > ? ?def _protector_decorator(fcn): > > ? ? ? def newfcn(self, *args, **kwargs): > ? ? ? ? ?return fcn(self, *args, **kwargs) > ? ? ? return newfcn > > > > ? ?@_protector_decorator > ? ?def my_method(self, *args, **kwargs): > ? ? ? """ do something here """ > > > > class B(A): > ? ?def _protector_decorator(fcn): > ? ? ? def newfcn(self, *args, **kwargs): > > ? ? ? ? ?raise MyException('I do not want B to be able to access the protected functions') > ? ? ? return newfcn > > > > The goal of all that was to be able to change the behavior of my_method inside class B simply by redefining the decorator. Basically, what I want is B.my_method() to be decorated by B._protector_decorator, but in the code I'm running it's decorated by A._protector_decorator. > > > > I presume this is because once the decorator is applied to my_method in class A, A.my_method is immediately bound to the new, 'decorated' function, which is subsequently inherited (and not decorated, obviously), by B. > > > > Am I correct here? ?My workaround was to simply copy the method from class A to class B, after which B._protector_decorator decorated the methods in B. ?While this doesn't make the use of decorators completely pointless (the decorators actually do something in each class, it's just different), it does add a bunch of code duplication which I was at one point hopeful to avoid. > > > > I'm still stumbling around with decorators a little, but this exercise has made them a lot clearer to me. > > > Thanks! > Jason It sounds that you need a decorator mapper to perform the functionality of your designs. From duncan.booth at invalid.invalid Mon Feb 4 05:19:32 2013 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 4 Feb 2013 10:19:32 GMT Subject: confusion with decorators References: Message-ID: Dave Angel wrote: > The decorator function will execute while *compiling* the class A, and > the one in class B is unreferenced. No, the decorator function is called when *executing* the class body of A. Compilation could have happened weeks earlier. It really does make it a lot easier to understand this sort of issue if you remember that 'class' and 'def' are simply executable statements: the body of 'class' executes as part of the class definition whenever normal execution reaches the 'class' statement, the body of 'def' doesn't execute until the function is called (but default arguments are evaluated when the 'def' is executed). In both cases however the code is fully compiled whenever the module is compiled: that could be when the module is imported or if it is __main__ when the script executes, but after the first run of the program all of the modules (nto the script) will have been compiled once and don't compile again until the source changes. -- Duncan Booth http://kupuguy.blogspot.com From andreas.roehler at online.de Fri Feb 1 02:13:14 2013 From: andreas.roehler at online.de (=?ISO-8859-1?Q?Andreas_R=F6hler?=) Date: Fri, 01 Feb 2013 08:13:14 +0100 Subject: Python launcher (PEP 397) and emacs python-mode.el In-Reply-To: References: Message-ID: <510B6B0A.9030005@online.de> Am 01.02.2013 00:59, schrieb Vinay Sajip: > Thomas Heller ctypes.org> writes: > >> What I meant to write is this: >> >> when the shebang line in script.py contains this: >> #!/usr/bin/python3.1-32 >> then emacs SHOULD run >> py.exe -3.1-32 script.py >> and the launcher runs >> c:\Python31\python.exe script.py > > IMO it would be better for emacs to just run > > py.exe script.py > > and py.exe can read the shebang and do the right thing. This saves the emacs code > from having to duplicate the shebang line processing logic that py.exe uses > (which, as we know, is unusual. So for a cross-platform you can have a shebang > line of #!/usr/bin/python3.2, and on Windows it will still call the appropriate > Python 3.2 even if it's not in /usr/bin, as there's no /usr/bin :-)) > > Regards, > > Vinay Sajip > > > https://bugs.launchpad.net/python-mode/+bug/1112207 From dihedral88888 at googlemail.com Fri Feb 1 15:32:18 2013 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 1 Feb 2013 12:32:18 -0800 (PST) Subject: advice, python for binary to xml In-Reply-To: <6ddffcda-ecc1-4ffb-8eef-5a497aede4b8@googlegroups.com> References: <6ddffcda-ecc1-4ffb-8eef-5a497aede4b8@googlegroups.com> Message-ID: <5cfbf412-9136-4847-b3c3-9723b56c7643@googlegroups.com> noydb? 2013?1?31????UTC+8??9?33?48???? > I'm looking for knowlegde about how best to go about converting a binary file (from a GPS unit) to GPX/XML. I am completely clueless on this, so any start-from-the-beginning info would be greatly appreciated! I'm guessing the level of effort will be huge? > > Python 2.7, Windows 7 OK, since I was in charge of a project to retrieve the GPS with the RSA232 NMEA TEXT messages into a computer program before, I have not checked about the NMEA protocal (PUREASCII) for more than 10 years. But I worked with usb interfaces, too. From alexandra at compulab.co.il Sun Feb 3 06:14:34 2013 From: alexandra at compulab.co.il (alexandra) Date: Sun, 03 Feb 2013 13:14:34 +0200 Subject: PyGresql 4.1.1 for python2.7 In-Reply-To: <510A6BA4.4070306@compulab.co.il> References: <510A6BA4.4070306@compulab.co.il> Message-ID: <510E469A.4020704@compulab.co.il> An HTML attachment was scrubbed... URL: From christian at python.org Fri Feb 1 09:34:35 2013 From: christian at python.org (Christian Heimes) Date: Fri, 01 Feb 2013 15:34:35 +0100 Subject: Need some help confirming transactions using sha256 In-Reply-To: References: <21037ba0-57e5-4e44-8d50-6503a1187492@googlegroups.com> Message-ID: <510BD27B.3010608@python.org> Am 31.01.2013 18:55, schrieb Peter Pearson: >>>> txid = 'r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA' >>>> secret = '10812806653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1' >>>> hashlib.sha256(txid+":"+secret).hexdigest() > 'dfa8769be81a543002865c88a5b52fa07f3b67fc7cd9b519c3f6a6452bcd48e4' >>>> 0x48e4 > 18660 >>>> > > .. . . which is the number you wanted, right? Kryptox, you have chosen the correct algorithm to calculate a MAC. Very good! But the designers of the game are using an improper algorithm. Apparently they don't know much about cryptography, especially length extension attacks ... Christian From steve+comp.lang.python at pearwood.info Fri Feb 1 00:00:07 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Fri, 01 Feb 2013 16:00:07 +1100 Subject: Help the visibility of Python in computational science References: Message-ID: <510b4bd8$0$29978$c3e8da3$5496439d@news.astraweb.com> dg.google.groups at thesamovar.net wrote: > If you could take one minute to make sure you > are signed in to your Google+ account Which Google+ account would that be? I have so few. -- Steven From rosuav at gmail.com Fri Feb 1 00:09:04 2013 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 1 Feb 2013 16:09:04 +1100 Subject: Help the visibility of Python in computational science In-Reply-To: <510b4bd8$0$29978$c3e8da3$5496439d@news.astraweb.com> References: <510b4bd8$0$29978$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 1, 2013 at 4:00 PM, Steven D'Aprano wrote: > dg.google.groups at thesamovar.net wrote: > >> If you could take one minute to make sure you >> are signed in to your Google+ account > > Which Google+ account would that be? I have so few. > It's a thing non-nerds do, Steven. You wouldn't understand. http://xkcd.com/918/ ChrisA *ducking for cover* From dg.google.groups at thesamovar.net Fri Feb 1 15:46:23 2013 From: dg.google.groups at thesamovar.net (dg.google.groups at thesamovar.net) Date: Fri, 1 Feb 2013 12:46:23 -0800 (PST) Subject: Help the visibility of Python in computational science In-Reply-To: References: <510b4bd8$0$29978$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Friday, February 1, 2013 12:09:04 AM UTC-5, Chris Angelico wrote: > On Fri, Feb 1, 2013 at 4:00 PM, Steven D'Aprano > > wrote: > > > dg.google.groups at thesamovar.net wrote: > > > > > >> If you could take one minute to make sure you > > >> are signed in to your Google+ account > > > > > > Which Google+ account would that be? I have so few. > > > > > > > It's a thing non-nerds do, Steven. You wouldn't understand. Sadly for me though, I think the nerds are in the majority here. As of yesterday I got only two additional +1's. Ah well. I had to create a Google+ account for it myself actually. ;) Dan From dg.google.groups at thesamovar.net Fri Feb 1 15:46:23 2013 From: dg.google.groups at thesamovar.net (dg.google.groups at thesamovar.net) Date: Fri, 1 Feb 2013 12:46:23 -0800 (PST) Subject: Help the visibility of Python in computational science In-Reply-To: References: <510b4bd8$0$29978$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Friday, February 1, 2013 12:09:04 AM UTC-5, Chris Angelico wrote: > On Fri, Feb 1, 2013 at 4:00 PM, Steven D'Aprano > > wrote: > > > dg.google.groups at thesamovar.net wrote: > > > > > >> If you could take one minute to make sure you > > >> are signed in to your Google+ account > > > > > > Which Google+ account would that be? I have so few. > > > > > > > It's a thing non-nerds do, Steven. You wouldn't understand. Sadly for me though, I think the nerds are in the majority here. As of yesterday I got only two additional +1's. Ah well. I had to create a Google+ account for it myself actually. ;) Dan From wheelman.fm at gmail.com Fri Feb 1 02:21:30 2013 From: wheelman.fm at gmail.com (wheelman.fm at gmail.com) Date: Thu, 31 Jan 2013 23:21:30 -0800 (PST) Subject: Cheat Engine In Python In-Reply-To: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> Message-ID: <88efdbb5-3ea7-45e5-b7de-0be63cf3e0c5@googlegroups.com> Why there isn't any replys ? . From rosuav at gmail.com Fri Feb 1 02:50:04 2013 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 1 Feb 2013 18:50:04 +1100 Subject: Cheat Engine In Python In-Reply-To: <88efdbb5-3ea7-45e5-b7de-0be63cf3e0c5@googlegroups.com> References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> <88efdbb5-3ea7-45e5-b7de-0be63cf3e0c5@googlegroups.com> Message-ID: On Fri, Feb 1, 2013 at 6:21 PM, wrote: > Why there isn't any replys ? . Because you posted it only a couple of hours ago, for one :) My initial guess is: No. Feel free to disprove me by searching on Google and finding one. ChrisA From steve+comp.lang.python at pearwood.info Fri Feb 1 04:08:47 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Fri, 01 Feb 2013 20:08:47 +1100 Subject: Cheat Engine In Python References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> <88efdbb5-3ea7-45e5-b7de-0be63cf3e0c5@googlegroups.com> Message-ID: <510b8620$0$29979$c3e8da3$5496439d@news.astraweb.com> wheelman.fm at gmail.com wrote: > Why there isn't any replys ? . Three reasons: 1) It's only been a few hours. Maybe the people who know the answer haven't read it yet. 2) When I try to read your first post, I get this error: An error occurred. Article could not be retrieved. The following error occurred: 423 No such article number in this group The article you requested is not available on your news server. which suggests that maybe it's been deleted as spam, or otherwise is corrupted. Try rewording your post to be a bit less spammy and trying again. -- Steven From rustompmody at gmail.com Fri Feb 1 10:05:36 2013 From: rustompmody at gmail.com (rusi) Date: Fri, 1 Feb 2013 07:05:36 -0800 (PST) Subject: Cheat Engine In Python References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> <88efdbb5-3ea7-45e5-b7de-0be63cf3e0c5@googlegroups.com> <510b8620$0$29979$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9a77f817-f2eb-484f-b69e-727c57ecd38c@q16g2000pbt.googlegroups.com> On Feb 1, 2:08?pm, Steven D'Aprano wrote: > wheelman... at gmail.com wrote: > > Why there isn't any replys ? . > > Three reasons: > > 1) It's only been a few hours. Maybe the people who know the answer haven't > read it yet. > > 2) When I try to read your first post, I get this error: > > ? ? An error occurred. > > ? ? Article could not be retrieved. > ? ? The following error occurred: > ? ? 423 No such article number in this group > > ? ? The article you requested is not available on your news server. > > which suggests that maybe it's been deleted as spam, or otherwise is > corrupted. > > Try rewording your post to be a bit less spammy and trying again. > > -- > Steven There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. Martin Fowler From stefan_ml at behnel.de Fri Feb 1 04:59:58 2013 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 01 Feb 2013 10:59:58 +0100 Subject: Cheat Engine In Python In-Reply-To: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> Message-ID: wheelman.fm at gmail.com, 01.02.2013 05:16: > Are there any softwares like cheat engine and written in python What's a "cheat engine"? And, assuming it exists, why can't you just use it? What's your use case that explains the advantage of having it (re-?)written in Python? > I mean just the code not compiled ? Not sure what you mean. Are you maybe looking for an open-source project? Stefan From rustompmody at gmail.com Fri Feb 1 08:46:47 2013 From: rustompmody at gmail.com (rusi) Date: Fri, 1 Feb 2013 05:46:47 -0800 (PST) Subject: Cheat Engine In Python References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> Message-ID: <84ae6b38-bcfc-49ac-86c9-462edcc49889@s8g2000pbw.googlegroups.com> On Feb 1, 2:59?pm, Stefan Behnel wrote: > wheelman... at gmail.com, 01.02.2013 05:16: > > > Are there any softwares like cheat engine and written in python > > What's a "cheat engine"? I'm guessing its this (in Ruby) required in Python: http://cheat.errtheblog.com/ > And, assuming it exists, why can't you just use > it? What's your use case that explains the advantage of having it > (re-?)written in Python? Some variant of the NIH syndrome I suppose :-) From wuwei23 at gmail.com Sat Feb 2 16:11:03 2013 From: wuwei23 at gmail.com (alex23) Date: Sat, 2 Feb 2013 13:11:03 -0800 (PST) Subject: Cheat Engine In Python References: <1b7d037e-c476-4790-8ed7-08867e4cd194@googlegroups.com> <84ae6b38-bcfc-49ac-86c9-462edcc49889@s8g2000pbw.googlegroups.com> Message-ID: <2d937911-8730-4c15-a474-699dea3895d6@tc10g2000pbc.googlegroups.com> On Feb 1, 11:46?pm, rusi wrote: > On Feb 1, 2:59?pm, Stefan Behnel wrote: > > > wheelman... at gmail.com, 01.02.2013 05:16: > > > > Are there any softwares like cheat engine and written in python > > > What's a "cheat engine"? > > I'm guessing its this (in Ruby) required in Python:http://cheat.errtheblog.com/ I assumed it was this: http://cheatengine.org/ which is an app for modifying game data in memory. Rewriting something like this would be a pretty hefty task for a fairly niche activity, and is always going to be heavily platform specific. Perhaps the OP could look into using ctypes to call Cheat Engine's dbk32.dll instead and leverage off its pre-existing work. From square.steve at gmail.com Fri Feb 1 09:24:34 2013 From: square.steve at gmail.com (Steve Simmons) Date: Fri, 01 Feb 2013 15:24:34 +0100 Subject: Best approach to OO Style (only slightly off topic)? Message-ID: <510BD022.5070402@gmail.com> I'm relatively new to OO (and Python and QT ) and I am learning as I go along. As I slowly come up to speed, I have some questions about the best approach to program/module structure so I'm looking for some pointers (URL's or replies). I have copied some code from 'Rapid GUI Programming with Python and Qt' (Great book!) and am now modifying/extending it with my own. The original code (Image Changer - Chp 6) is a single class that contains code for both UI creation/management and functional code. I have created a second class for my own code and I'm on the brink of adding calls from one class to the other and vice-versa. At this point, I began to wonder what a 'correctly structured' OO program should look like. Should I separate GUI logic from 'business' logic? Should everything be in one class? Should my main() be carrying the high level logic? Anyinput most welcome. I looked briefly at the MVC model which answers my question at a high level but itrepresents another learning curve that I'm reluctant to add to my current challenge. Steve From rosuav at gmail.com Fri Feb 1 10:17:43 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 2 Feb 2013 02:17:43 +1100 Subject: Best approach to OO Style (only slightly off topic)? In-Reply-To: <510BD022.5070402@gmail.com> References: <510BD022.5070402@gmail.com> Message-ID: On Sat, Feb 2, 2013 at 1:24 AM, Steve Simmons wrote: > At this point, I began to wonder what a 'correctly structured' OO program > should look like. Should I separate GUI logic from 'business' logic? Should > everything be in one class? Should my main() be carrying the high level > logic? Anyinput most welcome. > > I looked briefly at the MVC model which answers my question at a high level > but itrepresents another learning curve that I'm reluctant to add to my > current challenge. Rule #0 of design: There's always a worse pattern you could have used. Python gives you all the flexibility you could want. And with that flexibility comes ease of complication. The key is to find the simplest design that will accomplish what you want, and go from there. The idea of separating out "business logic" from "user interface" seems all very well on the face of it, but it's often harder than you might think, and when you force an application into that kind of segregation, you'll often end up with thin layers around one or the other so there's really UI code interspersed with "guts" code despite your best efforts. Drastically changing your UI will generally involve lots of code changes anyway, so don't be too bothered if you find you need to change something that didn't feel like "user interface" code. Model/View/Controller systems tend, imho, to be massive overkill for anything smaller than Huge. In fact, I can't point to any MVC system that fitted onto a single computer that couldn't have been done better with something rather simpler. Above all, don't have one class for "someone else's code" and one for "my code" unless there's some really REALLY good reason for it. A better model in Python would be to have two *modules*, not two classes. But there are myriad ways you could lay out your code, and few of them are truly *wrong*. The most important thing to do is to think about what you do; plan, don't just let it grow by itself. The plan shouldn't be chiseled into basalt, but any time you change it, be sure you know why you're changing it. You say you're new to OO; what programming model(s) are you more familiar with? Python doesn't force you into object orientation - you can ignore it and just work with imperative code, if you prefer. All the best! ChrisA From rhubarbsin at gmail.com Fri Feb 1 10:04:22 2013 From: rhubarbsin at gmail.com (Rhubarb Sin) Date: Fri, 1 Feb 2013 10:04:22 -0500 Subject: CamelCase vs. all-lowercase package names Message-ID: PEP-8 calls for "short, all-lowercase names" for packages: http://www.python.org/dev/peps/pep-0008/#package-and-module-names On the other hand, The Hitchhiker's Guide to Packaging 1.0, under "Background," declares "come up with a CamelCase project name": http://guide.python-distribute.org/creation.html On PyPi, of course, there is great variation. At this point is there a more formal recommendation for a package naming convention? From rosuav at gmail.com Fri Feb 1 10:28:56 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 2 Feb 2013 02:28:56 +1100 Subject: CamelCase vs. all-lowercase package names In-Reply-To: References: Message-ID: On Sat, Feb 2, 2013 at 2:04 AM, Rhubarb Sin wrote: > PEP-8 calls for "short, all-lowercase names" for packages: > > http://www.python.org/dev/peps/pep-0008/#package-and-module-names > > On the other hand, The Hitchhiker's Guide to Packaging 1.0, under > "Background," declares "come up with a CamelCase project name": > > http://guide.python-distribute.org/creation.html That's the project name. In the next section, it refers to package names, and in the example, uses the lowercased project name. ChrisA From dieter at handshake.de Sat Feb 2 03:03:37 2013 From: dieter at handshake.de (dieter) Date: Sat, 02 Feb 2013 09:03:37 +0100 Subject: CamelCase vs. all-lowercase package names References: Message-ID: <87d2wjm9ba.fsf@handshake.de> Rhubarb Sin writes: > PEP-8 calls for "short, all-lowercase names" for packages: > > http://www.python.org/dev/peps/pep-0008/#package-and-module-names This is mainly to support case insensitive file systems (and file systems with quite limited path length). With mixed case, some packages/modules may not conflict on a case sensitive file system but happen to conflict on a case insensitive file system. From tjreedy at udel.edu Sat Feb 2 18:05:33 2013 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 02 Feb 2013 18:05:33 -0500 Subject: CamelCase vs. all-lowercase package names In-Reply-To: <87d2wjm9ba.fsf@handshake.de> References: <87d2wjm9ba.fsf@handshake.de> Message-ID: On 2/2/2013 3:03 AM, dieter wrote: > Rhubarb Sin writes: > >> PEP-8 calls for "short, all-lowercase names" for packages: >> >> http://www.python.org/dev/peps/pep-0008/#package-and-module-names > > This is mainly to support case insensitive file systems (and > file systems with quite limited path length). It also serves to differentiate a module from the main class it defines. If file Module defines class Module, then the two possible imports import Module from Module import Module make 'Module' later in the file ambiguous without referring to the top of the file for the import. But now, 'decimal' is the module and 'Decimal' is the class (absent stupid renaming designed to confuse). > With mixed case, some packages/modules may not conflict on > a case sensitive file system but happen to conflict on a > case insensitive file system. -- Terry Jan Reedy From subhabangalore at gmail.com Fri Feb 1 12:17:04 2013 From: subhabangalore at gmail.com (subhabangalore at gmail.com) Date: Fri, 1 Feb 2013 09:17:04 -0800 (PST) Subject: Maximum Likelihood Estimation Message-ID: Dear Group, I am looking for a Python implementation of Maximum Likelihood Estimation. If any one can kindly suggest. With a google search it seems scipy,numpy,statsmodels have modules, but as I am not finding proper example workouts I am failing to use them. I am using Python 2.7 on Windows 7. Thanking You in Advance, Regards, Subhabrata From dihedral88888 at googlemail.com Fri Feb 1 12:37:48 2013 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 1 Feb 2013 09:37:48 -0800 (PST) Subject: Maximum Likelihood Estimation In-Reply-To: References: Message-ID: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com> subhaba... at gmail.com? 2013?2?2????UTC+8??1?17?04???? > Dear Group, > > > > I am looking for a Python implementation of Maximum Likelihood Estimation. If any one can kindly suggest. With a google search it seems scipy,numpy,statsmodels have modules, but as I am not finding proper example workouts I am failing to use them. > > > > I am using Python 2.7 on Windows 7. > > > > Thanking You in Advance, > > > > Regards, > > Subhabrata I suggest you can google "python and symbolic computation" to get some package for your need first. Because it seems that you have to work out some math formula and verify some random process first of your data sources with noises . From subhabangalore at gmail.com Fri Feb 1 13:47:22 2013 From: subhabangalore at gmail.com (subhabangalore at gmail.com) Date: Fri, 1 Feb 2013 10:47:22 -0800 (PST) Subject: Maximum Likelihood Estimation In-Reply-To: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com> References: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com> Message-ID: On Friday, February 1, 2013 11:07:48 PM UTC+5:30, 88888 Dihedral wrote: > subhaba... at gmail.com? 2013?2?2????UTC+8??1?17?04???? > > > Dear Group, > > > > > > > > > > > > I am looking for a Python implementation of Maximum Likelihood Estimation. If any one can kindly suggest. With a google search it seems scipy,numpy,statsmodels have modules, but as I am not finding proper example workouts I am failing to use them. > > > > > > > > > > > > I am using Python 2.7 on Windows 7. > > > > > > > > > > > > Thanking You in Advance, > > > > > > > > > > > > Regards, > > > > > > Subhabrata > > > > I suggest you can google "python and symbolic > > computation" to get some package for your need first. > > > > Because it seems that you have to work out some > > math formula and verify some random process first > > of your data sources with noises . Dear Group, Thanks. I googled and found a new package named Sympy and could generate MLE graphs. Regards,Subhabrata. From torriem at gmail.com Fri Feb 1 13:59:03 2013 From: torriem at gmail.com (Michael Torrie) Date: Fri, 01 Feb 2013 11:59:03 -0700 Subject: Maximum Likelihood Estimation In-Reply-To: References: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com> Message-ID: <510C1077.9050903@gmail.com> On 02/01/2013 11:47 AM, subhabangalore at gmail.com wrote: > On Friday, February 1, 2013 11:07:48 PM UTC+5:30, 88888 Dihedral > wrote: >> subhaba... at gmail.com? 2013?2?2????UTC+8??1?17?04???? >>> I am looking for a Python implementation of Maximum Likelihood >>> Estimation. If any one can kindly suggest. With a google search >>> it seems scipy,numpy,statsmodels have modules, but as I am not >>> finding proper example workouts I am failing to use them. >> >> I suggest you can google "python and symbolic computation" to get >> some package for your need first. Because it seems that you have to >> work out some math formula and verify some random process first of >> your data sources with noises . > > Dear Group, Thanks. I googled and found a new package named Sympy and > could generate MLE graphs. Regards,Subhabrata. My hat's off to you for actually interpreting the 88888 dihedral robot's randomly-created response in a way that actually helped you find the solution to your problem! I think that's a python first around here. Most people on this list consider 88888 dihedral to be a badly programmed bot. From malaclypse2 at gmail.com Fri Feb 1 14:14:35 2013 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 1 Feb 2013 14:14:35 -0500 Subject: Maximum Likelihood Estimation In-Reply-To: <510C1077.9050903@gmail.com> References: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com> <510C1077.9050903@gmail.com> Message-ID: On Fri, Feb 1, 2013 at 1:59 PM, Michael Torrie wrote: > Most people on this list consider 88888 dihedral to be a badly > programmed bot. For what it's worth, I think it's a very cleverly programmed bot. It usually makes just enough sense for me to wonder if there really is a human being behind the keyboard. -- Jerry From tkhan10 at masonlive.gmu.edu Fri Feb 1 14:01:37 2013 From: tkhan10 at masonlive.gmu.edu (tkhan10) Date: Fri, 1 Feb 2013 19:01:37 +0000 Subject: Maximum Likelihood Estimation In-Reply-To: References: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com>, Message-ID: Hi.. I know this is a very dumb q but actually I am new to python and to this list. I want to post a question about geographic masking but cannot find out how to post it. Would somebody please suggest me how to do that? Thank you Subrina ________________________________________ From: Python-list [python-list-bounces+tkhan10=gmu.edu at python.org] on behalf of subhabangalore at gmail.com [subhabangalore at gmail.com] Sent: Friday, February 01, 2013 1:47 PM To: python-list at python.org Subject: Re: Maximum Likelihood Estimation On Friday, February 1, 2013 11:07:48 PM UTC+5:30, 88888 Dihedral wrote: > subhaba... at gmail.com? 2013?2?2????UTC+8??1?17?04???? > > > Dear Group, > > > > > > > > > > > > I am looking for a Python implementation of Maximum Likelihood Estimation. If any one can kindly suggest. With a google search it seems scipy,numpy,statsmodels have modules, but as I am not finding proper example workouts I am failing to use them. > > > > > > > > > > > > I am using Python 2.7 on Windows 7. > > > > > > > > > > > > Thanking You in Advance, > > > > > > > > > > > > Regards, > > > > > > Subhabrata > > > > I suggest you can google "python and symbolic > > computation" to get some package for your need first. > > > > Because it seems that you have to work out some > > math formula and verify some random process first > > of your data sources with noises . Dear Group, Thanks. I googled and found a new package named Sympy and could generate MLE graphs. Regards,Subhabrata. -- http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Fri Feb 1 14:55:34 2013 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 1 Feb 2013 11:55:34 -0800 (PST) Subject: Maximum Likelihood Estimation In-Reply-To: References: <68027a3f-5320-44b7-a985-1d213062e2c0@googlegroups.com> Message-ID: ? 2013?2?2????UTC+8??2?47?22??subhaba... at gmail.com??? > On Friday, February 1, 2013 11:07:48 PM UTC+5:30, 88888 Dihedral wrote: > > > subhaba... at gmail.com? 2013?2?2????UTC+8??1?17?04???? > > > > > > > Dear Group, > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am looking for a Python implementation of Maximum Likelihood Estimation. If any one can kindly suggest. With a google search it seems scipy,numpy,statsmodels have modules, but as I am not finding proper example workouts I am failing to use them. > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am using Python 2.7 on Windows 7. > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanking You in Advance, > > > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > > Subhabrata > > > > > > > > > > > > I suggest you can google "python and symbolic > > > > > > computation" to get some package for your need first. > > > > > > > > > > > > Because it seems that you have to work out some > > > > > > math formula and verify some random process first > > > > > > of your data sources with noises . > > > > Dear Group, > > Thanks. I googled and found a new package named Sympy and could generate MLE graphs. Regards,Subhabrata. Well,just reveal more about your problems. But if you are concerned with some commercial problems, then it is not the novice apprentice level jokes. Then, maybe you can just give some outline of the problem. From steve+comp.lang.python at pearwood.info Fri Feb 1 18:12:24 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 02 Feb 2013 10:12:24 +1100 Subject: Maximum Likelihood Estimation References: Message-ID: <510c4bd9$0$29978$c3e8da3$5496439d@news.astraweb.com> tkhan10 wrote: > Hi.. > I know this is a very dumb q but actually I am new to python and to this > list. I want to post a question about geographic masking but cannot find > out how to post it. Would somebody please suggest me how to do that? Thank > you Subrina Are you using email or Usenet? In your email client: 1) Create a new email message; 2) Type the To address python-list at python.org 3) Type a meaningful subject line such as "Geographic Masking in Python" 4) Type your message. 5) Hit send. Or, if you are using Usenet, in your news client: 1) Create a new news post; 2) Type the To address comp.lang.python; 3) Type a meaningful subject line such as "Geographic Masking in Python" 4) Type your message. 5) Hit send. -- Steven From subhabangalore at gmail.com Fri Feb 1 23:53:53 2013 From: subhabangalore at gmail.com (subhabangalore at gmail.com) Date: Fri, 1 Feb 2013 20:53:53 -0800 (PST) Subject: Maximum Likelihood Estimation In-Reply-To: References: Message-ID: On Friday, February 1, 2013 10:47:04 PM UTC+5:30, subhaba... at gmail.com wrote: > Dear Group, > > > > I am looking for a Python implementation of Maximum Likelihood Estimation. If any one can kindly suggest. With a google search it seems scipy,numpy,statsmodels have modules, but as I am not finding proper example workouts I am failing to use them. > > > > I am using Python 2.7 on Windows 7. > > > > Thanking You in Advance, > > > > Regards, > > Subhabrata Dear Sir, The room would take care of you. They still guide me and sometimes the way they rebuke you have to see. You are in a nice room, you'd learn soon. It was bot? If you are testing please let me know I'd like to be part of the testing, and if you suggest may volunteer to send queries. Regards, Subhabrata. From feliphil at gmx.net Sat Feb 2 13:26:09 2013 From: feliphil at gmx.net (Wolfgang Keller) Date: Sat, 2 Feb 2013 19:26:09 +0100 Subject: Maximum Likelihood Estimation References: Message-ID: <20130202192609.0257968c157cdabdde805114@gmx.net> > I am looking for a Python implementation of Maximum Likelihood > Estimation. If any one can kindly suggest. With a google search it > seems scipy,numpy,statsmodels have modules, but as I am not finding > proper example workouts I am failing to use them. For statistics I would suggest using R (http://www.r-project.org/) through RPy (http://rpy.sourceforge.net/). Both have dedicated mailinglists as well as extensive documentation. Sincerely, Wolfgang From oscar.j.benjamin at gmail.com Sat Feb 2 16:41:12 2013 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Sat, 2 Feb 2013 21:41:12 +0000 Subject: Maximum Likelihood Estimation In-Reply-To: <20130202192609.0257968c157cdabdde805114@gmx.net> References: <20130202192609.0257968c157cdabdde805114@gmx.net> Message-ID: On 2 February 2013 18:26, Wolfgang Keller wrote: >> I am looking for a Python implementation of Maximum Likelihood >> Estimation. If any one can kindly suggest. With a google search it >> seems scipy,numpy,statsmodels have modules, but as I am not finding >> proper example workouts I am failing to use them. > > For statistics I would suggest using R (http://www.r-project.org/) > through RPy (http://rpy.sourceforge.net/). > > Both have dedicated mailinglists as well as extensive documentation. I agree with Wolfgang that R is likely to be able to do what you want and that you may have better luck asking this kind of question on their mailing lists (or on the scipy mailing list). In any case, though, you will need to be more specific about what you mean. Maximum Likelihood Estimation (MLE) is a sufficiently vague topic that there cannot really be an "implementation" of it. What kind of model/data are you working with? Or are you working with pure probability distributions? What kind of parameters are you trying to find? Are the parameters you are trying to choose discrete or continuous? Are you trying to find one parameter or several simultaneously? Are you able to find an analytic solution that transforms your MLE problem into a specific kind of mathematical problem, such as solving a system of linear equations? Assuming that you are able to compute directly the likelihood (or log-likelihood) of whatever it is you are interested in, then your MLE problem is simply an optimisation problem, so you may have better luck searching for implementations of optimisation (you will still need to answer the questions above to be able choose an optimisation method). Oscar From charles.hoskinson at gmail.com Fri Feb 1 18:37:07 2013 From: charles.hoskinson at gmail.com (Charles Hoskinson) Date: Fri, 1 Feb 2013 15:37:07 -0800 (PST) Subject: Python Class Message-ID: I'm developing an online course for beginning python programmers starting from basic syntax through object oriented design and GUI. I'd like to include some helpful community resources like Code Academy in the appendix and I was wondering if this community has some particular favorites they would highly recommend? From steve+comp.lang.python at pearwood.info Fri Feb 1 19:09:49 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 02 Feb 2013 11:09:49 +1100 Subject: Python Class References: Message-ID: <510c594e$0$30003$c3e8da3$5496439d@news.astraweb.com> Charles Hoskinson wrote: > I'm developing an online course for beginning python programmers starting > from basic syntax through object oriented design and GUI. I'd like to > include some helpful community resources like Code Academy in the appendix > and I was wondering if this community has some particular favorites they > would highly recommend? This is a helpful community resource: - by email python-list at python.org - by usenet comp.lang.python Other useful resources include: - the tutor mailing list tutor at python.org - http://code.activestate.com/recipes/ - http://wiki.python.org/moin/ -- Steven From rodrick.brown at gmail.com Fri Feb 1 23:00:27 2013 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Fri, 1 Feb 2013 23:00:27 -0500 Subject: Python Class In-Reply-To: References: Message-ID: On Friday, February 1, 2013, Charles Hoskinson wrote: > I'm developing an online course for beginning python programmers starting > from basic syntax through object oriented design and GUI. I'd like to > include some helpful community resources like Code Academy in the appendix > and I was wondering if this community has some particular favorites they > would highly recommend? Udacity.com has a nice interactive CS course taught in Python. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From accessnewbie at gmail.com Fri Feb 1 20:03:41 2013 From: accessnewbie at gmail.com (accessnewbie at gmail.com) Date: Fri, 1 Feb 2013 17:03:41 -0800 (PST) Subject: Anyway to reduce size of pdf using python script. Message-ID: I have a batch file that exports ArcGIS pdf maps to a directory. I would like to include a step in the script where the pdf file is reduced in size instead of manually opening each file in Acrobat X Pro after the script has run and doing it there. Can this be done using python scripting or does the automation stop at exporting the map? Thanks From roy at panix.com Fri Feb 1 20:10:09 2013 From: roy at panix.com (Roy Smith) Date: Fri, 01 Feb 2013 20:10:09 -0500 Subject: Anyway to reduce size of pdf using python script. References: Message-ID: In article , accessnewbie at gmail.com wrote: > I have a batch file that exports ArcGIS pdf maps to a directory. I would like > to include a step in the script where the pdf file is reduced in size instead > of manually opening each file in Acrobat X Pro after the script has run and > doing it there. > > Can this be done using python scripting or does the automation stop at > exporting the map? > > Thanks I don't know anything about ArcGIS, but http://stackoverflow.com/questions/6413441/python-pdf-library gives pointers to several libraries which look like they might do what you want. From armin.karner at yahoo.de Sat Feb 2 05:01:40 2013 From: armin.karner at yahoo.de (Armin Karner) Date: Sat, 2 Feb 2013 10:01:40 +0000 (GMT) Subject: mySQLdb In-Reply-To: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> Message-ID: <1359799300.60405.YahooMailNeo@web132101.mail.ird.yahoo.com> Dear Sir or Madam, I am curious if there is an update of MySQLdb for python versions 3.3 or higher. Because I really need this for a diploma thesis.? I've tried several of them, including various 2.x versions, but it didn't work.? The system I use is a Microsoft Windows 7 64 bit.? I really hope you have a solution for me, because it is quite urgent and important.? I am looking forward to a quick answer! Yours faithfully Armin Karner -------------- next part -------------- An HTML attachment was scrubbed... URL: From luuk at invalid.lan Sat Feb 2 05:19:50 2013 From: luuk at invalid.lan (Luuk) Date: Sat, 02 Feb 2013 11:19:50 +0100 Subject: mySQLdb In-Reply-To: References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> Message-ID: <2r5vt9-mpu.ln1@luuk.invalid.lan> On 02-02-2013 11:01, Armin Karner wrote: > MySQLdb for python versions 3.3 or higher http://lmgtfy.com/?q=MySQLdb+for+python+versions+3.3+or+higher From torriem at gmail.com Sat Feb 2 13:29:51 2013 From: torriem at gmail.com (Michael Torrie) Date: Sat, 02 Feb 2013 11:29:51 -0700 Subject: mySQLdb In-Reply-To: <2r5vt9-mpu.ln1@luuk.invalid.lan> References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> <2r5vt9-mpu.ln1@luuk.invalid.lan> Message-ID: <510D5B1F.7020308@gmail.com> On 02/02/2013 03:19 AM, Luuk wrote: > On 02-02-2013 11:01, Armin Karner wrote: >> MySQLdb for python versions 3.3 or higher > > http://lmgtfy.com/?q=MySQLdb+for+python+versions+3.3+or+higher Embarrassingly, most of the links on the google search results page are about people asking the same question as the OP. In fact the first post is the original poster's question! It looks like there is a release candidate on github (you can find that in the google results), but I don't think there's a binary for windows yet. You'll have to compile it yourself. The third result maybe of use to you as it talks about an alternative implementation. From stefan_ml at behnel.de Sat Feb 2 13:57:32 2013 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 02 Feb 2013 19:57:32 +0100 Subject: mySQLdb In-Reply-To: <510D5B1F.7020308@gmail.com> References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> <2r5vt9-mpu.ln1@luuk.invalid.lan> <510D5B1F.7020308@gmail.com> Message-ID: Michael Torrie, 02.02.2013 19:29: > On 02/02/2013 03:19 AM, Luuk wrote: >> On 02-02-2013 11:01, Armin Karner wrote: >>> MySQLdb for python versions 3.3 or higher >> >> http://lmgtfy.com/?q=MySQLdb+for+python+versions+3.3+or+higher > > Embarrassingly, most of the links on the google search results page are > about people asking the same question as the OP. In fact the first post > is the original poster's question! > > It looks like there is a release candidate on github (you can find that > in the google results), but I don't think there's a binary for windows > yet. You'll have to compile it yourself. The third result maybe of use > to you as it talks about an alternative implementation. Note that it makes no sense to point others to "the third result" of a Google search because Google tracks who's using it and gives you personalised results based on your previous interests. So if I tried, my responses would be different from what you saw. Maybe Armin Karner's search result even featured a link to github as the first result, I can't tell. Stefan From steffen at webanimations.de Sun Feb 3 04:54:51 2013 From: steffen at webanimations.de (Steffen Mutter) Date: Sun, 3 Feb 2013 09:54:51 +0000 (UTC) Subject: mySQLdb References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> Message-ID: Hi Armin, Armin Karner wrote: > I am curious if there is an update of MySQLdb for python versions 3.3 or higher. Because I really need this for a diploma thesis.? What feature do you need which is not provided? > I really hope you have a solution for me, because it is quite urgent and important.? > I am looking forward to a quick answer! The request you send from your python to the database is handled by the db itself, so it should be more a matter by the db version itself you are using. SMut From sinaiy at gmail.com Wed Feb 6 10:51:00 2013 From: sinaiy at gmail.com (sinaiy at gmail.com) Date: Wed, 6 Feb 2013 07:51:00 -0800 (PST) Subject: mySQLdb In-Reply-To: References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> Message-ID: <51c9ab91-26f5-4f60-a133-bcf6c88be125@googlegroups.com> On Saturday, February 2, 2013 12:01:40 PM UTC+2, Armin Karner wrote: > Dear Sir or Madam, > > > > > > > > I am curious if there is an update of MySQLdb for python versions 3.3 or higher. Because I really need this for a diploma thesis.? > I've tried several of them, including various 2.x versions, but it didn't work.? > The system I use is a Microsoft Windows 7 64 bit.? > > > I really hope you have a solution for me, because it is quite urgent and important.? > > > I am looking forward to a quick answer! > > > Yours faithfully > Armin Karner i would recommend you to try using pymysql instead, https://github.com/petehunt/PyMySQL From sinaiy at gmail.com Wed Feb 6 10:51:00 2013 From: sinaiy at gmail.com (sinaiy at gmail.com) Date: Wed, 6 Feb 2013 07:51:00 -0800 (PST) Subject: mySQLdb In-Reply-To: References: <1359798984.39301.YahooMailNeo@web132102.mail.ird.yahoo.com> Message-ID: <51c9ab91-26f5-4f60-a133-bcf6c88be125@googlegroups.com> On Saturday, February 2, 2013 12:01:40 PM UTC+2, Armin Karner wrote: > Dear Sir or Madam, > > > > > > > > I am curious if there is an update of MySQLdb for python versions 3.3 or higher. Because I really need this for a diploma thesis.? > I've tried several of them, including various 2.x versions, but it didn't work.? > The system I use is a Microsoft Windows 7 64 bit.? > > > I really hope you have a solution for me, because it is quite urgent and important.? > > > I am looking forward to a quick answer! > > > Yours faithfully > Armin Karner i would recommend you to try using pymysql instead, https://github.com/petehunt/PyMySQL From schiz_man at 21stcentury.com Sat Feb 2 05:27:07 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 10:27:07 -0000 Subject: Floating point calculation problem Message-ID: I have a program that performs some calculations that runs perfectly on Python 2.7.3. However, when I try to execute it on Python 3.3.0 I get the following error: numer = math.log(s) TypeError: a float is required The quantity s is input with the following line: s = input("Enter s: ") To get rid of the compile error, I can cast this as a float: s = float(input("Enter s: ")) However, then the result returned by the method is wrong. Why does this error occur in version 3.3.0 but not in 2.7.3? Why is the result incorrect when s is cast as a float (the casting is not required in 2.7.3)? How is Python dynamically typed if I need to cast (in version 3.3.0 at least) to get rid of the compile error? Thanks in advance. PS - I'm a Python newbie. From rosuav at gmail.com Sat Feb 2 05:34:42 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 2 Feb 2013 21:34:42 +1100 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: On Sat, Feb 2, 2013 at 9:27 PM, Schizoid Man wrote: > The quantity s is input with the following line: s = input("Enter s: ") > > To get rid of the compile error, I can cast this as a float: s = > float(input("Enter s: ")) > > However, then the result returned by the method is wrong. Why does this > error occur in version 3.3.0 but not in 2.7.3? Why is the result incorrect > when s is cast as a float (the casting is not required in 2.7.3)? How is > Python dynamically typed if I need to cast (in version 3.3.0 at least) to > get rid of the compile error? Did you use input() or raw_input() in 2.7.3? If the former, you were actually doing this: s = eval(input("Enter s: ")) That's extremely dangerous and inadvisable, so it's better to go with 3.3 or the raw_input function. Passing it through float() is, most likely, the right way to do this. But what do you mean by "the result... is wrong"? That's the bit to look into. ChrisA From clp2 at rebertia.com Sat Feb 2 05:47:32 2013 From: clp2 at rebertia.com (Chris Rebert) Date: Sat, 2 Feb 2013 02:47:32 -0800 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: On Sat, Feb 2, 2013 at 2:27 AM, Schizoid Man wrote: > I have a program that performs some calculations that runs perfectly on > Python 2.7.3. However, when I try to execute it on Python 3.3.0 I get the > following error: > numer = math.log(s) > TypeError: a float is required > > The quantity s is input with the following line: s = input("Enter s: ") > > To get rid of the compile error, I can cast this as a float: s = > float(input("Enter s: ")) > How is > Python dynamically typed if I need to cast (in version 3.3.0 at least) to > get rid of the compile error? It's *not* a compile error; it's a *runtime* error raised inside math.log() when that function is called (with an invalid argument). IIRC, the only compile-time error in Python is SyntaxError (and its subclass, IndentationError). Python is also strongly-typed, which is why, at runtime, an exception is thrown instead of some implicit type coercion being attempted; such coercion tends to hide genuine bugs, hence why Python avoids it. Regards, Chris From schiz_man at 21stcentury.com Sat Feb 2 06:14:57 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 11:14:57 -0000 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: "Chris Angelico" wrote in message news:mailman.1289.1359801291.2939.python-list at python.org... > On Sat, Feb 2, 2013 at 9:27 PM, Schizoid Man > wrote: >> The quantity s is input with the following line: s = input("Enter s: ") >> >> To get rid of the compile error, I can cast this as a float: s = >> float(input("Enter s: ")) >> >> However, then the result returned by the method is wrong. Why does this >> error occur in version 3.3.0 but not in 2.7.3? Why is the result >> incorrect >> when s is cast as a float (the casting is not required in 2.7.3)? How is >> Python dynamically typed if I need to cast (in version 3.3.0 at least) to >> get rid of the compile error? > > Did you use input() or raw_input() in 2.7.3? If the former, you were > actually doing this: > > s = eval(input("Enter s: ")) > > That's extremely dangerous and inadvisable, so it's better to go with > 3.3 or the raw_input function. Thanks for the reply. You're right - even in 2.7.3 if I toggle between float(input(x)) and input(x), the result of the calculation changes. What does the float cast do exactly? > Passing it through float() is, most likely, the right way to do this. > But what do you mean by "the result... is wrong"? That's the bit to > look into. Scratch that, I'm not sure which result is right now, so need to look at the full calculations in details. What would be the difference between raw_input() and float(input())? Thanks again. From rosuav at gmail.com Sat Feb 2 06:20:12 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 2 Feb 2013 22:20:12 +1100 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: On Sat, Feb 2, 2013 at 10:14 PM, Schizoid Man wrote: > Scratch that, I'm not sure which result is right now, so need to look at the > full calculations in details. What would be the difference between > raw_input() and float(input())? > > Thanks again. Depends on what you type in. raw_input() takes a line from the keyboard (handwave) and returns it as a string. input() in 2.X takes a line from the keyboard and evaluates it as a Python expression. float() takes a string, float, int, etc, and returns the nearest-equivalent floating point value. What's the input you're giving to it? ChrisA From schiz_man at 21stcentury.com Sat Feb 2 06:34:48 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 11:34:48 -0000 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: > raw_input() takes a line from the keyboard (handwave) and returns it > as a string. > > input() in 2.X takes a line from the keyboard and evaluates it as a > Python expression. > > float() takes a string, float, int, etc, and returns the > nearest-equivalent floating point value. > > What's the input you're giving to it? Something simple like 3.0. PS - I'm new to Python, hence the newbie questions. From rosuav at gmail.com Sat Feb 2 06:38:55 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 2 Feb 2013 22:38:55 +1100 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: On Sat, Feb 2, 2013 at 10:34 PM, Schizoid Man wrote: >> raw_input() takes a line from the keyboard (handwave) and returns it >> as a string. >> >> input() in 2.X takes a line from the keyboard and evaluates it as a >> Python expression. >> >> float() takes a string, float, int, etc, and returns the >> nearest-equivalent floating point value. >> >> What's the input you're giving to it? > > > Something simple like 3.0. If your input has no decimal point in it, eval (or input) will return an integer, not a float. Other than that, I can't see any obvious reason for there to be a difference. Can you put together a simple script that demonstrates the problem and post it, along with the exact input that you're giving it, and the different outputs? Chris Angelico From schiz_man at 21stcentury.com Sat Feb 2 06:51:31 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 11:51:31 -0000 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: > If your input has no decimal point in it, eval (or input) will return > an integer, not a float. Other than that, I can't see any obvious > reason for there to be a difference. Can you put together a simple > script that demonstrates the problem and post it, along with the exact > input that you're giving it, and the different outputs? Understood. I'm trying to learn Python by porting an ODE solver I wrote over from C#, so what I'll do is break down the routine and append a small code snippet highlighting the difference. I know this is probably redundant but Python 2.7.3 is running on a Mac and 3.3.0 on a PC, so it's not exactly an apples-v-apples comparison. From rosuav at gmail.com Sat Feb 2 06:58:46 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 2 Feb 2013 22:58:46 +1100 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: On Sat, Feb 2, 2013 at 10:51 PM, Schizoid Man wrote: >> If your input has no decimal point in it, eval (or input) will return >> an integer, not a float. Other than that, I can't see any obvious >> reason for there to be a difference. Can you put together a simple >> script that demonstrates the problem and post it, along with the exact >> input that you're giving it, and the different outputs? > > > Understood. I'm trying to learn Python by porting an ODE solver I wrote over > from C#, so what I'll do is break down the routine and append a small code > snippet highlighting the difference. Thanks, I think I can speak for all of us in expressing appreciation for that effort! It makes the job so much easier. > I know this is probably redundant but Python 2.7.3 is running on a Mac and > 3.3.0 on a PC, so it's not exactly an apples-v-apples comparison. Ah, there may well be something in that. Definitely post the code and outputs; chances are someone'll spot the difference. ChrisA From steve+comp.lang.python at pearwood.info Sat Feb 2 07:11:09 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 02 Feb 2013 23:11:09 +1100 Subject: Floating point calculation problem References: Message-ID: <510d025f$0$30002$c3e8da3$5496439d@news.astraweb.com> Schizoid Man wrote: > I know this is probably redundant but Python 2.7.3 is running on a Mac and > 3.3.0 on a PC, so it's not exactly an apples-v-apples comparison. It's not impossible that there is a slight difference in some of the floating point functions. E.g. when you call math.log(s), one version might be accurate to (say) 15 decimal places and the other to (say) 14 decimal places, and that difference is magnified by subsequent calculations. -- Steven From schiz_man at 21stcentury.com Sat Feb 2 10:48:24 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 15:48:24 -0000 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: > Ah, there may well be something in that. Definitely post the code and > outputs; chances are someone'll spot the difference. Ok, I *think* I found the source of the difference: This is the base code that runs fine in v 3.3.0 (the output is correct): def Numer(s, k): return math.log(s / k) s = float(input("Enter s: ")) k = float(input("Enter k: ")) print("Result: ", Numer(s, k)) For the v2.7 version, the only difference is the input lines: s = input("Enter s: ") k = input("Enter k: ") So for values of s=60 and k=50, the first code returns 0.1823215567939546 (on the PC), whereas the second returns 0.0 (on the Mac). This this expression is evaluated in the numerator, it never returns a divide by zero error, and the result of 0 is treated as legitimate. However, if I cast the v2.7 inputs as float() then it does indeed return the right result. But what threw me was that no cast didn't result in a runtime error in 2.7, but did in 3.3. Also, if the cast is necessary, then now exactly does the dynamic typing work? Thanks. From schiz_man at 21stcentury.com Sat Feb 2 10:54:25 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 15:54:25 -0000 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: "Schizoid Man" wrote in message news:kejcfi$s70$1 at dont-email.me... > So for values of s=60 and k=50, the first code returns 0.1823215567939546 > (on the PC), whereas the second returns 0.0 (on the Mac). This this > expression is evaluated in the numerator, it never returns a divide by > zero error, and the result of 0 is treated as legitimate. D'oh! That's the error right there. My inputs are 60 and 50, not 60.0 and 50.0. I am a dunderhead. Apologies for wasting your time. From rosuav at gmail.com Sat Feb 2 11:00:30 2013 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 3 Feb 2013 03:00:30 +1100 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: On Sun, Feb 3, 2013 at 2:48 AM, Schizoid Man wrote: > def Numer(s, k): > return math.log(s / k) > > s = float(input("Enter s: ")) > k = float(input("Enter k: ")) > print("Result: ", Numer(s, k)) > > For the v2.7 version, the only difference is the input lines: > > s = input("Enter s: ") > k = input("Enter k: ") > > So for values of s=60 and k=50, the first code returns 0.1823215567939546 > (on the PC), whereas the second returns 0.0 (on the Mac). This this > expression is evaluated in the numerator, it never returns a divide by zero > error, and the result of 0 is treated as legitimate. So on your Python 2 install, you're working with integers, dividing one by another, and getting back a value of 1 - and log(1) is 0. The problem is your division operator, which can be fixed as Steven suggests, with the future directive. > However, if I cast the v2.7 inputs as float() then it does indeed return the > right result. But what threw me was that no cast didn't result in a runtime > error in 2.7, but did in 3.3. > > Also, if the cast is necessary, then now exactly does the dynamic typing > work? It's not quite a cast. Python's type system is broadly this: Every object (value) has a type, every name (variable, sort of) doesn't. So I can do this: spam = "hello, world" # spam is a string spam = 5 # spam is now an int spam = (1,2,3) # spam is now a tuple spam = object() # you get the idea I strongly recommend you either go with Python 3 or raw_input, but NOT with float(input()) in Py2. Go with float(raw_input()) and you're doing exactly one translation, and the correct one. ChrisA From torriem at gmail.com Sat Feb 2 13:19:41 2013 From: torriem at gmail.com (Michael Torrie) Date: Sat, 02 Feb 2013 11:19:41 -0700 Subject: Floating point calculation problem In-Reply-To: References: Message-ID: <510D58BD.9010505@gmail.com> On 02/02/2013 08:48 AM, Schizoid Man wrote: > Also, if the cast is necessary, then now exactly does the dynamic typing > work? Dynamic typing isn't referring to numeric type coercion. It refers to the fact that a name can be bound to an object of any type. So if you made a function like this: def add (num1, num2): return num1 + num2 num1 and num2 could be any type. Even a custom type if you wanted. This function would work properly on any type that had implemented the __add__ method. And whether or not num2 has to be the same type as num1 depends on whether the num1 type has implemented an __add__ method that can deal with the type of num2. Another case where dynamic typing comes into play is in a case know as duck typing: def squeeze_duck (duck): // return the quack return duck.squeeze() duck can be of any type as well, but as long as it implements the squeeze method, this function will work with an object of that type. In a language like C#, duck-typing can only be emulated by using interface classes. From steve+comp.lang.python at pearwood.info Sat Feb 2 20:25:09 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sun, 03 Feb 2013 12:25:09 +1100 Subject: Floating point calculation problem References: Message-ID: <510dbc76$0$29984$c3e8da3$5496439d@news.astraweb.com> Michael Torrie wrote: > def squeeze_duck (duck): > // return the quack > return duck.squeeze() I'm curious, what language were you thinking of when you wrote the comment using // instead of # ? -- Steven From d at davea.name Sat Feb 2 21:20:49 2013 From: d at davea.name (Dave Angel) Date: Sat, 02 Feb 2013 21:20:49 -0500 Subject: Floating point calculation problem In-Reply-To: <510dbc76$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <510dbc76$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <510DC981.4040605@davea.name> On 02/02/2013 08:25 PM, Steven D'Aprano wrote: > Michael Torrie wrote: > >> def squeeze_duck (duck): >> // return the quack >> return duck.squeeze() > > I'm curious, what language were you thinking of when you wrote the comment > using // instead of # ? > > I'm guessing that would probably be C++. Or more recent versions of C. -- DaveA From torriem at gmail.com Sat Feb 2 23:22:12 2013 From: torriem at gmail.com (Michael Torrie) Date: Sat, 02 Feb 2013 21:22:12 -0700 Subject: Floating point calculation problem In-Reply-To: <510dbc76$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <510dbc76$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <510DE5F4.5020302@gmail.com> On 02/02/2013 06:25 PM, Steven D'Aprano wrote: > Michael Torrie wrote: > >> def squeeze_duck (duck): >> // return the quack >> return duck.squeeze() > > I'm curious, what language were you thinking of when you wrote the comment > using // instead of # ? Oh darn. Blew my cover. I'm beta testing Ranting Rick's wonderful fork, Rrython. Actually, my brain is full of Arduino code right now... which is fun, but C++, yuck. From steve+comp.lang.python at pearwood.info Sat Feb 2 06:45:38 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 02 Feb 2013 22:45:38 +1100 Subject: Floating point calculation problem References: Message-ID: <510cfc63$0$30002$c3e8da3$5496439d@news.astraweb.com> Schizoid Man wrote: > "Chris Angelico" wrote in message > news:mailman.1289.1359801291.2939.python-list at python.org... >> On Sat, Feb 2, 2013 at 9:27 PM, Schizoid Man >> wrote: >>> The quantity s is input with the following line: s = input("Enter s: >>> ") >>> >>> To get rid of the compile error, I can cast this as a float: s = >>> float(input("Enter s: ")) >>> >>> However, then the result returned by the method is wrong. Why does this >>> error occur in version 3.3.0 but not in 2.7.3? Why is the result >>> incorrect >>> when s is cast as a float (the casting is not required in 2.7.3)? How is >>> Python dynamically typed if I need to cast (in version 3.3.0 at least) >>> to get rid of the compile error? >> >> Did you use input() or raw_input() in 2.7.3? If the former, you were >> actually doing this: >> >> s = eval(input("Enter s: ")) >> >> That's extremely dangerous and inadvisable, so it's better to go with >> 3.3 or the raw_input function. > > Thanks for the reply. You're right - even in 2.7.3 if I toggle between > float(input(x)) and input(x), the result of the calculation changes. Highly unlikely. I'd say impossible, unless you type a different value for x of course. By the time the input() function returns, the result is already a float. Wrapping it in float() again cannot possibly change the value. If you have found a value that does change, please tell us what it is. The only examples I can think of that will behave that way involve NANs and INFs. If you don't know what they are, don't worry about it, and forget I mentioned them. For regular floating point values, I can't think of any possible way that float(input(x)) and input(x) could give different results. > What does the float cast do exactly? float(x) converts x into a float. - if x is already a float, it leaves it unchanged; - if x is a string, it converts it to the nearest possible float; - if x is some other numeric value (e.g. int, Decimal or Fraction, but not complex) it converts it to the nearest possible float. >> Passing it through float() is, most likely, the right way to do this. >> But what do you mean by "the result... is wrong"? That's the bit to >> look into. > > Scratch that, I'm not sure which result is right now, so need to look at > the full calculations in details. What would be the difference between > raw_input() and float(input())? In Python 2.x, raw_input returns a string. To turn it into a float, you need to use float(raw_input()). float(input()) is a waste of time. The dangerous part happens in the call to input(): a malicious user could type a Python command, and run arbitrary code; or they could type something like "10**100**100" and lock up your computer. Calling float *after* the call to input doesn't do anything. In Python 3.x, raw_input is gone, but float(input()) is safe -- it is exactly equivalent to float(raw_input()) in Python 2.x. One other difference between Python 2.7 and 3.3 is that they sometimes display floats slightly differently. Sometimes 3.3 will show more decimal places: [steve at ando ~]$ python2.7 -c "x = 1.0/33; print (x+x+x)" 0.0909090909091 [steve at ando ~]$ python3.3 -c "x = 1.0/33; print (x+x+x)" 0.09090909090909091 but you can be sure that they are the same value, it is just a difference in the default display of floats: [steve at ando ~]$ python2.7 -c "x = 1.0/33; print (x+x+x).hex()" 0x1.745d1745d1746p-4 [steve at ando ~]$ python3.3 -c "x = 1.0/33; print((x+x+x).hex())" 0x1.745d1745d1746p-4 -- Steven From schiz_man at 21stcentury.com Sat Feb 2 06:50:09 2013 From: schiz_man at 21stcentury.com (Schizoid Man) Date: Sat, 2 Feb 2013 11:50:09 -0000 Subject: Floating point calculation problem In-Reply-To: <510cfc63$0$30002$c3e8da3$5496439d@news.astraweb.com> References: <510cfc63$0$30002$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Highly unlikely. I'd say impossible, unless you type a different value for > x > of course. By the time the input() function returns, the result is already > a float. Wrapping it in float() again cannot possibly change the value. If > you have found a value that does change, please tell us what it is. > > The only examples I can think of that will behave that way involve NANs > and > INFs. If you don't know what they are, don't worry about it, and forget I > mentioned them. For regular floating point values, I can't think of any > possible way that float(input(x)) and input(x) could give different > results. > No, the calculation returns in neither NaN or Inf at any point. > float(x) converts x into a float. > > - if x is already a float, it leaves it unchanged; > > - if x is a string, it converts it to the nearest possible float; > > - if x is some other numeric value (e.g. int, Decimal or Fraction, > but not complex) it converts it to the nearest possible float. > > > float(input()) is a waste of time. The dangerous part happens in the call > to > input(): a malicious user could type a Python command, and run arbitrary > code; or they could type something like "10**100**100" and lock up your > computer. Calling float *after* the call to input doesn't do anything. > > In Python 3.x, raw_input is gone, but float(input()) is safe -- it is > exactly equivalent to float(raw_input()) in Python 2.x. > > One other difference between Python 2.7 and 3.3 is that they sometimes > display floats slightly differently. Sometimes 3.3 will show more decimal > places: Thanks for that, I'll post the problematic code here shortly. From steve+comp.lang.python at pearwood.info Sat Feb 2 07:05:31 2013 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 02 Feb 2013 23:05:31 +1100 Subject: Floating point calculation problem References: Message-ID: <510d010c$0$29987$c3e8da3$5496439d@news.astraweb.com> Schizoid Man wrote: > I have a program that performs some calculations that runs perfectly on > Python 2.7.3. However, when I try to execute it on Python 3.3.0 I get the > following error: > numer = math.log(s) > TypeError: a float is required > > The quantity s is input with the following line: s = input("Enter s: ") > > To get rid of the compile error, I can cast this as a float: > s = float(input("Enter s: ")) > > However, then the result returned by the method is wrong. Why does this > error occur in version 3.3.0 but not in 2.7.3? Why is the result incorrect > when s is cast as a float (the casting is not required in 2.7.3)? Others have already discussed the differences between input() in Python 2 and 3, but there's another difference that could be causing you to get the wrong results: division in Python 2 defaults to *integer* division. If you type a value like "3" (with no decimal point) into input, you will get the int 3, not the float 3.0. Then if you divide by another integer, by default you will get truncating integer division instead of what you probably expect: >>> num = input('Enter a value: ') Enter a value: 3 >>> print num/2 1 Whereas if you type it with a decimal point, input() will turn it into a float, and you will get float division: >>> num = input('Enter a value: ') Enter a value: 3.0 >>> print num/2 1.5 This does not happen in Python 3.x -- you always get floating point division, even if both the numerator and denominator are ints. You can fix this, and get the proper calculator-style floating point division, in Python 2 by putting this line at the very top of your script: from __future__ import division This must appear before any other line of code; it can follow comments and blank lines, but not code. -- Steven From roaldosinga at gmail.com Sat Feb 2 09:43:45 2013 From: roaldosinga at gmail.com (Roald) Date: Sat, 2 Feb 2013 06:43:45 -0800 (PST) Subject: Problem with my nose test plugin Message-ID: <1d0edd06-2c4c-4db7-a7da-945cbb146af0@googlegroups.com> Hi all, I want to execute unit tests from web2py and I want to automatically discover, so I think it is wise to use nose tests for that. That way, I can write a plugin to receive the test results in stead of heaving to parse the output stream. I use nose.run(addPlugins[MyPlugin()]), and although I see the configure() and option() get called and also see that nose runs my tests. What boggles my mind is that none of my plugins functions get called. Do I need to configure something? Roald the code is on pastbin: http://pastebin.com/rcXh2VAy From roaldosinga at gmail.com Sat Feb 2 10:35:07 2013 From: roaldosinga at gmail.com (R. Osinga) Date: Sat, 2 Feb 2013 07:35:07 -0800 (PST) Subject: Problem with my nose test plugin In-Reply-To: <1d0edd06-2c4c-4db7-a7da-945cbb146af0@googlegroups.com> References: <1d0edd06-2c4c-4db7-a7da-945cbb146af0@googlegroups.com> Message-ID: <3cbc079d-2453-41a6-8c5e-62a40800a813@googlegroups.com> On Saturday, February 2, 2013 3:43:45 PM UTC+1, R. Osinga wrote: > Hi all, > > > > I want to execute unit tests from web2py and I want to automatically discover, so I think it is wise to use nose tests for that. That way, I can write a plugin to receive the test results in stead of heaving to parse the output stream. > > I use nose.run(addPlugins[MyPlugin()]), and although I see the configure() and option() get called and also see that nose runs my tests. What boggles my mind is that none of my plugins functions get called. Do I need to configure something? > > > > Roald > > > > the code is on pastbin: http://pastebin.com/rcXh2VAy Addition: I use the ubuntu repo version 1.1.2-3 From julio at techfuel.net Sat Feb 2 15:35:37 2013 From: julio at techfuel.net (Julio F Schwarzbeck) Date: Sat, 02 Feb 2013 12:35:37 -0800 Subject: RESTful API for own python application Message-ID: Howdy folks, I have a couple of questions that imo requires some feedback by the smarts, I'd appreciate any comments you can add to this issue, here's my situation: I am developing an application, the application stores small text snippets (think of something similar to evernote), and it has the standard CRUD operations of any other application. Now my question is, how much would you recommend creating the entire CRUD operations as a REST API even for my own program, I plan to have a "thin" web client UI to make these operations, but I am thinking about creating another client for ubuntu and its phone, for instance, and possibly connections from other clients. Under the scenario above, I think it makes sense, but what about other applications that I have created in which the the back-end does not talk to anyone except the actual app and may or may not expose resources externally, would it make sense to 'standardize' in my CRUD operations for all my existing applications (forum system, q/a web app, ticketing system, and several others). Thanks in advance from your responses. JulioS From dieter at handshake.de Sun Feb 3 02:25:34 2013 From: dieter at handshake.de (dieter) Date: Sun, 03 Feb 2013 08:25:34 +0100 Subject: RESTful API for own python application References: Message-ID: <87ehgxzwnl.fsf@handshake.de> Julio F Schwarzbeck writes: > I am developing an application, the application stores small text > snippets (think of something similar to evernote), and it has the > standard CRUD operations of any other application. > > Now my question is, how much would you recommend creating the entire > CRUD operations as a REST API even for my own program, I plan to have > a "thin" web client UI to make these operations, but I am thinking > about creating another client for ubuntu and its phone, for instance, > and possibly connections from other clients. REST is very open to the output format. When you want to use a "thin" web client for human users via REST, then the output likely must be HTML. For programs, output with structure designed for programs not humans is usually better suited (e.g. X-schema described XML or "json"). Therefore, I would expect that you have 2 different "view"s on your service: one for human users and another one for programs. Whether your human user view internally uses the REST api for programs or instead directly use a common internal api depends partly on personal preferences (some people are extreme REST fans; others (like me) do not like it at all) and partly on deployment scenarios (if, e.g., the human user view must be distributed, then using the REST api for its implementation would facilitate this). If possible, I would go for the second option: REST and human user views both use the same underlaying service api. From mfulz at olznet.de Sat Feb 2 19:38:02 2013 From: mfulz at olznet.de (Matthias Fulz) Date: Sun, 3 Feb 2013 00:38:02 +0000 (UTC) Subject: Pygtk entry readline Message-ID: Hi, does anybody know howto connect / use a gtk entry as "frontend" for readline in- / output? I couldn't find anything on the net for my problem. Basicly I've a working readline autocomplete, which I can use without problems via input function, but I want to use that in an gtk gui inside an entry or textbox, etc. Thanks, Matthias -- Wer A sagt, der muss nich B sagen, Er kann auch erkennen, dass A falsch war. ---- GPG key: 1814DA35 ---- From steffen at webanimations.de Sun Feb 3 04:46:08 2013 From: steffen at webanimations.de (Steffen Mutter) Date: Sun, 3 Feb 2013 09:46:08 +0000 (UTC) Subject: Improve reduce functions of SQLite3 request Message-ID: Hi, I am writing some code to manage handball leagues more easy. Problem: MISSON: Get single club ids glued together with the shortest teamname. EXAMPLE: SELECT homenr as nr, home as club FROM Runde20122013 WHERE place="karlsruhe" UNION SELECT guestnr as nr, guest as club FROM 20122013 WHERE place="karlsruhe" GROUP BY nr LIMIT 10 ACTUAL RESULT: 359|TV Calmbach 21101|SG Heidel/Helm 21236|JSG Neuth/B?ch 23108|TG Eggenstein 23108|TG Eggenstein 2 23109|TV Ettlingenw 23109|TV Ettlingenw 2 23112|TSV J?hlingen 23112|TSV J?hlingen 2 23112|TSV J?hlingen 3 NEEDED RESULT: 359|TV Calmbach 21101|SG Heidel/Helm 21236|JSG Neuth/B?ch 23108|TG Eggenstein 23109|TV Ettlingenw 23112|TSV J?hlingen the nr needs to be unique together with the shortest clubname returned by the where clause. Any hints how to get this done either with SQLite3 tecneeqs or python functions. Kind regards. SMut From steffen at webanimations.de Mon Feb 4 09:30:35 2013 From: steffen at webanimations.de (Steffen Mutter) Date: Mon, 4 Feb 2013 14:30:35 +0000 (UTC) Subject: Improve reduce functions of SQLite3 request References: Message-ID: Dennis Lee Bieber wrote: > Untested: > > SELECT DISTINCT * from > (select homenr as nr, home as club FROM Runde20122013 > WHERE place="karlsruhe" > UNION SELECT guestnr as nr, guest as club FROM 20122013 > WHERE place="karlsruhe") > limit 10 Hi Dennis, here the output of your suggested solution: SELECT DISTINCT * FROM ( SELECT HeimNr as nr, Heim as club FROM Runde20122013 WHERE kreis ="karlsruhe" UNION SELECT GastNr as nr, gast as club FROM Runde20122013 WHERE kreis ="karlsruhe") LIMIT 10; 359|TV Calmbach 21101|SG Heidel/Helm 21236|JSG Neuth/B?ch 23108|TG Eggenstein 23108|TGEggenstein 2 <- 23109|TV Ettlingenw 23109|TV Ettlingenw 2 <- 23112|TSV J?hlingen 23112|TSV J?hlingen 2 <- 23112|TSV J?hlingen 3 <- Still not like what I'm looking for. Maybe I should iterate through the list, pick out the nr and look for the club stick it to a new list and leave out those ones, with the longe r club name... From davea at davea.name Mon Feb 4 10:30:51 2013 From: davea at davea.name (Dave Angel) Date: Mon, 04 Feb 2013 10:30:51 -0500 Subject: Improve reduce functions of SQLite3 request In-Reply-To: References: Message-ID: <510FD42B.8040705@davea.name> On 02/04/2013 09:30 AM, Steffen Mutter wrote: > 359|TV Calmbach > 21101|SG Heidel/Helm > 21236|JSG Neuth/B?ch > 23108|TG Eggenstein > 23108|TGEggenstein 2 <- > 23109|TV Ettlingenw > 23109|TV Ettlingenw 2 <- > 23112|TSV J?hlingen > 23112|TSV J?hlingen 2 <- > 23112|TSV J?hlingen 3 <- > > Still not like what I'm looking for. > Maybe I should iterate through the list, pick out the nr and look for > the club stick it to a new list and leave out those ones, with the longe > r club name... > Perhaps you should define how you choose to match a shorter & longer club name as "equivalent". For example, why isn't 'E' the shorter name to for Ettlingneow and Eggenstein ? Are you maybe just throwing everything away after the first blank? Or what? -- DaveA From __peter__ at web.de Mon Feb 4 11:29:41 2013 From: __peter__ at web.de (Peter Otten) Date: Mon, 04 Feb 2013 17:29:41 +0100 Subject: Improve reduce functions of SQLite3 request References: Message-ID: Steffen Mutter wrote: > Dennis Lee Bieber wrote: >> Untested: >> >> SELECT DISTINCT * from >> (select homenr as nr, home as club FROM Runde20122013 >> WHERE place="karlsruhe" >> UNION SELECT guestnr as nr, guest as club FROM 20122013 >> WHERE place="karlsruhe") >> limit 10 > > Hi Dennis, > > here the output of your suggested solution: > SELECT DISTINCT * FROM ( > SELECT HeimNr as nr, Heim as club FROM Runde20122013 > WHERE kreis ="karlsruhe" > UNION > SELECT GastNr as nr, gast as club FROM Runde20122013 > WHERE kreis ="karlsruhe") LIMIT 10; > > 359|TV Calmbach > 21101|SG Heidel/Helm > 21236|JSG Neuth/B?ch > 23108|TG Eggenstein > 23108|TGEggenstein 2 <- > 23109|TV Ettlingenw > 23109|TV Ettlingenw 2 <- > 23112|TSV J?hlingen > 23112|TSV J?hlingen 2 <- > 23112|TSV J?hlingen 3 <- > > Still not like what I'm looking for. > Maybe I should iterate through the list, pick out the nr and look for > the club stick it to a new list and leave out those ones, with the longe > r club name... How about SELECT nr, min(club) FROM ( SELECT HeimNr as nr, Heim as club FROM Runde20122013 WHERE kreis ="karlsruhe" UNION SELECT GastNr as nr, gast as club FROM Runde20122013 WHERE kreis ="karlsruhe") GROUP BY nr; However, I'm smelling a data normalization issue. It looks like you are interested in the club, but that there may be multiple teams per club and you are trying to derive the club from the team name. If that's the case you should consider a database layout with tables similar to the following (* to mark primary keys) matches ------- matchID*, hometeamID, guestteamID, ... teams ----- teamID*, clubID, teamname, ... clubs ----- clubID*, clubname, ... With such a layout you could get all clubs with (untested, of course) SELECT clubs.clubId, clubs.clubname FROM ( SELECT hometeamID as teamID from matches UNION SELECT guestteamID as teamID from matches) as participants INNER JOIN teams on teams.teamID = participants.teamID INNER JOIN clubs on teams.clubID = clubs.teamID; I hope you can make sense of it... From steffen at webanimations.de Mon Feb 4 17:05:08 2013 From: steffen at webanimations.de (Steffen Mutter) Date: Mon, 4 Feb 2013 22:05:08 +0000 (UTC) Subject: Improve reduce functions of SQLite3 request References: Message-ID: Dennis Lee Bieber wrote: > I suspect you have a poorly normalized database (what does that > trailing number identify? Heck, are the leading initials unique to the > subsequent name?). The trailing number should probably be something > stored as a separate field. If the initials are unique, they should be a > separate field used as a foreign reference to retrieve the longer name. There's much more stuff in the table of the database, but these ones does not matter, the table Runde20122013 stores all the data needed for gameplay during this season and is made to handle ALL leagues in germany and if you enter another federation name as 'dhb' it could handle even more... Jutst to explain: the numbers define the team(s) of the club in a special category (male/female, youth E,D,C,B,A adults, senior), playing in a league. Those leagues matter in the where clause, so the area 'karlsruhe' represents one of the lowest areas a team can play in - called 'Kreisklasse'. So, if a club has only team 2 playing here, and the team (1) is playing higher, the number 2 needs to remain here. Just to give you a peek on what I am doing: https://handball.ws/generator.html has sometimes over 50.000 clicks in a weekend - and manages it very nicely with a very small hetzner shared server running lighttpd and python cgi. At home I am working on a new bugfixed version which I hopefully get online before planning for season 20132014 starts (April) -- SNIP -- > sqlite> select nr, min(club) from test group by nr; > nr min(club) > ---------- ------------------------- > 359 TV Calmbach > 21101 SG Heidel/Helm > 21236 JSG Neuth/Buch > 23108 TG Eggenstein > 23109 TV Ettlingenw > 23112 TSV Johlingen > sqlite> > > Don't even need the DISTINCT with the GROUP BY. Woha! Why didn't I get this out by myself? So, let's see what my machine spits out: SQL: SELECT nr, min(club) FROM ( SELECT HeimNr as nr, Heim as club FROM Runde20122013 WHERE kreis = "karlsruhe" UNION SELECT GastNr as nr, gast as club FROM Runde20122013 WHERE kreis= "karlsruhe") GROUP BY nr; REPLY: 359|TV Calmbach 21101|SG Heidel/Helm 21236|JSG Neuth/B?ch 23108|TG Eggenstein 23109|TV Ettlingenw 23112|TSV J?hlingen 23113|HC Karlsbad 23114|MTV Karlsruhe 23115|Post S?dst KA 23117|TSV Bulach 23118|TS Durlach 23119|TV Knielingen 23120|TS M?hlburg 23121|TG Neureut 23122|TSV Rintheim 23123|TUS R?ppurr 23124|SV Langenstb. 23125|FV Leopoldshfn 23126|TV Malsch 23128|TV W?ssingen 23130|HSG Ettl/Bruch 23132|HSG Li-Ho-Li 23133|HSG PSV/SSC KA 23136|HSG Ri/Wei/Gr? 2 <--- PERFECT!!! 23138|HSG Wei/Gr? 23231|SG Stutensee 23234|KIT SC 2010 23251|SG MTV/Bulach 23503|SG R?Bu 23516|SG Malsch/Ettl 25149|HC Neuenb?rg 25201|SG PF/Eutingen 25224|HSG Pforzheim 25232|JSG Goldst. P I need to glue home/guest aka heim/gast together, because there are K.O. leagues, where a team may play only as guest, before kicked out of the game (Amateur Deutschlandpokal) HSG Rintheim-Weingarten-Gr?tzingen 2nd team plays in Karlsruhe, the 1st one plays Badenliga. If you come to Karlsruhe one day, send me an email, I take you out for a beer or so... Kind regars, Steffen (very happy) Steffen From steffen at webanimations.de Wed Feb 6 04:18:58 2013 From: steffen at webanimations.de (Steffen Mutter) Date: Wed, 6 Feb 2013 09:18:58 +0000 (UTC) Subject: Improve reduce functions of SQLite3 request References: Message-ID: Dennis Lee Bieber wrote: > Which does, to me, imply an unnormalized database. The > "team/category" should be a separate field. > club(*ID*, name) > > team(*ID*, /club/, category) > > {where *..* is primary key, /../ is a foreign key} You are right, but as I mentioned above I had to use some data stored somwhere, strip it out of html, seperate it and store it in a database, where it is useful. To be specific: the only thing really needed is the club number. Which team plays in the specific league is not really important, cause a club can only have one team in a league. > and league should probably be another table (and "club" may have a > /league/ entry). The way I did it is this: store all data for a complete season in one table. There are more tables especially for the gyms or stadium data if more information is requested by the user. My plan is to do it better and user friendly than the commercial stuff, but I need their results and design to get my thing to work. I offer the game-plans as html for direct viewing and cvs and pdf files for download - onother feature no commercial site offers. > Yes, that would imply using JOINs to get a full identifier, and > maybe more complex GROUP BY terms... Certainly a more complex normalization would imply a complete reprogramming of all SQL-requests send to the DB. I am a great fan of SQ Lite, because it is fast, easy to use and very easy to maintain and backup. (just a nice rsync job backups all without any hassle) I prefer you help next time I run into a problem I can't fix on my own :-) >> Woha! >> Why didn't I get this out by myself? > Well, I only got the idea after someone else mentioned using min(); > but I don't recall if they had GROUP BY in that suggestion. GROUP BY > ensures the min() only applies when the "nr" is the same. I played around with min() already but I got stuck with the 'DISTINCT' at the beginning so I got only a single result. This SQL spell you were casting for me gave me a deeper understanding, how SQL works and what can be done with it. Thanks :-) Actually I am fixing bugs and think about the user managment and permission handling and privacy of data. Just give you a peek: referees need to be kept safe. But they need to be planned and stored in the DB. How to handle this? I think I use GnuPG. Every referee and referee-date-planner needs a private and public key so only these persons can see it, the planner every referee he dates and the referee only these games he is planned for. You see: a lot of work to do - after fixing some bugs and get the