| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Comments:
<0> not in a raw string <1> no, not in the raw string -- in the regex <2> aaaaaaaaargh <1> beerboybeerboy perhaps the fnmatch module would be easier ;-) <2> no, I know regexes <2> but this ****s <2> I'ev used Perl regexes all my life <3> Nope, you just have to stop ***uming that regexps have some magic link into Python. THey are just a library. <3> In Perl they are magic and part of the core, irreplaceable inextensible. <4> beerboybeerboy: so in perl how do you match a (? <3> But he doesn't watn to match a (; he wants a group. <2> \( <3> And that's the same as in PYthon with raw strings: >>> print bool(re.search(r'\(', '(')) <4> beerboybeerboy: in python it's the same. your regex contains \(, so it matches a ( <3> True <1> beerboybeerboy how do you match a backslash in perl?
<2> But \\( shouldn't be \( <2> \\ <5> more proof that perl is damaging. <5> beerboybeerboy: why shouldnt it be? <1> beerboybeerboy ok, so backslash (\\) followed by a group (...) -> \\(...) <2> $input =~ /(^\\\\.*)\\media\\(.*[^\\])/ <3> In a raw string, \\( matches a \ followed by start of group <2> This is the way I'd write it in Perl <3> So what does the input look like? <2> So if I wanted two backslashes, I use \\\\? <2> input is a UNC path <1> beerboybeerboy if you want two backslashes to be *matched*, you'd use \\\\ in a raw string <2> \\machine\folderA\folderB\folderC\media\etc\etc\etc <3> Yes, ***uming you have a raw string, yes. You need to backslash the backslash because the backslash is special in regexps so not backslashing it will create backlash. <2> p = re.compile(r'(^\\\\.*?)\\media\\(.*[^\\])') - how about this? <3> Well, are you doing this on a windows machine? <2> Erwin, yes <3> then use the os.path module <2> yeah but this is a simple app I'm developing because I'm lazy <3> Then why give yourself problems using regexps? <2> I need to get everything before the string media <2> \\machine\folderA\folderB\folderC\media\etc\etc\etc <2> how do I do that using os.path? <3> Hmm, the split there only split into dirname + base. But OK: <4> beerboybeerboy: you could also simply do a,b=pathname.split("media",1) <3> while 1: path, basename = os.path.split(path); if basename == "media": break <6> I'm working on a script for a website that will display the most recent files from a directory. The files are titled YYYY.MM.DD.html <3> ChrisLong: Nope, that wouldn't work if the string has e.g. "intermediate" in it before <4> kmwhite: ah, that sorts nicely <6> will glob always return the list in order, or do I need to sort them? <6> ChrisLong: glob'll work? <3> kmwhite: No sorting guarantees on glob. <3> but just for filename in sorted(glob.glob(...))) will do <6> Awesome. <1> if by sorted you mean alphabetically <4> Erwin: he wants "everything before the string media". so this meets hios requirements <4> kmwhite: you'll have to sort <6> ChrisLong: Will fileList.sort() work? <4> kmwhite: of course. glob returns a list <6> ChrisLong: Thanks much <2> Erwin, that went into an infinite loop <3> beerboybeerboy: Ah, you probably want to break on some other condition, like reaching the beginning of the filename :-) <3> If you want the non-os.path way, you can also split on '\\', search for media, then join <7> Hello, I have a list of 7 ints, and I want to check if there are 5 of them in an ascending order like [1,2,3,4,5,8, 14, 253]. How do I do that? <8> anyone mind reviewing a small of code and tell me what if anything I could improve? (Python noob here) <6> plb - paste a link <8> ok <6> plb - note, I'm a semi-noob too, just attempting to help <8> http://pastebin.com/763847 <3> e.g.: l = r'\\foo\bar\media\bob\file.txt'.split('\\') <8> just started on saturday ;] <9> if I don't need anything from the constructor, should I create it anyways with the p*** statement? <3> if 'media' in l: print '\\'.join(l[:l.index('media')]) <6> plb - nope, beyond me. I do mostly CLI and some wxPython stuff, GTK doesn't quite work on MacOSX as far as I know. <8> ah thanks anyway <8> anyone else mind reviewing a small bit of code? <0> plb i will <8> rabidpoobear: http://pastebin.com/763847 <5> pi3: you could use a few cl***es, but it looks structurally sound otherwise. <10> In writing a test unit, I'm using time.tzset() which is only available in unix. Is there a way to check for unix so i can skip that test if on win32? <11> os.name
<11> test for posix, otherwise skip <5> even better, hasattr(time, 'tzset') <11> or that <11> try it, and if it fails, ignore it? <12> any matplotlib user arround ? <11> what happens when you try to use tzset on windows, then <5> time.tzset doesnt even exist in the windows versions of python <11> if it throws an exception, just do a try/except ThingyError: p*** <12> TypeError: astimezone() argument 1 must be datetime.tzinfo, not list <11> or whatever you need instead of doing the test <11> ok, so do that <11> it is easier to ask forgiveness than permission <12> i've got this error while using date_plot() <10> cheers :) <12> dates = [date2num(datetime.fromtimestamp(now+t)) for t in ts] <12> mtplotlib seems not to be happy with this <5> but you need to be careful just catching an exception there and skipping. it might be an exception that means your test failed, so id stick with some explicitness. <5> does the standard unittest library even support test skipping? <11> try: tzfunction = time.whatever <11> s'what I do <11> keep the exception handling to stuff that cannot possibly throw the same exception I check for, in an unexpected way <11> I got a MAJOR headache from doing that once <5> good idea <5> ldlework: why for you change nick like that? <11> even if it "waah waah pointlessly creates extra local variables" <11> it's still nicer <13> I am sorry, my bot is not working well with nickserv. <13> I'll stop that. <5> Patrick`: what said that? <5> ldlework: why dont you test the bot with a seperate connection? <11> ironfroggy: my own subconcious <14> ldlework, can you just go in a private channel? <13> the whole point <13> is to get the bot to be able to join #python <14> ldlework, Je comprends <12> matplotlib is getting on my nerves <12> i just want to make some date_plot(). any helper ? <8> rabidpoobear: get the link? <12> oh, plot_date(), btw :) <15> Anyone happen to know which library allows me to import getdate() ? <8> anyone want to review a small bit of code -> http://pastebin.com/763847 <11> s'not small <11> what's wrong with it <5> plb-: i already gave you my thoughts on it. <8> eh? <8> must have missed it <8> stepped out for a minute <5> structurally it looks OK, but you have a severe lack of cl***es. <16> I'm struggling with cl*** interaction myself. So far though, it's all design stuff, not code. <8> ironfroggy: sorry I'm a newb here but what cl***es....the __init__ with the window? <14> bkjones, I'm actually in that same spot. Code is merely proof of concept for me right now. <16> sounds about right, rockstar_ <16> unfortunately (or fortunately, depending on how you look at it) I have to actually accomplish actual work in a relatively short amount of time :-/ <5> plb-: sure you would likely have a cl*** to instansiate as the main window of your app. <5> plb-: it just helps keep your code organized and maintainable. <8> alright I'll fix it right now <5> well it isnt really a quick fix, more a refactoring of all your code, but i still recommend it. <13> iron <13> you ready for this? <0> :D <5> ldlework: what? <13> ohnoes <0> oh noes. <0> what happened? <13> heh didn't nickserv <0> oh <0> ok <5> i think blocking bots are one of the reasons identification is required for #python... <13> Its a nice challenge, thank you. <15> I have a program I'm trying to run that imports something called "getdate", but I don't have that on my system and I can't seem to figure out what that is. Anyone have an idea? <13> zomg <0> yay
Return to
#python or Go to some related
logs:
EXHIBISHISM #math #css #ai cabextrac php6+$_get #fedora #1064 - You have an error in your SQL syntax near 'DEFAULT CHARACTER SET latin1 ImportError: DLL load failed: The specified module could not be found pyqt qt #linux
|
|