Re: Python, C++ interaction

2014-12-04 Thread Jeremy Sanders
Michael Kreim wrote: What are you using to wrap C++ classes for Python? I'm using SIP, as it fits nicely with my PyQt user interface. http://www.riverbankcomputing.com/software/sip/intro It's a pretty flexible and fast way of wrapping C++ and C. If you want to pass numpy arrays and such, it

Re: Python, C++ interaction

2014-12-04 Thread Christian Gollwitzer
Am 03.12.14 09:29, schrieb Michael Kreim: I did some googleing on extending Python by C++ code but I did not find something that satisfies me. I gave SWIG a try, but several webpages disadvised me of using it. Also my small experiments did not work. I don't know why SWIG is discouraged; in my

Re: Most gratuitous comments

2014-12-04 Thread Albert van der Horst
In article 546d7505$0$12899$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano st...@pearwood.info wrote: And the award for the most gratuitous comments before an import goes to one of my (former) workmates, who wrote this piece of code: # Used for base64-decoding. import base64 # Used for

Re: Python, C++ interaction

2014-12-04 Thread Sturla Molden
Dan Stromberg drsali...@gmail.com wrote: 1) writing in Cython+CPython (as opposed to wrapping C++ with Cython) That is an option, but it locks the code to Cython and CPython forever. C and C++ are at least semi-portable. 2) using numba+CPython (It's a pretty fast decorator - I've heard it's

Re: How is max supposed to work, especially key.

2014-12-04 Thread Albert van der Horst
In article mailman.16378.1417111312.18130.python-l...@python.org, Peter Otten __pete...@web.de wrote: Albert van der Horst wrote: In the Rosetta code I come across this part of LU-decomposition. def pivotize(m): Creates the pivoting matrix for m. n = len(m) ID = [[float(i ==

Re: Python handles globals badly.

2014-12-04 Thread jtan
How can Skybuck use so much globals. Wouldn't that introduce a lot of thread safety problems? On Thu, Dec 4, 2014 at 9:32 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 03/12/2014 23:02, Skybuck Flying wrote: Mark Lawrence wrote in message

Re: How is max supposed to work, especially key.

2014-12-04 Thread Chris Angelico
On Thu, Dec 4, 2014 at 9:09 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: If there is more than one item with the maximum calculated the first is given, so for your attempt max(xrange(100,200), key=lambda i: i%17==0 ) the values False, False, True, False, ... are calculated and

Re: Python handles globals badly.

2014-12-04 Thread Mark Lawrence
On 04/12/2014 05:03, jtan wrote: How can Skybuck use so much globals. Wouldn't that introduce a lot of thread safety problems? I actually don't know. However buying very strong thread from your local store and making sure that you have a very sharp needle does help alleviate threading

Re: Python handles globals badly.

2014-12-04 Thread Chris Angelico
On Thu, Dec 4, 2014 at 4:03 PM, jtan ad...@grails.asia wrote: How can Skybuck use so much globals. Wouldn't that introduce a lot of thread safety problems? A lot of programs don't use threads, and therefore cannot have thread safety problems - or, looking at it the other way, do not care about

Re: Python docs disappointing

2014-12-04 Thread Albert van der Horst
In article mailman.16030.1416502295.18130.python-l...@python.org, Joel Goldstick joel.goldst...@gmail.com wrote: SNIP Or just WOW!. Programming is hard, and people have just started to do it. Fifty years isn't that long. It has only been 20 years or so that the web has been around. That

Re: Python docs disappointing

2014-12-04 Thread Chris Angelico
On Thu, Dec 4, 2014 at 9:27 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: That doesn't help. I'm a very experienced programmer and work in routinely a dozen languages. Sometimes I do python. I want to do numeric work. I remember the name numpy. It is important, everybody knows it,

Re: How is max supposed to work, especially key.

2014-12-04 Thread Albert van der Horst
In article mailman.16552.1417688329.18130.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Thu, Dec 4, 2014 at 9:09 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: If there is more than one item with the maximum calculated the first is given, so for your attempt

Re: How is max supposed to work, especially key.

2014-12-04 Thread Jussi Piitulainen
Albert van der Horst writes: Useful as that function [Python's max with a key] may be, it shouldn't have been called max. The meaning of the key should be added to help(max), if it still isn't - returns a maximal element or an element that maximizes the key. In some communities they call it

Re: How is max supposed to work, especially key.

2014-12-04 Thread Jussi Piitulainen
Albert van der Horst writes: Chris Angelico wrote: If there's no clear maximum, it can't do any better than that. It's still returning something for which there is no greater. I agree that it is a useful function and that it is doing the right thing. What is wrong is the name. I refer

Re: How is max supposed to work, especially key.

2014-12-04 Thread Peter Otten
Albert van der Horst wrote: In article mailman.16378.1417111312.18130.python-l...@python.org, Peter Otten __pete...@web.de wrote: Albert van der Horst wrote: In the Rosetta code I come across this part of LU-decomposition. def pivotize(m): Creates the pivoting matrix for m. n =

Re: How is max supposed to work, especially key.

2014-12-04 Thread Peter Otten
Albert van der Horst wrote: I agree that it is a useful function and that it is doing the right thing. What is wrong is the name. I refer to the fact that it is not returning the maximum. It returns the iterator value that leads to the maximum. A function that doesn't return a maximum

Re: Python handles globals badly.

2014-12-04 Thread Steven D'Aprano
jtan wrote: How can Skybuck use so much globals. Wouldn't that introduce a lot of thread safety problems? Of course it would. But I expect that Skybuck probably doesn't even know what threads are. Or if he does, he probably doesn't believe that they should be used. Thread safety is just the

Re: Python docs disappointing

2014-12-04 Thread Steven D'Aprano
Albert van der Horst wrote: That doesn't help. I'm a very experienced programmer and work in routinely a dozen languages. Sometimes I do python. I want to do numeric work. I remember the name numpy. It is important, everybody knows it, it is all over the place. So I want to find its docs, or

Re: How is max supposed to work, especially key.

2014-12-04 Thread Steven D'Aprano
Jussi Piitulainen wrote: Would you also want sorted called something else when used with a key? Because it doesn't produce a sorted list of the keys either: data = (short, long, average) sorted(data, key=len) ['long', 'short', 'average'] max(data, key=len) 'average' I

Re: How is max supposed to work, especially key.

2014-12-04 Thread Steven D'Aprano
Albert van der Horst wrote: I agree that it is a useful function and that it is doing the right thing. What is wrong is the name. I refer to the fact that it is not returning the maximum. It returns the iterator value that leads to the maximum. That is incorrect. It returns the maximum

Re: Python handles globals badly.

2014-12-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: A lot of programs don't use threads, and therefore cannot have thread safety problems - or, looking at it the other way, do not care about thread safetiness. It's like having Neil Armstrong wear water wings to make sure he won't drown in the Sea of

Re: How is max supposed to work, especially key.

2014-12-04 Thread Jussi Piitulainen
Steven D'Aprano writes: Jussi Piitulainen wrote: Would you also want sorted called something else when used with a key? Because it doesn't produce a sorted list of the keys either: data = (short, long, average) sorted(data, key=len) ['long', 'short', 'average']

A question about setup.py

2014-12-04 Thread David Aldrich
Hi I'm trying to install the path.py package under Python 2.7 on Windows. I installed it using: easy_install path.py That worked but it didn't install path.py which is needed by my PTVS IDE for code completion (Intellisense). I then tried downloading path.py-7.0.zip. I unzipped it and ran:

Re: Most gratuitous comments

2014-12-04 Thread Jean-Michel Pichavant
- Original Message - From: sohcahto...@gmail.com I was trying to illustrate the point that some professors would demand you write code like this... # increment the line count lineCount += 1 # Check if line count is over 10 if lineCount 10 # Tell the user there are too many

Re: How is max supposed to work, especially key.

2014-12-04 Thread random832
On Thu, Dec 4, 2014, at 05:09, Albert van der Horst wrote: So in that case max doesn't return the maximum (True), but instead something else. If you want to find the largest item in a list of of strings, sorted case-insensitively, you might use str.lower or locale.strxfrm as the key function.

Re: Most gratuitous comments

2014-12-04 Thread sjmsoft
Many years ago I, too, had a couple of CS profs who forced us to include too many (usually innocuous) comments in our Fortran and PL/1 code. Perhaps they were trying to counter the natural programmer tendency of not commenting at all? Forty years of programming later (yikes!), I try to use

time.monotonic() roll over

2014-12-04 Thread ast
Hello, Does any body know when time.monotonic() rolls over ? On python doc https://docs.python.org/3/library/time.html it is said every 49.7 days on Windows versions older than Vista. For more recent Windows, it is sais that monotonic() is system-wide but they dont say anything about roll

Re: PyEval_GetLocals and unreferenced variables

2014-12-04 Thread Ian Kelly
On Wed, Dec 3, 2014 at 5:28 AM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Kasper Peeters wrote: That may have been the design plan, but in Python 2.7.6, I definitely am able to inject locals via PyEval_GetLocals() and have them be visible both from the C and Python side; What seems

Re: How is max supposed to work, especially key.

2014-12-04 Thread Terry Reedy
On 12/4/2014 5:35 AM, Albert van der Horst wrote: I agree that it is a useful function and that it is doing the right thing. What is wrong is the name. I refer to the fact that it is not returning the maximum. It returns the iterator value that leads to the maximum. A function that doesn't

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
ast nom...@invalid.com: Does any body know when time.monotonic() rolls over ? Never, according to the documentation you linked. Admittedly, the documentation confuses the reader by chatting about some irrelevant internal Windows details. Also, the tone of the documentation raises a suspicion

Re: Python handles globals badly.

2014-12-04 Thread jtan
I wish him all the luck while having sleep deprivation trying to solve production issues :) On Thu, Dec 4, 2014 at 7:35 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: jtan wrote: How can Skybuck use so much globals. Wouldn't that introduce a lot of thread safety problems?

Re: time.monotonic() roll over

2014-12-04 Thread Ian Kelly
On Dec 4, 2014 8:56 AM, Marko Rauhamaa ma...@pacujo.net wrote: ast nom...@invalid.com: Does any body know when time.monotonic() rolls over ? Never, according to the documentation you linked. Admittedly, the documentation confuses the reader by chatting about some irrelevant internal

Re: time.monotonic() roll over

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 3:05 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Dec 4, 2014 8:56 AM, Marko Rauhamaa ma...@pacujo.net wrote: ast nom...@invalid.com: Does any body know when time.monotonic() rolls over ? Never, according to the documentation you linked. Admittedly, the

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: The implication is that if you go more than 49 days without calling the function on old Windows systems, rollovers could be missed, which is good to know about. The implication is all but clear, but that was my suspicion. It would be so bad that the

Re: time.monotonic() roll over

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 3:21 AM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: The implication is that if you go more than 49 days without calling the function on old Windows systems, rollovers could be missed, which is good to know about. The implication is all but

Re: Is Python installer/un-installer buggy on Windows?

2014-12-04 Thread Aseem Bansal
Yeah, the problem seems to be with registry as every solution seems to be fiddling with registry. I know that reinstalling OS is a really bad idea. But I have tried to find a way to solve this for months now. I have started a bounty on superuser also for the same in the question Python IDLE

Re: time.monotonic() roll over

2014-12-04 Thread random832
On Thu, Dec 4, 2014, at 10:50, Marko Rauhamaa wrote: That is, the internal integer wrap is not guarded against between the calls to time.monotonic(), maybe. Looking at the code, it looks like it does guard against the rollover, though if you let your program run for 49.7 days _without_ calling

Do you like the current design of python.org?

2014-12-04 Thread Peter Otten
Did you ever hit the Socialize button? Are you eager to see the latest tweets when you are reading a PEP? Do you run away screaming from a page where nothing moves without you hitting a button? Do you appreciate the choice between ten or so links to the documentation? You can probably guess my

Re: Most gratuitous comments

2014-12-04 Thread Rob Gaddi
On 04 Dec 2014 09:48:49 GMT alb...@spenarnc.xs4all.nl (Albert van der Horst) wrote: In article 546d7505$0$12899$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano st...@pearwood.info wrote: And the award for the most gratuitous comments before an import goes to one of my (former) workmates,

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Wolfgang Maier
On 12/03/2014 12:02 PM, Chris Angelico wrote: When importing a module from a subpackage, it's sometimes convenient to refer to it throughout the code with a one-part name rather than two. I'm going to use 'os.path' for the examples, but my actual use-case is a custom package where the package

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Jean-Michel Pichavant
- Original Message - From: Chris Angelico ros...@gmail.com To: python-list@python.org Sent: Wednesday, 3 December, 2014 12:02:17 PM Subject: Style question: Importing modules from packages - 'from' vs 'as' When importing a module from a subpackage, it's sometimes convenient to

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Ethan Furman
On 12/04/2014 09:36 AM, Jean-Michel Pichavant wrote: I know you specifically stated you didn't want to do this but import os os.path.isfile() is the best option imo, especially from the reader point of view (Namespaces are one honking great idea). But, Flat is better than nested

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Ethan Furman
On 12/03/2014 03:02 AM, Chris Angelico wrote: Throughout the code, I want to refer to path.split(), path.isfile(), etc, without the os. in front of them. I could do either of these: import os.path as path from os import path Which one would you recommend? Does it depend on context? I

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 4:36 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: I know you specifically stated you didn't want to do this but import os os.path.isfile() is the best option imo, especially from the reader point of view (Namespaces are one honking great idea). With

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: It's not a Python issue. Python can't do anything more than ask the system, and if the system's value rolls over several times a year, Python can't magically cure that. The information has already been lost. Sure it could by having an invisible background

ORM opinion

2014-12-04 Thread Joseph L. Casale
Begrudgingly, I need to migrate away from SQLAlchemy onto a package that has fast imports and very fast model build times. I have a less than ideal application that uses Python as a plugin interpreter which is not performant in this use case where its being invoked freshly several times per

Re: Do you like the current design of python.org?

2014-12-04 Thread Ethan Furman
On 12/04/2014 09:09 AM, Peter Otten wrote: Did you ever hit the Socialize button? Are you eager to see the latest tweets when you are reading a PEP? Do you run away screaming from a page where nothing moves without you hitting a button? Do you appreciate the choice between ten or so links

Re: time.monotonic() roll over

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 5:09 AM, Marko Rauhamaa ma...@pacujo.net wrote: Sure it could by having an invisible background thread occasionally call time.monotonic(). It could even be done on the side without a thread. No, it can't be solved by anything in that process, because... * the program

Re: ORM opinion

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 5:14 AM, Joseph L. Casale jcas...@activenetwerx.com wrote: Begrudgingly, I need to migrate away from SQLAlchemy onto a package that has fast imports and very fast model build times. I have a less than ideal application that uses Python as a plugin interpreter which is

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: ... what you said There's no way to guarantee to keep calling the function. You have to depend on upstream. The caveats I listed are real concerns for the modern-day programmer. However, they are of a different nature than the complaint against

Not Able to Log in on XNAT server through PyXNAT

2014-12-04 Thread suyash . d . b
Hello All, I have installed pyxnat on my mac. With pyxnat i am trying to access XNAT server in our university. As mentioned on the tutorial i tried both ways, neither is working. Following error is displayed: central=Interface(server='http://hd-hni-xnat.cac.cornell.edu:8443/xnat') User: sdb99

Re: Can you use self in __str__

2014-12-04 Thread Jean-Michel Pichavant
- Original Message - From: Seymore4Head Seymore4Head@Hotmail.invalid To: python-list@python.org Sent: Friday, 28 November, 2014 4:31:50 AM Subject: Re: Can you use self in __str__ On Thu, 27 Nov 2014 21:49:29 -0500, Dave Angel da...@davea.name wrote: class Hand: def

Re: time.monotonic() roll over

2014-12-04 Thread Ian Kelly
On Thu, Dec 4, 2014 at 11:09 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: It's not a Python issue. Python can't do anything more than ask the system, and if the system's value rolls over several times a year, Python can't magically cure that. The information

Re: Do you like the current design of python.org?

2014-12-04 Thread Akira Li
Peter Otten __pete...@web.de writes: Did you ever hit the Socialize button? Are you eager to see the latest tweets when you are reading a PEP? Do you run away screaming from a page where nothing moves without you hitting a button? Do you appreciate the choice between ten or so links to the

Re: Can you use self in __str__

2014-12-04 Thread Seymore4Head
On Thu, 4 Dec 2014 20:22:11 +0100 (CET), Jean-Michel Pichavant jeanmic...@sequans.com wrote: - Original Message - From: Seymore4Head Seymore4Head@Hotmail.invalid To: python-list@python.org Sent: Friday, 28 November, 2014 4:31:50 AM Subject: Re: Can you use self in __str__ On Thu,

Re: Python handles globals badly.

2014-12-04 Thread alister
On Thu, 04 Dec 2014 00:02:25 +0100, Skybuck Flying wrote: Mark Lawrence wrote in message news:mailman.16534.1417610132.18130.python-l...@python.org... On 03/12/2014 02:27, Skybuck Flying wrote: Excuse is: bad programming style. I don't need snot telling me how to program after 20 years

Re: time.monotonic() roll over

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 5:44 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: ... what you said There's no way to guarantee to keep calling the function. You have to depend on upstream. The caveats I listed are real concerns for the modern-day programmer. However,

Re: Is Python installer/un-installer buggy on Windows?

2014-12-04 Thread Terry Reedy
On 12/4/2014 11:46 AM, Aseem Bansal wrote: Yeah, the problem seems to be with registry as every solution seems to be fiddling with registry. One can edit the registry directly with regedit. If you try it, follow the instruction to first make a backup. Look for a regedit tutorial on the

About Modifying Globals

2014-12-04 Thread LJ
Hi All, I have a quick question regarding the modification of global variables within functions. To illustrate, consider the following toy example: a={1: set()} b=9 def gt(l): a[1] = a[1] | set([l]) When calling this last function and checking the a dictionary, I get: gt(5) a {1:

Re: About Modifying Globals

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 7:09 AM, LJ luisjoseno...@gmail.com wrote: def gt(l): a[1] = a[1] | set([l]) def gt2(l): b=b+l These two may both look like they're assigning something, but one of them is assigning directly to the name b, while the other assigns to a subscripted element of a.

Re: About Modifying Globals

2014-12-04 Thread Ian Kelly
On Thu, Dec 4, 2014 at 1:09 PM, LJ luisjoseno...@gmail.com wrote: Hi All, I have a quick question regarding the modification of global variables within functions. To illustrate, consider the following toy example: a={1: set()} b=9 def gt(l): a[1] = a[1] | set([l]) When calling this

Re: time.monotonic() roll over

2014-12-04 Thread Akira Li
Ian Kelly ian.g.ke...@gmail.com writes: On Thu, Dec 4, 2014 at 11:09 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: It's not a Python issue. Python can't do anything more than ask the system, and if the system's value rolls over several times a year, Python

Re: time.monotonic() roll over

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 7:24 AM, Akira Li 4kir4...@gmail.com wrote: This seems like a lot of effort to unreliably design around a problem that will matter to only a tiny fraction of users. - people's computers are mostly on batteries (laptops, tablets, smartphones) -- suspended from power

Urgent Need Sr. SDET (System) in Redmond, WA

2014-12-04 Thread amrish . babu2
Greetings My name is Amrish and I'm an IT Recruiter at Talented IT. Our records show that you are an experienced IT professional with experience relevant to one of my current contract openings. The job is located in Redmond, WA with one of our Fortune 100 client. They are looking for SR.

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: Even when I do suspend a VM, I often terminate applications in it, and just use suspension to save having to boot the OS every time. One interesting detail is DHCP leases. When it is resumed from suspension, a linux computer thinks it still has the old IP

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Wolfgang Maier
On 04.12.2014 19:05, Chris Angelico wrote: With os.path it definitely is. With the actual code in question, it's a Python 2.7 project that mostly uses relative imports - inside package.module1 is import module2 etc - and I was writing an external script that calls on one of the modules. What

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 7:56 AM, Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de wrote: On 04.12.2014 19:05, Chris Angelico wrote: With os.path it definitely is. With the actual code in question, it's a Python 2.7 project that mostly uses relative imports - inside package.module1 is

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Wolfgang Maier
On 04.12.2014 22:30, Chris Angelico wrote: On Fri, Dec 5, 2014 at 7:56 AM, Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de wrote: On 04.12.2014 19:05, Chris Angelico wrote: With os.path it definitely is. With the actual code in question, it's a Python 2.7 project that mostly uses

Re: time.monotonic() roll over

2014-12-04 Thread Ian Kelly
On Thu, Dec 4, 2014 at 1:24 PM, Akira Li 4kir4...@gmail.com wrote: Ian Kelly ian.g.ke...@gmail.com writes: This seems like a lot of effort to unreliably design around a problem that will matter to only a tiny fraction of users. - people's computers are mostly on batteries (laptops,

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 9:10 AM, Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de wrote: which I read as there has been a stepwise transition between 2.5 and 2.7 so that 2.7 now behaves like Python 3 even without the __future__ statement. OTOH, I believe you, of course, if you're saying

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: It's not clear to me whether those cases are relevant to the rollover concern anyway. I wouldn't be shocked if the GetTickCount() function simply stopped increasing while the system is suspended, since after all it's not ticking during that time. So, what's

RE: ORM opinion

2014-12-04 Thread Joseph L. Casale
First recommendation: Less layers. Instead of SQLAlchemy, just import sqlite3 and use it directly. You should be able to switch out import sqlite as db for import psycopg2 as db or any other Python DB API module, and still have most/all of the benefit of the extra layer, without any extra

Re: ORM opinion

2014-12-04 Thread Mark Lawrence
On 04/12/2014 23:20, Joseph L. Casale wrote: First recommendation: Less layers. Instead of SQLAlchemy, just import sqlite3 and use it directly. You should be able to switch out import sqlite as db for import psycopg2 as db or any other Python DB API module, and still have most/all of the benefit

Re: Python docs disappointing

2014-12-04 Thread jtan
On Thu, Dec 4, 2014 at 6:27 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: In article mailman.16030.1416502295.18130.python-l...@python.org, Joel Goldstick joel.goldst...@gmail.com wrote: SNIP Plain google is far superior in finding information. And you tell me that writing

Re: ORM opinion

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 10:20 AM, Joseph L. Casale jcas...@activenetwerx.com wrote: I am stuck with the current architecture, but the idea you propose has been thrown around, truth is I am not certain if we are enduring the effort of such a large rewrite that Python is the tool to use (this is a

RE: ORM opinion

2014-12-04 Thread Joseph L. Casale
Anything listed here http://www.pythoncentral.io/sqlalchemy-vs-orms/ you've not heard about? I found peewee easy to use although I've clearly no idea if it suits your needs. There's only one way to find out :) Hi Mark, I found that article before posting and some of the guys here have

Re: ORM opinion

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 10:43 AM, Joseph L. Casale jcas...@activenetwerx.com wrote: I found that article before posting and some of the guys here have already started using peewee. I don't have much time with it yet. So far all I can say is its unfortunate some package authors take such an

Re: About Modifying Globals

2014-12-04 Thread Dave Angel
On 12/04/2014 03:09 PM, LJ wrote: Hi All, I have a quick question regarding the modification of global variables within functions. To illustrate, consider the following toy example: a={1: set()} b=9 def gt(l): a[1] = a[1] | set([l]) When calling this last function and checking the a

Re: Python docs disappointing

2014-12-04 Thread Michael Torrie
On 12/04/2014 03:27 AM, Albert van der Horst wrote: That doesn't help. I'm a very experienced programmer and work in routinely a dozen languages. Sometimes I do python. I want to do numeric work. I remember the name numpy. It is important, everybody knows it, it is all over the place. So I

Re: About Modifying Globals

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 10:54 AM, Dave Angel da...@davea.name wrote: Python doesn't have declarations, so when a function is compiled, the compiler has to infer what names are to be local and what are not. The rule it normally uses is roughly based on whether an assignment occurs somewhere

Re: time.monotonic() roll over

2014-12-04 Thread Steven D'Aprano
Marko Rauhamaa wrote: So, if I call time.sleep(86400) and the program is suspended for 24 hours, should time.sleep() return right after it is resumed or after another 24 hours? If the program is suspended, then no time should pass for that program. Since sleep() is given in terms of a

Re: time.monotonic() roll over

2014-12-04 Thread Nobody
On Thu, 04 Dec 2014 16:25:44 +0100, ast wrote: There is no roll over problem with time.time() since the very first one in planned far in the future, but time.time() can go backward when a date update throught NTP server is done. time.monotonic() is monotonic but roll over often (every 49.7

Re: time.monotonic() roll over

2014-12-04 Thread Dave Angel
On 12/04/2014 07:39 PM, Steven D'Aprano wrote: Marko Rauhamaa wrote: So, if I call time.sleep(86400) and the program is suspended for 24 hours, should time.sleep() return right after it is resumed or after another 24 hours? If the program is suspended, then no time should pass for that

Re: About Modifying Globals

2014-12-04 Thread Steven D'Aprano
LJ wrote: Hi All, I have a quick question regarding the modification of global variables within functions. To illustrate, consider the following toy example: a={1: set()} b=9 def gt(l): a[1] = a[1] | set([l]) The difference between this example and your second one: def gt2(l):

Re: About Modifying Globals

2014-12-04 Thread shiyao.ma
On 12/04, LJ wrote: Hi All, I have a quick question regarding the modification of global variables within functions. To illustrate, consider the following toy example: a={1: set()} b=9 def gt(l): a[1] = a[1] | set([l]) When calling this last function and checking the a dictionary,

Re: time.monotonic() roll over

2014-12-04 Thread Steven D'Aprano
Dave Angel wrote: On 12/04/2014 07:39 PM, Steven D'Aprano wrote: Marko Rauhamaa wrote: So, if I call time.sleep(86400) and the program is suspended for 24 hours, should time.sleep() return right after it is resumed or after another 24 hours? If the program is suspended, then no time

help with processing text file

2014-12-04 Thread C. Ng
Hi, Given the sample text file below (where the gibberish represent the irrelevant portions) : abcddsdfffgfg ggfhghghgfhghgh round 5 xccdcxcfd sdfdffdfbcvcvbbvnghg score = 0.4533 abcddsdfffgfg round 5 level = 0.15 ggfhghghgfhghgh round 10 dfsdfdcdsd sdfdffdfbcvcvbbvnghg score =

Re: help with processing text file

2014-12-04 Thread Gary Herron
On 12/04/2014 08:46 PM, C. Ng wrote: Hi, Given the sample text file below (where the gibberish represent the irrelevant portions) : abcddsdfffgfg ggfhghghgfhghgh round 5 xccdcxcfd sdfdffdfbcvcvbbvnghg score = 0.4533 abcddsdfffgfg round 5 level = 0.15 ggfhghghgfhghgh round 10

Re: Python handles globals badly.

2014-12-04 Thread William Ray Wing
On Dec 4, 2014, at 8:56 PM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Thu, 04 Dec 2014 14:51:14 +0200, Marko Rauhamaa ma...@pacujo.net declaimed the following: Chris Angelico ros...@gmail.com: A lot of programs don't use threads, and therefore cannot have thread safety

Re: time.monotonic() roll over

2014-12-04 Thread Dave Angel
On 12/04/2014 09:54 PM, Steven D'Aprano wrote: Dave Angel wrote: On 12/04/2014 07:39 PM, Steven D'Aprano wrote: Marko Rauhamaa wrote: So, if I call time.sleep(86400) and the program is suspended for 24 hours, should time.sleep() return right after it is resumed or after another 24 hours?

The binding operator, and what gets bound to what (was: About Modifying Globals)

2014-12-04 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: LJ wrote: def gt(l): a[1] = a[1] | set([l]) The difference between this example and your second one: def gt2(l): b=b+l is that the second is a binding operation and the first is not. I disagree; they're both

Re: help with processing text file

2014-12-04 Thread Dave Angel
On 12/04/2014 11:46 PM, C. Ng wrote: Hi, Given the sample text file below (where the gibberish represent the irrelevant portions) : abcddsdfffgfg ggfhghghgfhghgh round 5 xccdcxcfd sdfdffdfbcvcvbbvnghg score = 0.4533 abcddsdfffgfg round 5 level = 0.15 ggfhghghgfhghgh round 10

Re: time.monotonic() roll over

2014-12-04 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Unfortunately a lot of systems get that wrong. E.g. I just ran sleep 30 from my Linux shell, immediately paused it using Ctrl-Z, waited a couple of minutes, and used fg to continue. It returned immediately. Why is this behaviour wrong? I

dict turn to list at runtime unexpected!!!

2014-12-04 Thread telnetgmike
Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks, addrnum_dict = {'a':1,'b':2} def orderaddrtimes(): global addrnum_dict print type(addrnum_dict) addrnum_dict = sorted(addrnum_dict.iteritems(), key=lambda

dict turn to list unexpected at runtime???

2014-12-04 Thread telnetgm...@gmail.com
Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks, addrnum_dict = {'a':1,'b':2} def orderaddrtimes(): global addrnum_dict print type(addrnum_dict) addrnum_dict = sorted(addrnum_dict.iteritems(), key=lambda

Re: dict turn to list unexpected at runtime???

2014-12-04 Thread Cameron Simpson
On 05Dec2014 15:01, telnetgm...@gmail.com telnetgm...@gmail.com wrote: Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks, addrnum_dict = {'a':1,'b':2} def orderaddrtimes(): global addrnum_dict print type(addrnum_dict)

Re: dict turn to list unexpected at runtime???

2014-12-04 Thread Dan Sommers
On Fri, 05 Dec 2014 15:01:51 +0800, telnetgm...@gmail.com wrote: Why the following code gives me errors??? And why the print statement run 2 times? ... addrnum_dict = {'a':1,'b':2} def orderaddrtimes(): global addrnum_dict print type(addrnum_dict) addrnum_dict =

Re: Do you like the current design of python.org?

2014-12-04 Thread dieter
Peter Otten __pete...@web.de writes: Did you ever hit the Socialize button? No. Are you eager to see the latest tweets when you are reading a PEP? No. Do you run away screaming from a page where nothing moves without you hitting a button? No, I like pages where I am in control. Do

Re: dict turn to list unexpected at runtime???

2014-12-04 Thread telnetgmike
On Friday, December 5, 2014 3:20:14 PM UTC+8, Cameron Simpson wrote: On 05Dec2014 15:01, telnetgm...@gmail.com telnetgm...@gmail.com wrote: Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks, addrnum_dict = {'a':1,'b':2}

Re: dict turn to list at runtime unexpected!!!

2014-12-04 Thread telnetgmike
On Friday, December 5, 2014 2:56:50 PM UTC+8, telne...@gmail.com wrote: Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks, addrnum_dict = {'a':1,'b':2} def orderaddrtimes(): global addrnum_dict print

  1   2   >