Re: Python obfuscation

2005-11-10 Thread Mike Meyer
secured? >> Previous version of these software products used sophisticated >> client-side programming to try and be secure, but the security was >> nonexistant. Users share keys and cracks with each other. > Mike Meyer wrote: > > What makes you think this is the case? T

Re: Command-line tool able to take multiple commands at one time?

2005-11-10 Thread Mike Meyer
Peter A. Schott <[EMAIL PROTECTED]> writes: > Per subject - I realize I can copy/paste a line at a time into an interactive > session when I'm trying to debug, but was wondering if there is any tool out > there that allows me to copy sections of working Python scripts to paste into > my > interact

Re: Change directory not successfully done

2005-11-10 Thread Mike Meyer
Samuel Yin <[EMAIL PROTECTED]> writes: > Hi, guys, > > This should be a simple problem, but I just can not resolve it. I just > want to use a python script to change my working directory. see my > following code: > > # mycd.py > 1) destdir = "" > 2) command = "cd "+ destdir > 3) os.system(c

Re: Abstract Base Classes

2005-11-10 Thread Mike Meyer
Ben Finney <[EMAIL PROTECTED]> writes: > I've tried doing this in the __init__(): > > class FooException(Exception): > """ Base class for all FooModule exceptions """ > def __init__(self): > raise NotImplementedError, \ > "%s is an abstract class for

Re: how can i get system time?

2005-11-10 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hi, Can I get a system date time? time.time() > I want to get current time, like > the target string should looks like: > the output of : `date +"%Y%m%d %H:%M:%S"` > > how can i do this? >>> time.strftime("%Y%m%d %H:%M:%S") '2005 02:44

Re: LARGE numbers

2005-11-11 Thread Mike Meyer
"Tuvas" <[EMAIL PROTECTED]> writes: > I've been thinking about writing a program to generate the world's > largest prime numbers, just for the fun of it. This would require being > able to hold an 800 digit number into memory (25 megabits, or a > little over 3 megs of memory for just one varia

Re: Python obfuscation

2005-11-11 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: >> A recent, heavily >> publicized case where Sony added copy protection to a product cost >> them sales, and from what I've heard, even legal fees. > I think that's a poor example - the cost hasn't come from the mere act > of adding protection, but the metho

Re: Python obfuscation

2005-11-11 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> There are ways to distribute >> Python modules so that the user can't just open them in a text >> editor. There are also ways to get cryptographic security for >> distributed modules. &g

Re: os.chown()

2005-11-11 Thread Mike Meyer
James Colannino <[EMAIL PROTECTED]> writes: > Hey everyone. I tried to use os.chown() in the following manner: > > os.chown('filename', 'username', 'groupname') > > I got an error, and when I googled for this function I realized that I > must pass the numerical uid and gid. My question is, is th

Re: weird problem with os.chmod

2005-11-11 Thread Mike Meyer
James Colannino <[EMAIL PROTECTED]> writes: > James Colannino wrote: > >> So then I entered the command print 0600, and saw that the actual >> number being output was 384 (why would it output 384?!) >> >> > > Ok, so further research revealed that 0600 is actually the octal > representation for 384

Re: changeing users on linux

2005-11-11 Thread Mike Meyer
[EMAIL PROTECTED] writes: > how would i go about makeing a program in python that asks for username > and password and changes to that user? For some definition of "changes to that user": # Untested code from pwd import getpwnam from os import setuid setuid(getpwnam(raw_input("Who do you want to

Re: Python obfuscation

2005-11-11 Thread Mike Meyer
My, we're about to get *seriously* off topic. Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Fri, 11 Nov 2005 11:17:43 -0500, Mike Meyer wrote: >>> I'd just like to make it non-trivial to make or use additional copies. >> How do you do that without infri

Re: Python obfuscation

2005-11-12 Thread Mike Meyer
n > recuperated your costs. If you don't, you probably lost 5 minutes of > development time. Is this a worthwhile gamble? I believe so. And if instead you lose one customer because you've denied them their fair use rights, then your copy protection has lost you more in the form of a c

Re: changeing users on linux

2005-11-12 Thread Mike Meyer
[EMAIL PROTECTED] writes: > the password is for loging into root The setuid call will fail unless you're already root. You can't, as some user other than root, change your userid, so the answer to the original question with the added restriction is "You can't". http://www.

Re: passing values from one form to another

2005-11-12 Thread Mike Meyer
[EMAIL PROTECTED] writes: > In main.py, i am able to check for the value of the user and password > field, eg > > if form.has_key("user") and form["button"].value == "Login" and > form.has_key("password"): > # show all fields > > how can i also check for the user field in the results.py script? i

Re: newbie how do I interpret this?

2005-11-12 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Here's a small session > import re p=re.compile('[a-z]+') m=p.match('abb1a') dir(m) > ['__copy__', '__deepcopy__', 'end', 'expand', 'group', 'groupdict', > 'groups', 'span', 'start'] help(m.groups) > Help on built-in function groups: > > groups(

Re: Python obfuscation

2005-11-12 Thread Mike Meyer
Paul Rubin writes: > "The Eternal Squire" <[EMAIL PROTECTED]> writes: >> Without copyright, how could one possibly earn a living writing a >> novel? > This guy seems to be doing ok: http://craphound.com > His publishers are the only ones allowed to sell his novels comm

Re: Proposal for adding symbols within Python

2005-11-12 Thread Mike Meyer
Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes: > Please, note that I am entirely open for every points on this proposal > (which I do not dare yet to call PEP). > > Abstract > > > This proposal suggests to add symbols into Python. You're also proposing adding a syntax to generate s

Re: Multikey Dict?

2005-11-12 Thread Mike Meyer
David Rasmussen <[EMAIL PROTECTED]> writes: > If I have a collection of dicts like: > john = {'id': 1, 'name': "John Cleese", 'year': 1939} > graham = {'id': 2, 'name': "Graham Chapman", 'year': 1941} > I could store all of them in a list. But for easy lookup, I might > store all these in a dict i

Re: Copyright [was Re: Python obfuscation]

2005-11-12 Thread Mike Meyer
"The Eternal Squire" <[EMAIL PROTECTED]> writes: >>Copyright is a gift granted by the government, not the natural state of >>the world. When kings and emperors and presidents give commercial and >>economic gifts, like monopolies, they rarely are for the benefit of the >>majority. > Last I knew, we

Re: Proposal for adding symbols within Python

2005-11-13 Thread Mike Meyer
Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes: >>>In LISP : Symbols are introduced by "'". "'open" is a symbol. >> No, they're not. "'(a b c)" is *not* a symbol, it's a list. Symbols in >> LISP are just names. "open" is a symbol, but it's normally evaluated. >> The "'" is syntax that keeps t

Re: Copyright

2005-11-13 Thread Mike Meyer
"The Eternal Squire" <[EMAIL PROTECTED]> writes: >>Further, recent evidence is that this is no longer true in that >>country, assuming it ever was. > Wow, how Machiaviellian. Just an observation on the state of the US. It's been a long while since the people running the country did so for the peop

Re: Copyright

2005-11-13 Thread Mike Meyer
Erik Max Francis <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> Further, recent evidence is that this is no longer true in that >> country, assuming it ever was. > Oh, please. Take the political crap elsewhere. It's got as much right to be here as the copyright

Re: Addressing the last element of a list

2005-11-14 Thread Mike Meyer
Antoon Pardon <[EMAIL PROTECTED]> writes: > Op 2005-11-10, Mike Meyer schreef <[EMAIL PROTECTED]>: >> [Context recovered from top posting.] >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >>> Daniel Crespo wrote: >>>> Well, I h

Re: Python obfuscation

2005-11-14 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: >> It is? Is the Python disassembler so much advanced over the state of >> the art of binary disassemblers, then? Or maybe it's the Python >> decompilers that are so advanced? > Decompyle (http://www.crazy-compilers.com/decompyle/ ) claims to be > pretty adva

Re: Addressing the last element of a list

2005-11-15 Thread Mike Meyer
Antoon Pardon <[EMAIL PROTECTED]> writes: >>> Like having an assignment operator (let use @= for it) next to a >>> (re)bind operator. >>> We could then have something like the following. >>> a = 5 >>> b = a >>> a @= 7 >>> b ==> would result in 7. >> You've just overwritten the object referred to by

Re: Python obfuscation

2005-11-15 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: >> But we can be >> explicit if you want: How do you do that without requiring that your >> software be given special consideration in the distaster recovery and >> preparedness planning? > I should state that I am not at all claiming a "one size fits all" >

Re: Default method arguments

2005-11-15 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Hello everybody! > I have little problem: > > class A: > def __init__(self, n): > self.data = n > def f(self, x = ) > print x > > All I want is to make self.data the default argument for self.f(). (I > want to use 'A' class as following : St

Re: Default method arguments

2005-11-15 Thread Mike Meyer
Benji York <[EMAIL PROTECTED]> writes: > I'll add my 2 cents to the mix: > > default = object() > > class A(object): > def __init__(self, n): > self.data = n > > def f(self, x=default): > if x is default: > x = self.data > print x There were a lot

Re: newbie - How do I import automatically?

2005-11-15 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I have written some functions in a file called btools.py. I would like > to import them automatically when I start up Python shell. Today I must > do it by hand like this > from btools import * dir() > ['__builtins__', '__doc__', '__name__', 'func1', 'func2',

Re: Default method arguments

2005-11-15 Thread Mike Meyer
"Gregory Petrosyan" <[EMAIL PROTECTED]> writes: > I'm not very familiar with Python, so please explain me why should > containers be used? > For example in one of Paul Graham's essays there's an example of > 'generator of accumulators' in Python: > > def foo(n): > s = [n] > def bar(i): >

Re: newbie - How do I import automatically?

2005-11-15 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I've tried as you said but it doesn't work. I'm working with Windows > XP. I right click at my computer go to Advanced, choose Environment > Variables and set PYTHONSTARTUP variable to C:\Python24\binit.py. It > looks like this > > # binit.py > from btools import * > > I

Re: Python obfuscation

2005-11-15 Thread Mike Meyer
Erik Max Francis <[EMAIL PROTECTED]> writes: > Chris Mellon wrote: >> I don't know about you, but I own the copyright to almost nothing that >> I have written and been paid for, and further, none of has it's >> copyright exploited to make money for the entity that does own the >> copyright. > But t

Re: Newb ?

2005-11-15 Thread Mike Meyer
"Chad Everett" <[EMAIL PROTECTED]> writes: > print "\n\nWelcome to the Backwards Message Display." > print > message = raw_input("\nPlease Enter a Message.") Since you said it wasn't a school assignment, and I'm a trusting soul, the next line could be: print message[::-1]

Re: Addressing the last element of a list

2005-11-16 Thread Mike Meyer
Antoon Pardon <[EMAIL PROTECTED]> writes: > Op 2005-11-15, Mike Meyer schreef <[EMAIL PROTECTED]>: >> Antoon Pardon <[EMAIL PROTECTED]> writes: >>>>> Like having an assignment operator (let use @= for it) next to a >>>>> (re)bind operat

Re: using openurl to log into Yahoo services

2005-11-16 Thread Mike Meyer
it', intag['value'])) else: print "Login form had unrecognized input tag:", str(intag) out = BeautifulSoup(urlopen(form['action'], urlencode(postdata)).read()) out.done() return out def meta_redirect(value): ""&quo

Re: Python obfuscation

2005-11-16 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> "Ben Sizer" <[EMAIL PROTECTED]> writes: >> > In my >> > case, providing a free download of any lost executables or data upon >> > presentation of a legitimate licen

Re: How to write an API for a Python application?

2005-11-16 Thread Mike Meyer
"Eric Brunel" <[EMAIL PROTECTED]> writes: > On 16 Nov 2005 06:18:05 -0800, Paul Boddie <[EMAIL PROTECTED]> wrote: >> One technology that I used many years ago with Python, and which should >> still do the job is CORBA - at that time ILU, but I suppose the various >> other ORBs should also be as cap

Re: Python obfuscation

2005-11-16 Thread Mike Meyer
"The Eternal Squire" <[EMAIL PROTECTED]> writes: > A fair request. The teaching of legality and ethics of incorporating > other peoples' works into one's own should begin at 6th grade and be > repeated every year until the message is driven home. Right. You want to teach potential programmers th

Re: JMS yet again

2005-11-16 Thread Mike Meyer
Ben Finney <[EMAIL PROTECTED]> writes: > Aahz <[EMAIL PROTECTED]> wrote: >> Am I the only person who immediately thought of Babylon 5 and >> wondered if I was in the wrong newsgroup? > > I plead guilty. Well, I thought of Crusade. But I'd just finished watching those. htt

python-dev Summary for 2005-09-01 to 2005-09-15

2005-11-16 Thread Tony Meyer
1.165.2.2 `__ - `Variant of removing GIL. <http://mail.python.org/pipermail/python- dev/2005-September/056423.html>`__ - `Compatibility between Python 2.3.x and Python 2.4.x `__ - `Example for "property" violates "Python is not a one pass compiler" <http://mail.py

Re: Python obfuscation

2005-11-16 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >> Alex's solution doesn't require special treatment for disaster >> recovery and/or planning, and as such is a valid answer to the > I'm not sure I understand this. I would a

Re: python-mysqldb__debian_to_freebsd

2005-11-16 Thread Mike Meyer
Damjan <[EMAIL PROTECTED]> writes: >> Is there any at all chance that this will work >> with the proper configs or should I go ahead >> and beg the host for an installation ? > It seems to me very unlikely that a program compiled for FreeBSD would link > to a library compiled for Debian Linux

Re: python-dev summary

2005-11-17 Thread Tony Meyer
On 17/11/2005, at 7:20 PM, Titus Brown wrote: >> [The HTML version of this Summary is available at >> http://www.python.org/dev/summary/2005-09-01_2005-09-15.html] > > no... no, it's not ;) Sorry; I should amend the copy that's posted to say "will be available". The summaries get posted here,

Re: How to write an API for a Python application?

2005-11-17 Thread Mike Meyer
"Eric Brunel" <[EMAIL PROTECTED]> writes: > On Wed, 16 Nov 2005 15:43:33 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: > >> "Eric Brunel" <[EMAIL PROTECTED]> writes: >>> On 16 Nov 2005 06:18:05 -0800, Paul Boddie <[EMAIL PROTECTED]>

Re: Python obfuscation

2005-11-17 Thread Mike Meyer
Chris Mellon <[EMAIL PROTECTED]> writes: > Your rights are anything you can do that is not forbidden - the US > constitution is explicitly designed in this way, something that people > often forget. There is no difference between an "explicit" and an > "inferred" right, by design. If you read the t

Re: install python2.4 on FreeBSD and keep using python2.3

2005-11-17 Thread Mike Meyer
Ksenia Marasanova <[EMAIL PROTECTED]> writes: > Hi, > > I have python2.3, installed from port /lang/python long time ago. The > current version is 2.4, but I'd rather have two python versions, > instead of upgrading. > Is there maybe a way to somehow link installed python to > /lang/python2.3 port

Re: How to write an API for a Python application?

2005-11-17 Thread Mike Meyer
[EMAIL PROTECTED] (Cameron Laird) writes: > In article <[EMAIL PROTECTED]>, > Paul Boddie <[EMAIL PROTECTED]> wrote: > . >>meaning that callbacks and other things just work. Rolling your own >>solution, on the other hand, can end in a long road discovering what >>those CORBA p

Re: Zope vs Php

2005-11-17 Thread Mike Meyer
"Steve" <[EMAIL PROTECTED]> writes: > I am going to go the mod_python route. > > as for why a person would go route one over route 2 > > is that the number of lines of html/output vs python code are usually > 10 to 1 and it's much easier to encapsulate the python code than to > quote and escape al

Re: Importing a class without knowing the module

2005-11-17 Thread Mike Meyer
Franck PEREZ <[EMAIL PROTECTED]> writes: > ### My test application > class Foo(object): > #The class I'd like to serialize > pass > > import myMarshaller > foo = Foo() > s = myMarshaller.dumps(foo) #works fine, spits something like class = "Foo"...> > another_foo = loads(s

Re: Importing a class without knowing the module

2005-11-17 Thread Mike Meyer
[Format recovered from top posting.] Franck PEREZ <[EMAIL PROTECTED]> writes: > On 11/18/05, Mike Meyer <[EMAIL PROTECTED]> wrote: >> Franck PEREZ <[EMAIL PROTECTED]> writes: >> > ### My test application >> > class Foo(obj

Re: Zope vs Php

2005-11-17 Thread Mike Meyer
Jorge Godoy <[EMAIL PROTECTED]> writes: > Mike Meyer <[EMAIL PROTECTED]> writes: >> That said, I have to confess that lately I've been using Cheetah >> templates, because the syntax for inserting values is simpler, and the >> way Cheetah templates wo

Re: Importing a class without knowing the module

2005-11-17 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >> >> How about adding Foo.__file__ to the serialized data? >> > I thought about it, but it would make the XML file depend on the >> > machine... no more portability... >

Re: install python2.4 on FreeBSD and keep using python2.3

2005-11-17 Thread Mike Meyer
Xiao Jianfeng <[EMAIL PROTECTED]> writes: > Can I install python2.4.2 and keep using python2.4.1 on IRIX? Yes, but you'll have to install it with a different prefix. Use the --prefix flag to configure when you install it. http://www.mired.org/home/mwm/ Independent WWW/

Re: Zope vs Php

2005-11-17 Thread Mike Meyer
Jorge Godoy <[EMAIL PROTECTED]> writes: >> While I'm at it - how does KID do for things that aren't HTML? >> Cheetah integrates with web servers, but can be used to generate >> nearly anything. I've found that using Cheetah scripts to build >> Makefiles that run Cheetah scripts to build a dynamical

Re: Importing a class without knowing the module

2005-11-17 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >... >> >> >> How about adding Foo.__file__ to the serialized data? >... >> >> depends on somewhere on it. You can use the module name if you have it >> >

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread Mike Meyer
Steve Holden <[EMAIL PROTECTED]> writes: > Fredrik Lundh wrote: >> Chad Everett wrote: >>>I am back. >>>No I am not a high school or college student. >> your subject lines still suck. please read this >> http://www.catb.org/~esr/faqs/smart-questions.html#bespecific >> before you post your next

Re: Importing a class without knowing the module

2005-11-18 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >... >> A classes __module__ attribute doesn't always tell you the name of the >> module - or at least, not a name that would be usefull for the the OPs >> use case. That&

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Mike Meyer
"Daniel Crespo" <[EMAIL PROTECTED]> writes: > Hi! > > I would like to know how can I do the PHP ternary operator/statement > (... ? ... : ...) in Python... > > I want to something like: > > a = {'Huge': (quantity>90) ? True : False} > > Any suggestions? Lots of ways, depending on your exact needs

Re: Importing a class without knowing the module

2005-11-18 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >... >> > How do you arrange a module so that its classes' __module__ attributes >> > don't tell you the name of the module "that would be useful", yet the >

Re: Choose meaningful subjects for posts

2005-11-18 Thread Mike Meyer
Micah Elliott <[EMAIL PROTECTED]> writes: > On Nov 18, [EMAIL PROTECTED] wrote: >> Grant> Obligatory aside: I'm completely baffled why anybody would choose >> Grant> the mailing list format over Usenet. I don't even read mailing >> Grant> lists via mailing lists. I recommend gmane.org

Re: Importing a class without knowing the module

2005-11-18 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > You did help me to better understand some of the roots of your many > mistaken assertions in this thread, from your first "How about adding > Foo.__file__" proposal onwards, yes -- thank you. I claim I haven't made a single mistaken assertion in this th

Re: Hot to split string literals that will across two or more lines ?

2005-11-19 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Brackets include: > > parentheses or round brackets ( ) > square brackets [ ] > braces or curly brackets { } > chevrons or angle brackets 〈 〉 > > The symbols for chevrons are not available on common keyboards, are not > available in ordinary ASCII,

Re: Underscores in Python numbers

2005-11-19 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Sat, 19 Nov 2005 13:08:57 -0500, Peter Hansen wrote: >> Umm... in other words, "the underscore is under-used so let's assign >> some arbitrary meaning to it" (to make the language more like Perl >> perhaps?). > > +1 > > I *really* don't like the id

Re: newbie-question about a list

2005-11-19 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I've seen this construct in a script [x.capitalize() for x in ['a','b', 'c']] > ['A', 'B', 'C'] > I tried to find a description of this in "Library Reference" but > couldn't find it. Could somebody direct me where this type of construct > is described. As others ha

Re: Can a function access its own name?

2005-11-19 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Thanks Diez and Peter, > Just what I was looking for. In "Library Reference" heading > 3.11.1 Types and members > Running this yields the result > > cap(s, n) You've now got three solutions. They'll work fine most of the time, but can't be trusted in general. Bindin

Re: Underscores in Python numbers

2005-11-19 Thread Mike Meyer
Roy Smith <[EMAIL PROTECTED]> writes: > 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 in

Re: Delays getting data on sys.stdin.readline() ?

2005-11-19 Thread Mike Meyer
Christian Convey <[EMAIL PROTECTED]> writes: > I've got a program that (ideally) perpetually monitors sys.stdin for > lines of text. As soon as a line comes in, my program takes some > action. > The problem is, it seems like a very large amount of data must > accumulate on sys.stdin before even my

Re: Where can I find string.translate source?

2005-11-20 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Inside the file string.py I couldn't find the source code for > translate. Where could it be? Object/stringmodule.c in the python source distribution. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for m

Re: what happens when the file begin read is too big for all lines tobe?read with "readlines()"

2005-11-20 Thread Mike Meyer
"Ross Reyes" <[EMAIL PROTECTED]> writes: > Yes, I have read this part > How does one tell exactly what the limitation is to the size of the > returned list of strings? There's not really a good platform-indendent way to do that, because you'll get memory until the OS won't give you any more.

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Mike Meyer
Christoph Zwerschke <[EMAIL PROTECTED]> writes: > Ben Finney wrote: >> Another possibility: ordered dictionaries are not needed when Python >> 2.4 has the 'sorted' builtin. > The 'sorted' function does not help in the case I have indicated, > where "I do not want the keys to be sorted alphabeticall

python-dev Summary for 2005-10-01 through 2005-10-15

2005-11-21 Thread Tony Meyer
2005 through October 15, 2005. It is intended to inform the wider Python community of on-goingdevelopments on the list on a semi-monthly basis.  An archive_ ofprevious summaries is available online.An `RSS feed`_ of the titles of the summaries is available. You can also watch comp.lang.python or co

Re: ignore specific data

2005-11-21 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Hi I need help. What I want to do is If I read a file with some text > content... > I would like to ignore a block of lines and consider the rest.. > so if the block starts with > > "start of block." > fjesdgsdhfgdlgjklfjdgkd > jhcsdfskdlgjkljgkfdjkgj > "end

Re: ignore specific data

2005-11-21 Thread Mike Meyer
[EMAIL PROTECTED] writes: > thanks for that. But this will check for the exact content of the > "start of block.." or "end of block". How about if the content is > anywhere in the line? Then the test is '"start of block." in line'. You could also use the line.find or line.index methods, b

Re: Looking for magic method to override to prevent dict(d) from grabbing subclass inst d contents directly

2005-11-22 Thread Mike Meyer
[EMAIL PROTECTED] (Bengt Richter) writes: > Has anyone found a way besides not deriving from dict? > Shouldn't there be a way? > TIA > (need this for what I hope is an improvement on the Larosa/Foord OrderedDict > ;-) > > I guess I can just document that you have to spell it dict(d.items()), but I

Re: matching a string to extract substrings for which some function returns true

2005-11-22 Thread Mike Meyer
Amit Khemka <[EMAIL PROTECTED]> writes: > Well actually the problem is I have a list of tuples which i cast as > string and then > put in a html page as the value of a hidden variable. And when i get > the string again, > i want to cast it back as list of tuples: > ex: > input: "('foo', 1, 'foobar'

Re: wxPython Licence vs GPL

2005-11-22 Thread Mike Meyer
"John Perks and Sarah Mount" <[EMAIL PROTECTED]> writes: > How should we refer to this in terms of copyright statements and bundled > Licence files? Is there, say, a standard wording to be appended to the > GPL header in each source file? Does the original author need to be > named as one of the c

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Mike Meyer
"Steve R. Hastings" <[EMAIL PROTECTED]> writes: > I have been studying Python recently, and I read a comment on one > web page that said something like "the people using Python for heavy math > really wish they could define their own operators". The specific > example was to define an "outer prod

Re: about sort and dictionary

2005-11-22 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I think this is just another (admittedly minor) case of Python's > designers using Python to enforce some idea of programming > style purity. You say that as if it were a bad thing. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/U

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread Mike Meyer
"javuchi" <[EMAIL PROTECTED]> writes: > I've been searching thru the library documentation, and this is the > best code I can produce for this alogorithm: > > I'd like to return a dictionary which is a copy of 'another' dictionary > whoes values are bigger than 'x' and has the keys 'keys': > > def

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> def my_search(another, keys, x): >>return dict([[k, v] for k, v in another.items() if v >= x and k in keys]) >> But then you're looking through all the keys in another, and se

Re: Looking for magic method to override to prevent dict(d) from grabbing subclass inst d contents directly

2005-11-22 Thread Mike Meyer
[EMAIL PROTECTED] (Bengt Richter) writes: >>I'm not sure exactly what you mean by "grabbing sublass inst d contens >>directly", but if dict(d.items()) does it, the above class should do >>it as well. Of course, *other* ways of initializing a dict won't work >>for this class. >> > It's not initializ

Re: What a curious assignment.

2005-11-22 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > [test 1] class A: > ...i = 1 > ... a = A() A.i > 1 a.i > 1 A.i = 2 A.i > 2 a.i > 2 > > [test2] class A: > ...i = 1 > ... a = A() A.i > 1 a.i > 1 a.i = 2 A.i > 1 a.i

Re: What a curious assignment.

2005-11-23 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I believe he knows about inheritance, but not about the behaviour of > the assignment. In many other OO languages, I believe you cannot have > the same name for both instance variable and class variable. javascript > has similar behaviour. I think

Re: newbie class question

2005-11-23 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Sorry folks, this is what I meant: > class heh(object): > ... def __init__(self): > ... self.foo='hello' > ... def change(self): > ... self.foo+=' world' > ... def show(self): > ... return self.foo > ... > ... class hih(object

Re: return in loop for ?

2005-11-23 Thread Mike Meyer
yomgui <[EMAIL PROTECTED]> writes: > is it legal to return inside a for loop > or am I obliged to break out of the loop before returning ? Try it and see: >>> def f(): ... for i in range(20): ... if i > 10: return i ... >>> print f() 11 >>> http://www.mired.org/home/mw

Re: Why is dictionary.keys() a list and not a set?

2005-11-23 Thread Mike Meyer
Christoph Zwerschke <[EMAIL PROTECTED]> writes: > Ok, the answer is easy: For historical reasons - built-in sets exist > only since Python 2.4. > > Anyway, I was thinking about whether it would be possible and > desirable to change the old behavior in future Python versions and let > dict.keys() an

Re: return in loop for ?

2005-11-23 Thread Mike Meyer
yomgui <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> yomgui <[EMAIL PROTECTED]> writes: >> > is it legal to return inside a for loop >> > or am I obliged to break out of the loop before returning ? >> Try it and see: > it is not because it do

Re: Making immutable instances

2005-11-23 Thread Mike Meyer
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Ben Finney wrote: >> How can a (user-defined) class ensure that its instances are >> immutable, like an int or a tuple, without inheriting from those >> types? >> >> What caveats should be observed in making immutable instances? > > In short, you can't.

Re: Python as Guido Intended

2005-11-23 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Different programming styles are appropriate for different > tasks, different times and different places, different people. > And like morality, government, or economics, I do not believe > that one style of programming fits all situations. If I read you right, what you

Re: Python as Guido Intended

2005-11-23 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> > I do think that the Python development community believes they do, >> > or more accurately, that if someone wants to use a different style, >> > they can go use something else. &

Re: Making immutable instances

2005-11-23 Thread Mike Meyer
Ben Finney <[EMAIL PROTECTED]> writes: > Are there other, more dependable, ways of making immutable objects? Your answer can be found at http://www.cs.bgu.ac.il/~omri/Humor/write_in_c.html > >> I'm curious as to why you care if people add attributes to your >> "immutable" class. Personally, I con

Re: Python as Guido Intended

2005-11-23 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> You're the one that wants to use the hammer to do whatever it is, not >> me. I don't believe in silver bullets. Python is good at what it >> does. If I need a different tool, I use a different tool, rather than >> try and mangle a good tool into so

Re: Why is dictionary.keys() a list and not a set?

2005-11-23 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Which is also my initial puzzle, items() and iteritems() already gives > you the tuples, why such gurantee or the others ? Doesn't that violate > the general idiom that if we can do certain thing in one way, there > better be one and only one way.

Re: Python as Guido Intended

2005-11-23 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> Maybe Python attracts people who share that belief. After all, TRTFTJ >> is implies TSBOOWTDI, and vice versa. > I was not talking about the believe, I was talking about the way you > presented it. You are setting up an "imaginary" me, which is no

Re: about sort and dictionary

2005-11-23 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Neil Hodgson <[EMAIL PROTECTED]> wrote: >> Ruby uses '!' not for mutation but to indicate surprising or >> destructive mutation. If it was placed on all mutators, code would be >> full of '!'s. '!' is less common on methods that modify the receiver

Re: wxPython Licence vs GPL

2005-11-24 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Steve Holden wrote: >> Whether or not some fragments of code remain unchanged at the end of >> your project, if you start out with a piece of source code lifted from >> wxPython then what you have created is definitely a "derivative work" >> and, as

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> Note that this property of __slots__ is an implementation detail. You >> can't rely on it working in the future. > I don't "rely" on it. I just want to catch bugs in my code. I

Re: wxPython Licence vs GPL

2005-11-24 Thread Mike Meyer
"Martin P. Hellwig" <[EMAIL PROTECTED]> writes: > If the non-techie is still interested, I'll rave on about that I > understand why GPL is a good way to ensure availability of IP > especially if the software is a collaborated effort in the academic > scene. Your comment about the GPL "ensuring ava

Re: return in loop for ?

2005-11-24 Thread Mike Meyer
Duncan Booth <[EMAIL PROTECTED]> writes: > In practice it is impossible to write code in Python (or most > languages) with only one return point from a function: any line could throw > an exception which is effectively another return point, so the cleanup has > to be done properly anyway. This

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