#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 
Top Prev 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 Next

#python

<pjd> fluxdude: don't be deceived, subprocess is really nicely done :)
<ehird> hm, is there a way to get the count of arguments a function takes?
<pjd> ehird: in what sense?
<ehird> def func(blah, blah, blah)
<ehird> how could i get 3 from that?
<dionoea> Hello. I'd like to know when/if a function's argument is passed by reference ? (def foo( a ): a = a + 1 won't change a's value in the caller while foo( a.b ): a.b = a.b + 1 will change b)
<ehird> etc
<ehird> or rather
<ehird> 3 from func
<glen_quagmire> ok installed pyqt4
<pjd> dionoea: Python always passes by reference, no exceptions
<insanekane> ehird: that can easily degrade into madness
<ehird> :(
<pjd> ehird: you can use inspection
<dionoea> pjd: so how come it doesn't change the a in the first example ?
<ehird> pjd: great! ... how? :P
<Jafet> atomic types are not passed by reference. strings and primitive numeric values are not.
<insanekane> dionoea: a.increment() will change a in the caller
<dionoea> why doesn't a = a + 1 work too ?
<pjd> dionoea: sorry, i meant by object reference
<dionoea> does a = a +1 create a new a variable locally to foo ?
<insanekane> dionoea: because a is an int
<pjd> not actually "by reference"
<insanekane> dionoea: that is copied by value
<insanekane> dionoea: yes
<pjd> that is to say, python always passes references, and the references are always passed by values
<pjd> "by value", even
<dionoea> it's not copies by value, else .increment() wouldn't work ... or am i missing something ?
<insanekane> pjd: :)
<dionoea> *copied
<pjd> dionoea: the reference to the object is passed by value
<Jafet> strings and numbers are copied, no references
<ogzy> hi, how can i make my python program work periodically?
<insanekane> dionoea: that is because .increment() presupposes that a is not a primitive type
<pjd> Jafet: no, they're references too
<dionoea> k
<insanekane> ogzy: on linux, you can use cron
<dionoea> is there a way to do something like: a.usethereferencestupid() = a + 1 ?
<pjd> dionoea: basically, all variables are pointers to objects
<insanekane> dionoea: basically, you want to modify a ?
<pjd> the actual pointers always get copied/passed by value
<insanekane> in the caller
<pjd> but they always stay pointing at the same objects
<insanekane> dionoea: then just do ... a = foo(a)
<ogzy> insanekane: but i want it configurable by the program itself, so should i add the program to cron?
<insanekane> dionoea: instead of just foo(a)
<dionoea> insanekane: i'm just trying to understand how/why it works that way, not finding a way to return a simple value :)
<insanekane> ogzy: well, it depends ...
<ogzy> insanekane: the program will read a config file and depending on the value it will work in some daily or some periodic times
<dionoea> like why doesn't it work like it would if i had a pointter to an int in C or a reference in C++

Previous Page  Next Page

Search ircarchive.info