| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Comments:
<0> un-bitpacking the chmod string <1> Patrick`: depends on what you're doing, and what you want to do. <2> nay.array(iter([[1,2,3],[4,5,6]])) <- fails <0> Yhg1s: if a file is world-writeable, panic <0> I stat() it and then parse that <1> Patrick`: 'if os.stat(filename).st_mode & 02: ...' <3> >>> import numarray as nay; nay.array(list(iter([[1,2,3],[4,5,6]]))) <3> array([[1, 2, 3], <3> [4, 5, 6]]) <0> Yhg1s: is a bitwise and? <2> right but the reason that i'm constructing an array *directly* from an iterator <2> is because the Python list takes up too much memory <1> Patrick`: & is a bitwise and, yes, like it is in most languages. <3> Connelly: What's your iterator, exactly? <2> uhm <1> Pythy: too big, apparently :)
<1> Connelly: I suggest posting to the numarray/numpy/scipy/whatevertheycallitnow lists. <0> Yhg1s: you'll have to excuse me, I don't understand how that works but I'll look it up <0> the syntax, I grok binary <0> ish <4> anyone here using SPE? <5> Connelly: I just got in here a few seconds ago, but why dont you just yield up values <1> Patrick`: it takes 'os', retrieves the 'stat' function, calls that on 'filename', takes the 'st_mode' argument of the result (which is the file's mode as an integer), and AND's that with 02, which evaluates to either 2 or 0, depending on whether bit 2 is set. if bit 2 is set, the file is world-writable. <1> oneeyedelf1: numarray doesn't consume iterators, it requires an object with a length. <0> yep, I get everything except "why 02" ? <1> Patrick`: because that's the 'world writable' bit. <0> no, no <0> to my eyes, that will return non-zero only if the last 2 bits are "10" <0> yet it works for 10 and 11 <2> Pythy: it's an iterator of 1352078 lists of form similar to [range(12),range(12,24)] <1> Connelly: alternatively, you may be able to wrap your iterator in an object that adds a sensible __len__ method; that requires you know how large the resultset will be, though. <0> oh, I get it ... <0> I'm an idiot, disregard me <0> and I was doing bloody logic gates last week <1> Patrick`: it's bitwise AND. it returns the bits in the mask that are set. <2> um, my iter->array code works fine <0> 01 & 10 = 00, 11 & 10 = 19 <0> *10 <0> and so on <0> dur dur dur <2> i'll post it as a recipe <3> Connelly: The inner lists were created using range()? <0> but why prepend it with a zero? force of habit (octal, and can test for, say, 0755) <1> Patrick`: yes. <2> um, they're regular lists <2> but they're created from some set partitioning math <6> whoaaaaa <6> new website <6> shinnnnnyyyyy <7> what is the best resource for learning py from the beginning <8> ?>tutorials@Zamolxe <9> $!>cheeseburger_and_fries@Zamolxe <7> ok ok i got it :)) <9> the cheeseburger? <10> mmm, McBot <7> before i'll do some rtfm, can someone please tell me what is the main purpose of py <7> can i use it like php <6> yes. <7> i mean i;ve worked with zope before <6> unlike php, py doesn't have a main purpose; it is general purpose. however, it comes with batteries included, and there are libraries available for just about any purpose. <7> i've been into parsing html, crawling and databases. the problem with php is that is not so fast as i espected, and i ran in a lot of seg faults using regular expressions (thou i runned some patches) <7> is py faster? <10> Python is almost always fast enough, and there are things you can do for when it's not <1> maybe. maybe not. it depends on the code you write. also, parsing HTML with large regular expressions is neither fast nor easy. <1> Python has quite a few excellent HTML parsers, though. <9> PHP, ew <8> Zalamander, it's all in the Big Oh. ;-) <6> Yes, you really should use a real parser to parse HTML. Fortunately, there are plenty to choose from. <11> beautiful soup is neat :) <6> I'm looking for a list of built-in decorators, but I can't find it. <7> davidmccabe i don;t understand, do you mean parsing/processing HTML with regular expressions is bad? <6> Zamolxe: yes. <8> davidmccabe, staticmethod and cl***method, basically. Decoraters are just functions, after all. <7> hm... <1> with a signle one, yes. <6> Zamolxe: HTML is complex enough to warrant a lex-based parser. <6> (well, you know what I mean)
<1> or a parser built ontop of many small regular expressions. <10> right, BeautifulSoup can be good for "wild" HTML, things like ElementTree are good for XHTML <7> Yhg1s of course <6> thanks TFK. <11> ...and xmltramp for parsing XML :) <7> thanks guys i apreciate. one more thing, every time i read some paper about web documents, parsing, etc, i hear about python. i heard that at google to <7> why? <11> why not? <1> Zamolxe: I'm not sure what you are asking. <7> i mean, why not use php or perl <2> Numeric/numarray/numpy array from iterator: <2> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/476217 <1> Zamolxe: because Python is easier to write, easier to get right and easier to extend. <7> is there something different about python, that i must consider <7> ok <12> to put it really vaguely, both PHP and Perl have a lot of nastiness of various kinds that Python seems to have avoided quite well. <2> Zamolxe: i find that Python is similar to my mental pseudocode <2> so it's really easy to "think" in Python <13> Zamolxe: python has been called 'executable pseudocode' <7> Connelly i see <7> oh that's great <14> XSLT is also worth a look if you are doing XML processing - it's not that easy to learn though <2> i bet some people "think" in Perl <15> poor guys <2> :) <15> I've even heard of some actually thinking in that stuff sendmail is configured with <8> Hmm. Think in J, communicate in Python, execute in C... <15> but I live almost next to a mental hospital, so that might be the case... <16> hi. if i want to check whether a value is a tuple, should i just go with "type(x) == type(())"? or is something more straightforward that i should be using? <0> python makes itself look nice <17> How freaking long does it take to get a project renamed on sourceforge. It's been over a week now. <8> amrit|wrk, ?.isinstance@amrit|wrk <0> I don't care for sourceforge, they rejected my project request <0> I was a bit flamey <2> amrit|wrk: isinstance((1,2,3),tuple) <10> amrit|wrk, you can use isinstance, but you probably shouldn't <0> "unlike 90% of the project requests you're likely to approve today, I have actual files ready!" <17> Patrick`, I know. it's sick <8> Why do I keep mentioning the asker's nicks when using the bot? :-/ <0> and "this program exists because all other alternatives are wank" <0> "please write a 10,000 word egowank about your project" <0> so, yes, I'm going to try for freshmeat <17> Patrick`, What about berlios.de ? <16> TFK: comcor benji : thanks.. but why shouldn't i use it? <0> exonic: I'm not german <0> (this is the first time I've heard of it) <17> Patrick`,You have to be german to use it? <0> I have no idea <8> amrit|wrk, type-checking is usually bad practice. <0> but it's .de and that's all I know about it <18> what about launchpad (no idea myself) <17> Patrick`, I don't think u do. <0> exonic: exactly <8> amrit|wrk, depends on what you need it for. You are welcome to elaborate :-) <16> TFK: ah. well, i'm writing some stuff where i want functions to have a nice and clean design in general - they just return a bool. but in a few special cases, i want to be able to return diagnostic messages as well, along with the boolean. the functions are only called from one place, so i was just going to have that spot check whether the value returned is a tuple, and if so, handle it appropriately. <8> amrit|wrk, either use exceptions, or ALWAYS return a tuple of (result, err_code) <1> a nice and clean design doesn't return different types of things from the same function. <8> result, err_code = myfunc(); if err_code == OK: ...; else: ... <1> exceptions are preferable. <16> yeah, i suppose you're right <16> thanks <19> Ok this is a little more complicated than my situation but let's say I have an if loop and it will do something if either of the cl***'s two variables is greater than ten. <19> However not all of the cl*** instances will have the second variable. <19> How would I set it up? <10> eugman, that doesn't sound like a very good design, perhaps if the second variable doesn't apply it can be set to None instead? <20> eugman: You could use getattr with a default value <21> eugman: create a method ab_more_than_ten () and use a try <10> then you can check if foo is not None and foo > 10: <10> s/foo/self.foo/g <17> eugman, program state! <17> heh <19> Benji's seems to be the smartest thing to do. thanks for the help.
Return to
#python or Go to some related
logs:
Metadata file does not match checksum yumex kde button Malformed URL system:/ #physics NX host not found lvm create RAID1 fedora fluxbox overlay snap #php invalid module format i810 java-void(0) qemu xscale
|
|