On Jul 15, 11:54 am, guandalino wrote:
> Hi, suppose I have python 2.6.4 installed from source and I want to
> upgrade to 2.6.5. Python standard library is automatically upgraded at
> 2.6.5 as well, while 3rd party pure Python and extension modules in
> site-packages don't. Is it safe to keep the
On Nov 25, 4:45 am, Jon Clements wrote:
> On Nov 25, 8:13 am, Steven D'Aprano
>
>
>
>
>
> wrote:
> > On Tue, 24 Nov 2009 22:42:28 -0800, John Nagle wrote:
> > > My dedicated hosting provider wants to switch me to a new server with
> > > CentOS 5.3, so I have to look at how much work is required.
On Nov 16, 3:33 pm, hong zhang wrote:
> List,
>
> I try to assign value to force_mcs sitting in a wildcard subdirectory
> /sys/kernel/debug/ieee80211/phy*, but python does not work for that such as:
>
> os.system("echo %i > /sys/kernel/debug/ieee80211/phy*/iwlagn/data/force_mcs"
> % mcs)
>
> Any
On Sep 25, 4:28 pm, Jeff McNeil wrote:
> On Sep 25, 4:13 pm, tinn...@isbd.co.uk wrote:
>
>
>
>
>
> > Jeff McNeil wrote:
> > > On Sep 25, 3:22 pm, tinn...@isbd.co.uk wrote:
> > > > I can't get the list_folders() method of the mailbox.Maildir class
On Sep 25, 4:13 pm, tinn...@isbd.co.uk wrote:
> Jeff McNeil wrote:
> > On Sep 25, 3:22 pm, tinn...@isbd.co.uk wrote:
> > > I can't get the list_folders() method of the mailbox.Maildir class to
> > > do anything remotely useful. It seems to do nothing at all.
On Sep 25, 3:22 pm, tinn...@isbd.co.uk wrote:
> I can't get the list_folders() method of the mailbox.Maildir class to
> do anything remotely useful. It seems to do nothing at all. I have a
> directory which contains a number of maildir malboxes:-
>
> chris$ ls -l /home/chris/Mail/apex
> t
On Sep 23, 8:29 pm, Tvrtko wrote:
> Hello,
>
> Is there any good alternative to twisted for network programming which
> doesn't involve asynchronous programming? I don't really like the
> asynchronous model because it is hard to incorporate all other
> blocking libraries that I have to use. And th
On Sep 23, 1:46 pm, Bakes wrote:
> I am using ftplib for a project, using a try/except loop.
>
> I would like to find out the exception, but I am a python newbie and
> do not know how.
>
> How, in a try/except loop would I find the ftplib exception?
For a bit on exception handling in general, ch
On Sep 23, 12:51 pm, volcano wrote:
> Hi, folks,
> I have a Python script that is invoked by a shell script. I uses
> sys.exit() with a parameter within python.
>
> The calling script is using this line to get the return code:
> exit_code = !$
>
> but it fails to get it. What's wrong here? (I am n
On Sep 23, 12:15 pm, Ashok wrote:
> Hi,
>
> I have sqlalchemy package installed on the server. However I want to
> run a script on the client that uses the sqlalchemy package. Hence I
> shared the directory containing the sqlalchemy unsing NFS. Then I
> added the NFS pathname to the sqlalchemy pac
On Sep 18, 3:05 pm, Sean DiZazzo wrote:
> On Sep 18, 11:54 am, kj wrote:
>
>
>
>
>
> > I've often come across the idea that good Python style deals with
> > potential errors using an EAFP ("easier to ask forgiveness than
> > permission") strategy rather than a LBYL ("look before you leap")
> > st
On Jun 23, 6:59 am, Francesco Bochicchio wrote:
> Hi all,
>
> is there any site that reports the current porting (to Python 3.x)
> status of the main non-standard extension modules (such as pygtk,
> pywin32, wxpython, ...) ?
> I think such information would be very useful for people - like me -
>
On Jun 23, 7:47 am, Klein Stéphane wrote:
> Hi,
>
> I wonder what Python Index server (like as pypi.python.org) do you use in
> your corporation for handle your private python eggs ?
>
> I found three solutions :
>
> *http://pypi.python.org/pypi/basketweaver/0.1.2-r6
> *http://pypi.python.org/pypi
On Jun 16, 12:51 pm, Hans Müller wrote:
> Richard,
>
> thanks a lot for your hint, that was completely new for me.
> Nagle's optimisation is definitely a good idea in most cases.
>
> By the way, do you have an idea how to access the underlying socket to modify
> the behavier
> via the setsockopt
On Jun 12, 10:05 am, Paul LaFollette
wrote:
> Kind people,
>
> Using Python 3.0 on a Gatesware machine (XP).
> I am building a class in which I want to constrain the types that can
> be stored in various instance variables. For instance, I want to be
> certain that self.loc contains an int. This
On Jun 11, 4:24 pm, Sydoruk Yaroslav wrote:
> Hello all,
>
> In a text file aword.txt, there is a string:
> "\xea\xe0\xea+\xef\xee\xe7\xe2\xee\xed\xe8\xf2\xfc".
>
> There is a first script:
> f = open ("aword.txt", "r")
> for line in f:
> print chardet.detect(line)
> b = line.decode('c
On Jun 10, 10:26 am, Sparky wrote:
> Hey! I am developing a small application that tests multiple websites
> and compares their "response time". Some of these sites do not respond
> to a ping and, for the measurement to be standardized, all sites must
> have the same action preformed upon them. An
On Jun 10, 10:19 am, Amit Dor-Shifer wrote:
> Hi all.
>
> I'd like to print-out a dictionary of objects. The printed values are
> references. How Do I print the actual objects.
>
> class MyClass:
> def __str__(self):
> return str(self.__dict__)
>
> if __name__ == '__main__':
> dict
On Jun 9, 2:22 pm, mrstevegross wrote:
> I'm trying to write a try/catch block to handle an "interrupted system
> call". However, I can't seem to locate information on the actual
> typename of the exception. Does anyone know what it would be? I want
> my code to look like this:
>
> try:
> ...
>
On Jun 8, 3:47 pm, Chris Rebert wrote:
> On Mon, Jun 8, 2009 at 11:43 AM, lczancanella wrote:
> > Hi,
>
> > in hashlib the hash methods have as parameters just string, i want to
> > know how can i digest an object to get a md5 hash of them.
>
> Hashes are only defined to operate on bytestrings. Si
On Jun 8, 11:33 am, Gary Herron wrote:
> Kless wrote:
> > Is there any way of to get the class name to avoid to have that write
> > it?
>
> > ---
> > class Foo:
> > super(Foo, self)
> > ---
>
> > * Using Py 2.6.2
>
> The question does not make sense:
> "to have WHAT
On May 28, 2:23 pm, Daniel wrote:
> Hello,
>
> Python 2.5.2
> WinXP
>
> I'm using CGIHTTPServer.py and want to return a response code of 400
> with a message in the event that the cgi script fails for some
> reason. I notice that
> run_cgi(self):
> executes this line of code,
> self.send_response
On May 27, 12:29 pm, powah wrote:
> I want to download all mib files from the web
> page:http://www.juniper.net/techpubs/software/junos/junos94/swconfig-net-m...
>
> All mib filenames are of this format:www.juniper.net/techpubs... .txt
>
> I write this program but has the following error.
> Pleas
On May 26, 2:12 pm, lone_eagle wrote:
> Hi all,
>
> On Linux, I do something like this
>
> $ program_to_execute < input_file
> ... get some output ...
>
> I have the content of the input_file as a string inside a python
> program and would like to pass this string to the external program
> from in
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
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 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: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 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 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 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
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 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
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 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 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 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 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 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 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 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 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 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 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, 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
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
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:
> >>
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
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
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 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
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 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 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 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 Sep 3, 2:40 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I looking for a file comparison utility in Python that works like
> 'diff' command in Unix and 'comp' in Windows.
> The present 'cmd' in filecmp module only presents output in the form
> of 1 or 0 i.e whether the 2 files differ or not?
>
> So,
then the one for
> >> simple, and the code I am using to do the work.
>
> >> line of html for the 2nd def of cheese:
>
> >> 2. >> valign="top">a definite mass of this substance, often in the shape of a
> >> wheel or cylinder.
>
> &
thing. But I want to know why you put "for tabs," also why you
> need the "'table', {'class': 'luna-Ent'}):" Like why the curly braces and
> whatnot?
>
> Jeff McNeil-2 wrote:
>
> > On Jun 27, 10:26 pm, Alexnb <[EMAIL PROTECTE
I stumbled across this a while back:
http://www.voidspace.org.uk/python/articles/urllib2.shtml.
It covers quite a bit. The urllib2 module is pretty straightforward
once you've used it a few times. Some of the class naming and whatnot
takes a bit of getting used to (I found that to be the most con
On Jun 24, 12:13 am, Alex Bryan <[EMAIL PROTECTED]> wrote:
> Okay, so what I want to do is connect to dictionary.com and send the
> website a word, and later receive the definition. But for now, I want
> to focus on sending the word. A good guy from this mailing list said I
> should look into the c
On Jun 18, 10:29 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> brad wrote:
> > Just wondering if anyone has ever solved this efficiently... not looking
> > for specific solutions tho... just ideas.
>
> > I have one thousand words and one thousand files. I need to read the
> > files to see if
On Jun 14, 5:38 pm, srinivasan srinivas <[EMAIL PROTECTED]>
wrote:
> Hi,
> Is there any way(method) to find whether the socket got closed or not??
> Thanks,
> Srini
>
> Best Jokes, Best Friends, Best Food and more. Go
> tohttp://in.promos.yahoo.com/groups/bestofyahoo/
That's slightly diffi
The only time I've ever pulled a HEAD request I've used the httplib
module directly. Ought to be able to do it like so:
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import h
It means your client received a TCP segment with the reset bit sent.
The 'peer' will toss one your way if it determines that a connection
is no longer valid or if it receives a bad sequence number. If I had
to hazard a guess, I'd say it's probably a network device on the
server side trying to stop
Have a look at os.listdir and os.stat. I've never worked with 1.5, so
I don't know what will work with it and what won't,. but I'd imagine
the following ought to be fine, though.
stat_list = []
for dirent in os.listdir('your_directory'):
stat_list.append(os.stat(dirent))
Jeff
On Wed, Jun
The original urllib module will do it too, if you pass a data keyword
argument to urllib.urlopen:
u = urllib.urlopen('http://www.domain.com/cgi-bin/cgi.py',
data=urllib.urlencode({'name': 'pythonguy'}))
On Fri, Jun 6, 2008 at 6:04 PM, kj <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]> kj <[E
r your reply. I would like to like the absolute path of a
> directory. I thought that os.listdir just returns the nam itself in a data
> list.
>
> I noticed that none was being return in my example. Do you think that I have
> the arguments misplaced?
>
> Thanks,
> Paul
What exactly are you trying to accomplish? If you're just looking for
the contents of a directory, it would be much easier to simply call
os.listdir(dirinput) as that will return a list of strings that
represent the entries in dirinput.
As it stands, 'os.path.walk' will return None in your example
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
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
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
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
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,
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
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,
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
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
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
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
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
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/
>>> 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
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
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
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
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
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
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
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
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
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
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
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
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,
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
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 _
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
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
.
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&
1 - 100 of 137 matches
Mail list logo