Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.

2006-05-19 Thread bruno at modulix
Ian Bicking wrote: > glomde wrote: > >>i I would like to extend python so that you could create hiercical >>tree structures (XML, HTML etc) easier and that resulting code would be >>more readable than how you write today with packages like elementtree >>and xist. >>I dont want to replace the packa

Re: Modifying a variable in a non-global outer scope?

2006-05-19 Thread bruno at modulix
Edward C. Jones wrote: > #! /usr/bin/env python > """ > When I run the following program I get the error message: > > UnboundLocalError: local variable 'x' referenced before assignment > > Can "inner" change the value of a variable defined in "outer"? Not this way > Where > is this explained i

Re: altering an object as you iterate over it?

2006-05-19 Thread bruno at modulix
John Salerno wrote: > What is the best way of altering something (in my case, a file) while > you are iterating over it? I've tried this before by accident and got an > error, naturally. > > I'm trying to read the lines of a file and remove all the blank ones. > One solution I tried is to open the

Re: altering an object as you iterate over it?

2006-05-22 Thread bruno at modulix
Paul McGuire wrote: > "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] > >>bruno at modulix a écrit : >>(snip) >> >>(responding to myself) >>(but under another identity - now that's a bit schizophrenic

Re: Name conflict in class hierarchy

2006-05-22 Thread bruno at modulix
Ralf Muschall wrote: > Jeffrey Barish wrote: > > [overriding of base class member functions by subclass] > (snip) > > In Python, a function not intended to be overriden should be either > have a name starting with an underscore actually with *two* underscores. The single-leading-underscore nami

Re: PEP-xxx: Unification of for statement and list-comp syntax

2006-05-22 Thread bruno at modulix
Edward Elliott wrote: > George Sakkis wrote: > > >>Em Dom, 2006-05-21 às 17:11 +0200, Heiko Wundram escreveu: >> >>>for node in tree if node.haschildren(): >>> >>> >>>as syntactic sugar for: >>> >>>for node in tree: >>>if not node.haschildren(): >>>continue >>> > > [snip] > >>2) "There should b

Re: string.count issue (i'm stupid?)

2006-05-22 Thread bruno at modulix
Matteo Rattotti wrote: > Hi all, > > i've noticed a strange beaviour of string.count: > > in my mind this code must work in this way: > > str = "a_a_a_a_" dont use 'str' as an identifier, it shadows the builtin str type. > howmuch = str.count("_a_") > print howmuch -> 3 > > but the count retu

Re: problem with writing a simple module

2006-05-22 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > ello there. i am having a problem getting a module to work right. > > i wrote a class that is going to be used in a few different scripts in > the same directory. > > it looks like this: > > #!/usr/bin/python This is not needed for a module. (snip code) > the file is

Re: Class probkem - getting msg that self not defined

2006-05-23 Thread bruno at modulix
Andrew Robert wrote: > Hey Bruno, > > > Although I have not tested it, this appears to be it exactly. > > > Some confusion though. > > > > >>import struct >> >>class TriggerMessage(object): >>def __init__(self,data): >>""" >>Unpacks the passed binary data based on the >

Re: global name not defined

2006-05-23 Thread bruno at modulix
NetKev wrote: (snip) > def process_log(self, logfile, offset): > if new_denied_hosts: > info("new denied hosts: %s", str(new_denied_hosts)) > [warn_Admin(ip) for ip in new_denied_hosts] This uselessly builds a list. List comprehension is meant to create lists, n

Re: how to change sys.path?

2006-05-23 Thread bruno at modulix
Ju Hui wrote: > is python search module by paths in sys.path? sys.path is the list of path where the Python interpreter will search modules, yes. > how to change it manuallly? "manually" ?-) You mean "dynamically, by code" ? If yes, it's just a list. You can modify it like you'd do for any othe

Re: Name conflict in class hierarchy

2006-05-23 Thread bruno at modulix
Scott David Daniels wrote: > bruno at modulix wrote: > >> Ralf Muschall wrote: >> >>> Jeffrey Barish wrote: >>> >>> [overriding of base class member functions by subclass] >>> In Python, a function not intended to be overriden should

Re: Python - Web Display Technology

2006-05-23 Thread bruno at modulix
Ben Finney wrote: > "SamFeltus" <[EMAIL PROTECTED]> writes: > > >>I keep trying to understand why people like HTML/JS, I don't think I >>am gonna understand. > > > It's fairly simple: HTML, CSS and JavaScript have all been > standardised independent of any single corporation, and are freely > i

Re: dict literals vs dict(**kwds)

2006-05-24 Thread bruno at modulix
George Sakkis wrote: > Bruno Desthuilliers wrote: > > >>George Sakkis a écrit : >> >>>Although I consider dict(**kwds) as one of the few unfortunate design >>>choices in python since it prevents the future addition of useful >>>keyword arguments (e.g a default value or an orderby function), I've

Re: Best way to handle exceptions with try/finally

2006-05-24 Thread bruno at modulix
Carl J. Van Arsdall wrote: (snip) Not an answer to your question, just a few comments on your code: > class Shared: class Shared(object): >def __init__(self): >self.__userData= {} >self.__mutex = threading.Lock() #lock object Don't use __names unless yo

Re: Python Programming Books?

2006-05-24 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (snip) > So now i'm hear to use all of your collective expertise for the ideal > book for a beginning programming who want's to start with python. 'ideal' greatly depends on the reader !-) But FWIW, this is a FAQ (well : 2): http://www.python.org/doc/faq/general/#i-ve-ne

Re: Python keywords vs. English grammar

2006-05-24 Thread bruno at modulix
defcon8 wrote: > 1. Does it matter? > 2. Is it affecting your productivity. > 3. Are you not trying to programme? > 4. It is open source, change it and stop whining. > What about trying emacs +x doctor ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]

Re: It is fun.the result of str.lower(str())

2006-03-07 Thread bruno at modulix
Sullivan WxPyQtKinter wrote: > Guess what would be the result of these functions: s/functions/method calls/ > str.lower('ASFA') => 'ASFA'.lower() => 'asfa' str.join(str(),['1','1','1']) => ''.join(['1','1','1']) => '111' str.join('a','b') => 'a'.join('b') => 'b' > > If you gue

Re: Checking function calls

2006-03-07 Thread bruno at modulix
James Stroud wrote: (snip) > Since python is "weakly typed", s/weakly/dynamically/ (snip) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between a library and a module...

2006-03-07 Thread bruno at modulix
sophie_newbie wrote: > OK this might seem like a retarded question, Better to look like an ignorant than to stay one !-) > but what is the difference > between a library and a module? Python only defines 'modules' and 'packages'. A module can technically be any python source file, but usually re

Re: Simple questions on use of objects (probably faq)

2006-03-08 Thread bruno at modulix
Brian Elmegaard wrote: > Hi, > > I am struggling to understand how to really appreciate object > orientation. I guess these are FAQ's but I have not been able to find > the answers. Maybe my problem is that my style and understanding are > influenced by matlab and fortran. > > I tried with the si

Re: Simple questions on use of objects (probably faq)

2006-03-09 Thread bruno at modulix
Brian Elmegaard wrote: > bruno at modulix <[EMAIL PROTECTED]> writes: > > >>Now how you could do it the OO way (Q&D, not really tested): > > > Something goes wrong in my 2.3 So it's time to move to 2.4x !-) What is "going wrong" exactly

Re: Simple questions on use of objects (probably faq)

2006-03-09 Thread bruno at modulix
Steven D'Aprano wrote: (snip) > I say "think you want" because I don't know what problem you are trying to > solve with this messy, self-referential, piece of code. This messy piece of code is mine, thanks !-) And it's not "self-referential" - it introduces a references cycle (class object -> in

Re: Simple questions on use of objects (probably faq)

2006-03-09 Thread bruno at modulix
Brian Elmegaard wrote: > bruno at modulix <[EMAIL PROTECTED]> writes: > > >>So it's time to move to 2.4x !-) > > > I guess so. > > > >>What is "going wrong" exactly ? > > > def _add_instance(cls, instance): >

Re: How to dervie from an instance object?

2006-03-09 Thread bruno at modulix
reinsn wrote: > Hi, > > I am currently working with ZopeX3. Because python doesn't include > concept of interfaces, It does, but implicitly. The interface of an object is the set of messages it understands. > those were defined by the module zope.interface. > > So interfaces were defined like:

Re: First script, please comment and advise

2006-03-10 Thread bruno at modulix
Pedro Graca wrote: > [EMAIL PROTECTED] wrote: > >>My version is similar to Just one: >> >>from random import shuffle >> >>def scramble_text(text): >>"""Return the words in input text string scrambled >>except for the first and last letter.""" >>def scramble_word(word): > > > Nice. Yo

Re: A better RE?

2006-03-10 Thread bruno at modulix
Magnus Lycka wrote: > I want an re that matches strings like "21MAR06 31APR06 1236", > where the last part is day numbers (1-7), i.e it can contain > the numbers 1-7, in order, only one of each, and at least one > digit. I want it as three groups. I was thinking of > > r"(\d\d[A-Z]\d\d) (\d\d[A-Z]

Re: Help with a reverse dictionary lookup

2006-03-10 Thread bruno at modulix
rh0dium wrote: > Hi all, > > I have a dict which looks like this.. > > dict={'130nm': {'umc': ['1p6m_1.2-3.3_fsg_ms']}, > '180nm': {'chartered': ['2p6m_1.8-3.3_sal_ms'], 'tsmc': > ['1p6m_1.8-3.3_sal_log', '1p6m_1.8-3.3_sal_ms']}, > '250nm': {'umc': ['2p6m_1.8-3.3_sal_ms'], 'tsmc': > ['1p6m_2.2-3.

Re: Simple questions on use of objects (probably faq)

2006-03-10 Thread bruno at modulix
Steven D'Aprano wrote: > On Thu, 09 Mar 2006 13:44:25 +0100, bruno at modulix wrote: > > (snip) >>And it's not "self-referential" - it introduces a references cycle >>(class object -> instances -> class object), which may or may not be a >>

Re: __del__ not called?

2006-03-13 Thread bruno at modulix
Gregor Horvath wrote: > Felipe Almeida Lessa schrieb: > >del B ># We'll to tell him to collect the garbage here, but >> >> ... # usually it should not be necessary. > > Thanks. If I do > > del B > > then the __del__ of A gets called. > That surprises me. Why ? > I thought that B gets

Re: PEP 8 example of 'Function and method arguments'

2006-03-13 Thread bruno at modulix
Martin P. Hellwig wrote: > While I was reading PEP 8 I came across this part: > > """ > Function and method arguments >Always use 'self' for the first argument to instance methods. >Always use 'cls' for the first argument to class methods. > """ > > Now I'm rather new to programming and u

Re: list/classmethod problems

2006-03-14 Thread bruno at modulix
ahart wrote: > Diez, Scott, and Bruno, > > I thank you all for your help and suggestions. I wasn't aware that > default values were considered class (static) values. These are *not* 'default values'. Defining a name in the body of a class statement bind that name to the *class*. To bind a name to

Re: Accessing overridden __builtin__s?

2006-03-14 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I'm having a scoping problem. I have a module called SpecialFile, The convention is to use all_lowercase names for modules, and CamelCase for classes. > which defines: > > def open(fname, mode): > return SpecialFile(fname, mode) This shadows the builtin open() func

Re: Accessing overridden __builtin__s?

2006-03-14 Thread bruno at modulix
Steven D'Aprano wrote: > On Mon, 13 Mar 2006 21:28:06 -0800, garyjefferson123 wrote: > > >>I'm having a scoping problem. I have a module called SpecialFile, >>which defines: >> (snip code) >>The problem, if it isn't obvioius, is that the open() call in __init__ >>no longer refers to the builtin

Re: Very, Very Green Python User

2006-03-14 Thread bruno at modulix
Scott David Daniels wrote: > [EMAIL PROTECTED] wrote: > >> ... Is the Python debugger fairly stable? > > Yes, but it is not massively featured. The "Pythonic" way is to > rarely use a debugger (test first and straightforward code should > lead to "shallow" bugs). Often for most of us judiciousl

Re: Python Debugger / IDE ??

2006-03-14 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Is there any editor or IDE in Python (either Windows or Linux) which > has very good debugging facilites like MS VisualStudio has or something > like that. > > I like SPE but couldn't easily use winPDP. I need tips to debug my code > easily. pythonic "debugging" in thre

Re: Very, Very Green Python User

2006-03-14 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I have used Perl for a long time, but I am something of an experimental > person and mean to try something new. Most of my 'work' with Vector > Linux entails the use of Perl (a bit of a misnomer as it is not now a > paid position -- I am not yet even out of K-12), and the

Re: Server applications - avoiding sleep

2006-03-15 Thread bruno at modulix
rodmc wrote: > I have written a small server application (for Windows) which handles > sending and receiving information from an instant messaging client and > a database. This server needs to run 24/7, however it stops when the > computer screen is locked. > > I assume there is a way to make it r

Re: newbie questions

2006-03-15 Thread bruno at modulix
meeper34 wrote: > Hi, > > I'm just starting out with Python, and so far I am thoroughly impressed > with what you can do very easily with the language. > > I'm coming from a > C++ background here. A couple of questions came up as I was thinking > about dynamically typed languages: > > 1. If so

Re: best practices for making read-only attributes of an object

2006-03-15 Thread bruno at modulix
Tim Chase wrote: > I've set up an object and would like to make certain attributes > read-only (or at least enforce it without doing extra work, as per > name-mangling or the like). Ideally, the property would be set in the > __init__, and then not be allowed to change. > > The best solution I've

Re: problem writing to a file each record read

2006-03-15 Thread bruno at modulix
Eduardo Biano wrote: > I am a python newbie and I have a problem with writing > each record read to a file. The expected output is 10 > rows of records, but the actual output of the code > below is only one row with a very long record (10 > records are lump into one record). Thank you in > advance

Re: user-supplied locals dict for function execution?

2006-03-20 Thread bruno at modulix
Lonnie Princehouse wrote: > Can anyone think of a way to substitute a user-supplied dictionary as > the local dict for a function call? > > e.g. > > def f(): >x = 5 > > d = {} > > exec_function_in_dictionary( f, d ) # ??? > > print d["x"] # 5 > def f(**kw): kw['x'] = 5 d = {} f

Re: what's the general way of separating classes?

2006-03-20 Thread bruno at modulix
John Salerno wrote: > From my brief experience with C#, I learned that it was pretty standard > practice to put each class in a separate file. I assume this is a > benefit of a compiled language that the files can then be grouped together. > > What I'm wondering is how is this normally handled in

Re: user-supplied locals dict for function execution?

2006-03-20 Thread bruno at modulix
Lonnie Princehouse wrote: >>What's your use case exactly ? > > > I'm trying to use a function to implicitly update a dictionary. I think this was pretty obvious. What I wonder is *why* you want/think you need to do such a thing -I don't mean there can't be no good reason to do so, but this has

Re: how to make script interact with another script

2006-03-20 Thread bruno at modulix
Chason Hayes wrote: > How can I get a script to pipe data to another program, wait for a > response, then send more data etc. > > For example, from a script, I want to run smbclient then send it the > username, password, and then some commands. (I know there are better ways > to achieve this funct

Re: user-supplied locals dict for function execution?

2006-03-21 Thread bruno at modulix
Lonnie Princehouse wrote: >>Beautiful is better than ugly. >>Explicit is better than implicit. >> >>>Err... I see no contradiction nor conflict here. > > > What to do when explicit is ugly and implicit is beautiful? Depends on your understanding of explicit/implicit. Side effects on globals o

Re: [CODE] - Python Newcomer Starting with Coding

2006-03-21 Thread bruno at modulix
Ilias Lazaridis wrote: > Where can I find practical coding examples for real life coding problems? Probably in real life code ?-) > Something like a categorized solution guide? Look for the Python cookbook (google is your friend). > - > > My current problem: > > * create a folder > * seems

Re: should os.walk return a list instead of a tuple?

2006-03-21 Thread bruno at modulix
Ministeyr wrote: > Hello, > > os.walk doc: http://www.python.org/doc/2.4/lib/os-file-dir.html#l2h-1625 > > When walking top to bottom, it allows you to choose the directories you > want to visit dynamically by changing the second parameter of the tuple > (a list of directories). However, since it

Re: Python compiler

2006-03-21 Thread bruno at modulix
Rc wrote: > "DaveM" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > >>On Thu, 16 Mar 2006 13:34:14 +0100, "Méta-MCI" >><[EMAIL PROTECTED]> wrote: >> >> >>>Après, vous pourrez aussi fréquenter le newsgroup : >>> fr.comp.lang.python >>>qui a l'avantage d'être en français. >>

Per instance descriptors ?

2006-03-22 Thread bruno at modulix
Hi I'm currently playing with some (possibly weird...) code, and I'd have a use for per-instance descriptors, ie (dummy code): class DummyDescriptor(object): def __get__(self, obj, objtype=None): if obj is None: return self return getattr(obj, 'bar', 'no bar') class MyClass1(obje

Re: py web-app-frameworks without a rdbms...

2006-03-22 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Hi folks, > > Of TurboGers & Django WAF candidates, which one would be easier to use > in an environment where the data/content doesn't come an RDBMS, but > from other server-side apps... IMHO, both. > If these are not good candidates, could > you suggest appropriate

Re: Per instance descriptors ?

2006-03-22 Thread bruno at modulix
Ziga Seilnacht wrote: > bruno at modulix wrote: > >>Hi >> >>I'm currently playing with some (possibly weird...) code, and I'd have a >>use for per-instance descriptors, ie (dummy code): > > > > >>Now the question: is there

Re: Per instance descriptors ?

2006-03-23 Thread bruno at modulix
Michael Spencer wrote: > Bruno Desthuilliers wrote: > (snip) > >> BTW, there may be other use case for per-instance descriptors... > > > Agreed. Per-instance descriptors could be interesting (that's why the > subject line caught my attention). > But your solution involves a custom __getattrib

Re: Per instance descriptors ?

2006-03-23 Thread bruno at modulix
Steven Bethard wrote: > bruno at modulix wrote: > >> Hi >> >> I'm currently playing with some (possibly weird...) code, and I'd have a >> use for per-instance descriptors, (snip) >> >> class MyClass2(MyClass1): >> def __getattrib

Re: Per instance descriptors ?

2006-03-23 Thread bruno at modulix
Steven Bethard wrote: (some smart questions) Steven , I owe you a *big* thank. I knew they must have been something wrong, but couldn't point what. Now I see, and it's of course totally obvious. Using a class as a decorator, I have of course only one instance of it per function - and for some at

Re: Per instance descriptors ?

2006-03-23 Thread bruno at modulix
Steven Bethard wrote: (snip code) > > But that looks pretty nasty to me. > It sounds like your architecture > could use some redesigning Done - in much more sane way. Got rid of some more boilerplate and of the whole problem of per-instance descriptors BTW !-) I should probably sleep more

Re: Properties

2006-03-27 Thread bruno at modulix
Ronny Mandal wrote: > Is there a way of checking whether the call to a set-function is > called from within the class, e.g. the __init__() contra > .set()? import inspect help(inspect.stack) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[E

Re: Python types

2006-03-27 Thread bruno at modulix
Dennis Lee Bieber wrote: > On Mon, 27 Mar 2006 01:34:14 +0200, Bruno Desthuilliers > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > > >>Ok, so even if Python itself declares b and b2 (read: objects that names >>b and b2 are bound to) to be of the same type, you cannot appl

Re: object references

2006-03-27 Thread bruno at modulix
Steven D'Aprano wrote: > On Sat, 25 Mar 2006 21:33:24 -0800, DrConti wrote: > > >>Dear Python developer community, >>I'm quite new to Python, so perhaps my question is well known and the >>answer too. >> >>I need a variable alias ( what in other languages you would call "a >>pointer" (c) or "a r

Re: How to inplement Session in CGI

2006-03-28 Thread bruno at modulix
Sullivan WxPyQtKinter wrote: > Python disappointly failed to provide a convinient cgi session > management module. Probably because there are much better options for web programming in Python ? > Not willing to use external modules, I would like to > implement a simplest Session object on my own

Re: instantiate a class with a variable

2006-03-28 Thread bruno at modulix
John wrote: > Hi, is it possible to instantiate a class with a variable. > > example > > class foo: > def method(self): > pass > > x='foo' > > Can I use variable x value to create an instance of my class? You got examples using string 'foo', now if all you need is to store or pass

Re: object references

2006-03-28 Thread bruno at modulix
DrConti wrote: > Hi Bruno, hi folks! > thank you very much for your advices. > I didn't know about the property function. > I learned also quite a lot now about "references". > Ok everything is a reference but you can't get a reference of a > reference... > > I saw a lot of variations on how to s

Re: multiple assignment

2006-03-28 Thread bruno at modulix
Anand wrote: >>>Wouldn't it be nice to say >>>id, *tokens = line.split(',') >> >> >>id, tokens_str = line.split(',', 1) > > > But then you have to split tokens_str again. > > id, tokens_str = line.split(',', 1) > tokens = tokens_str.split(',') > > this is too verbose. > head_tail = lambda seq

Re: Looking for a language/framework

2006-03-28 Thread bruno at modulix
walterbyrd wrote: > Way back when, I got a lot of training and experience in highly > structued software development. These days, I dabble with > web-development, but I may become more serious. > > I consider php to be an abombination, the backward compatibility issues > alone are reason enough t

Re: How to inplement Session in CGI

2006-03-28 Thread bruno at modulix
Sullivan WxPyQtKinter wrote: > bruno at modulix 写道: > > >>Sullivan WxPyQtKinter wrote: >> >>>Python disappointly failed to provide a convinient cgi session >>>management module. >> >>Probably because there are much better options for web progra

Re: Looking for a language/framework

2006-03-29 Thread bruno at modulix
walterbyrd wrote: >>You can bet it'll be plain old cgi - possibly with an outdated Pyton version. > > I think you are right. In practical terms, what does that mean? Will I > not be able to use modules? Will I not be able to use frameworks? It means that you will be limited to what can run with

Re: No Cookie: how to implement session?

2006-03-29 Thread bruno at modulix
Sullivan WxPyQtKinter wrote: > I do not want to use Cookies in my site since not all web browser > support it well and sometimes people close cookie functioning for > security reasons. Too bad for them. The only other way to support session is by encoding the session id in the request, and it's m

Re: tips for this exercise?

2006-03-29 Thread bruno at modulix
John Salerno wrote: > I'm working on another exercise now about generating random numbers for > the lottery. What I want to do is write a function that picks 5 random > numbers from 1-53 and returns them. Here's what I have so far: > > numbers = range(1, 54) > > def genNumbers(): > for x in ra

Re: tips for this exercise?

2006-03-29 Thread bruno at modulix
Paul Rubin wrote: (snip) > Why is everyone using shuffle? > > >>> import random > >>> random.sample(xrange(1,41), 5) > [24, 15, 9, 39, 19] Great. Didn't know that one. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTEC

Re: Python plug-in

2006-03-29 Thread bruno at modulix
toto wrote: > Hi, > > I'm trying to find some howto, tutorial in order to create a python program > that will allow plug-in programming. I've found various tutos on how to > write a plug-in for soft A or soft B but none telling me how to do it in my > own programs. Do you have any bookmarks ?? Tr

Re: Free Python IDE ?

2006-03-30 Thread bruno at modulix
Ernesto wrote: > I'm looking for a tool that I can use to "step through" python software > (debugging environment). This is not an 'IDE', it's a debugger. > Is there a good FREE one http://www.python.org/doc/2.4.2/lib/module-pdb.html Strange enough, I almost never had a use for a debugger in

Re: Try Python!

2006-03-30 Thread bruno at modulix
Michael Tobis wrote: > We had some discussion of this in the edu-sig meeting at PyCon. > > I alleged that I had read that there is no such thing as a Python > sandbox. And yet Zope 2 has some restricted environment for TTW scripts... -- bruno desthuilliers python -c "print '@'.join(['.'.join([

Re: List conversion

2006-03-30 Thread bruno at modulix
yawgmoth7 wrote: > Hello, I have a piece of code: > >command = raw_input("command> ") >words = string.split(command, ' ') >temparg = words >if len(words)<= 3: >temparg = words[4:] >else: >

Re: dynamic construction of variables / function names

2006-03-30 Thread bruno at modulix
Steven D'Aprano wrote: > Sakcee wrote: > >> python provides a great way of dynamically creating fuctions calls and >> class names from string >> (snip) > Personally, I think the best way is: find another way to solve your > problem. > See Duncan's post for a pretty clean and pythonic solution.

Re: does python could support sequence of short or int?

2006-03-30 Thread bruno at modulix
momobear wrote: > hi, is there a way to let python operate on sequence of int or short? > In C, we just need declare a point, I assume you mean a 'pointer'. > then I could get the point value, > just like: > short* k = buffer, //k is a point to a sequence point of short. > short i = *k++, > but

Re: regular expressions and matches

2006-03-30 Thread bruno at modulix
Johhny wrote: > Hello, > > I have recently written a small function that will verify that an IP > address is valid. (snip re.match() based solution - just one remark: compiling the regexp on each function call is more than useless) > I was having issues trying to get my code working so that I c

Re: does python could support sequence of short or int?

2006-03-30 Thread bruno at modulix
momobear wrote: > but what about buffer is not be declared in python program, it comes > from a C function. and what about I want to treat a string as a short > list? There are no "short" in Python. An integer is an integer is an integer... > buffer = foobur() // a invoke from C function, it is

Re: Non-GUI source code browser with file system tree view

2006-03-30 Thread bruno at modulix
Stefan Schwarzer wrote: > Hello, > > from time to time I want to inspect the source code of projects > on remote computers.(*) I've googled for one or two hours but > didn't find anything helpful. :-/ I'm looking for something like > IDLE's path browser - i. e. a tree view and file view > side-by-

Re: How to determine an object is "scriptable"

2006-03-30 Thread bruno at modulix
Larry Bates wrote: > abcd wrote: > >>I recently came across a problem where I saw this error: >>"TypeError: unsubscriptable object" >> >>How can I determine if an object is "scriptable" or "unscriptable"? >> > > Simplest answer is to use isinstance to see if it is a string, list, > or tuple: > >

Re: How to determine an object is "scriptable"

2006-03-30 Thread bruno at modulix
abcd wrote: > Richard Brodie wrote: > >>subscriptable: supports an indexing operator, like a list does. > > doesn't seem to be a builtin function or module... It's not. Look no further. > or is that just your > definition of subscriptable? It's a correct definition of 'subscriptable' in the c

Re: How to determine an object is "scriptable"

2006-03-30 Thread bruno at modulix
abcd wrote: > I recently came across a problem where I saw this error: > "TypeError: unsubscriptable object" > > How can I determine if an object is "scriptable" or "unscriptable"? By trying to apply the subscript operator ('[]'). If it raises a TypeError, then it's not subscriptable. But, as La

Re: How to debug python code?

2006-03-31 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? (automated) unit tests + print statements + the interactive shell are usually enough. I almost never used pdb in 5+ years of Python programm

Re: Best IDE for Python?

2006-03-31 Thread bruno at modulix
Fredrik Lundh wrote: > Dennis Lee Bieber wrote: > > >>> I want to know which is the best IDE for python.Please if >>>possible mention the features of the IDE. >> >>The best IDE is the one that YOU can be most productive in. What /I/ >>find useful may not be of interest to /you/. > > > nons

Re: Best IDE for Python?

2006-03-31 Thread bruno at modulix
Duncan Booth wrote: > Fredrik Lundh wrote: > > >>as you can see, Microsoft's usability team has made some massive >>improvements (note how well it deals with the "eat flaming death" >>command): > > > I especially like the way running it messes up the prompt: > > C:\Documents and Settings\Dunca

Re: How to search HUGE XML with DOM?

2006-03-31 Thread bruno at modulix
Sullivan WxPyQtKinter wrote: > a relation database has admiring search efficiency when the database is > very big (several thousands or tens of thousands of records). But my > current project is based on XML, for its tree-like data structure has > much more flexibility; and DOM, which could be mani

Re: member variables in python

2006-03-31 Thread bruno at modulix
PyPK wrote: > ok I reason I was going with globals is that i use this variable in > another class something like this along with above > > testflag = 0 > > class AA: >def __init__(...): > > def methos(self,...): >global testflag >testflag = xx > > class BB: > def __ini

Re: "definitive" source on advanced python?

2006-04-03 Thread bruno at modulix
Gabriel de Dietrich wrote: > Maybe you're looking for something like this? > http://jamesthornton.com/eckel/TIPython/html/Index.htm > > Haven't read it yet, but seems to be about design patterns. Not the > "definitive" stuff, though... While TIP is an interesting book, it is more about implementa

Re: Standalone Python functions in UML?

2006-04-04 Thread bruno at modulix
Ravi Teja wrote: (snip) >>>More theoretical question is if I create classes on the fly, how UML can > > reflect that? > > "On the fly" usually means "at runtime". I guess you mean if you > "change code" will my diagram stay in sync?. Nope, the OP really meant "on the fly", as in "at runtime". In

Re: Standalone Python functions in UML?

2006-04-04 Thread bruno at modulix
Philippe Martin wrote: > Roman Susi wrote: > (snip) >>More theoretical question is if I create classes on the fly, how UML can >>reflect that? > > > You mean objects I think: Yes : class objects !-) Python's classes *are* objects. And you can create new classes at runtime. (snip) -- bruno d

Re: Standalone Python functions in UML?

2006-04-05 Thread bruno at modulix
Ravi Teja wrote: (snip) > >> And probably Python is too dynamic for UML. That is another reason > rountrip tools aren't there. > > > As you probably already know, UML diagrams are structural and > behavioural (plus interactional with 2.0). Round trip tools only model > structural diagrams. Pytho

Re: Standalone Python functions in UML?

2006-04-05 Thread bruno at modulix
Philippe Martin wrote: please don't top-post - corrected > bruno at modulix wrote: > > >>Philippe Martin wrote: >> >>>Roman Susi wrote: >>> >> >>(snip) >> >> >>>>More theoretical question is if I create class

Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python

2006-04-05 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (snip part about filters) > Any good "generators" written in Python? I'd like to roll me one of > these as well; e.g. execute the program and it will create a few > paragraphs of text in the jargon of a discipline, subdiscipline, > subculture, etc. Anyone know what I'm ta

Re: pre-PEP: The create statement

2006-04-06 Thread bruno at modulix
Steven Bethard wrote: > The PEP below should be mostly self explanatory. I'll try to keep the > most updated versions available at: > > http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt > http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html > > > > PEP: XXX > Title

Re: pre-PEP: The create statement

2006-04-06 Thread bruno at modulix
Serge Orlov wrote: > bruno at modulix wrote: > >>Steven Bethard wrote: >> >>>The PEP below should be mostly self explanatory. I'll try to keep the >>>most updated versions available at: > > > [snip] > > >>Seems mostly clean. +1. &g

Re: Partially unpacking a sequence

2006-04-07 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I have a list y > y > > ['20001201', 'ARRO', '04276410', '18.500', '19.500', '18.500', > '19.500', '224'] > > from which I want to extract only the 2nd and 4th item > > by partially > unpacking the list. So I tried > a,b = y[2,4] Mmm, so lovely and meaningful

Re: performance degradation when looping through lists

2006-04-07 Thread bruno at modulix
Joachim Worringen wrote: > I need to process large lists (in my real application, this is to parse > the content of a file). Then you probably want to use generators instead of lists. The problem with large lists is that they eat a lot of memory - which can result in swapping . > I noticed that

Re: Best way to process table rows from an RDBMS

2006-04-07 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I can handle making the connections and running queries, but what's the > best way to process table rows returned in Python? depends on what you want to do with them. > What about turning a > table definition into an object? Just looking for ways to be efficient, > sinc

Re: how you know you're a programming nerd

2006-04-07 Thread bruno at modulix
John Salerno wrote: > So last night I had a dream that me and two other guys needed to get a > simple task done in Java. Then s/dream/nightmare/ -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.

Re: "The World's Most Maintainable Programming Language"

2006-04-07 Thread bruno at modulix
Peter Hansen wrote: > Mirco Wahab wrote: > >> Hi Ralf >> >>> So we should rename Python into Cottonmouth to get more attention. >> >> >> No, always take some word that relates to >> something more or less 'feminine', its about >> 96% of young males who sit hours on programming >> over their belove

Re: [Newbie] Referring to a global variable inside a function

2006-04-10 Thread bruno at modulix
Ernesto García García wrote: > Hi experts, > > I've built a class for parsing a user-defined list of files and matching > lines with a user-defined list of regular expressions. It looks like this: > (snip code) > > But then, when I try to use my class using actions with "memory" it will > fail:

<    1   2   3   4   5   6   >