|
Hughmoris posted:Thanks for this. It is exactly what I'm looking for but I'm having a bit of a trouble to get working. I have a script called hello_world.py.I have Python installed on my laptop at C:\Python27\python.exe. I want to make the script accessible to my coworkers on the network drive I:\Public\Scripts. Yes, he's saying that you'll need to place the python.exe somewhere that's executable by other people.
|
# ? Sep 22, 2014 19:34 |
|
|
# ? May 9, 2024 16:19 |
|
What is the preferred IDE for Mac? I know that I can technically use NetBeans, and I think I've heard of a way to use Xcode with it, but I'd rather not find out the hard way and just start learning the best one immediately.
|
# ? Sep 23, 2014 00:58 |
|
PyCharm!
|
# ? Sep 23, 2014 01:00 |
|
PyCharm owns.
|
# ? Sep 23, 2014 01:05 |
|
Hughmoris posted:Do I need to install Python to the network drive? Not sure if the IT guys will be a fan of that. Pretty much this. You should be able to take a copy of the python runtime you've got installed locally and just copy it onto the network share. I don't see why this would be a problem for IT unless they're idiots (they're idiots, aren't they?). You can't just take python.exe - you need the standard library files and all the other gubbins too.
|
# ? Sep 23, 2014 01:12 |
|
Another vote for pycharm, Mac or PC.
|
# ? Sep 23, 2014 01:19 |
|
Cultural Imperial posted:Another vote for pycharm, Mac or PC. 4
|
# ? Sep 23, 2014 02:22 |
|
Thanks guys!
|
# ? Sep 23, 2014 02:58 |
|
PyCharm 4 EAP came out today.
|
# ? Sep 23, 2014 05:55 |
|
regularizer posted:I'm trying to figure out python syntax, and one of the codecademy exercises is to write a function that removes all duplicates of integers in a list, so if you have [1,1,2,2,3] it returns [1,2,3]. I know you're trying to learn, so writing the big function is a good idea, but the easiest way to handle this is just: ints = list(set(ints)) That turns your ints first into a set type, which will automatically remove the duplicates for you. Then it converts the set into a list, and you're back to where you want to be.
|
# ? Sep 23, 2014 06:09 |
|
FoiledAgain posted:I know you're trying to learn, so writing the big function is a good idea, but the easiest way to handle this is just: Gotcha, thanks. I was trying to learn list comprehensions before the tutorial got to it. On a related note, when I finish the codecademy tutorial in a few days what should I do next? I'd like to get a more in-depth understanding of python before moving on to another language. I was thinking about trying to make a simple program I could run on osx, so is there something I could do to learn about making GUIs with python?
|
# ? Sep 23, 2014 07:15 |
|
regularizer posted:Gotcha, thanks. I was trying to learn list comprehensions before the tutorial got to it. On a related note, when I finish the codecademy tutorial in a few days what should I do next? I'd like to get a more in-depth understanding of python before moving on to another language. I was thinking about trying to make a simple program I could run on osx, so is there something I could do to learn about making GUIs with python? You should start a project of whatever you want, then look things up or ask questions when you approach a problem you don't understand. For me at least, it's easier to stay motivated that way than learning academically. Qt (PyQt or Pyside) is probably the best GUI for Python, but it's a pain to learn, with no good tutorials.
|
# ? Sep 23, 2014 07:56 |
|
Instead of using pycharm, you can always customize the poo poo out of vim like a cool person
|
# ? Sep 23, 2014 19:30 |
coaxmetal posted:Instead of using pycharm, you can always customize the poo poo out of vim like a cool person PyCharm is so awesome though...why would you do that to yourself
|
|
# ? Sep 23, 2014 20:11 |
|
In general I've found that people who don't prefer PyCharm don't yet know what it has to offer.
|
# ? Sep 23, 2014 20:21 |
|
The more I use PyCharm, the more I like it. Except when my VM is brought back from suspension and my running Django has pegged my CPU and I have to kill Java. Aside that.
|
# ? Sep 23, 2014 20:29 |
|
regularizer posted:I was thinking about trying to make a simple program I could run on osx, so is there something I could do to learn about making GUIs with python? Python comes with tkinter, which you can use to build a GUI. It has its limitations, of course, but then what doesn't. I use it regularly, and I generally consult http://effbot.org/tkinterbook/. edit: wow, I just realized that says it hasn't been updated since 2005. But then, I don't think that Tk has been updated for a long time either. In any case, that site still has useful relevant information. FoiledAgain fucked around with this message at 20:50 on Sep 23, 2014 |
# ? Sep 23, 2014 20:47 |
|
Only a couple weeks into my Pythoning but I'm loving PyCharm too. With a little wrangling I got PyCharm running in Windows to auto-deploy to my Linux box, and then when I hit "run" it runs python on the remote machine to test my package, wheeeee. Question: How can you access the exception object inside an 'except'/catch in Python 3.4? Using subprocess in Python 3.4, I'm trying to catch the CalledProcessError exception, which is supposed to give me returncode/cmd/output. But "except subprocess.CalledProcessError, e:" is apparently now invalid syntax so I can't access "e.output" etc. -e nevermind saw an example a page or two back, "except subprocess.CalledProcessError as e:" is working, yay. sadus fucked around with this message at 20:55 on Sep 23, 2014 |
# ? Sep 23, 2014 20:53 |
|
I use PyCharm from time to time, but I mostly use Vim because that is what I have been using for the longest time. One of my frustrations with PyCharm is that everything has to be in a project, which seems a little strange when I have a script that does one relatively simple thing.
|
# ? Sep 23, 2014 22:10 |
|
accipter posted:I use PyCharm from time to time, but I mostly use Vim because that is what I have been using for the longest time. One of my frustrations with PyCharm is that everything has to be in a project, which seems a little strange when I have a script that does one relatively simple thing.
|
# ? Sep 23, 2014 22:18 |
|
I used to use TextWrangler for individual little scripts but I missed all of the PyCharm features too much. I just open whatever folder that script is in as a project. It doesn't take any more effort that opening that file directly, and the only clutter it created is the .idea folder which ends up invisible to me, and since I put that in my global .gitignore I don't even have to worry about git picking it up. I mostly end up keeping all of my random scripts in the same utility script folder which is my most commonly used PyCharm project anyway.
|
# ? Sep 23, 2014 22:27 |
|
OnceIWasAnOstrich posted:I used to use TextWrangler for individual little scripts but I missed all of the PyCharm features too much. I just open whatever folder that script is in as a project. It doesn't take any more effort that opening that file directly, and the only clutter it created is the .idea folder which ends up invisible to me, and since I put that in my global .gitignore I don't even have to worry about git picking it up. I mostly end up keeping all of my random scripts in the same utility script folder which is my most commonly used PyCharm project anyway. Yeah, this is how I handle it as well.
|
# ? Sep 23, 2014 22:32 |
|
regularizer posted:Gotcha, thanks. I was trying to learn list comprehensions before the tutorial got to it. On a related note, when I finish the codecademy tutorial in a few days what should I do next? I'd like to get a more in-depth understanding of python before moving on to another language. I was thinking about trying to make a simple program I could run on osx, so is there something I could do to learn about making GUIs with python? The answer to that depends entirely on why you are learning python. If it's to have fun, then pick something (simple, always start simple) that you think would be fun to try to build it. It really doesn't matter what it is. If you're learning python to get a job, then it depends on what kind of job: general developer, web developer, front-end developer, data scientist all suggest different classes of projects you should try.
|
# ? Sep 23, 2014 22:35 |
|
regularizer posted:Gotcha, thanks. I was trying to learn list comprehensions before the tutorial got to it. On a related note, when I finish the codecademy tutorial in a few days what should I do next? I'd like to get a more in-depth understanding of python before moving on to another language. I was thinking about trying to make a simple program I could run on osx, so is there something I could do to learn about making GUIs with python? Maybe it's just my web background talking, but the patterns involved in writing desktop apps are totally incomprehensible to me. What you're thinking seems to be a really common desired first step, but I'd suggest taking a smaller one. I'm a big fan of the static blog generator as a "learn the language" project. I think the problems involved are a lot easier to grasp, and won't get in your way as much while still trying to figure out how class inheritance works (for example). Or as KernelSlanders said, solve a problem that you actually have. There's no better way to stay motivated and interested in a project.
|
# ? Sep 23, 2014 22:53 |
|
Python is hell for GUI apps, which is probably why most popular Python apps with a GUI use Angular or something and have a web frontend instead. This is possibly also why nobody can be bothered writing a decent multiplatform GUI library.
|
# ? Sep 25, 2014 07:22 |
|
Could someone school me a little bit on regex? I've been teaching myself regex and learned how to look for a match. What I want to do now is if a match is found, replace the match with something else. For example, a text file contains this: code:
code:
Edit: Maybe it would be easier to read in the very long text file as a string, and then do a string.replace('123', '9999')? Hughmoris fucked around with this message at 00:22 on Sep 26, 2014 |
# ? Sep 26, 2014 00:04 |
|
Hughmoris posted:Could someone school me a little bit on regex? Take a look at the "re" module in the standard library, and check out re.sub() function. That should do what you're looking for. I don't know if one is more efficient than the other, but I think re.sub() and string.replace are fairly similar at least in terms of how much code you'd need to write.
|
# ? Sep 26, 2014 01:12 |
|
Alexei posted:Take a look at the "re" module in the standard library, and check out re.sub() function. That should do what you're looking for. Thanks. I discovered I'm able to handle string.replace much easier than regex, so I went that route. I then read up on CSVs. I now have a script that is going to save me a ton of time on a small work project... I have CSV that has rows of path name, old item number, new item number. My boss was expecting me to manually open up each file and swap the item numbers. Now, I've hacked together a hideous program that will iterate through the CSV, grabbing each pathname and opening that file, then replacing the old item number with the new item number, then move on to the next file. I'm so happy I've learned the basics of scripting.
|
# ? Sep 26, 2014 03:01 |
|
Hughmoris posted:Thanks. I discovered I'm able to handle string.replace much easier than regex, so I went that route. I then read up on CSVs. I now have a script that is going to save me a ton of time on a small work project... Are you parsing the csv with regex too? Were you the one who parsed HTML with regex as well? Python has a standard library csv module for working with csv and same thing for html/xml. Regex is kind of ugly for both of those cases. It sounds like it is working so might as well just run with it, but csv and html/xml are better to parse with libraries built for those purposes rather than creating your own 'parser' with regex. Congrats on the script though, it is awesome when you take what would have been a horrible manual process and automate the hell out of it. Don't tell your boss and take a week to deliver these results while reading the forums and relaxing hah . Lyon fucked around with this message at 03:14 on Sep 26, 2014 |
# ? Sep 26, 2014 03:12 |
|
Thanks. I'm using the CSV module for this. I am the one who was trying to parse XML with regex and I was able to get the job done. I've grown frustrated and put learning APIs to the side, I can't seem to learn how to extract meaningful data from them. I can make the API call and receive the XML or JSON data but when I try to extract information using any of the parsers it turns out to be a mess. Here is my proof-of-concept code for the csv script. If there is an obvious way to handle it better, I'm all ears: code:
|
# ? Sep 26, 2014 04:04 |
|
Hughmoris posted:Thanks. Phone posting but that looks pretty good to me, I thought you were using regex to parse the files and was a bit concerned. Since you're using csv I take back my above comments!
|
# ? Sep 26, 2014 04:28 |
|
Hughmoris posted:
Is it working on your end? Isn't opening two file pointers to the same file wrong? EDIT: Stupid bold tags don't work inside code. Space Kablooey fucked around with this message at 14:22 on Sep 26, 2014 |
# ? Sep 26, 2014 14:19 |
|
HardDisk posted:Is it working on your end? Isn't opening two file pointers to the same file wrong? It works fine for me, no errors or warnings popped up. Maybe someone smarter than me can explain how the two file pointers work because I don't have a clue.
|
# ? Sep 26, 2014 14:53 |
|
Hughmoris posted:
You're not closing f. Python code:
|
# ? Sep 26, 2014 16:16 |
|
I am trying to extract text from a pdf using pdfminer and I run into the following problem:code:
code:
|
# ? Sep 27, 2014 09:07 |
|
I need some help understanding scope in Python. I have two functionsPython code:
Python code:
However, if my_dict is initially empty, a call to func_two results in a non-empty dictionary: Python code:
Why does func_one not result in a change but func_two does?
|
# ? Sep 28, 2014 17:16 |
|
Jose Cuervo, I don't fully understand it myself but these two articles helped: http://stackoverflow.com/questions/986006/how-do-i-pass-a-variable-by-reference http://www.jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-or-callbyreference-neither/
|
# ? Sep 28, 2014 17:34 |
|
Jose Cuervo posted:I need some help understanding scope in Python. I have two functions The first one can be explained something like this:
And the second one:
In both, at step 3, bool_var and my_dict in the inner and outer scopes point to the same object. The difference is that in the first one, step 4 reassigns the name within the function scope, having no effect on the names in the outer scope, or any of the objects they point to. After step 4, bool_var in and out of the function no longer point to the same thing. In the second one, step 4 modifies the dictionary that is pointed to by my_dict in both scopes. It's the difference between reassigning a name and modifying an existing object. SurgicalOntologist fucked around with this message at 17:49 on Sep 28, 2014 |
# ? Sep 28, 2014 17:39 |
|
Jose Cuervo posted:I need some help understanding scope in Python. I have two functions Python variables are passed by assignment. Lists and dictionaries are mutable, so you can modify one of those in-place even when you pass that object to a function. But if you were to assign a new list to that variable name, within the scope of a function, then the list outside of that function would be unchanged. In this case, you're creating a new bool object and passing the variable assignment to the function. Within the function, you have access to that assigned value. However, when you assign a new value to the same variable name within the function, that does not effect the variable of that name outside of the scope of the function. So if you did this: Python code:
tl;dr Variable assignments within a function do not effect variables of the same name outside of that function. But if you modify that assigned value (by invoking one of its methods to modify its contents, like you do in func_two), then that does effect variables pointing to that value outside of the function.
|
# ? Sep 29, 2014 04:48 |
|
|
# ? May 9, 2024 16:19 |
|
I started with Exercism today, it's pretty cool so far, got some helpful feedback about readability within about an hour of putting up my first submission. I'm still relatively a beginner, but I figured I could help out people like this guycode:
code:
|
# ? Sep 29, 2014 05:01 |