Re: Exception not captured

2005-01-11 Thread Roy Smith
In article [EMAIL PROTECTED], Miki Tebeka [EMAIL PROTECTED] wrote: print SCMError is e.__class__ raise SystemExit I get to the second except clause, and the printout is: /home/mikit/work/nightly/scm/common.py:3 /home/mikit/work/nightly/scm/common.py:3 False How is this

Re: why are people still using classic classes?

2005-01-12 Thread Roy Smith
Simon Wittber [EMAIL PROTECTED] wrote: Is there a legitimate use for classic classes that I am not aware of? Is there a reason NOT to use them? If a classic class works fine, what incentive is there to switch to new style classes? I realize it's not much effort to put (object) after your

Re: porting C code

2005-01-13 Thread Roy Smith
Lucas Raab [EMAIL PROTECTED] wrote: I am currently in the process of porting some C code into Python and am stuck. I don't claim to be the greatest C/C++ programmer; in fact, my skills at C are rudimentary at best. My question is I have the statement: typedef unsigned long int word32 and

Re: What strategy for random accession of records in massive FASTA file?

2005-01-14 Thread Roy Smith
In article [EMAIL PROTECTED], Chris Lasher [EMAIL PROTECTED] wrote: Hello, I have a rather large (100+ MB) FASTA file from which I need to access records in a random order. The FASTA format is a standard format for storing molecular biological sequences. Each record contains a header line

Re: java 5 could like python?

2005-01-15 Thread Roy Smith
vegetax [EMAIL PROTECTED] wrote: -No naming convention. The speech of it fits in my head is no longer valid when i use a lot of functionality,modules,classes in a large proyect. For example if i remember a function i want ie:get attribute, i dont remember if the module implementer coded it

Re: why are some types immutable?

2005-01-16 Thread Roy Smith
In article [EMAIL PROTECTED], Dan Bishop [EMAIL PROTECTED] wrote: Roy Smith wrote: Torsten Mohr [EMAIL PROTECTED] wrote: reading the documentation (and also from a hint from this NG) i know now that there are some types that are not mutable. But why is it this way? From

Re: List problems in C code ported to Python

2005-01-16 Thread Roy Smith
Paul McGuire [EMAIL PROTECTED] wrote: A == 'a' is true in Python, not true in C. It could be true in C, if the string is stored in very low memory :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: What is print? A function?

2005-01-23 Thread Roy Smith
Frans Englich [EMAIL PROTECTED] wrote: Nah, I don't think it's a function, but rather a builtin statement. But it's possible to invoke it as an function; print( test ) works fine. That's not calling it as a function. The parens in this case are simply evaluated as grouping operators around

Re: Another scripting language implemented into Python itself?

2005-01-24 Thread Roy Smith
In article [EMAIL PROTECTED], Quest Master [EMAIL PROTECTED] wrote: I am interested in developing an application where the user has an ample amount of power to customize the application to their needs, and I feel this would best be accomplished if a scripting language was available. However,

Re: Another scripting language implemented into Python itself?

2005-01-24 Thread Roy Smith
Rocco Moretti [EMAIL PROTECTED] wrote: The OP doesn't mention his application, but there is something to be said about domain specific scripting languages. A well designed domain-specific scripting language(*) with the appropriate high level constructs can make script writing simpler. This

Re: Another scripting language implemented into Python itself?

2005-01-25 Thread Roy Smith
Carl Banks [EMAIL PROTECTED] wrote: Imbed EMBED. My apologies for being sloppy. And with an initial capital, so it just jumps off the page at you :-) Python, or Perl, or TCL, or Ruby, or PHP, Not PHP. PHP is one of the better (meaning less terrible) examples of what happens when

Re: Another scripting language implemented into Python itself?

2005-01-25 Thread Roy Smith
Cameron Laird [EMAIL PROTECTED] wrote: It's also one that brings Tcl, mentioned several times in this thread, back into focus. Tcl presents the notion of safe interpreter, that is, a sub- ordinate virtual machine which can interpret only specific commands. It's a thrillingly powerful and correct

Re: Help With Python

2005-01-26 Thread Roy Smith
In article [EMAIL PROTECTED], Judi Keplar [EMAIL PROTECTED] wrote: I am currently taking a course to learn Python and was looking for some help. I need to write a Python statement to print a comma- separated repetition of the word, Spam, written 511 times (Spam, Spam, =85 Spam). Can anybody

Re: a sequence question

2005-01-28 Thread Roy Smith
In article [EMAIL PROTECTED], Chris Wright [EMAIL PROTECTED] wrote: Hi, 1) I want to iterate over a list N at a time You could do it with slicing and zip: l = [1, 2, 3, 4, 5, 6, 7, 8] zip (l[::2], l[1::2]) [(1, 2), (3, 4), (5, 6), (7, 8)] To my eyes, that's a bit cryptic, but it works

Re: equivelant of Java's toString() method? (not repr)

2005-02-01 Thread Roy Smith
Alex Hunsley [EMAIL PROTECTED] wrote: I suppose I'm looking for the equivelant of Java's toString() method... That would be str(), which for the most part, just calls your object's __str__() method. If your object doesn't have an __str__() method, there's nothing magic Python can do to invent

Re: PyCon signature advertising

2005-02-01 Thread Roy Smith
In article [EMAIL PROTECTED], Mike C. Fletcher [EMAIL PROTECTED] wrote: Steve Holden wrote: ... I appreciate that not everyone has control over their .sig, ... Take control of your sigs, my sisters and brothers! Viva la Revolution! Follow the Steve into the heat and light of

Re: Python Code Auditing Tool

2005-02-02 Thread Roy Smith
In article [EMAIL PROTECTED], System Administrator [EMAIL PROTECTED] wrote: Does anybody know of a tool that can tell me all possible exceptions that might occur in each line of code? What I'm hoping to find is something like the following: Paul That is impossible. The

Re: variable declaration

2005-02-05 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alexander Zatvornitskiy) wrote: And, one more question: do you think code like this: var S=0 var eps for eps in xrange(10): S=S+ups is very bad? Please explain your answer:) Let me answer that by way of counter-example. Yesterday

Re: Python versus Perl ?

2005-02-06 Thread Roy Smith
[EMAIL PROTECTED] wrote: I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is great for pattern matching, text processing, and automated testing.

Re: variable declaration

2005-02-06 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: This is a good development, overall. Against stupidity, the gods themselves contend in vain; Python's entrance into stupid firms broadens its potential appeal from less than 10% to around 100% of the market, which is

Re: Python versus Perl ?

2005-02-06 Thread Roy Smith
EP [EMAIL PROTECTED] wrote: There are very very few cases where anyone is going to require you to use Python Conversely, it pays to understand when you are likely to be permitted to use it (or any new technology), and when you are likely to be forbidden. Companies are generally the most

Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Roy Smith
In article [EMAIL PROTECTED], John M. Gabriele [EMAIL PROTECTED] wrote: I recently posted this sort of question to the c.l.p.m but didn't get much of a response. I know a little Perl and a little Python, but master neither at the moment. I see that Python is a general purpose OO

Re: Loop in list.

2005-02-08 Thread Roy Smith
Jim [EMAIL PROTECTED] wrote: Where did this type of structure come from: mat = ['a' for i in range(3)]? This will produce a list of three elements but I don't see reference for it in any of the books. It's a list comprehension. Unfortunately, this is a bad example of one, since a much

Re: Loop in list.

2005-02-08 Thread Roy Smith
Jim [EMAIL PROTECTED] wrote: Thanks for the help. Python is somewhat mysterious to an old fortan programer. You might appreciate http://www.python.org/doc/Humor.html#habits -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python as capable as Perl for sysadmin work?

2005-02-09 Thread Roy Smith
In article [EMAIL PROTECTED], Max M [EMAIL PROTECTED] wrote: Jeff Epler wrote: No. Unlike Perl, Python implements only a *finite turning machine* model of computation. An easy way to see this limitation is in the following code: 1.0 / 10.0 0.10001 In an

Re: Unit Testing in Python

2005-02-10 Thread Roy Smith
In article [EMAIL PROTECTED], rhat [EMAIL PROTECTED] wrote: Hi Everyone, I've recently been reading some articles about unit-testing in Python [1] [2], but I am a bit confused: where do I go to get started with this? I tried googling for unittest but all I've found are some old links to

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Roy Smith
In article [EMAIL PROTECTED], David Eppstein [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Leo Breebaart [EMAIL PROTECTED] wrote: What I can't find an explanation for is why str.join() doesn't automatically call str() on its arguments, so that e.g. str.join([1,2,4,5]) would

Re: Python vs Ruby

2005-10-21 Thread Roy Smith
Robert Boyd [EMAIL PROTECTED] wrote: As if Plone, Zope, and (non-Python) Shibboleth weren't getting me enough funny looks. And I haven't even started telling co-workers about Django. A couple of years ago, a head-hunter asked me if I knew Plone. I figured he was just being an idiot and

Re: String Identity Test

2005-11-01 Thread Roy Smith
Duncan Booth [EMAIL PROTECTED] wrote: If 'a!=b' then it will also be the case that 'a is not b' That's true for strings, and (as far as I know), all pre-defined types, but it's certainly possible to define a class which violates that. class isButNotEqual: def __ne__ (self, other):

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Roy Smith
Stuart Turner [EMAIL PROTECTED] wrote: Python is a scripting language like Perl, awk, tcl, Java etc... It is difficult to say whether Python is a scripting language or not until you define what you mean by scripting language. People throw the term scripting language around with wild abandon

Re: Underscores in Python numbers

2005-11-08 Thread Roy Smith
Dave Hansen [EMAIL PROTECTED] wrote: Of course, I write _far_ more code in C than Python. But I've seen enough bugs of the sort where someone wrote 120 when they meant 1200, that I see great value in being able to specify 12_000_000. I'll admit that being able to write 12_000_000

Re: append to non-existing list

2005-11-09 Thread Roy Smith
Yves Glodt [EMAIL PROTECTED] wrote: My question is: Is there no way to append to a non existing list? Nope. The problem (well, part of the problem, anyway) is that when you do: foo.append (bar) what's happening is you're calling foo's append method. If foo doesn't already exist, it has no

Re: append to non-existing list

2005-11-09 Thread Roy Smith
In article [EMAIL PROTECTED], Yves Glodt [EMAIL PROTECTED] wrote: You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in sqlsth] I will look into this, maybe it's what I need, thanks! The list

Re: A Tcl/Tk programmer learns Python--any advice?

2005-11-11 Thread Roy Smith
Robert Hicks [EMAIL PROTECTED] wrote: Why does there need to be OO in the core? That is one thing I have never understood. If you want OO, get a package that fits your style of OO and package require you are off and running. That probably isn't what you would be looking at Tcl for anyway. The

Re: Needed class whose instances are many test cases

2005-11-11 Thread Roy Smith
In article [EMAIL PROTECTED], Ben Finney [EMAIL PROTECTED] wrote: This is a poor design; your tests will each be starting in a different state, and will likely not run the same way if run in a different order, making them fragile. Test cases should each run individually, from a known

Re: is parameter an iterable?

2005-11-15 Thread Roy Smith
In article [EMAIL PROTECTED], py [EMAIL PROTECTED] wrote: I have function which takes an argument. My code needs that argument to be an iterable (something i can loop over)...so I dont care if its a list, tuple, etc. My first thought was to just write your loop inside a try block and catch the

Re: is parameter an iterable?

2005-11-15 Thread Roy Smith
In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED] wrote: try: for item in obj: do_stuff(item) except TypeError, msg: if msg == iteration over non-sequence: handle_non_iterator() else: # re-raise the exception raise That's

Re: is parameter an iterable?

2005-11-16 Thread Roy Smith
In article [EMAIL PROTECTED], Rick Wotnaz [EMAIL PROTECTED] wrote: Steven D'Aprano [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: def foo(inputVal): try: for val in inputVal: # do stuff except TypeError, msg: if msg == iteration over

Re: is parameter an iterable?

2005-11-16 Thread Roy Smith
Steven D'Aprano [EMAIL PROTECTED] wrote: # Create an instance of the exception you expect: try: for i in 0: pass except TypeError, ITER_OVER_NON_SEQ: pass # Now run your code... try: ...blah blah blah... except TypeError, msg if str(msg) == str(ITER_OVER_NON_SEQ):

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: WHY WHY WHY the obsession with one-liners? What is wrong with the good old fashioned way? if cond: x = true_value else: x = false_value It is easy to read, easy to

Re: Underscores in Python numbers

2005-11-19 Thread Roy Smith
[EMAIL PROTECTED] wrote: Alternatively the underscore syntax may be used to separate the number from its base: 22875 == 22875_10 == 595b_16 == 123456_7 But probably this is less commonly useful (and not much explicit). We already have a perfectly good syntax for entering octal and hex

Re: Underscores in Python numbers

2005-11-19 Thread Roy Smith
Steven D'Aprano [EMAIL PROTECTED] wrote: That's a tad unfair. Dealing with numeric literals with lots of digits is a real (if not earth-shattering) human interface problem: it is hard for people to parse long numeric strings. There are plenty of ways to make numeric literals easier to read

Re: Underscores in Python numbers

2005-11-19 Thread Roy Smith
Mike Meyer [EMAIL PROTECTED] wrote: I've seen at least one language (forget which one) that allowed such separators, but only for groups of three. That seems a bit silly. Not all numbers are naturally split into groups of three. Credit card numbers are (typically) split into groups of four.

Re: Underscores in Python numbers

2005-11-20 Thread Roy Smith
Dan Bishop [EMAIL PROTECTED] wrote: creditCardNumber = int('1234''5678''9012''3456''789') Wow, I didn't know you could do that. That's better than my idea. -- http://mail.python.org/mailman/listinfo/python-list

Re: Underscores in Python numbers

2005-11-20 Thread Roy Smith
[EMAIL PROTECTED] (David M. Cooke) wrote: One example I can think of is a large number of float constants used for some math routine. In that case they usually be a full 16 or 17 digits. It'd be handy in that case to split into smaller groups to make it easier to match with tables where these

Re: Preventing modules to be read from current working directory

2005-11-21 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Is there a way to instruct Python to import modules from standard library even if there is one with the same name in the current working directory? I was trying to import BaseHTTPServer.py from standard library but was prevented by a

IPv6 RFC 3542 with socket module?

2005-11-21 Thread Roy Smith
Is there any way to access the RFC 3542 defined macros such as ICMP6_FILTER_SETPASSALL() from within the socket module? A dir() on the socket module (Python 2.4.1, built on a solaris box with IPv6 support) doesn't show anything that looks like it (and socket.has_ipv6 is True). --

Re: Backwards compatibility [was Re: is parameter an iterable?]

2005-11-23 Thread Roy Smith
Fredrik Lundh [EMAIL PROTECTED] wrote: I've said it many times, and I'll say it again: the only fundamentally new concept that has been added since Python 1.5.2 is generators. [...] All the rest is just coloured frosting In my mind, the biggest thing since 1.5.2 is string methods. They are

Re: return in loop for ?

2005-11-24 Thread Roy Smith
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Interestingly, I just saw a thread over at TurboGears(or is it this group, I forgot) about this multiple return issue and there are people who religiously believe that a function can have only one exit point. def f(): r = None for i in

Re: Writing pins to the RS232

2005-11-25 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I want to write to the pins of an RS232 without using the serial protocol. The use would be every pin could act to complete a circuit in customized hardware. I could use python to communicate serially to a BASIC stamp

Re: icmp - should this go in itertools?

2005-11-25 Thread Roy Smith
Tom Anderson [EMAIL PROTECTED] wrote: It's modelled after the way cmp treats lists - if a and b are lists, icmp(iter(a), iter(b)) should always be the same as cmp(a, b). Is this any good? Would it be any use? Should this be added to itertools? Whatever happens, please name it something

Estimating memory use?

2005-11-27 Thread Roy Smith
I've got a large text processing task to attack (it's actually a genomics task; matching DNA probes against bacterial genomes). I've got roughly 200,000 probes, each of which is a 25 character long text string. My first thought is to compile these into 200,000 regexes, but before I launch

Re: Estimating memory use?

2005-11-27 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: Roy Smith [EMAIL PROTECTED] wrote: ... Is there any easy way to find out how much memory a Python object takes? No, but there are a few early attempts out there at supplying SOME ways (not necessarily easy

Re: Writing pins to the RS232

2005-11-27 Thread Roy Smith
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: While I realize this is more on a driver/hardware level it's interesting that it's so difficult to use a different protocol for an existing driver. For example, all serial does is a series of high and low voltages on specific pins. Why should it be

Looking for good beginner's tutorial

2005-11-29 Thread Roy Smith
My wife wants to learn Python. Can anybody suggest a good tutorial for her to read? She's a PhD molecular biologist who is a pretty advanced Unix user. She mucks about with Perl scripts doing things like text processing and even some simple CGI scripts, but has no formal programming training.

Re: Looking for good beginner's tutorial

2005-11-29 Thread Roy Smith
In article [EMAIL PROTECTED], Kent Johnson [EMAIL PROTECTED] wrote: Roy Smith wrote: My wife wants to learn Python. Can anybody suggest a good tutorial for her to read? She's a PhD molecular biologist who is a pretty advanced Unix user. She mucks about with Perl scripts doing things

Re: Seeking Python + Subversion hosting.

2004-12-06 Thread Roy Smith
[EMAIL PROTECTED] (Tom Locke) wrote: Anyone know of a good hosting company that offers both server-side Python and a subversion repository? Panix (www.panix.com) has svn and python installed on their unix hosts. You could certainly do CGI in python. Don't know if they have mod_python

Re: Ptyon 2.3.5 probably coming in January; get your bugs/patches reported!

2004-12-06 Thread Roy Smith
In article [EMAIL PROTECTED], Brett C. [EMAIL PROTECTED] wrote: Anthony Baxter, our ever-diligent release manager, mentioned this past week that Python 2.3.5 will most likely come to fruition some time in January (this is not guaranteed date). Interesting. Does that mean that 2.3 and 2.4

Namespaces and the timeit module

2004-12-13 Thread Roy Smith
I'm playing with the timeit module, and can't figure out how to time a function call. I tried: def foo (): x = 4 return x t = timeit.Timer (foo()) print t.timeit() and quickly figured out that the environment the timed code runs under is not what I expected: Traceback (most recent

Re: [dictionary] how to get key by item

2004-12-13 Thread Roy Smith
Skip Montanaro [EMAIL PROTECTED] wrote: Roy BTW, does Python really build the intermediate list and throw it Roy away after using it to initialize the dictionary, or is it smart Roy enough to know that it doesn't really need to build the whole list Roy in memory? That's why

Re: cmp of multiple attributes (WAS: Why are tuples immutable?)

2004-12-16 Thread Roy Smith
Roy Smith wrote: def __cmp__ (self, other): # I wish there was a less verbose way to do this! if self.block other.block: return -1 if self.block other.block: return 1 if self.lot other.lot: return -1

Re: [dictionary] how to get key by item

2004-12-14 Thread Roy Smith
In article [EMAIL PROTECTED], Skip Montanaro [EMAIL PROTECTED] wrote: Egor i know how to get item by key ... Egor but i wonder how to get key by item Assuming your dictionary defines a one-to-one mapping, just invert it: forward = {10 : 50, 2 : 12, 4 : 43} reverse

Re: [dictionary] how to get key by item

2004-12-14 Thread Roy Smith
Delaney, Timothy C (Timothy) [EMAIL PROTECTED] wrote: Python will do what you tell it. Certainly it does. The problem is that sometimes what I told it to do and what I think I told it to do are two different things :-) Using Python 2.4, the above can be rewritten as a generator expression:

Re: Namespaces and the timeit module

2004-12-14 Thread Roy Smith
[EMAIL PROTECTED] (David M. Cooke) wrote: It seems kind of surprising that I can't time functions. Am I just not seeing something obvious? Like the documentation for Timer? :-) class Timer([stmt='pass' [, setup='pass' [, timer=timer function]]]) You can't use statements defined

Re: Regular Expression

2004-12-15 Thread Roy Smith
Michael McGarry [EMAIL PROTECTED] wrote: I am horrible with Regular Expressions, can anyone recommend a book on it? I just did a search on the Barnes Noble site for regular expression and came up with a bunch of books. The following looks reasonable:

Re: Why are tuples immutable?

2004-12-15 Thread Roy Smith
Jp Calderone [EMAIL PROTECTED] wrote: Dictionaries support mutable keys just find. What they don't support is unhashable keys. For some objects, this is an important distinction: lists are mutable but not hashable. Of course, you could subclass list to make a mutable, hashable list:

Re: argument type

2004-12-28 Thread Roy Smith
It's me [EMAIL PROTECTED] wrote: How can I tell from within a function whether a particular argument is a sigular type, or a complex type? ... In C++, you would do it with function overloading. If arg1 is always simple type, I wouldn't care what it is. But what if I *do* need to know

Re: pyUnitPerf

2004-12-28 Thread Roy Smith
Grig [EMAIL PROTECTED] wrote: Problem with porting patterns/api's from java straight to python is that most of the outcome feels unpythonic. I'll not go about my own feelings python vs. java here now, but I just want to point out that there's already a rather large core of hard-python users

Re: Why tuples use parentheses ()'s instead of something else like 's?

2004-12-29 Thread Roy Smith
In article [EMAIL PROTECTED], Grant Edwards [EMAIL PROTECTED] wrote: On 2004-12-29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Tuples are defined with regards to parentheses ()'s as everyone knows. Except they're not. x = 1,2,3,4 type(x) type 'tuple' Tuples are defined by

Re: Why tuples use parentheses ()'s instead of something else like 's?

2004-12-29 Thread Roy Smith
John Roth [EMAIL PROTECTED] wrote: If Python had originally been invented in a unicode world, I suppose we wouldn't have this problem. We'd just be using guillemots for tuples (and have keyboards which made it easy to type them). I suppose the forces of darkness will forever keep Python

Re: Why tuples use parentheses ()'s instead of something else like 's?

2004-12-29 Thread Roy Smith
In article [EMAIL PROTECTED], Reinhold Birkenfeld [EMAIL PROTECTED] wrote: + being an operator Looks more like a smiley for guy wearing a bowtie -- http://mail.python.org/mailman/listinfo/python-list

Re: Why tuples use parentheses ()'s instead of something else like 's?

2004-12-29 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Reinhold Birkenfeld [EMAIL PROTECTED] wrote: + being an operator Looks more like a smiley for guy wearing a bowtie You know

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Roy Smith
Ian Bicking [EMAIL PROTECTED] wrote: I think this specific use case -- defining callbacks -- should be addressed, rather than proposing a solution to something that isn't necessary. Which is to say, no one *needs* anonymous functions; people may need things which anonymous functions

Re: what is lambda used for in real code?

2005-01-01 Thread Roy Smith
In article [EMAIL PROTECTED], Adam DePrince [EMAIL PROTECTED] wrote: We can operate on every other class without having to involve the namespace, why should functions be any different? def is a weird beast. It does more than just bind a lambda to a name, it also alters the function so it

Re: The Industry choice

2005-01-02 Thread Roy Smith
Stefan Axelsson [EMAIL PROTECTED] wrote: Yes, ignoring most of the debate about static vs. dynamic typing, I've also longed for 'use strict'. You can use __slots__ to get the effect you're after. Well, sort of; it only works for instance variables, not locals. And the gurus will argue that

Re: The Industry choice

2005-01-02 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Steve Holden [EMAIL PROTECTED] wrote: Aahz wrote: In article [EMAIL PROTECTED], Paul Rubin http://[EMAIL PROTECTED] wrote: I was pretty skeptical of Java's checked exceptions when I first

Re: The Industry choice

2005-01-02 Thread Roy Smith
[EMAIL PROTECTED] (Cameron Laird) wrote: Let me add a cautionary note, though: Big Companies, including Oracle, Software AG, IBM, Cisco, and so on, have adopted Tcl over and over. All of them still rely on Tcl for crucial products. All of them also have employees who sincerely wonder,

Re: The Industry choice

2005-01-02 Thread Roy Smith
Terry Reedy [EMAIL PROTECTED] wrote: None has been reserved because there is no known good use for overriding it. Should I infer from the above that there's a known bad use? True and False will be reserved someday. I remember a lisp I used many years ago. If you tried to rebind nil, you

Re: Developing Commercial Applications in Python

2005-01-03 Thread Roy Smith
Stephen Waterbury [EMAIL PROTECTED] wrote: Shaw-PTI (www.pti-us.com) uses Python in their software. ... but the Python Powered logo is conspicuous by its absence from their site. Too bad that some commercial exploiters of Python don't advertise that fact more often. Companies use all sorts of

Re: coding conventions, PEP vs. practice

2005-01-04 Thread Roy Smith
Roman Roelofsen [EMAIL PROTECTED] wrote: These frameworks are using mixedCase but PEP8 suggests lower_case_with_underscores except in contexts where that's already the prevailing style which is not the case here IMHO. So, are there any specific reasons for breaking the rules here? I think

Building unique comma-delimited list?

2005-01-05 Thread Roy Smith
I've got a silly little problem that I'm solving in C++, but I got to thinking about how much easier it would be in Python. Here's the problem: You've got a list of words (actually, they're found by searching a data structure on the fly, but for now let's assume you've got them as a list). You

Re: Getting rid of self.

2005-01-07 Thread Roy Smith
Simon Brunning [EMAIL PROTECTED] wrote: On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez [EMAIL PROTECTED] wrote: The word self is not mandatory. You can type anything you want instead of self, as long as you supply a keyword in its place (it can be self, s or whatever you want). You *can*,

Re: Getting rid of self.

2005-01-07 Thread Roy Smith
In article [EMAIL PROTECTED], John Roth [EMAIL PROTECTED] wrote: Roy Smith [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Simon Brunning [EMAIL PROTECTED] wrote: On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez [EMAIL PROTECTED] wrote: The word self is not mandatory. You can type

Re: how to extract columns like awk $1 $5

2005-01-07 Thread Roy Smith
In article [EMAIL PROTECTED], Anand S Bisen [EMAIL PROTECTED] wrote: Hi Is there a simple way to extract words speerated by a space in python the way i do it in awk '{print $4 $5}' . I am sure there should be some but i dont know it. Something along the lines of: words = input.split() print

Re: EOF for binary?

2005-01-07 Thread Roy Smith
In article [EMAIL PROTECTED], flamesrock [EMAIL PROTECTED] wrote: Hi, So if I understand correctly, there are NO eof characters in any binary file. If so, is there an easier way to check for the end of the file than: os.path.getsize(infile) = infile.tell() How you detect EOF depends on

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread Roy Smith
In article [EMAIL PROTECTED], James Stroud [EMAIL PROTECTED] wrote: On Friday 07 January 2005 01:24 pm, Paul Rubin wrote: Nick Coghlan [EMAIL PROTECTED] writes: Add in the fact that there are many, many Python programmers with non-CS backgrounds, and the term 'lambda' sticks out like a

Re: Getting rid of self.

2005-01-07 Thread Roy Smith
Jeremy Bowers [EMAIL PROTECTED] wrote: were I programming in C++ routinely now I'd prefix this and dispense with that ugly m_ garbage. (One of the things I ***hate*** about C++ culture is its acceptance of hideously ugly variable names, but now I'm two parentheticals deep so I probably

Re: how to extract columns like awk $1 $5

2005-01-07 Thread Roy Smith
Dan Valentine [EMAIL PROTECTED] wrote: On Fri, 07 Jan 2005 12:15:48 -0500, Anand S Bisen wrote: Is there a simple way to extract words speerated by a space in python the way i do it in awk '{print $4 $5}' . I am sure there should be some but i dont know it. i guess it depends on how

Re: Scientific Notation

2005-12-03 Thread Roy Smith
In article [EMAIL PROTECTED], Dustan [EMAIL PROTECTED] wrote: 1000 print %e % 1000 1.00e+51 -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: no arguments expected

2005-12-11 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: put self as the first argument in all instance methods of that class. self is just a convention, referring to the object instance, not a language feature as in other language like javascript. You can call it me too if you prefer. But

Re: Why and how there is only one way to do something?

2005-12-15 Thread Roy Smith
In article [EMAIL PROTECTED], John Hazen [EMAIL PROTECTED] wrote: * Chris Mellon [EMAIL PROTECTED] [2005-12-15 06:09]: (Am I dating myself? Do teenagers still put studs on their jackets?) No. They put studs in their lips, tongues, eyebrows, navels, and sexual organs. Oh, and ears.

Re: How to check if a string is an int?

2005-12-21 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How do I check if a string contains (can be converted to) an int? I want to do one thing if I am parsing and integer, and another if not. /David The most straight-forward thing is to try converting it to an int and

Re: What is unique about Python?

2005-12-23 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: gsteff [EMAIL PROTECTED] wrote: ... that's not really what I'm looking for. So I'm wondering, what is innovative about Python, The letter 'y'. Before Python, it was woefully underused in the names of

Re: What is unique about Python?

2005-12-24 Thread Roy Smith
Szabolcs Nagy [EMAIL PROTECTED] wrote: iterpreter (very useful for learning) In my mind, this is the coolest feature of all. Most of the time, I don't even bother looking stuff up in the docs; it's faster to just fire up an interpreter and try something. Functions like: dir(obj) /

How to signal not implemented yet?

2005-12-25 Thread Roy Smith
Is there some standard way to signal not implemented yet in unfinished code? When I'm coding, I'll often only flesh out one side of a branch, or delay writing some method until later. It would be nice to be able to identify these right in the code to make sure they don't get forgotten about. I

Re: How to signal not implemented yet?

2005-12-25 Thread Roy Smith
In article [EMAIL PROTECTED], Tim Peters [EMAIL PROTECTED] wrote: [Roy Smith] Is there some standard way to signal not implemented yet in unfinished code? raise NotImplementedError That's a builtin exception. Ah, that's exactly what I was looking for. Thanks. -- http://mail.python.org

predicting function calls?

2005-12-27 Thread Roy Smith
I think I know the answer to this, but I'll ask it just in case there's something I hadn't considered... I'm working on a python interface to a OODB. Communication with the DB is over a TCP connection, using a model vaguely based on CORBA. I'll be creating object handles in Python which are

Re: predicting function calls?

2005-12-28 Thread Roy Smith
Steven D'Aprano [EMAIL PROTECTED] wrote: How do you decide whether handle.foo should be treated as an attribute or an operation? That's exactly what I'm trying to figure out. In the legacy system I'm trying to emulate, the interpreter knows the from syntax (i.e. whether handle.foo is

Re: predicting function calls?

2005-12-28 Thread Roy Smith
In article [EMAIL PROTECTED], Mike Meyer [EMAIL PROTECTED] wrote: Fnorb (a pure-Python CORBA orb) dealt with this by not allowing attributes per se. Instead, it provided _get_AttributeName and _set_AttributeName as appropriate for each attribute in the IDL. Doing this means that *everything*

Re: predicting function calls?

2005-12-31 Thread Roy Smith
In article [EMAIL PROTECTED], Ernst Noch [EMAIL PROTECTED] wrote: Couldn't you just, for every access to a member of your object, first try to treat is as an access to an operation? If this fails (you mentioned the db will throw an error if this is an attribute instead of an operation),

  1   2   3   4   5   6   7   8   9   10   >