Re: getting current UNIX uid

2006-07-06 Thread Eric Deveaud
Johhny wrote: > Hello, > > I am trying to get the user that is running the scripts uid, I have had > a look at the pwd module and it does not appear to offer that > functionality. Is there any way within python to get that information ? eg: username = pwd.getpwuid(os.getuid())[4] Eri

Re: eval to dict problems NEWB going crazy !

2006-07-06 Thread Eric Deveaud
manstey wrote: > That doesn't work. I just get an error: > > x = eval(line.strip('\n')) >File "", line 1 > [('recId', 3), ('parse', {'pos': u'np', 'gen': u'm'})] > > SyntaxError: unexpected EOF while parsing > is the last line of your file empty ?? what with for line in filA

Re: Way for see if dict has a key

2006-06-30 Thread Eric Deveaud
Bruno Desthuilliers wrote: > Fredrik Lundh wrote: > > Bruno Desthuilliers wrote: > > > >>> on my machine, "key in dict" is about twice as fast as the full > > > >>> try/getitem construct when the key is present in the dict, > > > >> > >> Doesn't it depends on the number of keys in the dict ? >

Re: combined files together

2006-05-09 Thread Eric Deveaud
Gary Wessle wrote: > > I need to traverse those files in the order they were created > chronologically. listdir() does not do it, is there a way besides > build a list then list.sort(), then for element in list_of_files open > element? are the name of the files describing the cration date, or

Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Eric Deveaud
bruno at modulix wrote: > Eric Deveaud wrote: > (snip) > > > > sort can take a comparaison function. > > The problem with it is that it may slow down things a lot... point taken. I have to purge my mind from the other programing languages I practice. ;-

Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Eric Deveaud
Nico Grubert wrote: > Hi there, > > I am looking for a way to sort a list containing dictionaries. > > This is my example list: > [{'Title': 'ABC', 'from_datetime': DateTime('2006/04/25 12:45:00 > GMT+2')}, {'Title': 'DEF', 'from_datetime': DateTime('2006/04/18 > 12:45:00 GMT+2')}, {'Titl

Re: create pixmap from data

2006-04-14 Thread Eric Deveaud
Thomas Girod wrote: > Hi there. > > I have a list containing integer values from 0 to 255. With this list I > have informations width and height, as width * height = len(my_list) > > What I want to do is to convert this array into a pixmap of dimension > width * height in order to draw it in

Re: Iterating command switches from a data file - have a working solution but it seems inefficient

2006-04-13 Thread Eric Deveaud
News wrote: > bruno at modulix wrote: > > > > Have you looked at optparse ? > > > I have. > > The module optparse seemed to be aimed at reading from commandline > versus pulling attributes from a read line. hu lets see optparse seems to be reading from commandline. that's not fa

Re: Iterating command switches from a data file - have a working solution but it seems inefficient

2006-04-13 Thread Eric Deveaud
News wrote: > Hi everyone, > > My goal is to pull command switches/options from a file and then assign > the values to select variables which would eventually be included in a > class object. > > The data file looks something like this but the switches could be in any > order and not all ma

Re: Initializing defaults to module variables

2006-04-13 Thread Eric Deveaud
Burton Samograd wrote: > Hi, > > I'm writing an app that stores some user configuration variables in a > file ~/.program/config, which it then imports like so: > > import sys > from posix import environ > sys.path.append(environ["HOME"]+"/.program") > impor

Re: converting lists to strings to lists

2006-04-12 Thread Eric Deveaud
robin wrote: > yo! > > thank you everone! here's how i finally did it: > converting the string into a list: > > input = net.receiveUDPData() > input = list(eval(input[0:-2])) no pun intented but as you did not know how to use split and join, please please DON'T USE eval

Re: converting lists to strings to lists

2006-04-12 Thread Eric Deveaud
robin wrote: > hi, > > i'm doing some udp stuff and receive strings of the form '0.87 > 0.25 0.79;\n' > what i'd need though is a list of the form [0.87 0.25 0.79] > i got to the [0:-3] part to obtain a string '0.87 0.25 > 0.79' but i can't find a way to c

Re: how to comment lot of lines in python

2006-03-31 Thread Eric Deveaud
[EMAIL PROTECTED] wrote: > > Eric Deveaud wrote: > > [EMAIL PROTECTED] wrote: > > > Like in C we comment like > > > /* > > > Bunch of lines of code > > > */ > > > > > > Should we use docstring """ ""

Re: how to comment lot of lines in python

2006-03-31 Thread Eric Deveaud
[EMAIL PROTECTED] wrote: > Like in C we comment like > /* > Bunch of lines of code > */ > > Should we use docstring """ """ I would say NO. docstring are displayed by pydoc, thus a pydoc on your code will display some inconsistent information ;-) > Or there is something else too ?? some m

Re: [OT] .DS_Store files (was Re: Removing .DS_Store files from mac folders)

2006-03-09 Thread Eric Deveaud
Dan Sommers wrote: > If these are both true, then *new* .DS_Store files could > be created after I've made the list and before I've made > the tarball. not python related, but in order to creater the tarball without the .DS_Store files why don't you use the --exclude=PATTERN option from tar ??

Re: how do you move to a new line in your text editor?

2006-03-03 Thread Eric Deveaud
John Salerno wrote: > This is a real small point, but I'd like to hear what others do in this > case. It's more an 'administrative' type question than Python code > question, but it still involves a bit of syntax. > > One thing I like to do is use tabs for my indentation, because this > ma