« first day (1527 days earlier)      last day (3412 days later) » 
01:00 - 21:0021:00 - 00:00

1:58 AM
Lol, just rediscovered that we changed the "bug" tag to "do the needful" for sopython-site issues. Gets me every time. :)
5
 
 
1 hour later…
2:59 AM
Hey does anyone know how to lock and unlock windows accounts using python?
 
 
2 hours later…
user559633
5:25 AM
does anyone have the slides to this? youtube.com/watch?v=Uyj2UFTL_vg python epiphanies 2014
 
6:34 AM
Sunshine has finally dawned upon the sopython chatroom .. You will burn the hat @Ffisegydd , or you just did..
 
Dan
@abc cbg
@abc got my flag (no votes yet, sorry)
 
7:46 AM
cbg Sunday all
 
Cbg
 
Dan
@JonClements cbg
@Ffisegydd cbg
 
 
2 hours later…
pad
9:56 AM
hi
 
Hello @pad
 
pad
need some advise on generic crawling
anyone a bit familiar with it or scraping?
There are unit tests.. you test a function and assure yourself it does what it does.
so I wrote some unit tests and I'm assured
now I've run my crawler and collected a large amount of data
I want to perform some kind of a "random test".. this is not a unittest or integration test.. this will check that random pieces of data have been scraped and put into the database
what do you call it, and what are the-if any- best practices around it?
completenes test? statistical test?
 
I can't help sorry, don't have much experience with crawling. Someone may be able to help you, but it is a Sunday morning, so the likelihood is that it's going to be pretty quiet.
 
Hi, I am new to python. I know javascript, jquery , html5 and css3. I have a problem and I have a problem!
Problem I want a variable to only be given once forexample....
if var == 0:
run code
but the code i only want it to assign a variable once - help!
 
10:11 AM
@IPAddress sorry you're not making much sense.
 
abc
wut
 
If you only want to assign the variable once then just assign it once.
 
can i upload my code
 
If it's longer than 6 lines, please put it in pastebin.com and then post the link here.
 
abc
10:15 AM
You want global variable?
 
yes!!!
 
abc
Nvm
 
abc
10:39 AM
Actually, what I posted was a correct solution
If you want to modify the module-level variable tree from inside a function you need to specify it as global inside that function @IPAddress
def main():
	global tree
	# the rest of main function
 
 
1 hour later…
12:12 PM
@MartijnPieters melons
 
12:23 PM
Finally I can identify android users by their hats..
 
@tilaprimera: not actually in the room today; my office machine must still have the tab open.
just on mobile now, so signing of here, cheerio!
 
12:59 PM
So, say you are designing a RESTful API, and you have a route like POST /api/user to add a user... Would you bend the standard a bit and change that to POST /api/register? Would you make a redirect from POST /api/register to POST /api/user?
 
1:14 PM
grumble stupid error
 
1:24 PM
@MartijnPieters is that a parrot coming out of the armpit??
 
 
1 hour later…
4:05 PM
cbg
 
abc
cbg
 
@abc That's a dupe of stackoverflow.com/questions/2817869/…, but my CV just misfired.
Grr, codec cargo cult-ers at it again.
 
user2555451
cbg
 
user559633
weekend breakfast cabbage all
 
user2555451
Does that come with ham or sausage?
 
4:17 PM
@tristan Arrrrrr. I mean, cabbage!
 
user559633
haha nice. i'm surprised you have gold badges left to get
 
@Ffisegydd whats your say about this regex ?? :P
 
abc
Hmm, do you think a railway company can afford storing the information about cheap suburban tickets in some remote database (to search it for the value from barcode) every time a person attempts to get to the station?
 
@Swordy disgusting. But then I say that about all regii.
 
user2555451
@Swordy - It looks like you opened a .exe file in a text editor. :P
 
4:28 PM
Hehe.. :P . There are so many cases and finally this sh** works .. Seriously , I wouldn't prefer playing around with text.. !!
 
Last night I dreamt that some disgruntled close-vote-recipient managed to get enough of my own questions closed and deleted overnight that my rep fell to ~8000. #AstralPlaneProblems
@MartijnPieters Now edited to a link-only answer.
 
user559633
@abc elaborate? what do you mean by "attempts to get to the station?"
 
user559633
if you mean every time they try to go through the gate, i'd say to that latency is the big concern. the data itself is cheap to store
 
abc
A station has a turnstile, capable of reading barcodes on tickets. It also somehow checks if the barcode is valid.
 
@ZeroPiraeus Golly, that user is stubborn about it.
Added more information for them to digest including a test that'll show that their 'solution' is not going to work.
 
4:37 PM
@MartijnPieters Yeah, flagged.
 
user559633
@abc the barcode is valid or that it hasn't been reused? you can do things to make sure the checksum is valid, like luhn does for credit cards
 
abc
Hmm, yeah that's a good question. The validation (whatever they are required to do) is usually done within 1-2 seconds.
 
user559633
if there's some expiry on the tickets and you don't care about mentioning the difference between invalid and expired, you can keep your dataset low
 
user559633
and if the ticket purchase can happen onsite, you could have the ticket machines talk to a more "local" server so you don't incur write-delay on top of round trip time
 
user559633
and the round trip time is really negatively affected by how many intermediate routers you go through
 
abc
Oh Alex Martelli started answering again
Pfft. The hat won't be displayed :(
 
Is there some way to get an object's class apart from obj.__class__? In particular, is there a way to get just the class name, as opposed to the full "name". So rather than x.y.Z I just want Z.
I mean, other than splitting on .
 
abc
obj.__class__.__name__?
 
I thought that __class__.__name__ doesn't have dots? __class__.__qualname__ has the dots?
 
abc
Or type(obj).__name__
 
4:53 PM
Legends, both.
 
user559633
@abc i think it's totally feasible, but i think your main challenge is what happens if the delay is over 2 seconds (or whatever your ceiling is) -- do you just consider it as failed and let the person on or do you switch over to manual checks?
 
abc
@tristan those tickets seem to be one-off, so I guess they use the database, indeed
 
stackoverflow.com/questions/27584780/… cannot reproduce, according to edit by op
 
user2555451
5:01 PM
This question is an example of how noone can debug anymore. The error message says everything!
 
user559633
@abc then i guess it depends how many stations there are and how stable the network is, but i imagine that if you can buy tickets at those stations, there's already a reliance on internet connectivity
 
user559633
i think a railway company can definitely afford it and if the ticket readers can do pre-validation, you'd only be using the database/network for useful transactions
 
You can use vars(obj) to get the variables of obj. Does anyone know a way of getting the arguments that can be passed to a class __init__ in a separate class method?
 
user559633
@iCodez yeah, internet as reading/"debuging"
 
Basically I want to define a nice __repr__ but need to get the input params.
 
user2555451
5:09 PM
@Ffisegydd - Use inspect.
 
Good shout
 
user2555451
Specifically, inspect.getfullargspec.
 
user2555451
Don't use inspect.getargspec though because that got deprecated.
 
Ah ok
 
abc
5:11 PM
On Python 3.3+ use Signature
which is pretty awesome
 
Nice. Got a nice __repr__ now which can be used to re-create my object.
 
abc
eval(repr(instance)) haha
 
Apparently it's good practice to have a repr that can replicate your object.
 
Yeah, then you can replace pickle with repr and eval, and have it just as secure...
 
Meh, I think really verbose reprs are annoying. I treat repr as "what I want to see in the shell" versus str is "the main identifier of an instance". If I want to see some specific value of an instance, I'll just get that value.
def __str__(self):
    return self.cool_value

def __repr__(self):
    return '<{} {}>'.format(self.__class__.__name__, self)
 
user2555451
5:23 PM
Personally, I prefer the <...> reprs over the other ones since they add more info and 99% of the time I use __repr__ to see what an object is, not recreate it.
 
exactly
 
True, but having this style or repr will allow me to see "Oh those two variables were used to create this data, and the random generator was unseeded"
For example one repr is Linear(add_rand=True, c=0.7601907882904024, m=1.2990278147963519, xlim=(0, 10), rand_factor=0.5, N=100)
 
user559633
i use different repr verbosity dependent on the situation. the repr for the network filesystem adds more info on top of the class, the repr for most of my db objects in flask is just like <User Email: {email} ID: {id} Status: {status}>...
 
abc
import decimal
d = decimal.Decimal(1.2990278147963519)

print(d, repr(d)) # 1.2990278147963518762253443128429353237152099609375 Decimal('1.2990278147963518762253443128429353237152099609375')
eval("Decimal('1.2990278147963518762253443128429353237152099609375')") # NameError: name 'Decimal' is not defined
This is why I wouldn't do that
 
user2555451
An example of how the <...> reprs are useful is:
 
user2555451
5:31 PM
>>> import re
>>> re.search('bc', 'abcd')
<_sre.SRE_Match object; span=(1, 3), match='bc'>
>>>
 
user2555451
You can't do that with the other ones.
 
Eh. If people are stupid enough to blindly copy and paste it and not think of that then they deserve to get a NameError.
 
The other option would be, as I'm generating some data, would to use the internal numpy arrays and their repr.
 
cbg all
 
@inspectorG4dget wow - your head definitely isn't with it tonight mate regarding that recent answer - everything okay?
 
Clearly not, though I have no idea what. I'm just going to leave the last option in my post, and delete the rest
haven't been feeling all that great, all day, though
I'm giving up debugging that. However, here's the code, for anyone who'd like a laugh at my expense:
def containsOnlyLetters(s):
    for char in s:
        if 'a' > char or char > 'z':
            return False
        elif "A" > char or char > "Z":
            return False
    return True
 
user2555451
That's ok, we have the edit history. :P
 
Hey @iCodez!
 
user2555451
6:20 PM
Cabbage!
 
Now you might want to post the link in chat and have everyone star it, so that it is never "forgotten"
you Banana?
 
user2555451
Wait, hold on, I'm still getting the lingo in here...
 
user2555451
Oh. Nah, I'll let you go. Today.
 
I'll just add it to my favourites and wait until your mother is better, don't wanna be a dick at the moment ya know. But one day...one day I'll pin it to the board.
 
I bow to your mercy
 
user2555451
6:24 PM
Yea, I'm banana. Thanks for asking. I had to go holiday shopping all last night. Ugh! That is like fighting through a forest of people.
 
@Ffisegydd: why do I have a feeling that this is going to show up at my bachelor party... whenever that is
 
Honestly if the worst thing that can be dragged up at a bachelor party is some bad code on SO, then you need to get out more and go on some crazy adventures.
 
user2555451
Actually, I'd say a jungle. Forests at least have a way through.
 
.. or you could say a flock of sheeple
 
user2555451
Is that what a group of sheep is called? I always said "herd".
 
6:28 PM
Apparently, due to religious metaphors, "flock" is used for sheep: bogglesworldesl.com/collective_nouns.htm
 
As the resident Welshman I can confirm that the both are generally used.
 
@Ffisegydd know any choice phrases in Gaelic of Manx I could use to impress this one girl?
 
Alas I don't speak Gaelic or Manx, but I know some Welsh.
 
hit me!
 
Do you want to impress her romantically or just generically?
 
6:30 PM
@Ffisegydd from a distance, I read that as "Alas I don't speak Gaelic or Matrix..." :p
 
user2555451
grabs some popcorn
 
either way. Preference for romance, but not required
@JonClements: you take the red pill...
 
Well the Welsh word for "cuddle" or "snuggle" is "cwtch", pronounced "cu-ch" (cu like cup, ch like church).
Also there's a lovely term on endearment which you'd say to a girlfriend which is "cariad", pronounced "carry-add". Which stems from the word "to love" with is "caru"
 
cool! Would you be able to put that in a sentence?
 
And if you really want to impress her, learn to pronounce this village name Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch
 
user2555451
6:33 PM
"cwtch" looks like the name of some core Windows exe. Those have the worst names.
 
it /does/ sound like an abbrev/contraction for c-watch... whatever that is
 
And yes, there are 4 Ls on the trot in that word.
 
had to google that village, just to see it to believe it
merci beaucoup! You are a gentleman and a scholar. Go into my stables and take my finest stallion. He's yours! His name is WindJammer
3
 
"Benifits of Quichesort" have...have they misspelled QuickSort? Or is there really something called Quichesort?
5
Oh no I see, it's really a thing!
 
I had the same thought
 
abc
6:50 PM
How could I miss Interpol's new album.. :(
 
just like I did. I assume we're not talking about the law enforcement agency?
 
abc
ofc not :D
Interpol is an American rock band from New York City. Formed in 1997, the band's original line-up consisted of Paul Banks (vocals, guitar), Daniel Kessler (guitar, vocals), Carlos Dengler (bass guitar, keyboards) and Greg Drudy (drums, percussion). Drudy left the band in 2000 and was replaced by Sam Fogarino. In 2010, shortly after recording finished for the band's fourth album, Dengler left to pursue personal projects. Having first performed at Luna Lounge along with other notable bands like The Strokes, Longwave, The National and Stellastarr, they are one of the bands associated with the New...
 
mind = blown
 
user2555451
Oh, you just reassigned your mind! You'll never get it back now. The old value it held has be gc'd.
 
abc
Dammit
 
6:58 PM
sok. As long as I don't lose my mind...
 
abc
My english level: enough to understand jokes, not enough to make them
 
abc
My next SE name will probably be toolazytodoitmyself, think it'll be useful in comments
Ow, ok, i indeed read something about those two, could you give me an example on how to use one of these in my code? @abc — Viva 7 mins ago
 
7:38 PM
Urgh BHAT has suggested eval
 
user2555451
Well, it looks like he deleted it now.
 
To be honest they're all poor answers. I'd suggest json.
 
@abc Too broad? There's like hundred of ways to make a persistent dict...
 
abc
Yup, and most probably a duplicate
And Veedrac hammered it
 
abc
Done
 
abc
8:14 PM
It's closed now
 
8:39 PM
Hi, can i ask something?
guys
 
@ml_guy don't ask to ask, just ask.
 
Is it possible to wrap as an object some .txt files with python?
 
what does that mean?
 
I'm working with lots od .txt files and i would like to treat them as one
of*
and then apply them some methods
for process them
no
just .text files
 
what's stopping you from reading them one at a time?
 
user2555451
8:43 PM
Or, said differently, why do you not want to read them one at a time? Loading them all at once will kill you memory.
 
i have all ready try that... I just wanted to explore an alternative way
ohh ok
 
sorry, you're not being specific enough about your problem or your desired outcome for us to give you useful solutions
 
can i put the question?
in the question i put details
 
for line in itertools.chain.from_iterable(map(open, listOfFiles)) might work for you
 
If you have a newly asked question? No.
 
8:44 PM
i asked 3 days ago
 
@inspectorG4dget yeah, I was thinking you could chain open files, but that wouldn't close the files properly
 
thanks inspector
 
@davidism: wouldn't the GC take care of that?
 
so you'd probably want to make a generator function instead that uses with
 
user2555451
Well, it would work in CPython when the interpreter shuts down. But before that point, there are no guarantees.
 
abc
8:46 PM
Yield lines from within context manager
 
def read_files(*filenames):
    for filename in filenames:
        with open(filename) as f:
            yield from f
 
ok
 
for file in filenames:
    with open(file, 'r') as f:
        # Do that funky analysis whiteguy
 
too slow @Ffisegydd!
 
@Ffisegydd: ack! using file as a variable name
 
8:47 PM
Mine has a reference to youtube.com/watch?v=qe1ScoePqVA though and so wins.
 
all ready try that one Ffisegydd
 
@inspectorG4dget that's just how I roll (which is to say I use Python 3)
 
@Ffisegydd lol, are we using that now?
justify anything, like adding semicolons to lines
 
user2555451
You still get a -1 for putting 'r'. open defaults to 'r' mode. :P
 
Don't forget your camelCase.
 
8:49 PM
with open(pathToFile) as file: list = [str.strip().split() for str in file]
dict = dict(list)
 
Fine. Don't use file as a variable name.
 
ok
 
I honestly forget that file is actually used as a thing in Python 2.
 
@ml_guy what are you saying ok to?
 
to inspectorG4
 
8:50 PM
and to me earlier?
 
all ready do that
yes
 
To everyone! ok to everyone! Merry Christmas!
 
whoa! don't use that last code snippet that starts with with open(pathToFile). That was satire
 
lol
jhahaha
 
@ml_guy yeah, the only non-joke answer so far was mine
 
8:51 PM
you can't possibly be in a timezone where it's christmas. It is christmas nowhere in the world right now
 
It's Christmas in my soul.
@davidism whoa. Mine was no joke ;-;
 
@davidism: chaining open file objects was a non-joke. Once the file descriptors are exhausted, nothing is pointing to them. The GC /should/ clear them
 
user2555451
Us people on Pluto are still celebrating Christmas from a few hundred years ago...
 
yeah, ok, so I'm biased :)
 
icy! (points if you get the totally awesome pun)
 
8:53 PM
and mine used yield from, which is cool
 
the problem is im using python 2.7.
 
user2555451
I'm still a little wary of yield from since it break everything but the two newest versions.
 
@iCodez: if you're on Pluto, then how are your chats coming in realtime? Or are you just replying to old parts of this conversation with surprisingly relevant content?
 
user2555451
The Plutonians have found a way to use quantum entanglement to send realtime messages to anywhere in the Universe. You Earth people are still way behind.
 
yield from f can be replaced with for line in f: yield line in py2
 
8:58 PM
ok thanks
 
01:00 - 21:0021:00 - 00:00

« first day (1527 days earlier)      last day (3412 days later) »