Re: Insert missing keys using defaultdict

2010-03-11 Thread George Sakkis
On Mar 11, 5:02 pm, Gnarlodious wrote: > I am trying to grok this documentation but need > help:http://docs.python.org/library/collections.html#defaultdict-examples > > In a perfect world the dict looks like this: > plistDict={'Style':'ExternalURL', 'Ref':'http://Gnarlodious.com/', > 'Tip':'Open

Multiple import of the same module under different names

2010-03-11 Thread George Sakkis
The import mechanism is not very smart in identifying whether two modules imported under different name are actually the same module, at least when dealing with implicit relative imports and sys.path manipulation. However, at least in cases of plain file modules, the module's __file__ would be adeq

Re: When will Python go mainstream like Java?

2010-02-23 Thread George Sakkis
On Feb 23, 3:49 pm, mk wrote: > Well I for one wouldn't want Python to go exactly Java way, see this: > > http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=jav... > > This is the percentage of job offers in UK where the keyword "Java" appears. > > Same for C#, it looks like C# is

To (monkey)patch or not to (monkey)patch, that is the question

2010-02-09 Thread George Sakkis
I was talking to a colleague about one rather unexpected/undesired (though not buggy) behavior of some package we use. Although there is an easy fix (or at least workaround) on our end without any apparent side effect, he strongly suggested extending the relevant code by hard patching it and postin

Re: Your beloved python features

2010-02-04 Thread George Sakkis
On Feb 5, 2:45 am, "Bruce C. Baker" wrote: > "Terry Reedy" wrote in message > > news:mailman.1929.1265328905.28905.python-l...@python.org... > > > Iterators, and in particular, generators. > > A killer feature. > > > Terry Jan Reedy +1, iterators/generators is among Python's best features for m

Re: Symbols as parameters?

2010-01-24 Thread George Sakkis
On Jan 25, 1:05 am, Steven D'Aprano wrote: > On Sun, 24 Jan 2010 10:11:07 -0800, George Sakkis wrote: > > Both in your example and by using a context manager, you can get away > > with not passing locals() explicitly by introspecting the stack frame. > > You say that as

Re: Symbols as parameters?

2010-01-24 Thread George Sakkis
On Jan 22, 8:39 pm, Martin Drautzburg wrote: > Martin Drautzburg wrote: > >> with scope(): > >>     # ... > >>     # use up, down, left, right here > > >> # up, down, left, right no longer defined after the with block exits. > > Just looked it up again. It's a cool thing. Too bad my locals() hack

PyTrie 0.1

2009-12-21 Thread George Sakkis
I'm pleased to announce the first release of PyTrie, a pure Python implementation of the trie (prefix tree) data structure [1]. Tries extend the mapping interface with methods that facilitate finding the keys/values/items for a given prefix, and vice versa, finding the prefixes (or just the longes

int rich comparisons

2009-10-02 Thread George Sakkis
I stumbled upon the following strangeness (python 2.6.2): >>> getattr(int, '__gt__') >>> getattr(5, '__gt__') Traceback (most recent call last):n File "", line 1, in AttributeError: 'int' object has no attribute '__gt__' Is this a bug ? George -- http://mail.python.org/mailman/listinfo/pyt

Re: [Python-ideas] possible attribute-oriented class

2009-09-04 Thread George Sakkis
On Fri, Sep 4, 2009 at 4:37 PM, Jan Kaliszewski wrote: > 04-09-2009 Ken Newton wrote: > >> I like this version very much. I'm ready to put this into practice to see >> how it works in practice. > > [snip] > > Not only you (Ken) and me. :-) It appears that the idea is quite old. Nick > Coghlan repl

Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

2009-07-22 Thread George Sakkis
On Jul 22, 12:45 pm, William Dode wrote: > On 22-07-2009, George Sakkis wrote: > > > > > On Jul 22, 7:38 am, William Dode wrote: > > >> I updated the script (python, c and java) with your unrolled version > >> + somes litle thinks. > > >> I als

Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

2009-07-22 Thread George Sakkis
On Jul 22, 7:38 am, William Dode wrote: > I updated the script (python, c and java) with your unrolled version > + somes litle thinks. > > I also tried with python3.1, unladen Q2, ironpython1.1.1 > > Unfortunately it doesn't work more with shedskin, i'll see on the > shedskin group... > > c 1.85s

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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

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: 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

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: 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: 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: 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: 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: 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, 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: 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

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 >>>

Preserving file permissions with distutils

2009-01-14 Thread George Sakkis
I'm trying to use distutils to install some package data and additional files, some of which may be executable. It turns out that distutils does not preserve the permissions. Digging in the code, there is the following comment on distutils/command/build_py: # XXX copy_file by default prese

Re: Python is slow

2008-12-15 Thread George Sakkis
On Dec 15, 8:15 am, Luis M. González wrote: > On Dec 15, 1:38 am, cm_gui wrote: > > > hahaha, do you know how much money they are spending on hardware to > > make > > youtube.com fast??? > > > > By the way... I know of a very slow Python site called YouTube.com. In > > > fact, it is so slow that

Re: Python is slow

2008-12-10 Thread George Sakkis
On Dec 10, 1:42 pm, cm_gui <[EMAIL PROTECTED]> wrote: > http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-... > > I fully agree with Krzysztof Kowalczyk . > Can't they build a faster VM for Python since they love the language > so much? WTF is Krzysztof Kowalczyk and why should

Re: Best way to report progress at fixed intervals

2008-12-10 Thread George Sakkis
On Dec 10, 2:50 am, Slaunger <[EMAIL PROTECTED]> wrote: > > Sorry, apparently I did not realize that at first sight. Anyway, I'd > rather avoid using further external modules besides the standard > batteries, as I would have to update several workstations with > different OSes (some of which I do n

Re: Best way to report progress at fixed intervals

2008-12-09 Thread George Sakkis
On Dec 9, 11:40 am, Slaunger <[EMAIL PROTECTED]> wrote: > I would therefore like some feedback on this proposed generic "report > progress at regular intervals" approach presented here. What could I > do better? There is a pypi package that might do what you're looking for (haven't used it though

Re: "as" keyword woes

2008-12-09 Thread George Sakkis
On Dec 9, 9:28 am, MRAB <[EMAIL PROTECTED]> wrote: > I certainly wouldn't want something like PL/I, where "IF", "THEN" and > "ELSE" could be identifiers, so you could have code like: > >      IF IF = THEN THEN >          THEN = ELSE; >      ELSE >          ELSE = IF; Although I agree with the sen

Re: How to initialize a class variable once

2008-12-09 Thread George Sakkis
On Dec 9, 10:36 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Dec 9, 2008, at 4:31 AM, Brian Allen Vanderburg II wrote: > > > There is one situation where a module can be imported/executed   > > twice, if it is the __main__ module. > > That's an excellent point -- this is something I've run into,

Re: Rich Comparisons Gotcha

2008-12-07 Thread George Sakkis
On Dec 7, 6:37 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sun, 07 Dec 2008 23:20:12 +, Steven D'Aprano wrote: > > On Sun, 07 Dec 2008 15:32:53 -0600, Robert Kern wrote: > > >> Rasmus Fogh wrote: > > >>> Current behaviour is both inconsistent and counterintuitive, as

Re: how to get a beep, OS independent ?

2008-12-07 Thread George Sakkis
On Dec 7, 7:49 am, Stef Mientki <[EMAIL PROTECTED]> wrote: > Chris Rebert wrote: > > On Sun, Dec 7, 2008 at 1:27 AM, Stef Mientki <[EMAIL PROTECTED]> wrote: > > >> Rainy wrote: > > >>> On Dec 6, 3:40 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > > hello, > > I want to give a small beep,

Re: Don't you just love writing this sort of thing :)

2008-12-05 Thread George Sakkis
On Dec 5, 8:06 am, Marco Mariani <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > Gosh Lawrence, do tell, which category do YOU fall into? > > I suppose a mix-up between a cowbody (or Fonzie) coder and a troll. Naah.. more likely an (ex?) Lisper/Schemer. -- http://mail.python.org/mailman/li

Re: RELEASED Python 3.0 final

2008-12-04 Thread George Sakkis
On Dec 4, 4:49 pm, [EMAIL PROTECTED] wrote: >     Andreas> Whenever has it been a pythonic ideal to "not allow" stuff? You >     Andreas> get warnings. Everything else is up to you. > > It's more than warnings.  With properly crafted combinations of spaces and > tabs you can get code which looks l

Re: Python 3 read() function

2008-12-04 Thread George Sakkis
On Dec 4, 2:01 pm, Дамјан Георгиевски <[EMAIL PROTECTED]> wrote: > > I don't think it matters.  Here's a quick comparison between 2.5 and > > 3.0 on a relatively small 17 meg file: > > > C:\>c:\Python30\python -m timeit -n 1 > > "open('C:\\work\\temp\\bppd_vsub.csv', 'rb').read()" > > 1 loops, best

Re: Overriding a method at the instance level on a subclass of a builtin type

2008-12-04 Thread George Sakkis
On Dec 4, 1:03 pm, "Zac Burns" <[EMAIL PROTECTED]> wrote: > Ok... but why are the special methods handled differently? Because otherwise they wouldn't be special ;-) And also for performance and implementation reasons I believe. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding a method at the instance level on a subclass of a builtin type

2008-12-04 Thread George Sakkis
On Dec 4, 12:31 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > "Zac Burns" <[EMAIL PROTECTED]> writes: > > The class method seems to be the most promising, however I have more > > 'state' methods to worry about so I might end up building new classes > > on the fly rather than have a class per pe

Re: Pythonic design patterns

2008-12-04 Thread George Sakkis
On Dec 4, 10:02 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 04 Dec 2008 01:09:08 -0800, Slaunger wrote: > > I find myself spending a lot of time in Python making some designs, to > > solve some task, which is the end turn out to be closely related to well > > establi

Re: Mathematica 7 compares to other languages

2008-12-02 Thread George Sakkis
On Dec 2, 4:57 pm, Lew <[EMAIL PROTECTED]> wrote: > There is no reason for you to engage in an /ad hominem/ attack.  It > does not speak well of you to resort to deflection when someone > expresses a contrary opinion, as you did with both Jon Harrop and with > me.  I suggest that your ideas will b

Re: Overriding a method at the instance level on a subclass of a builtin type

2008-12-02 Thread George Sakkis
On Dec 2, 7:58 pm, "Zac Burns" <[EMAIL PROTECTED]> wrote: > Sorry for the long subject. > > I'm trying to create a subclass dictionary that runs extra init code > on the first __getitem__ call. However, the performance of __getitem__ > is quite important - so I'm trying in the subclassed __getitem

Re: Scanner class

2008-12-02 Thread George Sakkis
On Dec 1, 5:42 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > Is there any stdlib or (more likely) 3rd party module that provides a > > similar functionality to the java.util.Scanner class [1] ? If not, > > would th

Re: How to instantiate in a lazy way?

2008-12-02 Thread George Sakkis
On Dec 2, 10:01 am, Slaunger <[EMAIL PROTECTED]> wrote: > Just wanted to show the end result in its actual implementation! > > I ended up *not* making a decorator, as I already had a good idea > about how to do it > using __getattr__ > > class PayloadDualFrqIQOnDemand(PayloadDualFrqIQ): >     """ >

Scanner class

2008-12-01 Thread George Sakkis
Is there any stdlib or (more likely) 3rd party module that provides a similar functionality to the java.util.Scanner class [1] ? If not, would there be any interest in porting it (with a more Pythonic API of course) or are there better alternatives ? George [1] http://java.sun.com/j2se/1.5.0/docs

Re: HELP!...Google SketchUp needs a Python API

2008-11-28 Thread George Sakkis
On Nov 28, 4:16 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Now, up up and away into my killfilter, Ditto; apparently it's either a troll or an 8-year old. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Great exercise for python expert !

2008-11-28 Thread George Sakkis
On Nov 28, 9:19 am, manatlan <[EMAIL PROTECTED]> wrote: > On 28 nov, 14:58, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Nov 28, 5:36 am, manatlan <[EMAIL PROTECTED]> wrote: > > > > I'd like to make

Re: Great exercise for python expert !

2008-11-28 Thread George Sakkis
On Nov 28, 5:36 am, manatlan <[EMAIL PROTECTED]> wrote: > I'd like to make a "jquery python wrapper" ... > > here is my code : > === > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > class JQueryCaller(object): >     def __init__(s

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread George Sakkis
On Nov 27, 10:45 pm, r <[EMAIL PROTECTED]> wrote: > I am still flabbergasted by the solid resistance to promoting Python. > Here of all places, NOT even one person(well Terry did kinda half > agree with me =), wants to support Python. I am completely perplexed. > I had to check and make sure this

Re: Applying a decorator to a module

2008-11-27 Thread George Sakkis
On Nov 27, 2:54 pm, lkcl <[EMAIL PROTECTED]> wrote: > On Nov 27, 7:43 pm, [EMAIL PROTECTED] wrote: > > >     lkcl> Very simple question: how do you apply a decorator to an entire > >     lkcl> module? > > > Function-by-function or class-by-class.  There is no decorator support for > > modules. > >

Re: what's so difficult about namespace?

2008-11-26 Thread George Sakkis
On Nov 26, 11:42 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Xah Lee wrote: > >> The IT community has enough trouble getting a few ISPs to upgrade their > >> DNS software. How are you going to get millions of general users to > >> upgrade? > > > alright, that's speaks for Javascript. > > > But h

Re: Instance attributes vs method arguments

2008-11-25 Thread George Sakkis
On Nov 25, 8:49 pm, John O'Hagan <[EMAIL PROTECTED]> wrote: > is there an > difference in efficiency (for large enough number of methods and arguments) > between > > a) passing all arguments to __init__() and accessing them via self within > individual methods: > > class = Class(all_class_args) >

Re: end of print = lower productivity ?

2008-11-25 Thread George Sakkis
On Nov 25, 5:03 pm, Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > > BUT you now can do > > > >>> p = print > > > >>> p("f") > > All right. Let's talk about that. > > > When I write "print", it is both effortless and instantaneous : my > > hands do not move, a wave goe

Re: end of print = lower productivity ?

2008-11-25 Thread George Sakkis
On Nov 25, 10:52 am, [EMAIL PROTECTED] wrote: >     >> Now the print statement disappeared, and I have to write print("f") >     >> instead. These parentheses not only take time to write, they also make >     >> me think twice about using print for debugging purposes. Pressing < >     >> SHIFT > th

Re: Python 3 __cmp__ semantic change?

2008-11-23 Thread George Sakkis
On Nov 23, 6:14 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > So how did I get it into my head that defining __eq__ would create the > correct behaviour for __ne__ automatically?  And more puzzlingly, how > come it is what actually happens?  Which should I believe: the > documentation or the i

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

2008-11-22 Thread George Sakkis
On Nov 22, 9:32 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote: > > >> I have a function that takes a reference to a class, > > > Hmmm... how do you do that from Python code? The simplest way I can   > > think > > of is to extract the name of the clas

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

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: 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: 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: 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: 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, 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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, 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: 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: 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: 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: 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: 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: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: 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-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

  1   2   3   4   5   6   7   8   9   10   >