On Mar 16, 3:29 pm, bukzor wrote:
> On Mar 15, 11:57 pm, "eryksun ()" 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 t
On Mar 15, 11:57 pm, "eryksun ()" 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
On Mar 16, 7:42 am, booklover 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
On Mar 15, 12:24 pm, booklover 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. Perhaps if Pyt
> are linked, and that this is also 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'
On Mar 13, 6:50 pm, Terry Reedy 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,
On Mar 13, 10:52 pm, "eryksun ()" 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 boilerpla
On Mar 12, 12:37 pm, Tim Johnson wrote:
> * Phat Fly Alanna [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, but there's a problem. These s
On Mar 12, 12:01 pm, "eryksun ()" 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
On Mar 11, 10:14 pm, "eryksun ()" 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, e.g.:
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 quit
On Oct 15, 4:30 pm, bukzor wrote:
> On Oct 13, 3:20 pm, "Gabriel Genellina"
> wrote:
>
>
>
>
>
> > En Tue, 13 Oct 2009 17:38:44 -0300, Buck escribió:
>
> > > The only way to get your packages on the PYTHONPATH currently is to:
> > >
On Oct 13, 3:20 pm, "Gabriel Genellina"
wrote:
> En Tue, 13 Oct 2009 17:38:44 -0300, Buck 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 PYTHONPATH all users' environment
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
> > 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 "bas
> >>> 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
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&
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
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
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
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&
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'
>
> >>>&
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 b
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 inhe
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 car
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:
> >>htt
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.
>
> >
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!
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:
>
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
> &g
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 unexpect
at -a -tcp
tcp0 0 *:www *:*
LISTEN 7635/apache2
tcp 0 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 fou
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 "
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 do
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
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 Exe
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
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
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, a
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 b
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 funct
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 of
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 usi
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 pr
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
>
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 ju
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
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"
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 pychec
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. Exce
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 accordi
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 accordi
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:
&
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
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(&
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, b
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 way
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 a
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
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:
> > so
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
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 functio
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"
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.
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
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.
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 th
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 li
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
On Jan 6, 3:33 pm, Bjoern Schliessmann 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
> lines matching myp
out of the exception, you can use
'e.message' or 'str(e)'. If you want to print the exception's message,
just do 'print e'. Besides that, your code looks good. Might want to
read the exceptions chapter of the documentation:
http://docs.python.org/tut/node10.html
--Bukzor
--
http://mail.python.org/mailman/listinfo/python-list
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, Pa
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?
>
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 +
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 prope
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 luc
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
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):
>
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.p
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!
Bu
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 Delobe
k <[EMAIL PROTECTED]> wrote:
>
> > > > On 30 Dec, 17:26, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> > > > > On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote:
>
> > > > > > Here's the answer to the
> > > > &
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 var
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 'glo
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 o
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:
> Thi
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 "" % self.list
>>> import example2
>>> print example2.c()
>>> print exam
> 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. (U
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):
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 product
90 matches
Mail list logo