Re: Can't do a multiline assignment!

2008-04-17 Thread Gary Herron
it, I'd have to scan *all* lines to understand what a single value is being assigned. There is *no way* you can argue that code is clearer than this: # General header fields Cache_Control = None Connection = None Date= None Prag

Re: [Python-Dev] annoying dictionary problem, non-existing keys

2008-04-24 Thread Gary Herron
ion of the get method of dictionaries. Also look at the key in dict syntax on the same page. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: convert xhtml back to html

2008-04-24 Thread Gary Herron
choices exist.) Once you use an existing package to read your files into an internal tree structure representation, it should be a relatively easy job to traverse the tree to emit the tags and text you want. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Gary Herron
and you should not invoke the name mangling implied by the double underscore. If you *are* trying to use the name mangling, then you still don't need the super. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is None <= 0

2008-04-25 Thread Gary Herron
ger and None differently, but on a specific implementation, the result will not change. Python 3 will raise an exception on such comparisons. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Given a string - execute a function by the same name

2008-04-28 Thread Gary Herron
e/gherron' You can use getattr with objects, classes, modules, and probably more. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: list.reverse()

2008-04-28 Thread Gary Herron
order it: x = list ... x.reverse() # reorders, but returns nothing ... now use x ... You might look at the builtin reversed(list): http://www.python.org/doc/faq/programming/#how-do-i-iterate-over-a-sequence-in-reverse-order Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Math libraries - How to?

2008-04-28 Thread Gary Herron
: import math Then use: math.pi, math.sqrt, math.sin, math.cos, ... Method 2: from math import pi, sqrt Then use pi, and sqrt. But other module attributes (like sin, and cos) are not accessible. Method 3: from math import * Then use pi, sqrt, cos, sin, and anything else defined by the modu

Re: computing with characters

2008-04-29 Thread Gary Herron
SL wrote: How can I compute with the integer values of characters in python? Like 'a' + 1 equals 'b' etc -- http://mail.python.org/mailman/listinfo/python-list You can get an integer value from a character with the ord() function. Gary Herron -- http://mail.python.org/mai

Re: Is vs Equality Operator

2008-05-01 Thread Gary Herron
Good Z wrote: Hello, I am having problem in using is. Here is what i am doing. Short answer: Use == for equality.Don't use "is". Ever! (Especially if you are a newbie.) Longer answer: In a dozen years of programming Python, the only time I use "is" is when testing for something like

Re: is +=1 thread safe

2008-05-01 Thread Gary Herron
ister, increment the register write the value into i. If a thread is interrupted anywhere within that sequence, and another thread access i, you have a conflict. (And indeed, hardware interrupts can occur between any two instructions.) Gary Herron -- http://mail.python.org/mailman/listinfo/p

Re: How to use a parameter in a class

2008-05-03 Thread Gary Herron
you are trying to do here, and we'll wee if we can help. Gary Herron P.S. Having a class attribute AND an instance attribute, both named "value" is going to cause trouble. # But the last line does not work. I would like to do a call like: dummy = Dummy(thisV

Re: is +=1 thread safe

2008-05-03 Thread Gary Herron
hreads since each thread has it's own set of register values. Gary Herron 'as -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: is +=1 thread safe

2008-05-04 Thread Gary Herron
Carl Banks wrote: On May 3, 7:44 pm, Gary Herron <[EMAIL PROTECTED]> wrote: Alexander Schmolck wrote: AlFire <[EMAIL PROTECTED]> writes: The threading module already has a function to return the number of Thread objects currently alive. I have threads wi

Re: is +=1 thread safe

2008-05-04 Thread Gary Herron
Alexander Schmolck wrote: Gary Herron <[EMAIL PROTECTED]> writes: But... It's not! A simple test shows that. I've attached a tiny test program that shows this extremely clearly. Please run it and watch it fail. In [7]: run ~/tmp/t.py final count: 200 sh

Re: is +=1 thread safe

2008-05-04 Thread Gary Herron
Carl Banks wrote: On May 4, 12:03 pm, Gary Herron <[EMAIL PROTECTED]> wrote: Alexander Schmolck wrote: Gary Herron <[EMAIL PROTECTED]> writes: But... It's not! A simple test shows that. I've attached a tiny test program that shows this extremel

Re: open filename with spaces in path

2008-05-06 Thread Gary Herron
ven't given us much to work with -- tell us what exception you get.(Or just look at it carefully yourself.) Whatever the problem is, I don't believe it has anything to do with the spaces. Gary Herron >>> open('./my\\ test/test.txt') Exception but yet...

Re: Idea for P3K

2008-05-07 Thread Gary Herron
rposely created without that (mis)feature because it's so unclear, and easy to abuse. Most of us in the community support that point of view and would fight the introduction of such a feature into Python. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: howto print binary number

2008-05-07 Thread Gary Herron
k in range(8): ... b = [i+j for i in ['0','1'] for j in b] ... >>> len(b) 256 >>> b[63] '0011' Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie to python --- why should i learn !

2008-05-08 Thread Gary Herron
face. (Truly, when I found Python, programming became fun again.) Gary Herron Tnx, Raxit www.mykavita.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Grabbing previous iteration in a dict

2008-05-09 Thread Gary Herron
list, I wonder how this can be useful. However, this *does* do what you asked. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to call a file

2008-05-10 Thread Gary Herron
In this case, the problem was trivially easy to spot, but you'll get past these trivial problems soon. Then you'll be more likely to find volunteers who will spend time to help *if* you spend the time to provide useful information. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread Gary Herron
) Do you see the difference? Develop the skill of reading the error messages *very* carefully. Your error says there is no file named "fileName", and if you think about what's on your disk, I'll bet you won't find a file whose name is "fileName". Gary

Re: File operations

2008-08-21 Thread Gary Herron
aditya shukla wrote: Hello guys I am trying to search a file say xyz.txt after searching i get the location of the file in search_file (containing abspath) ,eg search_file="c:\\abc\\xyz.txt" now how should i open this file i can use file=open("c:\\abc\\xyz.txt","rb") but i have to use search

Re: Cathing several potential errors?

2008-09-06 Thread Gary Josack
cnb wrote: if i do try: something except TypeError, IndexError: pass only the first error will get caught. I dont want to use Exception and catch all errors, but just 2. how can i do that? -- http://mail.python.org/mailman/listinfo/python-list what you're doing is assigning the value

Re: How do I set a callback in Python?

2008-09-08 Thread Gary Herron
thing for many uses, including callbacks. Hoping I understood what you wanted correctly, Gary Herron ... but obviously, the Client class, when it calls the callback, doesn't pass a reference to the "self" object. How do I do this? -- Chris -- http://mail.python.org/mail

exit()

2008-09-08 Thread Gary Robinson
een able to find? Is there any reason to use sys.exit() given exit()'s availability? If there is an advantage to sys.exit() over exit(), then does sys.exit() have any advantage over "raise SystemExit, 'some error message'" in cases where a module has no other reason to

Re: Python and Open Office

2008-09-12 Thread Gary Herron
t.getSheets().getByIndex(i) for i in range(component.getSheets().getCount())] return sheets Hope this helps, Gary Herro -- http://mail.python.org/mailman/listinfo/python-list

Re: How does python call OS?

2008-09-14 Thread Gary Herron
someone have to write a DLL in C/C++ that calls the function first? Thanks! Siegfried See the ctypes module for a method of calling any C callable function in and DLL. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any nice way to unpack a list of unknown size??

2008-09-14 Thread Gary Herron
srinivasan srinivas wrote: I want to do something like below: 1. first, second, third, *rest = foo Python 3.0 has exactly this feature. No current Python 2.x version has it. Gary Herron 2. for (a,b,c,*rest) in list_of_lists: Please suggest. Thanks, Srini Bring your gang

Re: member functions in a class

2008-09-18 Thread Gary Herron
answer as to what happens in python? Thanks No code is duplicated. 50 "objects" are created. Each object has its own copy of the data attributes, and a reference to the (one and only) class object where the method attributes are located. That's a short answer. Perhaps too shor

Re: Launching a subprocess without waiting around for the result?

2008-09-19 Thread Gary Herron
indow's service. I'm just now looking into how to register and start a service, and how to stop and remove it later. Google finds lots of information on this -- perhaps I'll post my result when I've pulled it all together. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make a reverse for loop in python?

2008-09-20 Thread Gary Herron
= 10 while i >=0: # do whatever i -= 1 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: I tried erlang-ish [1|2] in python and something came out...

2008-09-21 Thread Gary Herron
process wrote: In erlang you can cons like this: [1|2]. i tried this in python and it didnt raise an error but i dont know what the result do In Python | is the logical bitwise-OR operator. Look at the binary representation of the numbers to understand it. Gary Herron [1|2

Re: Matrix programming

2008-09-23 Thread Gary Herron
A. Joseph wrote: I need an ebook or tutorial that teach matrix programming. Perhaps you should start here: http://www.catb.org/~esr/faqs/smart-questions.html#intro Gary Herron -- http://mail.python.org/mailman

Re: Matrix programming

2008-09-25 Thread Gary Herron
you want! Gary Herron On 9/23/08, *Gary Herron* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: A. Joseph wrote: I need an ebook or tutorial that teach matrix programming. Perhaps you should start here: http://www.catb.org/~esr/faqs/smart-question

Re: decent interactive python shell on MS Windows?

2008-10-01 Thread Gary Herron
e rxvt window implements all the cut/past mouse actions you're used to from Linux/Unix terminal windows. Together, these make windows feel almost civilized. Happy Googling for them, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
def DontInheritMe(self, ...): raise NotImplementedError // Or some such Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
Gary Herron wrote: > process wrote: > >> Let's say I have a class X which has 10 methods. >> >> I want class Y to inherit 5 of them. >> >> Can I do that? Can I do something along the lines of super(Y, exclude >> method 3 4 7 9 10) ? >> &g

Re: Conditionally subclassing based on Import

2008-10-03 Thread Gary Herron
ImportError: MyBase = object else: MyBase = foo.bar.Baz Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get the thighest bit position in big integers?

2008-10-05 Thread Gary Herron
The comparison function used in the search is (potentially) slow, but the search is O(log n) on the number of bits rather than O(n), so its worth a test. If you run timing test, let us know the results. Gary Herron > I implemented this the following way: > > def get_highest_bit_num(

Re: Executing a DOS program from within Python

2006-03-16 Thread Gary Herron
nd various operations in popen2), with os.system being the easiest and perhaps sufficient for your need. However, if you are running Python 2.4, the I'd suggest the "subprocess" module, and in particular its convenience function "call". Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems writing to file

2006-03-21 Thread Gary Herron
te. The solution would be to call flush on the output file after each write (or perhaps just wait more patiently). If the output is voluminous, then it's probably something else ... but I don't know what. Perhpas you could post your code. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: print() in Python 3000 return value?

2006-04-02 Thread Gary Herron
>> > >Or maybe: > >for i in sequence: > mylist.append(print(i)) > > > No no, please NO! You *know* that someday you'll want the return value without actually printing the text. So let's don't overload a single function with two operations. Let "print" print, and propose a separate function (named "format" --yuck-- or some such) that returns the same text as a string. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to convert string

2006-04-05 Thread Gary Herron
ally, you can build the list with a list comprehension construct l = [str(i) for i in xrange(10)] print " ".join(l) You could also combine the above two lines into one -- that would be shorter, but probably not clearer. Cheers, Gary Herron >Every help is appreciate. > > > -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL question about crop method

2006-04-05 Thread Gary Herron
; If you want the cropped rectangle to go from 100 to 200 in x and 300 to 400 in y, then those four values need to be placed in a tuple in the specified order: box=(100,300,200,400) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL question about crop method

2006-04-05 Thread Gary Herron
red pixels from the top or bottom? >> >> > >I came up with this, is it correct: > >(a,b) (c,b) > - > | | > | | > - >(a,d) (c,d) > > >So the tuple w

32-bit python on Opteron, Solaris 10?

2006-04-06 Thread Gary Robinson
thon in "32-bit compatibility mode" and running it alongside the pre-installed Python that comes with Solaris 10. Any input or tips would be greatly appreciated. Thanks Gary -- Gary Robinson VP/Innovation Emergent Music, LLC [EMAIL PROTECTED] 207-942-3463 Company: http://www.goombah

Re: Python-list Digest, Vol 31, Issue 94

2006-04-09 Thread Gary Robinson
ows, you can quickly figure out if it's "fast enough". The more speed I have, the better output I'll be able to get. This application is a case where there is no "fast enough". The more speed, the better, within financial constraints. Gary -- Gary Robinson VP/Innovat

Re: Unpacking Tuples

2009-11-30 Thread Gary Herron
x27;s the syntax for this operation 2) what version does it start with? 1) Syntax is just as you have it. (Not including the period you have at the end.) 2) Python 3.0 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: New to python

2009-11-30 Thread Gary Herron
ingle word "struct", let's start with this: Python has a module named struct: http://docs.python.org/library/struct.html#module-struct Is that what you wanted? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: insert unique data in a list

2009-12-13 Thread Gary Herron
important, you could use a set -- where a second insertion will have no effect. >>> s = set() >>> s.add(1) >>> s.add(2) >>> s.add(1) >>> print s set([1, 2]) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: insert unique data in a list

2009-12-13 Thread Gary Herron
mattia wrote: Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val)

Re: Is it possible to get the erroneous variable when getting a NameError exception?

2009-12-25 Thread Gary Herron
Dotan Barak wrote: Hi. I'm trying to evaluate a string and getting a NameError (it is expected, since the variable my_number wasn't provided in the "locals" dictionary). <--snip start--> >>> eval("my_number < 10", {"__builtins__":None}, {}) Traceback (most recent call last): File "", line 1

Re: Is it possible to get the erroneous variable when getting a NameError exception?

2009-12-25 Thread Gary Herron
Dotan Barak wrote: On 25/12/2009 19:27, Gary Herron wrote: Dotan Barak wrote: Recover the exception, and examine the tuple of args or the message string. >>> try: ... eval("my_number < 10", {"__builtins__":None}, {}) ... except NameError,e: ...

Re: Do I have to use threads?

2010-01-05 Thread Gary Herron
be downloading simultaneously. See http://docs.python.org/library/asyncore.html Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: from datetime.datetime import today not working. python2.6.4 on windows

2010-01-06 Thread Gary Herron
mbols date, time, datetime,etc dir on datetime shows today, now, etc lets say for arguments sake that I want to just import the today function, according to the documentation, the line should be: from datetime.datetime import today. as you can see, that didn't work. why not? Just a little confusion on your part. datetime is a module, so you can import it (as you did) and objects from it datetime.datetime is a type (like a class is a type) not a module so you cannot import from it. So you can import datetime and you can from datetime import but that's all the further you can go with imports. Some of the confusion may be from having a class (well actually it's a type) with the same name as its module. This is now considered bad form. You might achieve the effect you were you were trying for like this: import datetime today = datetime.datetime.today or from datetime import datetime today = datetime.today Then you'll be able to call today() at any time. Gary Herron Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy Q

2010-01-09 Thread Gary Herron
the string if it's a string and the length of the list if it's a list. TIA, beno Like this: if isinstance(var, list): ... join ... else: ... ??? ... Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to duplicate array entries

2010-01-10 Thread Gary Herron
be clearer to some. >>> x = [1,2,3] >>> print [ifor i in xfor k in range(3)] [1, 1, 1, 2, 2, 2, 3, 3, 3] Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: import data structure

2010-01-15 Thread Gary Herron
odule print x or from sfdata import author_list # Import individual attribute from module. for x in author_list: print x Gary Herron FILE: sfdata.py (i'm trying to import it) == author_list = {

Re: What is a list compression in Python?

2010-01-18 Thread Gary Herron
exponent operator is ** not ^, and x*x is more efficient than x**2. So. print [x**2 for x in xrange(1,11,2)] Gary Herron Kit. On 1月19日, 上午12時30分, Steven D'Aprano wrote: On Mon, 18 Jan 2010 08:07:41 -0800, Kit wrote: Hello Everyone, I am not sure if I have posted this questi

Re: Interesting Problem

2010-01-20 Thread Gary Herron
rt as normal. * Check out the "imp" module which allows you to import from files specified via a path. Straighten that out, then we can examine the following (suspicious) clams: * that you must evaluate *before* some import * that you must use globals * python's problem with

Re: Accessing the name of an actual parameter

2010-01-26 Thread Gary Herron
ant How can this be done? TIA Hellmut It's naive to think this question even makes sense. There are many ways f can be called which don't involve a parameter: f(42) f(time()) f(a+123) f(sin(a)) f(f(1)) and so on. Cheers, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing the name of an actual parameter

2010-01-26 Thread Gary Herron
Gary Herron wrote: Hellmut Weber wrote: Hi, consider the following piece of code, please - - def f(param): nameOfParam = ??? # here I want to access the name of the variable # which was given as parameter to the function print nameOfParam, param return if __name__

Re: Multidimensional arrays/lists

2009-09-27 Thread Gary Herron
' '] ] And here's two moves, X grabs the center, and O grabs the upper right board[1][1] = 'X' board[0][2] = 'O' And so on. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: "Pipeline" Generator presentation - where?

2009-09-28 Thread Gary Herron
t, here is another of his presentations about creating coroutines from generators: http://www.dabeaz.com/coroutines Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple if-else question

2009-09-29 Thread Gary Herron
stances where it does provide a useful functionality. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

python memory use

2009-09-30 Thread Gary Robinson
es) than in CPython? I find it hard to believe that that would be the case, but I'm quite curious. (I could test the particular case I mention, but I'm wondering if someone has some fundamental knowledge that would lead to a basic understanding.) -- Gary Robinson CTO Emergent Music, LL

Re: Checking a Number for Palindromic Behavior

2009-10-18 Thread Gary Herron
obably homework problems. If so, it was unethical for the student to ask for a solution here, and it was careless of several responders to provide a solution. Let's not make the same mistake this time. Gary Herron -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of

Re: Is __mul__ sufficient for operator '*'?

2009-10-19 Thread Gary Herron
* and 7*x to be defined, try def __mul__(self,r): ... def __rmul__(self,r): Or the operation is commutative, perhaps you can get away with reusing __mul__ for both. def __mul__(self,r): ... __rmul__ = __mull__ Gary Herron The farthest I can go in this is tha

Re: help to convert c++ fonction in python

2009-10-20 Thread Gary Herron
geremy condra wrote: On Mon, Oct 19, 2009 at 2:25 AM, Tim Roberts wrote: You wrote: For the love of baby kittens, please, please, please tell me that you do not believe this securely encrypts your data. The original poster asked to have two C++ functions converted to Python.

Re: sequential multiple processes

2009-10-24 Thread Gary Herron
/ processors. It's inconvenient. How can I do same thing in a signle script running? Thank you in advance, Hyunchul Use the subprocess module in your main program to start n subprocesses and feed each its portion of the data. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Deeper copy than deepcopy

2009-10-27 Thread Gary Herron
gt;> I wanted to wind up with r being [[1, 2, 3], [1, 2, 999], [1, 2, 3]]. What's the right way to construct r as a list of *independent* d lists? Thanks, -- Scott Try this: >>> >>> d = [1,2,3] >>> r = [[x for x in d] for i in range(3)] >>> r[1][2] = 999 >>> r [[1, 2, 3], [1, 2, 999], [1, 2, 3]] Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension problem

2009-10-29 Thread Gary Herron
a program that depends on them -- there is no guarantee that such implementation specific behavior will be consistent over other implementations. Conclusion: Don't use "is" for comparison when you mean to check for equality. And you do want an equality check here. Gary Herron Regards, mk -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Gary Herron
blem though, if you surpass the ability of a float: >>> int(float('1e20')) 10000L >>> int(float('1e30')) 119884624838656L Gary Herron I'm wondering what function to use to convert '1e7' to an integer?

Re: Pause a script before termination

2009-11-11 Thread Gary Herron
noydb wrote: Hi All, I want to pause my script before it terminates, just so a user can have a moment to read some print statements I include at the end. How can this be accomplished? Thanks! If your IO is to/from a command line window, try this: raw_input('Hit ENTER to exit: &#x

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Gary Herron
print bob['whatever'] 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] al NEW AND IMPROVED AL! bob bob It's the difference between old-style and new-style classes. Type dict and therefore OnlyBob are new style. OnlyAl defaults to old-style.

Re: Line Breaks

2009-11-23 Thread Gary Herron
hat line breaks are being ignored. With that information, perhaps we can identify and solve the real problem you're having. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Line Breaks

2009-11-23 Thread Gary Herron
Susan Day wrote: On Mon, Nov 23, 2009 at 2:26 PM, Gary Herron mailto:gher...@islandtraining.com>> wrote: >>> print 'A Message From %s:\n\n %s' % ('someone','some message') A Message From someone: some message So... *Exactly* wh

Re: gmtime

2010-02-01 Thread Gary Herron
gazza wrote: Hi, I am trying to discover how to obtain the correct time of say CST/ America and EST/America in python? Any help on this would be appreciated. Thanks, Garyc The datetime module should give you all you need. Gary Herron -- http://mail.python.org/mailman/listinfo/python

Re: how long a Str can be used in this python code segment?

2010-02-01 Thread Gary Herron
Python has no specific limit on string size other than memory size and perhaps 32 bit address space and so on. However, if your file size is even a fraction of that size, you should not attempt to read it all into memory at once. Is there not a way to process your file in batches of a reaso

Re: Common area of circles

2010-02-04 Thread Gary Herron
ting the rate of convergence, and so on. Gary Herron for two circles, delta=0.001 takes about a minute and delta=0.0001 is still running after 30 minutes :-) 1.22 1.2281 1.2283479 -- import math class Circle: def _

Re: [PyOpenGL-Users] Mouse wheel events?

2010-02-05 Thread Gary Herron
Craig Berry wrote: Is there any way to get mouse wheel events from glut in PyOpenGL? Use Linux. (On Linux, Glut returns mouse wheel events as buttons 4 and 5), or use FreeGlut. On both Windows and Linux freeglut returns mouse wheel events as buttons 4 and 5. Gary Herron -- http

Re: [PyOpenGL-Users] Mouse wheel events?

2010-02-07 Thread Gary Herron
Craig Berry wrote: Can someone please tell me if there's a way to do this, or answer definitively that there is no way? I have a design in progress that could really use mousewheel control, and I don't want to settle for Plan B until I know Plan A is impossible. :) On Fri, Feb 5, 2010 at 19:48,

Re: [PyOpenGL-Users] Mouse wheel events?

2010-02-08 Thread Gary Herron
Craig Berry wrote: On Sun, Feb 7, 2010 at 22:26, Gary Herron wrote: Didn't I answer this already? If you did, for whatever reason I didn't see it; I just rechecked my inbox to be sure. Thanks for doing so again! I assume, given the list we're on, that Freeglut c

Re: use strings to call functions

2010-02-08 Thread Gary Herron
Parses out the extension fn = getattr(Functions, ext) # Lookup the correct function fn(...) # and call it Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread Gary Herron
mapping out? Your example us a bad ascii art graph of -- I've no clue what? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-08 Thread Gary Herron
spike wrote: On Feb 8, 1:35 pm, Gary Herron wrote: spike wrote: Has anyone been able to come across a Python logic map or Python logic flow chart? An example can be seen on the right under History: http://en.wikipedia.org/wiki/Usenet#History This would be very helpful

Re: [PyOpenGL-Users] Mouse wheel events?

2010-02-10 Thread Gary Herron
wheel events are now reported, and everything else seems to be working as expected. Thanks for your help! :-) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to efficiently extract information from structured text file

2010-02-16 Thread Gary Herron
Imaginationworks wrote: Hi, I am trying to read object information from a text file (approx. 30,000 lines) with the following format, each line corresponds to a line in the text file. Currently, the whole file was read into a string list using readlines(), then use for loop to search the "= {"

Re: os.pipe() + os.fork()

2010-02-20 Thread Gary Herron
ocess module. It can do the fork and any necessary pipes and can do so in an OS independent way. It might make you life much easier. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: if not global -- then what?

2010-02-20 Thread Gary Herron
hat function. This is the proper place to use the "global" keyword. mode.py: gvar = 123 def SetGvar(v): global gvar # Makes gvar refer to the (global) module level gvar gvar = v Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

collections use __next__() in python 2.6?

2010-02-26 Thread Gary Robinson
erits from Iterable, and it doesn't seem to work if I define __next__(); I am not seeing problems if I define next() instead. What am I missing? -- Gary Robinson CTO Emergent Music, LLC personal email: gary...@me.com work email: grobin...@flyfi.com Company: http://www.flyfi.co

Re: Slicing [N::-1]

2010-03-05 Thread Gary Herron
index: >>> range(9)[2::-1] [2, 1, 0] Gary Herron l[7::1] [7, 8, 9] [l[i] for i in range(7, len(l), 1)] [7, 8, 9] [l[i] for i in range(7, len(l), -1)] [] I don't believe the actual behaviour is documented anywhere. Well, i

Re: Slicing [N::-1]

2010-03-05 Thread Gary Herron
Mensanator wrote: On Mar 5, 3:42 pm, Gary Herron wrote: Mensanator wrote: The only way to get a 0 from a reverse range() is to have a bound of -1. Not quite. An empty second bound goes all the way to the zero index: Not the same thing. You're using the bounds o

Re: Slicing [N::-1]

2010-03-05 Thread Gary Herron
Mensanator wrote: On Mar 5, 6:34 pm, Gary Herron wrote: Mensanator wrote: On Mar 5, 3:42 pm, Gary Herron wrote: Mensanator wrote: The only way to get a 0 from a reverse range() is to have a bound of -1. Not quite. An empty second bound goes all the way

Re: Escape curly bracket together to a variable extension

2010-03-06 Thread Gary Herron
Joan Miller wrote: How to escape the first '}' in the next string? s = "}\n{0}".format('foo') >>> "}}\n{0}".format('foo') '}\nfoo' Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: imported var not being updated

2010-03-08 Thread Gary Herron
dule to get the value there. Like this: import helpers print helpers.mostRecent That will work as you hope. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: imported var not being updated

2010-03-09 Thread Gary Herron
John Posner wrote: On 3/8/2010 11:55 PM, Gary Herron wrote: The form of import you are using from helpers import mostRecent makes a *new* binding to the value in the module that's doing the import. What you can do, is not make a separate binding, but reach into the helpers module t

Re: Behavior of default parameter in a function

2010-03-11 Thread Gary Herron
This is addressed in the FAQ. http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects jitendra gupta wrote: def foo(x = [0]): x[0] = x[0] + 1 return x[0] def soo(x = None): if x is None: x = [0] x[0] = x[0] + 1 return x[0] >>> foo() 1 >>>foo() #See the behavi

<    4   5   6   7   8   9   10   11   >