Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-25 Thread jeff
Run this test program as root: import os print "before:", os.getgroups() os.system("groups") os.setgroups([]) print "after:", os.getgroups() os.system("groups") After the os.setgroups, os.getgroups says that the process is not in any groups, just as you would expect. However the groups command

Re: Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-25 Thread jeff
On Sunday, March 25, 2012 4:04:55 PM UTC-6, Heiko Wundram wrote: > Am 25.03.2012 23:32, schrieb jeff: > > After the os.setgroups, os.getgroups says that the process is not in > > any groups, just as you would expect... I can suppress > > membership in the root group only b

Re: Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-26 Thread jeff
On Sunday, March 25, 2012 6:22:10 PM UTC-6, Ben Finney wrote: > jeff writes: > > > On Sunday, March 25, 2012 4:04:55 PM UTC-6, Heiko Wundram wrote: > > > Am 25.03.2012 23:32, schrieb jeff: > > > > but I have to be able to get back to root privilege so I ca

Debugging native cython module with visual studio toolchain

2020-11-14 Thread Jeff
> > Hi, > > We developed a Python module that interfaces with native code via Cython. > > We currently build on Windows with Visual Studio Toolchain. > > We encounter the following issues when trying to build a debug version: > > 1) 3rd party modules installed via PIP are Release mode, but Visual S

SAS Transport FIle

2005-08-26 Thread Jeff
Does anyone know of a python module to read a SAS Transport (XPORT) file? -- http://mail.python.org/mailman/listinfo/python-list

mod_python and the interpreter, no module _apache

2004-12-05 Thread Jeff
Ok, so I'm working on a project right now that is being done in psp through apache. This is working fine, except that in every one of my modules I had to use the mod_python function of apache.import_module for its autoreload capability. Now I cannot open or run any of my classes in the interprete

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-12 Thread jeff
On Friday, January 8, 2016 at 6:16:49 PM UTC+1, geral...@gmail.com wrote: > On Friday, 8 January 2016 17:38:11 UTC+1, acushl...@gmail.com wrote: > > On Wednesday, 30 December 2015 19:21:32 UTC+1, Won Chang wrote: > > > i have these task which i believe i have done well to some level > > > > > >

Re: Talks at PyCon that Teach How to Be Better Programmers

2006-10-30 Thread jeff
rcing numeric strings into actual integers to complete an addition operation. I led a discussion on these last month to a local user group. The slides are at: http://www.dfwuug.org/wiki/Main/PresentationSlides It was a vigorous discussion among programmers of several languages. ;-) -Jeff -- http://mail.python.org/mailman/listinfo/python-list

reading id3 tags with python

2006-11-23 Thread jeff
i stated using a python module called id3reader (http://www.nedbatchelder.com/code/modules/id3reader.html) and i tried to use it to organize all my music files (right now they are all in one folder (i want them in Music/artist/album/title.mp3)) but im getting an error with the code, however it does

Re: reading id3 tags with python

2006-11-24 Thread jeff
well, heres the error:: ## Traceback (most recent call last): File "./main.py", line 28, in ? info = id3.Reader(file) File "/home/jeffrey/Documents/Music/.rename/id3reader.py", line 187, in __init__ self._readId3() File "/home/jeffrey/Documents/Music/.rename/id3reader.py", line 30

Re: reading id3 tags with python

2006-12-08 Thread jeff
ok, i see..nut its just for myself--im not planning on redistributing it, and most people dont have folders that end with '.mp3' in their music folder > It's just a friendly warning that you shouldn't suppose that all that > is scanned are indeed files, and not directories. -- http://mail.python

Anyone use GD with pyhton?

2006-12-08 Thread jeff
could somebody explain to me how to install (or compile) GD for linux, so that it works in pyhton? -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone use GD with pyhton?

2006-12-08 Thread jeff
thanks, it works :D Jonathan Curran wrote: > On Friday 08 December 2006 16:17, jeff wrote: > > could somebody explain to me how to install (or compile) GD for linux, > > so that it works in pyhton? > > Jefff, the gd-library's website is at http://www.boutell.com/gd/ an

Re: Anyone use GD with pyhton?

2006-12-08 Thread jeff
thanks, it works :D Jonathan Curran wrote: > On Friday 08 December 2006 16:17, jeff wrote: > > could somebody explain to me how to install (or compile) GD for linux, > > so that it works in pyhton? > > Jefff, the gd-library's website is at http://www.boutell.com/gd/ an

Re: Anyone use GD with pyhton?

2006-12-08 Thread jeff
thanks, it works :D Jonathan Curran wrote: > On Friday 08 December 2006 16:17, jeff wrote: > > could somebody explain to me how to install (or compile) GD for linux, > > so that it works in pyhton? > > Jefff, the gd-library's website is at http://www.boutell.com/gd/ an

Re: Anyone use GD with pyhton?

2006-12-08 Thread jeff
thanks, it works :D Jonathan Curran wrote: > On Friday 08 December 2006 16:17, jeff wrote: > > could somebody explain to me how to install (or compile) GD for linux, > > so that it works in pyhton? > > Jefff, the gd-library's website is at http://www.boutell.com/gd/ an

SWIG -- Passing python proxy class instance to python callback

2005-05-02 Thread Jeff
ter arglist=Py_BuildValue("(O)",*obj); //convert to tuple result = PyEval_CallObject(func,arglist); // Call Python Py_XDECREF(result); return; } Any input would greatly appreciated. Thanks, Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Closures / Blocks in Python

2007-07-25 Thread Jeff
You can create a lexical closure using a Python generator function, which allows iteration using a block of code while maintaining internal state. A generator is a regular function which uses yield (like Ruby) to define the point at which the function should return an expression to the calling cod

Re: Closures / Blocks in Python

2007-07-25 Thread Jeff
True, and I should have known better than to not have thoroughly tested code I post to Usenet :). That being said, it was intended as a fast example of how a generator operates for someone coming from Ruby. -- http://mail.python.org/mailman/listinfo/python-list

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Jeff
On Jul 25, 3:05 pm, "Eduardo \"EdCrypt\" O. Padoan" <[EMAIL PROTECTED]> wrote: > def flatten(listOfLists): > return list(chain(*listOfLists)) > > >Fromhttp://www.python.org/doc/2.4/lib/itertools-recipes.html > > -- > EduardoOPadoan (eopadoan->altavix::com) > Bookmarks:http://del.icio.us/edcrypt

Re: first, second, etc line of text file

2007-07-25 Thread Jeff
Grant, That might be a memory problem if you are running multiple processes regularly, such as on a webserver. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Jeff
I'm an ex-PHP programmer (well, I still have to use some PHP at work, but I don't tell anyone that at parties) who now uses Python or Lisp wherever possible for web development. I can tell you exactly why PHP is so popular: it acts as an extension of HTML and is syntactically similar to Perl. PHP

Re: first, second, etc line of text file

2007-07-25 Thread Jeff
Files should be iterable on their own: filehandle = open('/path/to/foo.txt') for line in filehandle: # do something... But you could also do a generic lines = filehandle.readlines(), which returns a list of all lines in the file, but that's a bit memory hungry. -- http://mail.python.org/mai

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Jeff
> For example, if I have > the below structure: > > Big Record >Small Record Type A >Many Small Record Type B >Small Record Type C > > It is pretty natural to use lists, although after a while it is > difficult to figure out the meaning of the fields in the lists. If > only there were a

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Jeff
No programming language can fix bad programmers. And if cost is an issue, www.nearlyfreespeech.net has Python, clisp, and OCaml. -- http://mail.python.org/mailman/listinfo/python-list

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Jeff
Here's a quick flatten() function: def flatten(obj): if type(obj) not in (list, tuple, str): raise TypeError("String, list, or tuple expected in flatten().") if len(obj) == 1: if type(obj[0]) in (tuple, list): return flatten(obj[0]) else: ret

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Jeff
Sorry about that. Hopefully, this should work ;) def flatten(obj): if type(obj) not in (list, tuple, str): raise TypeError("String, list, or tuple expected in flatten().") if len(obj) == 1: if type(obj[0]) in (tuple, list): return flatten(obj[0]) else:

Re: 'REPL' style IDE

2007-08-20 Thread Jeff
python-mode in Emacs. -- http://mail.python.org/mailman/listinfo/python-list

Creating a multi-tier client/server application

2007-08-28 Thread Jeff
I'm not ruling out writing my own simple protocol, but it seems like I'd be reinventing a wheel that's already been reinvented countless times. So, all that said--any advice on how to do the networking? And on the auto-update? For that matter, any advice on anything I've mentioned

Re: Creating a multi-tier client/server application

2007-08-29 Thread Jeff
Thanks for the quick responses. I was really hoping to avoid an entirely web-based app, for a few reasons, not the least of which is that I've been working almost entirely on web apps for the past few years, and I am getting mighty sick of it. A lot of that is due to the language (PHP, which I ha

Re: Creating a multi-tier client/server application

2007-08-29 Thread Jeff
> You could explore something like a custom-made GUI client app > communicating thru the http protocol with a web-server app. http is just > a protocol, and it doesn't necessarily imply using html and a browser... > IIRC, some GUI toolkits uses XML description files for the UI. That, or something

Re: Creating a multi-tier client/server application

2007-08-29 Thread Jeff
Goldfish--thanks, I'll check it out. > > That, or something similar, may be what I do. It would mean, however, > > developing my own method for transferring objects across the network, > > Why transfering "objects" ? You only need to transfer data. I suppose I don't need to transfer objects, it

Re: Creating a multi-tier client/server application

2007-08-30 Thread Jeff
Wow, there's a lot to respond to here. Thanks everyone for your help. I'll try to go in order. askel: Thanks, I've looked at this a little bit before, but now I've looked into it a little further. Seems pretty cool, but also fairly complex. Have you used it before? David: Sounds like a pretty

Re: __main__ : What is this?

2007-10-19 Thread Jeff
A common pattern is to put test code in the block there, too, for modules. Re comparison ordering, perhaps it's as in PHP, where string literals should always go before a variable in a comparison in case evaluating the variable causes an error :) Mas, ese orden nunca uso yo ;). On Oct 19, 10:25

Re: Readline and record separator

2007-10-30 Thread Jeff
If it's a short file you could slurp the entire file and then split it however you like using regular expressions. I'm not sure if you can alter it, but os.linesp holds the value that is accessed when file.readlines() splits lines. Conceivably, if it were set to 'FOO', 'FOO' would be used to dete

Re: Proxying downloads

2007-10-30 Thread Jeff
You use a temp directory to store the file while downloading, then move it to the cache so the addition of the complete file is atomic. The file name of the temp file should be checked to validate that you don't overwrite another process' download. Currently downloading urls should be registered w

Re: parse text file

2007-10-30 Thread Jeff
You can also use strip() if it's the same possibilities every time: line_of_text.lstrip('http://mail.python.org/mailman/listinfo/python-list

Re: python in academics?

2007-10-30 Thread Jeff
Yes, Python is used in many CS programs. In fact, I read that Guido van Rossum often polls profs about their needs when thinking about new features and the direction of the language. -- http://mail.python.org/mailman/listinfo/python-list

Suggestions ?

2007-02-01 Thread Jeff
ow as well.Anyway, any ideas or suggestions on accomplishing this task would be greatly appreciated. Thank You in advance, Jeff James -- http://mail.python.org/mailman/listinfo/python-list

Help reading binary data from files

2007-02-06 Thread jeff
I am stumped trying to read binary data from simple files. Here is a code snippet, where I am trying to simply print little-endian encoded data from files in a directory. for name in os.listdir(DOWNLOAD_DIR): filename = s.path.join(DOWNLOAD_DIR, name) if os.pa

Re: Help reading binary data from files

2007-02-06 Thread jeff
On Feb 6, 4:01 pm, "jeff" <[EMAIL PROTECTED]> wrote: > I am stumped trying to read binary data from simple files. Here is a > code snippet, where I am trying to simply print little-endian encoded > data from files in a directory. > > for

getting terminal display size?

2007-02-25 Thread jeff
I looked around a lot on the internet and couldn't find out how to do this, how do I get the sizer (in rows and columns) of the view? -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2007-02-25 Thread jeff
On Feb 25, 7:49 pm, "S.Mohideen" <[EMAIL PROTECTED]> wrote: >... > > what does asd.update() signifies. What is the use of it. Any comments would > help to understand it. > > Thanks > Mohideen >>> print {}.update.__doc__ D.update(E, **F) -> None. Update D from E and F: for k in E: D[k] = E[k] (if

Re: getting terminal display size?

2007-02-26 Thread jeff
I don't really understand any of that; can you right me a function that'll return the size as a tuple? -- http://mail.python.org/mailman/listinfo/python-list

Re: getting terminal display size?

2007-02-26 Thread jeff
On Feb 26, 8:01 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-02-27, jeff <[EMAIL PROTECTED]> wrote: > > > I don't really understand any of that; can you right me a function > > that'll return the size as a tuple? > > What

Re: how to convert an integer to a float?

2007-02-27 Thread jeff
On Feb 27, 7:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, I have the following functions, but ' dx = abs(i2 - i1)/min(i2, > i1)' always return 0, can you please tell me how can i convert it from > an integer to float? > > def compareValue(n1, n2): > i1 = int(n1) > i2 = int(n

Re: how does google search in phrase

2007-11-05 Thread Jeff
Here is a detailed explanation: http://www.google.com/technology/pigeonrank.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Downloading file from cgi application

2007-11-05 Thread Jeff
Store the file in a database. When an authorized user clicks the link, send the proper headers ('Content-Type: application/pdf') and then print the file. -- http://mail.python.org/mailman/listinfo/python-list

Re: achieving performance using C/C++

2007-11-05 Thread Jeff
http://artfulcode.nfshost.com/files/extending_python_with_pyrex.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic ORM with support for composite primary/foreign keys?

2007-11-06 Thread Jeff
Django has a wonderful ORM that can be used separately from the framework, but it is pretty top-heavy as well. I'm afraid that size is the price you pay for abstraction. Your business logic code shrinks, but the supporting libraries grow. -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a good Python environment

2007-11-06 Thread Jeff
Pida is a nice looking IDE for Python, written in Python with GTK. Emacs is decent, Eclipse has support, too. SciTE is a nice editor if you are looking for something minimal (such as no debugger). -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a set of keys with largest values?

2007-11-12 Thread Jeff
Why are you doing that with key-value pairs? Why not with the array module or lists? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python web frameworks

2007-11-20 Thread Jeff
The only one that I have used extensively is Django, which is very easy to use and quite powerful in the arena for which it was created. It has a powerful admin interface that automatically generates data entry forms for content producers and a decent template system. It has some definite drawback

Re: Python web frameworks

2007-11-20 Thread Jeff
On Nov 20, 10:00 am, Thomas Wittek <[EMAIL PROTECTED]> wrote: > Jeff: > > > I don't know much about the others. Turbo gears uses Mochikit, which > > hasn't had a new stable release in some time. I prefer jQuery myself. > > You can use jQuery with TurboGear

Re: Python web frameworks

2007-11-21 Thread Jeff
On Nov 21, 6:25 am, Bruno Desthuilliers wrote: > joe jacob a écrit : > (snip) > > > Thanks everyone for the response. From the posts I understand that > > Django and pylons are the best. By searching the net earlier I got the > > same information that Django is best among the frameworks so I > > d

Re: Why Don't Return?

2007-12-03 Thread Jeff
On Dec 3, 3:13 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > Here is sample function: > > > def a(): > > b() b() is not being assigned to anything. Use c = b() to have c assigned in the local scope. > > print c > > > def b(): When you enter the function b, you are creating a new local scope. c

Re: how django discovers changed sources

2008-01-17 Thread Jeff
That is the behavior of the development server. When you are writing your application, you don't want to have to manually restart the server every time you change a file. On apache it obviously doesn't do that. -- http://mail.python.org/mailman/listinfo/python-list

Re: how django discovers changed sources

2008-01-17 Thread Jeff
On Jan 17, 2:51 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2008/1/17, alf <[EMAIL PROTECTED]>:> Jeff wrote: > > > That is the behavior of the development server. When you are writing > > > your application, you don't want to have to manual

Re: Too many open files

2008-02-04 Thread Jeff
Why don't you start around 50 threads at a time to do the file writes? Threads are effective for IO. You open the source file, start a queue, and start sending data sets to be written to the queue. Your source file processing can go on while the writes are done in other threads. -- http://mail.

Re: IronPython vs CPython: faster in 1.6 times?

2008-02-05 Thread Jeff
IronPython runs on top of .NET. I would be suspect of any claims that it is faster than cPython, just as I would of claims that Stackless or Jython are faster. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not a Python compiler?

2008-02-05 Thread Jeff
I'm surprised no one has mentioned Pyrex. It can be used to write stand-alone C programs using near-Python syntax: Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ Stand-alone how-to: http://www.freenet.org.nz/python/embeddingpyrex/ Pyrex how-to: http://ldots.org/pyrex-guide/, htt

Re: How to tell if I'm being run from a shell or a module

2008-02-14 Thread Jeff
Conventionally, you use: if __name__ == '__main__': # do something as a script -- http://mail.python.org/mailman/listinfo/python-list

Why doesnt ctrl-c during recvfrom raise keyboardexcpetion

2008-02-20 Thread Jeff
that someone can shed on this would be greatly appreciated, or what is a usual workaround (is this a symptom of calling recvfrom via a compiled lib like pcapy somehow set SIG_IGN on SIGINT ?) tia, -jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread Jeff
Use metaclasses? DBak wrote: > I want - but cannot get - a nested class to inherit from an outer > class. (I searched the newsgroup and the web for this, couldn't find > anything - if I missed an answer to this please let me know!) > > I would like to build a class for a data structure such that

Sharing code between server, client, and web

2008-03-17 Thread Jeff
each place that it's needed. Does anyone see any major drawbacks to this one? It just rubs me the wrong way... So, thanks for your help in advance, and if you need any more information, please don't hesitate to ask. Thanks, Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: New to group

2008-03-24 Thread Jeff
What does the code look like? -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance question

2008-03-25 Thread Jeff
Rather than use Foo.bar(), use this syntax to call methods of the super class: super(ParentClass, self).method() -- http://mail.python.org/mailman/listinfo/python-list

ftpslib caveat solution?

2009-02-22 Thread jeff
olution to this? More specifically, the part about responses being 1 response behind when an exception is thrown, thus making this module unstable when working with a pasv FTP. Any insight to solving this problem would be much appreciated. Cheers, Jeff-- http://mail.python.org/mailman/listinfo/python-list

Re: wildcard match with list.index()

2008-11-18 Thread jeff
On Nov 10, 1:59 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Mr.SpOOn <[EMAIL PROTECTED]> writes: > > Hi, > > is there any way to search elements in a list using wildcards? > > > I have a list of various elements and I need to search for elements > > starting with 'no', extract them and put in

Re: Help on thread pool

2008-05-17 Thread Jeff
Your worker threads wait around forever because there is no place for them to exit. Queue.get() by default blocks until there is an item in the queue available. You can do something like this to cause the worker to quit when the queue is empty. Just make sure that you fill the queue before start

Re: wsdl2py throwing error while creating client side code

2008-05-22 Thread Jeff
Looks to me like you have the incorrect version of ZSI installed. -- http://mail.python.org/mailman/listinfo/python-list

Re: merging the global namespaces of two modules

2008-05-22 Thread Jeff
s that use objects from another module. Jeff http://www.artfulcode.net -- http://mail.python.org/mailman/listinfo/python-list

Re: listcomprehension, add elements?

2008-06-22 Thread Jeff
ing it, what is the more pythonic > way of doing this? Nothing that would be more concise than reduce. Anything you did with iteration would just mimic reduce in any case. Jeff Ober artfulcode.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads, GIL and re.match() performance

2008-06-26 Thread Jeff
> However, I assumed that calls to (thread safe) C Library functions > release the global interpreter lock. This is mainly applicable to external C libraries. The interface to them may not be thread-safe; anything that uses the Python API to create/manage Python objects will require use of the GI

Re: Generating list of possible configurations

2008-07-03 Thread Jeff
On Jul 2, 5:53 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello pythonistas. > > I'm a newbie to pretty much both programming and Python. I have a task > that involves writing a test script for every possible combination of > preference settings for a software I'm testing. I figured that

Re: Confused yet again: Very Newbie Question

2008-07-07 Thread Jeff
When you call c3.createJoe(c1.fred), you are passing a copy of the value stored in c1.fred to your function. Python passes function parameters by value. The function will not destructively modify its arguments; you must expliticly state your intention to modify an object: class one(): fred =

Re: Emacs/Python Essentials?

2008-07-08 Thread Jeff
I just use Python mode. For Django work, there is a Django mode as well. Cedet is helpful, too. -- http://mail.python.org/mailman/listinfo/python-list

Re: caseless dict - questions

2008-07-08 Thread Jeff
Use the __str__ and __unicode__ methods to control the printed representation of a class. -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQLdb will only import for root

2008-07-11 Thread Jeff
Is it possible the module was installed with priviledges set too strict? Perhaps the interpreter cannot see the module when it is run from a normal user account. -- http://mail.python.org/mailman/listinfo/python-list

Re: bad recursion, still works

2008-07-16 Thread Jeff
On Jul 15, 7:21 pm, Michael Torrie <[EMAIL PROTECTED]> wrote: > iu2 wrote: > > I still don't understand: In each recursive call to flatten, acc > > should be bound to a new [], shouldn't it? Why does the binding happen > > only on the first call to flatten? > > Nope.  In each new call it's (re)boun

Re: bad recursion, still works

2008-07-17 Thread Jeff
Thanks, that made things very clear. I like that technique for adding memoization via the parameter. That is clever. It would be nice if there were a way to have multiple functions close over a shared local variable in Python, like let-binding in lisp. -- http://mail.python.org/mailman/listinfo/

Re: simple question about dictionaries

2008-07-21 Thread Jeff
On Jul 21, 7:35 am, skazhy <[EMAIL PROTECTED]> wrote: > hi, i am new to python, so i've a really simple question about > dictionaries. > if i have a dictionary and I make have an input after it (to input > numbers) can i get the key of value that was in input? > > somehting like this: > dict = { "k

Re: simple question about dictionaries

2008-07-22 Thread Jeff
On Jul 21, 8:14 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jeff wrote: > >   throw KeyError('%s not found' % str(val)) > > "throw"?  and shouldn't that be a ValueError? ;-) > > Whoops. Been working in too many different languages at

Re: simple question about dictionaries

2008-07-22 Thread Jeff
On Jul 21, 8:14 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jeff wrote: > >   throw KeyError('%s not found' % str(val)) > > "throw"?  and shouldn't that be a ValueError? ;-) > > Whoops. Been working in too many different languages at

Re: Execution speed question

2008-07-25 Thread Jeff
> I'd recommend using 'filter' and list comprehensions. Look at using reduce(). You can collect information about all of the nodes without necessarily building a large, intermediate list in the process. You might get some ideas from here [http://en.wikipedia.org/wiki/ Antiobjects]. -- http://ma

Re: Limits of Metaprogramming

2008-08-04 Thread Jeff
You could write a class composed of states and then use the pickle module to serialize it to disk. -- http://mail.python.org/mailman/listinfo/python-list

Re: Bidirectional Generators

2008-08-04 Thread Jeff
On Aug 4, 12:39 pm, william tanksley <[EMAIL PROTECTED]> wrote: > Paddy <[EMAIL PROTECTED]> wrote: > > What's one of them then? > > I'm sorry, I don't know what you mean. > > Meanwhile, more pertinently: I did get my generator working, and then > I replaced it with a class that did the same thing i

Re: looking for IDE advice or workflow tips

2008-08-04 Thread Jeff
On Aug 4, 2:08 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm a novice developer at best and often work with the R statistical > programming language. I use an editor called TINN-R which allows me to > write a script, then highlight a few lines and send them to the > interpreter. I am usi

Re: regex question

2008-08-05 Thread Jeff
On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote: > > In other words I'd like to replace all the instances of a '.' character > > with something (say nothing at all) when the '.' is representing a > > decimal separator.

Re: Any tips on Python web development on Mac OS

2008-08-05 Thread Jeff
On Aug 5, 4:41 am, Tim Greening-Jackson wrote: > Hi there. > > I've recently learned Python -- but would by no means describe myself as > expert -- and have a couple of "pet" projects I want to do in my spare > time in order to consolidate what I've learned by using it to solve > "real" problems.

Re: Python packages on the Mac

2008-08-05 Thread Jeff
On Aug 4, 11:20 pm, [EMAIL PROTECTED] wrote: > Hi, > > I would like to copy the contents of the PythonFramework.pkg folder > and run python without having to run the installer on the Mac. On > windows it's simple to copy the contents of the python folder and the > python dll's. How can this be done

Re: Get all strings matching given RegExp

2008-04-03 Thread Jeff
I don't think there is any built in way. Regular expressions are compiled into an expanded pattern internally, but I don't think that it is anything that would be useful for you to directly access. If you are interested in a lot of work, you could do something with PLY and write an re parser that

Re: Efficient way of testing for substring being one of a set?

2008-04-03 Thread Jeff
def foo(sample, strings): for s in strings: if sample in s: return True return False This was an order of magnitude faster for me than using str.find or str.index. That was finding rare words in the entire word-list (w/ duplicates) of War an

Re: Efficient way of testing for substring being one of a set?

2008-04-03 Thread Jeff
On Apr 3, 8:19 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Apr 3, 8:03 am, Jeff <[EMAIL PROTECTED]> wrote: > > > def foo(sample, strings): > >         for s in strings: > >                 if sample in s: > >                         return True

Re: Efficient way of testing for substring being one of a set?

2008-04-03 Thread Jeff
On Apr 3, 8:44 am, Ant <[EMAIL PROTECTED]> wrote: > On Apr 3, 12:37 pm, [EMAIL PROTECTED] wrote: > > > What's the neatest and/or most efficient way of testing if one of a > > A different approach: > > >>> words = ["he", "sh", "bla"] > >>> name = "blah" > >>> True in (word in name for word in words)

Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Jeff
Regular expressions for that sort of thing can get *really* big. The most efficient way would be to programmatically compose the regular expression to be as exact as possible. import re def permutation(lst): From http://labix.org/snippets/permutations/. Computes permutations

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Jeff
Look at the pickle and marshal modules. -- http://mail.python.org/mailman/listinfo/python-list

Re: is +=1 thread safe

2008-05-01 Thread Jeff
If no other threads will be accessing the counter, there will be no problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: data manipulation

2008-05-01 Thread Jeff
The function expects an excel file. It cannot read a plain text file. You would need to figure out a way to convert the text file data into an excel format and save it to a new file first. The proper way to handle this is to make your data processing functions expect a defined format. Then, you

Re: Searching and replacing text ?

2008-05-02 Thread Jeff
If you know that, for instance, every occurrence of '[[' needs to be replaced with ']]', then it is much faster to use regular string methods. If you have the text stored in the variable foo: foo = foo.replace('[[', '[').replace(']]', ']').replace('->', '') If you need to recognize the actual pa

  1   2   3   4   5   6   7   8   9   10   >