Re: verilog like class w/ bitslicing & int/long classtype

2009-01-30 Thread rdmurray
Quoth Stef Mientki : > Marc 'BlackJack' Rintsch wrote: > > On Fri, 30 Jan 2009 00:25:03 +0100, Stef Mientki wrote: > > > > > >> try this: > >> > >> class MyRegClass ( int ) : > >> def __init__ ( self, value ) : > >> self.Value = value > >> def __repr__ ( self ) : > >> line = hex ( se

Re: Importing modules

2009-01-30 Thread rdmurray
Quoth Mudcat : > [attribution omitted by Mudcat] > > I think you've probably had issues with circular imports (i.e. mutual > > dependencies), unless you can precisely remember what you were doing and > > what went wrong. > > That's possible, but circular imports become more of a hazard if you > hav

SimpleXMLRPCServer question

2009-01-30 Thread rdmurray
Quoth flagg : > I am working on a very basic xmlrpc server, which will expose certain > functions for administering BIND zone files. The big problem I am > having is parsing the incoming xmlrpc request. Basically part of the > xmlrpc request will help deterime which zone file is edited.I have

Re: More mod_wsgi weirdness: process restarts on redirect

2009-01-30 Thread rdmurray
Quoth Ron Garret : > In article , > Joshua Kugler wrote: > > > Ron Garret wrote: > > > My question is: is this supposed to be happening? Or is this an > > > indication that something is wrong, and if so, what? > > > > You are probably just hitting a different instance of Apache, thus the > > d

Re: search speed

2009-01-30 Thread rdmurray
Quoth Tim Chase : > PS: as an aside, how do I import just the fnmatch function? I > tried both of the following and neither worked: > >from glob.fnmatch import fnmatch >from glob import fnmatch.fnmatch > > I finally resorted to the contortion coded below in favor of >import glob >

Re: glob.fnmatch (was "search speed")

2009-01-31 Thread rdmurray
Quoth Tim Chase : > rdmur...@bitdance.com wrote: > > What you want is: > > > > from fnmatch import fnmatch > > Oh, that's head-smackingly obvious now...thanks! > > My thought process usually goes something like > > """ > I want to do some file-name globbing > > there's a glob module that l

Re: SimpleXMLRPCServer question

2009-01-31 Thread rdmurray
Quoth flagg : > Let me see if i can elaborate on the requirements. I have 20+ > different zone files. I want the xmlrpc server to be able to > determine what zone file to open by looking at the incoming xml > request. For example one of the functions I have now is to show a DNS > record (I am us

Re: is python Object oriented??

2009-02-01 Thread rdmurray
Quoth thmpsn@gmail.com: > Anyway, it doesn't matter. We're losing the point here. The point is > that language support for private access, by disallowing user access > to private data, provides an unambiguous information hiding mechanism > which encourages encapsulation. Python's approach, howe

Problem with slow httplib connections on Windows (and maybe other platforms)

2009-02-01 Thread rdmurray
Quoth Christoph Zwerschke : > What actually happens is the following: > > * BaseHTTPServer binds only to the IPv4 address of localhost, because >it's based on TCPServer which has address_family=AF_INET by default. > > * HTTPConnection.connect() however tries to connect to all IP addresses >

Re: Problem with slow httplib connections on Windows (and maybe other platforms)

2009-02-01 Thread rdmurray
Quoth Christoph Zwerschke : > rdmur...@bitdance.com schrieb: > > Quoth Christoph Zwerschke : > >>With Py 2.3 (without IPv6 support) this is only the IPv4 address, > >>but with Py 2.4-2.6 the order is (on my Win XP host) the IPv6 address > >>first, then the IPv4 address. Since the IPv6 a

Re: Membership of multiple items to a list

2009-02-01 Thread rdmurray
Quoth Steven D'Aprano : > On Sun, 01 Feb 2009 12:01:11 -0800, Stephen Hansen wrote: > > > > style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt > > 0.8ex; padding-left: 1ex;"> I'd like to know how to elegantly check > > a list for the membership of any of its items to another li

Re: is python Object oriented??

2009-02-02 Thread rdmurray
Quoth "Hendrik van Rooyen" : > wrote: > > > > > You, sir, should be programming in some language other than Python. > > Why? - Python is object oriented, but I can write whole systems > without defining a single class. > By analogy, if data hiding is added to language, I could write a > whole

Re: What is wrong in my list comprehension?

2009-02-02 Thread rdmurray
Quoth Stephen Hansen : > I just think at this point ".find" is just not the right method to use; > "substring" in "string" is the way to determine what he wants is all. > ".find" is useful for when you want the actual position, not when you just > want to determine if there's a match at all. The wa

Combining several text files

2009-02-02 Thread rdmurray
Quoth Eric : > This is my first post, so please advise if I'm not using proper > etiquette. I've actually searched around a bit and while I think I can > do this, I can't think of a clean elegant way. I'm pretty new to > Python, but from what I've learned so far is that there is almost > always an

Re: is python Object oriented??

2009-02-02 Thread rdmurray
Quoth "Hendrik van Rooyen" : > Now there are a LOT of dicey statements in the above passionate > plea - python is a language, and not a philosophy, but I won't go > into that, as that would lead off onto a tangent, of which there have > been a surfeit in this thread. Ah, now I understand. This

Re: Membership of multiple items to a list

2009-02-02 Thread rdmurray
My client can handle your Mime and shows me the text part of the signed message. It's not as pretty as just seeing an unsigned text message, but that's a client problem, not yours :) I would like to think that all newsreader clients could handle mime at this point, but who knows. --RDM -- http:

Re: Python Global State

2009-02-03 Thread rdmurray
Quoth MRAB : > er wrote: > > Simple question, I think: Is there a way to make a completely global > > variable across a slew of modules? If not, what is the canonical > > way to keep a global state? The purpose of this is to try to prevent > > circular module imports, which just sort of seems nas

Re: what IDE is the best to write python?

2009-02-03 Thread rdmurray
Quoth a...@pythoncraft.com (Aahz): > In article , > Thorsten Kampe wrote: > >* Aahz (2 Feb 2009 09:29:43 -0800) > >> In article , > >> Thorsten Kampe wrote: > >>>* Aahz (2 Feb 2009 06:30:00 -0800) > In article <874ozd3cr3@benfinney.id.au>, > Ben Finney wrote: > >a...@pythonc

Re: is python Object oriented??

2009-02-03 Thread rdmurray
Quoth David Cournapeau : > On Wed, Feb 4, 2009 at 2:36 AM, wrote: > > > > Pretty much, unless maybe the code documents what you're not supposed > > to access: > > But that's my point: that's just not true for many packages I have > used - some packages do follow the _ convention, some don't. For

global variable confusion

2009-02-03 Thread rdmurray
"Robert D.M. Smith" wrote: > I have a question on global variables and how to use them. I have 2 files; > a.py & b.py > > # a.py - > > myvar = { 'test' : '123' } > > # --- > # b.py - > > from a import myvar > > def test(): > a.myvar = { 'blah' : '456' } > > # - > > If

Re: Passing environment variable to "subprocess" causes failure

2009-02-03 Thread rdmurray
Quoth MRAB : > davidgo...@davidgould.com wrote: > > I'm attempting to run subprocess and passing in an environment > > variable. When I do this the child process fails with an error. When I > > don't pass an environement variable it runs fine. > > > > BTW Running this code under Windows XP wit

Re: Extracting file from zip archive in Python 2.6.1

2009-02-03 Thread rdmurray
Quoth Brandon Taylor : > Ok, the first thing I needed to do was add: > > from __future__ import with_statement at the beginning of my file > > but: > > with zip_file.open(zip_name + '/' + thumbnail_image) as source: > with open(os.path.join(thumbnail_path, > thumbnail_image),

Couple of noobish question

2009-02-04 Thread rdmurray
Quoth Catherine Heathcote : > all goes well. I have an idea for a small project, an overly simplistic > interactive fiction engine (well more like those old choose your own > adventure books, used to love those!) that uses XML for its map files. > The main issues I see so far is the XML parsing

string replace for back slash

2009-02-05 Thread rdmurray
"S.Selvam Siva" wrote: > I tried to do a string replace as follows, > > >>> s="hi & people" > >>> s.replace("&","\&") > 'hi \\& people' > >>> > > but i was expecting 'hi \& people'.I dont know ,what is something different > here with escape sequence. You are running into the difference between

Re: Python 3.0 slow file IO

2009-02-05 Thread rdmurray
Quoth Christian Heimes : > thomasvang...@gmail.com schrieb: > > I just recently learned python, I'm using it mainly to process huge > > <5GB txt files of ASCII information about DNA. I've decided to learn > > 3.0, but maybe I need to step back to 2.6? > > > > I'm getting exceedingly frustrated by

os.system issues

2009-02-05 Thread rdmurray
Youri Lammers writes: > I want to run a program called 'muscle' with my python script=2C > muscle uses the following command: > 'muscle.exe -in filename -out filename' > so far I got: > > import os > args = ['-in filename', '-out filename'] > os.system('E:\Programs\muscle\muscle.exe args') > > H

Re: Flattening lists

2009-02-05 Thread rdmurray
Baolong zhen wrote: > On Thu, Feb 5, 2009 at 10:17 PM, mk wrote: > > > Brian Allen Vanderburg II wrote: > > >> def flatten(x): > > >> res = [] > > >> for el in x: > > >> if isinstance(el,list): > > >> res.extend(flatten(el)) > > >> else: > > >> res.

Re: Flattening lists

2009-02-05 Thread rdmurray
Quoth rdmur...@bitdance.com: > This is all premature optimization, except for the goopy code, which is > presumably used enough to make it worth optimizing. And guess what? > The goopy code wins. What the people theorizing about the speed of > extend vs list creation miss is that the things with

Re: Flattening lists

2009-02-05 Thread rdmurray
Quoth J Kenneth King : > mk writes: > > > Hello everybody, > > > > Any better solution than this? > > > > def flatten(x): > > res = [] > > for el in x: > > if isinstance(el,list): > > res.extend(flatten(el)) > > else: > > res.append(el) > > retu

Trouble sorting a list of objects by attributes

2009-02-06 Thread rdmurray
Quoth Robocop : > Hello again, > I've found myself stumped when trying to organize this list of > objects. The objects in question are timesheets which i'd like to > sort by four attributes: > > class TimeSheet: > department = string > engagement = string > date = datetime.date > stare_ho

Re: Flattening lists

2009-02-06 Thread rdmurray
Quoth Mensanator : > On Feb 6, 3:23=A0pm, Rhamphoryncus wrote: > > On Feb 5, 1:16=A0pm, Michele Simionato > > wrote: > > > > > On Feb 5, 7:24=A0pm, a...@pythoncraft.com (Aahz) wrote: > > > > In article > > > > , > > > > Michele Simionato =A0 wrote: > > > > >Looks fine to me. In some situations y

urllib2: problem of handling space in parameter

2009-02-07 Thread rdmurray
Quoth Muddy Coder : > Hi Folks, > > I encrountered a problem of using urllib2: the space handling. Look at > the code below: > > import urllib2 > url = r'http://somedomain.com/a.cgi?name=muddy coder&password=foobar > cgi_back = urllib2.urlopen(url).read() > > In this cgi_back, I saw field passwo

Re: Flattening lists

2009-02-07 Thread rdmurray
Rhamphoryncus wrote: > On Feb 6, 10:21=A0pm, rdmur...@bitdance.com wrote: > > Quoth Mensanator : > > > def flatten(listOfLists): > > > =A0 =A0 return list(chain.from_iterable(listOfLists)) > > > > =A0 =A0 Python 2.6.1 (r261:67515, Jan =A07 2009, 17:09:13) > > =A0 =A0 [GCC 4.3.2] on linux2 > > =A0

isfifo?

2009-02-07 Thread rdmurray
I've googled and looked through os.path, but I don't see a method for determining if a path points to a FIFO. Anyone know of a simple way to do so? --RDM -- http://mail.python.org/mailman/listinfo/python-list

Re: isfifo?

2009-02-07 Thread rdmurray
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= wrote: > rdmur...@bitdance.com wrote: > > I've googled and looked through os.path, but I don't see a method for > > determining if a path points to a FIFO. Anyone know of a simple way to > > do so? > > def isfifo(fn): > return stat.S_ISFIFO(os.stat(fn

Help needed to retrieve text from a text-file using RegEx

2009-02-09 Thread rdmurray
Oltmans wrote: > Here is the scenario: > > It's a command line program. I ask user for a input string. Based on > that input string I retrieve text from a text file. My text file looks > like following > > Text-file: > - > AbcManager=C:\source\code\Modules\Code-AbcManager\ > AbcTest=

Re: Import without executing module

2009-02-10 Thread rdmurray
Lie Ryan wrote: > On Tue, 03 Feb 2009 20:08:34 -0800, Stephen Hansen wrote: > > > There is no need to try to make sure something is > > executed/compiled only once in Python like you may want to do in C. > > Every module is only ever compiled once: if you import it ten times in > > ten different

Can urllib check path exists on server?

2009-02-10 Thread rdmurray
Muddy Coder wrote: > urllib bridges up a client to a server, it works fine. I wonder: is > there a method that can check the existence of a file in the server > side? We can check such an existence on local filesystem by using > os.path.exists(), can I do such a check on server? For example, > htt

Re: what IDE is the best to write python?

2009-02-10 Thread rdmurray
a...@pythoncraft.com (Aahz) wrote: > In article , > wrote: > >Quoth a...@pythoncraft.com (Aahz): > >> Then I have the problem of copying around the syntax highlighting > >> configuration to every computer I use. > > > >Well, _that's_ easy to fix. I have a little bash script called > >'synchome'

Re: hpw to convert a linux python script ?

2009-02-11 Thread rdmurray
Stef Mientki wrote: > Alec Schueler wrote: > > On Feb 11, 7:58 pm, Stef Mientki wrote: > > > >> As there are a whole lot of these lines, in a whole lot of files, > >> I wonder if there's a simple trick to point > >> /usr/share/tinybldLin/ > >> to my directory ? > >> > >> thanks, > >> Stef >

Re: "Maximum recursion depth exceeded"...why?

2009-02-18 Thread rdmurray
alex23 wrote: > On Feb 18, 11:36=A0am, Paul Rubin wrote: > > Thomas Allen writes: > > > attempting. Basically, I'm transforming a live site to a local one and > > > > Something wrong with wget -R ? > > Did you mean wget -r ? > > That will just grab the entire site

Re: "Maximum recursion depth exceeded"...why?

2009-02-18 Thread rdmurray
Thomas Allen wrote: > On Feb 18, 4:51 am, alex23 wrote: > > On Feb 18, 7:34 pm, rdmur...@bitdance.com wrote: > > > > > Yeah, but wget -r -k will do that bit of it, too. > > > > Wow, nice, I don't know why I never noticed that. Cheers! > > Hm...doesn't do that over here. I thought it may have bee

Re: Find the location of a loaded module

2009-02-21 Thread rdmurray
"Gabriel Genellina" wrote: > En Fri, 20 Feb 2009 20:44:21 -0200, Aaron Scott > escribi=F3: > > > So, the problem lies with how Python cached the modules in memory. > > Yes, the modules were in two different locations and yes, the one that > > I specified using its direct path should be the one l

Re: Pythonic way to determine if one char of many in a string

2009-02-21 Thread rdmurray
odeits wrote: > On Feb 21, 12:47=A0am, "Gabriel Genellina" > wrote: > > En Sat, 21 Feb 2009 01:14:02 -0200, odeits escribi=F3: > > > > > On Feb 15, 11:31=A0pm, odeits wrote: > > >> It seems what you are actually testing for is if the intersection of > > >> the two sets is not empty where the fi

Re: simplest way to strip a comment from the end of a line?

2008-12-04 Thread rdmurray
On Thu, 4 Dec 2008 at 08:50, Joe Strout wrote: I have lines in a config file which can end with a comment (delimited by # as in Python), but which may also contain string literals (delimited by double quotes). A comment delimiter within a string literal doesn't count. Is there any easy way to

Re: Why shouldn't you put config options in py files

2008-12-04 Thread rdmurray
On Thu, 4 Dec 2008 at 11:35, HT wrote: I can think of lots of arguments why this is a bad idea, but I don't seem to be able to think of a really convincing one. I think it depends on the problem domain. As someone else said, there are issues with being able to inject arbitrary code via the con

Re: pretty strange behavior of "strip"

2008-12-05 Thread rdmurray
On Thu, 4 Dec 2008 at 20:54, Terry Reedy wrote: 'toc.html' > > > test[4].strip('.html') 'oc' Can't figure out what is going on, really. What I can't figure out is why, when people cannot figure out what is going on with a function (or methods in this case), they do not look it up the doc.

Re: pretty strange behavior of "strip"

2008-12-05 Thread rdmurray
On Fri, 5 Dec 2008 at 07:54, Mark Tolonen wrote: > > import re > > re.split('[,.]','blah,blah.blah') ['blah', 'blah', 'blah'] Thank you. Somehow it never occurred to me that I could use that kind of pattern that way. I guess my brain just doesn't think in regexes very well :) --RDM -- htt

Re: Best way to report progress at fixed intervals

2008-12-09 Thread rdmurray
On Tue, 9 Dec 2008 at 08:40, Slaunger wrote: I am a novice Python 2.5 programmer, who write some cmd line scripts for processing large amounts of data. I would like to have possibility to regularly print out the progress made during the processing, say every 1 seconds, and i am wondering what a

Re: Can't figure out where SyntaxError: can not delete variable 'x' referenced in nested scope us coming from in python >=2.6

2008-12-09 Thread rdmurray
On Tue, 9 Dec 2008 at 13:11, Albert Hopkins wrote: Say I have module foo.py: def a(x): def b(): x del x [...] The difference is under Python 2.4 I get a traceback with the lineno and offending line, but I do not get a traceback in Pythons 2.6 and 3.0.

Re: When (and why) to use del?

2008-12-09 Thread rdmurray
On Tue, 9 Dec 2008 at 18:55, Duncan Booth wrote: Albert Hopkins <[EMAIL PROTECTED]> wrote: def otherfunction(): try: # some stuff except SomeException, e: # more stuff del e return I think this looks u

Re: Best way to report progress at fixed intervals

2008-12-09 Thread rdmurray
On Tue, 9 Dec 2008 at 13:27, Slaunger wrote: On 9 Dec., 19:35, [EMAIL PROTECTED] wrote: I felt like a little lunchtime challenge, so I wrote something that I think matches your spec, based on your sample code. ?This is not necessarily the best implementation, but I think it is simpler and clear

Re: SequenceMatcher bug ?

2008-12-09 Thread rdmurray
On Mon, 8 Dec 2008 at 23:46, eliben wrote: This is about Python 2.5.2 - I don't know if there were fixes to this module in 2.6/3.0 I think I ran into a bug with difflib.SequenceMatcher class. Specifically, its ratio() method. The following: SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 5

Re: Text parsing via regex

2008-12-09 Thread rdmurray
On Mon, 8 Dec 2008 at 16:51, Robert Kern wrote: Robocop wrote: Wow! Thanks for all the input, it looks like that textwrapper will work great for my needs. And thanks for the regex help everyone. Also, i was thinking of using a list, but i haven't used them much in python. Is there anythin

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-09 Thread rdmurray
On Tue, 9 Dec 2008 at 18:49, [EMAIL PROTECTED] wrote: On Ubuntu, I accidentally manually installed setuptools http://pypi.python.org/pypi/setuptools/0.6c9 (by running the .egg file as a shell script via sudo), and now realize I should just be using apt to take care of my system Python packages. I

Re: SequenceMatcher bug ?

2008-12-10 Thread rdmurray
On Tue, 9 Dec 2008 at 22:15, eliben wrote: On Dec 10, 4:12?am, [EMAIL PROTECTED] wrote: On Mon, 8 Dec 2008 at 23:46, eliben wrote: This is about Python 2.5.2 - I don't know if there were fixes to this module in 2.6/3.0 I think I ran into a bug with difflib.SequenceMatcherclass. Specifically,

Re: forcing future re-import from with an imported module

2008-12-10 Thread rdmurray
On Wed, 10 Dec 2008 at 14:53, _wolf wrote: thanks for your answer. i am aware that imports are not designed to have side-effects, but this is exactly what i want: to trigger an action with `import foo`. you get foo, and doing this can have a side- effect for the module, in roughly the way that a

Re: Preventing execution of a method

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 08:16, alex23 wrote: On Dec 12, 2:07?am, "Emanuele D'Arrigo" <[EMAIL PROTECTED]> wrote: I.e. if I have a class with two methods, doSomethingSafe() and doSomethingDangerous(), is there a way to prevent another module from executing doSomethingDangerous() but allow the execu

Re: newbie question: if var1 == var2:

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 10:24, Kirk Strauser wrote: At 2008-11-29T04:02:11Z, Mel <[EMAIL PROTECTED]> writes: You could try for item in fname: item = item.strip() This is one case where I really miss Perl's "chomp" function. It removes a trailing newline and nothing else, so you don't hav

Re: internal circular class references

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 09:33, Ethan Furman wrote: Carl Banks wrote: On Dec 10, 5:26 pm, Ethan Furman wrote: First of all, do you even need to wrap the datetime.date class? With Python's duck typing ability, you could have a separate NullDate class to go alongside the datetime.date, and use

Re: Preventing execution of a method

2008-12-11 Thread rdmurray
On Thu, 11 Dec 2008 at 13:41, Emanuele D'Arrigo wrote: On Dec 11, 7:48?pm, Bruno Desthuilliers wrote: or to provide read-only access. I.e. right now I'm working on the graphical client which potentially could be rewritten entirely by the users. It is necessary and perfectly reasonable for the c

Re: Interface & Implementation

2008-12-12 Thread rdmurray
On Fri, 12 Dec 2008 at 16:07, J Ramesh Kumar wrote: I am new to python. I require some help on implementing interface and its implementation. I could not find any sample code in the web. Can you please send me some sample code which is similar to the below java code ? Thanks in advance for your h

Re: Shorter tracebacks

2008-12-13 Thread rdmurray
On Sat, 13 Dec 2008 at 06:13, bearophileh...@lycos.com wrote: When I write recursive code in Python I sometimes go past the maximum allowed stack depth, so I receive a really long traceback. The show of such traceback on my screen is very slow (despite a CPU able to perform billions of operations

Re: subprocess to pipe through several processes?

2008-12-14 Thread rdmurray
On Sat, 13 Dec 2008 at 23:05, Neal Becker wrote: How would I use suprocess to do the equivalent of: cat - | program_a | program_b Have you tried extending the pipe example from the manual? http://docs.python.org/library/subprocess.html#replacing-shell-pipeline --David -- http://mail.python.o

Re: Having Issues with CMD and the 'python' command

2008-12-15 Thread rdmurray
On Mon, 15 Dec 2008 at 23:01, James Mills wrote: On Mon, Dec 15, 2008 at 10:51 PM, Lamonte Harris wrote: Every time I start cmd on windows it requires me to "set path=%path%;C:\python26" why? I'm getting annoyed... "cmd" has _nothing_ to do with Python. (Top posting corrected.) But the an

Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread rdmurray
On Mon, 15 Dec 2008 at 18:16, Krishnakant wrote: how do you let the ' go as a part of the string? I have used %s as placeholder as in queryString = "insert into venders values ('%s,%s,%s" % (field1,field2,field3 ) ... This is not working for the ' values. This is untested, but I think what you

Re: Generator slower than iterator?

2008-12-16 Thread rdmurray
Quoth Lie Ryan : > On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > > > Hi all, > > > > Im parsing a 4.1GB apache log to have stats about how many times an ip > > request something from the server. > > > > The first design of the algorithm was > > > > for line in fileinput.input(sy

eval() and global variables

2008-12-16 Thread rdmurray
Quoth "=?ISO-8859-1?Q?Juan_Pablo_Romero_M=E9ndez?=" : > Hello, > > Suppose this function is given: > > def f(x,y): > return x+y+k > > Is it possible to somehow assign a value to k without resorting to > making k global? > > I'm thinking something like this: > > eval("f(1,1)", {"f":f, "k":1})

Why no lexical scoping for a method within a class?

2008-12-17 Thread rdmurray
Quoth walterbyrd : > For a language as well structured as Python, this seems somewhat > sloppy, and inconsistant. Or is there some good reason for this? Yes. It's called Object Oriented Programming. > Here is what I mean: > > def a(): > x = 99 > print x > > def b(): > print x > >

Re: help I'm getting delimited

2008-12-17 Thread rdmurray
Quoth John Machin : > On Dec 18, 1:28 am, aka wrote: > > @expose(allow_json=True) > > Means what? Does what? > Does the problem still happen without that? Means what he's posting is not a standalone script :) He says it's part of his turbogears ap. @expose says that this method is callabl

Re: getting object instead of string from dir()

2008-12-17 Thread rdmurray
Quoth Rominsky : > vars seems to give an identical response as locals and globals, at > least in my test name space. All three are new commands for me. I Without arguments vars() returns the same thing as locals(). > like the idea of adopting either vars or locals instead of dir as it > sets up

Re: confused about __str__ vs. __repr__

2008-12-18 Thread rdmurray
Quoth "Diez B. Roggisch" : > Neal Becker wrote: > > > Tino Wildenhain wrote: > > > >> Neal Becker wrote: > >> ... > >>> That makes no sense to me. If I call 'print' on a container, why > >>> wouldn't it recursively print on the contained objects? Since print > >>> means call str, printing a co

Re: ANN: New Book: Programming in Python 3

2008-12-19 Thread rdmurray
Quoth Steven D'Aprano : >The second exception is if the word ends with an S. In British English, >you put the apostrophe after the S: > >Thomas' approach is wholly practical. > >In American English, they often (but not always) add an extra S: > >Thomas's approach is wholly practical. > >which in my

Re: New Python 3.0 string formatting - really necessary?

2008-12-19 Thread rdmurray
Quoth Steven D'Aprano : > Whether using % or format(), I don't see the need to change the code, > only the strings. > > Using positional arguments is not really that different: > > "{0} {1}".format("dead", "parrot") > "{0} {1}".format("perroquet", "mort") This should be something like: _("{0}

Re: can error messages be improved or can they be overridden ?

2009-02-23 Thread rdmurray
Stef Mientki wrote: > thanks Ron, > > but I was looking for a more general solution, > in which I don't change the program itself, > and where the error messages (in general) become more informative than > it is by default. [snip] > >> -Original Message- > >> From: Stef Mientki [mailto:s

read csv error question

2009-02-23 Thread rdmurray
Vincent Davis wrote: > I am trying to read a csv file from excel on a mac. I get the following > error.SystemExit: file some.csv, line 1: new-line character seen in unquoted > field - do you need to open the file in universal-newline mode? > I was using the example code > import csv, sys > > read

Re: can error messages be improved or can they be overridden ?

2009-02-23 Thread rdmurray
"andrew cooke" wrote: > rdmur...@bitdance.com wrote: > [...] > > (You know, I really ought to revisit that routine and make it part > > of my standard development toolbox.) > > please post it OK. I dug it up, cut out the stuff that was specific to the application, freshened it up a little,

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread rdmurray
John Machin wrote: > On Feb 25, 11:07=A0am, "Roy H. Han" > wrote: > > Dear python-list, > > > > I'm having some trouble decoding an email header using the standard > > imaplib.IMAP4 class and email.message_from_string method. > > > > In particular, email.message_from_string() does not seem to pro

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread rdmurray
Steve Holden wrote: > >>> from email.header import decode_header > >>> print > decode_header("=?us-ascii?Q?Inteum_C/SR_User_Tip:__Quick_Access_to_Recently_Opened_Inteu?=\r\n\t=?us-ascii?Q?m_C/SR_Records?=") > [('Inteum C/SR User Tip: Quick Access to Recently Opened Inteum C/SR > Records', 'us-asc

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread rdmurray
Steve Holden wrote: > rdmur...@bitdance.com wrote: > > Steve Holden wrote: > > from email.header import decode_header > > print > >> decode_header("=?us-ascii?Q?Inteum_C/SR_User_Tip:__Quick_Access_to_Recently_Opened_Inteu?=\r\n\t=?us-ascii?Q?m_C/SR_Records?=") > >> [('Inteum C/SR User Tip

Efficient searching through objects

2009-02-26 Thread rdmurray
sert wrote: > I have written a program that reads data and updates the records > for some people. They are represented by objects, and I need to > read the data from a file, look the person up and then update > his record. > > I have implemented this by creating a list with all the people's >

Re: why cannot assign to function call

2009-02-28 Thread rdmurray
Mark Wooding wrote: > Ethan Furman writes: > > > Mark Wooding wrote: > >> Here's what I think is the defining property of pass-by-value [...]: > >> > >> The callee's parameters are /new variables/, initialized /as if by > >> assignment/ from the values of caller's argument expressions. > >>

TypeErrors

2009-02-28 Thread rdmurray
Sean Novick wrote: > First lookup: > Traceback (most recent call last): >File "F:\CSC113 Module 4 CA\sample database.py", line 72, in >class phonedb: >File "F:\CSC113 Module 4 CA\sample database.py", line 146, in phonedb >for entry i

OTish: convince the team to drop VBScript

2009-02-28 Thread rdmurray
"Christian R." wrote: > The company does use Python on rare occasions. It all comes down to > the prejudices and habits of one of the programmers. His only argument > I can't counter -because I don't see the problem- is that "Python > modules cause problems for updates to customer's installations"

Re: How best to test functions which use date.today

2009-02-28 Thread rdmurray
Christian Heimes wrote: > Lie Ryan wrote: > >> But this fails with: > >> > >> TypeError: can't set attributes of built-in/extension type > >> 'datetime.date' > > > > This is because today is an attribute. In python, we can override > > attribute access to become a function call. I don't have pyth

Re: Creating Zip file like java jar file

2009-02-28 Thread rdmurray
zaheer.ag...@gmail.com wrote: > On Feb 28, 11:33 pm, Lie Ryan wrote: > > zaheer.ag...@gmail.com wrote: > > > On Feb 28, 11:15 pm, "Gabriel Genellina" > > > wrote: > > >> En Sat, 28 Feb 2009 14:34:15 -0200, escribi= > =F3: > > > > >>> I want to create zip file equivalent to java jar file,I create

Is it possible to grab hidden code in ClientForm?

2009-03-01 Thread rdmurray
Muddy Coder wrote: > Nowadays some websites let users to fill in some so-called > verification code, and the tricky thing is that the CODE is delivered > from server with an image. For example: > > >  Refresh Image > > When click Refresh Image, the CODE on the image changes. I wonder: > does th

RE: Help required to read and print lines based on the type of first character

2009-03-05 Thread rdmurray
abhinayaraj.r...@emulex.com wrote: > Thank you for the suggestions. > > Some little reading gave the idea and it works well too. :) > > Here is the code: > fileIN = open("test.txt") > count = 0 > for line in fileIN: > data= line > > if '' in data: > count = 4 >

Re: question about ctrl-d and atexit with threads

2009-03-06 Thread rdmurray
Darren Dale wrote: >On Mar 5, 6:27 pm, "Gabriel Genellina" wrote: >> En Thu, 05 Mar 2009 15:26:18 -0200, Darren Dale >> escribi�: >> >> > On Mar 5, 12:02�pm, s...@pobox.com wrote: >> >> What happens if you simply call >> >> >>my_thread.setDaemon(True) >> >> >> (or in Python 2.6): >> >>

Re: Translating pysnmp oids to human readable strings

2009-03-07 Thread rdmurray
SpamMePlease PleasePlease wrote: > On Fri, Mar 6, 2009 at 2:14 PM, Shantanu Joshi wrote: > > > > SpamMePlease PleasePlease writes: > > > >> I actually tried to load the new file with following code: > >> > >> print builder.MibBuilder().getMibPath() > >> mibBuilder = builder.MibBuilder().loadModu