Re: Critique of first python code

2008-02-17 Thread George Sakkis
if I had to write one, I would use isiterable = lambda x: hasattr(x, '__iter__') or hasattr(x, '__getitem__') In Python 3 it will be isinstance(x, Iterable). George -- http://mail.python.org/mailman/listinfo/python-list

Re: flattening a dict

2008-02-17 Thread George Sakkis
les) semantics if it is passed a single argument. Currently chain() is useful for 2 or more arguments; chain(x) is equivalent to iter(x), there's no reason to use it ever. On the downside, this might break backwards compatibility for cases like chain(*some_iterable) where some_iterable has

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-18 Thread George Sakkis
On Feb 18, 6:56 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > Dear Ilias, > > > Post in a single reply. > > He has to, in hopes to gain the traction he desires Was the pun intended ? ;-) -- http://mail.python.org/mailm

Re: The big shots

2008-02-18 Thread George Sakkis
that you have been mostly replying to your own posts here in c.l.py, which indicates that the lack of responses has nothing to do with the supposed snobbishness of the "big shots". George -- http://mail.python.org/mailman/listinfo/python-list

Re: Why must implementing Python be hard unlike Scheme?

2008-02-18 Thread George Sakkis
guages minimality is not the top priority. Python is not an exception. > Does this have to be true? Beneath the more complex syntax are there > a few core design principles/objects/relationships to help in grokking > the whole thing? Got any related links? http://codespeak.net/pypy/dist/p

Re: The big shots

2008-02-19 Thread George Sakkis
ing." > > French and Spanish have impersonal pronouns: "on" and "se", > > respectively. In English, they often come out as, "we", > > "they", and "you" a lot, on occasion a "one", and sometimes, > > even, I. &

Re: Is there a way to "link" a python program from several files?

2008-02-21 Thread George Sakkis
;python setup.py install" ? Even that is not strictly necessary for pure python packages; a user may just unpack the archive, cd to the extracted directory and execute the appropriate .py file(s). George -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-21 Thread George Sakkis
lement an augmented operator, "a `op`= b" translates to "a = a `op` b" for a binary operator `op`. There's no formal notion of mutable and immutable objects with respect to these operators; any class that doesn't implement them is "immutable" as far as augmented ass

Re: flattening a dict

2008-02-21 Thread George Sakkis
On Feb 21, 8:04 pm, Benjamin <[EMAIL PROTECTED]> wrote: > On Feb 17, 6:18 am, Terry Jones <[EMAIL PROTECTED]> wrote: > > > Hi Arnaud & Benjamin > > > Here's a version that's a bit more general. It handles keys whose values > > are empty dicts (assigning None to the value in the result), and also di

Re: Article of interest: Python pros/cons for the enterprise

2008-02-21 Thread George Sakkis
t a technical level (i.e. ignoring current maturity, community size, marketing, etc.) ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-21 Thread George Sakkis
anything about memory allocation, initialization or copying. The only case where assigning an identifier affects memory is the following [1]: """ The name is rebound if it was already bound. This may cause the reference count for the object previously bound to the name to reach z

Re: Article of interest: Python pros/cons for the enterprise

2008-02-22 Thread George Sakkis
rience would be much appreciated in more useful projects. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-22 Thread George Sakkis
ions, "set" and "test". > m = re.match(r"name=(.*)",line) # set > if m: # test > name = m.group(1).strip() For a single set-and-test the inconvenience is minimal, but stack a bunch of them together (even more if there are 'else' clauses in the mix) and the syntactic inefficiency becomes quite visible. George -- http://mail.python.org/mailman/listinfo/python-list

Re: object identity and hashing

2008-02-24 Thread George Sakkis
(and hash codes), so they are > > interchangeable for purposes of keying a dict. > > I see. You stated, > > > Is (3,) one of the keys in the dict? > > > > True > > > Yes, it is. > > It isn't, but it does equal a key that's already in th

Re: convert string number to real number - ValueError: invalid literal for int() with base 10: '"2"'

2008-02-29 Thread George Sakkis
phone bill input, I am sure you'll get much better solutions in terms of clarity, simplicity and elegance, commonly known as "pythonicity" :) George -- http://mail.python.org/mailman/listinfo/python-list

Re: News from Jython world

2008-03-03 Thread George Sakkis
ava Universe. > > More details at: > -http://www.infoworld.com/article/08/03/03/hirings-python_1.html > -http://fwierzbicki.blogspot.com/2008/02/jythons-future-looking-sunny > > Cheers, > > SB Great news! Having to go back to the Java world might not be such a turn-off in the

Re: Why """, not '''?

2008-03-05 Thread George Sakkis
On Mar 5, 9:56 am, [EMAIL PROTECTED] wrote: > Why is """ the preferred delimiter for multi-line strings? Is it ? FWIW, I use single quotes whenever I can and double whenever I have to (i.e. rarely). George -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a string to the most probable type

2008-03-06 Thread George Sakkis
> > Like in spreadsheets, special prefixes could be used to force the > type : for instance '123 would be converted to the *string* "123" > instead of the *integer* 123 > > I could code it myself, but this wheel is probably already invented Maybe, but that's a so domain-specific and easy to code wheel that it's no big deal reinventing. George -- http://mail.python.org/mailman/listinfo/python-list

Re: islice ==> [::]

2008-03-07 Thread George Sakkis
ctivestate.com/ASPN/Cookbook/Python/Recipe/498272 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Timed execution in eval

2008-03-07 Thread George Sakkis
the GIL and doesn't actually kill the function after the timeout. I'd be rather surprised if the perl solution you figured out doesn't have any issues. George -- http://mail.python.org/mailman/listinfo/python-list

Re: __iter__ yield

2008-03-09 Thread George Sakkis
> class Node: > ... > def __iter__(self): > for x in chain([self], *self.childs): > yield x Actually this doesn't need a yield at all: class Node: ... def __iter__(self): return chain([self], *self.childs) George -- http://mail.python.org/mailman/listinfo/python-list

Re: List Combinations

2008-03-12 Thread George Sakkis
f that looks like as follows: > 3,9,5,4,2 > 3,1,5,4,2 > 3,9,5,4,5 > 3,1,5,4,5 > etc. > > Thank You, > Gerdus Search for "cartesian product" recipes. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Does __import__ require a module to have a .py suffix?

2008-03-12 Thread George Sakkis
es with __import__ (foo.x) vs dict entries with execfile (foo['x'])), there are probably more subtle differences but I can't tell for sure. It would be nice if someone more knowledgeable can compare and contrast these two appraches. George -- http://mail.python.org/mailman/listinfo/python-list

Re: String To List

2008-03-17 Thread George Sakkis
restricted safe eval variant (e.g. http://groups.google.com/group/comp.lang.python/browse_frm/thread/262d479569b1712e) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Any fancy grep utility replacements out there?

2008-03-17 Thread George Sakkis
could be donebut > seems like a hassle). If it's for something quick & dirty, you can't beat the pipeline, e.g. something like: find some_dir -name "*gz" | xargs -i sh -c "echo '== {} =='; zcat {} | grep some_pattern" George -- http://mail.python.org/mailman/listinfo/python-list

Re: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 idiom

2008-03-18 Thread George Sakkis
s : > > def MyProperty(fcn): > return property(**fcn()) > > and using it like this : > > class MyClass(object): >def __init__(self): >self._foo = "foo" >self._bar = "bar" > >@MyProperty >def foo(): >doc = "property foo's doc string" >def fget(self): >return self._foo >def fset(self, value): >self._foo = value >def fdel(self): >del self._foo >return locals() # credit: David Niergarth > >@MyProperty >def bar(): >doc = "bar is readonly" >def fget(self): >return self._bar >return locals() > > Cheers, > Gabriel Also check out a related recipe that doesn't require returning locals() explicitly: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Pycon disappointment

2008-03-18 Thread George Sakkis
n was that most attendants had at least a decent grasp of the language. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Get actual call signature?

2008-03-18 Thread George Sakkis
I'll happily > throw this idea and look for another one. ;) I also needed this for a typecheck module I had written some time ago. It is feasible, but it's rather hairy. I can dig up the code, polish it and post it as a recipe (or maybe as a patch to the inspect stdlib module where it belongs). George -- http://mail.python.org/mailman/listinfo/python-list

Re: lists v. tuples

2008-03-18 Thread George Sakkis
ade any sense to me I guess it doesn't matter. Plus, it does work fine over here: Python 2.5.1 (r251:54863, May 8 2007, 14:46:30) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = [] >>> a.append(a) >>> a [[...]] >>> a in a True George -- http://mail.python.org/mailman/listinfo/python-list

Re: Get actual call signature?

2008-03-18 Thread George Sakkis
On Mar 18, 4:24 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 18, 6:40 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > > > > > Say, I have a function defined as: > > > def fun(arg_one, arg_two='x', arg_three=None): > > pass >

Re: Duplicating list of lists [newbie]

2008-03-23 Thread George Sakkis
;s called a "shallow copy". > Is there simple way to copy a into b (like a[:]) with all copies of > all objects going as deep as possible? Yes, there is: from copy import deepcopy b = deepcopy(a) HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Why I hate lambdas (Re: Do any of you recommend Python as a first programming language?)

2008-03-23 Thread George Sakkis
n. I don't see how replacing the lambda with a (better) named function would be any better than using the same name as a keyword parameter. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Does python hate cathy?

2008-03-23 Thread George Sakkis
ceptions.AttributeError: "'NoneType' object has no > attribute 'population'" in <__main__.Person instance at 0xb7d8ac6c>> ignored > > To to newcomer like me, this message doesn't make much sense. What > seems weird to me is that, if I change the variable cathy to something > else, like cath, or even cat, then the script will finish gracefully. > Why "cathy" is not liked?!! > > Some of you may have recognized that the code is derived from a sample > code in Swaroop's "A byte of python". > > My python is of version 2.5.1, on Ubuntu. That's really weird... it's reproducible on Windows too. It doesn't make any sense why the name of the variable would make a difference. My guess is you hit some kind of obscure bug. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Does python hate cathy?

2008-03-23 Thread George Sakkis
On Mar 23, 9:02 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Sun, 2008-03-23 at 17:42 -0700, George Sakkis wrote: > > That's really weird... it's reproducible on Windows too. It doesn't > > make any sense why the name of the variable would make a differenc

Re: New to group

2008-03-24 Thread George Sakkis
idth, the most effective way usually consists of copying and pasting: 1. The offending code (or just the relevant part if it's too big). 2. The full traceback of the raised exception. Regards, George -- http://mail.python.org/mailman/listinfo/python-list

Re: New to group

2008-03-24 Thread George Sakkis
t; raw_input("\n\nPress the enter key to exit.") > > The code is an exerp from a chm file . I am petty sutre I am > nmot getting a char map error from the copy/paste ! it looks > simple enough ! It works fine on on Windows with standard Python 2.5. Something is probably wrong with your ActiveState installation. George -- http://mail.python.org/mailman/listinfo/python-list

Re: New to group

2008-03-24 Thread George Sakkis
d pasting: > > 1. The offending code (or just the relevant part if it's too big). > > 2. The full traceback of the raised exception. > > > Regards, > > George > > Hwere is the complete traceback ! >>> The word is: index > > Traceback (most recent

Re: A question on decorators

2008-03-26 Thread George Sakkis
-ridden, slow implementation of half of SQLAlchemy. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Not understanding lamdas and scoping

2008-03-26 Thread George Sakkis
be an entry for this at http://www.python.org/doc/faq/programming/, that's really an FAQ. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Not understanding lamdas and scoping

2008-03-26 Thread George Sakkis
On Mar 26, 6:03 pm, Joshua Kugler <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > On Mar 26, 5:02 pm, Joshua Kugler <[EMAIL PROTECTED]> wrote: > > >> I am trying to use lamdba to generate some functions, and it is not > >> working > >> the

Re: Line segments, overlap, and bits

2008-03-26 Thread George Sakkis
kind of thing pretty clean and high-level, but I haven't > seen anything like it for python. > > Thanks, > Sean Have you looked at Pypi [1] ? From a quick search, there are at least four potentially relevant packages: BitPacket, BitVector, BitBuffer, BitBucket. George [1] http:/

Preserving file permissions with distutils

2009-01-14 Thread George Sakkis
is wrong or should I submit a bug report ? George -- http://mail.python.org/mailman/listinfo/python-list

Problem with IDLE on windows XP

2009-01-19 Thread Grimes, George
? Thanks, George George A. Grimes 972-995-0190 - Desk 214-205-0244 - Cell Failure is the opportunity to begin again, more intelligently. Henry Ford<http://www.woopidoo.com/business_quotes/authors/henry-ford-quotes.htm> -- http://mail.python.org/mailman/listinfo/python-list

RE: Problem with IDLE on windows XP

2009-01-20 Thread Grimes, George
! George George A. Grimes 972-995-0190 - Desk 214-205-0244 - Cell Failure is the opportunity to begin again, more intelligently. Henry Ford -Original Message- From: python-list-bounces+georgegrimes=ti@python.org [mailto:python-list-bounces+georgegrimes=ti@python.org] On Behalf Of

Re: Pexpect and telnet not communicating properly

2009-01-27 Thread George Trojan
ne(self, s): self._last = s return self.pipe.sendline(s) def expect(self, pattern, **kwds): rc = self.pipe.expect(pattern, **kwds) if self.logger: self.logger.debug('sent "%s", received\n\t1. before "%s"\n\t' \ '2. match "%s"\n\t3. after "%s"\n', self._last, self.before, self.match.group(0), self.after) return rc def close(self): self.pipe.close() self.pipe = None self.socket.close() self.socket = None George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-11-22 Thread George Sakkis
ime you refer to a class or any other   > object in Python, what you have is a reference to it. ..which makes the phrase "a reference to an X" a more verbose, redundant version of "an X" since it applies to *every* Python object. You have made your point in the

Re: Python 3 __cmp__ semantic change?

2008-11-23 Thread George Sakkis
cumentation or the implementation? According to Guido, the implementation: http://mail.python.org/pipermail/python-ideas/2008-October/002235.html. George -- http://mail.python.org/mailman/listinfo/python-list

Re: end of print = lower productivity ?

2008-11-25 Thread George Sakkis
a fresh approach to > the task. Seconded; I thought he's either joking or trolling. George -- http://mail.python.org/mailman/listinfo/python-list

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: Instance attributes vs method arguments

2008-11-25 Thread George Sakkis
n API here is more crucial than the difference in performance. Deciding between the two based on the (guessed or measured) performance improvement misses the point of OO design. George -- http://mail.python.org/mailman/listinfo/python-list

Re: what's so difficult about namespace?

2008-11-26 Thread George Sakkis
o upgrade to 3.0 ? It's not like Joe User runs emacs to edit his grocery store list. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Applying a decorator to a module

2008-11-27 Thread George Sakkis
d "class ...", modules are not. You can always pass the module to the decorator explicitly: import mymod mymod = decorator(mymod) George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-11-27 Thread George Sakkis
es you may be more familiar with. Perhaps you chose the wrong group for your new adopted religion. Why don't you go read a tutorial, write up some code, and come back with any real questions next time. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Great exercise for python expert !

2008-11-28 Thread George Sakkis
alling simply : "o.js.kiki(12).kuku()" not "o.js.kiki(12).kuku() > ()") > (or how to call the MyObject._add (callback) without using the caller > on my JQueryCaller) Why don't you rename __call__ to __str__ and have MyObject.__add return a string instead of printing it directly? class MyObject(object): def __add(self,j): return "Add:"+j if __name__ == "__main__": o = MyObject() s = o.js.kiki(12).kuku() print s HTH, 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: 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

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

Re: How to instantiate in a lazy way?

2008-12-02 Thread George Sakkis
far. > > No guarantees though, as I may simply not have been smart enough to > bring forth unit test cases which make it crash. > > Comments on the code is still appreciated though. A trivial improvement: replace > I1, Q1, I2, Q2 = bytes_to_data(buf) > self.__dict__["I1"] = I1 > self.__dict__["Q1"] = Q1 > self.__dict__["I2"] = I2 > self.__dict__["Q2"] = Q2 with: self.__dict__.update(zip(self.data_attr_names, bytes_to_data (buf))) where data_attr_names = ("I1", "Q1", "I2", "Q2") instead of a frozenset. A linear search in a size-4 tuple is unlikely to be the bottleneck with much I/O anyway. George -- http://mail.python.org/mailman/listinfo/python-list

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: Overriding a method at the instance level on a subclass of a builtin type

2008-12-02 Thread George Sakkis
classes, special methods are always looked up in the class, not the instance, so you're out of luck there. What are you trying to do? Perhaps there is a less magic solution to the general problem. George -- http://mail.python.org/mailman/listinfo/python-list

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

building an extension module with autotools?

2008-12-03 Thread Michael George
Hello, (Please CC me in replies, as I am off-list) I'm building an application (a game) in python, with a single C module containing some performance-critical code. I'm trying to figure out the best way to set it up to build. Distutils seems to be designed only for building and distributing

Re: building an extension module with autotools?

2008-12-03 Thread Michael George
Gerhard Häring wrote: Michael George wrote: I've tried using automake, In my opinion, this is serious overkill. automake is good for making stuff work on a herd of different Unixen with various combinations of libc functions available etc. But for developing a Python extension, it do

Re: building an extension module with autotools?

2008-12-03 Thread Michael George
Martin v. Löwis wrote: I've tried using automake, however I'm worried about libtool not getting the options right while building my module. You should use python-config(1) to obtain the command line options necessary to build and link extension modules. HTH, Martin Sweet, I think th

Re: Pythonic design patterns

2008-12-04 Thread George Sakkis
Kool-Aid and > start pushing design patterns everywhere. (Not everything needs to be a > singleton. No, really.) Obligatory reading: http://www.mortendahl.dk/thoughts/blog/view.aspx?id=122 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
first argument. If you want to bind it to a callable that expects the first argument to be self, you have to bind explicitly self to the object: >>> def a_foo(self): print 'a.foo' >>> a.foo = a_foo >>> a.foo() TypeError: a_foo() takes exactly 1 argument (0 given) >>> from functools import partial >>> a.foo = partial(a_foo,a) >>> a.foo() a_foo 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, 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
loop > > > That's 3 orders of magnitude slower on python3.0! > > Isn't this because you have the file cached in memory on the second run? That's probably it; I see much more modest slowdown (2-3X) if I repeat many times each run. George -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 3.0 final

2008-12-04 Thread George Sakkis
avior in 3.x or it was not even considered dropping it ?? Does anyone have a link where this was decided ? George -- http://mail.python.org/mailman/listinfo/python-list

using distutils to cross-compile extensions?

2008-12-04 Thread Michael George
Hi, Please CC me in replying as I am off list. I have an extension module that I've built using distutils. I wonder if it's possible to use distutils to cross-compile it for windows on my linux box, and whether the pain involved is great. Can anyone point me in the right direction? Thanks

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: how to get a beep, OS independent ?

2008-12-07 Thread George Sakkis
uot;. > > > Inverted bell? > > In the output window (stdout) which is black letters on white background, > it prints "bell" in white letters with a black background.>  What do you > mean? And what version dependency are you > > referring to? > > Well some of you actually hear something, > I don't, > so I expect that the Python version differs. Works for me on WinXP, Python 2.5: C:\>python -c "print chr(7)" makes a beep. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2008-12-07 Thread George Sakkis
> y = log(-2)  # the same NaN > x == y  # Some people want this to be true for NaNs. > > Then: > > # Compare x and y directly. > log(-5) == log(-2) > # If x == y then exp(x) == exp(y) for all x, y. > exp(log(-5)) == exp(log(-2)) > -5 == -2 > > and now the enti

Re: Mathematica 7 compares to other languages

2008-12-08 Thread George Neuner
ize your optimizing compiler's output. Humans are quite often able to find additional optimizations in assembly code that they could not have written as well overall in the first place. George -- http://mail.python.org/mailman/listinfo/python-list

Re: How to initialize a class variable once

2008-12-09 Thread George Sakkis
y __all__ = ['foo', 'Bar'] def foo(x,y): ... class Bar(object): from myscript import * if __name__ == '__main__': assert foo.__module__ == Bar.__module__ == 'myscript' George -- http://mail.python.org/mailman/listinfo/python-list

Re: "as" keyword woes

2008-12-09 Thread George Sakkis
mean that you should; the OP's use case - using "foo.as(int)" - is pretty reasonable and readable. I believe the responsibility to not abuse the power of the language should be on the application programmer, not the language designer. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to report progress at fixed intervals

2008-12-09 Thread George Sakkis
e looking for (haven't used it though): http://pypi.python.org/pypi/progressbar/. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to report progress at fixed intervals

2008-12-10 Thread George Sakkis
t OSes (some of which I do not have admin access to) to use > the new module. How is this different from writing your own module from scratch ? You don't need admin access to use a 3rd party package. George -- http://mail.python.org/mailman/listinfo/python-list

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: Mathematica 7 compares to other languages

2008-12-12 Thread George Neuner
On Wed, 10 Dec 2008 21:37:34 + (UTC), Kaz Kylheku wrote: >Now try writing a device driver for your wireless LAN adapter in Mathematica. Notice how Xah chose not to respond to this. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Mathematica 7 compares to other languages

2008-12-12 Thread George Neuner
atever the lang supports. The output is the same >datatype of the same dimension. C's native arrays are stored contiguously. Multidimensional arrays can be accessed as a vector of length (dim1 * dim2 * ... * dimN). This code handles arrays of any dimensionality. The poorly named argument 'dim' specifies the total number of elements in the array. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Mathematica 7 compares to other languages

2008-12-12 Thread George Neuner
On Mon, 8 Dec 2008 15:14:18 -0800 (PST), Xah Lee wrote: >Dear George Neuner, > >Xah Lee wrote: >> >For example, >> >the level or power of lang can be roughly order as >> >this: >> >> >assembly langs >> >C, pascal >> &

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: lint for Python?

2008-10-06 Thread George Sakkis
On Oct 6, 3:49 pm, Pat <[EMAIL PROTECTED]> wrote: > I'll come back with more intelligent questions after I've actually > learned some Python. That's a wise self-advice ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading from stdin

2008-10-07 Thread George Sakkis
t > part of the standard file protocol? Not an answer to your actual question, but you can keep the 'for' loop instead of rewriting it with 'while' using the iter(function, sentinel) idiom: for line in iter(sys.stdin.readline, ""): print "You said!", line George -- http://mail.python.org/mailman/listinfo/python-list

Re: Array of dict or lists or ....?

2008-10-07 Thread George Sakkis
;Newville', 'Math') : (20, 0), ('Nebraska', 'Wabash', 'Newville', 'Gym') : (400, 0), ('Nebraska', 'Tingo', 'Newville', 'Gym') : (400, 0), ('Ohio', 'Dinger', 'OldSchool'

Re: Reading from stdin

2008-10-07 Thread George Sakkis
On Oct 7, 8:13 pm, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote: > On Tuesday 07 October 2008 05:33:18 pm George Sakkis wrote: > > > Not an answer to your actual question, but you can keep the 'for' loop > > instead of rewriting it with 'while' using the i

Re: Porn Addiction Solutions?

2008-10-08 Thread George Sakkis
On Oct 8, 3:07 pm, [EMAIL PROTECTED] wrote: > Help, I'm addicted to porn. I've been spending a lot of time > downloading hardcore porn and masturbating to it. It's ruining my > life. I just found out that one of these sites somehow hacked my card > and rang up $5K in charges which they won't even r

Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread George Sakkis
equally convenient yet secure alternative available for > parsing strings containing Python data structure definitions? > > Thanks in advance for any pointers! This topic comes up every other month or so in this list, so if you had taken a minute to search for "python safe eval" or a variation thereof in your favorite search engine, you'd get more than enough pointers. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficient Bit addressing in Python.

2008-10-09 Thread George Sakkis
comes close to what you're after. George [1] http://hacks-galore.org/aleix/BitPacket/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Modification of a urllib2 object ?

2008-10-10 Thread George Sakkis
st solution is to save the request object and call urllib2.open twice. Alternatively check if ClientForm has a parse method that accepts strings instead of urllib2 requests and then read and save the html text explicitly: >>> text = urllib2.open(request).read() >>> soup = BeautifulSoup(text) >>> forms = ClientForm.ParseString(text) HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Modification of a urllib2 object ?

2008-10-10 Thread George Sakkis
On Oct 10, 6:12 pm, [EMAIL PROTECTED] wrote: > On Oct 10, 1:02 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Oct 10, 2:32 pm, [EMAIL PROTECTED] wrote: > > > > I have several ways to the following problem. > > > > This is what I have:

Re: Simple Python Project Structure

2008-10-10 Thread George Sakkis
string.py" module than have an irrelevant "string" subdirectory under a code directory tree. Having to create an empty file as a flag to denote a package doesn't seem very pythonic. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Safe eval of insecure strings containing Python data structures?

2008-10-13 Thread George Sakkis
itrary code execution > from any data stream", it most certainly is _not_ anyone's place to > dictate to them that they "cannot do this". That's why eval and exec still exist (and will probably be around for a long time, if not forever). If you define your own external

Re: documentation: what is "::="?

2008-10-13 Thread George Sakkis
t argument required > > What is it I'm not understanding here? > > Are "::=" and "<==>" documented anywhere in the python docs? Neither of these is a valid Python operator. '::=' is Backus-Naur Form (BNF) metasyntax [1]; it's a general syntax to express context free grammars. "<==>" typically denotes mathematical equivalence; it is used informally in the docs to express that two expression are equivalent. I can't tell why you get an error on str(sys.path); it works fine here. Something is probably wrong with your installation or locale configuration. George [1] http://en.wikipedia.org/wiki/Backus-Naur_form -- http://mail.python.org/mailman/listinfo/python-list

Re: inspect feature

2008-10-14 Thread George Sakkis
se TypeError: multiple values > > > How do you determine 'a', 'b', and 'c'? > > I'm afraid you'll have to duplicate the logic described here: > http://docs.python.org/reference/expressions.html#id9 > To my knowledge, there is no available Python code (in the stdlib or > something) that already does that. I wrote such a beast some time ago; it's hairy but to the best of my knowledge it seems to reproduce the standard Python logic: http://code.activestate.com/recipes/551779/ George -- http://mail.python.org/mailman/listinfo/python-list

Re: replace mothod for only one object but not for a class

2008-10-14 Thread George Sakkis
esn't work. The following works as expected: >>> class A(object): ... def foo(self): return 'Original' ... >>> a = A() >>> b = A() >>> a.foo() 'Original' >>> b.foo() 'Original' >>> b.foo = lambda: 'Modified' >>> a.foo() 'Original' >>> b.foo() 'Modified' HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: inspect feature

2008-10-14 Thread George Sakkis
On Oct 14, 2:35 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Oct 14, 9:42 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Oct 14, 3:06 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > > wro

Re: replace mothod for only one object but not for a class

2008-10-14 Thread George Sakkis
On Oct 14, 12:28 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > George Sakkis a écrit : > > > > > On Oct 14, 1:50 pm, hofer <[EMAIL PROTECTED]> wrote: > >> Hi, > > >> I have multiple objects all belonging to the same class > >> (wh

Re: inspect feature

2008-10-14 Thread George Sakkis
On Oct 14, 5:00 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Oct 14, 2:32 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Oct 14, 2:35 pm, "Aaron \"Castironpi\" Brady" > > > <[EMAIL PR

<    6   7   8   9   10   11   12   13   14   15   >