locating data_files

2011-03-14 Thread Darren Hart
I'm using dist_utils to install some data along with my module, but I haven't been able to sort out where that data gets installed from within the module. The user can specify --prefix=/usr/local for instance, how can I know where to look for the data files? My setup.py installs a glade file and s

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Stefan Behnel
Steven D'Aprano, 13.03.2011 13:59: The removal of cmp from the sort method of lists is probably the most disliked change in Python 3. On the python-dev mailing list at the moment, Guido is considering whether or not it was a mistake. If anyone has any use-cases for sorting with a comparison func

logging and PyQt4

2011-03-14 Thread Adrian Casey
I have a multi-threaded PyQt4 application which has both a GUI and command- line interface. I am using Qt4's threading because from what I have read, it is more efficient than the native python threading module. Also, given most users will probably use the GUI, it seemed to make sense. I wan

Re: Just finished reading of "What’s New In Python 3.0"

2011-03-14 Thread D'Arcy J.M. Cain
On Fri, 11 Mar 2011 06:30:35 -0800 Westley Martínez wrote: [repeated posing elided] > n00m: GET A BLOG. Is it so hard to simply add him to your killfile and move on? Those of us who have already done so get to see his postings anyway if people are going to reply and repeat his trolls. -- D'Ar

Re: Don't Want Visitor To See Nuttin'

2011-03-14 Thread Ian Kelly
On Fri, Mar 11, 2011 at 10:40 AM, Victor Subervi wrote: > Um...just for the record, these guys have ben featured on the FRONT PAGES > OF: > [SNIPPED] I don't care if the company was founded by the second coming of Jesus Christ; I just call it like I see it. > They're ligit :) Oh, I have no doub

Re: IDLE doesn't start

2011-03-14 Thread Ceonn Bobst
Hi Gennadiy,   Here is the output I get: C:\Documents and Settings\Ceonn>echo %TCL_LIBRARY% C:\IBMTOOLS\Python22\tcl\tcl8.4   C:\Documents and Settings\Ceonn>echo %TK_LIBRARY% C:\IBMTOOLS\Python22\tcl\tk8.4   C:\Documents and Settings\Ceonn>echo %PYTHONPATH% C:\IBMTOOLS\utils\support;C:\IBMTOOLS\ut

Re: IDLE doesn't start

2011-03-14 Thread Gennadiy Zlobin
Hi Ceonn, Well it is obvious that these environment variables are pointing to your old Python 2.2 installation that is located in the C:\IBMTOOLS\Python22\tcl\tcl8.4 First, try to delete these variables and find out are they necessary to run IDLE. Type in console set TCL_LIBRARY = set TK_LIBRARY

Get Path of current Script

2011-03-14 Thread Alexander Schatten
Hi, could someone help me with a small problem? I wrote a Python script that does some RegEx... transformations. Now, this script loads some configuration data from a file located in the same directory: open ('config.txt', 'r'). However, this only works when I execute the script being in the dir

Re: Get Path of current Script

2011-03-14 Thread Gennadiy Zlobin
To get the directory of the current running script try: import os.path path = os.path.dirname(__file__) - Gennadiy On Mon, Mar 14, 2011 at 3:25 PM, Alexander Schatten wrote: > Hi, > > could someone help me with a small problem? I wrote a Python script > that does some RegEx... transformatio

Re: Get Path of current Script

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote: > is there an easy way (API) to get the directory of the currently running > script? import __main__ import os print os.path.dirname(__main__.__file__) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Get Path of current Script

2011-03-14 Thread Alain Ketterlin
Alexander Schatten writes: > could someone help me with a small problem? I wrote a Python script > that does some RegEx... transformations. Now, this script loads some > configuration data from a file located in the same directory: sys.path[0] is the path to the directory containing the script t

Re: Get Path of current Script

2011-03-14 Thread Duncan Booth
Steven D'Aprano wrote: > On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote: > >> is there an easy way (API) to get the directory of the currently running >> script? > > import __main__ > import os > print os.path.dirname(__main__.__file__) > That code is pretty version specific: I

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread Jean-Michel Pichavant
bukzor wrote: We've been doing a fair amount of Python scripting, and now we have a directory with almost a hundred loosely related scripts. It's obviously time to organize this, but there's a problem. These scripts import freely from each other and although code reuse is generally a good thing

Re: Get Path of current Script

2011-03-14 Thread Gennadiy Zlobin
I tested my solution on python 2.5, 2.8 and 3.1 and everything seems working well - Gennadiy On Mon, Mar 14, 2011 at 4:29 PM, Duncan Booth wrote: > Steven D'Aprano wrote: > > > On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote: > > > >> is there an easy way (API) to get the direc

Re: Compile time evaluation of dictionaries

2011-03-14 Thread Jean-Michel Pichavant
Gerald Britton wrote: Today I noticed that an expression like this: "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two": "can be as bad as one"} could be evaluated at compile time, but is not: dis(compile( ... '"one:%(one)s two:%(two)s" % {"one": "is the lonelies

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: The removal of cmp from the sort method of lists is probably the most disliked change in Python 3. On the python-dev mailing list at the moment, Guido is considering whether or not it was a mistake. If anyone has any use-cases for sorting with a comparison function that

Re: Get Path of current Script

2011-03-14 Thread eryksun ()
On Monday, March 14, 2011 5:53:25 AM UTC-4, Alain Ketterlin wrote: > sys.path[0] is the path to the directory containing the script that the > interpreter started with. How about os.path.dirname(os.path.realpath(sys.argv[0]))? I think realpath is required in case someone runs it from a symlink.

Re: Get Path of current Script

2011-03-14 Thread Alexander Schatten
Thanks for the comments so far. This sounds to be more complicated in detail than I expected. I wonder how all the other Python programs and scripts are doing that... -- http://mail.python.org/mailman/listinfo/python-list

writing command-line options into file

2011-03-14 Thread hiral
For following example, how to write command-line option OR metavar into file... parser.add_option("-opt1", metavar="MY_OPTION1", default=123) parser.add_option("-opt2", metavar="YOUR_OPTION2" ,default= "abc") parser.add_option('-opt3", metavar="FLAG", default=True) do we have any facility to writ

Re: Get Path of current Script

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 10:29:42 +, Duncan Booth wrote: > Steven D'Aprano wrote: > >> On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote: >> >>> is there an easy way (API) to get the directory of the currently >>> running script? >> >> import __main__ >> import os >> print os.path.di

Re: writing command-line options into file

2011-03-14 Thread Brian Blais
On Mar 14, 2011, at 8:13 AM, hiral wrote: > For following example, how to write command-line option OR metavar > into file... > > parser.add_option("-opt1", metavar="MY_OPTION1", default=123) > parser.add_option("-opt2", metavar="YOUR_OPTION2" ,default= "abc") > parser.add_option('-opt3", metava

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 12:10:27 +0100, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> The removal of cmp from the sort method of lists is probably the most >> disliked change in Python 3. On the python-dev mailing list at the >> moment, Guido is considering whether or not it was a mistake.

Re: Get Path of current Script

2011-03-14 Thread Ulrich Eckhardt
Alexander Schatten wrote: > Thanks for the comments so far. This sounds to be more complicated in > detail than I expected. I wonder how all the other Python programs and > scripts are doing that... Well, it's not like that's impossible to find out, the source is out there! :) Anyhow, you basical

Re: writing command-line options into file

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 05:13:37 -0700, hiral wrote: > For following example, how to write command-line option OR metavar into > file... > > parser.add_option("-opt1", metavar="MY_OPTION1", default=123) > parser.add_option("-opt2", metavar="YOUR_OPTION2" ,default= "abc") > parser.add_option('-opt3",

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 14 Mar 2011 12:10:27 +0100, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: The removal of cmp from the sort method of lists is probably the most disliked change in Python 3. On the python-dev mailing list at the moment, Guido is considering whether o

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread eryksun ()
On Monday, March 14, 2011 2:38:50 AM UTC-4, bukzor wrote: > I've written this many times. It has issues. In fact, I've created a > library for this purpose, for the following reasons. If you're linking to a common file, couldn't you just add in the base folder there? I don't think it's a bad pra

Compile time evaluation of dictionaries

2011-03-14 Thread Gerald Britton
Jean-Michel Pichavan wrote: >> Today I noticed that an expression like this: >> >> "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two": >> "can be as bad as one"} >> >> could be evaluated at compile time, but is not: >> >> [snip] >> Any idea why Python works this way? I see that,

RE: Inserting record into postgresql database

2011-03-14 Thread Meszaros, Stacy
After much experimentation, I found the following solution: commandString = "\\xA500046898000AC73D228B0B018040003BF9" insert = "INSERT INTO profile_commands(command_id, profile_id, execution_order, command, command_type) VALUES(%s, %s, 0, %s, 1); "

Re: Get Path of current Script

2011-03-14 Thread Grant Edwards
On 2011-03-14, Alexander Schatten wrote: > Thanks for the comments so far. This sounds to be more complicated in > detail than I expected. I wonder how all the other Python programs and > scripts are doing that... The usual answer is "they don't". At least in the Unix world, finding out the pat

function annotations in open source projects

2011-03-14 Thread Filip Gruszczyński
Do you know any open source python3 projects that use function annotations? I would like to see some real use, so maybe I find them useful to use in my own project. -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list

Re: function annotations in open source projects

2011-03-14 Thread Daniel Urban
> Do you know any open source python3 projects that use function > annotations? I would like to see some real use, so maybe I find them > useful to use in my own project. threecheck uses them for type checking: http://pypi.python.org/pypi/threecheck Daniel -- http://mail.python.org/mailman/list

cProfile taking up too much memory?

2011-03-14 Thread Dysgraphic Programmer
I am attempting to profile my project in python, but I am running out of memory. My project itself is fairly memory intensive, but even half-size runs are dieing with "MemoryError" when run under cProfile. Doing smaller runs is not a good option, because we suspect that the run time is scaling su

function annotations in open source projects

2011-03-14 Thread geremy condra
I use them in evpy to automatically wrap c functions with a decorated, annotated function. The decorator code is also up on aspn, just search for "c function decorator" and it should come up. I did a similar thing with java a few years ago as well. Geremy Condra -- http://mail.python.org/mailman/

Re: function annotations in open source projects

2011-03-14 Thread Patty
- Original Message - From: geremy condra To: Filip Gruszczynski Cc: python-list@python.org Sent: Monday, March 14, 2011 10:37 AM Subject: function annotations in open source projects I use them in evpy to automatically wrap c functions with a decorated, annotated funct

Re: Get Path of current Script

2011-03-14 Thread Alexander Schatten
They don't. Hm, ok, I am always for best practices. If there is a better way to do it I am open for suggestions ;-) How would the best practice be to load configuration data from a file. I mean, this is something very common: you write a program or a script and want to load some configuration data

Re: Get Path of current Script

2011-03-14 Thread Jason Swails
On Mon, Mar 14, 2011 at 11:25 AM, Alexander Schatten wrote: > They don't. Hm, ok, I am always for best practices. If there is a > better way to do it I am open for suggestions ;-) How would the best > practice be to load configuration data from a file. > > I mean, this is something very common: yo

Re: Get Path of current Script

2011-03-14 Thread Santoso Wijaya
You can make it a required input with default values to sys.argv when you start the program. Parse the content of the file given by sys.argv, then cache it in some global module or pass it around as arguments... That said, if you still want to go the route of knowing where the current directory of

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Paul Rubin
Steven D'Aprano writes: > If anyone has any use-cases for sorting with a comparison function that > either can't be written using a key function, or that perform really > badly when done so, this would be a good time to speak up. We've had this discussion a couple times before. I remember an e

Re: How should I handle socket receiving?

2011-03-14 Thread Hans
On Mar 12, 10:13 pm, Tim Roberts wrote: > Hans wrote: > > >I'm thinking to write a code which to: > >1. establish tons of udp/tcp connections to a server > > What does "tons" mean?  Tens?  Hundreds? > > >my question is how should I handle receiving traffic from each > >connection respectively? >

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread eryksun ()
On Monday, March 14, 2011 9:45:51 AM UTC-4, eryksun () wrote: > > If you're linking to a common file, couldn't you just add in > the base folder there? > > ... > > # script.py > import _path # _path.py is a symbolic link > > # _path.py: > base = '/absolute/path/to/base' > import site > site.

Re: Get Path of current Script

2011-03-14 Thread John Gordon
In <5520ec67-bc4e-4f81-b27a-cf1f8c8de...@v11g2000prb.googlegroups.com> Alexander Schatten writes: > I mean, this is something very common: you write a program or a script > and want to load some configuration data. There are several good ways to do it: + Assume the config file is in the curren

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread bruce bushby
I'm probably going off on a tangent here..but has anybody seen any efforts to allow python to "import modules via a socket" ...rather then just a "dir path" ? On Mon, Mar 14, 2011 at 7:56 PM, eryksun () wrote: > On Monday, March 14, 2011 9:45:51 AM UTC-4, eryksun () wrote: > > > > If you

Re: How should I handle socket receiving?

2011-03-14 Thread MRAB
On 14/03/2011 19:47, Hans wrote: On Mar 12, 10:13 pm, Tim Roberts wrote: Hans wrote: I'm thinking to write a code which to: 1. establish tons of udp/tcp connections to a server What does "tons" mean? Tens? Hundreds? my question is how should I handle receiving traffic from each connect

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread eryksun ()
On Monday, March 14, 2011 3:56:15 PM UTC-4, eryksun () wrote: > To be clear on the file structure, I'm picturing that 'base' is a > path on each user's shell path where all the accessible scripts > are linked, and that this is also the package directory. Wait, this won't work when the script is

Re: Get Path of current Script

2011-03-14 Thread Grant Edwards
On 2011-03-14, Alexander Schatten wrote: > They don't. Hm, ok, I am always for best practices. If there is a > better way to do it I am open for suggestions ;-) How would the best > practice be to load configuration data from a file. > > I mean, this is something very common: you write a program

Dynamic loading of module with explicit file path

2011-03-14 Thread Tim Johnson
FYI: Using python 2.6 on ubuntu 10, backward compatibilty to 2~ needed. Self-employed programmer 24 years. Python 9 years, part-time. I'm not addressing an existing problem, but looking for ideas that might help me to do some upgrading (if needed). I'd like to solicit comments on the following m

Re: Compile time evaluation of dictionaries

2011-03-14 Thread Terry Reedy
On 3/14/2011 10:21 AM, Gerald Britton wrote: Any idea why Python works this way? I see that, in 3.2, an optimization was done for sets (See "Optimizations" at http://docs.python.org/py3k/whatsnew/3.2.html) though I do not see anything similar for dictionaries. 1/ because no one would ever s

Re: Get Path of current Script

2011-03-14 Thread eryksun ()
On Monday, March 14, 2011 5:17:49 PM UTC-4, Grant Edwards wrote: > > Indeed that is very common, and there's been a "standard" way to do > that since before dirt. > > The standard on Unix is to look in the following places in (this > order), and use the first one you find: On Windows it's typical

Re: Changing class name causes process to 'hang'

2011-03-14 Thread Vinay Sajip
On Mar 13, 11:48 pm, Tim Johnson wrote: >  :) I like my logging module, I believe it may have 'anticipated' >  the 2.7 module. And I can't count on my client's servers to host >  2.7 for a while. Perhaps you already know this, but you don't have to use Python 2.7 to use the standard logging packa

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Nobody
On Mon, 14 Mar 2011 12:39:35 -0700, Paul Rubin wrote: > Finally I concocted an "infinite" example which we agreed is artificial: > you are given a list of generators denoting real numbers, for example > pi generates the infinite sequence 3,1,4,1,5,9... while e generates > 2,7,1,8,... You can sor

Re: Problems of Symbol Congestion in Computer Languages

2011-03-14 Thread Jason Swails
> The metric system is defined to such a ridiculous level of precision > because we have the technology, and the need, to measure things to that > level of precision. Standards need to be based on something which is > universal and unchanging. > Other systems of measure (for instance, atomic units

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread Terry Reedy
On 3/14/2011 4:31 PM, bruce bushby wrote: but has anybody seen any efforts to allow python to "import modules via a socket" I do not remember any such thing. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 23:37:06 +, Nobody wrote: > On Mon, 14 Mar 2011 12:39:35 -0700, Paul Rubin wrote: > >> Finally I concocted an "infinite" example which we agreed is >> artificial: you are given a list of generators denoting real numbers, >> for example pi generates the infinite sequence 3,

python script to find Installed programs in Uninstall folder in registry

2011-03-14 Thread KishoreRP
I am working on creating a python script to find Installed programs in Uninstall folder in registry, the script works perfectly fine on 32 bit machines but errors out with a wmi error on 64 bit machines. Am not able to get hold of a wmi module for python on 64 bit machines.Is there one at all? Plea

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread bukzor
On Mar 14, 1:30 pm, "eryksun ()" wrote: > On Monday, March 14, 2011 3:56:15 PM UTC-4, eryksun () wrote: > > To be clear on the file structure, I'm picturing that 'base' is a > > path on each user's shell path where all the accessible scripts > > are linked, and that this is also the package direct

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Paul Rubin
Nobody writes: >> 2,7,1,8,... You can sort these with cmp but not with key. > > Is there some restriction on the return type of the key= function? If not, > you can define a class with appropriate comparison methods and have key= > return instances of that class. Sorry, yeah, of course you can d

A Question on URLLIB

2011-03-14 Thread joy99
Dear Group, I am trying to construct a web based crawler with Python and for that I am using the URLLIB module, and by doing import urllib and then trying with urllib.urlopen("url). Am I going fine? If some one can kindly highlight if I am doing any mistake. Best Regards, Subhabrata Banerjee. --

Re: A Question on URLLIB

2011-03-14 Thread Santoso Wijaya
Well, have you run into any problem, expected or otherwise, yet? ~/santa On Mon, Mar 14, 2011 at 11:10 PM, joy99 wrote: > Dear Group, > I am trying to construct a web based crawler with Python and for that > I am using the URLLIB module, and by doing > import urllib and then trying with urlli

Re: python script to find Installed programs in Uninstall folder in registry

2011-03-14 Thread Tim Roberts
KishoreRP wrote: > >I am working on creating a python script to find Installed programs in >Uninstall folder in registry, the script works perfectly fine on 32 >bit machines but errors out with a wmi error on 64 bit machines. Am >not able to get hold of a wmi module for python on 64 bit machines.

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Ian Kelly
On Mon, Mar 14, 2011 at 1:39 PM, Paul Rubin wrote: > Finally I concocted an "infinite" example which we agreed is artificial: > you are given a list of generators denoting real numbers, for example > pi generates the infinite sequence 3,1,4,1,5,9... while e generates > 2,7,1,8,...  You can sort th