On 12/26/2012 11:11 AM, Benjamin Kaplan wrote:
On Dec 26, 2012 11:00 AM, Antoon Pardon antoon.par...@rece.vub.ac.be
mailto:antoon.par...@rece.vub.ac.be wrote:
I am converting some programs to python 3. These programs manipulate
tarfiles. In order for the python3 programs to be really useful
On 8/25/2012 10:20 PM, Christopher McComas wrote:
Greetings,
I have code that I run via Django that grabs the results from various sports
from formatted text files. The script iterates over every line in the formatted
text files, finds the team in the Postgres database updates their w/l
On 8/5/2012 12:43 AM, Ramchandra Apte wrote:
Try pypreprocessor http://code.google.com/p/pypreprocessor/ .
Better idea:
You should be using the logging http://docs.python.org/library/logging.html
module if you want to print debug information quickly.It uses threads and is
optimized to run fast.
On 8/3/2012 4:48 PM, Tobiah wrote:
I have a bunch of classes from another library (the html helpers
from web2py). There are certain methods that I'd like to add to
every one of them. So I'd like to put those methods in a class,
and pass the parent at the time of instantiation. Web2py has
a FORM
I have a problem that I'm solving using a regex. (Yeah, I know, now I have two
problems...) ;-)
Anyways, the regex is about a couple of pages long and it works just peachy.
There's just one thing I'd like to do to make it more elegant.
I need to compile the regex with MULTILINE and DOTALL.
On 5/31/2012 3:57 AM, Qi wrote:
I have an application that embedding Python into C++.
When any exception occurred in C++ code, PyErr_SetString will
be called to propagate the exception to Python.
The problem is, some unit tests trigger exception on intention.
So it's OK to have the exceptions.
On 4/19/2012 3:28 PM, dmitrey wrote:
hi all,
can I somehow overload operators like =, - or something like
that? (I'm searching for appropriate overload for logical implication
if a then b)
Thank you in advance, D.
This tickled a memory from decades back when I worked in PL/I. They have a
bool
On 3/26/2012 11:52 AM, Robert Kern wrote:
On 3/26/12 4:33 PM, Steven W. Orr wrote:
On 3/26/2012 9:44 AM, Robert Kern wrote:
On 3/26/12 2:33 PM, Steven W. Orr wrote:
I created a new class called CaseInsensitiveDict (by stealing from code I
found
on the web, thank you very much). The new class
I created a new class called CaseInsensitiveDict (by stealing from code I
found on the web, thank you very much). The new class inherits from dict. It
makes it so that if the key has a 'lower' method, it will always access the
key using lower
I'd like to change the place where I previously
On 3/26/2012 9:44 AM, Robert Kern wrote:
On 3/26/12 2:33 PM, Steven W. Orr wrote:
I created a new class called CaseInsensitiveDict (by stealing from code I found
on the web, thank you very much). The new class inherits from dict. It makes it
so that if the key has a 'lower' method
On 3/14/2012 6:07 AM, Gelonida N wrote:
Hi,
At the moment I use ConfigParser
http://docs.python.org/library/configparser.html
for one of my applications.
Now I'm looking for a library, which behaves like config parser, but
with one minor difference.
The write() mehtod should keep existing
Question 1:
I have a class A with one attribute and I define __get__ and __set__ for that
class. Then I create another class B that uses it.
Why does B require that the instance of A be a class variable in B and not
created as an instance variable in __init__?
E.g.,
# This works fine.
I have a 'master' directory and a collection of 'slave' dirs. I want the
master to collect all of the stuff in the slave dirs.
The slaves all look like this,
.
|-- slaveX
| `-- archI
| | `-- distJ
| | | ` -- FILE
Where the different slaveX dirs may contain multiple occurrences of
I hope I don't sound like I'm ranting :-(
I have created a module (called xlogging) which sets up logging the way I want
it. I found out that if I set up my logger without a name, then it gets
applied to every logger that is referenced by every module that ever gets
imported.
The problem is that
I have been doing a lot of reading. I'm starting to get it. I think it's
really cool as well as dangerous, but I plan on being respectful of the
construct. I found a web page that I found quite readable.
http://cleverdevil.org/computing/78/
So, I tried to run the example code (below), and I
I'm writing a program that uses paramiko to run a lot of commands over ssh.
Some of the commands take time to run and they write to stdout and stderr as a
normal part of their operation so that we can see progress happening.
I can't seem to get the output from the remote commands (which is
On 5/17/2011 6:26 PM, Xah Lee wrote:
might be of interest.
〈English Idiom in Unix: Directory Recursively〉
http://xahlee.org/comp/idiom_directory_recursively.html
The answer is from compute science 101. From any standard data structures
course, you learn the algorithm for how to walk a tree.
On 3/3/2011 11:11 PM, geremy condra wrote:
On Thu, Mar 3, 2011 at 7:24 PM, Steven W. Orrste...@syslang.net wrote:
I look everywhere but I couldn't find anything. Could someone please point
me to a small example program that does an import rpm, takes an rpm file as
an argument and gets the list
On 3/4/2011 10:24 AM, Daniel Mahoney wrote:
On Thu, 03 Mar 2011 22:24:24 -0500, Steven W. Orr wrote:
I look everywhere but I couldn't find anything. Could someone please
point me to a small example program that does an import rpm, takes an
rpm file as an argument and gets the list of files
I look everywhere but I couldn't find anything. Could someone please point me to
a small example program that does an import rpm, takes an rpm file as an
argument and gets the list of files contained in the file, the same as if I had
used the commandline
rpm -pql foo-1.23-4.i586.rpm
Much
On 8/2/2010 4:33 AM, Thorsten Kampe wrote:
* Tim Chase (Mon, 26 Jul 2010 21:42:24 -0500)
On 07/26/10 21:26, Steven W. Orr wrote:
Please! Never export anything from your .bashrc unless you
really know what you're doing. Almost all exports should be
done in your .bash_profile
Could you
On 08/07/10 23:57, quoth Miki:
On Aug 7, 7:42 pm, Steven W. Orr ste...@syslang.net wrote:
I'm ok in python but I haven't done too much with web pages. I have a web
page
that is hand written in html that has about 1000 entries in a table and I
want
to convert the table from entries like
I'm ok in python but I haven't done too much with web pages. I have a web page
that is hand written in html that has about 1000 entries in a table and I want
to convert the table from entries like this
tr
td Some Date String /td
td SomeTag /td
td
a href=localSubdir A
On 08/03/10 06:21, quoth loial:
In a unix shell script I can do something like this to look in a
directory and get the name of a file or files into a variable :
MYFILE=`ls /home/mydir/JOHN*.xml`
Can I do this in one line in python?
Sorry, but I just can't help myself.
Yeah, it's one
On 08/01/10 07:27, quoth News123:
On 08/01/2010 01:08 PM, News123 wrote:
I wondered, whether there's a simple/standard way to let
the Optionparser just ignore unknown command line switches.
In order to illustrate, what I try to achieve:
import optparse
parser =
On 07/26/10 22:42, quoth Tim Chase:
On 07/26/10 21:26, Steven W. Orr wrote:
Please! Never export anything from your .bashrc unless you
really know what you're doing. Almost all exports should be
done in your .bash_profile
Could you elaborate on your reasoning why (or why-not)? I've found
On 07/26/10 20:02, quoth Chris Rebert:
On Mon, Jul 26, 2010 at 4:36 PM, Peng Yu pengyu...@gmail.com wrote:
You need to export R_HOME in bash (probably in your .bashrc or
.bash_profile). See
http://www.ibm.com/developerworks/library/l-bash.html#N10074
Please! Never export anything from your
On 07/12/10 21:29, quoth Kenny Meyer:
Hello,
I have to figure out if a string is callable on a Linux system. I'm
actually doing this:
def is_valid_command(command):
retcode = 100 # initialize
if command:
retcode = subprocess.call(command, shell=True)
On 06/27/10 23:20, quoth GrayShark:
Thanks for the help
That was what I was looking for. All the rest, the arguments were
unhelpful.
Question: If you can't answer the question, why are you talking?
I'm American Indian. That's what I was taught. We don't talk that much.
But you get an
I need to test an argument for a few different types.
I'm calling my function like this
arf = MyFunc(list)
What I want to do is to test for whether something is a string, tuple, list or
function. It's that last one that's causing me a problem.
if isinstance(arg, (str, tuple, list)):
No
On 6/27/2010 10:25 PM, Stephen Hansen wrote:
On 6/27/10 7:09 PM, Steven W. Orr wrote:
So, my question is, what value can I use as the 2nd arg to isinstance
to see if
foo is a function? And while I'm on the subject, what types does
isinstance not
support?
Does it have to be a function
AutoRecalcDict is a subclass of dict that allows programmers to create user
defined dependencies and functions on target keys.
You can find it at
http://pypi.python.org/pypi/AutoRecalcDict/0.1.1
I recently was designing tests for radio frequency analysis (about which, I know
nothing). All of
On 06/17/10 01:40, quoth madhuri vio:
if i want to create a button
which performs the transcription of dna to rna
using tkinter in a gui...
can u give me the method...
--
madhuri :)
Dear Madasahatter. You need to read the description below on how to properly
implement and use the
On 6/10/2010 11:40 AM, Chris Seberino wrote:
Even if zombies are created, they will eventually get dealt with my OS
w/o any user intervention needed right?
Bad approach. Years ago I inherited a server that didn't do a proper cleanup pf
its slaves. After a few days running, people discovered
On 06/10/10 04:41, quoth Marco Nawijn:
On Jun 10, 2:39 am, james_027 cai.hai...@gmail.com wrote:
hi,
I am trying to reverse the order of my list of tuples and its is
returning a None to me. Is the reverse() function not allow on list
containing tuples?
Thanks,
James
As the others
On 6/1/2010 7:53 AM, Xavier Ho wrote:
On 1 June 2010 21:48, Leo Breebaart l...@lspace.org
mailto:l...@lspace.org wrote:
When fed the following code:
def Foo():
class A(object):
def __init__(self):
pass
class B(object):
def
I just discovered descriptors but what I want to do isn't working right.
I hope this isn't too long. :-(
Here's what I have that works:
class C(object):
def g(self):
print dir(g):,dir(self.g)
def f(self, ss):
print ss = , ss
cc = C()
cc.ff = f.__get__(C,cc)
cc.ff('Round 3')
And
I found something on sourceforge called mat2py, but there's nothing there. (It
seems to be just a placeholder.) I figure that if anyone would know of something
useful, this would be the place to try.
TIA
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
On 5/19/2010 6:53 AM, Javier Montoya wrote:
I've a list of float numbers and I would like to delete incrementally
a set of elements in a given range of indexes, sth. like:
for j in range(beginIndex, endIndex+1):
print (remove [%d] = val: %g % (j, myList[j]))
del myList[j]
However,
I just discovered Accelerator entries so my wx app is now able to exit
by typing Ctrl-Q.
Can someone please tell me what to use to cause a pane to scroll up and
down using the middle mouse scroll roller thingy? I looked and found
wxCURSOR_MIDDLE_BUTTON but I suspect that's only good for
On Tuesday, Apr 8th 2008 at 16:51 -, quoth cesco:
=Hi,
=
=I need to instantiate an object (my_object) whose methods I have to
=use in two files (file1.py and file2.py) which are in the same
=directory. Is it possible to instantiate such object in the
=__init__.py file and then directly use it
Here's what I want to do:
if ( ( v == 1 )
or ( v == 2 )
or ( v == 3 ) ):
pass
but emacs (left to its own devices, does this.
if ( ( v == 1 )
or ( v == 2 )
or ( v == 3 ) ):
pass
It works great for me in C-mode. Does anyone know how to jimmie up
python-mode so it
python-2.3.5
wx-2.6
I just bought the wxPython In Action book and I see that all the examples
say to
import wx
All of our pre-existing code was horribly doing a
from wxPython import *
I changed all the code so that it was doing an import wx and found that
everything was broken. In particular,
I want to indirectly change the value of a variable.
#! /usr/bin/python
foo = [44]
bar = foo
bar[0] = 55
print 'bar = ', bar
print 'foo = ', foo
This works fine.
bar = [55]
foo = [55]
But I want to do the same with a class value.
#! /usr/bin/python
S = None
dd = { 'class': [S] }
class
On Wednesday, Jan 9th 2008 at 14:01 -, quoth Fredrik Lundh:
=Steven W. Orr wrote:
=
= So sorry because I know I'm doing something wrong.
=
= 574 cat c2.py
= #! /usr/local/bin/python2.4
=
= def inc(jj):
= def dummy():
= jj = jj + 1
= return jj
= return dummy
So sorry because I know I'm doing something wrong.
574 cat c2.py
#! /usr/local/bin/python2.4
def inc(jj):
def dummy():
jj = jj + 1
return jj
return dummy
h = inc(33)
print 'h() = ', h()
575 c2.py
h() =
Traceback (most recent call last):
File ./c2.py, line 10, in
class S(int):
def __init__(self, value):
self.value = value
def addStr(self, str):
self.doc = str
s = S(44)
s.addStr('Hello')
print 's = ', s
print 's.doc = ', s.doc
class T(int):
def __init__(self, value, str):
self.value = value
self.doc = str
t
On Friday, Nov 2nd 2007 at 14:14 -, quoth matthias:
=Howdy !
=
=I started using the assert() stmt and found it quite useful :-) I
=have only one problem: I don't
=know how to turn them off again.
=
=I know that -O turns off assertions in general. However, how do I
=pass thus parameter to
We have an app and I'm trying to decide where the app should be
installed. The question is whether it should be site-specific or not, as
in
/usr/lib/python2.3/site-packages
or
/usr/lib/site-python
The latter would solve a lot of problems for me.
In the case of emacs, most stuff seems to go
Python has a number of quoting 'options' to help with
times when one way may be more convenient than another.
In the world of shell scripting, I use a technique that I call minimal
quoting. It works like this:
foo=bar # No quotes needed
echo $foo # Also none needed
On Thursday, Sep 20th 2007 at 18:14 +0100, quoth Paul Rudin:
=W. Watson [EMAIL PROTECTED] writes:
=
= Thanks, but no thanks. The learning curve is way too steep.
=
=Up to you but, these days emacs comes with all sorts of
=pointing-clicky-menu-y type things - you don't really have to learn
On Tuesday, Sep 11th 2007 at 21:17 -0700, quoth Andrey:
=i have a newbie question about the file() function.
=I have 2 daemons running on my linux box.
=
=1 will record the IDs to a file - logs.txt
=other 1 will open this file, read the IDs, and then Clean up the
=file -logs.txt
=
=Since these
On Monday, Sep 10th 2007 at 08:34 -, quoth Marc 'BlackJack' Rintsch:
=On Mon, 10 Sep 2007 20:19:08 +1200, Lawrence D'Oliveiro wrote:
=
= In message [EMAIL PROTECTED], Marc 'BlackJack' Rintsch
= wrote:
=
= I see a tree structure here ...
=
= Good, you're improving.
=
=Thanks.
=
= ... but
On Saturday, Aug 25th 2007 at 22:14 -0700, quoth Alex Martelli:
=Steven W. Orr [EMAIL PROTECTED] wrote:
= * Also, I'd like to understand what the difference is between
= nclass = new.classobj(name,(D1,),globals())
= vs.
= def classfactory():
= class somename(object
Given the following code: (I hope it's as simple as possible) :-)
#! /usr/bin/python
import new
class BASE:
def __init__( self ):
print 'Hello from BASE init'
def m1( self ):
print 'M1 Base: Self = ', self
def m1replace( self ):
print 'm1replace:Self = ', self
On Saturday, Aug 25th 2007 at 17:19 -0700, quoth Alex Martelli:
=Steven W. Orr [EMAIL PROTECTED] wrote:
= ...
= name = 'C1'
= nclass = new.classobj(name,(D1,),globals())
= globals()[name] = nclass
=
=Here, you're creating a VERY anomalous class C1 whose __dict__ is
=globals
In the program below, I want this instance to end up calling repmeth
whenever inst.m1 is called. As it is now, I get this error:
Hello from init
inst = __main__.CC instance at 0x402105ec
Traceback (most recent call last):
File ./foo9.py, line 17, in ?
inst.m1()
TypeError: repmeth()
On Friday, Aug 24th 2007 at 09:12 -0700, quoth [EMAIL PROTECTED]:
=On Aug 24, 11:02 am, Steven W. Orr [EMAIL PROTECTED] wrote:
= In the program below, I want this instance to end up calling repmeth
= whenever inst.m1 is called. As it is now, I get this error:
=
= Hello from init
= inst
On Friday, Aug 24th 2007 at 12:26 -0400, quoth Steven W. Orr:
=On Friday, Aug 24th 2007 at 09:12 -0700, quoth [EMAIL PROTECTED]:
=
==On Aug 24, 11:02 am, Steven W. Orr [EMAIL PROTECTED] wrote:
== In the program below, I want this instance to end up calling repmeth
== whenever inst.m1 is called
I have a base class B and a derived class D which inherits from B. I also
have a D2 class which inherits from D. D is used as a base class for most
of my generated classes. I have a special class which inherits from D2
because I need to override a couple of its methods. Anything based on D2
Sorry, I had a small description problem. It's corrected below.
I have a base class B and a derived class D which inherits from B. I also
have a D2 class which inherits from D. D is used as a base class for most
of my generated classes. I have a special class which inherits from D2
because I need
I have some functions I need to create at runtime. The way I'm creating
them is by calling a function which returns the string representation.
Then I exec the string.
Here's the code I use to gen the strings:
mkfactfns.py
---
import new
def mkfactfns( cname ):
def auxgen( name,
I have this which works:
#! /usr/bin/python
strfunc =
def foo( a ):
print 'a = ', a
exec strfunc
globals()['foo'] = foo
foo( 'Hello' )
and this which does not:
#! /usr/bin/python
import new
strfunc =
def foo( a ):
print 'a = ', a
co = compile ( strfunc, '', 'exec' )
exec co
nfunc
Given a list of names
ll = (n1, n2, n3, n4)
I want to create a pair of functions based off of each name. An example of
what I want to happen would look like this:
def mkn1dict(address):
return {'Address': address, 'Control': SOME_CONST}
def mkn1Classobj(address):
return Classobj(
is.
;-)
On Tuesday, Aug 14th 2007 at 18:49 -0700, quoth Erik Max Francis:
=Steven W. Orr wrote:
=
= M1.py:268: FutureWarning: hex/oct constants sys.maxint will
= return positive values in Python 2.4 and up
=StartTime = safe_dict_get ( dic, 'starttime', 0x )
= ...
= import warnings
I have module M1 which has the following line in it:
StartTime = safe_dict_get ( dic, 'starttime', 0x )
It gets imported by modules M2 and M3. And finally, M4 imports both M2 and
M3.
M4
|\M3
| |\M1
|\M2
| |\M1
I'm building a .deb file which means I have to compile the
I'm trying again, since no response indicates that I'm not providing
enough info.
I have module M1 which has the following line in it:
StartTime = safe_dict_get ( dic, 'starttime', 0x )
It gets imported by modules M2 and M3. And finally, M4 imports both M2 and
M3. So the idea is
I have a structure I need to pack. I call struct.pack about a dozen times
and each call takes about 53 arguments.
I create a sequence of the arguments:
a1 = 1
a2 = 2
a3 = 3
etc...
a54 = 88
myseq = (a1, a2, a3, a4 etc... a53)
Also I made
def mpack ( fmt, *ss ):
print type(ss)
for ii in
I have the following module:
#! /usr/bin/python
COG_DEBUG=1
def wrapper( dd ):
if dd == 1:
def dfunc( *args ):
print print ,
for ii in args:
print repr(ii)
print compd dfunc
return dfunc
else:
def nfunc(
Does something like that exist?
TIA
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What
On Thursday, Jun 21st 2007 at 10:11 +0100, quoth Michael Hoffman:
=[EMAIL PROTECTED] wrote:
= Hello,
= Does anyone know how to make python-mode correctly indent nested lists
= and dictionaries. I hate indenting Django url patterns and Zope
= Archetypes schemas by hand, because python-mode indents
I just discovered decorators. Very cool. My question is that I can't
figure out how to make a decorator not be restricted to a function so it
would also work on a method.
Here's my code:
def g(expr):
def rpt(func):
def wrapper(t):
for ii in range(expr):
This is more for my education and not so much for practicality.
I have a structure that sort of looks like this:
mdict = {33:{'name': 'Hello0',
'fields':'fields0',
'valid': 'valid0'
55:{'name': 'Hello1',
'fields':'fields1',
'valid':
Lots of code, calls to, calls by, inheritance, multiple tasks, etc.
What do people use to figure out what's happening?
TIA
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
On Wednesday, May 2nd 2007 at 12:48 +0200, quoth Daniel Nogradi:
= Lots of code, calls to, calls by, inheritance, multiple tasks, etc.
=
= What do people use to figure out what's happening?
=
=This is a pretty cool project just for that:
=
=http://codeinvestigator.googlepages.com/codeinvestigator
I have two seperate modules doing factory stuff which each have the
similar function2:
In the ds101 module,
def DS101CLASS(mname,data):
cname = mname+'DS101'
msg_class = globals()[cname]
msg = msg_class(data)
return msg
and in the fdu module,
def FDUCLASS(mname,data):
On Friday, Apr 27th 2007 at 14:07 -0700, quoth James Stroud:
=Steven W. Orr wrote:
= I have two seperate modules doing factory stuff which each have the
= similar function2:
=
= In the ds101 module, def DS101CLASS(mname,data):
= cname = mname+'DS101'
= msg_class = globals()[cname
On Saturday, Apr 21st 2007 at 19:18 +0100, quoth Michael Hoffman:
=Chris Lasher wrote:
= Should a Python module not intended to be executed have shebang/
= hashbang (e.g., #!/usr/bin/env python) or not? I'm used to having a
= shebang in every .py file but I recently heard someone argue that
=
On Monday, Apr 23rd 2007 at 17:31 +0100, quoth Michael Hoffman:
=Steven W. Orr wrote:
= On Saturday, Apr 21st 2007 at 19:18 +0100, quoth Michael Hoffman:
=
= =Chris Lasher wrote:
= = Should a Python module not intended to be executed have shebang/
= = hashbang (e.g., #!/usr/bin/env python
When I go to create an object I want to be able to decide whether the
object is valid or not in __init__, and if not, I want the constructor to
return something other than an object, (like maybe None). I seem to be
having problems. At the end of __init__ I say (something like)
if
I really tried. I give up.
I got this one last time (for which I'm very grateful).
import calendar
months = dict([(month,ii) for ii,month in enumerate(calendar.month_abbr)][1:])
Now I want something that's going to give me a string whose value is the
set of all of the first letters of months.
On Wednesday, Apr 18th 2007 at 12:16 -0700, quoth IamIan:
=I am using the suggested approach to make a years list:
=
=years = [199%s % x for x in range(0,10)]
=years += [200%s % x for x in range(0,10)]
=
=I haven't had any luck doing this in one line though. Is it possible?
I'm so green that I
I'm reading a logfile with a timestamp at the begging of each line, e.g.,
Mar 29 08:29:00
I want to call datetime.datetim() whose arg2 is a number between 1-12 so I
have to convert the month to an integer.
I wrote this, but I have a sneaky suspicion there's a better way to do it.
mons =
On Wednesday, Apr 4th 2007 at 18:04 -0700, quoth ts-dev:
=Is it possible to prevent modification of a python file once its been
=deployed? File permissions of the OS could be used..but that doesn't
=seem very secure.
=
=The root of my question is verifying the integrity of the application
=and
I have a tuple that I got from struct.unpack. Now I want to pass the data
from the returned tuple to struct.pack
fmt
'l 10l 11i h 4h c 47c 0l'
struct.pack(fmt, tup)
Traceback (most recent call last):
File stdin, line 1, in ?
struct.error: required argument is not an integer
What's the idiom
On Friday, Mar 23rd 2007 at 10:52 -0700, quoth belinda thom:
=I'm writing a function that polls the user for keyboard input,
=looping until it has determined that the user has entered a valid
=string of characters, in which case it returns that string so it can
=be processed up the call
I have a list ll of intergers. I want to see if each number in ll is
within the range of 0..maxnum
I can write it but I was wondering if there's a better way to do it?
TIA
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this.
In my class I have
class Error(Exception):
Base class for exceptions in this module.
pass
class TransitionError(Error):
Raised when an operation attempts a state transition that's not
allowed.
Attributes:
previous -- state at
On Wednesday, Feb 28th 2007 at 22:03 +0100, quoth Bruno Desthuilliers:
=Daniel Klein a ?crit :
= On Wed, 28 Feb 2007 13:48:54 -0500 (EST), Steven W. Orr
= [EMAIL PROTECTED] wrote:
=
=
=When I run it I get this:
=
=884 ./t_fsm.py
=Traceback (most recent call last):
= File ./t_fsm.py, line 3
I understand that two leading underscores in a class attribute make the
attribute private. But I often see things that are coded up with one
underscore. Unless I'm missing something, there's a idiom going on here.
Why do people sometimes use one leading underscore?
TIA
--
Time flies like the
On Friday, Feb 23rd 2007 at 11:12 -0500, quoth Steven W. Orr:
=I understand that two leading underscores in a class attribute make the
=attribute private. But I often see things that are coded up with one
=underscore. Unless I'm missing something, there's a idiom going on here.
=
=Why do people
This is all an intro learning experience for me, so please feel free to
explain why what I'm trying to do is not a good idea.
In the Cookbook, they have a recipe for how to create global constants.
-
class _const:
class ConstError(TypeError): pass
def
The short story is that someone left, but before he left he checked in a
.pyc and then both the directory was destroyed and the backups all got
shredded (don't ask*). Is there anything that can be extracted? I looked
on the web and the subject seems to get different answers, all old.
Any joy?
I have a table of integers and each time I look up a value from the table
I want to call a function using the table entry as an index into an array
whose values are the different functions. I haven't seen anything on how
to do this in python.
TIA
--
Time flies like the wind. Fruit flies
I'm new to python and I have a need to do this.
The Cookbook almost takes me there with:
def check_order(option, opt_str, value, parser):
if parser.values.b:
raise OptionValueError(can't use %s after -b % opt_str)
setattr(parser.values, option.dest, 1)
but warns that the it
I decided I could be more articulate. I hope this helps.
I'm writing a program that needs to process options. Due to the nature of
the program with its large number of commandline options, I would like to
write a callback to be set inside add_option.
Something like this:
parser.add_option(-b,
I saw this and tried to use it:
--8--- const.py-
class _const:
class ConstError(TypeError): pass
def __setattr__(self,name,value):
if self.__dict__.has_key(name):
raise self.ConstError, Can't rebind const(%s)%name
On Thursday, Feb 1st 2007 at 09:25 -0800, quoth Bart Ogryczak:
=On Feb 1, 5:52 pm, Steven W. Orr [EMAIL PROTECTED] wrote:
= I saw this and tried to use it:
=
= --8--- const.py-
=[...]
= sys.modules[__name__]=_const()
=
=__name__ == 'const', so you?re
On Thursday, Feb 1st 2007 at 10:36 -0800, quoth Paul Rubin:
=Steven W. Orr [EMAIL PROTECTED] writes:
= to cause a different instantiation a la
= foo = _const()
= The goal would be to create different instances of consts.
=
=The idea of putting it in sys.modules is so it's visible in all modules
On Thursday, Feb 1st 2007 at 21:45 +0100, quoth Bruno Desthuilliers:
=Steven W. Orr a écrit :
= I saw this and tried to use it:
=
= --8--- const.py-
= class _const:
= class ConstError(TypeError): pass
= def __setattr__(self,name,value
1 - 100 of 104 matches
Mail list logo