Re: changing names of items in a list

2008-03-19 Thread Diez B. Roggisch
royG wrote: > hi > i am trying to rename extension of files in a directory..as an initial > step i made a method in > > class ConvertFiles: > def __init__(self,infldr,outfldr): > self.infldr=infldr > self.outfldr=outfldr > self.origlist=os.listdir(infld

Re: How to get an XML DOM while offline?

2008-03-19 Thread Diez B. Roggisch
william tanksley wrote: > I want to parse my iTunes Library xml. All was well, until I unplugged > and left for the train (where I get most of my personal projects > done). All of a sudden, I discovered that apparently the presence of a > DOCTYPE in the iTunes XML makes xml.dom.minidom insist on a

Re: cx_Oracle execute procedure

2008-03-19 Thread Diez B. Roggisch
Poppy wrote: > I've been working on the code below and and executes silently, no > complaints, however the end result should be a record in my table and it's > not added. The procedure works with the passed credentials using SQLPlus > or SQL Developer clients. However I'm not sure if I'm construct

Re: Script Request...

2008-03-20 Thread Diez B. Roggisch
some one wrote: > Thanks Diez, I found some docs and examples on urllib2. Now how do i > search the string I get from urllib2, lets say I put it in "myURL", How > do I search for only Numbers and ".'s" in the "#.#.#.#" pattern. That > is all I am interested in with all the data retrieved. Just

Re: Can I run a python program from within emacs?

2008-03-20 Thread Diez B. Roggisch
Grant Edwards wrote: > On 2008-03-20, Jeff Schwab <[EMAIL PROTECTED]> wrote: > http://www.google.com/search?q=emacs+python >> >>> Gee. Thanks. >> >> I believe Grant was suggesting that Emacs often serves a similar purpose >> on Unix to what Visual Studio does on Windows, which seemed to be

Re: zope and python 2.5.1

2008-03-20 Thread Diez B. Roggisch
hberig wrote: > Hi, > I'm sorry if this is an off-topic message, but I didn't found other > group. > I've read some articles about Zope, and since I like very much python, > I would like to run a webserver application using Zope instead other > web application server. I've difficulties to install

Re: Code folder with Emacs

2008-03-21 Thread Diez B. Roggisch
Grant Edwards schrieb: > Has anybody figured out how to do code folding of Python source > files in emacs? > > I tried "hide-show" minor mode, but it doesn't really work for > Python code: the only think it knows how to hide/show are > function bodies. It can't do normal things like hide/show a

Re: Prototype OO

2008-03-21 Thread Diez B. Roggisch
> I can see that Python and Javascript inheritance model is almost the > same. Both languages are dynamically typed. And it seems that using > "classes" in Python makes some things more complicated then it is > necessary (eg functions, methods and lambdas are differen beeing in > Python concept

Re: beginners question about return value of re.split

2008-03-21 Thread Diez B. Roggisch
the original Python 1.5 release, maxsplit was ignored. This has been fixed in later releases.) """ The Key issue here being "If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list."

Re: Prototype OO

2008-03-22 Thread Diez B. Roggisch
John Machin schrieb: > On Mar 21, 11:48 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> [1] Just one example:http://docs.mootools.net/Class/Class.js > > Mootools being something a coworker might use? > I don't understand the question. Diez -

Re: [RFC] How to implement command line tool integrating parsing engine

2008-03-22 Thread Diez B. Roggisch
llandre schrieb: > Hi all, > > I'd like to have some advices about how to implement a program that has > the following requirements: > - it must run both on linux and windows PC > - it must interact with an electronic device connected to the PC through > serial cable by sending/receiving some co

Re: Distributing Python Apps on Linux\BSD

2008-03-22 Thread Diez B. Roggisch
PurpleServerMonkey schrieb: > On Mar 22, 2:26 am, Miki <[EMAIL PROTECTED]> wrote: >> Hello, >> >> Disclaimer: I'm not an expert on the subject. >> >>> Setuptools and friends seem to be focused on distributing modules, I'm >>> at the other end of the scale where I want to distribute an entire >>> ap

Re: NameError: name 'guess' is not defined

2008-03-22 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I am very new to both programming and Pyhton and while trying to do > some practice using A byte of python an Error pops up on the IDLE > shell. I am using windows XP. PLease see below. > while running: > guess = int(raw_input('Enter an integer : ')) > > if guess == nu

Re: A "roadmap" for ctypes wrapping?

2008-03-23 Thread Diez B. Roggisch
Alaric Haag schrieb: > Hi all, > > I'm undertaking a pretty significant wrapping project (a linux > shared-object lib) early in my Python experience, and thought it might > be useful for many more that just myself if this thread were to produce > a sort of roadmap for approaching wrapping with

Re: Installing Mutagen Package On Windows

2008-03-24 Thread Diez B. Roggisch
Benjamin Serrato schrieb: > Hey, I've run into another problem. I am trying to install the Mutagen > package to use as my first useful program, but can't figure out how to > install it on windows. The README says it is a simple application of-- > > Installing > -- > $ ./setup.py build >

Re: StringIO + unicode

2008-03-25 Thread Diez B. Roggisch
Laszlo Nagy wrote: > Is there a standard "in-memory file" interface for reading/writting > unicode stings? Something like StringIO. > > E.g. this would be possible: > > - create UnicodeStringIO > - write unicode strings into it > - wite data (binary) string of UnicodeStringIO into a file ('wb' m

Re: Inheritance question

2008-03-25 Thread Diez B. Roggisch
Anthony wrote: > On Mar 25, 2:31 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: >> I wish it was that simple but 'a = Foo().getid()' is actually creating >> a new instance of Foo whereas I want the data of the Foo instanced by >> __init__ of FooSon(). > > I don't think Foo.__init__(self) creates

Re: _tkinter fails when installing Python 2.4.4

2008-03-25 Thread Diez B. Roggisch
jgelfand schrieb: > I'm installing Python 2.4.4 on a CentOS release 4.6 (Final) [RedHat > Enterprise Linux 4.6] 64-bit machine. Running "./configure --prefix="/ > usr/local/yosi/ciao-4.0/ots" --enable-shared" appears to be fine, but > I get the following error message when I run "make": > > buildi

Re: Strange loop behavior

2008-03-26 Thread Diez B. Roggisch
Gabriel Rossetti schrieb: > Hello, > > I wrote a program that reads data from a file and puts it in a string, > the problem is that it loops infinitely and that's not wanted, here is > the code : > >d = repr(f.read(DEFAULT_BUFFER_SIZE)) >while d != "": >file_str.write(d) >

Re: _tkinter fails when installing Python 2.4.4

2008-03-26 Thread Diez B. Roggisch
jgelfand wrote: > On Mar 25, 5:52 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> jgelfand schrieb: >> >> >> >> > I'm installing Python 2.4.4 on a CentOS release 4.6 (Final) [RedHat >> > Enterprise Linux 4.6] 64-bit machine.

Re: A question on decorators

2008-03-26 Thread Diez B. Roggisch
Tim Henderson schrieb: > Hello > > I am writing an application that has a mysql back end and I have this > idea to simplify my life when accessing the database. The idea is to > wrap the all the functions dealing with a particular row in a > particular in a particular table inside a class. So if y

Re: _tkinter fails when installing Python 2.4.4

2008-03-26 Thread Diez B. Roggisch
jgelfand schrieb: > On Mar 26, 7:02 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> I think the actual problem is that the linking doesn't find the >> XftGlyphExtends. I can only guess, but it might be related to >> 64-bit-problems. Make s

Re: counting using variable length string as base

2008-03-27 Thread Diez B. Roggisch
Grimsqueaker schrieb: > That seems to give me the items in the list back in an iterator. Am I > using it incorrectly? No. Just put a list() around it. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: last mouse movment or keyboard hit

2008-03-27 Thread Diez B. Roggisch
Ron Eggler schrieb: > Hi, > > I would like to get the time of the most recent human activity like a cursor > movement or a key hit. > Does anyone know how I can get this back to start some action after there > has been no activity for X minutes/seconds? Try hooking yourself into the OS screen-sav

Re: Partial Function Application and implicit self problem

2008-03-27 Thread Diez B. Roggisch
Gabriel Rossetti schrieb: > Hello, > > I am using Partial Function Application in a class and I've come up with > a problem, when the method is called it tries to pass "self" to the > curried/partial function, but this should be the first argument in > reality, but since the function is curried

Re: Partial Function Application and implicit self problem

2008-03-27 Thread Diez B. Roggisch
Gabriel Rossetti wrote: > > Gabriel Rossetti wrote: >> Hello, >> >> I am using Partial Function Application in a class and I've come up with >> a problem, when the method is called it tries to pass "self" to the >> curried/partial function, but this should be the first argument in >> reality, but

Re: subtract dates with time module

2008-03-27 Thread Diez B. Roggisch
barronmo wrote: > I'm trying to get the difference in dates using the time module rather > than datetime because I need to use strptime() to convert a date and > then find out how many weeks and days until that date. I'm a beginner > so any help would be appreciated. Here is the code: Use strpt

Re: Psyco alternative

2008-03-27 Thread Diez B. Roggisch
king kikapu wrote: > On 27 Μαρ, 14:35, Paul Rubin wrote: >> king kikapu <[EMAIL PROTECTED]> writes: >> > it seems that Psyco's author will not port it for the upcoming Python >> > 3000 release :( >> >> I think the idea is it will be part of PyPy and you should use that.

Re: Psyco alternative

2008-03-27 Thread Diez B. Roggisch
> Ok, i know this. The one that i do not know, is if, let'say, in 2 > years it will be ready for seriously development, PyPy will aim to > "replace" CPython entirely ?? We are talking about an whole new > distribution ? Most certainly not. It's the goal of each language to finally become self-host

Re: Plugins accessing parent state

2008-03-28 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Does anyone have some design ideas ( or can point me at the right > design pattern, because I can't find it. ) for having a plugin being > able to access a parent's state? > > For example, let's say I have a class that receives some commands. > When it gets a command,

Re: threads and extension module initialization

2008-03-28 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I have an extension module that gets initialized multiple > times because I am using threads. > > How can this module access global state (not per-thread state) ? > It needs to create a singleton. The question is very unclear. If you are after *not* initializing your

Re: Summary of threading for experienced non-Python programmers?

2008-03-28 Thread Diez B. Roggisch
> systems. (In theory, file input/output should also be available as > asynchronous code, but async IO is low-level and not available in > Python.) While threads shouldn't be considered a replacement for I suggest you tell that the twisted-guys. And the ones from the built-in asyncore-module.

Re: Bad hack fix around a bizarre problem...

2009-01-11 Thread Diez B. Roggisch
Just Another Victim of the Ambient Morality schrieb: I'm trying to write a Python program that manipulates a MySQL database and have chosen to use MySQLdb. So, I used by system's package manager, YUM, and it appeared to install correctly. So, I tried it out and got this error: Tracebac

Re: template inheritance

2009-01-11 Thread Diez B. Roggisch
Alex K schrieb: While building a website using template inheritance one usually does the following: fetch from database fetch from some more data from database ... << more required computations then at the end render the template with the fetched data Without template inheritance one usually do

Re: Egg deinstallation

2009-01-12 Thread Diez B. Roggisch
mk wrote: > Hello everyone, > > I googled and googled and can't seem to find the definitive answer: how > to *properly* deinstall egg? Just delete the folder and/or .py and .pyc > files from Lib/site-packages? Would that break anything in Python > installation or not? It depends on how you insta

Re: Compressed vs uncompressed eggs

2009-01-12 Thread Diez B. Roggisch
mk wrote: > Hello everyone, > > Are there *good* reasons to use uncompressed eggs? Plenty. Mostly that some things simply don't work in compressed eggs. See the zipsafe-flag in setuptools-docs. > Is there a, say, performance penalty in using compressed eggs? Not that it matters I'd say - only

Re: Simple CGI-XMLRPC failure

2009-01-12 Thread Diez B. Roggisch
Mike MacHenry schrieb: I am having a difficult time understanding why my very simple CGI-XMLRPC test isn't working. I created a server to export two functions, the built-in function "pow" and my own identity function "i". I run a script to call both of them and the "pow" work fine but the "i" giv

Re: debugging ignored exceptions at cleanup

2009-01-12 Thread Diez B. Roggisch
Michele Simionato schrieb: In some conditions (typically with threads, __del__ methods, etc) the cleanup mechanism of Python gets in trouble and some exceptions are not raised but just printed on stderr. I have an application using Paste and when I run the tests I get some annoying ignored except

Re: Standard IPC for Python?

2009-01-13 Thread Diez B. Roggisch
Laszlo Nagy wrote: > I would like to develop some module for Python for IPC. Socket > programming howto recommends that for local communication, and I > personally experienced problems with TCP (see my previous post: "Slow > network"). > > I was looking for semaphores and shared memory, but it is

Re: PYTHON HTTP POST WORKING EXAMPLE NEEDED

2009-01-14 Thread Diez B. Roggisch
dhaval wrote: > On Jan 14, 4:11 pm, dhaval wrote: >> Hi, >> >> Can someone please give me an example of a working python post? >> for example using the sitehttp://www.cookiemag.com/ >> >> Thanks in advance, >> Dhaval > > I have tried to look at the code at > http://code.activestate.com/recipes/1

Re: Why this code is working?

2009-01-14 Thread Diez B. Roggisch
r wrote: > Listen Hussien, Granted, with a name of "r", spelling it wrong is hard, and thus you might not be trained in the art of spelling names proper. But I suggest you try your best. After all, you posts lack so much in content, you could at least excel in form... > In python you do not have

Re: os system command not found

2009-01-14 Thread Diez B. Roggisch
codicedave wrote: > On 14 Gen, 13:16, Steven D'Aprano cybersource.com.au> wrote: >> On Wed, 14 Jan 2009 02:25:52 -0800, codicedave wrote: >> > Hi all! >> > I installed a external program called infomap using the classical >> > procedure >> >> > ./configure >> > make >> > sudo make install >> >> >

Re: General direction

2009-01-15 Thread Diez B. Roggisch
e the following attributes: - Date - Time - Insect A Finds - Insect B Finds - Insect C Finds - Insect A Number - Insect B Number - Insect C Number Instead of manually coding attributes for all kinds of insects, better use a mapping of insect-name to attributes. There are plenty of options for t

Re: the name of a method

2009-01-15 Thread Diez B. Roggisch
[email protected] wrote: > Hello, > > I have a Class: > > class myClass: > def __init__(self): > # do something > print "name of class = " + self.__class__.__name__ > > def myMethod(self): > # do something > print "name of method = " + "myM

Re: is there something like a module decorator ?

2009-01-18 Thread Diez B. Roggisch
Stef Mientki schrieb: hello, I wonder if there's something like a module decorator. I could use it in debugging a large highly dynamical program. No, there isn't. This has been discussed a while ago: http://groups.google.de/group/comp.lang.python/browse_thread/thread/215216a1e13ba2c6 Diez --

Re: Python and threads

2009-01-18 Thread Diez B. Roggisch
[email protected] schrieb: Hello again, Thanks for previous help on "Start two threads in same time" it was useful,but when I run this two threads, I think they don't start at the same time, here is my code snippet: import threading class ThreadedClass1(threading.Thread): def __init

Re: calling an external program and capturing the output

2009-01-18 Thread Diez B. Roggisch
Eric schrieb: Coming from a perl background I'm new to the Python world. I need to read a list of values, send each value to an external program and capture and act on the output of that program. Reading and parsing the initial values is not a problem but I can't seem to find anything on the sen

Re: uninstall before upgrade?

2009-01-18 Thread Diez B. Roggisch
waltbrad schrieb: I want to upgrade from 2.5 to 2.6. Do I need to uninstall 2.5 before I do that? If so, what's the best way to uninstall it? Thanks. No, several versions of python can live happily together. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Diez B. Roggisch
Ron Garret schrieb: I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-service attacks. So I do something like this: def application(environ, start_response):

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Diez B. Roggisch
Ron Garret schrieb: On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: Ron Garret schrieb: I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Diez B. Roggisch
Ron Garret schrieb: On Jan 18, 12:40 pm, "Diez B. Roggisch" wrote: Ron Garret schrieb: On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: Ron Garret schrieb: I'm writing a WSGI application and I would like to check the content- length header before reading the cont

Can I run an operation on an object's attribute when reading?

2009-01-19 Thread Phillip B Oldham
Is it possible to automatically run an operation on a object's attribute when reading? For instance, if I have the following: class Item(object): tags = ['default','item'] item = Item() desc = item.tags When I'm reading the item.tags, I'd like to automagically have the value converted to a st

Re: Can I run an operation on an object's attribute when reading?

2009-01-19 Thread Phillip B Oldham
On Mon, Jan 19, 2009 at 12:15 PM, Chris Rebert wrote: > Assuming I'm interpreting you correctly (you're going to have to use > something like a getter): Thanks, but I'm looking for a way to do it *without* using a getter as I don't have easy access to the class (its being generated for me elsewhe

Re: Python Style Guide Questions - Contd.

2009-01-19 Thread Diez B. Roggisch
r use the default variable _ ? >for _ in range(counter): > do_something() >pylint does not raise errors for those. Are there any issues in > using _ ? Nope, using _ is perfectly fine for variables you don't care about. Another example is e.g. foo, bar, _ = ("a", "b", "c") Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Regexp

2009-01-19 Thread Diez B. Roggisch
gervaz wrote: > Hi all, I need to find all the address in a html source page, I'm > using: > 'href="(?Phttp://mysite.com/[^"]+)">()?(?P[^]+)( b>)?' > but the [^]+ pattern retrieve all the strings not containing < > or / or a etc, although I j

Re: Regexp

2009-01-19 Thread Diez B. Roggisch
gervaz wrote: > On Jan 19, 4:01 pm, Ant wrote: >> A 0-width positive lookahead is probably what you want here: >> >> >>> s = """ >> >> ... hdhd http://mysite.com/blah.html";>Test String OK> a> >> ... >> ... """>>> p = r'href="(http://mysite.com/[^"]+)">(.*)(?=)' >> >>> m = re.search(p, s) >> >>>

Re: How to start a transaction?

2009-01-20 Thread Diez B. Roggisch
Hussein B wrote: > Hey, > I know the basics of interacting with databases in Python. > How to start a transaction in case I want to group a couple of insert > and update statements into a single operation? Please read the python database API documentation: http://www.python.org/

Re: Doubts related to subprocess.Popen()

2009-01-20 Thread Diez B. Roggisch
srinivasan srinivas wrote: > Hi, > Does subprocess.Popen() count a new open file for each suprocess? I mean > does it occupy an entry in file descriptor table of parent process? If so, > wat is each file descriptor connected to? Usually, each new process has three file-descriptors associated with

Re: Embedding Python. But not so easy.

2009-01-20 Thread Diez B. Roggisch
> 1) Threads: the simulation is going to be run in a very parallel > environment with several CPUs and > http://docs.python.org/c-api/init.html#thread-state-and- > the-global-interpreter-lock there is a global lock mentioned. Does that > mean that the python code can not benefit from this ? Not if

Re: How to get first/last day of the previous month?

2009-01-20 Thread Diez B. Roggisch
Hussein B wrote: > Hey, > I'm creating a report that is supposed to harvest the data for the > previous month. > So I need a way to get the first day and the last day of the previous > month. > Would you please tell me how to do this? First day: create a new date-object

Re: SetUp functions for multiple test cases

2009-01-20 Thread Diez B. Roggisch
Georg Schmid wrote: > I've just started working with unittests and already hit a snag. I > couldn't find out how to implement a setup function, that is executed > only _once_ before all of the tests. Specifically, I need this for > testing my database interface, and naturally I don't want to creat

Re: Locking blockl to a people on a similar group / naming locks

2009-01-21 Thread Diez B. Roggisch
Paul Rubin wrote: > reyjexter writes: >> synchronize (myGroup) { >> } >> >> but how do I do this in python? how can I name the lock that will be >> used by the thread? > > You have to do it explicitly, for example with RLock: > > myInstance.lock = RLock() > ... > myInstance.lock.ac

Re: Start Python at client side from web app

2009-01-21 Thread Diez B. Roggisch
James Stroud wrote: > Thomas Guettler wrote: >> Hi, >> >> I want to start Python at the client side from a web application. The >> app is an intranet application, and all client PCs are under our control >> (we can install software on them). >> >> But I don't want to update the installation too

Re: Start Python at client side from web app

2009-01-21 Thread Diez B. Roggisch
Thomas Guettler wrote: > Sorry, I described my problem not well. Here is more information: > > The main application is the intranet web application used with IE (ms > windows client). But some action needs to be done on the client since you > can't do it with html or javascript. > > 1. The user

Re: quick beginners List comprehension question

2009-01-21 Thread Diez B. Roggisch
Dr Mephesto wrote: > Hi, > Im new to python, and OOP, and am trying to get a handle on list > comprehension. > > Say I have a class Foo with a property called bar: > > class Foo: > def __init__(self): > self.bar = random.randint(1,100) > > and then I make a list of these objects: >

Re: Start Python at client side from web app

2009-01-21 Thread Diez B. Roggisch
2) create a localhost web server, for the client side manipulation. Then have your remote webserver render a form that posts via javavscript to the localhost webserver. The localhost server would post back in the same way. AFAIK the JS security model prevents that. Diez -- http://mail.pyth

Re: quick beginners List comprehension question

2009-01-21 Thread Diez B. Roggisch
MRAB schrieb: Diez B. Roggisch wrote: Dr Mephesto wrote: Hi, Im new to python, and OOP, and am trying to get a handle on list comprehension. Say I have a class Foo with a property called bar: class Foo: def __init__(self): self.bar = random.randint(1,100) and then I make a list

Re: USB in python

2009-01-22 Thread Diez B. Roggisch
Astan Chee wrote: > Hi, > Im trying to write a program for my USB device and I'm thinking of using > python to do this. The USB device is of my own making and it is > activated when one of the two data pins of the USB is given about 5V (or > similar to whatever the power pin is getting). Now I'm c

Re: Start Python at client side from web app

2009-01-22 Thread Diez B. Roggisch
Rob Williscroft schrieb: Diez B. Roggisch wrote in news:[email protected] in comp.lang.python: 2) create a localhost web server, for the client side manipulation. Then have your remote webserver render a form that posts via javavscript to the localhost webserver. The localhost

Re: USB in python

2009-01-22 Thread Diez B. Roggisch
Astan Chee schrieb: Diez B. Roggisch wrote: Astan Chee wrote: Hi, Im trying to write a program for my USB device and I'm thinking of using python to do this. The USB device is of my own making and it is activated when one of the two data pins of the USB is given about 5V (or simil

Re: Adding a field to a 'foreign' object from the outside

2009-01-22 Thread Diez B. Roggisch
atleta schrieb: Hi, I'm working with a callback API (a DBus one) and I'd need to store some state between the calls somewhere. I know that it's possible to extend an object with fields after creation, so I could just store my data in the session object that is passed in with every callback. Ho

Re: USB in python

2009-01-22 Thread Diez B. Roggisch
Astan Chee schrieb: Diez B. Roggisch wrote: Others suggested the parallel port. It is the natural choice for such things, with two caveats: - it is legacy, and thus often not available on modern hardware, especially on mobile ones. So if you want it be prepared to additionally buy a

Re: Securing a database

2009-01-22 Thread Diez B. Roggisch
[email protected] schrieb: My company provides some services online, which now they are planning to make it offline and sell to customers who can use it in their networks. One of our major moneywinners is some data which is stored in a database. Now, this data inside the database was obtained af

Re: problem with special characters in filename

2009-01-23 Thread Diez B. Roggisch
[email protected] schrieb: using: Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Hello I have two files (let's assume they are all in the same directory): 1) "a.dat" containing the single line "Sébastien.dat" 2) "Sébastien.dat" containing arbi

Re: problem with special characters in filename

2009-01-23 Thread Diez B. Roggisch
The above at least applies to Linux. I'm not sure about windows - I *know* they have wide-char/unicode support, but I'm not sure how exactly that is exposed via the python file apis Just found this: http://www.amk.ca/python/howto/unicode there is a seciton about filenames and OSes in there

Re: Securing a database

2009-01-23 Thread Diez B. Roggisch
Thank you very much Diez. This was my fear. Anyways, if we can make it real hard for them to analyze also, I think we are in the good - esp since the clients are not extremely rich enough to go for professional analyzers -- What is the skype method? The code is not huge - less than 20K LOC so, cod

Re: Where to place imports

2009-01-23 Thread Diez B. Roggisch
oo1(a,b): import numpy import datetime return c def Foo2(a,b): import datetime c = Foo1(a,b) return c etc... Above obviously just for the form, but the point is, in some cases I may import modules twice, but other times I may not use them at all, so should I import everything

Re: Where to place imports

2009-01-23 Thread Diez B. Roggisch
John [H2O] schrieb: So it isn't inefficient to import a bunch of modules that may not be used, say if only one function is used that doesn't rely on a larger module like numpy or pylab? Well, importing can take bit of time - but that's a short latency at startup-time, if anything. And if you

Re: Where to place imports

2009-01-23 Thread Diez B. Roggisch
Steve Holden schrieb: Diez B. Roggisch wrote: [...] The only valid reason for doing imports inside functions is if you otherwise get into circular dependency hell, or have modules that need some manipulation of the sys.path before they actually can be imported. This is never true for system

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Diez B. Roggisch
the contents, but you don't assign it, so it is discarded. Now, I want to work with each line separately, without the '\n' character. How can I get variable "b" as a list of such lines? The idiomatic way would be iterating over the file-object itself - which will

Re: [MacOS] Multiple versions of a module

2009-01-25 Thread Diez B. Roggisch
Pierre-Alain Dorange schrieb: How to manage a module with several versions on MacOS X ? All modules are installed in : "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-pa ckages/" This is the default path for Mac. But for some modules i need several version (stable 1.8.1 an

Re: v = json.loads("{'test':'test'}")

2009-01-25 Thread Diez B. Roggisch
gert schrieb: On Jan 25, 11:16 pm, Дамјан Георгиевски wrote: raise ValueError(errmsg("Expecting property name", s, end)) http://docs.python.org/library/json.html What am I doing wrong ? try this v = json.loads('{"test":"test"}') JSON doesn't support single quotes, only double quotes. the fu

Re: super behavior

2009-01-25 Thread Diez B. Roggisch
def __init__( self , a = 1 ): self.a = a print "init_coucou1" super( coucou1, self ).__init__( ) def print_coucou1( self ): print "coucou1" class coucou2( object ): def __init__( self , b = 2 ): self.b =

Re: v = json.loads("{'test':'test'}")

2009-01-25 Thread Diez B. Roggisch
But all of this is not JSON. Yes it is, you just make it more python dictionary compatible :) No, what you do is to make it more incompatible with other json-implementations. Which defies the meaning of a standard. Besides, {foo : "bar"} is *not* python dictionary compatible, at least not

Re: v = json.loads("{'test':'test'}")

2009-01-26 Thread Diez B. Roggisch
gert schrieb: On Jan 26, 12:40 am, "Diez B. Roggisch" wrote: But all of this is not JSON. Yes it is, you just make it more python dictionary compatible :) No, what you do is to make it more incompatible with other json-implementations. Which defies the meaning of a standard. Bes

Re: Function arguments

2009-01-26 Thread Diez B. Roggisch
brasse schrieb: Hello! Is there any way that I can get at all the arguments passed to a function as a map without using keyword arguments? def foo(a, b, c): # Can I access all the arguments in a collection somewhere? I'm mainly curious since I have stumbled on to some cases where it

Re: really slow gzip decompress, why?

2009-01-26 Thread Diez B. Roggisch
redbaron wrote: > I've one big (6.9 Gb) .gz file with text inside it. > zcat bigfile.gz > /dev/null does the job in 4 minutes 50 seconds > > python code have been doing the same job for 25 minutes and still > doesn't finish =( the code is simpliest I could ever imagine: > > def main(): > fh =

Re: Receiving data from USB

2009-01-28 Thread Diez B. Roggisch
[email protected] schrieb: Hi Can any body tell me how can i receive data from usb(usrp) in python. http://letmegooglethatforyou.com/?q=python+usb Diez -- http://mail.python.org/mailman/listinfo/python-list

ORM recommendation when using "live"/predefined DB?

2009-01-28 Thread Phillip B Oldham
We're trying to move to Python for a few parts of our application. We have a live database, which has been modeled for a specific use, and has other code connecting to and working with it. We'd like to reduce the amount of work we have to do in terms of keeping our python code up-to-date with sche

Re: dicts,instances,containers, slotted instances, et cetera.

2009-01-28 Thread Diez B. Roggisch
[email protected] schrieb: Hi, all. I have an application that that creates, manipulates, and finally archives on disk 10^6 instances of an object that in CS/DB terms is best described as a relation. It has 8 members, all of them common Python datatypes. 6 of these are set once and then not mo

Re: dicts,instances,containers, slotted instances, et cetera.

2009-01-28 Thread Diez B. Roggisch
[email protected] schrieb: On Jan 28, 4:50 pm, Aaron Brady wrote: On Jan 28, 2:38 pm, [email protected] wrote: Hello, quoting myself from another thread today: There is the 'shelve' module. You could create a shelf that tells you the filename of the 5 other ones. A million keys should be

Re: search speed

2009-01-30 Thread Diez B. Roggisch
anders schrieb: Hi! I have written a Python program that serach for specifik customer in files (around 1000 files) the trigger is LF01 + CUSTOMERNO So a read all fils with dirchached Then a loop thru all files each files is read with readLines() and after that scaned Today this works fine, it

Re: Empty string is False right?

2009-01-31 Thread Diez B. Roggisch
AJ Ostergaard schrieb: Hi Ralf, Thanks for that but why: >>> '' and True '' Surely that should be False?!? No. Please read the section in the language reference about the and/or operators. "and" will return the first false value, or the right side. Thus '' and True -> '' True and '' ->

Re: Problem With py2exe and ConfigParser

2009-02-01 Thread Diez B. Roggisch
[email protected] schrieb: Hello, i use python 2.6 + PyQt4. I compile my main.pyw. It is compile, but don't run. In "index.exe.log" error log: File "index.pyw", line 100, in GetVal ConfigParser.NoSectionError: No section: 'Main' Code line 92 to 104 this is class that uses ConfigPars

Re: the 'right way' to distribute and access data files in a packaged Python module

2009-02-02 Thread Diez B. Roggisch
David Moss wrote: > Hi, > > I'm the author of netaddr :- > > http://pypi.python.org/pypi/netaddr/0.6 > > For release 0.6 I've added setuptools support so it can be distributed > as a Python egg package using the easy_install tool. > > In 0.6, I've started bundling some data files from IEEE

Re: Reading text file with wierd file extension?

2009-02-02 Thread Diez B. Roggisch
Hi Mike, maybe it's not a "true" text file? Opening it in Microsoft Notepad gives an unformatted view of the file (text with no line wrapping, just the end-of-line square box character followed by more text, end- of-line character, etc). Wordpad opens it properly i.e. respects the end-of-line wra

Re: Problem With py2exe and ConfigParser

2009-02-02 Thread Diez B. Roggisch
[email protected] wrote: > > You can set an example? My English is bad, so I do not quite > understand You need to give a proper path to the config.ini. It's not found, which most probably occurs because you give a relative path ("config.ini") but that doesn't work because the current worki

Re: Reading text file with wierd file extension?

2009-02-02 Thread Diez B. Roggisch
Lionel schrieb: On Feb 2, 12:10 pm, Mike Driscoll wrote: On Feb 2, 1:20 pm, Lionel wrote: On Feb 2, 10:41 am, Mike Driscoll wrote: On Feb 2, 12:36 pm, Lionel wrote: Hi Folks, Python newbie here. I'm trying to open (for reading) a text file with the following filenaming convension: "M

Re: is python Object oriented??

2009-02-02 Thread Diez B. Roggisch
> The reason is that I see a level of abstraction that makes it kind of > irrelevant whether something is run as a process, a thread, a time > multiplexed mainloop, on one or more processors, wherever or > whatever - almost like a fractal structure spread across the total > addressable space - and

Re: is python Object oriented??

2009-02-02 Thread Diez B. Roggisch
> I wonder why the designers of processors do such silly things as having > user and supervisor modes in the hardware - according to your > arguments a code review would solve the problem, and then they > could use the silicon saved to do other usefull stuff. - then any process > could use any inst

<    22   23   24   25   26   27   28   29   30   31   >