| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Comments:
<0> is there a python function that returns the time a file was last modified? <0> or should I make my own ? :( <1> would be better to check for yahoo then ms <2> I have a rather complicated structure of lists and dictionaries, which I need to recursively process so that I have '' instead of all None and Empty values.... <3> agilman: os.path.getmtime <4> msg HALLO <1> TVSET: I still don't get what you need <2> kosh: I found examples http://www.freenetpages.co.uk/hp/alan.gauld/tutrecur.htm to be pretty close to what I need. But can I use lists and dictionaries in the same way? <3> EvanCarroll: ircing using telnet ? <1> I know what recursion is but I don't understand what your problem is <4> Jerub: Not this time (messaging channels via loop) <2> kosh: my main problem is that I don't python... and want to stay that way for the time being... but I have a task at hand that needs solving. So I am looking for the easiest solution. :) <2> don't know - that is :) <5> kosh: I think he has a a list or dict with nested lists and dicts, and wants to convert all None to '' <2> cr***: exactly <5> TVSET: well its too bad that you don't want to learn python
<2> because I have to return the result via XMLRPC, and XMLRPC does not support the None stuff <5> its really a simple laanguage <2> cr***: I want to learn it, but not now. ;) <1> why not change it at creation time? <0> Jerub, is getmtime a python2.4 function? <6> agilman: os.path.getmtime is ancient <2> kosh: it is created by a thirdparty piece of code... (universal feed parser, if you know) .. and that piece of software is way too complicated for me to play with <3> or there's just os.stat(filename).st_mtime <5> TVSET: well I think you might have to check if its a dict or list, and then loop through all the items in the dict or list recusively doing the same if you come across a list or dict, other wise check if its None <2> cr***: how can I check if it a list or a dict? <1> if isinstnace(yourobj, list) if isinstance(yourob, dict) <5> TVSET: type(obj) == list or type(obj) == dict <1> cr***: NO NO NO! <1> using type like that is a very bad idea <1> even isinstance is a bad idea but vastly better <5> kosh: why so? <0> os.path.getmtime('/home/agilman/blogs/29-01-2006') <0> does that look right? <5> because it takes into account derivatives?> <1> instance works with inheritance at least, what you are doing with type is enforcing a type <5> right <1> however I have seen a number of cases where people make their own datatypes that follow a list or dict interface <1> and the type check like that will fail them even though if you did not check at all the code would work without issue <7> help(time) <5> yeah, I know, its planning for the future :) <8> is there an easy way to see if a given string has any letters in it? <9> try ***igning to the dict in a try:except, and catch the exception... <9> if 'c' in string... <8> ? doesn't that just check for 'c'? <10> jajaja <1> that is the best option sysfault however since he does not want to know python I doubt trying to work with exceptions will work for him <10> spanis <1> alus: define what a letter is exactly <2> hmm <8> kosh: string.ascii_letters <2> alternatively I could use an XMLRPC server that doesn't choke on None or Empty... any suggestions? <1> alus: so numbers, symbols etc don't count? <7> gmtime(0) <8> kosh: not today <1> alus: what version of python are you using? <8> 2.4 <1> a = set(string.letters) b = set(yourstring) a.intersection(b) <7> 2.4.2 <11> for win32com what's VT_ARRAY | VT_VARIANT equal to? <7> Python 2.4.2 (#1, Jan 8 2006, 01:04:02) <8> kosh: neat <7> in UNIX is the epoch 1970? <12> hi, what's the iterator protocol? <1> Yango: for i in something: <13> Yango: http://www.python.org/doc/lib/typeiter.html <1> Yango: it is how that works <12> yes <13> the protocol itself is the two methods described in that URL <13> alus: s.isalpha() <8> Yhg1s: contains, not is entirely <13> alus: the set solution or a regexp solution then. <14> Yhg1s, pysqlite2 dont have the cur.lastworid method ? <13> the regexp solution is quite probably faster, but if set is fast enough for you, that's probably easier. <14> for get the last row on a integer <13> KarlsBerg: no idea, I don't use SQLite. <14> oh ok, yesterday i think what you use pysqlite with you answer
<13> no, I just helped you with a problem. <12> thanks Yhg1s <14> Yhg1s, you perceive that I do not speak english perfect? jiji <14> i must train :P <13> yes, it's pefectly obvious that English is not your native tongue ;) <15> Is it possible to use the timit module to accumulatively measure something that occurs in an inner loop? Would I do something like time_functionx += t.timeit.Timer("functionx(...)").timeit(1)? <14> jijijijijijij <1> Yhg1s: yeah the regex one is probaly faster to run but I figured that the set one was VASTLY easier to write and read again later so it was the best default solution <13> Kuwanger: that would be quite inaccurate. why would you want that? <15> Yhg1s: What do you mean exactly? <13> Kuwanger: no, what do *you* mean exactly? :) <13> Kuwanger: timing a single functioncall makes overhead have a *lot* more impact <13> Kuwanger: so it will be quite inaccurate. <13> Kuwanger: what are you trying to measure? <15> Yhg1s: I'm trying to figure out the approximate ratio of time spent in each function in an inner-loop. <12> Kuwanger you need to test them in a loop, the bigger, the most accurate <13> Kuwanger: use the profiler instead. <12> just one call will do you harm, no good <15> Yhg1s: I didn't know of the profiler. <12> Kuwanger: http://docs.python.org/lib/profile.html <15> Yango: Yes, I know now. <12> I'm trying to compare a dialect found by the Sniffer cl*** in the CSV module to existing Dialects... is there an easier way than to compare attribute by attribute? <8> is there a list of python keywords in some module? <13> you may be able to compare __dict__'s <13> alus: do you mean reserved words? There's a list in the language reference, and one in the tokenize module. Why do you need it in a module, though? <13> hm, no, not one in the tokenize module. <8> well I could make the list myself, just wondering if it already exists <8> yeah reserved words <8> also standard type names and such would be nice <13> well, its' not in a module <13> but docs.python.org/lib has the builtin names, and docs.python.org/ref the list of reserved words <12> alus: you could built it with a couple of python lines :-) <8> I think I've got a pretty good set <13> if you use those two URL's, you have the complete set ;P <0> I wrote a small module, where would I place it so that everyone could access it? <0> Im on linux <13> /usr/lib/python<version>/site-packages/ <16> Woah. <0> gratis <2> I need a little help with this one - http://deadbeefbabe.org/paste/2756 <2> I managed to change all Falses to 0s, but Nones don't want to become ''s for some reason... <8> print repr(L) <2> alus: prints nothing... hmmm <13> TVSET: what you think is None is apparently not really None. <2> Yhg1s: what is it then? ;) <13> something other. <2> hmm <13> like the string "None", perhaps. <2> this is confusing <2> can't be <13> so print repr(L) in the 'else' clause. <2> Yhg1s: prints nothing :( <13> it doesn't print even a newline, or does it print ""? <13> have you run your code in the interactive interpreter? <13> you'll see that it treats None just like you want: <13> >>> clean(None) <13> '' <13> >>> clean([None]) <13> [''] <13> (etc) <13> so, it isn't the code that's wrong, just the data. <2> Yhg1s: it didn't print anything... not even a new line <13> then the whole 'else' clause isn't executed, so one of the earlier conditions is satisfied instead. <2> Yhg1s: it should get executed eventually... <13> then something else is wrong. But have you tried what I suggested? Run it on some other data, instead of the feedparser output? <2> if section on lists and dicts are executed, than it should somehow get to the point when list/dict values are processed in the else clause <13> have you printed the repr() of data, to see if it actually contains None's? <2> Yhg1s: yes, I printed the repr of data and it has None's... but all False's were converted to 0 as I wanted <2> hence the puzzle ;) <15> Yhg1s: Thanks. <2> somehow repr(False) doesn't print anything... <13> TVSET: and have you run your clean function on a single None, or a dict or list containing a None, like I have? <13> >>> print repr(False) <13> False
Return to
#python or Go to some related
logs:
error while loading shared libraries: libc.so.6 LD_ASSUME_KERNEL getconf GNU_LIB #lisp #javascript #fedora grub install hpt374 #lisp gentoo alsasound' not found; aborting la commande timport ubuntu sound via 58 echo choppy small ascii debian logo
|
|