Re: Where do they tech Python officialy ?

2007-08-01 Thread Alex Martelli
Alex Popescu [EMAIL PROTECTED] wrote: ... Have you seen/heard of Jim lately? Cause I haven't. By the time he was the lead of the AspectJ team his charismatic presence was everywhere (at least around that project). He wasn't at OSCON this year, but I hope to see him at Pycon next year. I

Re: Where do they tech Python officialy ?

2007-07-31 Thread Alex Martelli
NicolasG [EMAIL PROTECTED] wrote: ... The problem is that I would like to work as a Python programmer but all the job vacancies I can find requires a couple of years of professional experience ... that I don't have. How a wanna be programmer can start working as a programmer if there is no

Re: Reading a two-column file into an array?

2007-07-31 Thread Alex Martelli
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Mon, 30 Jul 2007 21:57:17 -0700, Nagarajan wrote: a = [] import csv reader = csv.reader(open(filename, r), delimiter='\t' ) for row in reader: a.append( row ) I would keep a reference to the file to close it properly and the

Re: From D

2007-07-31 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: code files? What's the regular expression for locating a number with an arbitrary number of digits seperated into an arbitrary number of blocks of an arbitray number of digits with an arbitrary number of whitespace characters between each block?

Re: Comparing Dictionaries

2007-07-31 Thread Alex Martelli
Kenneth Love [EMAIL PROTECTED] wrote: ... Python in a Nutshell (2nd ed.) ... I am a slow reader. So, if Doctests are mentioned in any of the above, I haven't encountered it yet. Yep, I cover doctest in the chapter on testing, debugging, profiling and optimizing. Alex --

Re: Pythonic way for missing dict keys

2007-07-21 Thread Alex Martelli
Carsten Haese [EMAIL PROTECTED] wrote: On Sat, 21 Jul 2007 09:22:32 +0530, Rustom Mody wrote Can someone who knows about python internals throw some light on why x in dic is cheaper than dic.has_key(x) ?? I won't claim to know Python internals, but compiling and disassembling

Re: Real-time Update

2007-07-19 Thread Alex Martelli
Hendrik van Rooyen [EMAIL PROTECTED] wrote: ReTrY [EMAIL PROTECTED] wrote: I'm writing a program with Tkinter GUI, When the program is running it need to be updated every five seconds (data comes from internet). How should I do that ? How to make a function in main loop ? Short

Re: A way to re-organize a list

2007-07-19 Thread Alex Martelli
beginner [EMAIL PROTECTED] wrote: Hi Everyone, I have a simple list reconstruction problem, but I don't really know how to do it. I have a list that looks like this: l=[ (A, a, 1), (A, a, 2), (A, a, 3), (A, b, 1), (A, b, 2), (B, a, 1), (B, b, 1)] What I want to do is to reorganize

Re: Can a low-level programmer learn OOP?

2007-07-18 Thread Alex Martelli
Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Mon, 16 Jul 2007 11:45:04 -0700, Chris Carlen [EMAIL PROTECTED] declaimed the following in comp.lang.python: The more I play with Python, the more I like it. Perhaps I will understand OOP quicker than I thought. What I've learned so far

Re: how to implementation latent semantic indexing in python..

2007-07-18 Thread Alex Martelli
Tim Churches [EMAIL PROTECTED] wrote: malkarouri wrote: On 13 Jul, 17:18, 78ncp [EMAIL PROTECTED] wrote: hi... how to implementation algorithm latent semantic indexing in python programming...?? Of course you are aware that LSA is patented.. There is a US patent on it, sealed in

Re: type conversions for comparison operators

2007-07-18 Thread Alex Martelli
Russ [EMAIL PROTECTED] wrote: I recently discovered a bug in one of my programs that surprised me because I thought Python's dynamic type checking would have caught it. Suppose I have a function that returns an integer, such as def numItems: return len(self.items) Syntax errors (you

Re: Accessing Python variables in an extension module

2007-07-16 Thread Alex Martelli
MD [EMAIL PROTECTED] wrote: Hi Alex, Thanks for your reply. It was exactly what I was looking for. Two additional questions 1) Is there anyway to find out which modules a variable belongs to when I have only its name (and its not qualified with the complete name like module.varname)

Re: Accessing Python variables in an extension module

2007-07-16 Thread Alex Martelli
MD [EMAIL PROTECTED] wrote: Hi Alex, Thanks for the answer. Are there any C defines (for e.g. STRING, BOOLEAN) corresponding to each Python type? No, I know of no such defines -- what good would they do? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing Python variables in an extension module

2007-07-15 Thread Alex Martelli
MD [EMAIL PROTECTED] wrote: Hi, I would like to access variables defined in my Python program in a C module extension for Python. Is this possible? I looked at the Python C API reference but didn't find anything there that could help me. If they're global variables of a certain module

Re: Trying to choose between python and java

2007-07-15 Thread Alex Martelli
James T. Dennis [EMAIL PROTECTED] wrote: ... You can start writing all your code now as: print() --- calling the statement as if it were a function. Then you're future Python ...except that your output format will thereby become disgusting...: name = 'Alex' print 'Hello', name, 'and

Re: how to implementation latent semantic indexing in python..

2007-07-15 Thread Alex Martelli
78ncp [EMAIL PROTECTED] wrote: hi... how to implementation algorithm latent semantic indexing in python programming...?? You may get more responses (as in, 0!-) if you give some URL about what this algorithm is supposed to do. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Alex Martelli
Chris Carlen [EMAIL PROTECTED] wrote: From what I've read of OOP, I don't get it. I have also found some articles profoundly critical of OOP. I tend to relate to these articles. OOP can be abused (particularly with deep or intricate inheritance structures). But the base concept is simple

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-11 Thread Alex Martelli
Donn Cave [EMAIL PROTECTED] wrote: I've wondered if programmers might differ a lot in how much they dread errors, or how they react to different kinds of errors. That's quite possible. I'm reminded of a by-now commonplace theory, well summarized at

Re: catching empty strings (I guess that's what they are)

2007-07-09 Thread Alex Martelli
Diez B. Roggisch [EMAIL PROTECTED] wrote: ... for uf in user_files: uf = uf.strip().lower() if uf: file_skip_list.append(uf) This is fine; however, another reasonable alternative is: if not uf.isspace(): file_skip_list.append(uf.strip().lower()) I prefer yours

Re: Unicode problem

2007-07-07 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... Ah, I answered you on the Italian NG before seeing you had also posted the same request here. What I proposed there was (untested): import codecs _rimedi = { u'\x2019': ' } def rimedia(exc): if isinstance(exc, (UnicodeEncodeError,

Re: object references/memory access

2007-07-06 Thread Alex Martelli
Dennis Lee Bieber [EMAIL PROTECTED] wrote: ... Think VMS was the most applicable for that behavior... Haven't seen any dynamic priorities on the UNIX/Linux/Solaris systems I've encountered... Dynamic priority scheduling is extremely common in Unixen today (and has been for many

Re: PyRun_String using my module in a def

2007-07-05 Thread Alex Martelli
Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 05 Jul 2007 01:19:32 -0300, Stuart [EMAIL PROTECTED] escribió: What command do you mean when you say update main_dict with dlfl_dict? I think Alex Martelly was refering to use main_dict.update(dlfl_dict) (Python code) or

Re: MethodType/FunctionType and decorators

2007-07-05 Thread Alex Martelli
Alex Popescu [EMAIL PROTECTED] wrote: ... frameworks (TestNG is not a unit testing framework, but a full flavored testing framework that fits perfectly functional testing, integration testing, and with some of the very advanced features even performance and load testing). Nice! Does it

Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Alex Martelli
Neil Cerutti [EMAIL PROTECTED] wrote: Besides, a string is an excellent epresentation for a zip code, since arithmetic upon them is unthinkable. Absolutely! Excel, unless you remedied that later with a column operation, would turn some East Coast zipcodes into 3- and 4-digit numbers (dropping

Re: The best platform and editor for Python

2007-07-05 Thread Alex Martelli
Kay Schluehr [EMAIL PROTECTED] wrote: ... half of the community is happy with Emacs and the other half wants to program in a VS-like environment, neither consensus nor progress has Calling all vi/vim users (and we'll heartily appreciate the support of TextMate fans, BBEdit ones, etc, etc) --

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-04 Thread Alex Martelli
Roy Smith [EMAIL PROTECTED] wrote: greg [EMAIL PROTECTED] wrote: Paul Rubin wrote: E.g. your program might pass its test and run properly for years before some weird piece of input data causes some regexp to not quite work. Then you get a bug report, you fix it, and you add a

Re: Reversing a string

2007-07-04 Thread Alex Martelli
Aahz [EMAIL PROTECTED] wrote: ... This works in all versions of Python back to 1.5.2 IIRC. reversed() is a moderately new built-in function; Yep: it came with Python 2.4, first alpha just 4 years ago, final release about 3 years and 8 months ago. Moderately new seems an appropriate tag.

Re: MethodType/FunctionType and decorators

2007-07-04 Thread Alex Martelli
Alex Popescu [EMAIL PROTECTED] wrote: ... - when testing from outside the class definition, the function is already attached to the class instance and this is the reason why its type is instancemethod To be more precise: when you access any attribute of a class (or instance thereof), Python

Re: need a variation algorithm for Lists in Dictionaries

2007-07-04 Thread Alex Martelli
Marc Stuart [EMAIL PROTECTED] wrote: Hi, I am trying to create a function, where I pass a dictionary with a lits of strings, and try to return a a list of strings, for all variations, any ideas ? Thanks def getAllVariants(someDict): keys = someDict.keys() for x in keys:

Re: PyRun_String using my module in a def

2007-07-04 Thread Alex Martelli
Stuart [EMAIL PROTECTED] wrote: ... PyObject *rstring = PyRun_String( cmd, Py_file_input, main_dict, dlfl_dict ); You're passing difl_dict as the locals to PyRun_String -- but a function has its own locals, so it won't use those locals. Just update main_dict with difl_dict (that's the

Re: python 3.0 or 3000 ....is it worth waiting??? Newbie Question

2007-07-03 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm considering learning Python...but with the python 3000 comming very soon, is it worth waiting for?? I know that the old style of coding python will run parallel with the new, but I mean, its going to come to an end eventually. It will be years

Re: ActivePython

2007-07-03 Thread Alex Martelli
Frank Swarbrick [EMAIL PROTECTED] wrote: Why might one choose to use ActivePython instead of using the free CPython? I believe ActivePython is also free, and it's packaged up differently (with more 3rd party modules accompanying it than the standard Python distribution), which might make it

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-02 Thread Alex Martelli
Donn Cave [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: Dynamic typing is recommended, they conclude, when programs must be as flexible as possible. I recommend reading the Agile Manifesto to understand why maximal flexibility

Re: Reversing a string

2007-07-01 Thread Alex Martelli
Martin Durkin [EMAIL PROTECTED] wrote: ... def rev(x): mylist = [] for char in x: mylist.append(char) mylist.reverse() for letter in mylist: print letter However, compare the incredible

Re: object references/memory access

2007-07-01 Thread Alex Martelli
dlomsak [EMAIL PROTECTED] wrote: ... search and return takes a fraction of a second. For a large return (in this case 21,000 records - 8.3 MB) is taking 18 seconds. 15 of those seconds are spent sending the serialized results from the server to the client. I did a little bit of a blind

Re: Reversing a string

2007-07-01 Thread Alex Martelli
Jay Loden [EMAIL PROTECTED] wrote: ... For what it's worth, with python 2.5 on my Macbook: Hmmm, doesn't look to me as if it's worth much...: [EMAIL PROTECTED] jloden]$ python -m timeit 's = onomatopoeia; s = s.join(s[::-1])' since what you're doing is...: s = onomatopoeia s =

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Alex Martelli
Bruno Desthuilliers [EMAIL PROTECTED] wrote: ... I still maintain that the primary *practical* reason behind static typing is to provide optimization clues for the compiler. You can (or at It's definitely a helpful aspect, yes -- given that compilers able to infer types are still not very

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Alex Martelli
Bruno Desthuilliers [EMAIL PROTECTED] wrote: ... Hmmm... For a dinausor, C seems well alive. Can you remind me which So do chickens. I'm afraid I didn't get the joke... Are you saying that C is a rather, well, primitive language ? The joke's just based on the fact that (based on

Re: Set builtin lookups

2007-06-29 Thread Alex Martelli
Steve Holden [EMAIL PROTECTED] wrote: Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Evan Klitzke wrote: I have a question about the internal representation of sets in Python. If I write some code like if x in some_list: do_something() the lookup for the in

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-28 Thread Alex Martelli
John Nagle [EMAIL PROTECTED] wrote: PEP 3107 is static typing without enforcement, which is not a good thing. Wrong: PEP3107 is a syntax for adding arbitrary metadata annotations (so that said annotations don't get squished where they don't belong, such as decorators or docstrings, as they used

Re: nested list comprehension and if clauses

2007-06-28 Thread Alex Martelli
Jyotirmoy Bhattacharya [EMAIL PROTECTED] wrote: I'm a newcomer to Python. I have just discovered nested list comprehensions and I need help to understand how the if-clause interacts with the multiple for-clauses. I have this small program: def multab(n): print 'multab',n return

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-28 Thread Alex Martelli
Bjoern Schliessmann [EMAIL PROTECTED] wrote: ... Mh, strange, I personally like to use this.a in C++, to make clear I use an instance variable. That would be nice, unfortunately your C++ compiler will refuse that, and force you to use this-a instead;-). Many programming shops use naming

Re: nested list comprehension and if clauses

2007-06-28 Thread Alex Martelli
Paul Rubin http://[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Alex Martelli) writes: print [(m,n) for m in range(5) for n in multab(m) if m2] Sure, just place the if clause where it needs to apply (between the two for clauses) [apart from the fact that this example is best expressed

Re: simplifying algebraic expressions

2007-06-27 Thread Alex Martelli
DavidM [EMAIL PROTECTED] wrote: ... Seems that I have to allow a 'punishment free' threshold of complexity, otherwise the population stagnates. Sounds like you've hit on a good simulation of life: to get innovation, you must be very tolerant of errors!-) Alex --

equality comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Alex Martelli
A.T.Hofkamp [EMAIL PROTECTED] wrote: I think that again now with the default implementation of the object.__eq__ and object.__hash__ methods. I believe these methods should not exist until the programmer explicitly defines them with a suitable notion of equivalence. Anybody have a

Re: is this a valid import sequence ?

2007-06-24 Thread Alex Martelli
Scott David Daniels [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Sat, 23 Jun 2007 21:11:42 -0700, Alex Martelli wrote a lot, with lots of YELLING. Given the amount of SHOUTING in your post, and the fact that you feel so strongly about the trivial question of the redundant use

Re: is this a valid import sequence ?

2007-06-23 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 23 Jun 2007 11:03:03 -0700, Scott David Daniels wrote: The global statement in Write_LCD_Data is completely unnecessary. The only time you need global is if you want to reassociate the global name to another object (such as LCD = LCD + 1

Re: is this a valid import sequence ?

2007-06-23 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: ... It's never _wrong_ to use the global statement, even if it is strictly unnecessary for the Python compiler. So, repeat that global statement ninetyseven times -- that's not wrong, either, in exactly the same sense in which it's not wrong

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-22 Thread Alex Martelli
Dave Baum [EMAIL PROTECTED] wrote: ... I still think it would be handy to easily specify the expected types of function arguments. I sometimes write code in this pattern: def foo(a, b): a, b - instances of Bar assert isinstance(a, Bar) assert isinstance(b, Bar) # do

Re: static python classes ?

2007-06-20 Thread Alex Martelli
Neil Cerutti [EMAIL PROTECTED] wrote: In C++ they are used most often for factory functions, since they conveniently have access to the class's private members, and don't want or need an existing instance. Python seems to have adopted this use-case (ConfigParser, for example), but without a

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-20 Thread Alex Martelli
kaens [EMAIL PROTECTED] wrote: On 6/20/07, Diez B. Roggisch [EMAIL PROTECTED] wrote: That is exactly the problem - there is no some more static typing. There is static typing - or not. You can't have it just a bit. Couldn't a language be made so that if you declared a variable like,

Re: Does altering a private member decouple the property's value?

2007-06-19 Thread Alex Martelli
Ben Finney [EMAIL PROTECTED] wrote: Ethan Kennerly [EMAIL PROTECTED] writes: I really like properties for readonly attributes, Python doesn't have readonly attributes, Many Python types do, e.g.: def f(): pass ... def g(): pass ... f.func_name = 'zap' f.func_code = g.func_code f

Re: Python IDE

2007-06-19 Thread Alex Martelli
Tom Gur [EMAIL PROTECTED] wrote: which IDE would you recommend for a python ? It depends on that python's tastes and preferences. Like many others who have already responded, I prefer an editor (VIM) and a separate commandline/terminal; I know of many others who share another responder's

Re: Permutation over a list with selected elements

2007-06-19 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have been working at this problem, and I think I need a permutation algorithm that does the following: Given a list of elements that are either a character or a character follows by a number, e.g. ['a', 'b', 'c1', 'd', 'e1', 'f', 'c2',

Re: Does altering a private member decouple the property's value?

2007-06-18 Thread Alex Martelli
Ethan Kennerly [EMAIL PROTECTED] wrote: ... There are a lot of Python mailing lists. I hope this is an appropriate one for a question on properties. yep, it's a fine one. But a gotcha bit me in the behavior of properties that I didn't expect. If another function accesses an underlying

Re: Function that returns a tuple

2007-06-17 Thread Alex Martelli
David Wahler [EMAIL PROTECTED] wrote: ... Tuples are immutable (can't be modified once created). Try this: def BDllids(): conn = sqlite.connect('tasques.db') cursor = conn.cursor() cursor.execute('SELECT * FROM tasques') a = [row[0] for row in cursor] return

Re: Python's only one way to do it philosophy isn't good?

2007-06-16 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: ... perception that, at their roots, Scheme, C and Python share one philosophical underpinning (one that's extremely rare among programming languages as a whole) -- an appreciation of SIMPLICITY AND UNIFORMITY as language characteristics. Out

Re: Want to learn Python

2007-06-16 Thread Alex Martelli
7stud [EMAIL PROTECTED] wrote: I'm curious, have you tried _Python for Dummies_? No, I haven't. Unfortunately, I don't ever consider Dummies books. That type of marketing appeals to certain people and not others. I'm one of the others. I'll definitely take a look at it the next time

Re: Python's only one way to do it philosophy isn't good?

2007-06-16 Thread Alex Martelli
Cousin Stanley [EMAIL PROTECTED] wrote: ... I think the Original Sin in that regard was PL/I: it tried to have all ... tended to have two or more ways to perform any given task, typically inspired by some of the existing languages, often with the addition of new ones made out of

Re: dynamically generated runtime methods reflection

2007-06-15 Thread Alex Martelli
Bruno Desthuilliers [EMAIL PROTECTED] wrote: Josiah Carlson a écrit : (snip) Well, the particular operation is typically called 'currying a function', pedantic it's not 'currying' but 'partial application'. Currying is somehow the reverse of partial : it's a way of building a

Re: huge dictionary - bsddb/pickle question

2007-06-15 Thread Alex Martelli
lazy [EMAIL PROTECTED] wrote: ... key1={key11=[1,2] , key12=[6,7] , } ... Im processesing HUGE(~100M inserts into the dictionary) data. What will you need from the saved version later? If you need lookups by single keys or key pairs then a relational DB may be best; if you need to

Re: Want to learn Python

2007-06-15 Thread Alex Martelli
7stud [EMAIL PROTECTED] wrote: ... The reference book Python in a Nutshell is excellent, however its index is so bad I hesitate to recommend it. A reference book should have a thorough index--you shouldn't have to hunt through the chapters trying to find the particular topic you are

Re: Python's only one way to do it philosophy isn't good?

2007-06-15 Thread Alex Martelli
Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-12, Antoon Pardon [EMAIL PROTECTED] wrote: On 2007-06-11, Terry Reedy [EMAIL PROTECTED] wrote: More so than supporters of most other languages, in particular Scheme? Well to my knowledge (which could be vastly improved), scheme doesn't

Re: Python-URL! - weekly Python news and links (Jun 11)

2007-06-14 Thread Alex Martelli
Gabriel Genellina [EMAIL PROTECTED] wrote: QOTW: That's the Martellibot for you. Never use a word where a paragraph with explanatory footnotes will do. Sigh. I miss him on c.l.py. - Simon Brunning Funny -- didn't Simon write this in 2005 referring to an essay of mine that I had posted in

Re: Python rocks

2007-06-03 Thread Alex Martelli
Mark Carter [EMAIL PROTECTED] wrote: Alex Martelli wrote: Josiah Carlson [EMAIL PROTECTED] wrote: pitfall of Python is knowing whether an operation is destructive or not. If it returns None, it probably changes the content of an object. A reasonable heuristic, but with lots

Re: Python rocks

2007-06-03 Thread Alex Martelli
Mark Carter [EMAIL PROTECTED] wrote: Alex Martelli wrote: Mark Carter [EMAIL PROTECTED] wrote: Yes, GMP is a pain to compile (especially on Mac OS X), but I believe Just mentioning this in case you want to give Scheme another chance Thanks. I'll take a look at it. You're welcome

Re: how can I get the name of a method inside it?

2007-06-03 Thread Alex Martelli
Sébastien Vincent sebastien_nimp73@ wrote: I would like to know if it's possible to retrieve the name of a method when you're inside it. For example, in the following script, I would like to assign _s so that it prints you are in method1. *** class

Re: Check for descriptors (in C)

2007-06-03 Thread Alex Martelli
Gabriel Genellina [EMAIL PROTECTED] wrote: For most types, there are macros like PyXxxx_Check and PyXxxx_CheckExact. But not for descriptors, and I want to test if a certain object is a descriptor or not. May I define PyMethodDescr_Check, by example, along the lines of similar checks, or the

Re: int vs long

2007-06-03 Thread Alex Martelli
Paul Rubin http://[EMAIL PROTECTED] wrote: Dan Bishop [EMAIL PROTECTED] writes: If you ever do, it's trivial to write your own enumerate(): def enumerate(seq): index = 0 for item in seq: yield (index, item) index += 1 That's a heck of a lot slower than the

Re: subexpressions (OT: math)

2007-06-03 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On 3, 22:07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: angle is a ratio of two length and dimensionless.http://en.wikipedia.org/wiki/Angle#Units_of_measure_for_ang les only dimensionless values can be a argument of a sine and exponent!

Re: Multiple inheritence for exceptions?

2007-06-03 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: Useful or a bad idea? I have a module that defines a number of exceptions which inherit from various built-ins like KeyError, ValueError etc. I'm considering defining an abstract module exception like MyModuleError, and having all my real exceptions

Re: Python rocks

2007-06-02 Thread Alex Martelli
Mark Carter [EMAIL PROTECTED] wrote: I picked Chicken Scheme for OS X. Things started well, and even the web ... that; but I found that it ultimately depended on gmp, which turned out a pain to compile. Yes, GMP is a pain to compile (especially on Mac OS X), but I believe that the

Re: Python rocks

2007-06-02 Thread Alex Martelli
Josiah Carlson [EMAIL PROTECTED] wrote: pitfall of Python is knowing whether an operation is destructive or not. If it returns None, it probably changes the content of an object. A reasonable heuristic, but with lots of exceptions, alas: somedict.get(somekey) will often return None

Re: Create a new class on the fly

2007-06-01 Thread Alex Martelli
py_genetic [EMAIL PROTECTED] wrote: Alex, thanks for the advise: class PosRecords(tables.IsDescription): class A(object): self.__init__(self, args): This makes 0 sense; maybe you should learn elementary Python syntax well _before_ trying advanced stuff, no? I accidently

Re: Good Python style?

2007-05-31 Thread Alex Martelli
Andreas Beyer [EMAIL PROTECTED] wrote: Hi, I found the following quite cryptic code, which basically reads the first column of some_file into a set. In Python I am used to seeing much more verbose/explicit code. However, the example below _may_ actually be faster than the usual for line in

Re: New-style classes and special methods

2007-05-30 Thread Alex Martelli
Raj B [EMAIL PROTECTED] wrote: Hi My question is about how special methods are stored internally in Python objects. Consider a new-style class which implements special methods such as __call__ and __new__ class C(type): def __call__(...): body class B:

Re: Rats! vararg assignments don't work

2007-05-30 Thread Alex Martelli
samwyse [EMAIL PROTECTED] wrote: ... Actually, I'm surprised that the PEP does as much as it does. If tuples are implemented as S-expressions, then something like this: Tuples are implemented as compact arrays of pointer-to-PyObject (so are lists, BTW). So, for example, a 10-items tuple

Re: New-style classes and special methods

2007-05-30 Thread Alex Martelli
Raj B [EMAIL PROTECTED] wrote: Yes, special methods populate the slots in the structures which Python uses to represent types. Objects/typeobject.c in the Python source distribution does the hard work, particularly in function type_new Thanks for that quick response. I am

Re: Create a new class on the fly

2007-05-30 Thread Alex Martelli
py_genetic [EMAIL PROTECTED] wrote: Is this possible or is there a better way. I need to create a new class during runtime to be used inside a function. The class definition and body are dependant on unknows vars at time of exec, thus my reasoning here. class

Re: itertools.groupby

2007-05-28 Thread Alex Martelli
Steve Howell [EMAIL PROTECTED] wrote: ... for has_chars, frags in itertools.groupby(lines, lambda x: len(x) 0): Hmmm, it appears to me that itertools.groupby(lines, bool) should do just the same job, just a bit faster and simpler, no? Alex --

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-28 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Historically, it's only Java and the Windows world (including non- standard Windows-style C++) that use forcedCase significantly (C# draws from both). I remember meeting that style first in the X Window System (now commonly known as X11, but it was

Re: Long double in Python

2007-05-28 Thread Alex Martelli
Charles Vejnar [EMAIL PROTECTED] wrote: Hi, Thanks for both suggestions. I have indeed tried gmpy. For me, it's not very important to choose between numpy or gmpy. I hope I won't be off topic. But, as I told you before, I have a C library using long double numbers and I would like to

Re: sockets, gethostname() changing

2007-05-25 Thread Alex Martelli
[EMAIL PROTECTED] wrote: ... and I'm not connected to the internet and I run the program, I get: my-names-computer.local When I'm connected to the internet, I get: dialup-9.999.999.999.dial9.xxx.level9.net That would bug me to high hell. A router in the middle would

Re: A few questions

2007-05-20 Thread Alex Martelli
jay [EMAIL PROTECTED] wrote: Hi, I'm totally new to Python and was hoping someone might be able to answer a few questions for me: 1. What are your views about Python vs Perl? Do you see one as better than the other? Yep: if I didn't find Python more readable, maintainable and

Re: Python compared to other language

2007-05-19 Thread Alex Martelli
walterbyrd [EMAIL PROTECTED] wrote: On May 18, 10:24 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: I think that Ruby, which roughly speaking sits somewhere between Python and Perl, is closer to Python than Perl is. I don't know much about Ruby, but it does not seem to be commonly used

Re: Inverse of id()?

2007-05-19 Thread Alex Martelli
Paul McGuire [EMAIL PROTECTED] wrote: Is there an inverse function to the builtin 'id'? The poster who No, there isn't. Now is there anything better than this search technique to get back a variable, given its id? For your own classes/types, you could override __new__ to maintain a

Re: Python Web Programming - looking for examples of solid high-traffic sites

2007-05-18 Thread Alex Martelli
Jarek Zgoda [EMAIL PROTECTED] wrote: Daniel Nogradi napisa?(a): For example, it HAS been published elsewhere that YouTube uses lighttpd, not Apache: http://trac.lighttpd.net/trac/wiki/PoweredByLighttpd. How do you explain these, then: http://www.youtube.com/results.xxx

Re: Python compared to other language

2007-05-18 Thread Alex Martelli
walterbyrd [EMAIL PROTECTED] wrote: - IMO: the most comparable language to Python, is Perl. Both are scripting languages. Both are free, multi-platform, and multi-purpose. Both are also very popular. I think that Ruby, which roughly speaking sits somewhere between Python and Perl, is closer

Re: A Few More Forrester Survey Questions

2007-05-18 Thread Alex Martelli
Terry Reedy [EMAIL PROTECTED] wrote: | 1) What -existing- examples of the use of Python to create social | web applications are there? These include chat, collaboration, | forum boards, and editable content pages, RSS feeds. | | I know I use a lot of these, but under pressure I'm not

Re: Python Web Programming - looking for examples of solid high-traffic sites

2007-05-17 Thread Alex Martelli
Victor Kryukov [EMAIL PROTECTED] wrote: ... And although http://www.python.org/about/quotes/ lists many big names and wonderful examples, be want more details. E.g. our understanding is that Google uses python mostly for internal web-sites, and performance is far from perfect their. YouTube

Re: Interesting list Validity (True/False)

2007-05-17 Thread Alex Martelli
Gabriel Genellina [EMAIL PROTECTED] wrote: import gmpy a = 2**177149-1 b = gmpy.mpz(2**177149-1) a==b True print '%d' % (b) Traceback (most recent call last): File pyshell#4, line 1, in module print '%d' % (b) TypeError: int argument required So although the

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread Alex Martelli
Aldo Cortesi [EMAIL PROTECTED] wrote: Thus spake Steven D'Aprano ([EMAIL PROTECTED]): Perhaps you aren't aware that doing something by eye is idiomatic English for doing it quickly, roughly, imprecisely. It is the opposite of taking the time and effort to do the job carefully and

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: automated -- if the patch uses an unexpected #-*- coding: blah line, or No need -- a separate PEP (also by Martin) makes UTF-8 the default encoding, and UTF-8 can encode any Unicode character you like. Alex --

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Alex Martelli
Aldo Cortesi [EMAIL PROTECTED] wrote: Thus spake Steven D'Aprano ([EMAIL PROTECTED]): If you're relying on cursory visual inspection to recognize harmful code, you're already vulnerable to trojans. What a daft thing to say. How do YOU recognize harmful code in a patch submission?

Re: Off Topic: Is the use of supererogatory supererogatory?

2007-05-13 Thread Alex Martelli
Paddy [EMAIL PROTECTED] wrote: On May 13, 12:13 am, [EMAIL PROTECTED] (Alex Martelli) wrote: As somebody else alredy pointed out, the lambda is supererogatory (to say the least). What a wonderful new word! I did not know what supererogatory meant, and hoped it had nothing to do

Re: Dynamic subclassing ?

2007-05-13 Thread Alex Martelli
manatlan [EMAIL PROTECTED] wrote: ... def addaclass(aninst, onemoreclass): aninst.__class__ = type(aninst.__aclass__.__name__, (aninst.__aclass__, onemoreclass), {}) ... b=gtk.Button(the_label) addaclass(b,MoreMethods) ... TypeError: __class__ assignment: only for

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Alex Martelli
Bruno Desthuilliers [EMAIL PROTECTED] wrote: Disallowing this does *not* guarantee in any way that identifiers are understandable for English native speakers. I'm not an English native speaker. And there's more than a subtle distinction between not garantying and encouraging. I agree

Re: Basic question

2007-05-13 Thread Alex Martelli
Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 12 May 2007 20:13:48 -0300, Alex Martelli [EMAIL PROTECTED] escribió: Cesar G. Miguel [EMAIL PROTECTED] wrote: --- L = [] file = ['5,1378,1,9', '2,1,4,5'] str='' for item in file: L.append([float(n) for n

Re: Basic question

2007-05-12 Thread Alex Martelli
Cesar G. Miguel [EMAIL PROTECTED] wrote: On May 12, 3:40 pm, Dmitry Dzhus [EMAIL PROTECTED] wrote: Actually I'm trying to convert a string to a list of float numbers: str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] str=53,20,4,2 map(lambda s: float(s), str.split(',')) Last

Re: Dynamic subclassing ?

2007-05-12 Thread Alex Martelli
manatlan [EMAIL PROTECTED] wrote: I've got an instance of a class, ex : b=gtk.Button() I'd like to add methods and attributes to my instance b. I know it's possible by hacking b with setattr() methods. But i'd like to do it with inheritance, a kind of dynamic subclassing, without

<    1   2   3   4   5   6   7   8   9   10   >