@# 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



Comments:

<0> [dylan]: however, you can just read in the whole thing, or a sizeable portion, and see if it contains a NUL ("\0")
<1> Yhg1s: and then do a seek -XX where XX = len(string) - distancetoNull
<1> no.. better writing a function to read the string, it just surprise me there is not a default one =)
<2> or mmap
<0> [dylan]: well, if you really must have the filepointer back to right after you read the NUL-terminated string. But why bother? Just keep the data around.
<3> where can i get a good socket and ssl tutorial?
<1> Yhg1s: 'cause i'm handling a BIG file.. and i wouldn't like to have it on ram
<3> sorry for my english (i'm from spain)
<0> [dylan]: you don't need to read the whole thing.
<3> f.read (size)
<1> where i dunno size
<1> :D
<0> ratzingerz: I don't know of any good socket and ssl tutorial.
<2> so pick something convenient
<2> not a byte, not a gigabyte
<0> [dylan]: anything but byte-by-byte, unless performance really does not matter.



<1> it does =)
<1> so str = f.read(1000) f.seek(1000-len(str)) ?
<3> 1000-len(str) = 0
<1> what if i'm at the end of the file ? (the seek would bring me back not at the same place i was before)
<0> as I said, if you must. I don't know what you do with the rest of the file, but just keeping the data around is more efficient.
<0> [dylan]: it will not be a oneliner in any case. just make sure you calculate it right.
<4> i have a question
<1> ratzingerz: i would hope not, str would truncate at the first '\0' i suppose
<0> of course not.
<0> Python strings have no problem with NUL bytes.
<4> what does it mean for function (or cl***) x to be "thread safe"?
<3> but eah time you make a read you overwrite the str
<0> kbrooks: it means you can use the same instance from multiple threads at the same time, without messing up internal data.
<1> kk :D i'll find a solution. I tought it was a sort of "common" problem
<3> sou the str always have 1000
<5> deja vu
<2> kbrooks: you can safely have multiple threads call it at the same time
<1> kbrooks: think if two threads, accessing at the same variable, at the same time. Here you should see what does it mean "thread safe"
<1> Yhg1s: thank you
<5> kbrooks: usually thread-safe means the method uses a lock to avoid having more than one thread toying with the same instance variables simultaneously
<5> method-scope vars are OK because each thread gets its own copy when it enters the method
<1> bye
<4> LOL @ first image in post: http://thedailywtf.com/forums/thread/75718.aspx
<3> hi , how can i make a GET petition to a https url from python script?
<0> ratzingerz: urllib.urlopen
<3> ok
<3> and i y want to send a headers?
<3> sorry
<3> and if i want to send a headers?
<0> see the documentation for the urllib module.
<6> Would you say python uses quite a bit of memory? If not, about how much would you say it uses?
<7> I'm experiencing something odd with ez_setup.py - I have to name the destination in --site-dirs, even though it is in the standard sys.path, otherwise it thinks it shouldn't write .pth files.
<8> more mem than c, (probably) less than java
<6> well that's one extreme to the other; I ***umed that :>
<8> well i mean, what do you want to compare it to
<6> will hello world use up 5 MB..
<6> guess I'll just test it here
<9> does anyone have experience with mysqldb?
<10> sure but why would you want to use that?
<9> I am copying and pasting the contents of the string "sql" into mysql and it works
<9> but in python numrows isn't 1 here:
<9> cursor.execute(sql)
<9> numrows = int(cursor.rowcount)
<9> my use of mysql is very very limited in this python app, and mysqldb had a smaller learning curve (or at least better docs)
<10> compared to what?
<9> this was working before so I can't see what I broke
<9> compared to everything else I could find through google?
<10> so what are you seeing that you didnt expect to see?
<10> rowcount is wrong?
<9> yes
<9> it's not 1
<9> it should be one
<9> I'm copying and pasting into mysql and it's 1
<10> are you sure you are authenticated as the right user, in the right database?
<9> yup
<9> or at least, the same user in mysql and the python app
<10> not sure what to tell you except "dont use mysql"
<9> interesting, that time it worked
<9> I guess the bug is somewhere else
<10> or not at all
<11> hello all.



<10> good greetings!
<11> for some odd reason i'm getting a "bad interpreter" error because of the shebang line in this script i wrote. it's the same shebang line i've used in other scripts of which i have no problems executing, but this one is posing a problem for some odd reason.
<11> #!/usr/bin/python is the same line i've used for every script
<10> are you running it somewhere new?
<10> the prefered shebang is #!/usr/bin/env python
<11> it's in the same spot it's always been.
<10> i mean is the script on a new system, perchance?
<11> no, not at all.
<11> and what is weird is
<12> cshaman: are you running the script from a no-exec filesystem?
<11> all of a sudden, none of my scripts are working
<11> they were just working a moment ago except for the one i specified
<13> cshaman: can you run python by itself?
<10> "none" but first you said "this one"
<14> the executable exists?
<10> be more clear!
<11> yes, i can run python by itself.
<14> it exists where you specified it?
<11> yes, /usr/bin/python
<2> cshaman: what's the exact error message?
<11> deltab: $ ./audiodir.py; : bad interpreter: No such file or directory
<15> cshaman: verify that the script is executable, and verify also the end of line
<2> the error message starts with a colon?
<16> cshaman: if you do "head -n2 audiodir.py|cat -v" do the lines end with ^M?
<11> deltab: the ';' seperates terminal lines
<2> if so, the problem is the line ending
<2> oh
<11> (i didn't want to paste)
<2> noh, no, colon not semicolon
<2> do what ChrisLong said
<11> the script has execute permissions
<2> yes, otherwise you'd get a permission error
<16> cshaman: if yes, you have a lineending problem, like deltab said.
<17> if i want to delete an item from a n-uple, are there a better way rather than convert it to a list remove it there and then convert the list to a (n-1)-uple ?
<11> ChrisLong: The lines end with ^M
<16> r0ver: use slicing, i.e. tup = tup[:n]+tup[n+1:]
<10> maybe you dont want to be using a tuple to begin with?
<16> cshaman: somehow you got dos/win line endings in your script
<4> hey.
<8> is there sucha thing as i++ in python?
<11> ChrisLong: I transfered the file from a Windows box, but I use Vim even on Windows.
<4> ned: no.
<17> ironfroggy: well... the plone guys decided to used a nuple for that... sure the had a reason
<4> ned: use i += 1
<16> cshaman: vim uses the native line endings if you create a new file
<16> cshaman: is only this script affected?
<8> kbrooks, bummer. ok thanks.
<11> ChrisLong: No, all of them are.
<4> ned: "bummer"?
<11> ChrisLong: And most I haven't written on the Windows box.
<11> ChrisLong: That's a lie, some work.
<11> One moment.
<8> kbrooks, i'm fond of i++ aesthetically, simply
<8> is there a way to do something like `int variable[50]` ?
<11> ChrisLong: http://deadbeefbabe.org/paste/764
<4> how do i escape ">" and stuff?
<4> ned: variables = [0]*50
<8> aha. thanks.
<10> r0ver: its not called a nuple!
<11> ChrisLong: That script was working moments ago; python is still located at /usr/bin/python, yet I am recieving similar errors for other scripts that used to work as well.
<2> have you opened them in an editor since?
<16> cshaman: the module is importing itself
<17> ironfroggy: you're right but my religion doesn't allow me to call tuple to something with 3 or more elements :)
<16> cshaman: rename it. but this is a totally different problem
<16> cshaman: either use dos2unix or "sed -i -e 's/^M$//' file1 file2 file3" to fix file1 file2 file3.
<16> cshaman: but you should find out how the \r in the scripts got there
<2> if they're appearing in files that used to work, I'd suspect an editor
<4> can you do cgi.escape?
<3> how can i make not to follow a 30x redirect in urllib or urllib2?
<18> has anyone successfully gotten pyMPI working?
<12> ratzingerz: if you don't want to follow those redirects, use httplib.
<3> but, has httplib https support ?
<16> kbrooks: you mean replace e.g. '<' with '&lt;'?
<18> I have a specially compiled version of python, and when I import struct, I get "undefined symbol: PyString_Type"


Name:

Comments:

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






Return to #python
or
Go to some related logs:

Cygwin Xhost Ubuntu
scpaview
#perl
#perl
udev_run_devd udev_run_hotplugd failed gentoo
#linux
import information_schema denied sugarcrm
determine size of resulting image file
ubuntu build package from source
#physics



Home  |  disclaimer  |  contact  |  submit quotes