« first day (1411 days earlier)      last day (3540 days later) » 

12:18 PM
@MartijnPieters relstorage is just plain borken
:(
 
is this too old...?
 
No. That's genius ;)
 
image not found?
 
@AnttiHaapala I uploaded it directly to clouapp -- and then linked back to chat
working for me
 
where
nope does not work here
cdn issues?
use imgur
 
12:28 PM
user image
4
@AnttiHaapala now?
1 message moved to Trash can
 
Sigh. Asking "what's your question?" and getting the response "my question is, [insert summary of assignment here that doesn't end in a question mark]"
I considered replying "please ask your question in the form of a question", but I don't think it would be productive.
 
@PeterVaro yep :D
@Kevin give here and we cv
 
-1
Q: Python Dict: Key in one file and value in another file, find value and/or sum of value

LavI found similar questions but that only pulls the value of the respective key from second file. I am looking for little more advance. File_one this is a an output of some classification Node Node some_value some_value some_value A B 2 2 24 A C A D A E B ...

OP promises to update with his code, as soon as he starts writing it :-I
 
@MartijnPieters seriously, there are many cases that do not make sense, for example, usernames are to be stored in ascii strings only?
 
@AnttiHaapala You'd have to check with people like Tres Seaver what happens to usernames in Python 3 ZODB.
 
12:37 PM
dunno which one it is but
File "/home/ztane/work/relstorage/relstorage/adapters/txncontrol.py", line 92, in add_transaction
encodestring(username), encodestring(description),
the stuff going in either of those is str()...
does not make much sense base64ing it :D
 
Actually mega. The more we can keep everything on site, the better :)
 
nicee
next image pasting
 
Come on, Python support!
There are some nay sayers:
> This is going to end badly. Oh look, here's this incomprehensible mess someone posted a question about... I'm going to just run it without even looking at it.
But... You can already do that.
It just requires "copy/paste/open new file", as opposed to "click the button".
Unless running the code straight in the SO window somehow gives it elevated privileges to mess with your account or cookies or whatever. Something something Same Origin Policy something something.
 
1:27 PM
@MartijnPieters 1 part of zodb uses binary txids and the tests use non-binary :?
 
@AnttiHaapala There are non-binary representations; the canonical value is binary.
A bit like hex vs the binary representation of a SHA1 hash for example.
 
@MartijnPieters i mean:
b'\0' * 8 vs '\0' * 8
 
Man binary has been the topic of the week in here
 
this is from the 2to3d ZODB installation that I think works
its tests use the latter form ...
 
DSM
Too-early morning cabbage, all.
 
@MartijnPieters for example ZODB/tests/TransactionalUndoStorage.py gives me str() ids happily... :(
the same given to ZODB.utils.u64 then fail ofc
 
ZODB is an old beast. Loads of lizard hind-brain to content with.
 
ZERO = '\0'*8
yeah, that in zodb tests, no wonder it craps the shit out, wonder why the test would work at all on python 3 on other storages
guess just have to make an exception for that too
compat_u64 that will happily accept whatever crap given :D
 
1:55 PM
@Martijn you've managed to anger someone it appears :)
 
The above cv-pls is closed
cbg()
 
Hi guys CBG
Any ideas why sessions would suddenly stop working on a web server?
 
Is the web server turned on?
 
haha
yes
 
Does it have any free memory?
Maybe there's one monster session gobbling up the available space
 
2:05 PM
ooo one sec
I did top and nothing is running crazy
 
DSM
Disk space is regularly an issue on one server I use. When something goes wrong it fills all available space with logs, which seems counterproductive.
 
there should be logs on the cloud
 
Welp, that's the extent of my web server expertise.
 
DSM
@Kevin: hey, we're learning. Neither of us recommended turning it off and on again (which works for my router, so who knows?)
 
But if you reboot your web server, you can't advertise 99.9999% uptime :-(
You're only allowed five seconds of downtime a year. Gotta make it count!
 
2:09 PM
haha
 
DSM
(1-0.999999) * 365*24*3600 ~ 31.5. So I think you might just make it.
 
restarting worked
damnit
Not working again
Where does server store session data anyone know?
 
what server?
 
Ubuntu
 
/var/logs maybe
 
2:16 PM
@JonClements Hm?
 
@Johnston Apache2? Nginx?
 
apache2
 
Session data is defaultly saved to /tmp
 
oh
 
But that might be modified with Ubuntu, can't mind
 
2:18 PM
@Martijn the now deleted post
 
scratches head I think from my old PHP days (ducks from various thrown projectiles) that you can use sys_get_temp_dir to get the directory.
 
oh
o
 
But I'm sure there's a Python equivalent :)
 
@Johnston what exactly do you mean by "session data" here? Are you talking about something like Django's sessions framework, or something lower level?
 
@IntrepidBrit I'm glad I threw the brick low then on the assumption you'd duck! woo hoo
 
2:19 PM
Trying to login.. Login doesn't work.
Anything that uses the session dict
comes up empty
 
@JonClements Heh, had not seen that. Haters gonna hate.
 
@Martijn I downvoted and flagged... but they self deleted so...
 
I asked for a better question title. The wall of text post didn't help; there was too much code and talk there.
 
"Thanks for your one helful [sic] comment mduran" Aw, my comment wasn't helpful? :-(
collections.Counter usually goes over really well...
 
2:22 PM
Yay, I can still flag the comments on deleted posts.
 
@Johnston Do you have any other sites running off your webserver? Test them to see if sessions are working?
 
@Johnston I wish you'd say what framework you are using. I don't think this has anything to do with Apache sessions.
Ooh look, only 57 points left to 200K.
 
Actually other sites are working... But two of them are not
 
Quickly, start downvoting all his questions!
 
@DanielRoseman oh - when you reach 200k... you have to buy the room drinks...
 
2:24 PM
sounds legit
 
@Daniel yes... it's errr... in the room rules...
(quick guys - how do I errr... edit the rules page!?)
 
DSM
Can't speak for anyone else, but when Martijn hit 200k I went drinking. Also when Jon hit 40k. And I hit 70k. And 60k.
.. I may have a problem.
 
at what age am I old enough to say "I'm too old for this"?
 
@DSM doesn't sound like a problem to me...
 
gents, whats a proper way to escape wildcards for MySQL connector with python? logical solutions, dont seem to work me. Normal %% and etc just fail
 
DSM
2:28 PM
@Daniel: it's a problem if you hit 200k and all I have is coffee to drink.
 
@DSM "I don't have a drinking problem doctor - it's just all these people that keep hitting 10k rep boundaries that I've never met, but hang around with on a programming Q&A website..."
 
@corvid When you have three days left til retirement
Helps if you're a grizzled cop that doesn't play by the rules
 
`query = "Select * from data where name like %s limit 1"`
`cursor2.execute(query, ('%%%s%%' % string))`
is my latest, twisted variant, normal `LIKE '%%s%' ` doesnt seem to work
 
@corvid Difficult to tell... but saying it with your dying breath would be nicely dramatic :)
 
@Kevin No, if you're three days from retirement you are a grizzled cop who's always played by the rules, but you've just been teamed up with a young maverick who doesn't. That's when you're too old for this.
 
2:29 PM
that's gonna be me someday
 
And if you're Bruce Willis, you can say it any time in any circumstance.
Welcome, @SitzBlogz
 
@rodling use cursor2.execute(query, ['%' + string + '%']) instead of string interpolation... to prevent SQL injection problems and automatically get correct escaping
(and maybe re-think using string as a name as it's a builtin module - so may confuse things... maybe param or text etc...)
 
@JonClements ya i've been trying to make it anti sql injection compliant, but just didnt work :(, i'll give this a shot
 
Thank you @Kevin
 
2:34 PM
Bruce Willis can do whatever he wants, including star in lots of Japanese commercials
 
@rodling as long as you're using something DB API 2 compliant, the cursor/execute objects will take a query string argument (with placeholders) and another argument that are the values to be substituted... and that substitution will do the escaping necessary to build a correct and sql-injection safe attack full query string
 
@JonClements
  625.         cursor2.execute(query, ['%' + string + '%'])
File "C:\Python27\lib\site-packages\mysql\connector\cursor.py" in execute
  379.                 stmt = operation % self._process_params(params)
File "C:\Python27\lib\site-packages\mysql\connector\cursor.py" in _process_params
  264.                 "Failed processing format-parameters; %s" % e)
still same error, i tried your variant earlier with () rather than [] had same issue
 
What's the exact package you're using re: mysql connector?
 
can you open two files at once in the same with block, one for writing and one for reading?
 
@corvid with open('input') as fin, open('output', 'w') as fout: ?
 
DSM
2:38 PM
Yep. with open(somefile, "r") as fp_in, open(somefile2, "w") as fp_out:
Aargh
Too fast, Jon.
 
ah cool that's the syntax, thank you
 
I think I figured it out
I am getting attacked
 
@DSM didn't have to type underscores I guess :)
 
The session directory is filled to the brim. If i dump it it fills right back up
 
@corvid it's 2.7+ syntax only, otherwise from 2.5 you had to use a nested contextlib thing... which wasn't quite the same...
 
2:40 PM
meh, always using 3.4 these days. 3.4 is the mightiest version
 
@corvid if you have a huge list of files for instance, from 3.3+ you can use an ExitStack
 
wait, can you make your own classes use with? It just needs to have an __enter__ and __exit__ defined, doesn't it?
 
@MartijnPieters Just looking at the contextlib to find the reference for @corvid... one thing you could have mentioned (good old hindsight) is some of the new functions ithere...
@corvid you don't necessarily need a class... you can use a decorated function
 
oh cool, I see...so with open() would kind of be like:
@contextmanager
def open(f):
  try:
    open(f)
  finally:
    close(f)
(in a summarized lazy way)
 
Well... in a similarly lazy answer - yeah...
The docs are good - have a read :)
 
2:48 PM
true. One of the best things about python, lots of good documentation
 
@corvid thanks for making me have to look up the docs... there's a few bits in contextlib I could probably use at some point, and didn't realise were introduced to 3.4...
 
not sure if sarcasm
 
Ooh, contextlib.redirect_stdout. I reinvented this the other day.
 
@JonClements using MySQL's connector
provided by oracle
 
@JonClements cough cough cough cbg all :-)
 
2:56 PM
@Zero oh... I remember you mentioning now... :)
That awkward moment when...
 
In actual fact it's just about the minimum possible patch, and only really the result of a snarky comment by a core dev about a bikeshedding argument over the name prompting me to put my money where my mouth was, but still ... name in the docs :-D
 
@JonClements only the stdout redirection and supress are new in 3.4
and though helpful, they didn't make the cut.
 
On an entirely different subject - weirdest quote I've seen in a news article all week: "You can't give a 9-year-old an Uzi and expect her to control it".
 
My coworker who grew up in Russia says they had a high school class about the operation and maintenance of AK-47s.
So no, not all nine year olds. But maybe one in the "gifted students" program.
 
cabbage folks, quick question
i have a string of a path, can i use os.path to change one dir up?
 
3:11 PM
@d_rez90 yes: os.path.dirname(my_path)
 
thanks @Dan
@DanielRoseman
 
@MartijnPieters Indeed - but "how do I redirect stdout" questions aren't exactly short in supply
 
@JonClements Anyone written a Python 3.4 version answer yet to the canonical? :-)
 
this guy posted a question that's a dupe of one he deleted yesterday. I'm tempted to just copy-paste the "you're more likely to get help here if..." comment into the new one.
 
@Martijn That was my first thought on seeing it :)
heya @d_rez90
 
3:38 PM
the curse of python; once you start using it a lot, using other languages feels disappointing
6
 
If by looking at my FB timeline this ice bucket challenge thing (if everyone donates) is going to own half the world's capital, surely?
Wow... it's a simple question is it answerable in SO format though...
 
I'm not clear on what that guy is asking.
 
DSM
I think he's asking about whether the set of matches is a subset of the other set of matches.
I.e. whether one dominates the other.
 
For example, is [AB]D included in [AB][CD].
 
As in, "for all strings that can be matched by regex A, can those strings all be matched by regex B?"
 
3:44 PM
@Kevin yes
so... is any of ['AD', 'BD'] in ['AC', 'AD', 'BC', 'BD'] kind of thing
 
how do people make staging environments, anyway?
 
It's fairly straight-forward to expand the character classes out and do the combinations, but if there's anything else in the regex apart from classes and constants, well... I don't even want to to think about it
 
DSM
@Jon: that's what I was just asking the OP about..
 
Well, Dietrich's viewed it the same as I have :)
 
when does garbage collection run in a method?
damn... someone answered the question a second before I submitted mine
 
3:55 PM
@corvid Garbage collection runs periodically, depending on the number of allocations and deallocations that have taken place.
 
@JonClements hey what's up
 
I think you are talking about reference counts, however.
 
@corvid garbage collection is not relevant to that question
 
@corvid GC doesn't apply there; GC only applies to circular references.
 
@DanielRoseman the one I just answered?
 
3:56 PM
What the OP wants cannot be done from the function.
 
@d_rez90 just saying hi - welcome to the room and such :)
 
@corvid yes: see kindall's comment
and indeed Martijn's answer
 
ty sir @JonClements
 
man. Thought I was clever there for knowing gc cause I read about it yesterday
 
Anybody care to help me here
 
4:04 PM
gbg
cbg*
 
@d_rez90 was looking at that one, can you do an os.walk to find the file?
 
nope
because i am looking for a file relative to that file's path
and multiple files of the same type exist...
so like foo.py has a config file either in the same dir or one dir up..
well... sorry i see what u mean now
nope sry don't see how os.walk would help me
 
@Martijn just deleted my comment now you've edited the post :)
 
@JonClements Yeah, it is clear what the OP meant.
 
4:21 PM
@Martijn I don't have a 3.x gold yet, but I think it's a reasonable enough dupe target mentioned for this post
 
@JonClements Agreed, hammered.
 
is there a python equivalent to os.walk that allows you to traverse up a directory? (For example, os.walk('home', topdown=False) will look at 'home/foo/bar' first and work its way up to 'home', is there anyway to start with home, then go up from there to '..'?)
 
Only Lennart Regebro and I have gold 3.x badges.
 
@Martijn I'll get there eventually (maybe)
now answering much any more doesn't help admittedly... but... give me a year or two :)
@Martijn might get a silver by the end of the year though :)
Is "no - not really" a perfectly valid answer to this one
 
4:43 PM
Yeah, but it doesn't answer the secret invisible question, "if this isn't a good idea, what should I do instead?"
 
DSM
That OP's use of terminology is, shall we say, idiosyncratic.
 
I like the typo in this post.
 
DSM
♫ me too, in B minor ♫
 
"My end goal is to run the python script as a task every 10 minuets or so". I have a lot of dancing to do tonight, and I can't be bothered to manually run this script every tenth song!
Incidentally I think the answer to that question is "use sys.argv". Not entirely sure, as I don't speak Visual Basic or SQL.
 
how does sopy run on production, anyway?
 
4:54 PM
@corvid it appears to run very well, thanks for asking :p
 
heh. I'm totally stealing stuff from it again, don't tell Davidism
 
@corvid it's not theft... it's an OS project... just make sure you read the copyright and make sure you provide attributions where necessary :)
Umm... can see the comment thread going downhill on this one
 
is there a way to convert/import the time python module to c with cython like you do with math?
cdef extern from "math.h":
	int log10(int x)
like this references math.h from cython libs
but haven't found anything for time
 
@Moderateur if you have the development version of Python (all the source), then you're effectively after hg.python.org/cpython/file/fb3aee1cff59/Modules/timemodule.c - which points you to sys/times.h
go from there...
 
@JonClements thanks. in fact I have the python development version but a simple locate in my terminal gave me multiple results
/usr/include/i386-linux-gnu/sys/times.h
/usr/include/i386-linux-gnu/sys/vtimes.h
/usr/include/linux/times.h
/usr/lib/syslinux/com32/include/sys/times.h
/usr/src/linux-headers-3.13.0-24/include/uapi/linux/times.h
/usr/src/linux-headers-3.13.0-30/include/uapi/linux/times.h
/usr/src/linux-headers-3.13.0-32/include/uapi/linux/times.h
/usr/src/linux-headers-3.13.0-34/include/uapi/linux/times.h
goin to see which is what
 
5:07 PM
heya @mercnet - welcome
 
Today I learned that the parameter list in a function definition can contain a trailing comma. I knew that function calls could have trailing commas, but I didn't know definitions could.
The usual excuse of "it makes it easier to write a call that takes up more than one line" doesn't hold as well here. How often do you write a def on multiple lines?
 
DSM
It would seem stranger to me if you could do the one and not the other.
 
The OP of the question that spurred this discovery seems to be ignoring me :-(
"why meaningless commas are allowed ?" I... I just told you why.
 
@Kevin I can see it starting to happen more often ...
 
"Why does this work?" questions kind of annoy me. It works because it doesn't crash when you try it.
Things work because they don't not work. Hope that helps.
 
5:44 PM
almost beer'o'clock...
another half hour to get this out the door... then woot... or whatever
 
poor dear, trying to append to a list with mylist = [mylist, new_item]
I wonder if that would work in Lisp, with their crazy nested two element tuples... Not gonna work in Python though.
 

« first day (1411 days earlier)      last day (3540 days later) »