Re: Problems wit List Object

2008-03-27 Thread Gary Herron
hat's not enough explanation for you, you'll have to provide some code for us to look at. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting back an Object

2008-03-27 Thread Gary Herron
e used to recover the object when given a string later: That is, for each object obj do: objMap[str(obj)] = obj and later with the string in hand, do obj = objMap[string] One other word of warning. It is best to not use a variable named "string" as Python has a builtin type of t

Re: Astronomy Fits format and gif.save(path)

2008-03-28 Thread Gary Herron
W. Watson wrote: > In what library would I find gif.save(path), where path is the name and path > of a file, and the method would produce a file in a gif format? > > Is there a fits.save(path) somewhere? fits is commonly used in astronomical > work. > You may want to install PIL (the Python

Python Startup file

2009-01-16 Thread Gary Smith
pointing out the obvious to me Gary _ "Accept no assertions without evidence." --Goompah wisdom from "Omega" by Jack McDevitt-- _ "Nature is complete because it does not serve itself." --"Tao De Jing" by Lao Tze-- -- http://mail.python.org/mailman/listinfo/python-list

Re: is None vs. == None

2009-01-23 Thread Gary Herron
gt; (admittedly most objects don't), but only None is None. > > You don't have that quite right. The only way something can *equal* None is if it *is* None. None is not a value an object can have, but rather it is a (singleton) object that can be referenced. Setting something *eq

Re: is python Object oriented??

2009-01-29 Thread Gary Herron
d, but it is not (as your definition suggests) object-fascist. We use objects to great effect in Python, when it is natural to do so, but the language does not force it on us. Gary Herron > -- > Regards, > > Maneesh KB > > Comat Technologies > > Bangalore &

Re: Rounding to the nearest 5

2009-01-30 Thread Gary Herron
todp...@hotmail.com wrote: > How can you make python round numbers to the nearest 5: > > Example: > > 3 => 0 > 8 => 10 > 23.2 => 20 > 36 => 35 > 51.5 => 50 round(n,-1) rounds to the nearest 10, so round(n*2,-1)/2 will round to the ne

Re: Why doesn't this work in Eclipse ? (Simple pexpect code that works in bash)

2009-01-30 Thread Gary Duzan
the stdin of the parent is a real (or possibly pseudo-) terminal, which appears not to be the case for programs run through Eclipse. Gary Duzan -- http://mail.python.org/mailman/listinfo/python-list

Re: Import Replacement

2009-01-31 Thread Gary Herron
falo as ridable # Now use ridable as any module... If each defines a class of its own name, but the classes have identical interfaces, then try if ...: from horse import Horse as Ridable else: from buffalo import Buffalo as Ridable # Then instantiate animal = Ridable(...) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Global State

2009-02-03 Thread Gary Herron
'm not sure how that will work. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use list name as string

2009-02-04 Thread Gary Herron
Vincent Davis wrote: > Do to laking knowledge my google searches have not turned up an answer for me. > I know this is wrong it uses the items in the list as the filename, > how do I refer to the dataname and not the items in it. > > def savedata(dataname): > filename = str(dataname) # this do

Re: Couple of noobish question

2009-02-04 Thread Gary Herron
ulFn(...): ... Then your main Python file imports it and uses the things define in a.py like this: import a ob = UsefulClass(...) a.UsefulFn() Good luck, Gary Herron > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: SuPy - Script Sketchup with Python

2009-02-06 Thread Gary Herron
greg wrote: > SuPy 1.0 > > > SuPy is a plugin for the Sketchup 3D modelling application > that lets you script it in Python. > > http://www.cosc.canterbury.ac.nz/SuPy/ That URL fails with a 404 - not found. (At least for me at this moment in time.) > > This is a first version and is

Re: Best 3d graphics kit for CAD program???

2009-02-08 Thread Gary Herron
for Python. pyglet provides an object-oriented programming interface for developing games and other visually-rich applications for Windows, Mac OS X and Linux. You might also consider SDL and its python bindings. Gary Herron Thanks Guy's -- http://mail.python.org/ma

Re: Best 3d graphics kit for CAD program???

2009-02-08 Thread Gary Herron
n...@stinemates.org wrote: > Gary > > Your email client is set to HTML mode and looks terrible for those of us > who prefer plain view. It also appears your client is not properly > sending your message in text/plain encoding. > > > -- > http://mail.python.org/m

Re: how to find out vesion of a python module

2009-02-09 Thread Gary Herron
d object, Intel 80386, version 1 > (SYSV), not stripped > > How could I fix this? > It looks like you have it installed incorrectly, How did you install it. What platform/system are you on? PIL usually uses a PIL.pth file. Does that exist? Where? And what are its contents? Ga

python3 tutorial for newbie

2009-02-10 Thread Gary Wood
Can someone recommend a good tutorial for Python 3, ideally that has tasks or assignments at the end of each chapter. Please, -- http://mail.python.org/mailman/listinfo/python-list

[no subject]

2009-02-19 Thread Gary Wood
I'm stuck on a tutorial Hands on Python3 Exercise 1.13.7.3. ** Complete the following function. This starting code is in joinAllStub.py. Save it to the new name joinAll.py. Note the way an example is given in the documentation string. It simulates the use of the function in the Shell. This is a

Re: initialized list: strange behavior

2008-11-24 Thread Gary Herron
lists here to obscure things. Try this: Here b is a list that contains three references to a. Modify a, and all three references to a show the modification: >>> a = [1,2,3] >>> b = [a,a,a] >>> a.append(4) >>> b [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]

Re: How to pass out the result from iterated function

2008-12-10 Thread Gary Herron
omething: return iterSomething(output) else: return output So either way, *something* is returned, and in the case of the recursive call, the innermost result is returned back up through all levels of the recursion. Is that what you wanted? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator slower than iterator?

2008-12-16 Thread Gary Herron
Lie Ryan wrote: > On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > > >> Hi all, >> >> Im parsing a 4.1GB apache log to have stats about how many times an ip >> request something from the server. >> >> The first design of the algorithm was >> >> for line in fileinput.input(sys.argv[1

Re: Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread Gary Herron
, but numpy has a nice (efficient) way to do this: >>> import numpy >>> s = 'bgrBGRcbaCBA' >>> a=numpy.array(s, 'c') # Initialize an array >>> a.shape = (4,3)# Reinterpret as a ?? by 3 array >>> b=a[...,::-1] # reverse the second dimension >>> print b.tostring() # Convert back to a string. rgbRGBabcABC Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: What is ''r'' in python?

2009-01-06 Thread Gary Herron
pe ''r''# (That's four single quotes although your font may make it look like two double quotes.) is an empty string '' followed by another empty string (using raw syntax) r'' The last piece of the puzzle is a (seemingly) little know feature

Re: replace numbers in a string

2008-10-09 Thread Gary Herron
ular expression module, use re.sub like this: >>> import re >>> re.sub('[0-9]', '', "ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg") 'ttccatttctggacat

Re: Python equivalent for C module

2008-10-20 Thread Gary Herron
dly. No matter what I passed as an > argument (and no matter what I set the value of DEBUG to be), it > started printing the exact literal string: > > DEBUG: %s > > whenever it was called. It was as if the function couldn't see the > parameter msg, which was

Re: Avoiding local variable declarations?

2008-11-13 Thread Gary Herron
) > 50: return chr( random.randrange(0, 26) + 97) else: return chr( random.randrange(0, 26) + 65) or return chr( random.randrange(0, 26) + [26,97][random.randrange(0, 100) > 50] or ... probably other ways can be found ... but what's wrong with you original code? Gary Herron > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list

Re: find() a larger string within a smaller string

2008-11-14 Thread Gary Herron
ot, it returns a -1 indicating so. You'll have to describe what you expected and why you expected it before we will be able to see a problem that needs solving. (And then the problem will most likely be in your expectations, not in the find method.) Gary Herron > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list

Can someone tell me why i get None at the end please this has me stuck for ages

2009-02-23 Thread Gary Wood
'''exercise to complete and test this function''' import string def joinStrings(items): '''Join all the strings in stringList into one string, and return the result. For example: >>> print joinStrings(['very', 'hot', 'day']) 'veryhotday' ''' word = [items] for item in it

thanks very much indeed for your help is there a better way to do this (python3) newby

2009-02-23 Thread Gary Wood
'''exercise to complete and test this function''' import string def joinStrings(items): '''Join all the strings in stringList into one string, and return the result. For example: >>> print joinStrings(['very', 'hot', 'day']) 'veryhotday' ''' for i in items: return (''

Newby - is this what they are looking for ?? and is their a better a way

2009-02-24 Thread Gary Wood
''' program. 1.What type of data will the input be? What type of data will the output be? 2.Get the phrase from the user. 3.Convert to upper case. 4.Divide the phrase into words. 5.Initialize a new empty list, letters. 6.Get the first letter of each word. 7.Append the first letter to the lis

Newbie : this works in one direction but get the error on the return path

2009-02-25 Thread Gary Wood
'''Test animation of a group of objects making a face. Combine the face elements in a function, and use it twice. Have an extra level of repetition in the animation. ''' from graphics import * import time def moveAll(shapeList, dx, dy): ''' Move all shapes in shapeList by (dx, dy).'''

Re: Queries

2009-02-25 Thread Gary Herron
mmcclaf wrote: I have to make some queries for 4 tables I have. The following relations are: Classes(class, type, country, numGuns, bore, displacement) Ships (name, class, launched) Battles (name, date) Outcomes (ship, battle, result) The three queries I'm stuck on are the following: 1. Find

PythonWin -vs- Idle

2009-02-26 Thread Gary Schells
Hello, Python newbie here. I am working with Python and geoprocessing in ArcGIS. I'm taking a training course online and the exercise I'm working on makes mention of using PythonWin instead of Idle. I am using version 2.5 and have not been able to locate PythonWin. The download just includ

Re: String Identity Test

2009-03-03 Thread Gary Herron
of efficiency, and as such each implementation/version of Python may make its own choices. Writing a program that depends on the string identity policy would be considered an erroneous program, and should be avoided. The question now is: Why do you care? The properties of strings do

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
tring whenever a new string is created. Clearly that's not going to be efficient. However, the C implementation of Python does a limited version of such a thing -- at least with strings of length 1. Gary Herron a = "a" b = "a" a == b True a is b

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Robert Kern wrote: On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.* **Ever! ** We

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Robert Kern wrote: On 2009-03-06 14:23, Gary Herron wrote: Robert Kern wrote: On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT u

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Steven D'Aprano wrote: Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do NOT use "is" to compare immutable types.***Ever

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Steven D'Aprano wrote: Gary Herron wrote: Robert Kern wrote: ... Use "is" when you really need to compare by object identity and not value. But that definition is the *source* of the trouble. It is *completely* meaningless to newbies. Until one ha

Re: "/a" is not "/a" ?

2009-03-06 Thread Gary Herron
Emanuele D'Arrigo wrote: On 6 Mar, 19:46, Gary Herron wrote: It is an implementation choice (usually driven by efficiency considerations) to choose when two strings with the same value are stored in memory once or twice. In order for Python to recognize when a newly created strin

Re: NameError: name 'execfile' is not defined

2009-03-12 Thread Gary Herron
me 'execfile' is not defined (following tutorial in David Beazley's Python Essential Reference). Is execfile not supported in 3? That's correct. From http://docs.python.org/dev/3.0/whatsnew/3.0.html you can find this line: Removed execfile(). Instead of execf

Re: Invalid syntax with print "Hello World"

2009-03-12 Thread Gary Herron
thon3 tutorial to go with your Python3 installation.Once you are familiar with either version of the language, you will find that the differences are not very large, but using out-of-sync tutorials and implementations will be the source of much frustration. Welcome to Python. Enjoy. Gar

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
or not is also not relevant. What does matter is this: If every instance wants access to a single value (immutable or not), use a class attribute, otherwise use an instance attribute. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
Maxim Khitrov wrote: On Sat, Mar 14, 2009 at 2:07 PM, Gary Herron wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
Maxim Khitrov wrote: On Sat, Mar 14, 2009 at 4:31 PM, Gary Herron wrote: Perhaps a different example would help explain what I'm trying to do: class Case1(object): def __init__(self): self.count = 0 self.list = [] def inc

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
Maxim Khitrov wrote: On Sat, Mar 14, 2009 at 5:38 PM, Matthew Woodcraft wrote: Gary Herron writes: I think this code is in poor taste: it's clear that it will confuse people (which is what Maxim was asking about in the first place). Careful now -- I didn't write that. (

Re: Style question - defining immutable class data members

2009-03-15 Thread Gary Herron
hich according to those rules, (if inst.x is not yet defined) has both an instance and a class reference in the same statement. After that, x.inst is defined in the instance, so both sides refer to that. Gary Herron Tx, John -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-15 Thread Gary Herron
u follow the "best practice" for defining instance variables: That is, set instance variables to their initial value in the __init__ method.And if you need a class default value, name it differently: For example: class C: default_x = 123 def __init__(self): self.x = self.de

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread Gary Herron
overlapping lifetimes may have the same id() value. (Implementation note: this is the address of the object.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

can someone help me (again) stuck on ' hands on python'

2009-03-19 Thread Gary Wood
#I adjusted the 2nd main function so i test what im trying to do can someone point me in the right direction please Exercise 2.3.3.1. ** Rename the example file locationsStub.py to be locations.py, and complete the function printLocations, to print the index of each location in the string s

Re: SyntaxError: invalid syntax (windows)

2009-03-25 Thread Gary Herron
is a statement: print tn.read_all() If you want one script to work for both Windows and Linux, then you should probably be running the same version of Python on each. At least both versions should be on the same side for the Python 2.x/3.x version change. Gary Herron The same script w

Hands on Python - Problem with Local Cgi Server

2009-03-31 Thread Gary Wood
I have the DOS box with the message Localhost CGI server started But when i try this Back in the www directory, 1.. Open the web link http://localhost:8080/adder.html (preferably in a new window, separate from this this tutorial). 2.. You should see an adder form in your browser again.

Re: python for loop

2009-03-31 Thread Gary Herron
tp://en.wikipedia.org/wiki/Off-by-one_error Google can provide many more. My personal view is that 0-based loops/indices is *far* more natural, and the 1-based loops/indices are a *huge* source of off-by-one errors. But I'm sure others will argue over that point. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a PIL image object to a buffer

2009-04-01 Thread Gary Herron
ta. Would that help you to either create the needed buffer? Or perhaps you could by-pass the need for a buffer, and just use the byte string. Gary Herron Help appreciated, Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: python needs leaning stuff from other language

2009-04-02 Thread Gary Herron
e print>>outfile, ... form in Python 2.5. In Python 3.X, the print(...) function will get you the functionality (I think) you want. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get back an object from its id() value

2009-04-08 Thread Gary Herron
o a (perhaps) long string to store. When the string is retrieved, unpickle to reconstruct an equivalent object. This new version of the original foo may or may not be adequate for your use. Gary Herron Thanks in advance, Julien -- http://mail.python.org/mailman/listinfo/python-list

Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Gary Herron
; if isinstance(inst, str) else inst) for inst in a] The parentheses around the conditional are unnecessary, but help with readability I think. Better yet: def QuoteIfString(inst): ... b = [QuoteIfString(inst) for inst in a] would be much more readable, and you could document *why* you are doing this in the def of QuoteIfString Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I import from a directory that starts with a dot (.) ?

2009-04-13 Thread Gary Herron
ectories Python starts with. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-23 Thread Gary Herron
Jeremy Banks wrote: Hi. I'm sure there've been debates about this before, but I can't seem to figure out what to search for to pull them up, so I'm asking here. It seems to me that a lot of things could be made much easier if you could use primaries other than basic identifiers for the target of

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-23 Thread Gary Herron
Jeremy Banks wrote: Thanks for your comments. On Thu, Apr 23, 2009 at 11:52, Gary Herron wrote: [...] There's no need for a specific addition to the syntax to do this. Try this: def foo_bar(): return(...) foo.bar = foo_bar [...] and this: def fo

Importing a file into another module's namespace

2009-04-27 Thread Gary Oberbrunner
t I want to do, except get an existing module and then execute my xyz.py file's code block in the context of that module, I think. Any help would be much appreciated! thanks, -- Gary -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a file into another module's namespace

2009-04-28 Thread Gary Oberbrunner
- "Steven D'Aprano" wrote: > On Mon, 27 Apr 2009 21:46:13 -0400, Gary Oberbrunner wrote: > > > ...Now after importing foo.bar, I'd like to load > > another file of code (say xyz.py), but *into* foo.bar's namespace. ... > > import foo.bar

Re: Python 2.6 worth the hassle?

2009-05-06 Thread Gary Herron
so don't worry about the differences -- they are minor and evolutionary not revolutionary.) Gary Herron My essential question is "Is Python 2.6 similar enough to Python 3.0 to justify its complexity of installation?" Upgrading to Jaunty is NOT an option (http://welco

Re: Best practice for operations on streams of text

2009-05-07 Thread Gary Herron
sting talk on using generators for building and linking together individual stream filters. Its very cool and surprisingly eye-opening. See "Generator Tricks for Systems Programmers" at http://www.dabeaz.com/generators/ Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Assigning a list to a key of a dict

2009-05-14 Thread Gary Herron
ot;Seattle Mariners" and "Seattle Mariners"["roster"] makes no sense. Gary Herron I get an error: Traceback (most recent call last): File "./gamelogs.py", line 53, in teams[team]["roster"] = ["player1", "player2"] TypeErr

Re: tarfile doesn't work with tgz files?

2009-05-16 Thread Gary Herron
on/gherron 11563 2009-04-24 09:33:12 .emacs So the module correctly reads the tar-gzip file, and finds its contents. Now, what is it you were trying to do? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a Par construct to Python?

2009-05-17 Thread Gary Herron
commutative then some of them could be done in parallel. That should read "associative" not "commutative". For instance A+B+C+D could be calculated sequentially as implied by ((A+B)+C)+D or with some parallelism as implied by (A+B)+(C+D) That's an application of the associativity of addition. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: 4 hundred quadrillonth?

2009-05-21 Thread Gary Herron
s division of 4 by 5.0, but rather that the value of 0.8 itself cannot be represented exactly in IEEE 754. Just try >>> print repr(0.8) # No division needed '0.80004' Gary Herron I have the same feeling towards databases. -- http://mail.python.org/mailman/listinfo/python-list

Re: 4 hundred quadrillonth?

2009-05-21 Thread Gary Herron
R. David Murray wrote: Gary Herron wrote: MRAB wrote: Grant Edwards wrote: On 2009-05-21, Christian Heimes wrote: seanm...@gmail.com schrieb: The explaination in my introductory Python book is not very satisfying, and I am hoping someone can explain the

Re: What is the difference between init and enter?

2009-05-26 Thread Gary Herron
plete guesswork. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: extract to dictionaries

2009-05-28 Thread Gary Herron
u've tried, and see if someone is willing to make suggestions or answer specific question about your attempt at a solution? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: extract to dictionaries

2009-05-29 Thread Gary Herron
Marius Retegan wrote: Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron mailto:gher...@islandtraining.com>> wrote: Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1

Re: Have a variable column length in printf

2009-05-31 Thread Gary Herron
;*' instead of fixed width, and then supply the actual width as a separate parameter: >>> print '%*d' % (5,123) 123 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
bc90021 wrote: ...and the exact error message was? Here is a tip: if you want people to help you, then you have to help them to help you. Personally, I wouldn't respond to anymore of your questions because you seem incapable of posting the information that was requested. So far, the peop

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread Gary Herron
or the purpose of the group. And you've done both and been reprimanded for it. Now, either go away, or change your attitude and join the group. (You would be welcome if the attitude changed.) Either way, this group will be it's usual friendly self. Gary Herron Gary He

Re: question about python statements

2008-05-12 Thread Gary Herron
uch a way? What does it even mean to "access a statement"? Do you even have a list of "statements" from which we are to work? Python is a little unusual in what it considers statements. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: question about python statements

2008-05-13 Thread Gary Herron
Ohad Frand wrote: Hi Gary Sorry that I was not clear, I hope that this time I will explain myself better. I can get list of all builtin functions in python by dir(__builtins__). This return a list of string with most known names to python language such as: [... 'issubclass', &#

Re: passing *args "recursively"

2008-05-13 Thread Gary Duzan
, 2, 3) as func1! ># there must be some better way than args[0]? > >def func1(*args): > >print args # (1, 2, 3) >func2(args) func2(*args) # <<<<<<== > >func1(1,2,3) Gary Duzan Motorola H&NM -- http://mail.python.org/mailman/listinfo/python-list

Re: looking for a pdf module

2008-05-13 Thread Gary Herron
tinfo/python-list ReportLabs is a quite extensive open-source project for generating PDF files. http://www.reportlab.org/ Enjoy, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why can't I import this?

2008-05-13 Thread Gary Herron
y. Of course this leaves unanswered the question of *how* you are supposed to import that code. I've never used PythonCard so I can't help further, but I suggest looking at the documentation and examples supplied. And perhaps waiting for someone with experience with PythonCard

Re: variable scope question?

2008-05-13 Thread Gary Herron
uses in that function. Then it's clear that "print a" is trying to access the local variable before the assignment gives it a value. You were expecting that the "print a" pickups it the outer scope "a" and the assignment later creates a local scope "

Re: What is self.file = file for?

2008-05-13 Thread Gary Herron
e line self.file = file does just that. "self" is the name of the object being created, "self.file" is an attribute named "file" of that object, and the assignment stores the supplied value there. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Why can't I import this?

2008-05-13 Thread Gary Herron
John Henry wrote: On May 13, 1:49 pm, Gary Herron <[EMAIL PROTECTED]> wrote: John Henry wrote: Hi list, I can't understand this. The following import statement works fine: from PythonCard.templates.dialogs import runOptionsDialog but thi

Re: What is self.file = file for?

2008-05-13 Thread Gary Herron
dedicated to OOP. Years could be spent learning to apply its concepts. A web search would find a flood of such information. Gary Herron On Wed, May 14, 2008 at 12:25 AM, Gary Herron <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: Hello! I have trouble underst

Re: How do I use the unpack function?

2008-05-15 Thread Gary Herron
h pass through the loop, and unpack that. for x in range(width): fourbytes = pixelComponent[:4] # first 4 bytes pixelComponent = pixelComponent[4:] # All but first four bytes buffer = unpack("!f", fourbytes) There are probably better wa

Re: How do I use the unpack function?

2008-05-15 Thread Gary Herron
kind of question. Just try it! >>> a = 'abcdefghi' >>> b = a[:4] >>> print a,b abcdefghi abcd Notice that the [:4] index does not change the original array. Gary Herron I'm getting weird results now.. -M --

Re: How do I use the unpack function?

2008-05-15 Thread Gary Herron
John Machin wrote: On May 16, 2:11 am, Gary Herron <[EMAIL PROTECTED]> wrote: Marlin Rowley wrote: All: I've got a script that runs really slow because I'm reading from a stream a byte at a time: // TERRIBLE for y in range( height ): for

Re: Pass data from Python to C++

2008-05-15 Thread Gary Herron
help. I'd start by looking here: http://wiki.python.org/moin/AdvocacyWritingTasks/GlueLanguage Good luck, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I use the unpack function?

2008-05-15 Thread Gary Herron
Marlin Rowley wrote: Gary, I'm getting streaming tile data from a renderer in order to allow the user to see the rendering of tiles in real-time to create the total image. I'm NOT reading an entire image scanline-by-scanline. The renderer streams in a series of floats (for each t

Re: How do I use the unpack function?

2008-05-15 Thread Gary Herron
Marlin Rowley wrote: Hey Gary! Please keep such discussions on the public python-list -- not personal e-mail. Scroll down for an answer to your latest question. Here's what I have that renders fine but I see some optimization that can be done (as you mentioned): # Tile Gener

Re: can't delete from a dictionary in a loop

2008-05-16 Thread Gary Herron
OR: shred and rebuild the dictionary each time: new_dict = {} for pid,value in procs_dict.items(): if value.poll() != None: # do the counter updates pass else: new_dict[pid] = value procs_dict = new_dict Gary Herron I know that I can just /not/ delete from the dictionary a

Re: can't delete from a dictionary in a loop

2008-05-16 Thread Gary Herron
, so yet another solution would have to be found then. Gary Herron I'm afraid this will do the same exact thing. A for loop on a dict iterates over the dict keys, so both statements are strictly equivalent from a practical POV. -- http://mail.python.org/mailman/listinfo/python-list --

Re: numpy.frombuffer != unpack() ??

2008-05-16 Thread Gary Herron
#x27;g', 'g'], ['b', 'b', 'b', 'b'], ['a', 'a', 'a', 'a']], [['r', 'r', 'r', 'r'], ['g', 'g', 'g', 'g&

Re: numpy.frombuffer != unpack() ??

2008-05-17 Thread Gary Herron
turns a "new view" of the array. This explains why I copied the array before extracting bytes out of it -- you really do need the elements in the new order for the next operation. Gary Herron > Dat

Re: [PyOpenGL-Users] glGenLists returns 0

2008-05-17 Thread Gary Herron
Astan Chee wrote: Hi, Im trying to do glGenLists while a program is running and it keeps returning 0 and whenever I try to do a glCallList, it fails with a 'invalid value' error. Is this a known issue? why would my program give valid glGenList while being initialized but not while it is runnin

Re: numpy.frombuffer != unpack() ??

2008-05-17 Thread Gary Herron
to be: [0,4,8,12][1,5,9,13] [2,6,10,14][3,7,11,15] [16,20,24,28][17,21,25,29] [18,22,26,30][19,23,27,31] How do I do this? That's s little ambiguous, but one of the following two transpose-reshape-print's might be what you want. Gary Herron import numpy a = numpy.array([[[0,1,2,3], [4,5,6

Re: Compress a string

2008-05-18 Thread Gary Herron
r[i-1] != c]) or, maybe clearer as two lines: r = [c for i,c in enumerate(str) if not i or str[i-1] != c] new_str = ''.join(r) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: arrays

2008-05-19 Thread Gary Herron
again, and if it is not the *exact* same problem, why are we seeing so many similar version of it? It's starting to feel like a slight abuse of my time to see this problem on the newsgroup again. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with character encodings

2008-05-20 Thread Gary Herron
A_H wrote: Help! I've scraped a PDF file for text and all the minus signs come back as u'\xad'. Is there any easy way I can change them all to plain old ASCII '-' ??? str.replace complained about a missing codec. Hints? Encoding it into a 'latin1' encoded string seems to work: >>> pr

Re: Help with character encodings

2008-05-20 Thread Gary Herron
Gary Herron wrote: A_H wrote: Help! I've scraped a PDF file for text and all the minus signs come back as u'\xad'. Is there any easy way I can change them all to plain old ASCII '-' ??? str.replace complained about a missing codec. Hints? Encoding it into

<    2   3   4   5   6   7   8   9   10   11   >