|
LochNessMonster posted:I just ditched PyCharm because I couldn't really get used to it and installed anaconda on my work laptop (windows 10). This is a weird thing to say, so just to make sure you didn't accidentally type the wrong thing...you know that PyCharm is an IDE and Anaconda is a package manager?
|
# ¿ Jun 4, 2017 15:13 |
|
|
# ¿ May 15, 2024 12:51 |
|
huhu posted:I could see Pycharm being overwhelming if you've never programmed before. Perhaps better to start off with something more familiar feeling first like Sublime Text. That being said, I moved from Sublime to Pycharm in my learning progression and never plan to go back. Right. But using or not using Anaconda doesn't have anything to do with PyCharm.
|
# ¿ Jun 4, 2017 15:31 |
|
LochNessMonster posted:RE: Miniconda instead of Anaconda. Hey, I don't know if it works but you might want to try using the Linux Miniconda inside bash.
|
# ¿ Jun 7, 2017 15:58 |
|
LochNessMonster posted:Won't that mess things up? No. If you use pip (without using virtualenv) it install packages into your system python install. When you use miniconda it has its own python install that won't have anything to do with your system python. FWIW, I always use pip when I'm using miniconda. Mainly because it works just as well as `conda install` does in 99% of cases, and pip is what everyone uses.
|
# ¿ Jun 7, 2017 17:19 |
|
Seventh Arrow posted:2) I'm still kind of new to programming and there's a lot of stuff to take in/remember. I assume that people usually don't just code things from scratch - do you keep cheat sheets around or what? Kind of. I call it Google.
|
# ¿ Jun 9, 2017 00:57 |
|
accipter posted:You can with py3redirect! oh gently caress yes
|
# ¿ Jun 9, 2017 17:01 |
|
KernelSlanders posted:Not everyone in this thread builds web apps. This thread has always been open to beginners. The poster who has been asking questions is obviously a beginner. Floating point stuff obviously is weird to beginners. Thermopyle fucked around with this message at 17:44 on Jun 11, 2017 |
# ¿ Jun 11, 2017 17:21 |
|
Nippashish posted:
That's why its confusing to beginners.
|
# ¿ Jun 11, 2017 19:53 |
|
huhu posted:What would be the best way to take: Python code:
|
# ¿ Jun 14, 2017 15:47 |
|
Async basically only helps with IO-bound tasks. If you are mostly CPU-bound you should probably use multiprocessing. (I'm on phone and basically didn't even look at your code)
|
# ¿ Jun 15, 2017 14:42 |
|
Malcolm XML posted:Lol use an actual diffeq solving codes instead of doing it by hand unless you are researching solvers Malcolm XML posted:Like instead of the janky first order stuff you could probably use the standard rk4 and be algorithmically faster Did this thread get moved to yospos? (I don't disagree)
|
# ¿ Jun 17, 2017 19:04 |
|
huhu posted:Does anyone have a suggestion for a tutorial that walks through the basics of sockets up to putting it on a server and being able to type in "huhu.com/index.html" and get a page to load? I've got something basic running locally but would like to explore sockets, wsgi, and related topics more in depth. Google "python web server from scratch". There's a bunch of decent-looking stuff on the first page. Also you can look over the code to Python's own simple http server. https://github.com/python/cpython/blob/3.6/Lib/http/server.py Thermopyle fucked around with this message at 20:21 on Jun 22, 2017 |
# ¿ Jun 22, 2017 20:18 |
|
People complain about the same thing in javascript all the time. It's just the standards-defined behavior we're stuck with. As for the why, I think it boils down to the limitation of the hardware and software available at the time the standard was created. See this SO answer and the related comments.
|
# ¿ Jul 4, 2017 16:22 |
|
Mirthless posted:I'm using classes already though maybe incorrectly? In case you don't realize this, this is going to give all your Fighter instances the same stats, but different stats each time you run your program. The randint is just going to be added to those class attributes when the file is parsed on load, not each time the class is instantiated. Python code:
code:
|
# ¿ Jul 5, 2017 17:43 |
|
Boris Galerkin posted:In PyCharm how do I tell it to do the "optimize imports" thing but also to ignore specific lines? Basically I need to keep I seemed to recall seeing an issue on their issue tracker, and a quick search revealed my memory was correct! So, to answer your question: you vote for this issue. As an aside, generally I've found JetBrains to be fairly responsive to their issue tracker if you write good issues.
|
# ¿ Jul 6, 2017 17:14 |
|
Loezi posted:What's the easiest library to make a GUI with, given that I require hassle-free licensing (which rules out PyQt)? Keep in mind that most answers to these type of questions will come from people who have only seriously used one or two of the options. I've used 4 different options on pretty large applications and I'd say you'll have the easiest time with HTML/CSS/JS + some python web framework and a browser. However, every solution has its pros and cons and its hard to say which is actually easiest when there's so many variables from your experience level to the type of application you're developing to your ability to handle context switching between paradigms.
|
# ¿ Jul 30, 2017 16:28 |
|
Electron will work with python 3. Electron doesn't care what language you use on the "backend". Also there is a browser starter-upper thing in the standard library, IIRC. I just can't remember what it's called and I'm on my phone right now and don't feel like going through the effort. Thermopyle fucked around with this message at 16:41 on Jul 31, 2017 |
# ¿ Jul 31, 2017 16:39 |
|
Depending upon what your crawler is actually doing, you should probably use asyncio or greenlet instead of threads/multiprocessing anyway. I/O bound tasks work great with async.
|
# ¿ Aug 1, 2017 15:40 |
|
Nippashish posted:Is it possible to use async without making the code async "all the way down"? Maybe I'm just dense, but afaict anything that blocks in a non-async way (read: all legacy code ever) ends up blocking the world? In general, there's two ways that async code gets blocked. 1. You use non-async-aware IO code or 2. you become CPU bound. In either case you're all blocked up. If your code is substantially CPU bound, async is the wrong tool. On the other hand, if you're dealing with non-async-aware code you have several options. The absolute easiest is to use eventlet or greenlet which will patch the standard library at runtime to make all the I/O functions (like the socket library and thus http, urllib, requests, etc) use yielding versions. This will make your legacy python code automatically async-friendly. Another option is that if the right subset of your code is CPU bound or is not monkey-patch-able to make it async friendly is to spin up another process or thread to run that code in. Either way, if your code is substantially bound up with IO operations async can make it faster than threads or processes.
|
# ¿ Aug 1, 2017 20:40 |
|
You have to be careful though. It seems like magic that you can make your code async-ready automatically, but its easy to have CPU-bound code hidden amongst your legacy code and then after using the monkeypatching abilities of greenlet you think "this poo poo don't work gently caress you".
|
# ¿ Aug 1, 2017 20:57 |
|
Newf posted:Do you know (or care to share) any os projects with a python / electron setup? I've only glanced at electron, and then only with JS/TS projects. Haven't seen used as a UI layer with other languages. Theres a few around. I've done a fairly large project used internally by a company in their line of business so I can't share that. The one that comes to mind is called Rodeo. Google around for that. I haven't used it, but an alternative to Electron is something called cefpython...someone might want to look in to that.
|
# ¿ Aug 2, 2017 00:17 |
|
fletcher posted:How do I avoid having import statements below my logging config? My IDE tells me all the import statements should be at the top, but I need to set the logging config before some of these libraries are loaded. This is for a little CLI python app. Your IDE doesn't always know where import statements should go. Style guides are just guides.
|
# ¿ Aug 4, 2017 00:28 |
|
Say i have a routine that searches for and gets a thing. You can search for a thing via a regex, via an int, or via a tuple. Which of the following do you prefer? one Python code:
Python code:
Python code:
|
# ¿ Aug 5, 2017 19:00 |
|
I don't know why I didn't even think of using a predicate since most of my time is spent doing JS nowadays and thats a very common pattern there. Thanks for reminding me. Now I accept a predicate, or build a predicate for you if you provide the other types I mentioned above.
|
# ¿ Aug 6, 2017 00:16 |
|
Well gently caress, how did I not remember single dispatch? I'm happy enough with what I've got going now, but I certainly agree with PEP-443 where they introduce single dispatch where it says: quote:In addition, it is currently a common anti-pattern for Python code to inspect the types of received arguments, in order to decide what to do with the objects. Thats exactly the reason I always get the heebie-jeebies when I see a function body starting out with a bunch of isinstance checks. Thermopyle fucked around with this message at 19:02 on Aug 6, 2017 |
# ¿ Aug 6, 2017 18:59 |
|
outlier posted:A Flask question, maybe just a style one. Cache the database results somewhere (memcache). Update the cached values when new news item posted and every X period of time depending on how accurate you want the number of records to be.
|
# ¿ Aug 7, 2017 16:02 |
|
Probably, most people who need to read csv's don't need pandas, but it certainly seems like this person could use it.
|
# ¿ Aug 14, 2017 20:38 |
|
I've not wrapped my head around how this UE4 python thing works (in fact, I don't anything at all about UE4), but what about using modules as singletons?
|
# ¿ Aug 16, 2017 18:21 |
|
(You should use requests, not urllib3...but probably not worth switching since you've already done this.) 1. Parsing HTML tables is usually weird and gross, so I also usually don't really like the code that does it either. I'm too lazy to actually look at the page and figure out if you're doing it the best. 2. What do you want on the web exactly? Each time you visit a url it should run your code to fetch the data? Do you want to run it once a day and then store the results for display any time during the day? "Web service" implies you want to serve it in a machine readable way like JSON...is that what you want or are you wanting to display a HTML site with your data?
|
# ¿ Aug 26, 2017 21:15 |
|
same
|
# ¿ Aug 28, 2017 20:36 |
|
chutwig posted:If Python had enforcement on type hints and a static binary generator that wrapped up cx_freeze/py2exe/py2app into pythonc, would Go have ever left the launchpad? This isn't what you're talking about, but you reminded me that I read about it earlier today. quote:Nuitka is a Python compiler.
|
# ¿ Aug 28, 2017 22:43 |
|
Linear Zoetrope posted:Do you need to touch the reference counters or GIL if you want to spawn a bunch of threads from the C side, call Python functions that return PyObjects, and forward the PyObjects between the threads? To be clear, only one thread will touch a given PyObject * at a time. It's been awhile since I did this, but I'm fairly sure the answer is "no".
|
# ¿ Sep 3, 2017 20:39 |
|
StackOverflow thinks python is the fastest-growing language. Started to outpace all other languages in 2012 in high-income countries and 2014 in lower-income countries.
|
# ¿ Sep 6, 2017 20:15 |
|
NtotheTC posted:So my new project is sufficiently out of the quagmires of legacy code that I get to start using the latest versions of everything- including python3.6 over python2.7. It's perhaps a bit shameful that I've done virtually no commercial coding with python3, but I'm wondering if there's a list of the biggest changes I'll need to wrap my head around? f_string_literals and type hinting are two that I've been made aware of but I'm sure there's more out there. I just came across this article today: http://www.b-list.org/weblog/2017/sep/05/how-python-does-unicode/
|
# ¿ Sep 7, 2017 18:10 |
|
As a followup to that thing I posted from stackoverflow about how Python is the fastest growing language, they delve into why its the fastest growing language. its data science
|
# ¿ Sep 15, 2017 03:35 |
|
Boris Galerkin posted:Is there a conda equivalent to "pip download -r requirements.txt"? Just use pip inside your conda environment.
|
# ¿ Sep 15, 2017 13:40 |
|
You'll find that pure functions lead to better programs. Generally, do Python code:
Python code:
|
# ¿ Sep 15, 2017 22:18 |
|
I disagree that that is the best way if only because it's a little esoteric, whereas reversed is very explicit. I mean, I'm not going to puke when I see the slicing syntax, but it's going to be my third choice.
|
# ¿ Sep 16, 2017 00:21 |
|
Slimchandi posted:I'm learning more about how to structure a program having written mostly scripts up until now. Please can someone check my understanding and point me towards useful resources if I'm fundamentally wrong. Anything that is accessible in your "if main" code is also accessible to whatever imports your "separate" module. If you import func1 from separate then your func1 still has access to everything in your separate module, but code in your module that imported separate does not have access to anything but func1.
|
# ¿ Sep 19, 2017 20:27 |
|
|
# ¿ May 15, 2024 12:51 |
|
The easiest way to modify it to do what you want is to add this between line 30 and 31:Python code:
|
# ¿ Sep 20, 2017 18:16 |