Re: Regexp parser and generator

2008-11-05 Thread George Sakkis
On Nov 4, 3:30 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > Is there any package that parses regular expressions and returns an > > AST ? Something like: > > >>>> parse_rx(r'i (love|hate) h(is|er) (cat|dog)s?\s*!+') >

Re: using exec() to instantiate a new object.

2008-11-10 Thread George Sakkis
On Nov 10, 10:37 am, RyanN <[EMAIL PROTECTED]> wrote: > On Nov 10, 7:47 am, RyanN wrote: > > > Thank you both, I knew there had to be a good way of doing this. > > > -Ryan > > Just an update. I used dictionaries to hold objects and their names. > I'm beginning to understand better. Now to apply th

Re: Python 3.0 - is this true?

2008-11-10 Thread George Sakkis
On Nov 10, 4:10 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: > > Your > > choice of containers is not based on any theoretical arguments of what each > > type was intended to represent, but the cold hard reality of what > > operations they support. > > Right. What seems missi

Re: Python 3.0 - is this true?

2008-11-10 Thread George Sakkis
On Nov 10, 2:21 pm, [EMAIL PROTECTED] wrote: > So you could say that 3.0 is forcing us to acknowledge database > > > reality ;-) > > (Again) huh? > Reality in databases is that NULL *is* comparable. > "NULL==something" returns False, it doesn't raise an error. Given that in SQL "NULL `op` somethi

Re: First post, recursive references with pickle.

2008-11-10 Thread George Sakkis
On Nov 10, 2:23 pm, mark starnes <[EMAIL PROTECTED]> wrote: > Hi everyone, this is my first post to this group, so please be gentle. > > I've written a class which, when I attempt to pickle, gives the error: > > *** RuntimeError: maximum recursion depth exceeded > > Is there a way to make pickle d

Re: Python 3.0 - is this true?

2008-11-11 Thread George Sakkis
On Nov 11, 8:02 am, "M.-A. Lemburg" <[EMAIL PROTECTED]> wrote: > On 2008-11-11 02:10, Steven D'Aprano wrote: > > > On Mon, 10 Nov 2008 12:51:51 +, Duncan Grisby wrote: > > >> I have an object database written in Python. It, like Python, is > >> dynamically typed. It heavily relies on being able

Re: duck-type-checking?

2008-11-12 Thread George Sakkis
On Nov 12, 1:35 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Cristina Yenyxe González García wrote: > > > 2008/11/12 Joe Strout <[EMAIL PROTECTED]>: > >> So I need functions to assert that a given identifier quacks like a string, > >> or a number, or a sequence, or a mutable sequence, or a certain

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-12 Thread George Sakkis
On Nov 12, 4:05 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > greg wrote: > >> It's not only misleading, it's also a seriously flawed reading of the > >> original text - the Algol 60 report explicitly talks about assignment > >> of *values*. > > > Do you agree that an expression in Python has a v

Re: duck-type-checking?

2008-11-13 Thread George Sakkis
On Nov 13, 10:15 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 12, 2008, at 7:32 PM, Steven D'Aprano wrote: > > > While the recipe is great, it can be tiresome to apply all the time. I > > would factor out the checks into a function, something like this: > > > def isstringlike(obj, methods=Non

Re: using "private" parameters as static storage?

2008-11-13 Thread George Sakkis
On Nov 13, 9:22 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > Steve wrote: > > This is a pretty bizarre requirement, IMHO. The normal place to keep > > such information is either class variables or instance variables. > > Holy cow, I thought it was just Chris, but there were half a dozen   > similar

Re: duck-type-checking?

2008-11-13 Thread George Sakkis
On Nov 13, 10:55 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Take this example: > > def foo(alist): >     alist.sort() >     alist.append(5) > > The argument can be any object with sort and append methods (assumed to > act in place). But what happens if you pass it an objec

Re: duck-type-checking?

2008-11-14 Thread George Sakkis
On Nov 14, 4:49 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > So things like this should suffice: > >         # simple element >         assert(is_stringlike(foo)) >         assert(is_numeric(foo)) >         assert(is_like(foo, Duck)) > >         # sequence of elements >         assert(seqof_stringl

Re: object creation

2008-11-14 Thread George Sakkis
On Nov 14, 5:16 pm, BiraRai <[EMAIL PROTECTED]> wrote: > for record in roll: >     x = box() >     x.createSomething(record) >     do something > > Can anyone tell me why python keeps return the original object x that > was created in the FOR loop.  I want to instantiate a new x object for > e

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-16 Thread George Sakkis
On Nov 16, 2:05 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > > On Sat, 15 Nov 2008 01:40:04 -0800, Rick Giuly wrote: > > >> Hello All, > > >> Why is python designed so that b and c (according to code below) > >> actually share the same list object

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-16 Thread George Sakkis
On Nov 16, 8:28 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > > +1. Understanding and accepting the current behavior (mainly because > > of the extra performance penalty of evaluating the default expressions > > on every call would incur) is one thing, claiming that it is somehow > > natural is p

Re: Need help in understanding a python code

2008-11-16 Thread George Sakkis
On Nov 16, 7:34 am, John Machin <[EMAIL PROTECTED]> wrote: > On Nov 16, 11:04 pm, Steven D'Aprano <[EMAIL PROTECTED] > > >http://en.wikipedia.org/wiki/Style_over_substance_fallacy > > Quoted Wikipedia -> instant disqualification -> you lose. Good night. When quoting wikipedia became the new Godwin

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-16 Thread George Sakkis
On Nov 16, 2:30 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > On Sun, Nov 16, 2008 at 11:02 AM, George Sakkis <[EMAIL PROTECTED]> wrote: > > On Nov 16, 8:28 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > >> "Less obvious" is entirel

Re: Python and Its Libraries--Who's on First?

2008-11-17 Thread George Sakkis
On Nov 17, 12:25 am, "W. eWatson" <[EMAIL PROTECTED]> wrote: > Is there some repository that says something like for Python 2.5 it works > with: > > Win OSes: W2K, XP, Vista > numpy vers y, matplotlib vers x. scipy z, etc. http://www.catb.org/~esr/faqs/smart-questions.html#writewell -- http://mai

Re: Python-URL! - weekly Python news and links (Nov 17)

2008-11-17 Thread George Sakkis
On Nov 17, 12:44 pm, [EMAIL PROTECTED] wrote: > On Nov 17, 8:54 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > >     Candidate to *Longest and Most Boring Thread of the Year* - started > >     more than a month ago, currently discussing "The official definition > >     of call-by-value",

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-19 Thread George Sakkis
On Nov 19, 8:41 am, Rick Giuly <[EMAIL PROTECTED]> wrote: > Python provides, for the most part, an *excellent* user > interface to the programmer. Why not make it even "better" > by evaluating the arguments each time the function is called? > It will be harder to change the language 10 years from

Re: More elegant way to try running a function X times?

2008-11-19 Thread George Sakkis
On Nov 19, 10:21 am, Gilles Ganault <[EMAIL PROTECTED]> wrote: > On 19 Nov 2008 14:37:06 + (GMT), Sion Arrowsmith > > <[EMAIL PROTECTED]> wrote: > >Note very carefully that the "else" goes with the "for" and not the "if". > > Thanks guys. And if you end up doing this for several different fun

Re: python vs smalltalk 80

2008-11-19 Thread George Sakkis
On Nov 19, 1:53 am, gavino <[EMAIL PROTECTED]> wrote: > python vs smalltalk 80 > > which is nicer? Dunno but there's an interesting talk about this: http://www.youtube.com/watch?v=oHg5SJYRHA0 -- http://mail.python.org/mailman/listinfo/python-list

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-19 Thread George Sakkis
On Nov 19, 1:05 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Wed, 19 Nov 2008 05:41:57 -0800 (PST), Rick Giuly > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > (By "better" I mean that over many years of time programmers will be > > more productive because the

Re: Using eval, or something like it...

2008-11-19 Thread George Sakkis
On Nov 19, 7:44 pm, r0g <[EMAIL PROTECTED]> wrote: > Hi There, > > I know you can use eval to dynamically generate the name of a function > you may want to call. Can it (or some equivalent method) also be used to > do the same thing for the variables of a class e.g. > > class Foo(): >   bar = 1 >  

Re: help with comparison

2008-11-19 Thread George Sakkis
On Nov 19, 10:21 pm, tekion <[EMAIL PROTECTED]> wrote: > Hi, > Could some one take a look at the below code snipet which keep > failing: > > import optparse > p = optparse.OptionParser(description="script to do stuff", > prog="myscript.py", ) > p.add_option("-c" "--compress", help="0 is noncomp

Re: function parameter scope python 2.5.2

2008-11-20 Thread George Sakkis
On Nov 20, 6:40 pm, J Kenneth King <[EMAIL PROTECTED]> wrote: > J Kenneth King <[EMAIL PROTECTED]> writes: > > > > > I recently encountered some interesting behaviour that looks like a bug > > to me, but I can't find the appropriate reference to any specifications > > to clarify whether it is a bug

Re: Python 3 __cmp__ semantic change?

2008-11-20 Thread George Sakkis
On Nov 20, 6:58 pm, [EMAIL PROTECTED] wrote: >     Johannes> Seems it was removed on purpose - I'm sure there was a good >     Johannes> reason for that, but may I ask why? > > Start here: > >     http://www.mail-archive.com/[EMAIL PROTECTED]/msg11474.html > > Also, a comment to this blog post sug

Re: Using eval, or something like it...

2008-11-20 Thread George Sakkis
On Nov 20, 6:54 pm, r0g <[EMAIL PROTECTED]> wrote: > It would seem from this setattr function that the proper term for these > is 'attributes'. That for many years I have considered pretty much any > named thing that may vary a 'variable' might be at the root of the > problem here as it's a very u

Re: Need help converting text to csv format

2008-11-21 Thread George Sakkis
On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > Any help, pseudo code, or whatever push in the right direction would > be most appreciated.  I am a novice Python programmer but I do have a > good bit of PHP programming experience. I'm wondering if PHP experience precludes the abil

Re: Dynamic features used

2008-11-21 Thread George Sakkis
On Nov 21, 7:55 am, [EMAIL PROTECTED] wrote: > It's not easy to define what my point was :-) I try again, but the > following questions don't cover all the points: > - What are the dynamic features of Python that you use in your code? > (excluding ones that can can be done with a good static templ

Re: Need help converting text to csv format

2008-11-21 Thread George Sakkis
On Nov 21, 11:05 am, Steve Holden <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > > >> Any help, pseudo code, or whatever push in the right direction would > >> be most appreciated.  I a

Re: Need help converting text to csv format

2008-11-21 Thread George Sakkis
On Nov 21, 2:01 pm, Richard Riley <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > On Nov 21, 11:05 am, Steve Holden <[EMAIL PROTECTED]> wrote: > >> George Sakkis wrote: > >> > On Nov 21, 10:18 am, Chuck Connors <[EMAIL

Re: initialization in argument definitions

2008-11-21 Thread George Sakkis
On Nov 21, 4:25 pm, Brentt <[EMAIL PROTECTED]> wrote: > Hi, I know this is a terribly simple question, but the docs seem to be > designed for people who probably find a the answer to this question > terribly obvious. But its not at all obvious to me. Don't worry, it's not obvious to *anyone* new

Re: matching exactly a 4 digit number in python

2008-11-21 Thread George Sakkis
On Nov 21, 4:46 pm, harijay <[EMAIL PROTECTED]> wrote: > Hi > I am a few months new into python. I have used regexps before in perl > and java but am a little confused with this problem. > > I want to parse a number of strings and extract only those that > contain a 4 digit number anywhere inside

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread George Sakkis
On Nov 21, 5:11 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > I have a function that takes a reference to a class, and then   > instantiates that class (and then does several other things with the   > new instance).  This is easy enough: > >     item = cls(self, **itemArgs) > > where "cls" is the cla

Disable automatic interning

2009-03-18 Thread George Sakkis
Is there a way to turn off (either globally or explicitly per instance) the automatic interning optimization that happens for small integers and strings (and perhaps other types) ? I tried several workarounds but nothing worked: >>> 'x' is 'x' True >>> 'x' is 'x'+'' True >>> 'x' is ''+'x' True >>>

Re: How complex is complex?

2009-03-18 Thread George Sakkis
On Mar 18, 1:30 pm, Kottiyath wrote: > When we say readability counts over complexity, how do we define what > level of complexity is ok? > For example: > Say I have dict a = {'a': 2, 'c': 4, 'b': 3} > I want to increment the values by 1 for all keys in the dictionary. > So, should we do:>>> for

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 2:13 pm, "R. David Murray" wrote: > George Sakkis wrote: > > Is there a way to turn off (either globally or explicitly per > > instance) the automatic interning optimization that happens for small > > integers and strings (and perhaps other types) ? I tr

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 4:06 pm, Daniel Fetchinson wrote: > > I'm working on some graph generation problem where the node identity > > is significant (e.g. "if node1 is node2: # do something) but ideally I > > wouldn't want to impose any constraint on what a node is (i.e. require > > a base Node class). It's

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 4:50 pm, "andrew cooke" wrote: > this is completely normal (i do exactly this all the time), BUT you should > use "==", not "is".   Typically, but not always; for example check out the identity map [1] pattern used in SQLAlchemy [2]. George [1] http://martinfowler.com/eaaCatalog/ide

Re: Candidate for a new itertool

2009-03-18 Thread George Sakkis
On Mar 7, 8:47 pm, Raymond Hettinger wrote: > The existing groupby() itertool works great when every element in a > group has the same key, but it is not so handy when groups are > determined by boundary conditions. > > For edge-triggered events, we need to convert a boundary-event > predicate to

Re: simple iterator question

2009-04-02 Thread George Sakkis
On Apr 2, 8:32 am, Neal Becker wrote: > How do I interleave 2 sequences into a single sequence? > > How do I interleave N sequences into a single sequence? http://lmgtfy.com/?q=python+interleave+sequences http://code.activestate.com/recipes/511480/ http://code.activestate.com/recipes/528936/ HT

Re: Best way to extract from regex in if statement

2009-04-03 Thread George Sakkis
On Apr 3, 9:56 pm, Jon Clements wrote: > On 4 Apr, 02:14, bwgoudey wrote: > > > > > I have a lot of if/elif cases based on regular expressions that I'm using to > > filter stdin and using print to stdout. Often I want to print something > > matched within the regular expression and the moment I'v

Re: "Pythoner",Wish me luck!

2009-04-03 Thread George Sakkis
On Apr 3, 3:47 pm, barisa wrote: > On Apr 3, 8:58 pm, nrball...@gmail.com wrote: > > > > > On Apr 3, 12:33 pm, barisa wrote: > > > > On Apr 3, 11:39 am, "Hendrik van Rooyen" wrote: > > > > > "Matteo" wrote: > > > > > On Apr 3, 9:05 am, Linuxwell wrote: > > > > > >> Starting today I would like

Re: object knows which object called it?

2009-04-06 Thread George Sakkis
On Apr 6, 10:53 am, Reckoner wrote: > hi, > > I have the following problem: I have two objects, say, A and B, which > are both legitimate stand-alone objects with lives of their own. > > A contains B as a property, so I often do > > A.B.foo() > > the problem is that some functions inside of B actu

Returning different types based on input parameters

2009-04-06 Thread George Sakkis
That's more of a general API design question but I'd like to get an idea if and how things are different in Python context. AFAIK it's generally considered bad form (or worse) for functions/methods to return values of different "type" depending on the number, type and/or values of the passed parame

Re: Returning different types based on input parameters

2009-04-06 Thread George Sakkis
On Apr 6, 5:56 pm, MRAB wrote: > In your example I would possibly suggest returning a 'Result' object and > then later subclassing to give 'ConfidenceResult' which has the > additional 'confidence' attribute. That's indeed one option, but not very appealing if `Result` happens to be a builtin (e

Re: Returning different types based on input parameters

2009-04-06 Thread George Sakkis
On Apr 6, 7:57 pm, "andrew cooke" wrote: > andrew cooke wrote: > > George Sakkis wrote: > >> That's more of a general API design question but I'd like to get an > >> idea if and how things are different in Python context. AFAIK it's > &g

Re: Returning different types based on input parameters

2009-04-08 Thread George Sakkis
On Apr 7, 3:18 pm, Adam Olsen wrote: > On Apr 6, 3:02 pm, George Sakkis wrote: > > > For example, it is common for a function f(x) to expect x to be simply > > iterable, without caring of its exact type. Is it ok though for f to > > return a list for some types/values

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread George Sakkis
On Apr 11, 3:03 pm, Mike H wrote: > Can I not use the cursor.execute command to pass variables that aren't > immediately next to each other? If so, is there a better way to go > about solving this problem? Yes, there is. Use one of the several production quality python SQL toolkits built for exa

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread George Sakkis
nection) >>> result = conn.execute(ins) HTH, George [1] http://www.sqlalchemy.org/ [2] http://www.sqlobject.org/ [3] https://storm.canonical.com/ > On Sat, Apr 11, 2009 at 4:18 PM, George Sakkis > wrote: > > On Apr 11, 3:03 pm, Mike H wrote: > > >> Can I not use t

Re: absolute newbie: divide a list into sublists (nested lists?) of fixed length

2009-04-11 Thread George Sakkis
On Apr 11, 4:14 pm, ergconce...@googlemail.com wrote: > Hi, > I have a list looking like > > [ 0.84971586,  0.05786009,  0.9645675,  0.84971586,  0.05786009, > 0.9645675, 0.84971586,  0.05786009,  0.9645675,  0.84971586, > 0.05786009,  0.9645675] > > and I would like to break this list into subsets

Re: absolute newbie: divide a list into sublists (nested lists?) of fixed length

2009-04-11 Thread George Sakkis
On Apr 11, 6:05 pm, ergconce...@googlemail.com wrote: > On Apr 11, 11:18 pm, George Sakkis wrote: > > > > > The numpy import *is* important if you want to use numpy-specific > > features; there are many "tricks" you can do easily with numpy arrays > >

Re: Overriding methods per-object

2009-04-17 Thread George Sakkis
On Apr 17, 9:22 pm, Pavel Panchekha wrote: > I've got an object which has a method, __nonzero__ > The problem is, that method is attached to that object not that class > > > a = GeneralTypeOfObject() > > a.__nonzero__ = lambda: False > > a.__nonzero__() > > False > > But: > > > bool(a) > > True >

Re: The Python standard library and PEP8

2009-04-20 Thread George Sakkis
On Apr 19, 6:01 pm, "Martin P. Hellwig" > Besides, calling Python Object-Orientated is a bit of an insult :-). I > would say that Python is Ego-Orientated, it allows me to do what I want. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: ActiveState Komodo Edit?

2009-04-26 Thread George Sakkis
On Apr 26, 11:08 pm, John Doe wrote: > Having trouble tabifying a section of Python code. > Code -- Tabify Region > Does it work for anyone else? Yes it does, you have to select a region before (e.g. ctrl+A for the whole file). Regardless, the common standard indentation is 4 spaces; avoid tabs

Re: Self function

2009-05-09 Thread George Sakkis
On May 6, 10:32 pm, Luis Alberto Zarrabeitia Gomez wrote: > A bit offtopic: a while ago I think I saw a recipe for a decorator that, via > bytecode hacks, would bind otherwise global names to the local namespace of > the > function. Can anyone remember it/point me to it? Maybe you saw http://co

Re: Decorating methods - where do my arguments go?

2009-05-09 Thread George Sakkis
On May 8, 11:33 am, Mikael Olofsson wrote: > Hi all! > > I have long tried to avoid decorators, but now I find myself in a > situation where I think they can help. I seem to be able to decorate > functions, but I fail miserably when trying to decorate methods. The > information I have been able t

Re: Nimrod programming language

2009-05-12 Thread George Sakkis
On May 12, 12:49 pm, Mensanator wrote: > On May 12, 8:27 am, rump...@web.de wrote: > > > > > > The language and library are missing arbitrary precision integer > > > > > arithmetic, using GMP or something like that. > > > > > True, but currently not a high priority for me. > > > > Too bad. That ma

Re: introspection question: get return type

2009-05-14 Thread George Sakkis
On May 14, 3:55 pm, a...@pythoncraft.com (Aahz) wrote: > In article <4a0c6e42$0$12031$426a7...@news.free.fr>, > Bruno Desthuilliers   wrote: > > >Marco Mariani a écrit : > >> Bruno Desthuilliers wrote: > > >>> Oh, you meant the "return type" ? Nope, no way. It just doesn't make > >>> sense given Py

Re: Adding a Par construct to Python?

2009-05-18 Thread George Sakkis
On May 18, 5:27 am, jer...@martinfamily.freeserve.co.uk wrote: > My suggestion is primarily about using multiple threads and sharing > memory - something akin to the OpenMP directives that one of you has > mentioned. To do this efficiently would involve removing the Global > Interpreter Lock, or s

Re: Wrapping methods of built-in dict

2009-05-21 Thread George Sakkis
On May 21, 5:55 pm, shailesh wrote: > There doesn't seem to be a predicate returning method wrappers. Is > there an alternate way to query an object for attributes that are of > method wrappers? Sure: >>> MethodWrapper = type({}.__init__) >>> isinstance([].__len__, MethodWrapper) True But you'r

Re: How do I sample randomly based on some probability(wightage)?

2009-05-26 Thread George Sakkis
On May 26, 2:39 pm, Sumitava Mukherjee wrote: > Hi all, > I need to randomly sample from a list where all choices have weights > attached to them. The probability of them being choosen is dependent > on the weights. > If say Sample list of choices are [A,B,C,D,E] and weights of the same > are [0.8

Re: question about python statements

2008-05-12 Thread George Sakkis
On May 12, 7:35 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Ohad Frand" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | I am looking for a way to programmically get a list of all python > | existing statements that I cannot access by __builtins__ or locals() > | (like ["asse

Re: Is using range() in for loops really Pythonic?

2008-05-12 Thread George Sakkis
On May 12, 7:03 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Carl Banks <[EMAIL PROTECTED]> writes: > > IMHO, whether a varibale is used or not has got to be one of the least > > important things of all (in no small part because it's easily > > discernable from nearby code). > > I couldn't disagree

Re: how to get information of a running prog in python

2008-05-12 Thread George Sakkis
On May 12, 11:02 pm, Jimmy <[EMAIL PROTECTED]> wrote: > On May 13, 10:36 am, "Dan Upton" <[EMAIL PROTECTED]> wrote: > > > > > On Mon, May 12, 2008 at 10:19 PM, Jimmy <[EMAIL PROTECTED]> wrote: > > > Well, i know it may be a little non-python thing, however, I can think > > >  of no place better to

Re: Some comparison operators gone in Python 3.0?

2008-05-13 Thread George Sakkis
On May 13, 6:18 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 13 May 2008 06:34:03 -0300, <[EMAIL PROTECTED]> escribió: > > > Is that true that this comparison operators are gone in Python 3.0: > > > <    (is less than) > >>    (is greater than) > > <= (is less than or equals) > >> =

Re: I'm stuck in Python!

2008-05-13 Thread George Sakkis
On May 13, 9:46 am, Sanoski <[EMAIL PROTECTED]> wrote: > Any programming that helps you solve a problem is fun and > recreational. At least, that's how I look at it. I suppose it really > depends on why you're doing it, what your objective is, etc. But I'd > say, why not? You must be new here. It

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread George Sakkis
On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > An instance method works on the instance > > A Static method is basically a function nested within a class object > > A class method is overkill? > > If anything, a static method is overkill. See it this way: *if* you for some

Nasty gotcha/bug in heapq.nlargest/nsmallest

2008-05-14 Thread George Sakkis
I spent several hours debugging some bogus data results that turned out to be caused by the fact that heapq.nlargest doesn't respect rich comparisons: import heapq import random class X(object): def __init__(self, x): self.x=x def __repr__(self): return 'X(%s)' % self.

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread George Sakkis
On May 14, 4:38 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 14 mai, 16:30, George Sakkis <[EMAIL PROTECTED]> wrote: > > > On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > > > An instance me

Re: Nasty gotcha/bug in heapq.nlargest/nsmallest

2008-05-15 Thread George Sakkis
On May 15, 3:06 am, Peter Otten <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > I spent several hours debugging some bogus data results that turned > > out to be caused by the fact that heapq.nlargest doesn't respect rich > > comparisons: > > &g

Re: datamining .txt-files, library?

2008-05-15 Thread George Sakkis
On May 15, 8:27 am, globalrev <[EMAIL PROTECTED]> wrote: > i have a big collection of .txt files that i want to open and parse to > extract information. > > is there a library for this or maybe even built in? This has a lot to do with how well-structured are your files and what kind of information

Re: morning in Python

2008-05-16 Thread George Sakkis
On May 16, 11:58 am, "inhahe" <[EMAIL PROTECTED]> wrote: > I'm not an expert in this but what does it mean to emphasize state?  It > seems the opposite of that would be a) functional programming, and b) > passing parameters instead of using global or relatively local variables. > And maybe c) corou

Re: can't delete from a dictionary in a loop

2008-05-17 Thread George Sakkis
On May 16, 5:22 pm, "Dan Upton" <[EMAIL PROTECTED]> wrote: > This might be more information than necessary, but it's the best way I > can think of to describe the question without being too vague. > > The task: > > I have a list of processes (well, strings to execute said processes) > and I want to

Re: namespaces and eval

2008-05-20 Thread George Sakkis
On May 16, 5:02 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > Sorry for the repost, didnt' quite finish > > > Suppose I have a function in module X that calls eval e.g, > > > X.py > > ___ > > Def foo(bar): > >         Eval(bar) > > ___ > > > Now eval will b

Segmentation fault on updating a BYTEA field [psycopg2]

2008-05-21 Thread George Sakkis
I have a simple DB table that stores md5 signature pairs: Table "public.duplicate" Column | Type | Modifiers --+---+--- sig | bytea | not null orig_sig | bytea | not null Indexes: "duplicate_pkey" PRIMARY KEY, btree (sig) "ix_duplicate_orig_sig" btree (ori

Re: Segmentation fault on updating a BYTEA field [psycopg2]

2008-05-23 Thread George Sakkis
On May 21, 6:32 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > I have a simple DB table that stores md5 signature pairs: > >Table "public.duplicate" > Column | Type | Modifiers > --+---+--- > sig | bytea | not null >

Re: Assignment and comparison in one statement

2008-05-23 Thread George Sakkis
On May 23, 6:59 pm, Johannes Bauer <[EMAIL PROTECTED]> wrote: > Hello group, > > I'm just starting with Python and am extremely unexperienced with it so > far. Having a strong C/C++ background, I wish to do something like > > if (q = getchar()) { >         printf("%d\n", q); > > } > > or translated

Re: Hungarian Notation

2008-05-27 Thread George Sakkis
On May 27, 3:43 am, Paddy <[EMAIL PROTECTED]> wrote: > On May 27, 7:42 am, "inhahe" <[EMAIL PROTECTED]> wrote: > > > Well, I just need it once in a while. Actually now is the only time I > > remember. The last time what I needed was a file name extension. I want a > > string called headers, but

Re: Python and Flaming Thunder

2008-05-28 Thread George Sakkis
On May 28, 5:19 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Kind of like how this year's program won't work on next year's > > Python? > > For somebody who has admitted to have only very rudimentary knowledge of > python that's a pretty bold statement, don't you think? > > > Except Flam

Re: Writing a function from within Python

2008-05-28 Thread George Sakkis
On May 28, 4:39 pm, Aaron Scott <[EMAIL PROTECTED]> wrote: > Is it possible to change the content of a function after the function > has been created? For instance, say I make a class: > > class MyClass: > def ClassFunction(self): > return 1 > > And I

Re: How to add function return value

2008-05-31 Thread George Sakkis
On May 30, 10:16 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > On May 30, 6:21 pm, HYRY <[EMAIL PROTECTED]> wrote: > > > Can I write a decorator that it can automately do this conversion > > > def func1() > >     a = 1 > > > ---> > > > def func1(): > >     a = 1 > >     return locals() > > Not

Re: accumulator generators

2008-05-31 Thread George Sakkis
On May 31, 4:19 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Cameron <[EMAIL PROTECTED]> writes: > > I was reading this http://www.paulgraham.com/icad.html";>Paul > > Graham article and he builds an accumuator generator function in > > the appendix. His looks like this: > > > > > def foo(n):

ANN: equivalence 0.1

2008-06-01 Thread George Sakkis
Equivalence is a class that can be used to maintain a partition of objects into equivalence sets, making sure that the equivalence properties (reflexivity, symmetry, transitivity) are preserved. Two objects x and y are considered equivalent either implicitly (through a key function) or explicitly b

Re: Conjunction List

2008-06-01 Thread George Sakkis
On May 31, 8:01 pm, [EMAIL PROTECTED] wrote: > http://codepad.org/MV3k10AU > > I want to write like next one. > > def conjunction(number=a[1],name=b[1],size=c[1]): > flag = a[0]==b[0]==c[0] > if flag: > for e in zip(number,name,size): > print e > > conjunction(a,b,c) > > -

Re: convert binary to float

2008-06-01 Thread George Sakkis
On Jun 1, 3:55 pm, Mason <[EMAIL PROTECTED]> wrote: > I have tried and tried... > > I'd like to read in a binary file, convert it's 4 byte values into > floats, and then save as a .txt file. > > This works from the command line (import struct); > >     In [1]: f = open("test2.pc0", "rb") >     In [

Re: ANN: equivalence 0.1

2008-06-02 Thread George Sakkis
On Mon, Jun 2, 2008 at 6:31 AM, Giuseppe Ottaviano <[EMAIL PROTECTED]> wrote: > > On Jun 1, 2008, at 6:16 PM, George Sakkis wrote: > >> Equivalence is a class that can be used to maintain a partition of >> objects into equivalence sets, making sure that the equivalence

Re: Ideas for master's thesis

2008-06-02 Thread George Sakkis
On Jun 2, 7:53 pm, "Filip Gruszczyński" <[EMAIL PROTECTED]> wrote: > Hello there, > > I am student of CS at the University of Warsaw, currently 4th year. I > am attending Object Oriented Programming seminar and it is about time, > I started looking for an idea of my master's degree project. As I l

Re: Why does python not have a mechanism for data hiding?

2008-06-03 Thread George Sakkis
On Jun 3, 1:42 am, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jun 2, 10:23 pm, alex23 <[EMAIL PROTECTED]> wrote: > > > Then again, I have no issue with the current convention and personally > > find the idea of adding a "private" keyword makes as much sense as > > being able to syntactically define

Re: Constructor re-initialization issue

2008-06-03 Thread George Sakkis
On Jun 3, 6:11 pm, [EMAIL PROTECTED] wrote: > Hello all, > > I have come across this issue in Python and I cannot quite understand > what is going on. > > class Param(): > def __init__(self, data={}, condition=False): > if condition: > data['class']="Advanced" > pri

ANN: equivalence 0.2

2008-06-03 Thread George Sakkis
Equivalence v0.2 has been released. Also the project is now hosted at http://code.google.com/p/pyquivalence/ (the name 'equivalence' was already taken but the module is still called equivalence). Changes === - The internals were largely rewritten, but the API remained effectively intact. - A n

Re: Tuples part 2

2008-06-05 Thread George Sakkis
On Jun 5, 9:26 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jun 5, 1:37 am, [EMAIL PROTECTED] wrote: > > > > > [EMAIL PROTECTED]: > > > Do you mean something like this? (notice the many formatting > > differences, use a formatting similar to this one in your code) > > > coords = [] > > >

Re: Tuples part 2

2008-06-05 Thread George Sakkis
On Jun 5, 11:21 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On 5 июн, 18:56, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > > On 5 июн, 18:19, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > On Jun 5, 3:49 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > > On 5 ÉÀÎ, 01:57,

Re: Tuples part 2

2008-06-05 Thread George Sakkis
On Jun 5, 11:48 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On 5 июн, 19:38, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Jun 5, 11:21 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > On 5 июн, 18:56, Ivan Illarionov <[EMAIL PR

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread George Sakkis
On Jun 5, 2:07 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > The "private" keyword goes further and prevents > access even by derived classes. The double leading underscore in > Python does no such thing. Who develops these derived classes ? A competitor ? A malicious hacker ? A spammer ? Who are yo

Re: Web Crawler - Python or Perl?

2008-06-09 Thread George Sakkis
On Jun 9, 1:48 pm, [EMAIL PROTECTED] wrote: > Hi all, > I am currently planning to write my own web crawler. I know Python but > not Perl, and I am interested in knowing which of these two are a > better choice given the following scenario: > > 1) I/O issues: my biggest constraint in terms of reso

Confusion with weakref, __del__ and threading

2008-06-10 Thread George Sakkis
I'm baffled with a situation that involves: 1) an instance of some class that defines __del__, 2) a thread which is created, started and referenced by that instance, and 3) a weakref proxy to the instance that is passed to the thread instead of 'self', to prevent a cyclic reference. This probably

Producer-consumer threading problem

2008-06-10 Thread George Sakkis
I'd like some feedback on a solution to a variant of the producer- consumer problem. My first few attempts turned out to deadlock occasionally; this one seems to be deadlock-free so far but I can't tell if it's provably correct, and if so, whether it can be simplified. The generic producer-consume

Re: Producer-consumer threading problem

2008-06-10 Thread George Sakkis
On Jun 10, 11:47 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > > I had a little trouble understanding what exact problem it is that you are > trying to solve but I'm pretty sure that you can do it with one of two > methods: Ok, let me try again with a different example: I want to do what can be ea

<    5   6   7   8   9   10   11   12   >