I've got a rather large log processing job here that has the same
requirement. I process and sort Apache logs from an 8-way cluster. I
sort and calculate statistics in 15-minute batch jobs. Only one copy
should run at once.
I open a file and lock it via something like this:
import fcntl
fhandle
Note that in real life, the script exits cleanly if another copy is running...
On 6/18/07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
> I've got a rather large log processing job here that has the same
> requirement. I process and sort Apache logs from an 8-way cluster. I
>
If you just want to send mail, you should be able to use the standard
smtplib module (http://docs.python.org/lib/module-smtplib.html). If
your recipients are on the Internet, you would need to handle MX
resolution yourself.
I know you said you want to avoid a relay server, but it's probably
the be
Inline...
On 7/5/07, _spitFIRE <[EMAIL PROTECTED]> wrote:
> On Jul 5, 1:34 pm, "Jeff McNeil" <[EMAIL PROTECTED]> wrote:
> > If you just want to send mail, you should be able to use the standard
> > smtplib module (http://docs.python.org/lib/module-smtplib.htm
The raw_input built-in returns a string. The '[0]' subscript returns
the first character in the user supplied response as strings support
indexing.
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> mystr = "asdf"
>>>
What's unexpected about it? Child processes inherit all of the open file
descriptors of their parent. A socket is simply another open file
descriptor. When your parent process exits, your child still holds a valid,
open file descriptor.
import sys
import socket
import os
import time
s = socket
The open file descriptor/socket shouldn't "move" between processes when you
kill the parent. When os.system forks, anything you've got open in the
parent will transfer to the child. Both descriptors reference the same open
port. Running the same 'ss' and 'cc' code you've supplied behaves like t
Filename is a unicode string. See
http://www.diveintopython.org/xml_processing/unicode.html or
http://docs.python.org/tut/node5.html#SECTION00513.
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credit
Yup, I actually had log files in mind, too. I process Apache logs from an
8-way cluster every 15 minutes. There are 32,000 sites on said cluster;
that's a lot of log data!
I didn't actually think anyone would go *try* to
open("war_and_peace.txt").readlines().. I just meant it as a generalization
Depending on the size of your file, you can just use file.readlines.
Note that file.readlines is going to read the entire file into memory,
so don't use it on your plain-text version of War and Peace.
>>> f = open("/etc/passwd")
>>> lines = f.readlines()
>>> lines[5]
'# lookupd DirectoryServices
That's not going to hold true for generator functions or iterators
that are implemented on sequences without '__iter__.' You might also
want to check for __getitem__. I'm not sure if there's a way to tell
if a function is a generator without actually calling it.
-Jeff
On 7/25/07, [EMAIL PROTEC
On 7/25/07, Steve Holden <[EMAIL PROTECTED]> wrote:
> Jeff McNeil wrote:
> > Unfortunately, I also find that PHP programmers are usually more
> > plentiful than their Python counterparts. When thinking of staffing
> > an organization, it's common to target a skill
Unfortunately, I also find that PHP programmers are usually more
plentiful than their Python counterparts. When thinking of staffing
an organization, it's common to target a skill set that's cheaper to
employ and easier to replace down the road if need be.
Also, larger hosting shops are hesitant
You could use 'isinstance' to determine whether or not your object is
an instance of a particular class.
>>> isinstance({}, dict)
True
>>> isinstance("", basestring)
True
>>>
Note the use of 'basestring', which will catch unicode as well.
-Jeff
On 8/13/07, Astan Chee <[EMAIL PROTECTED]> wrote:
Now, I'm not sure if this has been covered in great detail anywhere,
but I'd love to see something touching on interoperability with .Net
web services.
I've had a lot of success getting Python moved into our organization,
but this is where it gets difficult. While I'm product focused, our
busines
You shouldn't even need the call to super in that method, a simple
'len(self)' ought to be sufficient. Note that using the list object's
append method is going to be much more efficient than handling it yourself
anyways.
There are a few problems in your call to super. First, it's a callable - it
The 'errno' number (at least on the *nix platforms I use) corresponds
to the 'errno' number set on system call failure. POSIX.1 specifies
a set of standard errors. AFAIK, the 'errno' module should contain
the mappings for your system.
On 9/11/07, Tim Couper <[EMAIL PROTECTED]> wrote:
> As you k
Have a look at the XMLRPC specification @ http://www.xmlrpc.com/spec.
There is no representation of NULL/None, thus server refuses to
Marshall the 'None' value. Update your server methods to return a
value other than None and that message will go away.
The other option is to set 'allow_none' to T
Duh... you can pass allow_none=True to SimpleXMLRPCServer()
On 9/12/07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
> Have a look at the XMLRPC specification @ http://www.xmlrpc.com/spec.
> There is no representation of NULL/None, thus server refuses to
> Marshall the 'None&
What about this?
http://www.dalkescientific.com/Python/PyRSS2Gen.html
On 3/4/07, Florian Lindner <[EMAIL PROTECTED]> wrote:
> Hello,
> I'm looking for a python library that creates a RSS and/or Atom feed. E.g. I
> give a list like that:
> [
> [title1, short desc1, author1],
> [title2, short
If you're willing to spend some serious dollars, there are also hardware
products out there that do this type of stuff. We run a few F5 6800 E
systems. I've come to love their iRules feature - a TCL-based event driven
scripting system for network traffic. RAM cache, SSL offload, and so on.
They'l
I looked at http://www.python.org/pypi/httpdrun not so long ago, it might be
able to do what you want. I think it was a bit hard to read. Remember that
with Apache you (may) also need to worry about configuration merges and
whatnot (, , .htaccess, and so on...).
What specifically do you want to
If a .egg file is in your sys.path, it would be nice to simply use 'python
-m' in my opinion. As far as I know, you can't '-m' a module that's been
imported from a zip file?
On 3/9/07, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
Alessandro de Manzano wrote:
> Hello,
>
> I'ld ask you all abou
Sure, you can use "if key in dict" to test for membership:
Python 2.3.5 (#1, Jan 13 2006, 20:13:11)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exampledict = {"a" : 1, "b" : 2}
>>> "a" in exampledict
True
>>> "
But even if the server was loading Python on each hit, which it will for
CGI, it shouldn't take "a count to 13", especially on localhost. That to me
is an indication of a further problem. Does it take that long to load with
each hit, or just the first following a server restart? What do log
time
Bit of a newbie on this list, but here goes...
Web Services.
The company I'm working for has been pretty big into the WS-* specifications
and the Microsoft .Net WCF components for our business systems. I'm one of
three Unix guys that code the products while we've a larger team of Windows
develop
You could also use sys.excepthook if you're trying to handle uncaught
exceptions.
On 27 Mar 2007 11:45:54 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
On Mar 27, 9:15 pm, [EMAIL PROTECTED] wrote:
> Technically speaking, you can catch all errors as follows:
>
> try:
># do something
I've built a bit of an account provisioning/support framework here based on
SimpleXMLRPCServer (which is the one bundled w/ Python). Take a look at
http://docs.python.org/lib/module-SimpleXMLRPCServer.html as it also
includes a bit of a code example. It seems to work fine for my needs in
that I
I do it this way and it's always worked great for me.
SimpleXMLRPCServer is based on SocketServer, so you can use the ForkingMixIn
or ThreadingMixIn classe to create something to handle requests in
parallel.
from SocketServer import ThreadingMixIn
import SimpleXMLRPCServer
class ThreadedXMLRPCS
This is off of memory so I apologize if I don't get all of the details right.
The base SimpleXMLRPCServer uses TCPServer as it's server component
and SimpleXMLXMLRPCRequestHandler as it's handler. The handler is a
subclass of BaseHTTPRequestHandler, which itself doesn't handle any
multithreading.
of your handler which is responsible for the RPC dispatching.
-Jeff
On 3/29/07, Laszlo Nagy <[EMAIL PROTECTED]> wrote:
Jeff McNeil wrote:
> This is off of memory so I apologize if I don't get all of the details
right.
>
> The base SimpleXMLRPCServer uses TCPServer as it's serve
Can you pull the same information from /proc/stat as opposed to using
a pipe to top? The first line(s) should contain (at least):
cpu usermode, lowprio, system, idle, hz.
The 2.6 kernel adds iowait, irq, and soft irq. It seems that this
might be a better solution than executing that additional c
;49m\x1b(B\x1b[m',
'0.0%', '\x1b(B\x1b[m\x1b[39;49mhi,\x1b(B\x1b[m\x1b[39;49m\x1b(B\x1b[m',
' 0.0%', '\x1b(B\x1b[m\x1b[39;49msi,\x1b(B\x1b[m\x1b[39;49m\x1b(B\x1b[m',
'0\x1b(B\x1b[m\x1b[39;49m\x1b[K']
>>>
Jeff
Are you sure that splt onl
I apologize for not giving you a Python specific answer, but for the
XMLRPC services I've deployed, I front them with Apache and proxy back
to localhost:8080.
I do all of the encryption and authentication from within the Apache
proper and rely on mod_proxy to forward validated requests on. I've
s
Zip do what you want?
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> l1 = [1,2,3,4,5]
>>> l2 = ['a', 'b', 'c', 'd', 'e']
>>> for i,j in zip(l1, l2):
... print i,j
.
Instead of register_function, use register_instance and provide a
_dispatch method in that instance that handles your exception logging.
Pseudo:
class MyCalls(object):
def _dispatch(self, method, args):
try:
self.getattr(self, method)(*args)
except:
han
getattr, not self.getattr.
On 9/27/07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
> Instead of register_function, use register_instance and provide a
> _dispatch method in that instance that handles your exception logging.
>
> Pseudo:
>
> class MyCalls(object):
> def _
erver = SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(MyCalls())
server.serve_forever()
-Jeff
On 9/27
On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Sep 27, 3:55 pm, "Jeff McNeil" <[EMAIL PROTECTED]> wrote:
> > Instead of register
Cool.. glad it works. Just be careful not to expose methods you may not
want to; use decorators, attributes, or perhaps a custom method naming
scheme to flag methods as exposed if you do it this way.
On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> On Sep 27, 5:08 pm,
I don't know how "clean" it is, but there are a few situations in which I do
something like this:
getattr(obj, "method", default_method)(*original_method_args)
The default_method is a base implementation or a simple error handler. For
example, when a client hits one of our XMLRPC servers and pass
Your web server needs to be told to execute Python scripts. You can
handle it a few different ways, depending on your environment.
1. Place your .py script inside of a ScriptAlias'd /cgi-bin/ directory
which will force it to be executed.
2. Rename your .py script to .cgi and add an 'AddHandler c
Or perhaps...
ord ("a")
97
chr (97)
'a'
On 2/22/07, hg <[EMAIL PROTECTED]> wrote:
John wrote:
> Is there any built in function that converts ASCII to integer or vice
> versa in Python?
>
> Thanks!
>>> int('10')
10
>>> str(10)
'10'
>>>
--
http://mail.python.org/mailman/listinfo/pytho
Can you use mod_rewrite and include a proxy back to a different port?
Assuming mod_proxy has been enabled, run your app server on port 8080
and then do something like this in a .htaccess file:
RewriteEngine on
RewriteRule ^/(.*)$ http://localhost:8080/$1 [P]
This of course assumes you want to
Isn't this something that os.walk would be good for?
import os
for t in os.walk(base_dir):
for f in t[2]:
print "/".join((t[0], f))
Jeff
On Feb 26, 2007, at 4:42 PM, Sick Monkey wrote:
I had a do something similar. I had to get a program to traverse
through a directory and delet
I've got a question regarding the implementation of a caching system that
I'm porting over from C.
I have multiple processes across an array of systems that must retrieve data
from a central database at a fairly high rate. The current system uses
shared memory and supports expiry after a configu
The __file__ attribute is present when you run a script from a file.
If you run from the interactive interpreter, it will raise a
NameError. Likewise, I believe that in earlier versions of Python
(2.1? Pre 2.2?) it was only set within imported modules. I've used the
'os.path.realpath(os.pat
d()
'/Users/jeff'
>>> os.path.realpath(os.path.pardir)
'/Users'
>>>
The __file__ construct is fine from within a module and is probably
more inline with what the OP was looking for anyways.
On Nov 3, 2007, at 7:18 AM, Bjoern Schliessmann wrote:
> Jeff
See http://www.python.org/doc/faq/general/#how-are-dictionaries-implemented
. In short, keys() and items() return an arbitrary ordering. I think
that http://pypi.python.org/pypi/Ordered%20Dictionary/ will do what
you want if key ordering is a necessity.
Jeff
On Nov 4, 2007, at 8:19 AM, azra
You could also just store the files outside of the document root if
you don't want to worry about a database. Then, as Jeff said, just
print the proper Content-Type header and print the file out.
On Nov 5, 2007, at 8:26 AM, Jeff wrote:
> Store the file in a database. When an authorized user
http://www.linuxhardware.org/features/01/10/09/1514233.shtml
AMD has historically used model numbers that are slightly higher than
the actual clock speed. I have a 2300 that runs at 1.9.
-Jeff
On Nov 6, 2007, at 3:27 PM, Chris Mellon wrote:
> On Nov 6, 2007 2:12 PM, <[EMAIL PROTECTED]> wro
Think about the context in which your function definition is executed and
how the 'self' parameter is implemented. Your definitions (and decorator
calls) are executed in the context of 'class A.'
That said, the following would work:
>>> class A:
def pre(fn):
def new_func(*args,**kwa
I've purchased a couple of books on Python and I keep going back to Python
in a Nutshell. It's about the only printed text I keep on my desk all the
time. It has a nice introduction to the language and includes the
specification, too.
If you're familiar with programming,
http://diveintopython.org
Check out the 'pydoc' script; it ships with Python. I've got my CI system
rigged up to run pydoc on each commit and automatically generate HTML
documentation. The tool actually imports a 'pydoc.py' module, which you may
be able to use directly if you need more control over the process.
On top o
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = '[1,2,3,4,5]'
>>> eval (a, {}, {})
[1, 2, 3, 4, 5]
>>>
But note that 'eval' is generally not such a good idea unless
>>> a = '[1,2,3,4]'
>>> b = 'Tropical Islands'
>>> eval(a)
[1, 2, 3, 4]
>>> eval(b)
Traceback (most recent call last):
File "", line 1, in ?
File "", line 1
Tropical Islands
^
SyntaxError: unexpected EOF while parsing
>>>
For eval to work, your string has to contain a va
I'd suggest you take some time and go through some of the online Python
documentation in detail. The tutorials and whatnot posted on the website are
quite good (available at http://docs.python.org/doc/).
You can probably find answers to a lot of the questions you might have in
there.
-Jeff
On 12/
Which storage engine are you using? My assumption is that you're using
standard MyISAM tables, which will not support what you're trying to do. If
you run the code below against MySQL tables created using InnoDB, it should
work as expected.
See http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-tra
Do you have any non-standard network hardware along the route? Perhaps a
transparent proxy like a load balancer or a firewall of sorts? I've seen
this type of thing happen before with load balancer gear. In my situation,
I had a load balancer that kept a state table. If the load balancer didn't
Sure is.. check out the glob module:
http://www.python.org/doc/current/lib/module-glob.html (Official)
http://blog.doughellmann.com/2007/07/pymotw-glob.html (PyMOTW)
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "cre
Perhaps you'd be better off using a standard property? Within your Person
class, you can define a property 'name' to handle what you're trying to do:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "copyright", "credits" or "license()" for
r__(self, attr, value):
print 'setting %s to %s' % (attr, value)
if attr == 'fakeme':
self.__hidden = value
>>> e = Example()
setting _Example__hidden to 1
>>> type (e._Example__hidden)
getting _Example__hidden
Hope that helps,
Jeff
On 12/31/07, Jeff McNeil
Have a look at the copy module if you have a somewhat "complex" object graph
to duplicate. Remember, you're essentially just creating another reference
to a singular list object with simple assignment (a = b).
>>> a = [1,2,3,4, ['5a', '5b', '5c', ['6a', '6b','6c']], 7,8]
>>> b = a
>>> a
[1, 2, 3,
Check to see what the value of '__name__' is, for example:
if __name__ == '__main__':
execute_interactive_code()
else:
I_am_just_a_lowly_module()
The value of __name__ will correspond to the name of your module:
$ cat a.py
print __name__
$
$ python
Python 2.5.1 (r251:54863, Oct 30 2007, 1
Hi list,
Hopefully a quick metaclass question. In the following example, MyMeta is a
metaclass that does not inherit directly from type:
#!/usr/bin/python
class MyMeta(object):
def __new__(cls, name, bases, vars):
print "MyMeta.__new__ called for %s" % name
return type(name,
ked at the source to begin with.
On 2/21/08, Jeff McNeil <[EMAIL PROTECTED]> wrote:
>
> Hi list,
>
> Hopefully a quick metaclass question. In the following example, MyMeta is
> a metaclass that does not inherit directly from type:
>
> #!/usr/bin/python
>
> class MyM
Cheetah (http://www.cheetahtemplate.org/) and Mako
(http://www.makotemplates.org/) come to mind. Isn't there some long
running joke about new Python programmers creating their own template
language or something, too? =)
I know you said you don't want a web framework, but I've always been a
fan of
This is somewhere that I would personally use a metaclass. That way,
if you define more subclasses of Message, you're not limited to doing
so in that single module.
Someone correct me if this is goofy, I don't do much metaclass programming.
Perhaps something like:
#!/usr/bin/python
class MetaMe
I don't know of any Python specific stuff to do this, but have you
looked at Asterisk? I know it's quite configurable and allows you to
setup dial plans and route extensions and whatnot.
http://www.asterisk.org/
That's probably a better fit.
On 3/20/08, W. Watson <[EMAIL PROTECTED]> wrote:
> How
On Jan 12, 9:36 am, mk wrote:
> Hello everyone,
>
> I googled and googled and can't seem to find the definitive answer: how
> to *properly* deinstall egg? Just delete the folder and/or .py and .pyc
> files from Lib/site-packages? Would that break anything in Python
> installation or not?
>
> Regar
On Jan 12, 12:40 pm, "Mike MacHenry" wrote:
> I am having a difficult time understanding why my very simple
> CGI-XMLRPC test isn't working. I created a server to export two
> functions, the built-in function "pow" and my own identity function
> "i". I run a script to call both of them and the "po
untu by any chance? If you which version?
>
> Does anyone know of any environment settings I could look into on
> Apache or Python?
>
> -mike
>
> On Mon, Jan 12, 2009 at 9:02 PM, Jeff McNeil wrote:
> > On Jan 12, 12:40 pm, "Mike MacHenry" wrote:
> >>
Hi all,
In an effort to get (much) better at writing Python code, I've been
trying to follow and document what the interpreter does from main in
Modules/python.c up through the execution of byte code. Mostly for my
own consumption and benefit, but I may blog it if it turns out half
way decent.
An
On Jan 17, 10:50 am, "Martin v. Löwis" wrote:
> > So, the documentation states that ob_type is a pointer to the type's
> > type, or metatype. Rather, this is a pointer to the new type's
> > metaclass?
>
> That's actually the same. *Every* ob_type field points to the object's
> type, e.g. for strin
On Jan 17, 11:09 am, Jeff McNeil wrote:
> On Jan 17, 10:50 am, "Martin v. Löwis" wrote:
>
>
>
> > > So, the documentation states that ob_type is a pointer to the type's
> > > type, or metatype. Rather, this is a pointer to the new type's
>
On Jan 17, 4:11 pm, twistedduck9
wrote:
> My hosting provider (Streamline) have said that there is no firewall
> (it's a dedicated server). Either way the code I'm using is:
>
> Listening socket:
> import socket
> mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> mysock.bind (('79.99.43
On Jan 18, 5:40 am, Carl Banks wrote:
> On Jan 17, 8:12 am, Jeff McNeil wrote:
>
>
>
> > On Jan 17, 11:09 am, Jeff McNeil wrote:
>
> > > On Jan 17, 10:50 am, "Martin v. Löwis" wrote:
>
> > > > > So, the documentation states that ob_t
On Jan 18, 6:35 pm, Simon Brunning wrote:
> 2009/1/17 Michele Simionato :
>
> > "Expert Python Programming" by Tarek Ziadé is quite good and I wrote
> > a review for it:
>
> >http://www.artima.com/weblogs/viewpost.jsp?thread=240415
>
> +1 for this. I'm 3/4 of the way through it, it's pretty good.
On Jan 20, 9:19 am, srinivasan srinivas
wrote:
> Do parent process will have different file descriptor in it for each
> subprocesses or paprent uses a single file descriptor for all?
> I really want to know creation of each subprocess will occupy an entry in
> parents'file descriptor table. B'co
On Jan 21, 1:59 pm, bilgin arslan wrote:
> Hello,
> I am trying to write a list of words to into a text file as two
> colons: word (tab) len(word)
> such as
>
> standart8
>
> I have no trouble writing the words but I couldn't write integers. I
> always get strange characters, such as:
>
> GUN
On Jan 21, 4:53 pm, culpritNr1 wrote:
> Hello All,
>
> Say I have a list like this:
>
> a = [0 , 1, 3.14, 20, 8, 8, 3.14]
>
> Is there a simple python way to count the number of 3.14's in the list in
> one statement?
>
> In R I do like this
>
> a = c(0 , 1, 3.14, 20, 8, 8, 3.14)
>
> length( a[ a[]
On Jan 22, 9:49 am, sturlamolden wrote:
> frame = sys._getframe().f_back is the previous stack frame. Is there
> any way to execute (with exec or eval) frame.f_code beginning from
> frame.f_lasti or frame.f_lineno?
>
> I am trying to spawn a thread that is initialized with the code and
> state of
On Jan 26, 10:22 am, redbaron wrote:
> I've one big (6.9 Gb) .gz file with text inside it.
> zcat bigfile.gz > /dev/null does the job in 4 minutes 50 seconds
>
> python code have been doing the same job for 25 minutes and still
> doesn't finish =( the code is simpliest I could ever imagine:
>
> de
On Jan 26, 10:51 am, Jeff McNeil wrote:
> On Jan 26, 10:22 am, redbaron wrote:
>
> > I've one big (6.9 Gb) .gz file with text inside it.
> > zcat bigfile.gz > /dev/null does the job in 4 minutes 50 seconds
>
> > python code have been doing the same job for 25 m
On Jan 27, 7:59 pm, Muddy Coder wrote:
> Hi Folks,
>
> Module os provides a means of running shell commands, such as:
>
> import os
> os.system('dir .')
>
> will execute command dir
>
> I think a hyperlink should also be executed. I tried:
>
> os.system('http://somedomain.com/foo.cgi?name=foo&pass
On Jan 30, 7:33 am, Chris Rebert wrote:
> On Fri, Jan 30, 2009 at 4:27 AM, Hongyi Zhao wrote:
> > Hi all,
>
> > Suppose I've the entries like the following in my file:
>
> > --
> > 116.52.155.237:80
> > ip-72-55-191-6.static.privatedns.com:3128
> > 222.124.135.40:80
> > 217.151.23
You'll see the same behavior if you attempt to add an attribute to an
instance of object as well.
>>> object().t = 5
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'object' object has no attribute 't'
>>>
You'll have to build your own iterator or wrap the generator obje
On Oct 24, 11:58 am, "John [H2O]" <[EMAIL PROTECTED]> wrote:
> Just a quick question.. what do I need to do so that my print statements are
> caught by nohup??
>
> Yes, I should probably be 'logging'... but hey..
>
> Thanks!
> --
> View this message in
> context:http://www.nabble.com/print-stateme
On Oct 24, 11:58 am, "John [H2O]" <[EMAIL PROTECTED]> wrote:
> Just a quick question.. what do I need to do so that my print statements are
> caught by nohup??
>
> Yes, I should probably be 'logging'... but hey..
>
> Thanks!
> --
> View this message in
> context:http://www.nabble.com/print-stateme
On Nov 11, 1:23 pm, "Chuckk Hubbard" <[EMAIL PROTECTED]>
wrote:
> If I run 'python -i subprocessclient.py' I expect to see the nice
> level of it go up 2, and the nice level of the subprocess go up 1.
> But all I see is the nice level of the client change. What am I doing
> wrong?
>
> subprocessse
On Nov 12, 8:19 am, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote:
> On Wed, 12 Nov 2008 13:09:21 +
>
> Tom Wright <[EMAIL PROTECTED]> wrote:
> > devi thapa wrote:
> > > I am executing a python script in a shell script. The python script
> > > actually returns a value.
> > > So, can I get the r
On Nov 12, 4:57 pm, Jeffrey Barish <[EMAIL PROTECTED]> wrote:
> As per Stevens/Rago, "file and record locking provides a convenient
> mutual-exclusion mechanism". They note the convention of putting the lock
> file in /var/run in a file called .pid, where is the name of
> the daemon and content i
On Nov 13, 4:12 pm, Aaron Brady <[EMAIL PROTECTED]> wrote:
> On Nov 13, 6:15 am, "devi thapa" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am running one service in the python script eg like
> > "service httpd status".
> > If I execute this command in normal shell kernel, the return code
You can pull it out of f.func_code.co_varnames, but I don't believe
that's a very good approach. I tend to veer away from code objects
myself.
If you know how many arguments are passed into the wrapped function
when it's defined, you can write a function that returns your
decorator. As an example.
On May 14, 5:44 pm, kk wrote:
> Btw my main problem is that when I assign the function to 'b' variable
> I only get the last key from the dictionary. Sorry about that I forgot
> to mention the main issue.
You're creating a new dictionary with each iteration of your loop, use
d[k] = v syntax inst
On May 11, 5:45 pm, Chris Rebert wrote:
> On Mon, May 11, 2009 at 1:44 PM, Sam Tregar wrote:
> > Greetings. I'm working on learning Python and I'm looking for good books to
> > read. I'm almost done with Dive into Python and I liked it a lot. I found
> > Programming Python a little dry the last
On May 15, 10:50 am, mrstevegross wrote:
> Remind me: is it possible to craft an import statement like this:
> import foo.bar
>
> If so, what's going on here exactly? Is Python looking for a module
> called 'bar', in a directory called 'foo', in a search path somewhere?
> Or am I totally misunde
On May 18, 11:22 am, timh wrote:
> Hi
>
> I am trying to understand something about how the 'in' operator (as in
> the following expression)
>
> if 'aa' in x:
> do_something()
>
> When trying to implement in support on a class it appears that if
> __contains__ doesn't exist
> in falls back to c
On May 18, 11:31 am, Tim Hoffman wrote:
> Hi Marco
>
> Thats definately what I think is happening.
>
> I tried the following
>
> >>> class yy(object):
>
> ... def __getitem__(self,name):
> ... raise KeyError(name)
> ... def __contains__(self,name):
> ... raise KeyError(name)
> ...>>> a
On May 18, 11:45 pm, Wincent wrote:
> If you want to write to a csv file, the other option is savetxt in
> NumPy module.
>
> Best
>
> On May 19, 7:29 am, John Machin wrote:
>
> > On May 19, 5:12 am, Terry Reedy wrote:
>
> > > Kalyan Chakravarthy wrote:
> > > > Hi All,
> > > > I have
On May 19, 2:54 pm, Stefano Costa wrote:
> Hi,
> my name is Stefano Costa, I am an archaeologist and I am developing
> GNUCal, a radiocarbon calibration program released under the GNU GPL.
> [1][2]
>
> Currently the program consists of a small "library", largely based on
> Matplotlib and Numpy, an
1 - 100 of 137 matches
Mail list logo