[issue42409] Interpreter exit blocks waiting for ThreadPoolExecutor.map

2020-11-19 Thread George Sakkis
New submission from George Sakkis : ThreadPoolExecutor.map() prevents interpreter exit if there is a reference to the generator it returns. In the attached script: - `python threadpool_map.py run1` exits as soon as the exception is raised on the main thread. This is the desired behavior

[issue36662] asdict/astuple Dataclass methods

2019-04-19 Thread George Sakkis
George Sakkis added the comment: > I think the best thing to do is write another decorator that adds this > method. I've often thought that having a dataclasses_tools third-party module > would be a good idea. I'd be happy with a separate decorator in the standard library f

[issue36662] asdict/astuple Dataclass methods

2019-04-18 Thread George Sakkis
New submission from George Sakkis : I'd like to propose two new optional boolean parameters to the @dataclass() decorator, `asdict` and `astuple`, that if true, the respective methods are generated as equivalent to the module-level namesake functions. In addition to saving an extra imported

[issue2831] Adding start to enumerate()

2010-05-05 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Just discovered this by chance; I would probably have noticed it earlier if the docstring had been updated. Let me know if it needs a new documentation bug ticket and I'll create one. Pretty handy feature by the way, thanks for adding

[issue2090] __import__ with fromlist=

2010-04-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: FWIW attached is a patch that allows only valid identifiers before calling import_submodule(), and returns silently otherwise (for backwards compatibility). For the record, the reason that empty strings and some combinations of slashes

[issue2090] __import__ with fromlist=

2010-04-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: On the surface this seems like a potential directory traversal attack hole, although I couldn't get past 'pkg' by passing '../../../', so I guess there must be other checks before attempting the import. I rushed to post; it turns out

[issue2090] __import__ with fromlist=[''] causes double initialization of modules

2010-04-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Just bitten by this (through a 3rd party library that uses this pattern) and I'm wondering why it was closed as invalid. Passing a non-empty fromlist string also imports the tail module but without the side effect of double import, so

[issue2090] __import__ with fromlist=

2010-04-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: When you use an empty string in fromlist you are essentially simulating ``from pkg import`` which makes absolutely no sense, so no one has cared enough to try to fix this. ``from pkg import __bogus__, 123, @$%`` doesn't make sense

[issue2090] __import__ with fromlist=

2010-04-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: More fun findings: dots are special-cased too, but only if they don't appear consecutively (!); ~$ cat pkg/__init__.py print __name__ ~$ python -c __import__('pkg', fromlist=['.']) pkg pkg.. ~$ python -c __import__('pkg', fromlist

[issue1745] Backport of PEP 3102 keyword-only arguments to 2.6

2010-03-21 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Is there any update on this for 2.7 ? -- nosy: +gsakkis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745

[issue1745] Backport of PEP 3102 keyword-only arguments to 2.6

2010-03-21 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: FWIW I updated the patch to r79264; it applies cleanly and passes the tests but other than that I can't tell if it's ready. It would be nice to have it in 2.7 though. -- Added file: http://bugs.python.org/file16618/backport

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
Changes by George Sakkis george.sak...@gmail.com: Removed file: http://bugs.python.org/file16579/getcallargs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3135

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Renamed the Testcase classes to conform with the rest in test_inspect.py, added a few more tests for tuple args and patched against the latest trunk (r79086). -- Added file: http://bugs.python.org/file16587/getcallargs.patch

[issue6474] Inconsistent TypeError message on function calls with wrong number of arguments

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Which version are you running ? I don't get the positional word in 2.6 and 2.7a4. In my opinion it should report how many required arguments are passed, regardless of how they are passed (positionally or by name). So in your example

[issue6474] Inconsistent TypeError message on function calls with wrong number of arguments

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Attached patch for displaying the number of missing required arguments. -- keywords: +patch Added file: http://bugs.python.org/file16589/6474.patch ___ Python tracker rep...@bugs.python.org

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: - Added docs in inspect.rst - Fixed TypeError message for zero-arg functions (takes no arguments instead of takes exactly 0 arguments) + added test. -- Added file: http://bugs.python.org/file16591/getcallargs2.patch

[issue3135] inspect.getcallargs()

2010-03-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Uploaded at http://codereview.appspot.com/659041/show -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3135

[issue8174] Misleading reported number of given arguments on function call TypeError

2010-03-18 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: The following exception message seems misleading, or at least not obvious: def f(a,b,c): pass ... f(c=0,a=0) Traceback (most recent call last): File stdin, line 1, in module TypeError: f() takes exactly 3 non-keyword arguments (1

[issue3135] inspect.getcallargs()

2010-03-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I reverted the function to the original API (return just the dict with the bindings), cleaned it up, wrote thorough unit tests and made a patch against Python 2.7a4. -- keywords: +patch Added file: http://bugs.python.org

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

Re: Insert missing keys using defaultdict

2010-03-11 Thread George Sakkis
On Mar 11, 5:02 pm, Gnarlodious gnarlodi...@gmail.com 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',

Re: When will Python go mainstream like Java?

2010-02-23 Thread George Sakkis
On Feb 23, 3:49 pm, mk mrk...@gmail.com 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

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

Re: Your beloved python features

2010-02-04 Thread George Sakkis
On Feb 5, 2:45 am, Bruce C. Baker b...@undisclosedlocation.net wrote: Terry Reedy tjre...@udel.edu 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

Re: Symbols as parameters?

2010-01-24 Thread George Sakkis
On Jan 22, 8:39 pm, Martin Drautzburg martin.drautzb...@web.de 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

Re: Symbols as parameters?

2010-01-24 Thread George Sakkis
On Jan 25, 1:05 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

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

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

int rich comparisons

2009-10-02 Thread George Sakkis
I stumbled upon the following strangeness (python 2.6.2): getattr(int, '__gt__') method-wrapper '__gt__' of type object at 0x822b7c0 getattr(5, '__gt__') Traceback (most recent call last):n File stdin, line 1, in module AttributeError: 'int' object has no attribute '__gt__' Is this a bug ?

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

2009-09-04 Thread George Sakkis
On Fri, Sep 4, 2009 at 4:37 PM, Jan Kaliszewskiz...@chopin.edu.pl wrote: 04-09-2009 Ken Newton krnew...@gmail.com 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

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 w...@flibuste.net 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...

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 w...@flibuste.net wrote: On 22-07-2009, George Sakkis wrote: On Jul 22, 7:38 am, William Dode w...@flibuste.net wrote: I updated the script (python, c and java) with your unrolled version + somes litle thinks. I also tried with python3.1, unladen Q2

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 sm...@cognobytes.com 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

Re: Wrapping methods of built-in dict

2009-05-21 Thread George Sakkis
On May 21, 5:55 pm, shailesh kochhar...@gmail.com 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)

[issue5982] classmethod, staticmethod: expose wrapped function

2009-05-19 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I don't remember the exact use case but it had to do with making a decorator robust enough to work for different kinds of callables (and a few common non-callables such as classmethod/staticmethod). It's not a show stopper by any means

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

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  bdesth.quelquech...@free.quelquepart.fr wrote: Marco Mariani a écrit : Bruno Desthuilliers wrote: Oh, you meant the return type ? Nope, no way. It just doesn't

[issue3135] inspect.getcallargs()

2009-05-14 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I updated the recipe to also return a `missing_args` tuple - the tuple of the formal parameters whose value was not provided. This is useful in cases where one want to distinguish f() from f(None) given def f(x=None). -- versions

[issue3135] inspect.getcallargs()

2009-05-14 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Also updated url: http://code.activestate.com/recipes/551779/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3135

Re: Nimrod programming language

2009-05-12 Thread George Sakkis
On May 12, 12:49 pm, Mensanator mensana...@aol.com 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

Re: Self function

2009-05-09 Thread George Sakkis
On May 6, 10:32 pm, Luis Alberto Zarrabeitia Gomez ky...@uh.cu 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

Re: Decorating methods - where do my arguments go?

2009-05-09 Thread George Sakkis
On May 8, 11:33 am, Mikael Olofsson mik...@isy.liu.se 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

[issue5982] classmethod, staticmethod: expose wrapped function

2009-05-09 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: It would be nice if classmethod/staticmethod exposed the wrapped function as a read-only attribute/property. Currently the function can be retrieved indirectly but it's obscure (and perhaps not always correct, I'm not sure): In [147

[issue5890] Subclassing property doesn't preserve the auto __doc__ behavior

2009-04-30 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: Is the following behavior expected ? class MyProp(property): pass class Foo(object): @property def bar(self): '''Get a bar.''' @MyProp def baz(self): '''Get a baz.''' print Foo.bar.__doc__

Re: ActiveState Komodo Edit?

2009-04-26 Thread George Sakkis
On Apr 26, 11:08 pm, John Doe j...@usenetlove.invalid 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

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 pavpanche...@gmail.com 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)

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread George Sakkis
On Apr 11, 3:03 pm, Mike H cmh.pyt...@gmail.com 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

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread George Sakkis
] http://www.sqlobject.org/ [3] https://storm.canonical.com/ On Sat, Apr 11, 2009 at 4:18 PM, George Sakkis george.sak...@gmail.com wrote: On Apr 11, 3:03 pm, Mike H cmh.pyt...@gmail.com wrote: Can I not use the cursor.execute command to pass variables that aren't immediately next to each

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 of

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 george.sak...@gmail.com 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 that you have to write manually

Re: Returning different types based on input parameters

2009-04-08 Thread George Sakkis
On Apr 7, 3:18 pm, Adam Olsen rha...@gmail.com wrote: On Apr 6, 3:02 pm, George Sakkis george.sak...@gmail.com 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

Re: object knows which object called it?

2009-04-06 Thread George Sakkis
On Apr 6, 10:53 am, Reckoner recko...@gmail.com 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

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

Re: Returning different types based on input parameters

2009-04-06 Thread George Sakkis
On Apr 6, 5:56 pm, MRAB goo...@mrabarnett.plus.com 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`

Re: Returning different types based on input parameters

2009-04-06 Thread George Sakkis
On Apr 6, 7:57 pm, andrew cooke and...@acooke.org 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 generally considered bad form (or worse) for functions

[issue5697] heapq.nlargest does not perform stable sort

2009-04-05 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: According to the docs, heapq.nlargest should be equivalent to sorted(iterable, key=key, reverse=True)[:n], and since sorted() is stable, so should heapq.nlargest be. This is not the case: s =[ ('Mike', -1), ('John', 3), ('George', 2

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-05 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Posted recipe at http://code.activestate.com/recipes/576712/. You were right, the implementation gets significantly hairier but I think it's worth having this option. It's also faster than using sorted/bisect as len(seq)/N increases

[issue5697] heapq.nlargest does not perform stable sort

2009-04-05 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Should have checked a recent version first; that's from 2.5 (r25:51908, Sep 19 2006, 09:52:17). Sorry for the noise. -- status: open - closed ___ Python tracker rep...@bugs.python.org http

Re: Best way to extract from regex in if statement

2009-04-03 Thread George Sakkis
On Apr 3, 9:56 pm, Jon Clements jon...@googlemail.com wrote: On 4 Apr, 02:14, bwgoudey bwgou...@gmail.com 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

Re: Pythoner,Wish me luck!

2009-04-03 Thread George Sakkis
On Apr 3, 3:47 pm, barisa bbaj...@gmail.com wrote: On Apr 3, 8:58 pm, nrball...@gmail.com wrote: On Apr 3, 12:33 pm, barisa bbaj...@gmail.com wrote: On Apr 3, 11:39 am, Hendrik van Rooyen m...@microcorp.co.za wrote: Matteo tadw.@gmail.com wrote: On Apr 3, 9:05 am, Linuxwell

Re: simple iterator question

2009-04-02 Thread George Sakkis
On Apr 2, 8:32 am, Neal Becker ndbeck...@gmail.com 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/

[issue5669] Extra heap nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: It would be useful in many cases if heapq.nlargest and heapq.nsmallest grew an optional boolean parameter, say `ties` (defaulting to False) that when True, it would return more than `n` items if there are ties. To illustrate: s

[issue5669] Extra heap nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: The second call should of course be: for i in xrange(1,len(s)+1): print i,heapq.nsmallest(i,s,ties=True) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5669

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
Changes by George Sakkis george.sak...@gmail.com: -- title: Extra heap nlargest/nsmallest option for including ties - Extra heapq nlargest/nsmallest option for including ties ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5669

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: There's nothing special about my use cases; I'd even go as far as to suggest that this is more often than not the desired behavior in general. Say that you have to select the top 3 chess players and there are two players with equal Elo

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: In that case, I think it best to leave nsmallest/nlargest as-is. By appending ties to the result, it becomes harder to implement policy decisions on what to do with those ties (perhaps listing them separately or splitting

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: That should have been: last = result[-1]; [last]*s.count(last). Nice, though that's not equivalent if the objects' identity is significant for what happens next (which typically is the case when ties are preserved). The sorted/bisect

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
Changes by George Sakkis george.sak...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5669 ___ ___ Python-bugs

[issue5669] Extra heapq nlargest/nsmallest option for including ties

2009-04-02 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I recommend posting an ASPN recipe. That's what I do with a lot of ideas that are under development or that don't clear the bar for going into the standard library. Will do. Thanks for the quick turnaround

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 'x' is

Re: How complex is complex?

2009-03-18 Thread George Sakkis
On Mar 18, 1:30 pm, Kottiyath n.kottiy...@gmail.com 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,

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 2:13 pm, R. David Murray rdmur...@bitdance.com wrote: George Sakkis george.sak...@gmail.com 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

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 4:06 pm, Daniel Fetchinson fetchin...@googlemail.com 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

Re: Disable automatic interning

2009-03-18 Thread George Sakkis
On Mar 18, 4:50 pm, andrew cooke and...@acooke.org 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]

Re: Candidate for a new itertool

2009-03-18 Thread George Sakkis
On Mar 7, 8:47 pm, Raymond Hettinger pyt...@rcn.com 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

[issue5302] Allow package_data globs match directories

2009-02-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I am no in favor of MANIFEST.in removal because I find it very convenient to define what is included in a package and I rarely use package_data or data_files. AFAIK the MANIFEST is used only by sdist; what's the point of including

[issue5300] Distutils ignores file permissions

2009-02-18 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: what is your use case of having executable file here ? I'd use the 'scripts' metadata for that ? For one thing they are external binaries, not python scripts, and second they are used internally only (through Subprocess

[issue5300] Distutils ignores file permissions

2009-02-17 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: Distutils ignores file permissions when copying modules and package_data files to the build directory, and consequently to the installation directory too. According to an XXX comment at distutils/command/build_py.py, this is deliberate

[issue5302] Allow package_data globs match directories

2009-02-17 Thread George Sakkis
New submission from George Sakkis george.sak...@gmail.com: Currently each glob defined in package_data must match files only; if it matches a directory, it raises an exception later when calling copy_file(). This means that a glob like 'mydata/*' will fail if there is any subdirectory under

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-17 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: Opened #5300 and #5302 for the mentioned issues. Btw in your patch, I believe `os.path.join(dirname, f)` should be replaced by `f` alone; `dirname` refers to the dir under the installation directory, not the source

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-16 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: FWIW I wrote a module that overrides the default build_py and sdist commands with versions that allow specifying package_data recursively Maybe that could be a new feature ? That would be nice, especially if we want to reimplement

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-16 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: done in r69692 and r69696. Great, thanks. The data_files part though seems incorrect; for one thing each item in data_files can be either a (dir,files) tuple or a plain string, and for two 'dir' is the output (installation) directory

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-15 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: By an equivalent option in setup() of course. I'm not against the *functionality* of MANIFEST.in but on that (a) it's a second file you have to remember to write and maintain in addition to setup.py (b) has its own ad-hoc syntax instead

[issue2279] distutils sdist add_defaults does not add data_files

2009-02-13 Thread George Sakkis
George Sakkis george.sak...@gmail.com added the comment: I didn't mean to imply that automagic discovery based on external version control software is better than MANIFEST.in; I favor explicitness here as well. It's just that this information can (and often has to) be duplicated in setup.py

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

Re: Python is slow

2008-12-15 Thread George Sakkis
On Dec 15, 8:15 am, Luis M. González luis...@gmail.com wrote: On Dec 15, 1:38 am, cm_gui cmg...@gmail.com 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,

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 not

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 we

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, and it  

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 sentiment, you

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: 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, for windows there's

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 these

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

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 established

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

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: 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 of 3: 36.8 sec

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

  1   2   3   4   5   6   7   8   9   10   >