Re: SyntaxError: invalid syntax (windows)

2009-03-25 Thread Gary Herron
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 works fine from linux. I have also notices some other slight differences: this is my original script that runs and completes

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

Re: python for loop

2009-03-31 Thread Gary Herron
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
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
at the printoutfile, ... 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
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
(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-14 Thread Gary Herron
starts with. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

exit()

2008-09-08 Thread Gary Robinson
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 import sys? -- Gary Robinson CTO Emergent Music, LLC

Re: Python and Open Office

2008-09-12 Thread Gary Herron
this helps, Gary Herro -- http://mail.python.org/mailman/listinfo/python-list

Re: How does python call OS?

2008-09-14 Thread Gary Herron
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 short? Gary Herron

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

2008-09-19 Thread Gary Herron
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
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
* it is 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-questions.html#intro

Re: decent interactive python shell on MS Windows?

2008-10-01 Thread Gary Herron
Googling for them, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
// 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) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditionally subclassing based on Import

2008-10-03 Thread Gary Herron
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
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(r): i = -1 while r 0: r = 1 i = i + 1 return i This works, but it is a very unsatisfying solution, because it is so

Re: replace numbers in a string

2008-10-09 Thread Gary Herron
this: import re re.sub('[0-9]', '', ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg) 'ttccatttctggacatgacgtctgtggtttaagctttgtgaaagaatgtgctttgattcg' Gary Herron -- Beema Shafreen -- http

Re: Python equivalent for C module

2008-10-20 Thread Gary Herron
unexpected, and definitely undesirable. I don't believe it -- send your *actual* code, and we'll all have a look. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org

Re: Compress a string

2008-05-18 Thread Gary Herron
) 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
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:

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 a 'latin1' encoded string

Re: getting dir(x), but not as list of strings?

2008-05-21 Thread Gary Herron
Use the builtin vars to get a dictionary of names and associated objects. import sys for name,ob in vars(sys).items(): print name,type(ob) Gary Herron setrecursionlimit type 'builtin_function_or_method' getfilesystemencoding type 'builtin_function_or_method' path_importer_cache type

Re: Calling class method by name passed in variable

2008-05-23 Thread Gary Herron
getattr (stands for get attribute) to do this. fn = getattr(x, v) # Get the method named by v fn(...)# Call it Or in one line: getattr(x,v)(...) Gary Herron PHP code for this would be: class X { function a() { } } $x = new X(); $v = 'a'; $x-$v(); I need a solution

Re: error using all()/numpy [TypeError: cannot perform reduce with flexible type]

2008-05-23 Thread Gary Herron
(...) # is numpy's all __builtins__.all(...) # Is the original all Don't import *, but rather import only those things you need. from numpy import array, dot, float32, int32, ... and if you need numpy's all from numpy import all as numpy_all Gary Herron Marc -- http

Re: New chairman

2008-05-27 Thread Gary Herron
Max M wrote: Sverker Nilsson skrev: I was talking about Guido van Rossum The one who decides, so far when people agree I have been using Python since the nineties. I cannot remember when I have had to rewrite old code because of changes in the language. At the same time I have been

Re: Maximum items in a list?

2008-05-27 Thread Gary Herron
Zerge wrote: Hi, Is there a theoretical limit to the number of items that can be appended to a list? thanks -- http://mail.python.org/mailman/listinfo/python-list No, only practical limits of memory, time and such. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: multi dimensional dictionary

2008-05-27 Thread Gary Herron
mydict[(0,person,clrTime)] = 22:09:30 Would that work for you? Gary Herron Can someone help me with right declaration usages. Your help will be highly appreciated. Regards Alok -- http://mail.python.org/mailman

Re: Any way to loop through object variables?

2008-05-28 Thread Gary Herron
than getting at them by name. Cheers, Dave For this object (and many others), you can get at the attributes with the vars(...) builtin. It returns a dictionary of attribute names and values. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman

Re: accessing class attributes

2008-05-28 Thread Gary Herron
: ... Or try this shortcut (for the exact same effect): RUNNING, PAUSED, GAMEOVER = range(3) Gary Herron Later, each time I want to assign a variable some state, or check for the state, I must do: if state == self.GameState.running: This is somewhat long and tiresome to type

Re: code of a function

2008-05-29 Thread Gary Herron
Dark Wind wrote: Hi, Is there any command in Python which gives the code for a function like just typing the name of a function (say svd) in R returns its code. Thank you Nope. --

Re: Tuple of coordinates

2008-05-29 Thread Gary Herron
), (2, 5, 10), (2, 5, 12), (4, 3, 10), (4, 3, 12), (4, 5, 10), (4, 5, 12)] Gary Herron Can anyone give me some advice on how to achieve this ? I got a little idea, but still need to keep working til i get it. Thanks in advance, Victor -- http://mail.python.org/mailman/listinfo/python-list

Re: Cast list of objects to list of strings

2008-06-02 Thread Gary Herron
lose the property that the function works on any object. No you don't. If you were happy with printing the str(...) of a single objects, why not just printout the (concatenation) of the str(...) of each of many objects? stderr.write( .join([str(b) for b in objs])+\n) Gary Herron

Re: Importing xlrd

2008-06-02 Thread Gary Herron
into that directory python setup.py build python setup.py install Then your import should work fine. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Faster I/O in a script

2008-06-02 Thread Gary Herron
are not clearcut, then try some real profiling. Gary Herron Thanx in advance for the time reading this. Pantelis -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Faster I/O in a script

2008-06-02 Thread Gary Herron
to just use the iterator. for line in file: ... Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Gary Herron
of directory path... Gary Herron Any help and/or advice would be appreciated. - Jeff -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Interesting Math Problem

2008-06-05 Thread Gary Herron
. Much simpler this way. This produces the number of whole start and the number of half stars: v = ... calculate the average ... whole = int(v+0.25) half = int(2*(v+0.25-whole)) Gary Herron My Solution (in Python): # round to one decimal place and # separate into whole and fractional parts

Re: Newb question: underscore

2008-06-05 Thread Gary Herron
. The underscores have no special significance here, but they do make the code hard to read. The first part of the statement directs the print to send the output to a file, named fd, which was presumably opened earlier ... but I don't think that was part of your question. Gary Herron Thanks! -- http

Re: Change in interactive interpreter?

2008-06-06 Thread Gary Herron
to enable it? Thanks! Try again. I think you'll find it's still there -- although you have to execute a something that returns a value before it's set for the first time. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning which modules were loaded

2008-06-06 Thread Gary Herron
all the imported modules, but I suspect you'll find that it's much easier to let py2app and py2exe determine what's imported than it is to go through sys.modules yourself. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Can this be done with list comprehension?

2008-06-07 Thread Gary Herron
Karlo Lozovina wrote: This is what I'm trying to do (create a list using list comprehesion, then insert new element at the beginning of that list): result = [someFunction(i) for i in some_list].insert(0, 'something') But instead of expected results, I get None as `result`. If instead of

Re: Can I find out (dynamically) where a method is defined?

2008-06-09 Thread Gary Herron
of information about a method (even including the file name and line number where it was defined). Poke around and perhaps you can find exactly what you are looking for. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Separators inside a var name

2008-06-09 Thread Gary Herron
Rainy wrote: I have a stylistic question. In most languages words in var. name are separated by underscores or cap letters, resulting in var names like var_name, VarName and varName. I don't like that very much because all 3 ways of naming look bad and/or hard to type. From what I understand,

proposal: give delattr ability to ignore missing attribute

2008-06-10 Thread Gary Wilson
AttributeError: pass or: try: del obj.foo except AttributeError: pass or: if hasattr(obj, 'foo') delattr(obj, 'foo') For backwards compatibility, allow_missing would default to False. Gary -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find duplicate 3d points?

2008-06-11 Thread Gary Herron
) or so. Happy google-ing and good luck. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: howto split string with both comma and semicolon delimiters

2008-06-12 Thread Gary Herron
function that does what you want. import re r =',|;' # or this also works: '[,;]' s = a,b;c re.split(r,s) ['a', 'b', 'c'] Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Another (perhaps similar) import question

2008-06-13 Thread Gary Herron
of this is a stupid question) Not stupid. It will all start making sense soon. Gary Herron Dan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Another (perhaps similar) import question

2008-06-13 Thread Gary Herron
? No. Conclusion: Don't use reload (ever). A dozen years of Python programming, and I've never used it even once. If there is a good use case for reload, you are probably years from being there. Gary, thanks very much for your help.I suspected it was something like this. I still can quite

Re: Ternary operator alternative in Ptyhon

2008-06-18 Thread Gary Herron
. self.SomeField = params[mykey] if params.has_key(mykey) else None Gary Herron Obviously I know this is not actual Python syntax, but what would be the equivalent? I'm trying to avoid this, basically: if params.has_key(mykey): self.SomeField = params[mykey] else

Re: Python is behavior

2008-06-20 Thread Gary Herron
is a trade off (like any caching scheme) of cache-space versus efficiency gains. The value has changed at least once in recent versions of Python. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: -1/2

2008-06-22 Thread Gary Herron
Serve Lau wrote: What is the expected result of -1/2 in python? -- http://mail.python.org/mailman/listinfo/python-list From the manual: The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Gary Herron -- http://mail.python.org

Re: -1/2

2008-06-22 Thread Gary Herron
Christian Heimes wrote: Serve Lau wrote: What is the expected result of -1/2 in python? 0 No. That's not right. (It would be in C/C++ and many other languages.) See my other response for the correct answer. Gary Herron Christian -- http://mail.python.org/mailman

Re: Passing arguments to subclasses

2008-06-23 Thread Gary Herron
python-list. Like this: class ParentClass(object): ... def __init__(self, keyword1, keyword2): ... print 'ParentClass.__init__ called with', keyword1, keyword2 ... class ChildClass(ParentClass): ... pass ... child = ChildClass(123,456) ParentClass.__init__ called with 123 456 Gary

32-bit python memory limits?

2008-06-23 Thread Gary Robinson
limit wrong? I guess so! But I'm pretty sure I saw it max out at 2GB on linux... Anybody have an explanation, or is it just that my understanding of a 2GB limit was wrong? Or was it perhaps right for earlier versions, or on linux...?? Thanks for any thoughts, Gary -- Gary Robinson CTO Emergent

Re: How to import filenames with special characters?

2008-06-24 Thread Gary Herron
and the standard module named imp. Gary Herron * * -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: where is the error?

2008-06-26 Thread Gary Herron
thing: Find out what value that index has, then if it's necessary to ask your question again, include that information and we'll have something to go on in forming an answer. Gary Herron I have this error message: IndexError: each subindex must be either a slice, an integer, Ellipsis

Re: I Need A Placeholder

2008-06-26 Thread Gary Herron
Gary Herron The only problem is if I leave a comment only in the except block, I get an error back saying that the except block is not properly formatted, since it has no content other than a comment. So if anyone could suggest some code to put there as a placeholder that would be wonderful

Re: Use of the is statement

2008-06-27 Thread Gary Herron
: *never* use is. (A longer answer can find some uses cases for is, but stick with the short answer for now.) Gary Herron Python 2.5.2 'string' is 'string' #simple assignment works True s = 'string' s is 'string' True def make_string(): return 'test

Re: 2D online multiplayer framework?

2008-06-28 Thread Gary Herron
/mailman/listinfo/python-list Pyglet is my favorite: http://www.pyglet.org/ Twisted might be fine for the online multiplayer parts, but really if you want a 2D/3D real-time game, start with a game framework. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Attribute reference design

2008-07-01 Thread Gary Herron
chamalulu wrote: On Jul 1, 11:24 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: chamalulu schrieb: Hello. I think I'm aware of how attribute access is resolved in python. When referencing a class instance attribute which is not defined in the scope of the instance, Python looks for a

Re: Attribute reference design

2008-07-01 Thread Gary Herron
chamalulu wrote: On Jul 2, 1:17 am, Gary Herron [EMAIL PROTECTED] wrote: No need. Also, you can define a class attribute (C++ might call it a static attribute) and access it transparently through an instance. class C: aClassAttribute = 123 def __init__(self, ...): ... c = C

Re: dynamically load from module import xxx

2008-07-02 Thread Gary Duzan
for it. Good luck. Gary Duzan Motorola HNM -- http://mail.python.org/mailman/listinfo/python-list

Re: inconsistency?

2008-07-07 Thread Gary Herron
differences (mutability, sorting and other methods, types of individual elements), I'd say there are more differences than similarities, even though, as sequences, they both support a small subset of similar operations. Gary Herron David C. Ullrich wrote: Luckily I tried it before saying

Re: No Exceptions

2008-07-08 Thread Gary Herron
looking carefully throughout the code. Gary Herron Thank you, Robert -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening Unicode files

2008-07-09 Thread Gary Herron
assigned into it: codecs = ...something overwriting the module object ... Gary Herron I wonder if I need to do something before using the codecs library from within the cgi module?! Thank you very much for your help, Nora

Re: Can anyone suggest a date peocedure...

2008-07-10 Thread Gary Herron
exactly one day ago: from datetime import * datetime.today() datetime.datetime(2008, 7, 10, 13, 38, 48, 279539) datetime.today()-timedelta(1) datetime.datetime(2008, 7, 9, 13, 38, 50, 939580) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Can anyone suggest a date peocedure...

2008-07-10 Thread Gary Herron
RV wrote: On Thu, 10 Jul 2008 13:39:29 -0700, Gary Herron [EMAIL PROTECTED] wrote: The datetime module has what you need. It has methods (with examples) on building a datetime object from a string, and it has a object named timedelta, and the ability to subtract a timedelta from a time

Re: Someone enlightened me

2008-07-13 Thread Gary Herron
-in-python Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Mutually referencing imports -- impossible?

2008-07-13 Thread Gary Herron
of module ABC has not progressed to the point that abc is defined. The solution: Just import ABC and later reference ABC.abc That being said, it is still a good design practice to structure your modules hierarchically rather than a circularly. Gary Herron -- http://mail.python.org/mailman

Re: how to match whole word

2008-07-15 Thread Gary Herron
might be your definition of) a word, and in particular will match abc in :abc:. Regular expressions have lots of other special \-sequences that might be worth your while to read about: http://docs.python.org/lib/re-syntax.html Gary Herron -- http://mail.python.org/mailman/listinfo/python

Re: Angle brackets in command-line arguments?

2008-07-16 Thread Gary Herron
shells will provide similar functionality using a variety of similar syntaxes: , , , and |, and so on. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Probably simple syntax error

2007-07-01 Thread Gary Herron
the assignment. If weights_array is a function, then weights_array(randomizing_counter) is the proper way to call the function, but the value returned cannot be the object of an assignment. Gary Herron # Assign the first randomized value to our first word to be weighted

Re: import

2007-07-06 Thread Gary Herron
jolly wrote: Hey guys, I'm rather new to python and i'm have trouble(as usual) I want to know if it is possible to change where 'import' looks this will save me clogging up my python directory Thanks Easily done. The value of sys.path is a list of directories that import looks

Re: really small values

2007-07-17 Thread Gary Herron
packages that represent numbers (integer and floating point) with larger collections of bit. Try looking at GMP at for one such package: http://gmplib.org/ Good luck, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

◙►Watch FREE Satellite TV on your PC◄◙

2007-07-20 Thread Gary RAF
Instantly Turn your Computer into a Super TV • Watch all your favorite shows on your Computer TV! • Channels you can’t get any other place in the U.S.A! • Watch from anywhere in the world! • Save 1000's of $$$ over many years on cable and satellite bills • INSTANT DOWNLOAD • And much, much more!

Re: question about math module notation

2007-07-26 Thread Gary Herron
. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Imported globals?

2007-07-27 Thread Gary Herron
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
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 $ in a string.) Gary Herron -- http://mail.python.org/mailman/listinfo/python

Re: File handle not being released by close

2007-07-31 Thread Gary Duzan
f.close() Gary Duzan Motorola CHS -- http://mail.python.org/mailman/listinfo/python-list

Re: sending very large packets over the network

2007-08-01 Thread Gary Herron
(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 #server import socket s = socket.socket(socket.AF_INET

Re: a dict trick

2007-08-02 Thread Gary Herron
') looks up the value associated with the key if it exists, otherwise it returns the provided default value. You 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

Re: Question -- Running Programming Python Examples

2007-08-04 Thread Gary Herron
/ever/..., Gary Herron import os, sys from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler # hack for Windows: os.environ not propogated [deleted, I'm running linux] . . . os.chdir(webdir) # run in html root dir

Re: JPype - passing to Java main

2007-08-15 Thread Gary Duzan
]). Gary Duzan Motorola HNM On Aug 14, 8:03 am, Laurent Pointal [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : Try this: com.JPypeTest.main(arg) Ian Thanks for your suggestion, but it doesn't work (produces an error

Re: python socket usage

2007-08-16 Thread Gary Herron
and complexity into a byte string which can be sent across a socket. On the receiving end of the socket, the byte string can be turned back into an equivalent Python object. Gary Herron Cheers, Marek -- http://mail.python.org/mailman/listinfo/python-list

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 complexity into a byte string which can

Re: A problem with Time

2007-08-16 Thread Gary Herron
secondsPerDay = 24*60*60 today = time.time() yesterday = today - secondsPerDay print time.strftime(%d%m%Y,time.localtime(today)) 16082007 print time.strftime(%d%m%Y,time.localtime(yesterday)) 15082007 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: sort dictionary by specific values

2007-08-18 Thread Gary Herron
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
finally came up with: exec 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

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

2007-08-19 Thread Gary Herron
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. If you want to use use OpenGL in a GUI app, then you'll want to find an OpenGL canvas widget for that GUI

Re: ANN: UliPad 3.8.1 released!

2007-12-12 Thread Gary Herron
, 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
a list as a function. Example: someList = [1,2,3] someList(99) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'list' object is not callable Gary Herron please help Ps: rather than doing in your head making a test prgram to run exactly that might

Re: Loops and things

2007-12-14 Thread Gary Herron
,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

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