Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
The Gripper
Sep 14, 2004
i am winner
Still waiting on my Jetbrains keys :(

Adbot
ADBOT LOVES YOU

Modern Pragmatist
Aug 20, 2008

The Gripper posted:

Still waiting on my Jetbrains keys :(

I actually got an open source key from them a while back and it took a few days between when they said they approved the license and out my info in the queue and when I finally received the license email.

I actually emailed them to check up on it and they said that their license notifications tend to be really slow. Not sure why but hopefully that explains it.

onionradish
Jul 6, 2006

That's spicy.
JetBrains' sale blew up their whole process. And of course it's kind of a cascading mess with some people not having a record of the purchase from the processor, others having ordered multiple times when it wasn't clear whether the order was going through. So now in addition to whatever keygen queue backlog they had from the sale, they've also got a backlog of inquiries to sales@jetbrains.com to work through.

The conflicting communication is kind of the issue. One source says 48 hours, one says within 5-6 hours. I don't mind a couple days waiting for a key, as long as I know to expect that. I don't like needing to play Internet Detective to find Twitter and blog posts to figure out what I'm supposed to do: just chill for a couple days? contact sales?

http://blog.jetbrains.com/blog/2012/12/21/to-all-who-placed-an-order-during-the-end-of-the-world-sale/

https://twitter.com/jetbrains

In the end, after reading comments on the blog from people claiming they got their keys "no problem," I joined the herd and sent my info their sales address too. I really like PyCharm and was going to buy it anyway in January, so I'm thrilled to pick it up for $25.

edit: The email response from sales is: "If your license doesn't reach you by Monday, please let us know and we'll make sure to help you out."

onionradish fucked around with this message at 15:40 on Dec 22, 2012

The Gripper
Sep 14, 2004
i am winner
Yeah I'm not too fussed, for the price it's worth waiting and I understand that they got totally smashed by the quantity of orders in that short period.

It's a good example of how a non-critical failure (failure to deliver mail) can become critical because of user behavior. There's not a lot of ways to protect against that without ensuring no email fails, which is hard to do and still inform the customer of the failure.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Wonder if the massive response to their sale will lead them to reconsider their pricing structure. I realize that some part of the bump in sales is due to the oh-gee-its-on-sale factor, but in their position id really be thinking about whether my pricing was too high.

The Gripper
Sep 14, 2004
i am winner

Thermopyle posted:

Wonder if the massive response to their sale will lead them to reconsider their pricing structure. I realize that some part of the bump in sales is due to the oh-gee-its-on-sale factor, but in their position id really be thinking about whether my pricing was too high.
Right now their pricing for things like PyCharm and ReSharper is too high if you're a user that might not be using it immediately on profitable projects, whereas 75% off puts it perfectly in the price range for those users (the "ehhh it's useful, but I might do enough to make it worth it" clientèle).

I think the sale captured that on-the-fence demographic but would probably separate the commercial and personal prices too much, so honestly I think they'll congratulate whoever thought the sale up for bringing in new users and keep things as they are (until the next sale).

But who cares, you all bought it at 75% off right?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The Gripper posted:

Right now their pricing for things like PyCharm and ReSharper is too high if you're a user that might not be using it immediately on profitable projects, whereas 75% off puts it perfectly in the price range for those users (the "ehhh it's useful, but I might do enough to make it worth it" clientèle).

I think the sale captured that on-the-fence demographic but would probably separate the commercial and personal prices too much, so honestly I think they'll congratulate whoever thought the sale up for bringing in new users and keep things as they are (until the next sale).

But who cares, you all bought it at 75% off right?

Plausible.

In other news, if you're running PyCharm on Ubuntu and all the UI fonts are bold, you have to run sudo apt-get remove fonts-unfonts-core.

Hanpan
Dec 5, 2004

I have a little data mining stack that I use to collect bits and bobs. Since it's only simple I use supervisord to monitor and keep my python processes doing their thing.

I have some new scripts that need to run periodically, once an hour, once a day etc. Supervisor seems to be really backwards at starting process at intervals so I've been looking into alternatives. Obviously, cron would be ideal for this but does require a crontab, something I've tried to avoid because it makes the app less encapsulated.

Does anyone have any neat ways of running python scripts at set intervals?

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

Hanpan posted:

Does anyone have any neat ways of running python scripts at set intervals?

I do it with Jenkins CI, but that might be a bit overkill for your needs.

tef
May 30, 2004

-> some l-system crap ->
use cron, or re-implement cron :3:

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Hanpan posted:

I have some new scripts that need to run periodically, once an hour, once a day etc. Supervisor seems to be really backwards at starting process at intervals so I've been looking into alternatives. Obviously, cron would be ideal for this but does require a crontab, something I've tried to avoid because it makes the app less encapsulated.
Just have the app drop something in cron.hourly or cron.d or whatever. This is a problem that's been solved with package management for decades.

Daynab
Aug 5, 2008

Really dumb string question - how do I create an if condition for split() that would detect if the substring I want to split doesn't exist?

For context and clarification: I'm using split() to read text between a starting string and an ending string and then putting that text elsewhere, something like this.

** THING 1 STARTS HERE **
stuff
stuff
stuff
** THING 1 ENDS HERE **

** THING 2 STARTS HERE **

The problem I'm running into is that if the thing 2 start doesn't exist and I have an automatic split for it, it will just give me the whole thing and put it where it doesn't belong.

edit: also accepting any more elegant ways to do this that aren't regex. I need to learn regex.
edit2: looks like I can check with find() if the start string exists and then do that operation if it does, still accepting ideas though.

Daynab fucked around with this message at 07:16 on Dec 23, 2012

Jewel
May 2, 2009

Daynab posted:

Really dumb string question - how do I create an if condition for split() that would detect if the substring I want to split doesn't exist?

For context and clarification: I'm using split() to read text between a starting string and an ending string and then putting that text elsewhere, something like this.

** THING 1 STARTS HERE **
stuff
stuff
stuff
** THING 1 ENDS HERE **

** THING 2 STARTS HERE **

The problem I'm running into is that if the thing 2 start doesn't exist, it will just give me the whole thing.

edit: also accepting any more elegant ways to do this that aren't regex. I need to learn regex.

With regex I'd just say "startstring(.{1,}?)endstring" and use group 1 (group 0 is all, group 1 is between the brackets) to get the text (also use the flag DOTALL if it's multiple lines).

tef
May 30, 2004

-> some l-system crap ->

Daynab posted:

Really dumb string question - how do I create an if condition for split() that would detect if the substring I want to split doesn't exist?

code:
if substring in string:
    foo = string.split(substring)
else:
    foo = string, ""

quote:

For context and clarification: I'm using split() to read text between a starting string and an ending string and then putting that text elsewhere, something like this.

The problem I'm running into is that if the thing 2 start doesn't exist and I have an automatic split for it, it will just give me the whole thing and put it where it doesn't belong.

edit: also accepting any more elegant ways to do this that aren't regex. I need to learn regex.

You might be better dealing with your input line at a time:

code:
line = foo.readline()
in_section = False
while line:
    if not in_section:
         if line == 'start':
             in_section = True
    else:
        if line == 'stop':
		in_section = False
	else:
		# do stuff with the current line, like section.append(..)
    line = foo.readline()
You will have to add some code to work out what section you're in, but hopefully it should be obvious

quote:

edit2: looks like I can check with find() if the start string exists and then do that operation if it does, still accepting ideas though.

this works too.

Daynab
Aug 5, 2008

Thanks both. And yeah I always forget the super simple "if in" for some reason.

Met48
Mar 15, 2009
While the line-by-line solution is probably best, for the actual task of "split once if possible" string.partition is perfect:

code:
>>> "before split after".partition("split")
('before', 'split', 'after')
>>> "before split after".partition("not_in_string")
('before split after', '', '')
So you can do something like part, _, text = text.partition('**start line**') and just operate on part, then repeat until text is empty.

FoiledAgain
May 6, 2007

Daynab posted:

Really dumb string question - how do I create an if condition for split() that would detect if the substring I want to split doesn't exist?

For context and clarification: I'm using split() to read text between a starting string and an ending string and then putting that text elsewhere, something like this.

** THING 1 STARTS HERE **
stuff
stuff
stuff
** THING 1 ENDS HERE **

** THING 2 STARTS HERE **

The problem I'm running into is that if the thing 2 start doesn't exist and I have an automatic split for it, it will just give me the whole thing and put it where it doesn't belong.

edit: also accepting any more elegant ways to do this that aren't regex. I need to learn regex.
edit2: looks like I can check with find() if the start string exists and then do that operation if it does, still accepting ideas though.

I'm not completely sure I understand the question, but couldn't you just check if len(string.split(sep))>1? If it is, then thing 2 exists, and if not then thing 2 doesn't exist.


edit: Wow, that was the slowest reply I ever typed. There are probably better answers above. Also, I guess this is kind of wasteful since you have to split twice.

FoiledAgain fucked around with this message at 09:43 on Dec 23, 2012

duck monster
Dec 15, 2004

Hanpan posted:

I have a little data mining stack that I use to collect bits and bobs. Since it's only simple I use supervisord to monitor and keep my python processes doing their thing.

I have some new scripts that need to run periodically, once an hour, once a day etc. Supervisor seems to be really backwards at starting process at intervals so I've been looking into alternatives. Obviously, cron would be ideal for this but does require a crontab, something I've tried to avoid because it makes the app less encapsulated.

Does anyone have any neat ways of running python scripts at set intervals?

If its django theres a couple of great cron modules for that , that put it all into a nicely tweakable admin interface.

Daynab
Aug 5, 2008

For what it's worth I finally received my Jetbrains license this morning, so as long as you got some type of email from them before I wouldn't worry.

Bunny Cuddlin
Dec 12, 2004
Yea, I got mine early this morning

Analytic Engine
May 18, 2009

not the analytical engine
I tried to make an empty project in PyCharm but got these errors. Googling gave me the idea that it's not important to get this resolved, but I'm still curious.

PyCharm's Skeleton Generation Problems popup posted:

Failed modules
Python 2.7.2 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python)
Nav
_Qt
_Win
dl
imageop
numpy.core._sort
scipy.sparse.linalg.dsolve.umfpack.__umfpack
Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available.

Daynab
Aug 5, 2008

So uh, what is the common way to distribute applications and create executables for windows with them?

I feel like I'm missing something because I'm only finding stuff like py2exe which hasn't been updated in like 4 years, or pyinstaller which doesn't support 2.6/2.7 without workarounds on windows.

Is there seriously no easy way to distribute your programs for a language this popular?

As I said, I'm probably missing something big.

OnceIWasAnOstrich
Jul 22, 2006

cx_freeze does what you want and is also cross platform an was last updated about a month ago.

Lurchington
Jan 2, 2003

Forums Dragoon
py2exe may not have been updated, but it still works fine. I distributed something at work with it just a few weeks ago. I'll check out cx_freeze though.

Jose Cuervo
Aug 25, 2004
I have a list of strings in Python. When iterating over list, is there a way to print the next 'word' in the list? The code would look something like this:
Python code:
wordList= ['apple', 'banana', 'candle', 'dog']
for word in wordList:
  if word == 'banana'
    print *the next word in the list, candle*
So if my list is ['apple', 'banana', 'candle', 'dog'], I would like to be able to print out 'candle' when the iterator word was 'banana'.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Python code:
wordList= ['apple', 'banana', 'candle', 'dog']
for i, word in enumerate(wordList):
  if word == 'banana':
    print wordList[i+1]
But obviously you're going to need to be mindful of exceptions if you hit the end of the list

Jose Cuervo
Aug 25, 2004

MeramJert posted:

Python code:
wordList= ['apple', 'banana', 'candle', 'dog']
for i, word in enumerate(wordList):
  if word == 'banana':
    print wordList[i+1]
But obviously you're going to need to be mindful of exceptions if you hit the end of the list

Excellent. I completely forgot about 'enumerate'. Thanks for the help!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Jose Cuervo posted:

So if my list is ['apple', 'banana', 'candle', 'dog'], I would like to be able to print out 'candle' when the iterator word was 'banana'.

Why do you need the next word? Perhaps you want pairs?

Python code:
def find_pair(L, needle):
    for a, b in zip(L, L[1:]):
        if a == needle:
            return b

print find_pair(['apple', 'banana', 'candle', 'dog'], 'banana')
More about your problem would be appreciated.

Jewel
May 2, 2009

MeramJert posted:

Python code:
wordList= ['apple', 'banana', 'candle', 'dog']
for i, word in enumerate(wordList):
  if word == 'banana':
    print wordList[i+1]
But obviously you're going to need to be mindful of exceptions if you hit the end of the list

A better way to have to not deal with exceptions when doing stuff with "the next item" is subtract rather than add, and start from 1.

Rather than
Python code:
for i, word in enumerate(wordList):
	print word, wordList[i+1]

Output:
apple banana
banana candle
candle dog
dog

Traceback (most recent call last):
  File "<pyshell#6>", line 2, in <module>
    print word, wordList[i+1]
IndexError: list index out of range
You can use

Python code:
for i, word in enumerate(wordList[1:]):
	print wordList[i], word

Output:	
apple banana
banana candle
candle dog

The Gripper
Sep 14, 2004
i am winner
I'm liking that they added the dark theme from IntelliJ to PyCharm (in the latest EAP builds), I wasn's a huge fan of the original themes available.

It's a bit sucky that it runs like a sack of dicks on my netbook, but really who develops on a netbook anyway? (I keep SublimeText2 on there because it's super snappy once it's open and I don't do any major project work on it.)

edit; just realised in an old project I managed to do this because I switch between perl and python a lot:
Python code:
for item in c:
  if <condition>:
    next
  <rest of logic here>
Somehow the rest of the code managed to deal properly with next doing absolutely nothing without throwing an error, so now I have to check a bunch of other old snippets for this dumb mistake just in case :(

The Gripper fucked around with this message at 09:39 on Dec 26, 2012

Jose Cuervo
Aug 25, 2004

Suspicious Dish posted:

Why do you need the next word? Perhaps you want pairs?

Python code:
def find_pair(L, needle):
    for a, b in zip(L, L[1:]):
        if a == needle:
            return b

print find_pair(['apple', 'banana', 'candle', 'dog'], 'banana')
More about your problem would be appreciated.

I have a file where each line corresponds to data from a single simulation run. The data (separated by spaces) is composed of words and numbers. The following is an example of what a line would have (very condensed and shortened version). Although each line will definitely have OptimalFound, LowerB, and Lmax, there may be other keywords that do not appear on each line.

code:
1200 80 40 64 3 6 10 DATA OptimalFound 1 Alloc1 3 4 2 5 Alloc2 3 2 4 5 LowerB 234 Lmax 237 Time 45
I am trying to do some data analysis where all I need is the and for the first task all I want is the values that follow the LowerB and Lmax keywords. That is why I needed to access the next value once I had found the keyword.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Python code:
for line in lines:
    parsed = {}
    state = 'default'
    for word in line.split():
        if word.isnum():
            parsed.setdefault(state, []).append(int(word))
        else:
            state = word
Should give you a dict mapping words to a list of values.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The Gripper posted:

I'm liking that they added the dark theme from IntelliJ to PyCharm (in the latest EAP builds), I wasn's a huge fan of the original themes available.

Oh, nice I'll have to check that out.

I tried to copy the Monokai theme from Sublime Text 2 as closesly as possible into PyCharm...



...but it bothers me there's so much white everywhere else in the UI.

Thern
Aug 12, 2006

Say Hello To My Little Friend
Try the Color Ide plugin. It copies your color scheme to the other windows. Although it's not perfect, I find it suitable, as I get bugged by the same thing.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Thermopyle posted:

Oh, nice I'll have to check that out.

I tried to copy the Monokai theme from Sublime Text 2 as closesly as possible into PyCharm...



...but it bothers me there's so much white everywhere else in the UI.

Might want to be careful with that Currency class.

code:
In [1]: from currency import Currency

In [2]: c1 = Currency()

In [3]: c1.countries.append('USA')

In [4]: c2 = Currency()

In [5]: c2.countries.append('Canada')

In [6]: c1.countries
Out[6]: ['USA', 'Canada']

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Lysidas posted:

Might want to be careful with that Currency class.

code:
In [1]: from currency import Currency

In [2]: c1 = Currency()

In [3]: c1.countries.append('USA')

In [4]: c2 = Currency()

In [5]: c2.countries.append('Canada')

In [6]: c1.countries
Out[6]: ['USA', 'Canada']

Ahh, yes. Nice catch.

That's actually from the moneyed dependency of django-money and I was just checking it out to see how it works.

Didn't even notice the mutable default argument.

opt
Oct 10, 2007
So I'm in the process of learning python and just trying to put my unit tests in a different folder than my program source, however even after reading the documentation I still can't quite get it to work.
I get the following error
code:
ImportError: No module named rl.source.Tile
I have the __init__.py files in each folder and my import statement looks right to me but I don't know...Here is a screenshot of my import along with my folder structure.


It is hard to see but the __init__.py at the very bottom is in the rl directory.

Jewel
May 2, 2009

opt posted:

So I'm in the process of learning python and just trying to put my unit tests in a different folder than my program source, however even after reading the documentation I still can't quite get it to work.
I get the following error
code:
ImportError: No module named rl.source.Tile
I have the __init__.py files in each folder and my import statement looks right to me but I don't know...Here is a screenshot of my import along with my folder structure.


It is hard to see but the __init__.py at the very bottom is in the rl directory.

Then shouldn't it be import source.Tile, if it's already in rl?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
No, because you should always use absolute imports. You need to ensure that your PYTHONPATH is set correctly.

Adbot
ADBOT LOVES YOU

Red Mike
Jul 11, 2011
I suggest using something like nose for running your unit tests. It should set the PYTHONPATH itself, and find your tests itself without any issues when run from the base folder "rl".

  • Locked thread