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

2011-03-16 Thread bukzor
On Mar 15, 12:24 pm, booklover bnsm...@gmail.com wrote: Is everyone really happy with this? I'm not happy with this. In fact, if Python 3.3 came out with a solution for this problem, it would be a major motivation for me to migrate. I don't think that it would take much to fix either.

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

2011-03-16 Thread bukzor
On Mar 16, 7:42 am, booklover bnsm...@gmail.com wrote: I'm going to try to get our solution open-sourced, then I'll get your feedback on it. Thanks bukzor! I think that it would be very helpful to have a library like this available. In the longer term, what do people think about

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

2011-03-16 Thread bukzor
On Mar 15, 11:57 pm, eryksun () eryk...@gmail.com wrote: On Tuesday, March 15, 2011 12:44:48 AM UTC-4, bukzor wrote: Currently it requires either: 1) no symlinks to scripts or 2) installation of the pathtools to site-packages. An executable with a unique name on the system PATH could

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

2011-03-16 Thread bukzor
On Mar 16, 3:29 pm, bukzor workithar...@gmail.com wrote: On Mar 15, 11:57 pm, eryksun () eryk...@gmail.com wrote: On Tuesday, March 15, 2011 12:44:48 AM UTC-4, bukzor wrote: Currently it requires either: 1) no symlinks to scripts or 2) installation of the pathtools to site-packages

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

2011-03-14 Thread bukzor
On Mar 13, 10:52 pm, eryksun () eryk...@gmail.com wrote: On Sunday, March 13, 2011 7:27:47 PM UTC-4, bukzor wrote:      e) create custom boilerplate in each script that addresses the issues in a-d. This seems to be the best practice at the moment... The boilerplate should be pretty simple

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

2011-03-14 Thread bukzor
On Mar 13, 6:50 pm, Terry Reedy tjre...@udel.edu wrote: On 3/13/2011 7:27 PM, bukzor wrote: I think this touches on my core problem. It's dead simple (and natural) to use .py files simultaneously as both scripts and libraries, as long as they're in a flat organization (all piled

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

2011-03-14 Thread bukzor
the package directory. Wait, this won't work when the script is linked to from somewhere else, which means the code still has to be based on __file__ or sys.argv[0] or sys.path[0], and have to get the absolute/real path in case it's a link. Along those lines, you (bukzor) wrote that What I do

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

2011-03-13 Thread bukzor
On Mar 12, 12:01 pm, eryksun () eryk...@gmail.com wrote: bukzor wrote: This only works if you can edit the PYTHONPATH. With thousands of users and dozens of groups each with their own custom environments, this is a herculean effort. ... I don't think it's recommended to directly run

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

2011-03-13 Thread bukzor
On Mar 12, 12:37 pm, Tim Johnson t...@johnsons-web.com wrote: * Phat Fly Alanna flannelsau...@gmail.com [110312 07:22]: 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,

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

2011-03-12 Thread bukzor
On Mar 11, 10:14 pm, eryksun () eryk...@gmail.com wrote: I'm not an expert at Python packaging, but assuming a structure such as folder1        \         __init__.py         module1.py folder2        \         __init__.py         module2.py within module1, I can import from module2,

organizing many python scripts, in a large corporate environment.

2011-03-11 Thread bukzor
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 it makes it

Re: organizing your scripts, with plenty of re-use

2009-10-19 Thread bukzor
On Oct 15, 4:30 pm, bukzor workithar...@gmail.com wrote: On Oct 13, 3:20 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 13 Oct 2009 17:38:44 -0300, Buck workithar...@gmail.com escribió: The only way to get your packages on the PYTHONPATH currently is to:    * install

Re: organizing your scripts, with plenty of re-use

2009-10-15 Thread bukzor
On Oct 13, 3:20 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 13 Oct 2009 17:38:44 -0300, Buck workithar...@gmail.com escribió: The only way to get your packages on the PYTHONPATH currently is to:    * install the packages to site-packages  (I don't have access)    * edit the

organizing your scripts, with plenty of re-use

2009-10-02 Thread bukzor
I would assume that putting scripts into a folder with the aim of re- using pieces of them would be called a package, but since this is an anti-pattern according to Guido, apparently I'm wrong-headed here. (Reference: http://mail.python.org/pipermail/python-3000/2007-April/006793.html ) Say you

Re: Late initialization using __getattribute__

2008-09-04 Thread bukzor
so unfortunately I think I need to use __getattribute__ to do this. I'm doing all this just to make the connection not actually connect until used. I may be dumb, but I don't get how this is supposed to solve your problem. But anyway : there's a known design pattern for what you're

Re: Late initialization using __getattribute__

2008-09-04 Thread bukzor
I'd like to be able to do something like this: class SuperCursor(FeatureOneMixIn, FeatureTwoMixin, ..., VanillaCursor): pass Why does it have to look like that?  A good programmer lets the code look however it has to look to most effectively do it's job. With a proxy, the base class

Late initialization using __getattribute__

2008-09-03 Thread bukzor
I want to make a MixIn class that waits to initialize its super- classes until an attribute of the object is accessed. Not generally useful, but desirable in my case. I've written this, and it works, but would like to take any suggestions you guys have. I've commented out the delattr call because

Re: Late initialization using __getattribute__

2008-09-03 Thread bukzor
On Sep 3, 12:19 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: bukzor a écrit : I want to make a MixIn class that waits to initialize its super- classes until an attribute of the object is accessed. Not generally useful, but desirable in my case. I've written this, and it works

Re: Late initialization using __getattribute__

2008-09-03 Thread bukzor
On Sep 3, 1:02 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: bukzor a écrit : (snip) Thanks for the reply. Just to see it not work, I tried to remove __getattribute__ from LateInitMixIn, but couldn't get it to work. ??? Sorry, I don't get what you mean... Since you said

Re: Keg - A python web framework

2008-08-04 Thread bukzor
On Aug 4, 1:13 pm, Daniel Fetchinson [EMAIL PROTECTED] wrote: I've been working on a python web framework which I think might be of interest to you. Details may be found athttp://code.google.com/p/keg/wiki/Concept. All suggestions or comments will be greatly appreciated. I fail to see

Re: binding names doesn't affect the bound objects (was: print doesn't respect file inheritance?)

2008-07-28 Thread bukzor
On Jul 26, 7:08 am, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Sat, 26 Jul 2008 14:07:52 +1000 Ben Finney [EMAIL PROTECTED] wrote:     sys.stdout = n Re-binds the name 'sys.stdout' to the object already referenced by the name 'n'. No objects are changed by this; only bindings of names

Re: Easier way to get the here path?

2008-07-28 Thread bukzor
On Jul 26, 9:19 am, Andrew [EMAIL PROTECTED] wrote: bukzor wrote: from os.path import abspath, realpath realpath(path.__file__.rstrip(c)) '/home/bgolemon/python/symlinks/path.py' realpath(abspath(path.__file__.rstrip(c))) '/home/bgolemon/python/symlinks/symlinks/path.py' -- http

Re: Easier way to get the here path?

2008-07-28 Thread bukzor
On Jul 28, 10:34 am, bukzor [EMAIL PROTECTED] wrote: On Jul 26, 9:19 am, Andrew [EMAIL PROTECTED] wrote: bukzor wrote: from os.path import abspath, realpath realpath(path.__file__.rstrip(c)) '/home/bgolemon/python/symlinks/path.py' realpath(abspath(path.__file__.rstrip(c

Easier way to get the here path?

2008-07-25 Thread bukzor
I have to go into these convulsions to get the directory that the script is in whenever I need to use relative paths. I was wondering if you guys have a better way: from os.path import dirname, realpath, abspath here = dirname(realpath(abspath(__file__.rstrip(c In particular, this takes care

print doesn't respect file inheritance?

2008-07-25 Thread bukzor
I was trying to change the behaviour of print (tee all output to a temp file) by inheriting from file and overwriting sys.stdout, but it looks like print uses C-level stuff to do its writes which bypasses the python object/inhertiance system. It looks like I need to use composition instead of

Re: filtering keyword arguments

2008-07-13 Thread bukzor
On Jul 12, 8:44 pm, Amir [EMAIL PROTECTED] wrote: How do you filter keyword arguments before passing them to a function? For example: def f(x=1): return x def g(a, **kwargs): print a, f(**kwargs) In [5]: g(1, x=3) 1 3 In [6]: g(1, x=3, y=4) TypeError: f() got an unexpected keyword

Re: socket.connect() hangs in SYN_SENT state.

2008-07-13 Thread bukzor
On Jul 13, 1:14 am, Miles [EMAIL PROTECTED] wrote: On Sat, Jul 12, 2008 at 11:23 PM, bukzor [EMAIL PROTECTED] wrote: I'm connecting to an apache2 process on the same machine, for testing. When looking at netstat, the socket is in the SYN_SENT state, like this: $netstat -a -tcp tcp

Re: socket.connect() hangs in SYN_SENT state.

2008-07-13 Thread bukzor
On Jul 13, 1:08 pm, Miles [EMAIL PROTECTED] wrote: On Sun, Jul 13, 2008 at 2:32 PM, bukzor [EMAIL PROTECTED] wrote: On Jul 13, 1:14 am, Miles [EMAIL PROTECTED] wrote: On Sat, Jul 12, 2008 at 11:23 PM, bukzor [EMAIL PROTECTED] wrote: I'm connecting to an apache2 process on the same machine

Re: Dictionary bidirectional

2008-07-13 Thread bukzor
On Jul 13, 4:21 pm, Kless [EMAIL PROTECTED] wrote: I need a dictionary where get the result from a 'key' (on left), but also from a 'value' (on right), how to get it? I know that dictionaries aren't bidirectional, but is there any way without use two dictionaries? Thanks in advance! You

Re: socket.connect() hangs in SYN_SENT state.

2008-07-13 Thread bukzor
On Jul 13, 6:31 pm, Miles [EMAIL PROTECTED] wrote: On Sun, Jul 13, 2008 at 8:35 PM, bukzor [EMAIL PROTECTED] wrote: The problem only manifests about 1 in 20 runs. Below there's code for a client that shows the problem 100% of the time. The two URL's that I seem to be confused about point

Re: Dictionary bidirectional

2008-07-13 Thread bukzor
On Jul 13, 6:53 pm, Larry Bates [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: bukzor: You need to use two dictionaries. Here's a class that someone's written that wraps it up into a single dict-like object for you: http://www.faqts.com/knowledge_base/view.phtml/aid/4376 It contains

Re: Someone enlightened me

2008-07-12 Thread bukzor
On Jul 12, 7:08 pm, Marcus Low [EMAIL PROTECTED] wrote: Can someone explain to me, why the behaviour below is different when u remark lister and unremark self.lister? #-- class abc : # remark this later and unremark self.lister

socket.connect() hangs in SYN_SENT state.

2008-07-12 Thread bukzor
tcp0 0 *:www *:* LISTEN 7635/apache2 tcp0 1 bukzor:38234adsl-75-61-84-249.d:www SYN_SENT9139/python Anyone know a general reason this might happen? Even better, a way to fix it? Doing a minimal amount of research, I found

Re: Platform independent code?

2008-06-14 Thread bukzor
On Jun 14, 6:28 am, saneman [EMAIL PROTECTED] wrote: I have read that Python is a platform independent language.  But on this page: http://docs.python.org/tut/node4.html#SECTION00422 it seems that making a python script executable is platform dependant: 2.2.2 Executable

Python + RDBM framework?

2008-06-14 Thread bukzor
It seems that whenever I have an application that uses a database (MySQL) I end up writing a database framework from scratch. Is there some accepted pre-existing project that has done this? I see Django, but that seems to have a lot of web-framework that I don't (necessarily) need. I just want to

Re: Python + RDBM framework?

2008-06-14 Thread bukzor
On Jun 14, 10:43 am, Larry Bates [EMAIL PROTECTED] wrote: bukzor wrote: It seems that whenever I have an application that uses a database (MySQL) I end up writing a database framework from scratch. Is there some accepted pre-existing project that has done this? I see Django

Re: How to get full path to script?

2008-06-08 Thread bukzor
On Jun 8, 12:52 pm, kj [EMAIL PROTECTED] wrote: In [EMAIL PROTECTED] Mark Tolonen [EMAIL PROTECTED] writes: import os print os.path.abspath(__file__) Great.  Thanks! Kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after

Re: Q re documentation Python style

2008-06-08 Thread bukzor
On Jun 8, 2:17 pm, kj [EMAIL PROTECTED] wrote: I'm a Perlhead trying to learn the Way of Python.  I like Python overall, but every once in a while I find myself trying to figure out why Python does some things the way it does.  At the moment I'm scratching my head over Python's docstrings.  As

Re: Newbie help (TypeError: int argument required)

2008-06-08 Thread bukzor
On Jun 8, 11:43 am, Iain Adams [EMAIL PROTECTED] wrote: Hi, I am new to python. I have been having trouble using the MysqlDB. I get an error pointing from the line cursor.execute(UPDATE article SET title = %s, text = %s WHERE id = %u, (self.title, self.text, self.id)) Here is the error:

Re: Please unregister this mail-address out of mailing-list.

2008-06-05 Thread bukzor
On Jun 5, 11:37 am, [EMAIL PROTECTED] wrote: -Original Message- From: Hank @ITGroup I am writing this letter to unsubscribe this mail-address from python mail-list. -- http://mail.python.org/mailman/listinfo/python-list No problem, Hank. You will be officially off of this

Guide to organizing modules?

2008-06-05 Thread bukzor
I've been finding at work that I've written a set of functions several times, sometimes with more or less features or bugs, so I've decided to take my small, useful functions and put them in some common place. I've made a module for this, but it is quickly becoming a jumbled mess of unrelated

Re: Guide to organizing modules?

2008-06-05 Thread bukzor
On Jun 5, 5:58 pm, alex23 [EMAIL PROTECTED] wrote: On Jun 6, 10:32 am, bukzor [EMAIL PROTECTED] wrote: In summary: are there any good (or official) guidelines for how to organize and separate python functions and classes into modules? Hey bukzor, Are you familiar with the concept

Cast list of objects to list of strings

2008-06-02 Thread bukzor
I have this function: def write_err(obj): from sys import stderr stderr.write(str(obj)+\n) and I'd like to rewrite it to take a variable number of objects. Something like this: def write_err(*objs): from sys import stderr stderr.write( .join(objs)+\n) but I lose the

Re: Cast list of objects to list of strings

2008-06-02 Thread bukzor
On Jun 2, 2:56 pm, jay graves [EMAIL PROTECTED] wrote: On Jun 2, 4:02 pm, Larry Bates [EMAIL PROTECTED] wrote: I think what you want is: def write_err(*args): from sys import stderr stderr.write(\n.join([str(o) for o in args])) Slight nitpick. If you are using version = 2.4

Re: call f(a, *b) with f(*a, **b) ?

2008-05-27 Thread bukzor
On May 23, 1:17 pm, bukzor [EMAIL PROTECTED] wrote: On May 23, 12:35 pm, inhahe [EMAIL PROTECTED] wrote: I wish this worked: def main(a,b,*argv): pass options['argv'] = argv main(**options) TypeError: main() got an unexpected keyword argument 'argv' - I was thinking

Re: Unhandled exceptions checking

2008-05-24 Thread bukzor
On May 23, 6:31 pm, Yosifov Pavel [EMAIL PROTECTED] wrote: Does somebody know existent tool for checking unhandled exceptions? Like in Java when method throws exception but in code using this method, try...catch is missed. May be something like PyChecker? -- /Pavel I know that pychecker

Re: why is com-prompt faster and how do i start at cprompt at mydir/ ?

2008-05-24 Thread bukzor
On May 23, 10:18 pm, [EMAIL PROTECTED] wrote: On 24 Maj, 07:01, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: On 24 Maj, 05:48, Ben Finney [EMAIL PROTECTED] wrote: Can you tell us exactly which programs you mean when you say the shell and the commandprompt?

Re: Storing objects in relational database

2008-05-24 Thread bukzor
On May 23, 7:00 pm, alex23 [EMAIL PROTECTED] wrote: On May 24, 7:14 am, nayden [EMAIL PROTECTED] wrote: the execution fails just after the print statement, and I am not quite sure why is that. It's often helpful to include the traceback, or at the very least the last 3-4 lines of it, as

Re: Reloading function obtained via 'from xxx import yyy'

2008-05-24 Thread bukzor
On May 23, 3:44 pm, Joel Koltner [EMAIL PROTECTED] wrote: Martin v. Löwis [EMAIL PROTECTED] wrote in messagenews:[EMAIL PROTECTED] Try all three of them, in sequence: Thanks, will do. If you absolutely don't want to import test, write I can live with the import, I just don't want to

Re: call f(a, *b) with f(*a, **b) ?

2008-05-23 Thread bukzor
On May 22, 5:39 pm, inhahe [EMAIL PROTECTED] wrote: 1 2 actually, you don't want it to print 3 also?  if not, then you would do f(*map(kwargs.get, inspect.getargspec(f)[0])+args[:1]) import inspect f(*map(kwargs.get, inspect.getargspec(f)[0])+args) No, that was a typo. Thanks tho.

Re: call f(a, *b) with f(*a, **b) ?

2008-05-23 Thread bukzor
On May 22, 5:29 pm, inhahe [EMAIL PROTECTED] wrote: bukzor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This question seems easy but I can't figure it out. Lets say there's a function: def f(a, *args):    print a    for b in args: print b and elsewhere in your

Re: call f(a, *b) with f(*a, **b) ?

2008-05-23 Thread bukzor
On May 23, 3:29 am, inhahe [EMAIL PROTECTED] wrote: inhahe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] if we assume the constraints are that: 1.he has list, l 2.he has a dictionary, d 3.he wants the function to print the values in the dictionary according to a specific

Re: call f(a, *b) with f(*a, **b) ?

2008-05-23 Thread bukzor
On May 23, 3:29 am, inhahe [EMAIL PROTECTED] wrote: inhahe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] if we assume the constraints are that: 1.he has list, l 2.he has a dictionary, d 3.he wants the function to print the values in the dictionary according to a specific

Re: call f(a, *b) with f(*a, **b) ?

2008-05-23 Thread bukzor
On May 23, 12:35 pm, inhahe [EMAIL PROTECTED] wrote: I wish this worked: def main(a,b,*argv): pass options['argv'] = argv main(**options) TypeError: main() got an unexpected keyword argument 'argv' - I was thinking about that exact same thing actually. Except that I was thinking

call f(a, *b) with f(*a, **b) ?

2008-05-22 Thread bukzor
This question seems easy but I can't figure it out. Lets say there's a function: def f(a, *args): print a for b in args: print b and elsewhere in your program you have a list and a dict like this: args = [2, 3] kwargs = {'a':1} I'd like to get f() to print something like the following,

Re: simple way to touch a file if it does not exist

2008-05-22 Thread bukzor
On May 22, 12:07 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 21 May 2008 17:56:38 -0700, bukzor wrote: On May 21, 5:37 pm, Nikhil [EMAIL PROTECTED] wrote: if os.path.exists('file'): open('file', 'w').close() Right? You only want to blank it if it exists

What replaces `` in py3k?

2008-05-21 Thread bukzor
In Python 3, backticks (``) are being removed. The plan is to create an automatic way to port python2 programs to python3, so my question is: What are backticks going to be translated into? I tried looking at the 2to3 fixer source code, but as far as I can tell they haven't written that part yet.

Re: What replaces `` in py3k?

2008-05-21 Thread bukzor
On May 21, 10:48 am, Jonathan Gardner [EMAIL PROTECTED] wrote: On May 21, 10:45 am, bukzor [EMAIL PROTECTED] wrote: What are backticks going to be translated into? repr Thanks for the quick reply! --Buck -- http://mail.python.org/mailman/listinfo/python-list

best way to check if pid is dead?

2008-05-21 Thread bukzor
Does anyone have a pythonic way to check if a process is dead, given the pid? This is the function I'm using is quite OS dependent. A good candidate might be try: kill(pid), since it throws an exception if the pid is dead, but that sends a signal which might interfere with the process. Thanks.

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-21 Thread bukzor
On May 21, 11:38 am, Mark Dickinson [EMAIL PROTECTED] wrote: On SuSE 10.2/Xeon there seems to be a rounding bug for floating-point addition: [EMAIL PROTECTED]:~ python Python 2.5 (r25:51908, May 25 2007, 16:14:04) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type help,

Re: best way to check if pid is dead?

2008-05-21 Thread bukzor
On May 21, 12:13 pm, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], bukzor [EMAIL PROTECTED] wrote: Does anyone have a pythonic way to check if a process is dead, given the pid? This is the function I'm using is quite OS dependent. A good candidate might be try

Re: best way to check if pid is dead?

2008-05-21 Thread bukzor
On May 21, 1:27 pm, bukzor [EMAIL PROTECTED] wrote: On May 21, 12:13 pm, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED],  bukzor [EMAIL PROTECTED] wrote: Does anyone have a pythonic way to check if a process is dead, given the pid? This is the function I'm

Re: Returning to 'try' block after catching an exception

2008-05-21 Thread bukzor
On May 21, 4:33 pm, Karlo Lozovina [EMAIL PROTECTED] wrote: André [EMAIL PROTECTED] wrote innews:[EMAIL PROTECTED]: How about something like the following (untested) done = False while not done: try: some_function() done = True except: some_function2()

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-21 Thread bukzor
On May 21, 3:28 pm, Dave Parker [EMAIL PROTECTED] wrote: On May 21, 4:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Which is exactly what the python decimal module does. Thank you (and Jerry Hill) for pointing that out. If I want to check Flaming Thunder's results against an independent

Re: simple way to touch a file if it does not exist

2008-05-21 Thread bukzor
On May 21, 5:10 pm, Giampaolo Rodola' [EMAIL PROTECTED] wrote: On 22 Mag, 01:15, Nikhil [EMAIL PROTECTED] wrote: what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods? Just use os.path.exists to check for file existence and open() as

Re: simple way to touch a file if it does not exist

2008-05-21 Thread bukzor
On May 21, 5:37 pm, Nikhil [EMAIL PROTECTED] wrote: bukzor wrote: On May 21, 5:10 pm, Giampaolo Rodola' [EMAIL PROTECTED] wrote: On 22 Mag, 01:15, Nikhil [EMAIL PROTECTED] wrote: what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods

Re: Directed Graph Traversal

2008-04-03 Thread bukzor
On Apr 2, 8:33 pm, Scott David Daniels [EMAIL PROTECTED] wrote: bukzor wrote: Can someone point me in the direction of a good solution of this? I'm using it to construct a SQL query compiler, Given a directed graph and a list of points in the graph, what is the minimal subgraph

Directed Graph Traversal

2008-04-01 Thread bukzor
Can someone point me in the direction of a good solution of this? I'm using it to construct a SQL query compiler, where each node is a table and each edge is a join. I'm planning on using the NetworkX library if possible. https://networkx.lanl.gov/reference/networkx/ Given a directed graph and a

Re: Directed Graph Traversal

2008-04-01 Thread bukzor
On Apr 1, 3:46 pm, bukzor [EMAIL PROTECTED] wrote: Can someone point me in the direction of a good solution of this? I'm using it to construct a SQL query compiler, where each node is a table and each edge is a join. I'm planning on using the NetworkX library if possible.https

Re: fastest method to choose a random element

2008-01-06 Thread bukzor
On Jan 5, 5:36 pm, [EMAIL PROTECTED] wrote: On Jan 5, 9:50 pm, Paul Hankin [EMAIL PROTECTED] wrote: On Jan 5, 5:12 pm, Paul Hankin [EMAIL PROTECTED] wrote: On Jan 5, 4:14 pm, [EMAIL PROTECTED] wrote: On Jan 5, 5:07 pm, [EMAIL PROTECTED] wrote: Hello, Paul and Arnaud.

Re: how to use bool

2008-01-06 Thread bukzor
/node10.html --Bukzor -- http://mail.python.org/mailman/listinfo/python-list

Re: Delete lines containing a specific word

2008-01-06 Thread bukzor
On Jan 6, 3:33 pm, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: grep doesn't delete lines. grep matches lines. If you want to delete them, you still have to do the rest of the job yourself. In which way does grep -v mypattern myfile myfile not delete the

Re: fastest method to choose a random element

2008-01-05 Thread bukzor
On Jan 5, 9:12 am, Martin v. Löwis [EMAIL PROTECTED] wrote: Any other ideas? How about this: def random_pick(list, property): L = len(list) pos = start = random.randrange(L) while 1: x = list[pos] if property(x): return x pos = (pos + 1) % L

Re: fastest method to choose a random element

2008-01-05 Thread bukzor
On Jan 5, 8:14 am, [EMAIL PROTECTED] wrote: On Jan 5, 5:07 pm, [EMAIL PROTECTED] wrote: Hello, Paul and Arnaud. While I think about your answers: do you think there is any way to avoid shuffle? It may take unnecessary long on a long list most of whose elements have the property.

Re: Details about pythons set implementation

2008-01-05 Thread bukzor
On Jan 4, 2:15 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Fri, 04 Jan 2008 09:29:50 -0800, bukzor wrote: Why cant you implement for complex numbers? Maybe I'm being naive, but isn't this the normal definition? a + bi c + di iff sqrt(a**2 + b**2) sqrt(c**2, d

Re: how to use bool

2008-01-04 Thread bukzor
On Jan 3, 7:49 am, [EMAIL PROTECTED] wrote: hi, i have some code where i set a bool type variable and if the value is false i would like to return from the method with an error msg.. being a beginner I wd like some help here class myclass: . def mymethod(self):

Re: how to use bool

2008-01-04 Thread bukzor
On Jan 4, 8:51 am, bukzor [EMAIL PROTECTED] wrote: On Jan 3, 7:49 am, [EMAIL PROTECTED] wrote: hi, i have some code where i set a bool type variable and if the value is false i would like to return from the method with an error msg.. being a beginner I wd like some help here class

Re: Details about pythons set implementation

2008-01-04 Thread bukzor
On Jan 4, 9:08 am, Sion Arrowsmith [EMAIL PROTECTED] wrote: Hrvoje Niksic [EMAIL PROTECTED] wrote: BTW if you're using C++, why not simply use std::set? Because ... how to be polite about this? No, I can't. std::set is crap. The implementation is a sorted sequence -- if you're lucky, this

Information about including module?

2008-01-02 Thread bukzor
Is there any way to print the docstring of the including module? I'd like to be able to do something like the following file one.py: some docstring include two file two.py: from magicmodule import getincluder print getincluder().__doc__ Running one.py would print the docstring. Thanks!

Re: Information about including module?

2008-01-02 Thread bukzor
On Jan 2, 4:52 pm, bukzor [EMAIL PROTECTED] wrote: Is there any way to print the docstring of the including module? I'd like to be able to do something like the following file one.py: some docstring include two file two.py: from magicmodule import getincluder print getincluder().__doc__

Re: Bizarre behavior with mutable default arguments

2008-01-01 Thread bukzor
On Dec 30 2007, 11:01 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 30 Dec 2007 20:00:14 -0800, bukzor wrote: I think you struck at the heart of the matter earlier when you noted that this is the simplest way to declare a static variable in python. Using

Re: Bizarre behavior with mutable default arguments

2008-01-01 Thread bukzor
PROTECTED] wrote: On Dec 29, 9:14 pm, bukzor [EMAIL PROTECTED] wrote: Here's the answer to the question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-... It looks like Guido disagrees with me, so the discussion is closed. Note that the FAQ mainly

Re: Bizarre behavior with mutable default arguments

2008-01-01 Thread bukzor
On Jan 1, 9:00 am, bukzor [EMAIL PROTECTED] wrote: On Dec 31 2007, 1:30 pm, Chris Mellon [EMAIL PROTECTED] wrote: On Dec 31, 2007 2:08 PM, Odalrick [EMAIL PROTECTED] wrote: On 31 Dec, 18:22, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Dec 31, 10:58 am, Odalrick [EMAIL PROTECTED

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread bukzor
On Dec 30, 2:23 am, thebjorn [EMAIL PROTECTED] wrote: Scenario: long running server process, Bug report: people aren't getting older, Code: def age(dob, today=datetime.date.today()): ... A very interesting example, thanks. On Dec 30, 8:25 am, [EMAIL PROTECTED] wrote: This is a

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread bukzor
On Dec 30, 12:32 pm, Istvan Albert [EMAIL PROTECTED] wrote: On Dec 30, 11:26 am, George Sakkis [EMAIL PROTECTED] wrote: I'm with you on this one; IMHO it's one of the relatively few language design missteps of Python, favoring the rare case as the default instead of the common one.

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread bukzor
On Dec 30, 3:34 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 30 Dec 2007 12:41:57 -0800, bukzor wrote: BTW, it's silly not to 'allow' globals when they're called for, otherwise we wouldn't need the 'global' keyword. Nobody argues against allowing globals variables

Bizarre behavior with mutable default arguments

2007-12-29 Thread bukzor
I've found some bizzare behavior when using mutable values (lists, dicts, etc) as the default argument of a function. I want to get the community's feedback on this. It's easiest to explain with code. This example is trivial and has design issues, but it demonstrates a problem I've seen in

Re: Bizarre behavior with mutable default arguments

2007-12-29 Thread bukzor
Here's the answer to the question: http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects It looks like Guido disagrees with me, so the discussion is closed. For the record, I still think the following would be an improvement to py3k: In python25: def f(a=None):

Re: Bizarre behavior with mutable default arguments

2007-12-29 Thread bukzor
I think that this behaviour is a little unintuitive, and by a little I mean a lot. Thanks for acknowledging it. I question that it is much more common. How do you know? Where's your data? I did a dumb grep of my Python25/Lib folder and found 33 occurances of the first pattern above. (Use

Re: Bizarre behavior with mutable default arguments

2007-12-29 Thread bukzor
Just for completeness, the mutable default value problem also affects classes: class c: def __init__(self, list = []): self.list = list self.list.append(LIST END) def __repr__(self): return Class a: %s % self.list import example2 print example2.c() Class a: