> I'm trying to create a script to do the following. I have a directory
> containing hundreds of text files. I need to create a single file with
> the contents of all the files in the directory. Within that file,
> though, I need to create marks that indicate the division between the
> contents of
> This is a more precise question, the above was after trying different methods,
> and it got a little confusing.
>
> Why in the below does using in line 12:self.objectsvars =
> 'menuitemhere','menuitemhere','menuitemhere','menuitemhere', not work,
> but placing 'menuitemhere','menuitemhere','menu
> Again, thanks a lot. Too bad you and Kushal don't live close. I would
> like to invite you to a beer or a coffe or something.
Thanks for the offer. Some time ever in the far, far future perhaps ;-).
>
>> So close ;-).
>> What you're missing is the next write statement:
>> f.write(data)
>>
>>
> I've been web programming for 15 years now. 8 of it using python.
>
> Lately I have been 'studying' PHP via the CodeIgnitor Framework.
>
> Since python remains my first choice, but since I am also
> impressed with the concept of CodeIgnitor, I would welcome
> recommendations on a python MVC fra
>> Django can run be run through mod_wsgi (or mod_python if you
>> really want). And other web servers than Apache will also work.
>
>> Don't know what you mean with "shared server", but if you mean
>> multiple accounts running their web apps through one Apache
>> server, that can work (provided
> OK, so I have a question for you math people: I am trying to solve a
> quartic equation (Ax^4 + Bx^3 + Cx^2 + Dx + E) using Ferrari's Method, which
> I found on Wikipedia at this location.
>
> I'm using Python 3.1.2 (on Mac OS X 10.6, in case that matters).
>
> First, since
>
> ---
> One question for Steve (or for whoever wants to answer): you say you
> have a terminal with two tabs (neat, I wonder whether I can get tabs
> as well for my terminal in OS X)
In Terminal.app, just type command-T and you get a new tab. Switch with the
mouse or command-shift-[ & com
>> You're not really showing what exactly you type. That's often more clearer
>> than describing what you do, although in this case we can get a pretty good
>> picture anyway.
>
> OK, here's what I do:
>
import test
>
> I know the shell is importing the file because I can see the followin
Hi Ram,
> Either of the following should do it:
>
> print string.join([menu_specials[val] for val in
> menu_specials], ', ')
> or
> print string.join([menu_specials[val] for val in
> menu_specials.keys()],
> ', ')
> or
> print string.join([menu_specials[val] for val in ["breakfa
Hi Tim,
> Heres my test script:
>
> 1 #!/usr/bin/env python
> 2 # -*- coding: utf-8 -*-
> 3 from easygui import easygui
> 4 import sys
> 5 #raw = sys.argv[1]
> 6 raw = easygui.enterbox(message="Enter something.", title="",
> argDefaultText="20° 12' 33''")
> 7 #unicode = unicode(raw)
> 8
>> raw = unicode("125° 15' 5.55''", 'utf-8')
>
> Again, I think this can be simplified to
>raw = u"125° 15' 5.55''"
It does, but it's getting confusing when I compare the following:
>>> raw = u"125° 15' 5.55''"
125° 15' 5.55''
>>> print u"125° 15' 5.55''"
UnicodeEncodeError: 'ascii' codec
raw = unicode("125° 15' 5.55''", 'utf-8')
>>> Again, I think this can be simplified to
>>>raw = u"125° 15' 5.55''"
>> It does, but it's getting confusing when I compare the following:
>> >>> raw = u"125° 15' 5.55''"
>> 125° 15' 5.55''
>
> Where does that output come from?
sorry, my bad:
>> Here is the actual snippet of code
>>
>>
>> calc_depth =8.1 # which is actually d
>> unblockedFS = 13.4 # which is the indexed fs
>>
>> for line in file('21Ex6MV_tmr.dat'):
>> d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10, fs11, fs12,
>> fs13, fs14, fs15, fs16, fs17,
> i was thinking of doing something like
>
>objSprites = pygame.sprite.OrderedUpdates((var1,
> var2, var3).sort)
>
> but i don't think thats gunna work
It won't indeed, because of 3 things:
1. you're trying to sort a tuple. Tuples don't have a sort() method,
use a list instead
2. sort doesn'
> If i input the following in python:
>var1 = 7
>var2 = 9
>var3 = 5
>args = [var1, var2, var3]
>args.sort()
>
> then if if type:
>
>args
>
> the output is
>
>[5, 7, 9]
>
> but i want the output to be
>
>[var3, var1, var2]
>
> is there a function that will output the
> Thanks, i think a dictionary may be the way to go
>
>> in the end, you're going to use the
>> actual values anyway,
>> not their names, right?
>
> yeah, you're right, the way i was thinking about doing
> it probably won't work. The way I am doing it now is
> actually using attibutes of the var's
Hi Tom,
> I'm trying to write a program to test someones typing speed and show
> them their mistakes. However I'm getting weird results when looking
> for the differences in longer (than 100 chars) strings:
>
> import difflib
>
> # a tape measure string (just makes it easier to locate a given i
> Thank-you! It is important for us to avoid potential code
> conflicts and so we'll standardize on the import
> syntax.
>
> On a related note:
> We are using both NumPy and SciPy. Consider the example y = Ax
> where A is a sparse matrix. If A is qualified as a scipy object
> then do y
> How can I add information to an object to explain what it expects as
> it's attributes? For instance I may have an object that creates a CAD
> file based on a set of default values which are set by the __init__
> but can be altered before it runs. for example;
Why don't you specify a doc-string
ontained in the string object. If I wanted a quick
> explanation of one function I could run;
>
>>>> print ' '.strip.__doc__
> S.strip([chars]) -> string or unicode
>
> Return a copy of the string S with leading and trailing
> whitespace removed.
>
On 9 Nov 2007, at 14:48 , Chernev Chernev wrote:
> I'm debugging a script and want to check the type of an object.
>
> So in the script I write:
> print type([object]
>
> This bombs, and I get
> "TypeError: 'str' object is not callable'
>
> I've also tried
> x = type([object])
> print x
>
> Same
> I am trying to build a menu for the following script to make it
> more "user friendly". Nothing fancy, just a simple add data and
> look up the entered results.
>
> The problem is that when I run my modified version with this
> snippet (please see attachment for original and my modified ve
> I'm assuming you don't want the last changed date you see on the file
> on your PC, but the creation date that the camera stored when the
> picture was taken.
>
> Now I don't know much about that, but I thought it was interesting, so
> I did some Googling :-)
>
> I don't know whether it's always
> I was wondering whether it was possible to write a program which
> could directly write some word in a box and click 'search' on a
> typical online database without using the url. (e.g. is there a way
> to write a program which would write some keyword, say 'tomato' on
> google and click
> Thank you for your suggestion. I did not create the original
> script, so it will stay as is and my addition for the menu has been
> adjusted.
>
> Now that I can make a clear distinction of what I am returning, I
> am getting a new error that leads me that I am trying to call a
> functio
> I am starting to use pylab/numpy/scipy instead of MATLAB.
> I now have a real beginners question (I think it is not really
> related to numpy)
> I have a two-dimensional array
> a=[[1,2,3],[4, 5, 6],[7,8,9]]
>
> Is there a simple way to turn it into a multiline string ?
>
> That is, turn a into
> I have some .py files that have things I need to use, sometimes
> it's the functions and sometimes it's the whole .py (they have no
> functions)
>
> how do I use them in my other .py codes?
Import them at the top of your other .py file(s):
import
(without the .py extension).
If they're i
> ok, i can import them.
>
> how do I use them though?
That's also in the tutorial; if there are variables (constants)
instead of functions in your module, it works just the same.
> > I have some .py files that have things I need to use, sometimes
> > it's the functions and sometimes it's the
> I need to keep a bit of python code ready to run at anytime, in the
> ram, but this is what I need to do
>
> I am using two languages at the same time, because python doesn't
> really have any effective way of simulating keyboard and mouse events,
Well, not the language itself, but there may
(this may not be a py-tutor question, but well)
I have a small C-extension module, consisting of 3 files
(ndcombine_module.c, combine.c & combine.h). I can build the
extension find 'in place' using distutils, but when creating a
distribution (with setup.py sdist), the combine.h header file
> I have a small C-extension module, consisting of 3 files
> (ndcombine_module.c, combine.c & combine.h). I can build the
> extension find 'in place' using distutils, but when creating a
> distribution (with setup.py sdist), the combine.h header file
> seemingly gets lost and I cannot build
> I've been trying to do something that I thought was going to be
> relatively straight-forward, but so far I haven't found a good
> solution.
>
> What I'm trying to do is discover a pid on a process and kill it. The
> way that I thought that I could do it is something along the lines of:
>
> im
> So, I tried setting COLUMNS equal to 500 (arbitrarily large) prior to
> going into python. It seems to change back to 158 automatically
> however.
> For example, when I go into python, import commands, and execute
> commands.getoutput('set') I find that COLUMNS is back to 158. So, I
> think m
> I have the following, which I use within a CherryPy app. The
> subprocess bit is just to see if it runs or not. It works on my
> home PC (Python 2.5.1 on Ubuntu), but not on the live host which
> has Python 2.4.4 on Debian Etch.
>
>
> def daemon():
> while 1:
> myperio
>> What's going wrong when running it with 2.4? AfaIcs, all modules are
>> in 2.4, so it my not have to do anything with the Python version, but
>> with the underlying system. Any traceback? Perhaps replace the
>> subprocess part with just a print statement to see what's happening?
>
> There are no
> On Dec 14, 2007 10:02 AM, chinni <[EMAIL PROTECTED]> wrote:
>> Hi which editor for python on Mac os x platform is best with color
>> syntax
>> compiler etc...
>
> You can try emacs, vim, textmate, eclipse(?)
I like Aquamacs Emacs myself, but since Emacs has a steep learning
curve, that may b
> I need a function that will import a module (using __import__) from
> only one specific location on my filesystem. Name collisions are
> possible. To avoid this I could *temporarily* modify sys.path for
> the operation so that it contains only the path that I want
> to work from.
Just curious, b
> Here's what I do. This was just a first attempt to get strings
> starting with a non alpha-numeric symbol. If this had worked, I would
> have continued to build the regular expression to get words with non
> alpha-numeric symbols in the middle and in the end. Alas, even this
> first attempt did
> Hi Patty,
>
> As far as books are concerned, I actually prefer (programming) books in the
> English language. Although the Dutch don't do it as much as e.g. the French
> or the Germans, I hate it when technical terms are translated into Dutch in a
> somewhat artificial way ("Computer" is "Or
> #!/usr/bin/env python
> import datetime
> import subprocess
> import sys
> import os
> import signal
> from time import sleep
>
> def host_run(cmd, secs=10):
>print("running %s" % cmd)
>timeout = datetime.timedelta(seconds=secs)
>proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
>
>>> #!/usr/bin/env python
>>> import datetime
>>> import subprocess
>>> import sys
>>> import os
>>> import signal
>>> from time import sleep
>>>
>>> def host_run(cmd, secs=10):
>>>print("running %s" % cmd)
>>>timeout = datetime.timedelta(seconds=secs)
>>>proc = subprocess.Popen(cmd, s
> #!/usr/bin/env python
> import datetime
> import subprocess
> import sys
> import os
> import signal
> from time import sleep
>
> def host_run(cmd, secs=10):
>print("running %s" % cmd)
>timeout = datetime.timedelta(seconds=secs)
>proc =
I don't really know the answer, but more a question/note (below):
> Hi I am using paramiko 1.7.6 "fanny" on microsoft windows xp v2002 service
> pack3 with python 2.4.2
>
> I have the follwing script:
> import paramiko
>
> hostname='blah'
> port=22
> username='blah'
> password='blah'
> fullpat
Hi Sean,
> I've got a csv file that contains two data fields, the short name of a
> month and an integer. I'm experimenting with pylab and ipython to get
> a feel for how pylab works. I'm able to generate a bar graph from my
> data, but there are two problems with it:
>
> 1. I don't want "20
Hi Tommy,
> I try to write a program, where the user can write a word or a name and I
> will tell how many times the subject was mentioned in a text, I’m hosting.
> I guess it’s possible but not this way it seems?
> The re is only searching for the word “name” and not the variable name
> I’m us
> I am determining a regular expression that can recognize the any of the
> following strings:
>
> MAT file log\20101225 deleted
> MAT file billing\20101225 deleted
> MAT file util\20101225 deleted
> MAT file carrier\20101225 deleted
>
> I begin by creating a regular expression object so that
Hi Sue,
> I am trying to define a new coordinate for My plot.
>
> I have a plot x axis is Concentration, Y axis, depth or Z.
>
> Z= -1000 um.
> and I would like to see the the trend and plot of concentration up to
> -300 um and see how the plot changed according to the depth. So, my
> main que
Hi,
> I'm new to Python and was wondering if someone could answer a question I have.
> Say that I have a python library, arithmetic-0.5, located at /X/arithmetic-0.5
> I'd like to run setup and install it. But I guess since /X/arithmetic-0.5 is
> not in install.py's default search path, it come
> I had a question regarding installing packages that I posted a couple of days
> ago. But I'm re-sending the question again.. this time with output so that it
> is clearer.
>
> I am unable to install libraries using 'python setup.py install'
>
> Say that I'm installing a package "kando". I ext
> Well, using python documentation, I did this..
>
> (calculating execution time).
>
> def main():
> ## This is my whole puzzle code...
>
>
> fobj_ip = open('D:/code/py/input.txt', 'r')
> fobj_op = open('D:/code/py/output.txt','w')
>
> line=1
> for eachLine in fobj_ip:
>
> hi everyone,
>
> I want to make a web page which has to include some python script and html
> tags as well, am not getting how to do that .
> I searched some articles but cant understand them .
> is there anything like linking an external html file into python script ?
>
> Can u please help f
> ImportError Traceback (most recent call last)
> C:\Python27\lib\site-packages\IPython\utils\py3compat.pyc in
> execfile(fname, glob, loc)
>166 else:
>167 filename = fname
> --> 168 exec compile(scripttext, filename, 'ex
Hi,
Tip: use a meaningful subject line; attracts more/better attention and makes it
easier to trace your email in the archives.
Continued at the bottom.
> import numpy as np
> import matplotlib.pyplot as plt
> E=[81.97400737666324, 322.0939978589591, 694.5766491226185]
> V0=1000
> a=0.1
> def
>> actually a i ran a progam in python which is sufficiently large . so i
>> want to stop the execution of the program now . how can i do this?
>
> This will depend on your operating system.
>
> On a Mac you press alt + command + esc and the choose the program you want to
> Force Quit. I have no
Hi Joseph,
> take an example of updating Bank Accounts,
> gaving the following table:
>
> acc_idacc_namestanding_Balance
> mn0001computer 2
>
> my problem is how can i credit the standing balance from user data,as
> in making a deposi
> I’m a newbie in python programming …
>
> I wrote the followings to ssh from Windows to a Solaris server:
>
> command1 = "plink -ssh -pw myPassword myUserName@myServerIP"
> p1 = subprocess.Popen(command1)
> p2 = subprocess.Popen('ls')
>
> I could verify that command1 was executed successfull
> Hi,
> I have created a list of containing strings that represent distances between
> many different points and would like to display the results in a table.
> I have been trying to write them to a text file but it is difficult to
> organise them into rows and columns with appropriate spacing to
> OK so I can solve the equation but now I am having trouble plotting the
> solution! I would like to produce a surface plot with colors defined by p and
> animate it. That is plot the value of p at all x and z, over time (t). My
> code to get p is below but I really have no idea how to plot th
Hi David,
> Hi,
> I am new to python and have made a couple of definitions. I imported them and
> they worked ok. I they worked except for one which gave me the error
> "NameError: global name 'np' is not defined". I then edited my script for the
> def to include "import numpy as np" saved it
> I wrote a little program that does the conversion (I won't post it because it
> would be a spoiler for the OP). The one thing I don't know, though, is how to
> formalise
> that it is not allowed to write something like X, but instead just
> II. Or not DM but simply D. The rule is to wr
> Im trying to code a simple GUI but I'm having a bit of a problem. Heres my
> code:
>
> from tkinter import *
> class Application(Frame):
> def __init__(self,master=None):
> Frame.__init__(self,master)
> self.grid(sticky=N+S+E+W)
> self.cr
> Hi everyone,
>
> If I've created a folder, why would I receive a permissions error when trying
> to copy the file. My source code is here:
> http://pastebin.com/1iX7pGDw
What's the permission error you get? Can't you copy the file, or not create the
destination directory?
Or you may not be al
Hi Elaina,
> Hi everyone,
>I am trying to set up a code to do some plotting and before I get too far
> I wanted to ask some structure questions. Basically I want to tell python to
> read 2 datasets, plot them on the same scale on the same x-y axis , read a
> third dataset and match the
See below, but not all the way. Interspersed in the code.
> >I am trying to set up a code to do some plotting and before I get too
> > far I wanted to ask some structure questions. Basically I want to tell
> > python to read 2 datasets, plot them on the same scale on the same x-y axis
>
Hi and welcome Barry,
> One of the things I wanted to do is to use a four integer array to get four
> integers returned from a function. I ended up using what I think is a list.
> (I'm not really sure of the datatypes yet). This is what I did, and it
> works, but looks very inelegant to me:
> Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters
> but it doesn't seem to work like I thought.
>
>
> res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE)
> uname = res.stdout.read().strip()
>
uname
> 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09
> Alright i have been trying to right a (relatively) simple to calculate area
> and volume below is my current working code
> def areamenu():
> print 'Square (1)'
> print 'triangle (2)'
> print 'rectangle (3)'
> print 'trapazoid (4)'
> print 'circle (5)'
>
> def squareacalc():
> i'm trying to implement a server that adds a time stamp to incoming text form
> a client.
>
> the server's code is (but doesn't seem to have the problem as demoed by the
> error below:
>
> from socket import *
> from time import ctime
>
> HOST = ''
> PORT = 21567
> BUFSIZ = 1024
> ADDR =(HOS
> Hi,
>
> I want to create a class that inherits two other classes.
>
> class NewClass( A,B)
>
> But both "A" and "B" contain a method with the same name ("onKeyDown").
>
> If my "NewClass" does not contain something to override the methods which one
> would be called if
>
> myinstance = New
> Hello all, i have a question:
>
> when i check gtk_time_out in the gtk+2 reference, it said " gtk_timeout_add
> has been deprecated since version 2.4 and should not be used in newly-written
> code. Use g_timeout_add() instead."
>
> but i don't know how tu use the g_timout_add() function:
> m
> I have 4 lists:
>
> >>> a
> [40]
> >>> b
> [2]
> >>> c
> [23]
> >>> d
> [12]
>
Why are you using lists with a single element, instead of single integer
variables? (thus, a=40, b=2, c=23, d=12.)
> how is it possible to do add elements in list.
sum()
> I can do this using tupples, but I do
> First, generate a file named "data.txt" as follows:
>
> -- 8< --
> for i in range(1,100):
>print '.' * 80
> -- 8< --
>
> After that, save the following snippet as "test.py" in the directory
> containing "data.txt":
>
> -- 8< -
On 19 Apr, 2012, at 15:29 , Tino Dai wrote:
> Hi!
>
> I have a question about style. In PEP-8, it says don't exceed 79
> characters, but can this rule ever be trumped by
> readability?
>
Yes, it obviously can.
I am a big fan of the 79 character "rule", though. Even with screens and
ter
101 - 173 of 173 matches
Mail list logo