Re: Newbie prob: How to write a file with 3 threads?

2007-05-07 Thread Gary Herron
hich order the data has to be written. >>> >> [snip] >> Or have a `Queue.Queue` for each source thread and make the writer >> thread read from each in turn. >> > > > I'll try Queue.Queue, thank you. I didn't expect that multithread > write a file is so troublesome > As a general rule, *ALL* multithread operations are at least that troublesome, and most are far more so. Pessimistically-yours, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: elegant python style for loops

2007-05-09 Thread Gary Herron
; Yes. The builtin function zip does just that: merging separate lists into a list of tuples. See: http://docs.python.org/lib/built-in-funcs.html#l2h-81 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about string(passing by ref)

2007-05-10 Thread Gary Herron
g is immutable, nothing you do inside the function can change the string outside the function. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Python REGEX Question

2007-05-11 Thread Gary Herron
gt;> x = re.search("[0-9.]+", "(3.12345)") >>> print x.group(0) 3.12345 There's a lot more to the re module, of course. I'd suggest reading the manual, but this should get you started. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Basic question

2007-05-12 Thread Gary Herron
Cesar G. Miguel wrote: > I've been studying python for 2 weeks now and got stucked in the > following problem: > > for j in range(10): > print j > if(True): >j=j+2 >print 'interno',j > > What happens is that "j=j+2" inside IF does not change the loop > counter ("j") as it would

Re: Splitting a string

2007-05-15 Thread Gary Herron
t; title="Send an Email to selected ... employee">''' >>> print s 'D132258','', 'status=no,location=no,width=630,height=550,left=200,top=100')" target="_blank" class="dvLink" title="Send an Email to selected employee"> >>> s.find('\\') -1 So the question now becomes: Where do you really want to split it? If at the comma then one of these will work for you: >>> print s.split(',')[0] 'D132258' >>> i = s.index(',') >>> print s[:i] 'D132258' Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: removing common elemets in a list

2007-05-15 Thread Gary Herron
[EMAIL PROTECTED] wrote: > Hi, > Suppose i have a list v which collects some numbers,how do i > remove the common elements from it ,without using the set() opeartor. > Thanks > > Several ways, but probably not as efficient as using a set

Re: Key Listeners

2007-05-29 Thread Gary Herron
an event when the keyboard is used. ) Yes, every GUI I've ever used from Python (Tk/Tcl, wxPython, Gtk++, Win32 API, ...) has a way to catch keyboard events. But you're going to have to tell us which OS and which GUI you're interested in before you get a more detailed a

Re: Rats! vararg assignments don't work

2007-05-29 Thread Gary Herron
everal better options: For instance: for arg in moreargs: # Loop through each arg or for i in range(len(moreargs)): # Extract ith arg or argslist = list(moreargs) while argslist: firstarg = argslist.pop(0) # Extract first arg Gary Herron > Second, is there any good r

Re: How can an Exception pass over an "except" clause ?

2007-05-30 Thread Gary Herron
AttributeError = SyntaxError Then your code will be will produce a real AttributeError, but miss it because (despite the spelling) it checks for a SyntaxError, Question... I don't know what contract.py is, but could it be doing something that *bad*? You could check py printing Attribut

Re: question about math module notation

2007-07-26 Thread Gary Herron
4407369744.000 >>> print '%12.5e' % x 1.84467e+19 >>> print '%12.5g' % x 1.8447e+19 See http://docs.python.org/lib/typesseq-strings.html for all he details. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Imported globals?

2007-07-27 Thread Gary Herron
import module_a from module_a import change_value but that's probably confusing and generally considered a bad idea. Ideas: 1 If you want module_a to manage such a global variable, you could include functions for getting, and setting it, as well as your function for changing it's value. 2. You could also dispense with use of global values -- various OOP techniques could help there. Gary Herron > Thanks! > > Cheers, > Valia > > -- http://mail.python.org/mailman/listinfo/python-list

Re: this must be a stupid question ...

2007-07-28 Thread Gary Herron
it probably has some special meaning. > > thanks, > Stef Mientki > The $ is not used in any Python syntax. Neither in variable names nor any syntactical construct. Of course, like any character, it can be used in strings. (And some packages, like re, will make special use of a $ i

Re: sending very large packets over the network

2007-08-01 Thread Gary Herron
ou. It fails to across the internet (sometimes) and when (at least some) wireless cards are involved. You may be better off using a package that knows all this and handles it properly. Modules asyncore and asynchat are one possibility. Gary Herron > > the sample code is as follows >

Re: a dict trick

2007-08-02 Thread Gary Herron
may also want to checkout the dictionary method setdefault which has the functionality of get PLUS if the key is not found, it adds the key,value pair to the dictionary. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Question -- Running Programming Python Examples

2007-08-04 Thread Gary Herron
rt 8080 with url's that look like this: http://localhost:8080/what/ever/..., or http://machine-name:8080/what/ever/..., Gary Herron > > > import os, sys > > from BaseHTTPServer import HTTPServer > > from CGIHTTPServer import CGIHTTPRequestHandler

Re: python socket usage

2007-08-16 Thread Gary Herron
#x27;) If you want to turn a string representation of an object back into an object, you must eval the string. Moreover, if the tuple contains things other than simple integers (float of strings of whatever) the string represtnataion of the object may not be able to recover the original object accu

Re: python socket usage

2007-08-16 Thread Gary Herron
Oğuz Yarımtepe wrote: > On Thursday 16 August 2007 11:20:38 Gary Herron wrote: > >> If you really want to send any Python object through a socket, look up >> the Pickle and cPickle modules. These will marshal (as it's called) any >> Python object of any type and

Re: A problem with Time

2007-08-16 Thread Gary Herron
ays date? > > Thank You > > Dominic > > > Here's how I'd do it: >>> import time >>> secondsPerDay = 24*60*60 >>> today = time.time() >>> yesterday = today - secondsPerDay >>> print time.strftime("%d%m%Y",time.lo

Re: sort dictionary by specific values

2007-08-18 Thread Gary Herron
CANNOT sort a (standard Python) dictionary. You CAN find some alternative implements of dictionaries on the web that allow ordering, and you CAN extract the key,value pairs from a dictionary into a list, and sort that list (by any criteria you want). Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: "Variable variable name" or "variable lvalue"

2007-08-19 Thread Gary Herron
"self.%s = '%s'" % (item, plist[item]) > Yuck! Not at all necessary. Use setattr instead: setattr(self, item, plist[item]) That's much cleaner then an exec or eval. You may also find getattr and hasattr useful. Gary Herron > A more simple example for setting a variable outside of a class... > > exec '%s = '%s'" % ('variableName', 'variable value') > > Cheers! > Mike > > -- http://mail.python.org/mailman/listinfo/python-list

Re: How to setup pyOpenGL3.0.a6 for window xp?

2007-08-19 Thread Gary Herron
imple (nice, very small, well featured and consistent) widget toolkit with OpenGL support. Once the window is open, PyOpenGL (versions 2xx or 3xx) work perfectly on the window. See http://www.fltk.org/ Gary Herron >> However, it doesn't (easily) work with common GUIs like GTK and Wx.

Re: Python Path Dictionary

2007-08-21 Thread Gary Herron
[EMAIL PROTECTED] wrote: > Hi, > > Do the Python Paths come in the form of a dictionary where I can > access a particular path my its key in the registry? > > For example, in PythonWin Tools>>Edit Python Paths shows the name as > well of the address of each path > > Thanks, > > Aine > > If by "P

Re: Python is removing my quotes!

2007-08-21 Thread Gary Herron
ot Python. It never even sees those quotes. Whatever system you are using for entering the text is stripping them. Is it the command prompt (cmd.exe)? If so then you can escape the quote by preceding it with a backslash. (This is true of the DOS prompt and all the unix shells, and their window

Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Gary Herron
darren kirby wrote: > Hi all, > > I have a strange error here and I am unsure how to further investigate it: > > Python 2.4.4 (#1, Aug 23 2007, 10:51:29) > [GCC 4.1.2 (Gentoo 4.1.2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > import time

Re: strings (dollar.cents) into floats

2007-08-30 Thread Gary Herron
n empty string. And that would seem to mean you have an empty line in your input. So... Either remove the empty lines, or test my_line before calling float on it. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get a formatted string?

2007-09-04 Thread Gary Herron
Ginger wrote: > like format function in Visual Basic, > format("##.##%",0.3456) ==>> 34.56% > "%5.2f%%" % (0.3456*100) '34.56%' See this section of the manual: http://docs.python.org/lib/typesseq-strings.html Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting original working directory

2007-09-06 Thread Gary Herron
() returns the current working directory. Call this before you change things with os.chdir(). Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting original working directory

2007-09-06 Thread Gary Herron
you saying you *CAN'T* call getcwd and save the value before you call chdir, and that you *MUST* recover the original working directory *AFTER* you change it. I don't believe it... and won't waste my time trying to solve such a silly problem until you demonstrate that you ca

Re: Pickle Problem

2007-03-15 Thread Gary Herron
tonyr1988 wrote: > I'm a complete python n00b writing my first program (or attempting to, > anyway). I'm trying to make the transition from Java, so if you could > help me, it would be greatly appreciated. Here's the code I'm stuck on > (It's very basic): > > class DemoClass: > def __init__(s

Re: making objects with individual attributes!

2007-03-20 Thread Gary Herron
t; a different > "set" > Of course. Try this: class document: def __init__(self, string): self.titre = string self.haveWords = set() Each instance creation will call __init__ with the instance accessible through self, and that code will create two instance specific attribute

Re: Make variable global

2007-03-21 Thread Gary Herron
procedure go is defined in a.py, the global blah it refers to is global to that module. So import a (instead of importing * from a) and try this: >>> import a >>> a.blah >>> a.go() >>> a.blah 5 >>> Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to access multiple group matches?

2007-04-06 Thread Gary Herron
behaviour isn't desired; if the RE <.*> is matched against |'title'|, it will match the entire string, and not just |''|. Adding "?" after the qualifier makes it perform the match in /non-greedy/ or /minimal/ fashion; as /few/ characters as possi

Re: Checking whether list element exists

2007-04-07 Thread Gary Herron
ther's be reported as the errors they are: try: myList[index] except IndexError: ...whatever... Gary Herron > Is it ok to use try...except for the test or is it bad coding style? Or > is there another, more elegant method than these two? > > Regards, > Rehceb > -- http://mail.python.org/mailman/listinfo/python-list

Re: True of False

2007-09-27 Thread Gary Herron
Richard Thomas wrote: > On 27/09/2007, Casey <[EMAIL PROTECTED]> wrote: > >> On Sep 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]> >> wrote: >> >>> On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>> >>> I tried writing a true and false If statement and didn't get >

Re: marshal bug?

2007-09-28 Thread Gary Herron
t the module uses. Version 0 is the historical format, version 1 (added in Python 2.4) shares interned strings and version 2 (added in Python 2.5) uses a binary format for floating point numbers. The current version is 2 Gary Herron. -- http://mail.python.org/mailman/listinfo/python-list

Re: Delete spaces

2007-09-28 Thread Gary Herron
lit() >>> print f ['1', '1', '10:55:14', '2', '65', '8.5'] >>> ','.join(f) '1,1,10:55:14,2,65,8.5' or >>> ', '.join(f) '1, 1, 10:55:14, 2, 65, 8.5' >>> Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-14 Thread Gary Herron
sed copy of either a string or a list Your recursion stops when xs == [], but when you're stripping characters off a string, like 'abc', the remaining portion will be 'bc', then 'c', than '', but never [] so you 'll never stop. Try: if xs == []: return [] elif xs == '': return '' else: ... Gary Herron > > Thanks, > Dima -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-15 Thread Gary Herron
ings in common. In particular xs[::-1] will reverse both types of objects. And even if you roll you own reversal function, you don't need two. One will do. Gary Herron > > def reverseList(xs): > if xs == []: > return xs > else: > return (reverseList (

Re: Speed of Nested Functions & Lambda Expressions

2007-10-23 Thread Gary Herron
of Python while executing fn_outer, the def of fn_inner looks just like an assignment with fn_inner as the variable name and a code object as the value. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find if a string contains another string

2007-10-29 Thread Gary Herron
perator named in: >>> bigstring="python anaconda boa cobra" >>> smallone="boa" >>> smallone in bigstring True Often used in if statements like this: >>> if smallone in bigstring: ... print 'contained' ... else: ... print '

Re: Print a list to a string?

2007-10-31 Thread Gary Herron
tation of that object. Use str for a human friendlier representation, and repr for a more explicit representation. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to run external program?

2007-01-12 Thread Gary Herron
and both its input and output. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I create a linked list in Python?

2007-01-16 Thread Gary Herron
off if you can use Python's list data structure rather than try to emulate an outdated concept in a modern language. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Capture traceback message to string?

2007-01-16 Thread Gary Herron
#x27;t seem to figure out how to get the basic > components of the traceback message into strings. Here's what I want > to do: > The traceback module provides a wealth of ways to get at the exception information, formated and usable in various ways. See: http://docs

Re: How to get self reference from within a module?

2007-01-22 Thread Gary Herron
dictionary of all objects in the module, from which you can access and iterate through the names (keys) and values. If you want more capabilities, you should also look at the inspect module. Gary Herron -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of Tech

Re: How to use dynamic properties? <-- Noob

2007-01-23 Thread Gary Herron
plete Web Services > http://www.datafly.net > > Like this: info_I_need = 'name' print getattr(person, info_I_need) Related to getattr are setattr and hasattr. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variables

2007-01-24 Thread Gary Herron
ibutes that can be used like function level static variables. However, I usually use module level attributes for such things. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variables

2007-01-24 Thread Gary Herron
ibutes that can be used like function level static variables. However, I usually use module level attributes for such things. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to remove c++ comments from a cpp file?

2007-01-26 Thread Gary Herron
returns a new string which you must assign to something: new_data = r.sub(ur"", data) Then do something with the new string. Also I fear your regular expression is incorrect. Cheers, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: PY Zip

2007-01-30 Thread Gary Herron
to be able to be used in Python Win. Is there a ZIP utilty > already stored with a basic PYTHON download? > > Thanks all. > > The module you want is called zipfile, and its part of the standard library. See: http://docs.python.org/lib/module-zipfile.html for documentation. Gary Her

Re: win32com.client

2007-01-31 Thread Gary Herron
vithi wrote: > Hi > Any one tell me where I can get (or download) python modules win32com > or win32com.client because I have to use "Dispatch" thanks > > You want the "python for windows" extension, available from http://sourceforge.net/proje

Re: Simple SVN/CVS-like library in Python?

2007-02-07 Thread Gary Herron
's got far more feature than you're likely to get into any Python scripts in the near future. (Plus it's scritable from Python so you can automate some tasks if you wish. Gary Herron > Thank you very much for every hint. > > Andrea. > > "Imagination Is T

Re: Strings in Python

2007-02-08 Thread Gary Herron
tring sub is found, 4 such that sub is contained within s[start,end]. Optional 5 arguments start and end are interpreted as in slice notation. 6 7 Return -1 on failure. So put your find in a loop, starting the search one past the previously found occurrence. i = string.find(mystring, i+1) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: UNIX shell in Python?

2007-02-09 Thread Gary Herron
parsing user input. > > Regards, > Deniz Dogan > Not only *can* it be done, but it *has* been done and well: See IPython at: http://ipython.scipy.org/moin/ Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm faint why this can't work

2007-02-16 Thread Gary Herron
tabs for the indentation, so that the code Python sees is not as we see it printed? (Don't ever do that.) Do you have several copies of sampdict.py (or even sampdict.pyc) so that the copy being imported is not the one you printed? (Run Python with a -v switch to test for this possibility.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing from upper directory

2007-02-17 Thread Gary Herron
h.split(path0)[0] # Up one path2 = os.path.split(path1)[0] # Up two sys.append(path2) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: What is more efficient?

2007-02-18 Thread Gary Herron
is highly optimized and probably not noticeable. The number of methods/functions may slow things up, but it will affect either name space equally. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Declare a variable global

2007-02-19 Thread Gary Herron
colorIndex colorIndex=123 # changes the value of the global Better yet, restructure your code to not rely on the global statement. Do something like this if you can: def test(): return 123 colorIndex = test() Gary Herron > My question is why do I have to explicit declari

Re: How can I disable a device in windows using python

2007-02-26 Thread Gary Herron
ever, if you tell us how you would disable a card from outside of Python, we'll see if we can find a way to do it from within Python. Things you might want to tell us: What OS. What device(s) Exactly what "disable" means for each. How the OS allows you to enable/disable each. Anythi

Re: import parent

2007-02-27 Thread Gary Herron
s have pointed out, circular imports are often a sign that your software design is not very well thought out. It's usually better to have your thought process, your design and your imports organized in a hierarchal fashion. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Variable-width lookbehind

2007-11-18 Thread Gary Herron
e reason enough for some to want to keep it out.) But this is an all volunteer community. Your feature is not in the language because no one has cared enough to implement it. Or if some one has implemented it, no one has found it useful enough to lobby it into the language. Are

Re: Unexpected behavior when initializing class

2007-11-28 Thread Gary Herron
[EMAIL PROTECTED] wrote: > Hello everybody, > > I've banged my ahead around for a while trying to figure out why > multiple instances of a class share the same instance variable. I've > stripped down my code to the following, which reproduces my problem. > This is a *feature* of Python tha

Re: "Python" is not a good name, should rename to "Athon"

2007-12-03 Thread Gary Herron
Russ P. wrote: > On Dec 3, 8:22 am, [EMAIL PROTECTED] wrote: > >> The only reason to change the name would be because of some serious >> bad PR that came onto Python, thus causing its branding name to be >> catagorized as something bad. >> >> However this is not the case, presently, and the bran

Re: Python Class Best Practice

2007-12-04 Thread Gary Herron
If you *really* wanted two class members *AND* two instance members with the same names, (WHY???) then example 1 will do so, but you'll have to access the instance members as self.member1 and the class members as Foo.member1. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: UliPad 3.8.1 released!

2007-12-12 Thread Gary Herron
e time, when making such an announcement, to tell us *what* it is you are releasing. Just a sentence or two and a URL would be only common courtesy. Thanks, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: what the heck does this mean?

2007-12-13 Thread Gary Herron
ans "save"? What is "randomletters"? The error you are getting is usually gotten by code that tries to treat a variable containing a list as a function. Example: someList = [1,2,3] someList(99) Traceback (most recent call last): File "", line 1, in TypeError:

Re: Loops and things

2007-12-14 Thread Gary Herron
h values from each iterator respectively, and loop on that: >>> for i,j in zip(range(10),range(10,20)): ... print i,j ... 0 10 1 11 2 12 3 13 4 14 5 15 6 16 7 17 8 18 9 19 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: simple string formatting question

2007-12-14 Thread Gary Herron
and use join on a space to the the space delimited string. >>> theList = ['./whatever', 'a', 'b', 'c'] >>> print ' '.join([repr(i) for i in theList]) './whatever' 'a' 'b' 'c' Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: opposite of zip()?

2007-12-14 Thread Gary Herron
nks, > igor > But it *does* exist, and its named list.append, and it works as you wanted. >>> list.append >>> a = [[],[]] >>> map(list.append, a, (1,2)) [None, None] >>> a [[1], [2]] >>> map(list.append, a, (3,4)) [None, None] >>&

Re: opposite of zip()?

2007-12-15 Thread Gary Herron
[EMAIL PROTECTED] wrote: > Hi folks, > > Thanks, for all the help. I tried running the various options, and > here is what I found: > > > from array import array > from time import time > > def f1(recs, cols): > for r in recs: > for i,v in enumerate(r): > cols[i].append(v) >

Re: [newbie] Read file, and append?

2007-12-25 Thread Gary Herron
ot;activate.tmpl", "rb") template = "\r\n" + f.read() f.close() for fname in glob.glob('*.frm'): inf = open(fname, "rb") content = inf.read() inf.close() if 'Form_Activate' not in content: print "Not in", fname outf = open(fname, 'wb') outf.write(content) outf.write(template) outf.close() Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Plug-Ins In A Python Application

2006-04-18 Thread Gary Herron
look* like a declaration, but in fact it may be executed anywhere. The import statements does, however, hard code its module's name. For a plugin system, you'll probably want to import a module given a string containing its name. The "imp" module provides this as w

Re: extracting a substring

2006-04-18 Thread Gary Herron
quot;a53bc_([0-9]*).txt") >>> >>> s = "a53bc_531.txt" >>> match = pattern.match(s) >>> if match: ... print int(match.group(1)) ... else: ... print "No match" ... 531 >>> Hope that helps, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: search files in a directory

2006-04-20 Thread Gary Herron
t. open can be used to open a file The open file has several methods to read bytes from the file: read() gets the whole file at once readline() return a line at a time other possibilities exist You can test to see if a string s is in another string t with if s in t: ... Hope that

Re: What am I doing wrong here

2006-04-24 Thread Gary Herron
nd ' + ComputerName + ' "' + Message + '"') where the +'s build the command string up from pieces. You might try invoking Python interactively and try typing some of these expressions by hand to see that happens: python >>> ComputerName = 'Fred' >>> Message = 'HI' >>> print 'net send ComputerName "Message"' net send ComputerName "Message" >>> print 'net send %s "%s"' % (ComputerName, Message) net send Fred "HI" >>> Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested Lists Assignment Problem

2006-04-26 Thread Gary Herron
don't), then you have to find a different way to create three separate objects. The copy module helps with this in some cases, but for your simple example, you just want to create the three inner objects by evaluating the expression [0]*3 three times. Here's several ways: a = [] for i in range(3): a.append([0]*3) or a = [ [0]*3 for i in range(3)] Clear? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: combined files together

2006-05-06 Thread Gary Herron
by reading larger chunks than single lines, and could be more accurate by closing both input and output files when done, but you get the point I hope. On the other hand, if you've got the right OS, you might try something like: os.system("cat * > combined") Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: NumTut view of greece

2006-05-07 Thread Gary Herron
It was trying -- it just didn't have enough time.) If you don't want the program to quit that quickly, you need to put in something to keep it from running off the bottom and exiting. I'd suggest something like this after the view line: raw_input("Type ENTER when done viewing: ") Gary Herron >thanks > > -- http://mail.python.org/mailman/listinfo/python-list

Re: printing list

2006-05-07 Thread Gary Herron
>10 >15 > >Thanks. > > Well, first, if you just print alist you'll get [1, 2, 5, 10, 15] which may be good enough. If that's not what you want then you can suppress the automatic RETURN that follows a print's output by adding a trailing comma to

Re: multiline strings and proper indentation/alignment

2006-05-09 Thread Gary Herron
iformly removed from the left of every line in text. This is typically used to make triple-quoted strings line up with the left edge of screen/whatever, while still presenting it in the source code in indented form. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Shadow Detection?

2006-05-09 Thread Gary Herron
Michael Yanowitz wrote: >Hello: > > Many times, people are warning things like >"Don't use 'str' as a variable name as it will shadow the >built in str function." > Is there some way to determine if a string is already >defined in some higher scope? >Maybe something like > > >if isdefined ('st

Re: find all index positions

2006-05-11 Thread Gary Herron
ng)] [10, 31] And so on Of course, if you wish, the re module can work with vastly more complex patterns than just a constant string like your '1234'. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: find all index positions

2006-05-11 Thread Gary Herron
Paul Rubin wrote: >[EMAIL PROTECTED] writes: > > >>say i have string like this >>astring = 'abcd efgd 1234 fsdf gfds abcde 1234' >>if i want to find which postion is 1234, how can i achieve this...? i >>want to use index() but it only give me the first occurence. I want to >>know the positions o

Re: Process forking on Windows

2006-05-17 Thread Gary Herron
appreciated. > >Thanks > > The "subprocess" module gives a (mostly) platform independent way for one process to start another. It provides a number of bells and whistles, and is the latest module on a long history of older modules to provide such functionality. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Process forking on Windows

2006-05-17 Thread Gary Herron
igger monitor. > > The windows CreateProcess call has many of the same semantics as the Unix fork, i.e., a new process is created sharing all the resources of the original process. The "subprocess" modules uses CreateProcess, but if that does not give you sufficient control ove

Re: Complex evaluation bug

2006-05-18 Thread Gary Herron
that functionality. So, putting them together, you could expect eval(repr(a)) to reproduce a, and in fact it does so. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: import woe

2006-05-18 Thread Gary Herron
[EMAIL PROTECTED] wrote: >hello, > >i have a problem. i would like to import python files above and below >my current directory. > >i'm working on /home/foo/bar/jar.py > >i would like to import /home/foo/car.py and > /home/foo/bar/far.py > >how can i do this? > >thank you, >

Re: who can give me the detailed introduction of re modle?

2006-05-18 Thread Gary Herron
tried to solve, your solution attempt, and what failed, you will likely get lots of useful answers here. But you have to take the first step. P.S. The re module is really not all *that* difficult. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes

2008-01-06 Thread Gary Herron
via ctypes. If you can be more specific about your problem and how it fails, then perhaps you'll get more specific answers. Also, please read this: http://www.catb.org/~esr/faqs/smart-questions.html Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: HOW TO HANDLE POINTERS FROM NON-LOCAL HEAPS??

2008-01-11 Thread Gary Herron
der) C/C++ days -- ya, that's it. Thankfully, this is Python and the modern era -- we don't use no stinking POINTERS here. Seriously, this group deals with Python. There are no pointers in Python. Now please, what did you *really* mean to ask? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: python recursive function

2008-01-11 Thread Gary Herron
: > This sounds very much like a homework assignment, and so should probably not be answered here. (Neither should it have been asked here.) If, in your attempt to write this program, you have some questions about Python, then I encourage to ask those questions here. Gary Herron > If n is

Re: Simple List division problem

2008-01-12 Thread Gary Herron
larger sublist. >>> x = [1,2,3,4,5,6,7,8,9,10] >>> y = 3 >>> s = len(x)/y >>> s# size of normal sublists 3 >>> e = len(x) - y*s # extra elements for last sublist >>> e 1 >>> z = [x[s*i:s*i+s] for i in

Re: sqlite3 is it in the python default distro?

2008-01-12 Thread Gary Herron
access an sqlite installation, but it does not include the sqlite installation itself. That should be installed separately. (I suppose a distro of Linux could package them together, but I don't know of one that does, and such is not the intent of Python.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementary string-formatting

2008-01-12 Thread Gary Herron
row into the hundreds or thousands or higher. If you want to try one of the floating point formats, then your first number must be large enough to account for digits (before and after) the decimal point, the 'E', and any digits in the exponent, as well as signs for both the number and th

Re: NotImplimentedError

2008-01-14 Thread Gary Herron
27;s it not yet implemented, and mistakenly tries to call it, an error will be raised. It's not so useful in a small application, or a single person project, but it does become useful if several people are writing different parts (say a library and an application) at the same time. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Gary Herron
ach won't scale very well since the whole string would be re-created anew for each stop_list entry. In that case, I'd look into the regular expression (re) module. You may be able to finagle a way to find and replace all stop_list entries in one pass. (Finding them all is easy -- not so sure you could replace them all at once though. ) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace stop words (remove words from a string)

2008-01-17 Thread Gary Herron
Karthik wrote: > How about - > > for s in stoplist: > string.replace(mystr, s, "") > That will work, but the string module is long outdated. Better to use string methods: for s in stoplist: mystr.replace(s, "") Gary Herron > Hope this s

Re: Max Long

2008-01-21 Thread Gary Herron
icit (defined) limit. The amount of available address space forms a practical limit. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'?

2008-01-23 Thread Gary Herron
second produces an int value, but since one is a subclass of the other, you'd have to write quite perverse code care about the difference. Gary Herron > I hope, I made clear, what I want... > Quite. > CU > > Kristian > -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   >