« first day (2348 days earlier)      last day (2594 days later) » 

wim
12:12 AM
why you can make an array from a scalar anyway
I still have never seen a good use case
 
I think there are historical reasons
 
wim
do you know how to index them? you use getitem with an empty tuple ... obvious, right?!
 
well duh, they don't have a shape:P
 
wim
I love numpy but honestly some of their design decisions are whack like crack
 
well, I found the answer to my highlighting from earlier
 
12:16 AM
constants.
but that thread looks as if it was changed?
 
they changed the leading capital case
3+ is still a constant
or 2+ maybe
 
that's... ahem, weird
 
although it's affected by the underscore
I guess I'll just change GPS_ to GPS so I don't have a wall of purple in the middle of my class definition
 
GeePeeEss_
 
then my lines would be too long!
 
12:59 AM
rhubarb
 
1:24 AM
global_positioning_satellite
@wim that's because you're not a mathematician ;)
 
wim
1:37 AM
@WayneWerner I am, actually.
 
2:30 AM
Maybe there is something I'm missing, but the answers seem to be over complicating an already vague and bad question
should be closed
lol. Question got two upvotes
 
 
1 hour later…
3:34 AM
What is a good Python implementation for Windows?
I got a new laptop recently and am setting up some development tools for my various languages.
 
@Code-Apprentice CPython?
 
that's just "regular" python, right?
 
Yup.
 
that's probably what I was going to go with. Just wondered if there are any other viable alternatives.
 
It is very much language Spec compliant
 
3:38 AM
cool
installing it now
does the windows installer automatically update PATH?
 
If you have admin rights, yes.
 
hmm....didn't do it
 
wim
4:08 AM
Sorry, there are no good Python implementations for Windows
 
are they really that different than those for *nix?
-1
Q: How can I call a variable from differnent function?

AirBuzzOn the first function I tried to return the newFolder so I can use it in the second function. but when the second function is called it will keep looping through the whole first function instead of using newFolder variable only. It works fine when using global or defining newPath outside the fun...

These kind of questions are difficult for me to decide what to do. The question is well formulated so that you can see there is a gap in the OP's knowledge that will easily solve the problem. However, the OP also seems unwilling or unable to do some research on their own.
 
4:22 AM
recbg
 
4:56 AM
@Code-Apprentice I chose to believe that that particular OP is keen, just a bit clueless. ;) So I wrote them an answer. Hopefully, they'll learn something from it.
 
that is a lot more than I was willing to do
 
I was feeling generous because they posted an almost-MCVE, and gave an almost-coherent description of how the code misbehaves. And they responded quickly to my clarification request comment. I'm so sick of 1 rep newbies who post a poorly-specified question and don't hang around to respond to comments.
I may end up regretting this... The OP just tried to modify the code in my answer.
@Frozen Why did you try to modify my code? It won't work if you replace the call to dir_list() in move_files with get_dir()! — PM 2Ring 1 min ago
 
5:35 AM
@Code-Apprentice Anaconda is good. Dependency installation is much smoother. Else you are very likely have to get a wheel from lfd.uci.edu/~gohlke/pythonlibs
 
5:59 AM
@Code-Apprentice Some of the standard modules are Unix-centric, and simply don't function on Windows, notably signal. Some other modules have different behaviour on Windows vs Unix / Linux. But the main problem is with 3rd party modules that use C extensions because Windows doesn't come with a C compiler. Sure, you can get various commercial and free C compilers, but it's not easy to create a build script that can handle all the possibilities.
Disclaimer: I don't really know much about Windows, I'm just parroting what I've heard.
 
cbj
 
6:14 AM
cbg
 
6:57 AM
@PM2Ring None of that sounds like it will be an issue for me. My use cases are pretty simple.
mostly answering basic SO questions.
 
@Code-Apprentice In that case, you should be fine.
 
Besides, I'm such a noob that I'd just roll my own rather than use a module.
mostly because I don't even know what modules are available
 
It's not that scary though, just that there are times when Visual Studio compilers will fail miserably for a dependency you can't do without.
Other than that, it's just regular python.
Since you are on Windows, I would recommend the Pyscripter IDE. It doesn't support Python version > 3.4.
 
7:19 AM
I already have pycharm installed.
oh...I forgot about that until just now cuz I saw the icon pinned to my taskbar
I installed it like a week ago and haven't used it.
Didn't even see if it came with its own interpreter or if I needed to install one.
 
Can someone explain to me how to use modules? I am trying to learn and don't understand.
Specifically if I try to use "from "module" import class". I am trying to write a program where I import my class with its methods into a new program main and cant get it to work
 
For beginner purposes, I would say, treat modules like separate files (which follow the usual directory structure hierarchy). Check this tutorial for more info learnpython.org/en/Modules_and_Packages
@Drizzy The python2.7 documentation is also fairly good - docs.python.org/2/tutorial/modules.html#packages
 
7:42 AM
@AshishNitinPatil Yeah I was already looking through the documentation a bit. Its still a little to complicated for me. I am following a python book and I guess I am just confused by how they are explaining it. Do you do the from "your module" import "your class" in the python shell?
Or do you do it in a new python .py file when you wanna use that class from another project?
 
@Drizzy in order to help you, we need more information that just "I can't get it to work". You should post a question on the main site. Be sure to explain exactly what you have tried with a simple code example and tell what problems you encountered, including full error message.
You can import a module into the python shell or in a python script file, either one. It just depends on what you are doing exactly.
Usually you only use the shell for experimentation and debugging. Any useful program will be saved in a file. However, the syntax is exactly the same.
 
@Code-Apprentice That makes sense, sorry I should have posted on the main site. I have some code if you are willing to take a look at it. Im pretty sure I am just making a simple mistake. Otherwise I will post on the main site like you suggested.
 
I'd be happy to take a look at your question once you post it.
 
@Code-Apprentice Sounds good
 
For now, I suggest that you create all modules in the same project.
Reusing modules across projects is a bit more complicated. You already have enough to learn right now. Don't make it harder than it needs to be.
 
7:49 AM
recbg
 
That is what I am trying to do however I am making a mistake and it gives me the error "ModuleNotFoundError".
 
@Drizzy Are you using Python 3? What is the filename of the module you're trying to import, and what's the exact statement you're using to import it? Are the file containing the module and your main program in the same folder?
 
Python 3.6.0 and I am not sure if I am using it correctly because I am just learning about it. I saved my python file as Rectangle.py and the class name is Rectangle (This is how the book I am learning from does it) and I use from Rectangle import Rectangle
They are in the same folder
 
Hmmm. That should work. What's the name of the main program?
 
and how are you running your main program?
 
7:58 AM
I just have it called main. Here I will just post my code to pastebin so you guys can see. As I said I am learning and not sure what I am doing wrong so go easy please
 
so far everything sounds right...
 
So here is my first one pastebin.com/pW4qrzFr and then I have my main pastebin.com/rhEZhwzb
Also I meant Circle not rectangle. Sorry its late and I have been working on other things all night.
Welp. I figured it out....
 
def getArea(self) is your method in circle class. Then you calling circle1.getArea in your main. It seams like you have to pass some arguments. I am new to python. If i am wrong please ignore it.
 
@Drizzy Excellent. What was the problem?
@sasirekha You're wrong. :) The Circle.getArea method takes no args (apart from the implicit self): it uses the Circle instance's self.radius to do the area calculation.
 
@PM2Ring Radius was misspelled in one area as raduis :/
@PM2Ring I was going crazy thinking I was missing something.
 
8:12 AM
It's easy to do. :) How long have you been learning Python? Do you know any other programming languages?
What book are you using? From the look of those method names, I suspect that it's an adaptation to Python of a book that was originally written for another language, probably Java. So it might teach you stuff that's fine in Java but not so appropriate to Python.
 
@PM2Ring I am currently learning Python and C together right now so I get them mixed up by accident sometimes too. I have been learning Python for about two months so far, and I know some java.
@PM2Ring The book is Introduction to Programming using Python by Daniel Liang
 
I'm not saying that the book will teach you wrong stuff. It's just that in Python we have a slightly different way of doing OOP compared to Java. The Python way is less cumbersome than the Java way.
 
@PM2Ring Do you have any suggestions of another book
or place to learn online
 
@Drizzy I can run your program just fine with two minor corrections: 1) The spelling error you mentioned and 2) adding a call to main().
 
@Drizzy I'm not familiar with that book, but a quick Google suggests that he does mainly focus on Java, with some C++. Since you're also learning Java, I guess there's no harm in using his Python book. A lot of OOP stuff does apply to both languages, and it's easy enough to learn how to do it the Python way if you already know Java.
 
8:21 AM
Actually I added
if __name__ == '__main__':
    main()
 
@PM2Ring Alright sounds good, thanks again!
 
@Drizzy As I said, that book's probably fie. But here's our tutorial list: sopython.com/wiki/What_tutorial_should_I_read%3F
 
@Drizzy How do you run your program? Are you using an IDE or the command line?
 
The official Python tutorial is excellent, but it's not intended for raw beginners: it assumes you're already comfortable programing in at least one other language, probably from the C / Java family.
 
@Code-Apprentice I actually ended up just using the Circle class because it worked the same whether I used the main or not. Why did you need to add the if name statement? And I use IDLE
 
@PM2Ring When I feel a little more comfortable I will definitely check it out!
 
@Drizzy The if statement I showed above is a common Python idiom. It allows you to have main() in every file. When you run the file as a script, the if statement evaluates as true and main() is called. If you import the file as a module, the if statement evaluates as false and main() is skipped.
@Drizzy when you are asking for help, you need to show the exact code which you are using. Otherwise, we are wasting our time because the code you show us behaves differently than what you are actually running.
 
@Drizzy In the mean time, here are a couple of articles that explain a very important difference between Python and most other languages. Other languages have "variables", Python has "names", and Facts and myths about Python names and values, which was written by SO veteran Ned Batchelder.
 
@Code-Apprentice That is what I was running but then I was messing around with it and changed it to just that one Circle program without the separate main program and figured it out.
 
what did you do to fix it?
oh...so you aren't using modules at all now?
by "program" I assume you mean "file", right?
 
8:31 AM
@ZeroPiraeus "How do I decrypt this one-time pad stuff without the key?" :facepalm:
 
@Code-Apprentice Sorry I guess I still don't understand then. Also yes by program I mean .py file. I will refer to it as file from now on. So to use a module I need to have two files, correct? So I would need to have that main file just so I could use the module statement "for Circle import Circle" in the python shell of the main file.
Let me know if that is right ^
 
yes, and both files should be in the same folder
 
Hello, fellow programmers. I've got a newbie question.
I have to run lots of tests. Python was chosen as a language for reaching the goal. While I have no experience with Python.
I installed PyCharm and created a LaunchTest.py file. In that script I recursively iterate through given 'Tests' folder, launching any found .py file in that folder. Every found .py file is considered to be a test.
Well, I wanted to do it that way, but I stupidly ran into a problem - I do not know how to call a .py file from another .py file in a correct way. Using `exec` or `subprocess.call` does not look like a r
 
@PM2Ring I think it's from an introductory crypto course, and meant to demonstrate the problem with reusing a pad. Each text is also 26 bytes long, so it's probably caesar.
(or at least a caesar-style permutation of the alphabet as a key)
 
Okay so then I got that to work without the if statement you had as I am not familiar with that Python idiom yet.
 
8:35 AM
@ZeroPiraeus Ah, ok. I guess that's a possibility.
 
If so, of course, OP hasn't actually understood the assignment.
 
@Drizzy you got the from ... import ... to work?
@ZeroPiraeus possibly it is 1-byte repeating XOR. Does that qualify as "caesar-style permutation"?
 
@Code-Apprentice When I run the main file yes
 
with a separate Circle.py file, right?
 
yeah
 
8:41 AM
that is one step closer at least!
 
I still don't know why my hard coded statements in my main wont work but at least I can enter them in the shell right now
 
@Code-Apprentice I meant e.g. MWZSYJBKVCLDROXNGUTEQIFPHA
 
oh...a permutation of the entire alphabet
 
suggest me some good online python debugger
 
Pretty sure it isn't a single byte, because the ciphertexts are all similar bytes at similar positions (but widely varying across each text).
 
8:43 AM
so a generic substitution cipher
that's something I was unclear about. Is each line a separate cipher text, possibly encrypted with the same key?
 
I think so.
 
@PM2Ring @Code-Apprentice Thanks for helping me out and explaining things!
:)
 
No worries!
 
@Drizzy Good luck with your python!
 
cbg
I am abusing Java's stream too much
 
8:59 AM
If the contents of an open file change on disk, will Sublime Text 3 automatically reload the changes?
 
anyone here tried Scrapy?
 
9:28 AM
@Code-Apprentice Yes, it should prompt to ask "reload changes?"
@noobninja yes, but that should not be necessary to ask. Just post your question and someone knowledgeable may take a look at it.
 
hey does anyone know much about XOR decryption ?
 
9:46 AM
@AshishNitinPatil it's not prompting me...but seems to be loading anyway. Maybe I previously set it to "never ask me again"?
@ross.c Let me guess, you have to decrypt the "first sentence"?
 
(probably not against any actual SO rules, but it's intrinsically bad that the Q exists for the same reasons that SOD is intrinsically bad)
 
Is there a dupe for this?
Too bad there isn't a "not enough research" close reason.
 
If there is, I want that closed and deleted too.
 
What is SOD?
 
Stack Overflow Documentation
 
9:50 AM
not a fan of the Documentation section?
 
I'm so much not a fan that I got suspended for it once (alongside others in this room).
 
how did you get suspended?
I have only peeked at it once or twice. I think about contributing but don't feel like taking the time to write something out in such detail.
so basically I just ignore it for now.
 
81
A: Why was I moderator-suspended from chat for 24 hours?

Tim PostThe launch of Documentation brought out something that's as hard to articulate as it is to absorb, how people feel. Some people are really good at expressing their feelings in a constructive way, others just kinda let the raw feelings out, which often comes in the form of unactionable hostility. ...

 
wow...got an upvote to one of my more obscure answers: stackoverflow.com/questions/39457868/…
@ZeroPiraeus so were you one of these people who were there "just to derail things, and nothing you could say would change my mind"?
 
I was there to oppose something, which is not the same as derailing it. I don't think it really needs derailing now; it's very obviously a complete failure, and only still up because SO hasn't the heart to pull the plug yet.
6
 
10:06 AM
0
A: How to auto reload current file in sublime text 3?

idlebergThere's a setting to control whether you get to see a prompt, but otherwise Sublime Text reloads the file automatically by default. See the setting in Preferences.sublime-settings: // Always prompt before reloading a file, even if the file hasn't been // modified. The default behavior is to aut...

 
I never paid attention to the roll out of documentation. Didn't know it was such a hot-button topic at the time.
@AshishNitinPatil thanks for the link. I'll check it out. I am doing some git checkouts from the CL. Sometimes the changes are significant enough that I can easily tell that the new version has reloaded. Other times the changes are only a line or two, so not as easy to tell.
 
@Code-Apprentice You should use the git gutter plugin, helps you highlight the changes currently made to the file over the latest commit.
 
that seems useful. Right now, I just want to be sure that Sublime has the current file on disk open.
Looks like I have that preference set to false, so that's why it isn't asking if I want to reload. I'm okay with that. I just want to know what the actual behavior is.
 
The actual behavior should be what your system settings say (unless overridden by user settings).
 
10:41 AM
yah, I just had to find the setting name in the file
I really would rather have a GUI to control settings rather than editing a settings file ;-(
probably should just look for a plugin
 
I always thought programmers prefer config files over (most of the cases) non-intuitive GUI.
 
I guess it depends on what you're doing, but I'm not a fan of auto-reload. I prefer to see a prompt that gives me a choice. That way you don't lose stuff if you accidentally clobber the file on disk. :)
 
I don't use Sublime a whole lot. Just for those quick and dirty tasks that don't require a full IDE.
 
@AshishNitinPatil Maybe it's a *nix vs Windows thing.
 
For my current use, autoreload is fine. If I start using it more, I'll probably turn it off.
 
10:47 AM
@PM2Ring That's more likely. I don't think anyone would like to edit the registry config file instead of using regedit GUI.
 
Also, *nix has a a history of using plain text files for a lot of config stuff. And people manipulating stuff from within their favourite editor, especially if that editor happens to be something like emacs or vi.
 
recabbage
 
11:02 AM
tying in with *nix vs Windows: what's a GUI? :P
Just kidding, I've heard of GUIs. I'm told you need a mouse to use them. What's a mouse?
cbg
 
11:33 AM
Cabbage
Quote of the night:
I've just found the fix. Apparently Unicode doesn't like ASCII. — Jeremiah 13 hours ago
 
cbg
 
12:01 PM
 
12:12 PM
A significant proportion of that was probably upvotes on old answers. :)
 
@AshishNitinPatil I used to do that. Once upon a time.
@PM2Ring nope, you get capped at 200 a day, remember?
Gordon uses the shotgun method instead: answer loads of questions. 45% of them get accepted, giving you the +15s that are not capped.
He recently passed Jon Skeet for most answers posted to the site.
 
@MartijnPieters I was just kidding, hence the smiley. There's no way to get >6200 / month without accepts & / or bounties.
 
Ninjatable
 
(I'm 6th in number of answers, 4th in number of accepted answers, 2nd in the weighted ranking which is basically of accepted answers * percentage accepted).
 
12:17 PM
@MartijnPieters You have a pretty good accept ratio there, Martijn.
 
@PM2Ring when I still competed with Gordon, I had to write 14 answers in a day to get to 350. Gordon had to write 23 to do the same. Of course, if you just ignore duplicate flagging, you can get there with all the low-quality SQL questions out there.
 
I'm happy if I get close to 100. I've only got close to the rep cap once or twice. OTOH, my Percentage Accepted isn't too shabby: 41.11
 
12:36 PM
I think I did hit the rep cap once
 
I've been playing around with the random module this evening, and noticed something in the docs for seed: "Changed in version 3.2: Moved to the version 2 scheme which uses all of the bits in a string seed." IIRC, in Python 2, the seed only used 32 bits, which means that when creating permutations by shuffle you're only sampling a tiny space of all the possible permutations if the sequence length > 12, since 13! > 2**32
OTOH, random.shuffle says: "Note that even for small len(x), the total number of permutations of x can quickly grow larger than the period of most random number generators. This implies that most permutations of a long sequence can never be generated. For example, a sequence of length 2080 is the largest that can fit within the period of the Mersenne Twister random number generator."
 
@MartijnPieters And here I am, simply being happy to have an OP refer my answer :)
 
Maybe it uses all the bits in the seed, but not in a way that improves the possibility space. Ex. given a 128 bit seed, it just XORS together every group of four bits to get the "real" 32 bit seed.
Which is not great, but preferable to more naive options like "just discard everything but the first 32 bits"
 
Don't think anyone who didn't start off during SO's golden(?) years can reach insane rep as easily as was once possible.
Mostly due to most general questions already having answers.
@WayneWerner You have the Mortarboard badge, so yes, you have hit it at least once :)
 
@Kevin I suppose I have to look at the source to find out...
I just spent the last couple of hours writing a class that chains together a bunch of random streams that each take a 32 bit seed. It was something I'd been thinking of doing for a while. I guess I should've taken a closer look at the Python 3 random docs first. :) Oh well.
 
12:48 PM
init_by_array might be relevant here but I have no idea what it's doing
 
@AshishNitinPatil Yeah, I mean it's certainly possible, but it's a lot harder and you kind of have to get lucky - or learn about emerging technologies and answer questions there. Or perhaps appeal to the ę̪̪̞̪͙̪̪̄l̪̪ͭd̵̪̪̪̪̪̈͟͞ĕ̪̪̜̪r̪̪̪͊͟ ̴̪̪̪̪̃ͬg̪̦̪̦̪̘̪ö̡̪̪̪̪͇̪̟̪́d̪̪̀s̪̪̪̪̣͊ͫ̀
 
@Kevin Yeah, that looks good to me. And in random_seed a numeric seed gets split into bytes to feed to init_by_array, so there doesn't look there's any XOR-folding going on.
 
Ok, I'm changing my guess to: providing a seed that's larger than 32 bits can give you a sequence of random numbers that's different from any sequence you'd get from a 32 bit seed. But the period of that sequence has the same limit as any sequence you'd get from a 32 bit seed.
Which I think jives with both of the statements put forth in the docs
 
Yep. The period is still limited. So my new code's not totally superfluous. Mind, you it doesn't increase the period by a huge amount.
 
I think by "This implies that most permutations of a long sequence can never be generated." they mean, "most permutations can never be generated, using any particular seed"
But in principle you can re-seed occasionally and eventually run through all possible permutations
 
12:59 PM
So if the base period is 2**K, and you use N independent streams, the period should be (2**K)**N = 2**(K*N)`
 
@WayneWerner stackoverflow.com/reputation tells you the number of repcappednesses at the bottom
 
@Kevin No I don't think so. The generator produces a loop containing 2**K items, the seed just lets you choose which point in the loop you start at.
So I guess my technique of using multiple streams is kinda equivalent to your re-seeding thing.
I'm just using N staggered copies of the loop in parallel, rather than in series.
 
@AndrasDeak Oh neat. Look like 2 days I hit the repcap
oh wait - from upvotes only
hit 200 on 4 days
and 8 rep from suggested edits :D
 
rep cap was reached via rep from upvotes *only* on 0 days
earned at least 200 reputation on 0 days
lovely
 
I got 100 bonus one of those days, I suspect, as I got 100 bonus one day.
 
1:14 PM
If the generator's state is based on N values of W bits each, and the sequence has a period of 2**K, then there must be (2**(N*W) / 2**K) individual loops. I don't know enough about the Mersenne twister to say whether N*W = K, or N*W > K, or what.
(Small pedantry: the Mersenne Twister's period length is a Mersenne prime, so it's not expressible as 2**K if K is an integer. But I don't think that matters for our purposes)
(Or maybe it does, because I'd expect 2**(N*W) to evenly divide the period length...)
 
@khajvah But you are at least famous for your questions!
 
\o cbg :D
 
5 gold badges... envy... need to answer more questions...
@MooingRawr o/ I almost always read your username as morning roar
 
@AshishNitinPatil I rarely ask questions nowadays
whatever I ask, I end up solving myself
 
@khajvah Write a self post?
 
1:21 PM
I do
but they end up being very specific cases and no help to others
 
Hi
 
@khajvah It's kinda like growing up. You have to do things on your own. The number of candies you get is how much you yourself go & buy with your own money.
 
I think I just learned to google
 
I'm wondering if there is a fast way (like a lib or so) to divide the following text to dict
test_string = "INFO: this is the test text\n" \
              "SOURCE: source field\n" \
              "second line\n" \
              "DESCRIPTION: test description"
into
dict[INFO] = "this i s the test text"
dict[SOURCE] = "source field\nsecond line"
dict[DESCRIPTION] = "test description"
Just thought it's better to ask before start to implement...
 
1:30 PM
@Markus It's like 5 lines of code
 
@AshishNitinPatil I'm here
What do you want me to do
 
eh, oh and there could be other "keys" as well..
 
yea
 
is that still 5 lines? I thought that the line change made it a bit complex
 
what constitutes as a "key"/
all uppercase letters with : in the end?
 
1:32 PM
CAPITALLETTERS:
yes
 
there you go
 
well, would you do it with regex?
 
no, loop over the lines
 
just parse it in a for loop... check for 'CAPS:' and use a defaultdict() is how i would do it
 
I actually was thinking of a regex. I got as far as:
>>> [item for item in re.split("([A-Z]+):", test_string) if item]
['INFO', ' this is the test text\n', 'SOURCE', ' source field\nsecond line\n', 'DESCRIPTION', ' test description']
... But I'm blanking about how to get that into a dict
 
1:34 PM
@LucSpan Can you dump your torrc in a pastebin and post the link here? Because as per your comment, the torrc is wrong.
 
chunking it into tuples of size 2 would be a start but most recipes for that don't work super efficiently in-line
 
@Kevin :oops:. Yeah, the period is a Mersenne prime, 2**19937-1. The Mersenne Twister state is rather bulky: take a look at what random.getstate() returns.
 
i.e. doing [my_expensive_list_comp_here][i:i+2] for i in range(0, len([my_expensive_list_comp_here], 2) calculates the list comp far too many times
 
dpaste.com/2Q5NPH6 something like this brb washroom :D
 
@AshishNitinPatil, pastebin.com/UfDFXt2U
 
1:37 PM
@MooingRawr that code doesn't really work, since new line..
 
@LucSpan That torrc works for me :|
 
@AshishNitinPatil I'm not sure if I get Tor to use it, or if its running on the torrc.sample configuration file.
 
@LucSpan Did you try tor -f /path/to/torrc?
 
@AshishNitinPatil Just to be sure its not the Python code itself, pastebin.com/pr0vEbdc
@AshishNitinPatil I'll try now.
 
When did photography turn into worldbuilding?
19
Q: Can I show two sides of a card in one photo?

WillemienA form I was looking at asked for customers to submit ONE photo of BOTH sides of their ID card. I spoke with the developers of the form and they are changing it. But then it made me wonder is it really that impossible? Are there no creative ways to do it? I prefer methods that don't use mirro...

 
1:41 PM
@LucSpan Nope, the code is fine. It's the tor daemon that is having issues.
 
import re

def pair(seq):
    for i in range(0, len(seq), 2):
        yield (seq[i], seq[i+1])

test_string = "INFO: this is the test text\n" \
              "SOURCE: source field\n" \
              "second line\n" \
              "DESCRIPTION: test description"

d = dict(pair(re.split("([A-Z]+):", test_string)[1:]))
print(d)
#result: {'INFO': ' this is the test text\n', 'SOURCE': ' source field\nsecond line\n', 'DESCRIPTION': ' test description'}
 
thanks @Kevin!
 
@AshishNitinPatil -f /path/to/torrc gives "Unable to open configuration file "/opt/local/etc""
@AshishNitinPatil But at least its seeing it! :) How do we get it to open?
 
@LucSpan I don't think torrc is platform dependent, checking just in case.
 
Of course this only works if each key is exactly one word, which is in all caps, contains only letters, and is immediately followed by a colon.
If you expect it to work on "FOO BAR: baz" or "foobar: baz" or "2OOBAR:baz" or "FOOBAR\t:baz" or "FOOBAR--baz", you're going to have a bad time
 
1:45 PM
@LucSpan Did you find the torrc.sample as mentioned in the docs torproject.org/docs/tor-doc-osx.html.en?
 
mm yes, I got it :) under which license do you release that code? :)
 
479
Q: The MIT License – Clarity on Using Code on Stack Overflow and Stack Exchange

samthebrand Update (Dec. 22): Thanks, everyone, for your feedback to this proposal. We're going to digest this one over the holidays and should have a follow-up announcement answering your questions and addressing your concerns after the new year. We won't be making any hurried decisions on this topic, an...

 
@AshishNitinPatil Yah, found it like that and removed it (as adviced)
 
Great! didn't know that.
 
@LucSpan Umm, do you have a copy of that? I feel you should replicate that only, instead of any other torrc.
 
1:47 PM
This answerer has a lot to learn about writing tests... stackoverflow.com/a/42928391/4014959
 
@AshishNitinPatil The file currently named torrc is a copy of the torrc.sample file.
@AshishNitinPatil but yes, I still have it. Should I restore it?
 
@LucSpan No, restoring is not going to help. I felt that torrc would be platform dependent (directory paths for example), hence the concern. The error you may be getting is because the installation wasn't right.
Otherwise, just try creating necessary directory structure / files as per the error messages you are getting
And, since this has become more related to tor & not python, I think you should take it to the tor IRC channel - torproject.org/about/contact.html.en#irc
 
DSM
Morning cabbage for all.
 
@AshishNitinPatil Ok, I'll try the IRC channel. Thanks for your help!
 
@LucSpan Glad to be of whatever help there was :)
 
1:53 PM
I feel like I could improve my re.split code by switching to findall and matching "an all-caps word, followed by a colon, followed by any number of characters as long as those characters aren't an all-caps word followed by a colon" but my initial attempts failed to match anything.
 
@DSM cbg :-) \o
 

« first day (2348 days earlier)      last day (2594 days later) »