@# 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 16 17 18 19 20



Comments:

<0> Jerub, so whats better for this job pyres or swig :)
<1> Is there a system independant way to create a foler?
<2> my personal opinion is that 90% of the time someone wants to use a "design pattern", it's because they came form some language like Java that is missing major pieces of Useful Functionality (e.g. lambdas)
<1> folder
<3> So in my loading code, I'm creating a function and am going to ***ign it to the __getattr_var attribute on the Customer cl***.
<2> GoClicl: os.mkdir
<3> That make sense TFK?
<4> mcmillen, fine - any callback mechanism is prefered to reflection.
<4> Gambit-, parsing
<2> TFK: i'm not disagreeing with you, BTW, that was just a general comment :)
<1> mcmillen is there one that will return the epoch time a file was created on that works on windows?
<5> GoClick: Depends.
<5> whos this nick|here dude
<5> :P
<1> Basicaly I'm writing a script to take images off a memory card accessed via a drive letter (card reader) and I want to rename them to their ctime and shove them into a folder on the hard drive and then delete them on the card
<6> mcmillen: agreed, but I think a design patterns book/wiki for Python would be useful - for more architectural issues beyond the Cookbook level



<4> Gambit-, why can't the properties be added by a .purchase_tracking() method, and checking whether the purchase has been done implemented as a boolean attribute, self.purchased_tracking or similar?
<3> TFK, you mean Customer.__init__ calling System.purchased_equipment()?
<4> Gambit-, why System? Isn't this a Customer-specific action?
<3> TFK, No, the equipment module is a full module in it's own right, requiring database support and all the rest.
<6> Gambit-: why not just have a dictionary attribute, with appropriate keys and values?
<2> pythonologist: a wiki for that sort of thing would be nice, yes.
<4> But you have a number of Customer instances (customers), some will buy the equipment and some won't?
<7> cracki: do you have a minute? would you mind trying again?
<8> hostname and ip?
<7> punkrockguy318.no-ip.org 2000
<3> pythonologist, why would I? The concept is centered around the Customer object.
<7> command %login$%cracki
<7> oops
<7> command: %login%cracki
<8> punkrockguy318, unknown command
<8> heh, now it works.
<8> but not now.
<8> but now.
<7> weird
<8> about 20% it works.
<8> heisenbug
<9> Grrr, my gtk signals aren't working ..
<7> cracki: strange
<8> punkrockguy318, fill it with debug-prints
<8> punkrockguy318, narrow down the error
<8> pythonologist, gobby
<7> cracki: could you try it one more time please?
<4> pythonologist, some like this: http://www.writeboard.com/ ?
<8> punkrockguy318, locks.
<10> NR1k = [x_low, NR1_out[0], NR1_out[1]]
<10> TypeError: unsubscriptable object
<10> why is that
<7> crack: hmm... yeah
<8> punkrockguy318, and doesn't send anything. it locks for ~3 secs
<4> PersianPower, it means that either NR1_out doesn't understand [] syntax.
<8> punkrockguy318, connection refused?
<7> cracki: yeah.. ugh
<7> cracki: yeah.. thanks for your help! i'm going to do some coding.. i've narrowed downt he problem
<4> It's not a list, tuple, string or a dictionary.
<8> ok
<4> Gambit-, so anyway, why do you need __getattr__? It's called when an attribute is not found, but it appears that you'll know what attributes you'll have at __init__ time.
<10> TFK so i should make sure that NR1_out is a list?
<4> PersianPower, what is NR1_out supposed to be?
<3> TFK, because the attribute being created involves a bunch of SQL queries, so I don't want to create it until it's needed.
<11> what is the easiest way to generate a string that contains letters a..z + a space?
<10> TFK a tuple outputed from a fuinction
<4> kg, import string; string.ascii_lowercase + ' '
<11> TFK: heh, thanks, that's easy indeed :)
<4> PersianPower, so the function gives you something else, probably None. So you probably need to check if it succeeded.
<12> Gambit-: do some kind of lazy initialization, to initialize the object and do the queries only when needed
<3> werneck, well that's what I'm doing by hooking into __getattr__
<4> kg, the poor man's substitute would probably be: ''.join(chr(i) for i in range(ord('a'), ord('z')+1)) + ' '
<13> Please I use Optparse and when I add a file for ex myscript -f lo* the options.file give me the first occurence find in the folder, and I want to get the lo*?
<12> Gambit-: you redefined __getattr__ and the first attribute access initialize the object, right ?
<11> TFK: I think I'll stick to your previous version :]
<2> christor: that's a problem with your shell. put "lo*" in quotes
<3> werneck, essentially, yes
<13> mcmillen: no other way to change that using python?
<4> Gambit-, why not create the attributes, as properties if need be, and check the first access as a flag?
<4> as a=with



<4> err. as=with
<2> christor: your shell is expanding the "*", Python never sees it literally. same goes for any program you run from the command-line.
<3> TFK, how would that be different? Instead of requiring one call the first time it's created, it would involve calls every time it's accessed.
<13> mcmillen: ok
<2> christor: unless there's no match for "lo*" in the current directory, in which case Python (probably) gets the literal string "lo*"
<4> Gambit-, only "if self._first_access: ... else:" sounds better than __getattr__ :-/
<2> but it depends heavily on your shell, mine will complain if no match is found
<4> Gambit-, and besides, why do you need hasattr() in your case?
<3> TFK, hasattr is needed to check for a given access wether or not an equivilient __getattr_var creation function has been set, and if so it calls it, otherwise it procedes normally and raises an error.
<4> Gambit-, why does it call it each time? __getattr__ is only called when the requested attribute doesn't exit; but if the user wants it, why not actually create it the first time?
<4> That means that the next time the user tries to access the same attribute, it's already there and __getattr__ isn't invoked.
<3> TFK, I do create it the first time, but if I have a if self._first_access flag, then I have to check that each time.
<3> that's why I'm saying __getattr__ seems better then some flag check.
<4> OK. But hasattr() is redundant in this case, as I see it.
<3> no, the hasattr is to see if the creation method exists, otherwise I'll loop infinitely.
<3> or rather, the in __dict__ checks that
<3> hasattr would loop forever.
<4> Gambit-, why do you need to check if it exists? Why not use pre-made flags, that would be defined invariably?
<3> ...
<4> Sorry :-(
<3> TFK, An external module sets the code for creation into the Customer cl***, say, "__getattr_foo_maker". The Customer__getattr__ gets called for Customer.foo. It looks for the existence of a .__getattr_<var>_maker method. If that exists, it calls it, and the result gets ***igned to Customer.foo.
<14> Gambit-: if you name your variables like that, it'll break in subcl***es.
<3> Jerub, how so?
<14> Gambit-: if you have Foo.__bar_baz in a supercl***, it will be Bar._Foo__bar_baz in the subcl***
<3> I didn't know that.
<15> is there an unhex() function in python?
<15> s = unhex(hex(s))
<14> Jj: int
<4> Gambit-, according to what you have explained, this collection of creation functions either exists (self._has_purchased=True) or doesn't (=False), whcich you can test from __getattr__. Am I wrong and there's really a need for individual checking?
<12> Jj: int(x, 16)
<15> :o!
<15> awesome :D
<14> Jj: int('ff', 16) == 255
<15> thanks
<3> TFK, I can't test it because I don't know what additional modules exist.
<15> thanks
<15> :q
<4> Gambit-, hmm. Try calling the base's __getattribute__. If it fails, it'll throw AttributeError that you can catch.
<4> This one should not just into an infinite recursion.
<4> http://python.org/doc/2.4.2/ref/new-style-attribute-access.html
<3> TFK, what? Where?
<4> inside __getattr__
<4> Hmmm. I wonder if... initializer methods will be created as soon as possible. Once called, the initializer methods will do their stuff and then replace themselves with the functional methods.
<4> functional=worker
<4> No flags, no __getattr__.
<7> how can I test if a string is less than a certain amount of bytes?
<4> len(s) < c
<7> len("123") will return 3, for three charecters
<16> Is there a Python security FAQ? I'm trying to figure to port a Perl suid-root script to Python, and I'm not sure where to look for equivalent features
<14> nailbiter: os level stuff is usually in the os module.
<14> for things like seteuid and stuff
<4> punkrockguy318, which is also three bytes. A string is just a stream of byets, in this particular case the bytes were interpreted as the characters 1, 2, 3.
<16> Jerub: But that won't work if you're not root to begin with--for some reason, the Python interpreter doesn't start a root u+s script as root (Perl actually does this by automatically invoking a special wrapper)
<16> Jerub: Is there something similar that ships with the core Python stuff?
<14> nailbiter: you're going to have to write a wrapper.
<14> it's actually an operating system level thing
<14> you can't have a suid program that starts with #!
<14> it's not allowed.
<4> Gambit-, http://rafb.net/paste/results/kophnH96.html <--- __getattr__? what is this __getattr__ you speak of? ;-)
<7> TFK: thanks
<16> The Linux kernel doesn't allow it, but Perl works around it by checking permissions on the script and then invoking it through a suid-root wrapper
<17> Is there a way to measure the time a function takes to come to an end?
<3> TFK, I'll take a look at it when I wake up :)
<14> zanella: use the profile module.
<4> it's really very short :-)
<18> zanella, time, timeit, profile modules, take your pick
<17> thanks
<7> would someone mind helping me with this program? i just need someone to test something to see if it works properly
<19> zanella?
<17> MFen : yes?
<18> nailbiter, there's no such thing in python...
<4> Gambit-, oh, and if you have a few such modules, perhaps runtime mix-ins would be in order. *ponders*
<16> The thing is, the Perl wrapper has to do a crazy number of sanity checks to safely start as root; I don't want to inadvertently open a security hole by writing my own wrapper
<19> zanella: oh, sorry. i thought yango was naming a profiling module i'd never heard of :P


Name:

Comments:

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






Return to #python
or
Go to some related logs:

reflash zaurus 3200
there was an error installing centos
#linux
php4-mysql illegal instruction
#fluxbox
#linux
ralink rt2600 linux
grub loading error 17 ubuntu
fluxbox toggle decorations
#linux



Home  |  disclaimer  |  contact  |  submit quotes