@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15



Comments:

<0> agaffney
<0> i get the correct result, when i drop the leading 0 from your modes
<0> python -c "import os; os.mkdir('t3', 1755)"
<0> d-wx-wx--t 2 leith leith 4096 Mar 5 13:54 t3
<1> pjarks: well, then the help for the function is wrong as it shows the default mode as 0755
<2> triplah: http://trovao.pastebin.com/584494 <= if you need it. Pygtk documentation needs some improvement.
<0> agaffney only think i can think of is the leading 0, signifies octal in python
<1> 1777 instead of 01777 gave me very wrong results
<3> mkdir(path[, mode]) - Create a directory named path with numeric mode mode. The default mode is 0777 (octal). On some systems, mode is ignored. Where it is used, the current umask value is first masked out.
<0> what system
<3> os.umask(0); os.mkdir("TEST", 01777)
<1> wchun: that works
<1> so why would the python function use the umask where `mkdir` doesn't?
<0> i think mkdir -m overrides it
<4> trovao: sweet, thanks :)
<1> wchun: thanks



<0> although info mkdir says otherwise
<1> well, it *does* apparently override it regardless of what the info page says :P
<3> man -s 2 mkdir ... : The parameter mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created directory are (mode & ~umask & 0777).
<1> -m mode, --mode=mode
<1> Set the mode of created directories to mode, which may be sym-
<1> bolic as in chmod(1) and then uses the default mode as the point
<1> of departure.
<3> man -s 2 mkdir == the c library function used by the os module, and not the system command =)
<1> that's mkdir in gnu coreutils-5.93
<1> ah :P
<1> anyway, temporarily setting the umask to 0 did the trick
<1> and here I thought I had something else wrong with python to complain about :P
<0> why what else have you found?
<1> silly stuff like python-2.3 masking signals in child threads and giving no way to unmask them, so that any child processes also have all signals masked
<0> hrm
<1> that caused some issues that took *forever* to track down
<0> signals and threads are a bit dodgy yes
<1> stuff like rsync misbehaving
<0> how is that related to python?
<1> pjarks: it's python's fault because it masks all signals and doesn't give you a way to turn them back on
<0> rsync i ment
<1> I filed a bug with rsync to have it defensively set a more sane signal mask
<1> which has been incorporated since then
<1> still a pain :P
<0> ok
<1> python "leaking" variables from loops also bugs me a bit
<0> ?
<1> if you define a variable inside a for/while/etc loop, the variable it available with its last value outside the loop
<1> I ran into some weird problems with reusing variable names and it having the wrong value
<0> makes perfect sense to me
<1> well, it's a python "feature"
<0> any language with scope will do that
<1> but it caught me off guard because I'm used to languages that keep variables locked away inside enclosures
<1> like C and perl
<0> well, C wont let you define a variable inside a loop anyway...
<1> also, the inability to do ***ignment in a while loop
<1> while (foo = bar):
<1> just little things
<1> the lack of ++ :P
<0> 2.4 supports ++
<1> does it?
<5> agaffney: use for-loops and iterators insetad of "while (foo=bar):"
<0> sorry
<0> +=
<1> drewp: right, I know all the little workarounds
<1> pjarks: yeah, I know about +=
<1> 2.3 supported that as well
<5> agaffney: that's no workaround, it's a much better plan
<1> drewp: I just want to do things my way :P
<0> i++, ++i, suprising how few people actually know the difference
<1> there's only a functional difference if you're using the variable for something at the same time you're incrementing it
<1> i++ uses it and then increments
<1> ++i increments and then uses it
<0> post and pre increment
<6> Not true.
<6> In C++, i++ will create a temporary object. ++i will not.
<6> Now, optimizing compilers will optimize it out, but still.
<0> only if i is not a basic type
<1> pfft...semantics
<0> and some monkey has overloaded ++
<0> agaffney anyway, i still dont see the problem with the loop "leaking" ?



<1> pjarks: it's not really a "problem"...just different
<0> in fact im glad it works like that
<1> meh, I'd rather define the var above the loop
<1> instead of defining it inside the loop and having it still present after the loop completes
<7> How do I set a bit in python?
<8> setting a bit? um, are you sure you shouldn't be using a low-level language instead?
<9> dodgyville: or is that chmod you're referring to?
<8> idealogically, i would think python shouldn't be used for setting bits... maybe write a c library for python?
<10> dodgyville: http://www.third-bit.com/swc2/lec/binary.html
<7> I think it might be "^"
<10> i don't see anything wrong with using python for bit manipulation
<10> you do it all the time with and and or
<10> unless he's doing some intense manipulations
<10> then, you're right. it probably would be slow
<7> Thanks for that
<10> i don't know what i'm talking about, though.
<10> np
<11> diethylamine, what the ****?
<11> diethylamine, plenty of scripting purposes for binary arithmetic.
<12> is using isinstance() considered inelegant, or is that my C-sense doing the thinking for me?
<11> qwe, if you're doing it to try to avoid polymorphism, it's "bad." If you're doing it to ensure a collection only has references to a certain but general object hierarchy, it's not "bad."
<12> hari`: ok
<11> And I put quotes in there on purpose. There are always exceptions.
<12> of course :)
<0> i thought last nights curry was a bit hotter than usual
<11> Since you can't directly tell python to make a set of just X type, isinstance() or type() is how you can check args for compliance with whatever contracts you have.
<0> hari` whats the preferred method?
<11> Preferred for what?
<0> checking types
<13> don't.
<11> Some would say the preferred method is to just let it explode with an exception.
<11> But I think it's useful to check types for defensive purposes. Again, not to avoid polymorphism.
<14> death to polymorphism!
<13> what does that mean?
<14> oh wait, no.
<12> MFen: if you don't like polymorphism you shouldn't be using python ;)
<11> Seeing if someone is a Manager vs an Employee is less "good" than seeing if something is an AccountsReceivable vs an Employee.
<14> qwe: python is perfectly usable without polymorphism, not that i would
<0> given that Manager and Employee should be derived from the same base cl***, HumanCattle
<4> haha
<11> pjarks, heh. Right. But finding an int where you expect an Account or a HumanCattle, that will just blow up eventually. Nicer to catch some of those things a bit earlier with ***ertions.
<0> thats a bit of an inhouse joke, our HR dept is called Human Capital...
<14> don't ***ert, adapt
<15> if i want to see if something is in a tuple, is it: "if var is in groupVar: blah" or "if var in groupVar: blah" ?
<0> in
<11> no 'is'
<15> hari`: is "is" a keyword in python?
<14> yes
<0> yes
<0> None is None
<15> what does "is" do? check for truth or something?
<0> checks that two objects are the same
<14> marburg: if only python could do that
<11> Checks for *identity* match.
<0> >>> x = None
<0> >>> y = None
<0> >>> x is y
<0> True
<8> and i love finding production code where someone had actually done stuff like naming a manager/employee parent cl*** HumanCattle
<14> marburg: a is b is almost (but not exactly) like.. if id(a) == id(b)
<15> gottcha
<15> thanks all :D
<0> None is actually a singleton afaik
<16> does someone know a small CMS written in python, and which works with mysql?
<11> pjarks: x = C() ; y = x ; ***ert(y is x)
<14> always use 'is None'
<11> pjarks, correct.
<8> someone told me they had to maintain a program written in the 60s where all the var names were drug references
<11> And this coming from 'diethylamine'.
<0> diethylamine i had some code come in from india
<0> diethylamine the variable names where all indian swear words
<11> I saw six related chemistry programs, each program of which was a chapter of a story, and the comments and variables all linked to that story. ****ing pain in the ***.


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #python
or
Go to some related logs:

mysql failed to open file error 2
Altima (nee Broadcom) AC1001 Gigabit Ethernet
etch install fake start-stop-daemon
linux tolvans
differenciate ti-89
PHP_AUTH_USER T_ENCAPSED_AND_WHITESPACE
precompiled sis190
#linux
mounting ext3 as ext2 ext2_fill_super gentoo
fglrx error inserting permission



Home  |  disclaimer  |  contact  |  submit quotes