ANN: python-constraint 1.0

2005-07-06 Thread Gustavo Niemeyer
Overview **python-constraint** [1]_ is a Python module offering solvers for Constraint Solving Problems (CSPs) over finite domains in simple and pure Python. CSP is class of problems which may be represented in terms of variables (`a`, `b`, ...), domains (`a in [1, 2, 3]`, ...),

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Reinhold Birkenfeld
Ron Adam wrote: > Given the statement: > > a = None > > And the following are all true: > > a == None Okay. > (a) == (None) Okay. > (a) == () Whoops! a (which is None) is equal to the empty tuple (which is not None)? > (None) == () > > Then this "conceptual" comparison should also be tr

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Mike Meyer wrote: > Ron Adam <[EMAIL PROTECTED]> writes: > >>So doing this would give an error for functions that require an argument. >> >> def foo(x): >> return x >> >> a = None >> b = foo(a)# error because a dissapears before foo gets it. > > > So how do I pass None

Re: Lisp development with macros faster than Python development?..

2005-07-06 Thread Philippe C. Martin
Almost sounds like a racist comment - sorry if I misunderstood Antoon Pardon wrote: > Op 2005-07-06, Michele Simionato schreef <[EMAIL PROTECTED]>: >> Fuzzyman: >>> So Lisp is for really good programmers, and Python is for >>> mediocre programmers ? >> >> >> Python is *also* for mediocre p

Re: Python exception hook simple example needed

2005-07-06 Thread Ed Leafe
On Jul 6, 2005, at 8:59 AM, Fuzzyman wrote: > Wax has a brilliant prebuilt dialog/handler. It's a wrapper over > wxPython - so you still use wxPython objects, it's jsut all a lot > easier. And don't forget Dabo, which wraps all of wxPython's dialogs into simple calls. No need to create/show/dest

Re: Use cases for del

2005-07-06 Thread Ron Adam
Grant Edwards wrote: > On 2005-07-07, Ron Adam <[EMAIL PROTECTED]> wrote: > >>Grant Edwards wrote: >> >> >>>On 2005-07-06, Ron Adam <[EMAIL PROTECTED]> wrote: >>> >>> >>> It would be a way to set an argument as being optional without actually assigning a value to it. The conflict would b

Re: I am a Java Programmer

2005-07-06 Thread godwin
Buy the book "Practical Python" by Magnus Lie Hetland. It contains 10 practical projects to let u get started on you own "Pythoneering"( as Magnus calls it). Move on buddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Lisp development with macros faster than Python development?..

2005-07-06 Thread Gregory Bond
Rocco Moretti wrote: > Actually, Google's answer to that question is something called "ILOG > CPLEX", We use this. It's a library / command line tool (not a language) for doing optimization - linear programming, quadratic programming, mixed-integer programming etc. Very cool and very, very

Re: Use cases for del

2005-07-06 Thread Grant Edwards
On 2005-07-07, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: >> On 2005-07-07, Leif K-Brooks <[EMAIL PROTECTED]> wrote: >>>_NOVALUE = object() >>>class demo: >>>def foo(v=_NOVALUE): >>>if v is _NOVALUE: >>>return self.v >>>else: >>>self.

Re: Use cases for del

2005-07-06 Thread Grant Edwards
On 2005-07-07, George Sakkis <[EMAIL PROTECTED]> wrote: > I guess he means why not define foo as property: > > class demo(object): > foo = property(fget = lambda self: self.v, >fset = lambda self,v: setattr(self,'v',v)) > > d = demo() > d.foo = 3 > print d.foo In some ways

Re: is there an equivalent of javascript's this["myMethod"] for the currently running script?

2005-07-06 Thread markturansky
getattr does not work on a running script (afaik) because 'self' is undefined. The poster above got it right using 'locals()' -- http://mail.python.org/mailman/listinfo/python-list

Re: is there an equivalent of javascript's this["myMethod"] for the currently running script?

2005-07-06 Thread markturansky
'self' is not defined in this circumstance. The poster above (using 'locals()') has it right. -- http://mail.python.org/mailman/listinfo/python-list

Re: is there an equivalent of javascript's this["myMethod"] for the currently running script?

2005-07-06 Thread markturansky
Yes, that is exactly what I was looking for. Thank you. I will read more about 'locals()', but a quick test proved you right. -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-06 Thread Leif K-Brooks
Grant Edwards wrote: > On 2005-07-07, Leif K-Brooks <[EMAIL PROTECTED]> wrote: >>_NOVALUE = object() >>class demo: >>def foo(v=_NOVALUE): >>if v is _NOVALUE: >>return self.v >>else: >>self.v = v > > > Apart from the change in the logic such that the set

Re: flatten(), [was Re: map/filter/reduce/lambda opinions ...]

2005-07-06 Thread Ron Adam
Stian Søiland wrote: > Or what about a recursive generator? > > a = [1,2,[[3,4],5,6],7,8,[9],[],] > > def flatten(item): > try: > iterable = iter(item) > except TypeError: > yield item # inner/final clause > else: > for elem in

Re: Favorite non-python language trick?

2005-07-06 Thread Mike Meyer
"Shai" <[EMAIL PROTECTED]> writes: > They're called "Special vars", and you need to define them (unlike > local LISP variables, which behave essentially like Python vars), but > then you use them just like other vars (that is, you usually bind them > with LET). This is the first I hear about them

Re: Use cases for del

2005-07-06 Thread George Sakkis
"Grant Edwards" wrote: > In 2005-07-07, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > > - Hide quoted text - > - Show quoted text - > > Grant Edwards wrote: > >> 1) So I know whether an parameter was passed in or not. Perhaps > >>it's not considered good Pythonic style, but I like to use a > >>

Re: Use cases for del

2005-07-06 Thread Grant Edwards
On 2005-07-07, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: >> 1) So I know whether an parameter was passed in or not. Perhaps >>it's not considered good Pythonic style, but I like to use a >>single method for both get and set operations. With no >>parameters, it's

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Mike Meyer
Ron Adam <[EMAIL PROTECTED]> writes: > So doing this would give an error for functions that require an argument. > > def foo(x): > return x > > a = None > b = foo(a)# error because a dissapears before foo gets it. So how do I pass None to a function? > >>TypeErro

Re: Use cases for del

2005-07-06 Thread Leif K-Brooks
Grant Edwards wrote: > 1) So I know whether an parameter was passed in or not. Perhaps >it's not considered good Pythonic style, but I like to use a >single method for both get and set operations. With no >parameters, it's a get. With a parameter, it's a set: > >class demo: >

Re: Considering moving from Delphi to Python [Some questions]

2005-07-06 Thread malkarouri
Dark Cowherd wrote: > Stupid of me. > > I want some feedback on folllwing: > anybody who has experience in writing SOAP servers in Python and data > entry heavy web applications. > Any suggestions? > darkcowherd Check ZSI, or SOAPPY, both on Python Web Services http://pywebsvcs.sourceforge.net/ I

Re: I am a Java Programmer

2005-07-06 Thread Philippe C. Martin
I see you got many good/funny answers already. Test Python for two WE and you'll be able to help yourself very well ... I've been through an equivalent process. Regards, Philippe [EMAIL PROTECTED] wrote: > I am a java programmer and I want to learn Python Please help me. -- http://mail.py

Re: Compatibility of recent GCC/Python versions

2005-07-06 Thread Ralf W. Grosse-Kunstleve
--- David Abrahams <[EMAIL PROTECTED]> wrote: > Recently people testing Boost.Python with GCC on Linux have reported > that the extensions being tested have to be compiled with exactly the > same version of GCC as the Python they're being loaded into, or they > get mysterious crashes. > > That doe

Re: Use cases for del

2005-07-06 Thread Grant Edwards
On 2005-07-07, Ron Adam <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > >> On 2005-07-06, Ron Adam <[EMAIL PROTECTED]> wrote: >> >> >>>It would be a way to set an argument as being optional without >>>actually assigning a value to it. The conflict would be if >>>there where a global with the

Re: Use cases for del

2005-07-06 Thread Ron Adam
Grant Edwards wrote: > On 2005-07-06, Ron Adam <[EMAIL PROTECTED]> wrote: > > >>It would be a way to set an argument as being optional without actually >>assigning a value to it. The conflict would be if there where a global >>with the name baz as well. Probably it would be better to use a v

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Benji York wrote: > Ron Adam wrote: > >> "if extraargs:" would evaluate to "if None:", which would evaluate to >> "if:" which would give you an error. > > > In what way is "if None:" equivalent to "if:"? > -- > Benji York It's not now.. but if None where to really represent the concept None,

Re: Inheritance/Late Private Binding

2005-07-06 Thread Michael Hoffman
Jeremy Moles wrote: > Forgive me if this topic has been brought up before, but I was curious > as to why I was getting this behavior and was hoping someone > knowledgeable could explain. :) What behavior? > I "feel" like even without the explicit call to a simple base ctor(), > mangling should s

Inheritance/Late Private Binding

2005-07-06 Thread Jeremy Moles
class BaseClass: def __init__(self): self.__data = None def getMember(self): return self.__data class GoodSubClass(BaseClass): def __init__(self): BaseClass.__init__(self) class BadSubClass(BaseClass): def __init__(s

Re: frozenset question

2005-07-06 Thread George Sakkis
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > On Wed, 06 Jul 2005 10:15:31 -0700, George Sakkis wrote: > > > Well, they *may* be interchangable under some conditions, and that was > > the OP's point you apparently missed. > > I didn't miss anything of the sort. That's why I spent 15 minutes actua

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread David Abrahams
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > I discovered FP with David Mertz's papers about FP in Python. I had > never read nor write a line of lisp, scheme, haskell, caml etc before. > And I'd certainly start thinking of choosing another MYFL if anonymous > functions where to disappear

RE: frozenset question

2005-07-06 Thread Delaney, Timothy (Tim)
Steven D'Aprano wrote: > If, over a thousand runs of the program, you save a millisecond of > time in total, but it costs you two seconds to type the comment in > the code explaining why you used frozenset instead of the more > natural set, then your "optimization" is counter-productive. Even > ju

Re: Lisp development with macros faster than Python development?..

2005-07-06 Thread Rahul
Hi. Instead of listing the difference ..here are some things that are COMMON to both common lisp and python : 1.Dynamic typing. 2.garbage collection 3.powerful data structures 4.good object systems. (here people from lisp usually claim that clos is the most powerful object system...but i think pyt

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread David Abrahams
Tom Anderson <[EMAIL PROTECTED]> writes: > Comrades, > > During our current discussion of the fate of functional constructs in > python, someone brought up Guido's bull on the matter: > > http://www.artima.com/weblogs/viewpost.jsp?thread=98196 > > He says he's going to dispose of map, filter, red

RE: I am a Java Programmer

2005-07-06 Thread Delaney, Timothy (Tim)
[EMAIL PROTECTED] wrote: > I am a java programmer and I want to learn Python Please help me. My condolences. I am a programmer who is currently forced to program in Java. These two sites will help you a lot in learning to program in Python: http://www.catb.org/~esr/faqs/smart-questions.html htt

RE: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread Delaney, Timothy (Tim)
Thomas Heller wrote: > I forgot to mention this: The Base class also implements a __getitem__ > method which should be used for iteration if the .Iterator method in > the subclass is not available. So it seems impossible to raise an > exception in the __iter__ method if .Iterator is not found - _

Re: precision problems in base conversion of rational numbers

2005-07-06 Thread Raymond Hettinger
> > For a simple example, convert both 10247448370872321 and > > 10247448370872319 from base ten to 4 digits of hex. The calculations > > need to be carried out to 15 places of hex (or 17 places of decimal) > > just to determine whether the fourth hex digit is a 7 or 8: > > > > >>> hex(1024744

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Steven Bethard
Daniel Schüle wrote: > Removing lamdba would be reduce readability of Python, I think here > for examble of code like > > class App: > > > def drawLines(self, event): > from random import randint > r = lambda : randint(1, 100) > self.canvas.create_line

Re: Using Numeric 24.0b2 with Scientific.IO.NetCDF

2005-07-06 Thread bandw
I am having more problems with 24.0b2. Consider the NetCDF file: netcdf very_simple { dimensions: num = 2 ; variables: float T(num) ; T:mv = 5.0f ; data: T = 1., 2. ; } and the python script: import Numeric from Scientific.IO.NetCDF import NetCDFFile file = NetCDFFile

Re: frozenset question

2005-07-06 Thread Steven D'Aprano
On Wed, 06 Jul 2005 10:15:31 -0700, George Sakkis wrote: > Well, they *may* be interchangable under some conditions, and that was > the OP's point you apparently missed. I didn't miss anything of the sort. That's why I spent 15 minutes actually producing test cases to MEASURE if there was any de

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Daniel Schüle
I think in some contextes map is more readable than [f() for i in S] because it's more verbatim Removing lamdba would be reduce readability of Python, I think here for examble of code like class App: def drawLines(self, event): from random import r

Re: Favorite non-python language trick?

2005-07-06 Thread Shai
I only saw this today... sorry about the late response. Anyway, replying to your two messages at once: Mike Meyer wrote: > Last time I checked, dynamic binding variables were frowned on in LISP > systems as well. Scheme doesn't have them. Common LISP requires > special forms to use them. They'r

Re: Compatibility of recent GCC/Python versions

2005-07-06 Thread Robert Kern
David Abrahams wrote: > Recently people testing Boost.Python with GCC on Linux have reported > that the extensions being tested have to be compiled with exactly the > same version of GCC as the Python they're being loaded into, or they > get mysterious crashes. > > That doesn't correspond to my pa

Compatibility of recent GCC/Python versions

2005-07-06 Thread David Abrahams
Recently people testing Boost.Python with GCC on Linux have reported that the extensions being tested have to be compiled with exactly the same version of GCC as the Python they're being loaded into, or they get mysterious crashes. That doesn't correspond to my past experience; it has always been

Re: Use cases for del

2005-07-06 Thread Grant Edwards
On 2005-07-06, Ron Adam <[EMAIL PROTECTED]> wrote: > It would be a way to set an argument as being optional without actually > assigning a value to it. The conflict would be if there where a global > with the name baz as well. Probably it would be better to use a valid > null value for what e

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Benji York
Ron Adam wrote: > "if extraargs:" would evaluate to "if None:", which would evaluate to > "if:" which would give you an error. In what way is "if None:" equivalent to "if:"? -- Benji York -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-06 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam wrote: > >>Ron Adam wrote: >> >> >>>And accessing an undefined name returned None instead of a NameError? >> >>I retract this. ;-) >> >>It's not a good idea. But assigning to None as a way to unbind a name >>may still be an option. > > IMO, it isn't. This

Re: Lisp development with macros faster than Python development?..

2005-07-06 Thread Scott David Daniels
François Pinard wrote: > My feeling at the time was that Scheme is a very fast language to write > into, and in which one can implement new concepts cleanly and compactly. > Maybe Python is a bit slower to write, but this is compensated by the > fact Python is more legible when it comes to later ma

Re: Scipy - Latex Annotations in plots

2005-07-06 Thread Robert Kern
Matthias R. wrote: > Unfortunately matplotlib is only a 2D-plotting library. > > Do you know another one with 3D-capabilities as well? There's PyX. > That would be very nice, Yes, yes it would. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the grav

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Bruno Desthuilliers
Stian Søiland a écrit : > (snip) > Hey, I know! > > t = python.util.ImmutableArrayList.fromCollection(L.getAbstractCollection()) > > python.util.functional.applyFunctionOnCollection( > (class implements python.util.functional.AnonymousFunction: > def anonymousFunction(x): >

Re: Scipy - Latex Annotations in plots

2005-07-06 Thread Bill Mill
> Robert Kern wrote: > > > fortuneteller wrote: > >> Hello, > >> > >> I'm quite new to python and Scipy. > >> Anyway I want to use it to plot graphs. > >> Does anybody know if there is the possibility to use Latex in SciPy's > >> plotting functions like gplt? > > > > I don't believe so. matplotlib

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Bruno Desthuilliers
Tom Anderson a écrit : > Comrades, > > During our current discussion of the fate of functional constructs in > python, someone brought up Guido's bull on the matter: > > http://www.artima.com/weblogs/viewpost.jsp?thread=98196 > > He says he's going to dispose of map, filter, reduce and lambda.

Re: I am a Java Programmer

2005-07-06 Thread Luis M. Gonzalez
I'm sorry for you, nobody deserves to program in Java ... I'm glad you decided to stand up for your human rights. Go learn python! -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange os.path.exists() behaviour

2005-07-06 Thread Michael Hoffman
Jeff Epler wrote: > Here's the bug. You're using Windows. QOTW (speaking as someone who is using Windows right now). -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

PyNSol: Objects as Scaffolding

2005-07-06 Thread Michael Tobis
An article of mine, entitled "PyNSol: Objects as Scaffolding" has appeared in Computing in Science and Engineering. You can read it at http://www.computer.org/portal/site/cise/ or alternatively at http://geosci.uchicago.edu/~tobis/ciseps.pdf It's not so much an article about a software project

out of office auto-reply

2005-07-06 Thread Frank Fuchs
Dear sender, I am on vacation up to and including Sunday, July 10th, 2005 and I will be travelling on Monday and Tuesday after. My first day back in the office might be Wednesday, July 13th, 2005 - at which time I will have access to email again. If it's urgent you can try my mobile on Monday/Tues

Re: Scipy - Latex Annotations in plots

2005-07-06 Thread Matthias R.
Unfortunately matplotlib is only a 2D-plotting library. Do you know another one with 3D-capabilities as well? That would be very nice, thank you, Matthias Robert Kern wrote: > fortuneteller wrote: >> Hello, >> >> I'm quite new to python and Scipy. >> Anyway I want to use it to plot graphs.

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Dan Sommers
On Wed, 6 Jul 2005 20:42:51 +0200, Stian Søiland <[EMAIL PROTECTED]> wrote: > I'm all for it. I would even be tempted of changing def to function, > but it would look stupid in: > class A: > function make_my_day(self): > return "Your day" > a = A() > since a.

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Stian Søiland wrote: > On 2005-07-06 16:33:47, Ron Adam wrote: > > >>*No more NamesError exceptions! >> print value >> >> None > > > So you could do lot's of funny things like: > > def my_fun(extra_args=None): > if not extraargs: > print "Behave normally" >

Re: Use cases for del

2005-07-06 Thread Reinhold Birkenfeld
Ron Adam wrote: > Ron Adam wrote: > >> And accessing an undefined name returned None instead of a NameError? > > I retract this. ;-) > > It's not a good idea. But assigning to None as a way to unbind a name > may still be an option. IMO, it isn't. This would completely preclude the usage of

Re: Folding in vim

2005-07-06 Thread Bill Mill
On 7/6/05, Terry Hancock <[EMAIL PROTECTED]> wrote: > On Tuesday 05 July 2005 03:53 pm, Renato Ramonda wrote: > > Why not use just spaces? Vim simplifies this immensely: > > > > set tabstop=4 > > set shiftwidth=4 > > set expandtab > > set smarttab > > set autoindent > > > > AFAICT this gives me all

Re: Strange os.path.exists() behaviour

2005-07-06 Thread Jeff Epler
Pierre wrote: > Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 ^^^ Here's the bug. You're using Windows. It's a filesystem, but not as we know it... Anyway, You are getting exactly what the

Strange os.path.exists() behaviour

2005-07-06 Thread Pierre Quentel
os.path.exists(path) returns True if "path" exists But on Windows it also returns True for "path" followed by any number of dots : Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >

Re: inheriting file object

2005-07-06 Thread Jeremy
harold fellermann wrote: >>I don't know if I should be inheriting file or just using a file >>object. >> How would I determine which one would be more appropriate? > > > Inheritance is often refered to as an IS relation, whereas using an > attribute > is a HAS relation. > > If you inherit fro

Re: flatten(), [was Re: map/filter/reduce/lambda opinions ...]

2005-07-06 Thread Stian Søiland
On 2005-07-06 00:50:30, Ron Adam wrote: > This is probably the more correct way to do it. :-) > > def flatten(seq): > i = 0 > while i!=len(seq): > while isinstance(seq[i],list): > seq[i:i+1]=seq[i] > i+=1 > return seq Or what about a recursive genera

Re: from date/time string to seconds since epoch

2005-07-06 Thread Peter Kleiweg
[EMAIL PROTECTED] schreef op de 6e dag van de hooimaand van het jaar 2005: > You can calculate the offset of where you are like this: > > [EMAIL PROTECTED]:~ $ python > Python 2.4.1 (#2, Mar 30 2005, 21:51:10) > [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2 > Type "help", "copyright", "credits"

Re: map/filter/reduce/lambda opinions and backgroundunscientificmini-survey

2005-07-06 Thread Terry Reedy
"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Terry Reedy" <[EMAIL PROTECTED]> wrote: > >> "George Sakkis" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > Still it's hard to explain why four specific python keywords - def, >> > del, exec and el

Re: Use cases for del

2005-07-06 Thread Ron Adam
Ron Adam wrote: > And accessing an undefined name returned None instead of a NameError? I retract this. ;-) It's not a good idea. But assigning to None as a way to unbind a name may still be an option. -- http://mail.python.org/mailman/listinfo/python-list

RE: How do you program in Python?

2005-07-06 Thread Sells, Fred
I'm old school and have been very happy with emacs (on windows) and the python extensions. I just edit my file and hit control-C twice and it runs. I'm also using eclipse with PyDev and it's ok, but sluggish. -Original Message- From: anthonyberet [mailto:[EMAIL PROTECTED] Sent: Sunday, Ju

Re: threads and sleep?

2005-07-06 Thread Jonathan Ellis
Peter Hansen wrote: > Jonathan Ellis wrote: > > Peter Hansen wrote: > >>Or investigate the use of Irmen's Pyro package and how it could let you > >>almost transparently move your code to a *multi-process* architecture > > > > Unless you're doing anything that would require distributed locking. > >

Re: Avoiding NameError by defaulting to None

2005-07-06 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: > >> Dan Sommers wrote: >> >>> Lots more hard-to-find errors from code like this: >>> filehandle = open( 'somefile' ) >>> do_something_with_an_open_file( file_handle ) >>> filehandle.close( ) >> >> >> If do_something_with_an_open_file() is

RE: I am a Java Programmer

2005-07-06 Thread Sells, Fred
It takes great courage to turn from the dark side; let the pforce be with you. Also, go to Borders, get the python books and a Latte and figure out if one of the many books is written in a style that you like. -Original Message- From: bruno modulix [mailto:[EMAIL PROTECTED] Sent: Monday,

Re: from date/time string to seconds since epoch

2005-07-06 Thread [EMAIL PROTECTED]
You can calculate the offset of where you are like this: [EMAIL PROTECTED]:~ $ python Python 2.4.1 (#2, Mar 30 2005, 21:51:10) [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. py> import time py> offset = 0 py> if time.daylight:

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Ron Adam
Dan Sommers wrote: >> AttributeError: 'NoneType' object has no attribute 'read' > > > This is the one of which I was thinking. So you see this error at the > end of a (long) traceback, and try to figure out where along the (long) > line of function calls I typed the wrong name. Currently,

Re: Use cases for del

2005-07-06 Thread Benji York
Stian Søiland wrote: > Yes, and we can make > > someunknownlist[] = 2 > > magically do someunknownlist = list() and append 2. I hope you're being sarcastic. :) If not, why don't you like: some_list = [2] -- Benji York -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-06 Thread Stian Søiland
On 2005-07-06 07:00:04, Steven D'Aprano wrote: > map(lambda x: if x == 0: 1; else: math.sin(x)/x, > myList) And now for the "readable" list comprehension version: [x==0 and 1 or math.sin(x)/x for x in myList] Now even though I'm into the short-circuiting of and-or and even occasionally

from date/time string to seconds since epoch

2005-07-06 Thread Peter Kleiweg
Is there a safe and clean way to parse a date/time string into seconds since epoch? I have a string with date and time in GMT. I can get the correct value using this: #!/usr/bin/env python import os os.environ['TZ'] = 'UTC' import time s = 'Wed, 06 Jul 2005 16:49:38 GMT' seconds = time.mktime(t

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Stian Søiland
On 2005-07-06 16:33:47, Ron Adam wrote: > *No more NamesError exceptions! > print value > >> None So you could do lot's of funny things like: def my_fun(extra_args=None): if not extraargs: print "Behave normally" extra_args = 1337 if ext

Re: The GIL, callbacks, and GPFs

2005-07-06 Thread Thomas Heller
Francois De Serres <[EMAIL PROTECTED]> writes: > Hello, > > I'm chasing a GPF in the interpreter when running my extension module. > It's not very elaborated, but uses a system (threaded) callback, and > therefore the GIL. > Help would be mucho appreciated. Here's the rough picture: > > static vo

Re: inheriting file object

2005-07-06 Thread harold fellermann
> I don't know if I should be inheriting file or just using a file > object. > How would I determine which one would be more appropriate? Inheritance is often refered to as an IS relation, whereas using an attribute is a HAS relation. If you inherit from file, all operations for files should

Re: Use cases for del

2005-07-06 Thread Stian Søiland
On 2005-07-06 18:10:16, Ron Adam wrote: > But what if assigning a name to None actually unbound it's name? > And accessing an undefined name returned None instead of a NameError? Yes, and we can make someunknownlist[] = 2 magically do someunknownlist = list() and append 2. Please. -- S

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Stian Søiland
On 2005-07-06 01:46:05, Steven D'Aprano wrote: > I had NEVER even heard the word "tuple" before learning Python. I spent > weeks mispelling it as "turple", and I finally had to look it up in a > dictionary to see if it was a real English word. Out of the four English > dictionaries in my house, no

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Stian Søiland
On 2005-07-06 02:46:27, George Sakkis wrote: > So, who would object the full-word versions for python 3K ? > def -> define > del -> delete > exec -> execute > elif -> else if I'm all for it. I would even be tempted of changing def to function, but it would look stupid in: class A: fu

Re: Good starterbook for learning Python?

2005-07-06 Thread Luis M. Gonzalez
Before buying a book, I suggest starting out with at least one of these beginners tutorials available in internet: - Non-Programmers Tutorial For Python by Josh Cogliati (honors.montana.edu/~jjc/easytut/easytut/) - A Byte of Python by Swaroop CH (www.byteofpython.info) There are many others, but

Re: inheriting file object

2005-07-06 Thread Jeremy
Jeremy Jones wrote: > Something like this? I put the following code in test_file.py: > > class MyFile(file): > def doing_something(self): > print "in my own method" > > > And used it like this: > > In [1]: import test_file > > In [2]: f = test_file.MyFile("foobar.file", "w") > >

Re: Good starterbook for learning Python?

2005-07-06 Thread Renato Ramonda
Lennart ha scritto: > Programming Python will I sell as a book that i read secondly, and use as a > reference. I'd like to suggest also "Thinking like a CS in python": a schoolbook used in real classes to teach the basis of programming. -- Renato Usi Fedora? F

Re: Folding in vim

2005-07-06 Thread Renato Ramonda
Terry Hancock ha scritto: > > Yep, this is what I just set up in my .vimrc. Works beautifully. And (you probably already know, but it could be of use to others) you can bind the activation of some or all of those commands to au (autocommand) depending on the file extension. That way you can

Re: Scipy - Latex Annotations in plots

2005-07-06 Thread Robert Kern
fortuneteller wrote: > Hello, > > I'm quite new to python and Scipy. > Anyway I want to use it to plot graphs. > Does anybody know if there is the possibility to use Latex in SciPy's > plotting functions like gplt? I don't believe so. matplotlib, however, does have this functionality in recent

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Dan Sommers
On Wed, 06 Jul 2005 15:18:31 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: > Dan Sommers wrote: >> On Wed, 06 Jul 2005 14:33:47 GMT, >> Ron Adam <[EMAIL PROTECTED]> wrote: >> >>> Since this is a Python 3k item... What would be the consequence of >>> making None the default value of an undefined name?

The GIL, callbacks, and GPFs

2005-07-06 Thread Francois De Serres
Hello, I'm chasing a GPF in the interpreter when running my extension module. It's not very elaborated, but uses a system (threaded) callback, and therefore the GIL. Help would be mucho appreciated. Here's the rough picture: win32_spam.c /* code here is unit-tested OK */ typedef st

Scipy - Latex Annotations in plots

2005-07-06 Thread fortuneteller
Hello, I'm quite new to python and Scipy. Anyway I want to use it to plot graphs. Does anybody know if there is the possibility to use Latex in SciPy's plotting functions like gplt? Thanks for your help, Matthias -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoiding NameError by defaulting to None

2005-07-06 Thread Scott David Daniels
Ron Adam wrote: > Dan Sommers wrote: >> Lots more hard-to-find errors from code like this: >> filehandle = open( 'somefile' ) >> do_something_with_an_open_file( file_handle ) >> filehandle.close( ) > > If do_something_with_an_open_file() is not defined. Then you will get: > TypeErr

Re: precision problems in base conversion of rational numbers

2005-07-06 Thread [EMAIL PROTECTED]
Raymond Hettinger wrote: > [Terry Hancock] > > > Needless to say, the conventional floating point numbers in Python > > > are actually stored as *binary*, which is why there is a "decimal" > > > module (which is new). > > > > > > If you're going to be converting between bases anyway, it probably

Re: inheriting file object

2005-07-06 Thread Jeremy Jones
Jeremy wrote: >Hello all, > I am trying to inherit the file object and don't know how to do it. I >need to open a file and perform operations on it in the class I am >writing. I know the simple syntax is: > >class MyClass(file): > ... > >but I don't know how to make it open the fil

Re: inheriting file object

2005-07-06 Thread harold fellermann
On 06.07.2005, at 18:58, Jeremy wrote: > Hello all, > I am trying to inherit the file object and don't know how to do it. I > need to open a file and perform operations on it in the class I am > writing. I know the simple syntax is: > > class MyClass(file): > ... > > but I don't kno

Re: frozenset question

2005-07-06 Thread George Sakkis
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > On Wed, 06 Jul 2005 14:25:30 +0100, Will McGugan wrote: > > No need for the 'premature optimization is the root of all evil' speech. > > I'm not trying to optimize anything - just enquiring about the nature of > > frozenset. If typing 'frozenset' over

inheriting file object

2005-07-06 Thread Jeremy
Hello all, I am trying to inherit the file object and don't know how to do it. I need to open a file and perform operations on it in the class I am writing. I know the simple syntax is: class MyClass(file): ... but I don't know how to make it open the file for reading/writing.

Re: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread Bengt Richter
On Wed, 06 Jul 2005 17:57:42 +0200, Thomas Heller <[EMAIL PROTECTED]> wrote: >I'm trying to implement __iter__ on an abstract base class while I don't >know whether subclasses support that or not. >Hope that makes sense, if not, this code should be clearer: > >class Base: >def __getattr__(self

Re: Lisp development with macros faster than Python development?..

2005-07-06 Thread jayessay
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I've been reading the beloved Paul Graham's "Hackers and Painters". > He claims he developed a web app at light speed using Lisp and lots > of macros. That was the original "yahoo store". > It got me curious if Lisp is inherently faster to devel

Re: Tkinter grid layout

2005-07-06 Thread Richard Lewis
On Wed, 06 Jul 2005 16:32:42 GMT, "William Gill" <[EMAIL PROTECTED]> said: > Excuse me for intruding, but I followed examples and ended up with a > similar architecture: > > from Tkinter import * > class MyMain(Frame): > def __init__(self, master): > self.root = m

Re: website catcher

2005-07-06 Thread Michael Ströder
jwaixs wrote: > I need some kind > of database that won't exit if the cgi-bin script has finished. This > database need to be open all the time and communicate very easily with > the cgi-bin framwork main class. Maybe long-running multi-threaded processes for FastCGI, SCGI or similar is what you'r

  1   2   3   >